DOMAINS

GORDON PLOTKIN Department of Computer Science

University of Edinburgh

CONTENTS

Notes to the TEX Edition and Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii

1. Complete Partial Orders and Continuous Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2. Products and Function Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21

3. Other Constructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32

4. The Category of CPOs Considered as a CPO Itself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44

5. Solving Recursive Domain Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

6. Algebraic Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59 Continuous Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Completion by Ideals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Function Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

7. Computability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Computability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Computable Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Least Fixed-Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Function Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Embeddings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 Direct Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 Algebras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

8. Nondeterminism and Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Discrete Powerdomains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 The Relational View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 The Egli-Milner Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 The Smyth Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Predicate Transformers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 General Powerdomains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 How to Order Subset of D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Denotational Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Synchronisation Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Communicating Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 General Powerdomains: The Plotkin Powerdomain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Finitely Generable Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101 How to Order Our Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Canonical Representatives and Scott-Compact Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 The Lawson Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 General Powerdomains: The Smyth Powerdomain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Duality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 The Vietoris Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114

NOTES TO THE TEX EDITION AND ACKNOWLEDGEMENTS

This is a TEX^{∗}-ed edition of the course notes “Domains” by Professor Gordon Plotkin and the copyright of this edition belongs to him^{+}.

This edition was prepared by Yugo Kashiwagi† and Hidetaka Kondoh‡ using Prof. Donald Knuth’s plain TEX with some macros (especially for the picture environment) from Dr. Leslie Lamport’s LaTEX macro package after some modifications for use in plain TEX and Prof. Michael Barr’s macro package for category theoretic diagrams. Misprints in the original notes were corrected without notices, and some notations were changed uniformly due to typographical difficulties imposed by TEX.

The editors of this edition wish to express their deepest thanks to Dr. Tatsuya Hagino for lending them his copy of the original Prof. Plotkin’s course notes so that they could photocopy it, without which the present edition could never be produced, and his memos in his copy were very helpful in correcting misprints. They also thank to Prof. Michael Barr for e-mailing one of them (HK) his diagram macro packages, which enable them to typeset many diagrams found in the present notes.

The present edition was typeset as carefully as possible. The editors, however, are afraid that there may be some misprints not appeared in the original course notes.

Therefore comments and information on misprints and/or typographical problems/advice are welcome. They are preferably notified by e-mail to one of the editors (HK‡).

June, 1992 HK

After the first version of this TEX edition was released, the editors have received more than 170 direct requests to this edition, and they have been very much encouraged by these so many responses. The editors wish to deeply thank to the readers for their encouragements. When the editors prepared the first version, regrettably however, they had no spell-checker available at hand, hence there remained so many misspellings in the first version. They sincerely apologise the readers as well as Prof. Plotkin for the low quality of the first version.

In the present second version many misspellings as well as several misprints in mathematical formulae are corrected. In this new version, the editors have changed a few typographical conventions in order to increase the typographical consistency, have changed the original spellings in the first version according to the direction of the original author, Prof. Plotkin, have recovered an original notation which seemed to be difficult for them to typeset in TEX due to their illiteracy about TEX when they prepared the first version of this TEX edition, and have made use of an AMS-font to get better output for a family of symbols appeared in Chapter 8.

First of all, the editors wish to express their deepest thanks to Prof. Plotkin for his warm encouragements and his generous permission to the distribution of this TEX edition. The editors also wish to acknowledge (in alphabetical order) Yutaka Kikuchi at Tokyo Institute of Technology, Ralf Treinen at Univ. des Saarlandes, and David Wald at Massachusetts Institute of Technology for supporting ftp services of the TEX edition, which substantially decreased the editors’ efforts required for the distribution, and without their supports, the number of people accessible to this TEX edition would be significantly less than as it is, and David Wald also have repositioned the dvi file of the TEX edition in A4 size so that it is appropriate for US letter-size papers.

Last but not least, the editors wish to sincerely thank Professor John C. Mitchell, who informed them that there remained many misspellings in the first version and strongly advised them to use some spell checker, and also have kindly spent his important time to pass the TeX source files to a spell-checker and told them the results with the original author’s comments and directions concerning misspellings and several original (British) spellings in the notes, and Marcelo Fiore at Univ. of Edinburgh and Daisuke Suzuki at Univ. of Tokyo for notifying them of many misprints.

November, 1992 HK

∗ TEX is a trademark of the American Mathematical Society.

+ \begin{matrix}c \\ ◯ \end{matrix} Gordon D. Plotkin, 1983.

  † kasiwagi@hcrlgw.hitachi.co.jp
  ‡ kondoh@harl.hitachi.co.jp

1. Complete Partial Orders and Continuous Functions

It is possible to carry out a good deal of denotational semantics without invoking any mathematical apparatus other than sets, simple constructions on them and ordinary functions over them. We illustrate this with an extended example and then see what problems arise to force us out of the comfortable world of sets. Please note that we are assuming a standard approach to denotational semantics in which we ascribe meanings to syntactical objects, following the syntactic structure of these objects. The meanings are elements of some abstract domain, which is often a set. In computer science, however, it seems that sets are not enough. First, here is a simple imperative language (or, rather, a family of such languages) called Imp.

\underline{Syntax}. There are three sets of syntactic items.

1. BExp — a given set of boolean expressions, ranged over by the metavariable, b.

2. Act — a given set of primitive actions, ranged over by the metavariable, a.

3. Stat — a set of statements, ranged over by the metavariable, s and given in terms of BExp and Act

by the grammar:

s ::= a | dummy | (s; s) | (if b then s else s).

\underline{Semantic Domains}. There are three semantic domains used to provide denotations for syntactic items. 1. T — the set, {tt, ff }, of truth-values, ranged over by t.

2. S — a given set of states, ranged over by σ.

3. C = (S → S) — the set of commands, ranged over by θ.

\underline{Denotations}. There are three denotational functions, one for each syntactic class.

1. B: BExp → (S → T) — a given denotational function.

2. A: Act → C — a given denotational function.

3. C: Stat → S — defined by structural induction on statements by:

C[[a]](σ) = A[[a]](σ); (i) C[[dummy]](σ) = σ; (ii) C[[s_{1}; s_{2}]](σ) = C[[s_{2}]](C[[s_{1}]](σ)); (iii) (iv) C[[(if b then s_{1} else s_{2})]](σ) = Cond(B[[b]](σ), C[[s_{1}]](σ), C[[s_{2}]](σ))

where the function Cond: T × S × S → S is given by:

Cond(t, σ, σ′) = \{ \begin{matrix}σ & (if t = tt), \\ σ′ & (if t = ff ). \end{matrix}

The reader will note how these definitions follow his computational intuitions. It is not our intention to follow up these connections in detail here, although the connection between denotational and operational semantics is of course an important topic. However, we shall rely heavily on our computational intuitions when formulating semantics. It could even be argued that we should concentrate first on an analysis of computability and then describe (or even design) programming languages accordingly. This is advice we will not take: existing languages are used to develop our ideas on computability in the first instance and so we begin with them.

The next example is a simple expressional language (or rather family of such languages) called Dec.

\underline{Syntax}.

1. Id is a given set of identifiers ranged over by x.

2. Fun_{n} is a given set of function symbols ranged over by f_{n} (n = 1, 2, …).

3. Op_{n} is a given set of operations ranged over by o_{n} (n = 1, 2, …).

4. BExp is a given set of boolean expressions ranged over by b.

5. Exp is a set of expressions ranged over by e and given by:

e ::= x | o_{0}() | o_{1}(e) | o_{2}(e, e) | ⋯ | (if b then e else e) | (let x be e in e) | (let f_{1}(x) be e in e) | · · · .

\underline{Semantic Domains}.

1. V is a given set of values ranged over by v.

2. IEnv = V^{Id} is the set of identifier environments ranged over by ρ.

3. FEnv = _{∏n≥1}(V^{n} → V)^{Fun^{n}} is the set of function environments, ranged over by φ.

\underline{Denotations}.

1. I_{n}: Op_{n} → (V^{n} → V) is given.

2. B: BExp → (IEnv × FEnv → T) is given.

3. E: Exp → (IEnv × FEnv → V) is given by structural induction:

E[[x]](ρ, φ) = ρ[[x]]; (i) E[[o_{n}(e_{1}, …, e_{n})]](ρ, φ) = I_{n}[[o_{n}]](E[[e_{1}]](ρ, φ), …, E[[e_{n}]](ρ, φ)); (ii)_{n} (iii) E[[(if b then e_{1} else e_{2})]](ρ, φ) = Cond(B[[b]](ρ, φ), E[[e_{1}]](ρ, φ), E[[e_{2}]](ρ, φ)); (iv) E[[(let x be e_{1} in e_{2})]](ρ, φ) = E[[e_{2}]](ρ[E[[e_{1}]](ρ, φ)/x], φ)

where · [·/·]: IEnv × V × Id → IEnv is given by:

ρ[v/x][[x′]] = \{ \begin{matrix}v & (if x = x′), \\ ρ[[x′]] & (if x ≠ x′); \end{matrix}

E[[let f_{n}(x_{1}, …, x_{n}) be e_{1} in e_{2}]](ρ, φ) =

(v)_{n}

E[[e_{2}]](ρ, φ[λv_{1} ∈ V, …, v_{n} ∈ V.E[[e_{1}]](ρ[v_{1}/x_{1}] ⋯ [v_{n}/x_{n}], φ)/f_{n}]) where · [·/·]: FEnv × (V^{n} → V) × Fun_{n} → FEnv is given by:

(φ[g/f_{n}])_{n′}[[f′_{n′}]] = \{ \begin{matrix}g & (if n′ = n and f′_{n′} = f_{n}), \\ φ_{n′}[[f′_{n′}]] & (otherwise). \end{matrix}

Both languages can be put together by giving Act by the little grammar: a ::= (x := e), then giving S as IEnv × FEnv and giving A by:

A[[x := e]](ρ, φ) = (ρ[E[[e]](ρ, φ)/x], φ).

Notice the various methods we have used. First we pick out various sets either as being somehow given (parameters) or given by some syntactic means (and we are not worrying about details of syntax) or given by constructions such as Cartesian product, or powers, or sets of functions. Next we then pick out some denotational functions over these sets either as given or else as defined by ordinary mathematical expression (if you allow the typed λ-calculus). When we use more complicated objects than sets, we will have to consider these methods anew.

To see that sets are not enough and that instead we need “partial” or “incomplete” entities as well as the usual “total” ones, suppose we added a recursive declaration facility to Dec as for example:

e ::= (letrec f(x) be e in e).

So for example if V = N, the set of integers, and Op, includes the successor function, (· + 1) then the intention of the expression letrec f(x) be f(x) + 1 in f(0) is to declare f to be a function g: N → N such that g(n) = g(n) + 1 for all integers n and then to give as result g(0). (We feel free to use infix and other notations rather than the strict function applications considered above.) However there is no such function as g and computational intuition suggests that the expression does not terminate and indeed after such a declaration any expression of the form f(e) will not terminate. So we expect that the value of the expression is undefined and we will have to use partial functions on the integers.

Again iteration will, like recursion, introduce non-termination. Suppose we extend Imp by adding the following clause to the definition of Stat:

s ::= (while b do n).

Then we expect the meaning of while b do s to be the same as that of

if b then s; (while b do s) else dummy.

So if this meaning is θ and that of b is p: S → T and that of s is θ′: S → S we expect that:

θ(σ) = Cond(p(σ), θ(θ′(σ)), σ)  (1)

and if, for example b is true, the constantly true Boolean expression, and s is dummy then we have:

θ(σ) = θ(σ)

and θ can be any function at all; but again computational intuition suggests it ought to be always undefined.

As is well-known, Scott introduced an element, ⊥, into the value domain, V, rather than worrying about partial functions and undefined results: to coin a phrase, he objectifies (some of) the metalanguage. This is particularly appropriate as it is possible for a subexpression to be undefined but for the whole expression to have a value, as in:

e = (letrec f(x) be f(x) + 1 in (let g(x) be 0 in g(f(0))))

which under Algol’s copy rule (call-by-name) has value 0 although f(0) would have been undefined. So we want to consider partiality in the domain as well as the codomain. So in the integer example we will use N_{⊥} ( =^{def}N ∪ {⊥}) and define ⊥ + 1 = ⊥ in accord with computational intuition and then the equation g(n) = g(n) + 1 has the (unique) solution g(n) = ⊥. But having introduced ⊥ we cannot allow arbitrary functions w: N_{⊥} → N_{⊥} as then we would just get the same problems over again. Once more, computational intuition comes to the rescue and we expect that if w(⊥) ≠ ⊥ then w(⊥) = w(n) for all integers, n. This can be put much better: since ⊥ is undefined it is less defined than anything else and we introduce a partial order, ⊑, into N_{⊥} by:

x ⊑ y =^{def} (x = ⊥) ∨ (x = y).

Then the condition on w is just that it is monotonic i.e. that if x ⊑ y then w(x) ⊑ w(y). Here is a picture of N_{⊥}:

[figure: 0; 1; 2; ⋯; n; ⋯; ⋯; ⋯; ⊥]

Figure I: The integer domain, N_{⊥}.

Similarly we would introduce S_{⊥} and then expect that θ(σ) = ⊥, always; we also introduce T_{⊥} which looks like:

[figure: tt; ff; ⊥]

Figure II: The truth-value domain, T_{⊥}.

These simple partial orders are called flat or discrete being characterised by the fact that if x ⊑ y ⊑ z then x = y or y = z. More complicated ones arise if we consider functions of several arguments such as Cond: T_{⊥} × S_{⊥} × S_{⊥} → S_{⊥}. Again computational experience suggests that Cond is to be defined by: Cond(⊥, σ, σ′) = ⊥, Cond(tt, σ, σ′) = σ and Cond(ff , σ, σ′) = σ′. So we expect that Cond — and all other computable functions of several arguments — will be monotonic in each of their arguments. We can rephrase this by defining the partial order on the Cartesian product to be the coordinatewise one:

⟨t, σ_{0}, σ_{1}⟩ ⊑ ⟨t′, σ′_{0}, σ′_{1}⟩ =^{def} (t ⊑ t′) ∧ (σ_{0} ⊑ σ′_{0}) ∧ (σ_{1} ⊑ σ′_{1})

and then noting that monotonicity in each argument is exactly monotonicity on the newly defined partial order. Here is an “aerial” picture of T_{⊥} × T_{⊥} which shows that the orders are no longer flat:

[figure: ⟨ff , ff ⟩; ⟨tt, ff ⟩; ⟨ff , tt⟩; ⟨tt, tt⟩; ⟨⊥, ff ⟩; ⟨⊥, ⊥⟩; ⟨⊥, tt⟩; ⟨ff , ⊥⟩; ⟨tt, ⊥⟩]

Figure III.

Thus we are led to the general idea of considering our domains to be partial orders rather than sets: the relation x ⊑ y means that the abstract object, x, viewed as the result of a computation (or more generally when involved in one) contains less information than y does. This general idea makes it reasonably clear that ⊑ is a partial order: reflexivity and transitivity are obvious and the point of antisymmetry is that if two elements contain exactly the same amount of information then they have the same uses and cannot be told apart — so we identify them. (It does not make much difference to the theory if we drop antisymmetry.) What is more there is always a least element, ⊥, which corresponds to no information at all. So we have the following thesis (axiom) for all domains where we will take our denotations to lie:

Thesis 1. All domains are partial orders with a least element.

Our experience with functions now suggests a thesis about the computable functions over domains:

Thesis 2. All computable functions are monotonic.

This is the reasonable requirement that the amount of information in the output of a function grows as we increase the amount of information in the input.

Of course the above discussion is not a knockdown argument and many other structures than partial orders might fit the bill just as well. Let us look for further examples. Returning to equation (1) we see that it can be rewritten as:

θ = F (θ)

where the second-order functional, F: (S_{⊥} →_{M} S_{⊥}) → (S_{⊥} →_{M} S_{⊥}) is defined by:

F (θ)(σ) = Cond(p(σ), θ(θ′(σ)), σ).

Here S_{⊥}→_{M}S_{⊥} is the set of all monotonic functions from S_{⊥} to S_{⊥}. Similarly recursive function declarations can be read as needing the fixed-point of a second-order functional, of a slightly different type. Now arbitrary functionals do not always have fixed-points and we return again to our computational intuitions. If F (θ)(σ) is defined (σ ∈ S) then in the corresponding computation finitely many (one!) values of θ will be needed (namely the value at θ′(σ)). So if we replace θ by another function \overline{θ} which always returns a result with more information, for any given argument, F (\overline{θ})(σ) will be defined too, and have the same value. This observation is just that F is monotonic, if we define the natural partial order on S →_{M} S by:

θ ⊑ \overline{θ} ≡ ∀σ ∈ S_{⊥}.θ(σ) ⊑ \overline{θ}(σ).

So we have another example, S_{⊥} →_{M} S_{⊥} of a partial order and another example, F: (S_{⊥} →_{M} S_{⊥})→_{M} (S_{⊥} →_{M} S_{⊥}) of a monotonic function. However we have now hit a second obstacle: not all monotonic functions have fixed-points. The reader is invited to follow out the corresponding considerations on recursive function declarations where he will encounter exactly the same difficulty.

Now while S_{⊥} is a simple partial order, (S_{⊥} →_{M} S_{⊥}) is not, as it contains nontrivial countably infinite increasing chains if S is infinite. All these chains have least upper bounds (lubs) defined pointwise by: (_{⨆n} θ_{n})(σ) = _{⨆n} θ_{n}(σ). Furthermore F preserves the lubs of such increasing chains. Let ⟨θ_{n}⟩_{n∈ω} be an increasing chain in (S_{⊥} →_{M} S_{⊥}). Then F (_{⨆n} θ_{n})(σ) = σ′ where σ and σ′ are in S. Now the value of F (_{⨆n} θ_{n})(σ) depends, as remarked above, on finitely many values of (_{⨆n} θ_{n}) which therefore must also be given by one of the θ_{n} and then F (θ_{n})(σ) = σ′ for that θ_{n} showing (_{⨆n} F (θ_{n}))(σ) = σ′. Thus we have proved the reverse inclusion (the other cases are trivial), albeit using a rather informal argument.

These facts make it easy to show that F has a fixed-point. For the sequence ⟨F^{n}(⊥)⟩_{n∈ω} is increasing as is easily shown by induction using the monotonicity of F. Let its lub be fix_{F}. Then:

F (fix_{F}) = F (⨆_{n} F^{n}(⊥)) = ⨆_{n} F^{n+1}(⊥) = fix_{F} .

As is well-known, fix_{F} is the least fixed-point of F for if θ is any other one one easily shows by induction that F^{n}(⊥) ⊑ θ. Intuitively this minimality corresponds to the computational situation where we only expect θ to be defined when that can be proved — forced to be true by virtue of the computation rules. Indeed let us consider the iterates, F^{n}(⊥). Writing them using the definition of F we find:

F^{0}(⊥)(σ) = ⊥,
F^{1}(⊥)(σ) = Cond(p(σ), ⊥, σ),
F^{2}(⊥)(σ) = Cond(p(σ), Cond(p(θ′(σ)), ⊥, θ′(σ)), σ),
F^{3}(⊥)(σ) = Cond(p(σ), Cond(p(θ′(σ)), Cond(p(θ′(θ′(σ))), ⊥, θ′(θ′(σ))), θ′(σ)), σ).

So F^{n}(⊥) corresponds to going around the loop up to n times at most and so it does seem that fix_{F} is the right fixed-point to choose. Essentially the same considerations apply to recursive declaration of functions.

All this suggests that we ought to consider domains which are partial orders with a least element which have lubs of increasing ω-chains; these partial orders are called complete partial orders (cpos):

Thesis 3. Every domain is a cpo.

What is more we ought to consider only these monotonic functions between cpos which preserve the lubs of increasing ω-chains; these functions are called continuous functions:

Thesis 4. Every computable function is continuous.

It turns out that we can do a great deal just with these two simple notions of cpos and of the continuous functions between them. We study them both together as a category:

Definition 1. The category, CPO has as objects the cpos and as morphisms the continuous functions between them. Composition of morphisms is ordinary function composition.

One easily checks that the identity function, id_{D}: D→D is continuous and that the composition D →^{f} E →^{g} F of two continuous functions is continuous, showing that CPO is indeed a category.

Note that all flat partial orders are cpos (as is any partial order, such as T_{⊥} × T_{⊥}, with a least element which only has eventually constant increasing ω-chains); further all monotonic functions over such partial orders are continuous.

The above considerations on fixed-point are quite general. Let D →^{f} D be a continuous function. A prefixed-point of f is an element d of D such that f(d) ⊑ d.

Theorem 1 The Fixed-point Theorem. Let D be a cpo and let f: D → D be a continuous function. Then fix_{f} =^{def} _{⨆n} f^{n}(⊥_{D}) is the least prefixed-point of f. Proof. This is a straightforward generalisation of the particular case considered in the text and is left to the reader.

The applications of this theorem are so widespread and important in the present approach to the denotational semantics of programming languages, that it is sometimes called the fixed-point approach. Let us now consider cpos and continuous functions at the general level of information content, before giving further examples. In a cpo D, the lub, _{⨆D} d_{n} of an increasing chain, ⟨d_{n}⟩_{n∈ω} of elements of D is just all the information in the d_{n}. To make it feasible that such lubs exist we consider a certain idea of finite information which is implicit in some of the above discussion, and which will be studied more thoroughly in the chapter on algebraicity.

We suppose that some elements in D are finite, that is, contain only a finite amount of information, while the others are infinite. For example in this sense every element of N_{⊥} (or any other flat cpo) is finite while the finite elements of, say, N_{⊥} →_{M} T_{⊥} are those monotonic functions which have value ⊥ almost everywhere. Now consider the following axioms on finiteness for a partial order, D, with least element ⊥.

1. Let d be finite and suppose ⟨x_{n}⟩ is an increasing ω-chain whose lub, _{⨆D} x_{n}, exists. Then if d ⊑ _{⨆D} x_{n} it follows that for some n, d ⊑ x_{n}.

2. Each infinite element, x, is the lub of an increasing ω-chain of finite elements.

3. Every increasing ω-chain of finite elements has a lub in D. We believe Axioms 1 and 2 are evident, Axiom 3 says that all “potential” infinities are allowed. It is a consequence of these axioms that D is a cpo. For let ⟨x_{n}⟩ be an increasing ω-chain in D and suppose that, by Axiom 2, for every n, ⟨e_{nm}⟩_{m∈ω} is an increasing chain of finite elements of D with lub x_{n}. By Axiom 1 for each e_{nm} and n′ ≥ n, as e_{nm} ⊑ x_{n} ⊑ x_{n′} = _{⨆m_{′}} e_{n′m′}, there is an e_{n′m′} so that e_{nm} ⊑ e_{n′m′}. It follows that we can find an increasing chain ⟨e_{n}⟩ of finite elements such that each e_{n} is some e_{nm}, e_{0} is e_{00}, and for all n′ < n, m′ < n, e_{n′m′} ⊑ e_{n}. Then by Axiom 3, _{⨆D} e_{n} exists and is easily seen to be _{⨆D} x_{n}.

[figure: e_{00} = e_{0}; e_{10}; e_{20}; e_{01}; e_{11} = e_{1}; e_{21}; e_{02}; e_{12}; e_{22}; e_{29} = e_{2}; ⋮; ⋮; ⋮; ⋮]

Figure IV: Construction of the chain ⟨e_{n}⟩.

Similarly we can give a general version of the above argument for the continuity of the second-order functional, F. Suppose D and E obey the above axioms on finiteness and f: D → E is monotonic. Then f is continuous iff wherever e ⊑ f(x) and e is finite there is a finite d such that d ⊑ x and e ⊑ f(d). What this condition says is that any finite amount of information in the output only depends on a finite amount of information in the input. Suppose the condition holds and ⟨d_{n}⟩ is an increasing chain of elements in D. Then by monotonicity f(_{⨆n} d_{n}) ⊒ _{⨆n} f(d_{n}). Now if e ⊑ f(_{⨆n} d_{n}) where e is finite, it follows by the condition that there is a finite d in D such that d ⊑ _{⨆n} d_{n} and e ⊑ f(d). But then by Axiom 1, d ⊑ d_{n}, for some n and so e ⊑ _{⨆n} f(d_{n}). Now by Axiom 2 f(_{⨆n} d_{n}) = _{⨆n} e_{n}, where ⟨e_{n}⟩ is an increasing ω-chain of finite elements of E. So by the above reasoning e_{n} ⊑ _{⨆n} f(d_{n}) for each n and so f(_{⨆n} d_{n}) ⊑ _{⨆n} f(d_{n}) which completes the proof that f is continuous. Conversely suppose f is continuous and e ⊑ f(x) where ⟨d_{n}⟩ is an increasing ω-chain of finite elements of D and so e ⊑ f(x) = f(_{⨆n} d_{n}) = _{⨆n} f(d_{n}) (by continuity) and so, by Axiom 1, e ⊑ f(d_{n}) for some n, which establishes the condition. (Note that Axiom 3 was not used in this argument.)

We would like to suggest another thesis on continuous functions which refines Thesis 2. There are many monotonic but noncomputable functions in, for example, N_{⊥} →_{M} N_{⊥}, but they are all computable by infinite programs, or more generally by machines with infinitely many internal states. Of course such computation is not effective or even mechanical in the usual sense of a finite machine. Nonetheless it is physically feasible. And indeed at higher types continuity is a real restriction. Again with the above characterisation of continuous functions we could imagine an infinite machine which stored (codes for) all the pairs (d, e) of finite elements such that e ⊑ f(d) used this store to give out the information in each e whenever it had received all the information in the corresponding d. Of course, this depends on the input and output domains being themselves physically feasible (and we would dearly like to be able to put down the right axioms for that notion), but let us state a thesis for such domains:

Thesis 5. A monotonic function is continuous iff it is physically feasible.

This implies Thesis 4 as surely every computable function is physically feasible. Since the thesis is an equivalence it may be easier to give more convincing arguments for its truth than Thesis 4, in some cases at least.

One kind of information is to do with (occurrences of) events: namely the information that those events occurred. For example in the case of N_{⊥}, ⊥ might mean that no event occurred and an integer n, might mean that the event occurred of the integer n being output (or, in another circumstance being input). For an example with more structure, suppose we have a Turing machine (TM) with an input tape and an output tape. The tape squares can be blank, or, after printing, contain a 0 or a 1. The events that can occur are the printing of a 0 or a 1 on the (next) output tape square by the TM or the inputting (by some unspecified agency) of a 0 or a 1 on the (next) input tape square. Thus the output domain is just the collection of all possible sets of events that could occur, ordered by the subset ordering; equivalently this is the set of all finite or infinite binary sequences with the subsequence ordering. For example 0111 means that 0 was printed on the first tape square, and one on the second, third and fourth tape squares, and thereafter there was no more output. The same (isomorphic) domain is associated with the input. This cpo is called Tapes, not unnaturally, and the reader will see that the function f: Tapes → Tapes computed by the TM must be continuous.

By taking a different view of what constitutes an output event, we can obtain a different cpo for the same physical situation. Let us agree that outputting a 0 followed by n 1’s followed by a 0 constitutes an outputting of the integer n (and so the same event may occur several times). Then the appropriate cpo is {P \atop ω}, the set of all subsets of ω (= N) with the subset ordering. It must be admitted that what can legitimately be called an event is not a very clear notion, although there must be some rules. For example it does not seem correct to allow as an event “the printing of infinitely many 1’s”. Again if we regard the input tape also as specifying an element of {P \atop ω}, the TM may not compute a function from {P \atop ω} to {P \atop ω} at all — we should insist either that the input has a special form or that the TM has a certain kind of behaviour.

Just as more than one domain may be appropriate when describing a physical situation, so the same domain may be used to describe different situations. For example suppose we have infinitely many lights and a computational mechanism which is switching them on (and never off). Then “the switching on of the nth light” would be a bona fide event and the appropriate cpo would then be {P \atop ω} again.

In all those last examples we have not considered any problem of giving a denotational semantics; however the above domains would clearly arise if we wanted to consider the semantics of languages for outputting or inputting on tapes or for switching on infinite arrays of lights.

In terms of events a finite amount of information should just be a finite set of events. Then if ⨆n x_{n} = _{⋃n} x_{n} (as seems reasonable) the above axioms seem reasonable enough and we also believe that it is reasonably self-evident that any physically feasible function must be monotonic and obey the condition proved equivalent to continuity as an output event could hardly depend on infinitely many input events as a machine should only be able to do a finite amount of computation before causing a given output event. However further analysis of events is required to show that every continuous function is feasible. But in particular cases, such as the above interpretation of Tapes, this is not difficult.

In the above we have argued for the use of the category, CPO of cpos and continuous functions, rather than the category of sets and (ordinary) functions. We have come across a few examples of cpos. Each set, X, gives us a flat cpo, X_{⊥} = X ∪ {⊥} ordered by: x ⊑ y iff x = ⊥ or x = y. Particular examples are given in Figures I, II above and we should also mention U =^{def} ∅_{⊥} and O 0 =^{def} {⊤}_{⊥}. We have considered such continuous functions as (+1): N_{⊥} → N_{⊥} and should also mention (−1): N_{⊥} → N_{⊥} and Z: N_{⊥} → T_{⊥} where:

x − 1 = \{ \begin{matrix}n & (∃n ∈ N.x = n + 1), \\ ⊥ & (otherwise); \end{matrix}

Z(x) = \{ \begin{matrix}tt & (if x = 0), \\ ff & (if x ≠ 0, ⊥), \\ ⊥ & (otherwise). \end{matrix}

We have also seen nonflat cpos such as Tapes and {P \atop ω}. Some basic continuous functions for these cpos are (0 · −), (1 · −), tl: Tapes → Tapes, hd: Tapes → T_{⊥}, (+1), (−1): {P \atop ω} → {P \atop ω} and Z: {P \atop ω} → T_{⊥} (we don’t mind introducing a small amount of ambiguity for names of functions), where (0 · −) and (1 · −) append 0 (respectively 1) to a tape and tl and hd are characterised by the equations, tl(0·x) = tl(1·x) = x, tl(⊥) = ⊥, hd(0 · x) = ff , hd(1 · x) = tt, hd(⊥) = ⊥ and the functions over {P \atop ω} are given by:

x + 1 = {n + 1 | n ∈ x};
x − 1 = {n | n + 1 ∈ x};
Z(x) = \{ \begin{matrix}tt & (0 ∈ x), \\ ⊥ & (otherwise). \end{matrix}

We will consider other cpos and functions of several arguments when we discuss the construction in CPO.

Let us conclude with some discussion of some choices we have not made. First we have not used complete lattices, that is we have not assumed that every subset has a lub (although, of course, the lattices are included). For the presence of the top element, ⊤ (= _{⨆D} D) causes problems, leading to extra decisions when extending functions and cases when making proofs, in an unsystematic way. For example suppose we make T into a lattice by adding a top element, giving:

[figure: ⊥; ⊤; tt; ff]

Figure V: The truth-value lattice.

Now, even apart from the fact that ⊤ has no computational interpretation, when using T_{⊥} in the cases discussed above, it is not clear how to extend the definition of Cond: T_{⊥} × N_{⊥} × N_{⊥} → N_{⊥} to a function on the lattices. By monotonicity we must make N_{⊥} into a lattice too, say by adding a top element, and then we must choose between a minimum and a maximum extension:

Cond(⊤, x, y) = x ⊔ y

or

Cond(⊤, x, y) = ⊤.

Either choice means that one of the following program equivalence will fail in general, although they are correct from the computational point of view:

(if b then (if b then e_{0} else e_{1}) else (if b then e_{2} else e_{3})) ≡ (if b then e_{0} else e_{3}),
(if b_{0} then (if b_{1} then e_{0} else e_{1}) else (if b_{1} then e_{2} else e_{3})) ≡
(if b_{1} then (if b_{0} then e_{0} else e_{2}) else (if b_{0} then e_{1} else e_{3})).

One often sees another definition of cpo in which it is assumed that every directed set has a lub, where a set X is directed iff it is nonempty and any two elements have an upper bound in X. Let us call such partial orders dcpos to distinguish them from ours. We decided to make the choice of assuming only lubs of increasing ω-chains because lubs of general directed sets are not so easily justified from a computational point of view and because it is a weaker assumption. But we shall see that all the cpos we are interested in to turn out to be dcpos, so this choice is of little importance in the end.

As to functions, we have not assumed that our functions are strict (preserve the least element). For then all least fixed-points would be ⊥, which is certainly wrong. But on the other hand from the categorical point of view the strict continuous functions are important as they preserve all the cpo structure. So we will often consider the subcategory CPO_{⊥} of all strict continuous functions and write f: D →_{⊥} E to mean f is strict and continuous. Other axioms and kinds of functions will be considered later.

Exercises

1. Add a syntax for BExp to the specification of Dec, and extend the semantics accordingly.

2. In the semantics given above for nonrecursive function declarations, the free variables (other than the parameters) in the body of the function declaration receive their values from the “definition-time” environment. Can you change the semantics so that this value is taken from the “call-time” environment instead?

3. Suppose we add a class Proc of (parameterless) procedure variables to the syntax of Imp and add procedure declaration and calling facilities to Stat by including the extra clauses:

s ::= (proc p begin s end) | (call p).

What difficulties do you discover when trying to do the denotational semantics?

4. Add some facilities to Imp to allow reading a boolean value from an input channel and outputting one to an output channel. What happens with the denotational semantics? (Repeated input requests and outputs are allowed.)

5. Let S be a set, p: S → T be a predicate, θ′: S → S be a command as above. What commands, θ, satisfy the fixed-point equation, θ(σ) = Cond(p(σ), θ ∘ θ′(σ), σ).

6. Write Turing machines to compute the functions (0 · −), (1 · −), tl: Tapes → Tapes, hd: Tapes → T_{⊥},

(+1), (−1): {P \atop ω} → {P \atop ω} and Z: {P \atop ω} → T_{⊥}.

7. Let D be a cpo and let f: D → D be continuous. A prefixed-point (fixed-point, postfixed-point) of f is an element, d of D such that fd ⊑ d (fd = d, fd ⊒ d). Show that the set of prefixed-points (respectively fixed-points, postfixed-points) of f form a cpo under the partial order inherited from D.

8. Show that every monotonic function, f: D → D where D is a dcpo has a least fixed-point. Give an example of a monotonic function f: D → D, where D is a cpo, which does not have any fixed-point.

9. The cpo, Pred, is the set of partial function f: N →_{P} T ordered by:

f ⊑ g iff ∀n ∈ N.f(n) defined ⇒ (g(n) defined and f(n) = g(n));

the partial order, (T_{⊥})^{ω} is the Cartesian Product of denumerably many copies of T_{⊥}; the partial order N_{⊥} →_{⊥} T_{⊥} is the subset of strict functions of N_{⊥} →_{M} T_{⊥} with the inherited ordering. Show that all these cpos are isomorphic to the cpo,

{⟨x, y⟩ | x ⊆ N, y ⊆ N, x ∩ y = ∅}

under the ordering: ⟨x, y⟩ ⊑ ⟨u, v⟩ iff x ⊆ u and y ⊆ v.

10. Why is the function Tot: O 0 → T not intuitively computable, where: Tot(⊤) = tt, Tot(⊥) = ff ? Find some other, similar examples.

11. Find an example of a monotonic but intuitively non-computable function from Pred (see Exercise 9) to T_{⊥}. Show it is not continuous. Find some other, similar examples.

12. The function ∂_{D}: D → O 0 where D is a cpo defined by:

∂_{D}(d) = \{ \begin{matrix}⊤ & (d ≠ ⊥), \\ ⊥ & (d = ⊥). \end{matrix}

Show ∂_{D} is continuous. Give an argument to show that ∂_{Tapes} is intuitively computable for at least one interpretation of Tapes; do the same for ∂_{Pred}. A function f: D → E where D, E are partial orders is multiplicative iff whenever the glb, x ⊓ y of two elements x and y of D exists then f(x ⊓ y) = f(x) ⊓ f(y); it is dual-continuous iff whenever ⟨d_{n}⟩_{n∈ω} is a decreasing sequence in D with glb _{⊓_{D}} x_{n} then f(_{⊓_{D}} x_{n}) = ⊓_{E} f(x_{n}). Is ∂_{D} always multiplicative? Is it always dual-continuous?

13. A function is additive iff it preserves binary lubs (cf. Exercise 12). Give an example of a continuous, intuitively computable function between cpos which is not additive. Why is the functional F: (S_{⊥} → S_{⊥}) → (S_{⊥} → S_{⊥}) involved in the above discussion on while-loops additive?

14. A function \overline{μ}: Pred → N is a minimalisation operator iff \overline{μ}(f) = n ≠ ⊥ implies f(n) = tt and ∀m < n.f(m) ≠ tt. Show there is a greatest monotonic minimalisation operator and that is continuous. Is the case \overline{μ}: (N_{⊥} →_{M} T_{⊥}) → N_{⊥} much different?

15. A function \overline{∃}: (N_{⊥} →_{M} T_{⊥}) → T_{⊥} is an existential quantifier iff

\overline{∃}f = tt ⇒ there is an element, d of N s.t. f(d) = tt,
\overline{∃}f = ff ⇒ for all elements, d of N s.t. d ≠ ⊥, f(d) = ff .

What are the maximal monotonic and continuous existential quantifiers, respectively? How is the continuous one intuitively computable? What happens if you replace (N_{⊥} →_{M} T_{⊥}) by Pred?

16. Draw the following partial orders: O 0 →_{M}O 0 , O 0 →_{M}T_{⊥}, T_{⊥}→_{M}O 0 , T_{⊥}→_{M}T_{⊥}, (O 0 →_{M}O 0 )→_{M}(O 0 →_{M}O 0 ), O 0 × O 0 , (O 0 × O 0 ) →_{M} O 0 , Tapes.

17. The definition of Tapes of tapes uses {0, 1} as a parameter. Define X^{∞} similarly for any set X so that Tapes = {0, 1}^{∞} and ω =^{def} {0}^{∞} looks like:

[figure: 0 = ⊥; 1; 2; ⋮; n; ⋮; ω]

Figure VI: The cpo ω.

18. Define the partial order R (closed intervals on the real line) as the set \{[\underline{x}, \overline{x}] | −∞ ≤ \underline{x} ≤ \overline{x} ≤ +∞\} where the intervals [\underline{x}, \overline{x}] =^{def} \{y ∈ Reals | \underline{x} ≤ y ≤ \overline{x}\} are ordered by reverse inclusion, i.e. [\underline{x}, \overline{x}] ⊑ [\underline{x′}, \overline{x′}] iff \underline{x} ≤ \underline{x′} ≤ \overline{x′} ≤ \overline{x}. Show that R is a cpo. How would you use R when computing functions over reals?

19. Cantor’s Theorem shows there is no nontrivial set X which is isomorphic to (in bijection with) its own function space, X^{X}. Show there is no nontrivial partial order, D, such that D ≅ D →_{M} D.

This gives yet another argument for restricting attention to the continuous functions, as we will see that the answer for the corresponding question on cpos and continuous functions is positive. [Hint Consider D → O 0 and the cardinalities of sets of incomparable elements.]

20. Show that every denumerable directed subset of a cpo has a least upper bound. Let D, E be cpos. Show that f: D → E is continuous iff f preserves lubs of denumerable directed sets (i.e. iff for every denumerable directed subset, X, of D, f(X) is directed and f(_{⨆D} X) = _{⨆E} f(X)). Let D be a cpo and let ⟨d_{m,n}⟩_{m,n∈ω} be a double increasing sequence (i.e. m ≤ m′, n ≤ n′ implies d_{m,n} ⊑ d_{m′,n′}). Show that _{⨆m}(_{⨆n} d_{m,n}) = ⨆m,n d_{m,n} = _{⨆n} d_{n,n}.

21. Let D be a cpo. Show that a T_{0}-topology can be defined in D by taking a subset, O, to be open iff: (1) Whenever x, y are elements of D such that x ⊑ y and x ∈ O then y ∈ O.

(2) Whenever ⟨x_{n}⟩_{n∈ω} is an increasing sequence of elements of D s.t. (_{⨆n} x_{n}) ∈ O, then for some n,

x_{n} ∈ O. Show that the order can be recovered from the topology by: x ⊑ y iff ∀ open sets O.(x ∈ O ⇒ y ∈ O). Show too that if D, E are cpos then f: D → E is continuous iff it is topologically continuous with respect to the above topology. Show that this is the only assignment of topologies to cpos which makes topological continuity coincide with order continuity. [Hint Consider O 0 , ω (Exercise 17) and then an arbitrary cpo.]

22. Let D, E be dcpos. A function f: D → E is (directed) continuous iff for every directed subset, X, of D, f(X) is directed and f(_{⨆D} X) = _{⨆E} f(X). Give a T_{0}-topology for dcpos so that this definition of continuity coincides with topological continuity. Give a topology for partial orders so that topological continuity coincides with monotonicity.

2. Products and Function Spaces

Now that we have an idea of what our domains are, we need some language (metalanguage) to denote elements of and continuous functions between domains. This will be a more or less normal mathematical language of terms, including a typed λ-calculus, and looks much like the language used to describe the set-theoretic semantics of Imp and Dec in Chapter 1. We will treat this language and its semantics in a semi-formal fashion, leaving the reader, if he cares, to provide a formal definition in set theory.

In fact we expand the language as we go along, beginning with:

E1. There are constants, a, … denoting elements of cpos. Their types and what they denote are given when they are introduced. For example, ⊥_{D} denotes the least element of D (and we just write ⊥ when D is understood from the context). We also use tt, ff for elements of T_{⊥}, numerals for elements of N_{⊥}, ⊤_{D} for the top element of D, if it exists, all as in Chapter 1.

E2. There are variables, x, … denoting elements of cpos. Their types and what they denote are determined by the context of their use.

E3. There are constants, id_{D}, (+1), (−1), Z, … denoting morphisms, that are continuous functions between cpos. Their types and what they denote are given when they are introduced. Again we have introduced a few of these in Chapter 1. Again we tolerate a certain amount of ambiguity — as long as this can be disambiguated by the context; for example for each constant a, denoting an element of a domain E, we have the constant K_{a} denoting the function f: D → E where f(d) = a, and D is to be understood from the context.

E4. If α, β are expressions denoting morphisms of types A → B, B → C respectively then (β ∘ α) is an expression of type A → C which denotes the composition of β and α. Because function composition is associative we can always omit brackets.

E5. If α is an expression denoting a morphism f: A → B and e is an expression denoting an element, a of A, then α(e) denotes f(a). Actually we won’t stick to this rigid applicative syntax, but will also infix and postfix operators and so on.

We will write e: D to mean that the expression e has type D and also α: D → E to mean that the expression α has type D → E. Note that there is a correspondence between expressions denoting elements and expressions denoting morphisms. If e is an expression of type E with one free variable, x, of type D then we can define a function, f, from D to E by: f(x) = e. This is continuous as can be shown by a little inductive proof to the effect that each such function can be denoted by an expression: a variable x of type D gives the function id_{D}; the expression α(e) gives the function α ∘ β where e gives β.

What we need next are functions of several variables and they go hand in hand with products in CPO. Let D_{0}, …, D_{n−1} be cpos. Their Cartesian product, ∏_{i<n} D_{i} is the set {⟨x_{0}, …, x_{n−1}⟩ | ∀i < n.x_{i} ∈ D_{i}} of n-tuples ordered coordinatewise by:

⟨x_{0}, …, x_{n−1}⟩ ⊑ ⟨x′_{0}, …, x′_{n−1}⟩ ≡ ∀i < n.x_{i} ⊑_{D_{i}} x′_{i}.

(We have already seen an example of this construction in Chapter 1, namely T_{⊥} × S_{⊥} × S_{⊥}.) Sometime we write D_{0} × ⋯ × D_{n} for ∏_{i<n} D_{i} or D^{n} when the D_{i} are all the same. Note that the Cartesian product is a cpo with the least element, ⟨⊥_{D_{0}}, …, ⊥_{D_{n−1}}⟩ and with lubs of increasing sequence ⟨x^{(m)}⟩_{m∈ω} determined coordinatewise as: ⨆_{m} x^{(m)} = ⟨⨆_{m} _{D_{0}}x_{0}^{(m)}, … ⨆_{m} _{D_{n−1}}x_{n−1}^{(m)}⟩, (and in fact all lubs are determined coordinatewise).

This product is also the normal categorical product. We have the natural projection maps,

π_{i}: (∏_{i<n} D_{i}) → D_{i} (i < n)

where π_{i}(x) = x_{i} — and these are continuous as can be seen from the remark on lubs. Sometimes π_{i}(x) is written as (x ↓ i) or even (x)_{i}. The projection maps have the universal property that if f_{i}: F → D_{i} (i < n) are n continuous maps then there is a unique (mediating) morphism, h: F → (∏_{i<n} D_{i}) which makes all the following diagrams commute:

[figure: F; _{∏i<n} D_{i}; h; f_{i}; D_{i}; π_{i}  (i < n)]

To see this, suppose h is such a morphism. Then for any element, x, of F:

h(x) = ⟨h(x)_{0}, …, h(x)_{n−1}⟩
= ⟨π_{0} ∘ h(x), …, π_{n−1} ∘ h(x)⟩
= ⟨f_{0}(x), …, f_{n−1}(x)⟩,

showing uniqueness. Conversely we can use the formula to define h, proving continuity by:

h(⨆_{m} x_{m}) = ⟨f_{0}(⨆_{m} x_{m}), …, f_{n−1}(⨆_{m} x_{m})⟩
= ⟨⨆_{m} f_{0}(x_{m}), …, ⨆_{m} f_{n−1}(x_{m})⟩  the f_{i} are continuous
= ⨆_{m}⟨f_{0}(x_{m}), …, f_{n−1}(x_{m})⟩  lubs are determined coordinatewise
= ⨆_{m} h(x_{m})  by definition of h.

We write h as ⟨f_{0}, …, f_{n−1}⟩ and the double use of pointed brackets should not cause any confusion. Note the particular case, n = 0, when ∏_{i<0} D_{i} is just U and we see that for any cpo, F, there is a unique morphism F→U, showing that U is the final object in CPO. Note, too, that as usual the universal property determines ∏_{i<n} D_{i} up to isomorphism.

We can now expand our stock of expressions:

E6. If e_{0}, …, e_{n−1} are expressions of types D_{0}, …, D_{n−1} respectively, then ⟨e_{0}, …, e_{n−1}⟩ is an expression of type D_{0} × ⋯ × D_{n−1} and denotes the n-tuple of the values denoted by the e_{0}, …, e_{n−1}, taken in that order. When α: (D_{0} × ⋯ × D_{n−1}) → E we will often write α(e_{0}, …, e_{n−1}) instead of the more pedantic α(⟨e_{0}, …, e_{n−1}⟩); this is just the usual notation for functions of several arguments.

E7. If α_{0}, …, α_{n−1} are expressions of types (F → D_{0}), …, (F → D_{n−1}) respectively then ⟨α_{0}, …, α_{n−1}⟩ is an expression of type F → (∏_{i<n} D_{i}), and it denotes the evident mediating morphism, as described above.

One reason for interest in the categorical properties of the Cartesian product is that they serve as a guide for the right axioms, which we can give in terms of either the morphisms or the elements. We call the first kind of axiomatisation external and the second internal. Unfortunately, we will not have time to pursue questions of proof much further than informally stating a few axioms.

External Axiomatisation.

1. ∀f_{0}: F → D_{0}. . . . .∀f_{n−1}: F → D_{n−1}.∀i < n.π_{i} ∘ ⟨f_{0}, …, f_{n−1}⟩ = f_{i}.

2. ∀h: F → (∏_{i<n} D_{i}).h = ⟨π_{0} ∘ h, …, π_{n−1} ∘ h⟩.

These axioms are clearly true. Let us see that they imply the requisite universal property. Let f_{i}: F → D_{i} (i < n) be n morphisms then let the mediating morphism be h =^{def} ⟨f_{0}, …, f_{n−1}⟩. By Axiom 1 all the required diagrams commute. Now let h′ be any morphism which makes all the diagrams commute. Then h = ⟨f_{0}, …, f_{n−1}⟩ = ⟨π_{0} ∘ h′, …, π_{n−1} ∘ h′⟩ (h′ makes all the diagrams commute) = h′ (by Axiom 2).

Internal Axiomatisation.

1. ∀x_{0}: D_{0}. . . . .∀x_{n−1}: D_{n−1}.π_{i}(x_{0}, …, x_{n−1}) = x_{i}.

2. ∀x: ∏_{i<n} D_{i}.x = ⟨π_{0}(x), …, π_{n−1}(x)⟩.

Again the axioms are true and they imply the external ones (using the extensionality of functions, the definition of composition and the definition of the tupling operator on functions). Note that the external axiomatisation refers to “external” cpos, such as F, whereas the internal one refers only to the D_{i} (and their product).

Returning to expressions we note an extended version of the correspondence between expressions for elements and expressions for morphisms. For any expression e: D suppose x_{0}: D_{0}, …, x_{n−1}: D_{n−1} is a list (without repetition) of variables of the indicated types which includes all the free variables of e (i.e. all the variables). Then we can define a function f: ∏_{i<n} D_{i} → D by f(x_{0}, …, x_{n−1}) = e. This is a continuous function as it can be given by an expression α[e; x_{0}, …, x_{n−1}] which is defined by structural induction on expressions e, thus:

(i)  α[a; x_{0}, …, x_{n−1}] = K_{a},
(ii)  α[x_{i}; x_{0}, …, x_{n−1}] = π_{i},
(iii)  α[β(e); x_{0}, …, x_{n−1}] = β ∘ (α[e; x_{0}, …, x_{n−1}]),
(iv)  α[⟨e_{0}, …, e_{m−1}⟩; x_{0}, …, x_{n−1}] = ⟨α[e_{0}; x_{0}, …, x_{n−1}], …, α[e_{m−1}; x_{0}, …, x_{n−1}]⟩.

It follows if we fix some arguments of a continuous function f: ∏_{i<n} D_{i} →D we still obtain a continuous function. For suppose we fix the ith argument to be the element d_{i} in D then the function g: D_{0} × ⋯ × D_{i−1} × D_{i+1} × ⋯ × D_{n−1} → D where g(x_{0}, …, x_{i−1}, x_{i+1}, …, x_{n−1}) = f(x_{0}, …, x_{i−1}, d_{i}, x_{i+1}, …, x_{n−1}) is continuous as the expression on the right of the equation is one of the expression we have considered above. Now it is clear that the same holds if we fix any subset of the arguments of f. As it happens the converse is true: if a function is continuous in each of its arguments it is continuous (where a function is continuous in its ith argument means that the function obtained by fixing all the other arguments is continuous). We illustrate this for binary functions. Certainly monotonicity in each argument implies monotonicity; for continuity suppose f: D × E → F and ⟨d_{n}, e_{n}⟩_{n∈ω} is an increasing chain of elements in D × E. Then:

f(⨆_{n}⟨d_{n}, e_{n}⟩) = f(⟨⨆_{n} d_{n}, ⨆_{n} e_{n}⟩)  lubs are determined coordinatewise
= ⨆_{n} f(d_{n}, ⨆_{n} e_{n})  f is continuous in its first argument
= ⨆_{n} ⨆_{m} f(d_{n}, e_{m})  f is continuous in its second argument
= ⨆_{n} f(d_{n}, e_{n})  by Exercise 1.20, as f is monotonic.

Example. Any function f: X_{0} ×⋯×X_{n−1} →Y on sets extends to a monotonic and so continuous function, f_{⊥}: (X_{0})_{⊥} × ⋯ × (X_{n−1})_{⊥} → Y_{⊥} where

f_{⊥}(d_{0}, …, d_{n−1}) = \{ \begin{matrix}⊥ & (if some d_{i} is ⊥), \\ f(d_{0}, …, d_{n−1}) & (otherwise). \end{matrix}

This is the minimal extension and is the one we will normally consider. For example the resulting truth-table for or_{⊥}: T_{⊥} × T_{⊥} → T_{⊥} is:

or_{⊥} tt ff ⊥
tt tt tt ⊥
ff tt ff ⊥
⊥ ⊥ ⊥ ⊥

A program for or_{⊥} is: if x then (if y then true else true) else (if y then true else false). It is the “call-by-value” or. However there are three other monotonic extensions which we might call or_{L}, or_{R}, or_{P} with truth tables:

or_{L} tt ff ⊥
tt tt tt tt
ff tt ff ⊥
⊥ ⊥ ⊥ ⊥

or_{R} tt ff ⊥
tt tt tt ⊥
ff tt ff ⊥
⊥ tt ⊥ ⊥

or_{P} tt ff ⊥
tt tt tt tt
ff tt ff ⊥
⊥ tt ⊥ ⊥

One occasionally sees programming constructs corresponding to or_{L}. One can write a program for it as: if x then true else (if y then true else false) and a similar one for or_{R}. However one can’t write a sequential program for or_{P} — parallel or. This distinction raises the question where one can axiomatise the sequential continuous functions, as the others play no role in most programming languages.

The conditional function cond: T_{⊥} × N_{⊥} × N_{⊥} → N_{⊥} defined in Chapter 1 is also not the minimal extension of the set-theoretic condition, and this is in accord with the computational intuition that, according to the value of the first argument, either the second or the third argument is not evaluated. There is also a larger extension, parcond: T_{⊥} × N_{⊥} × N_{⊥} → N_{⊥} given by:

parcond(t, x, y) = \{ \begin{matrix}x & (t = tt or x = y), \\ y & (t = ff or x = y), \\ ⊥ & (otherwise). \end{matrix}

Note that parcond(⊥, x, x) = x showing its parallel nature. More generally we define cond_{D}: T_{⊥}×D×D→D by:

cond_{D}(t, x, y) = \{ \begin{matrix}x & (t = tt), \\ y & (t = ff ), \\ ⊥ & (t = ⊥). \end{matrix}

We will often write (e → e′ | e′′) instead of cond_{D}(e, e′, e′′). When D has a continuous glb operation, ⊓ (as is the case with flat domains) we define:

parcond_{D}(t, x, y) = \{ \begin{matrix}x & (t = tt), \\ y & (t = ff ), \\ x ⊓ y & (t = ⊥) \end{matrix}

and it is easily verified that cond_{D} and parcond_{D} are continuous. Note that or_{P} can be defined in terms of parcond_{T_{⊥}} by:

or_{P}(x, y) = parcond_{T_{⊥}}(x, tt, cond_{T_{⊥}}(y, tt, ff )).

With the above exceptions, and unless otherwise stated, we will always use the minimal extensions hereafter and will drop the suffix, ⊥ — similarly we will drop the suffices on T_{⊥}, N_{⊥}, … when it is clear we intend a cpo rather than a set. So for example when e, e′ are expressions of type X_{⊥}, we write the expression =_{⊥} (e, e′) of type T in the less pedantic form (e = e′). Note this is different from the assertion e = e′ which means that e and e′ denote the same value: so for example the assertion ⊥ = ⊥ is true but the expression (⊥ = ⊥) denotes ⊥, as does (e = ⊥) or (⊥ = e).

Finally we consider the example of finite and infinite binary trees possibly with integers on their tips, ordered by the sub-tree ordering.

[figure: ⊥; 0; n; …; …; 0; 0; 0; 0; 0; 0]

Figure VII: The cpo Btrees.

Some of this domain, Btrees, is drawn in the diagram. It is only one of a great variety of domains of trees. We will give a construction of Btrees later, but intuitively it can be thought of as generated by the following rules:

1. Any element of N_{⊥} is a Btree: if t_{0}, t_{1} are elements so is • \/ t_{0} t_{1}.

2. For any element, t, we have ⊥ ⊑ t; if t_{0} ⊑ t′_{0} and t_{1} ⊑ t′_{1} then • \/ t_{0} t_{1}⊑ • \/ t′_{0} t′_{1}, for the finite elements, and then adding the infinite ones as limits of ω-chains with the rule: ⨆_{n} t_{n} ⊑ ⨆_{n} t′_{n} ≡ ∀n.∃m.t_{n} ⊑ t′_{m} to decide the approximation order between two chains.

The appropriate functions are tip: N → Btrees, mktree: Btrees × Btrees → Btrees, val: Btrees → N, ltree, rtree: Btrees → Btrees and istip: Btrees → T where:

tip(n) = \{ \begin{matrix}⊥ & (n = ⊥), \\ \begin{matrix}n \\ . \end{matrix} & (n ≠ ⊥). \end{matrix}

maketree(t_{0}, t_{1}) = • \/ t_{0} t_{1}.
val(t) = \{ \begin{matrix}n & (t = \begin{matrix}n \\ . \end{matrix}), \\ ⊥ & (otherwise). \end{matrix}

ltree(t) = \{ \begin{matrix}t_{0} & (t = • \/ t_{0} t_{1}), \\ ⊥ & (otherwise). \end{matrix}

rtree(t) = \{ \begin{matrix}t_{1} & (t = • \/ t_{0} t_{1}), \\ ⊥ & (otherwise). \end{matrix}

istip(t) = \{ \begin{matrix}tt & (t = \begin{matrix}n \\ . \end{matrix}), \\ ff & (t = • \/ t_{0} t_{1}), \\ ⊥ & (t = •). \end{matrix}

We conclude the discussion of the Cartesian product construction by noting that there is a product operation on the morphisms too. Suppose f: D_{i} →E_{i} (i < n) are continuous functions. Then ∏_{i<n} f_{i}: ∏_{i<n} D_{i} → ∏_{i<n} E_{i} is defined by:

∏_{i<n} f_{i} = ⟨f_{0} ∘ π_{0}, …, f_{n−1} ∘ π_{n−1}⟩

so that (∏_{i<n} f_{i})(x_{0}, …, x_{n−1}) = ⟨f(x_{0}), …, f(x_{n−1})⟩. Sometimes it is written as f_{0} × ⋯ × f_{n−1} instead. The two product operations (on objects and morphisms) together make Cartesian product into a covariant functor, ∏: CPO^{n} → CPO, which just means that the following equations are true:

(i)  ∏_{i<n} id_{D_{i}} = id_{∏_{i<n} D_{i}},
(ii)  ∏_{i<n}(g_{i} ∘ f_{i}) = (∏_{i<n} g_{i}) ∘ (∏_{i<n} f_{i}).

It will prove very useful when we come to solving recursive domain equations (try Exercise 1.3) to consider domain constructions, such as Cartesian product, as functors.

In applications of the fixed-point theorem we will usually want to use domains of functions, as illustrated in Chapter 1 and so we now consider the function-space construction (exponentiation). Let D and E be cpos. Their function space, D → E in the set of all continuous functions from D to E with the pointwise ordering:

f ⊑ g iff ∀x ∈ D.f(x) ⊑_{E} g(x).

Note that (D→E) is a cpo with least element K_{⊥_{E}} and with lubs of increasing sequence determined pointwise by: (⨆_{n} f_{n})(x) = ⨆_{n}(f_{n}(x)).

We can characterise exponentiation by a universal property relating it to Cartesian product. Note that there is a natural application (evaluation) function, apply: ((D → E) × D) → E defined by:

apply(f, x) = f(x).

This is continuous as it is continuous in each argument separately. We have already seen in our discussion of expressions that f(x) is continuous in x, when f is a fixed function (the value of some constant). The formula for lubs of increasing chains of continuous functions shows that the expression f(x) is continuous in its first argument too.

The universal property is that if f: F×D→E is any continuous function (so that F is a “trial” functionspace) there is a unique mediating morphism g: F → (D → E) so that the following diagram commutes:

[figure: (D → E) × D; F × D; g × id_{D}; E; apply; f]

To see this suppose g is such a morphism. Then for any elements v of F and d of D we have:

g(v)(d) = apply(g(v), d)
= apply(g × id_{D}(v, d))
= apply ∘ (g × id_{D})(v, d)
= f(v, d)

showing that g(v) is uniquely determined as the function z_{v}: (D → E) such that z_{v}(d) = f(v, d), which is continuous with a fixed f and v, by the above remarks on expressions. To see that g itself is continuous, let ⟨v_{n}⟩_{n∈ω} be an increasing sequence of elements of F and calculate:

g(⨆_{n} v_{n})(d) = f(⨆_{n} v_{n}, d)
= ⨆_{n} f(v_{n}, d)  f is continuous and so continuous in its first argument

= ⨆_{n}(g(v_{n})(d))

= (⨆_{n} g(v_{n}))(d)  limits being determined pointwise

which shows that g(⨆_{n} v_{n}) = ⨆_{n} g(v_{n}) by extensionality. In category-theoretic jargon, we have shown that CPO is Cartesian closed.

We write g as Curry(f) and expand our stock of expressions for continuous functions:

E8. If α is an expression of type (F × D) → E then Curry(α) is one of type F → (D → E), with denotation as specified above.

External Axiomatisation.

1. ∀f: (F × D) → E.f = apply ∘ (Curry(f) × id_{D}).

2. ∀g: F → (D → E).g = Curry(apply ∘ (g × id_{D})).

These axioms are easily seen to be true. Axiom 1 implies the existence part of the universal property: Axiom 2 implies uniqueness as if g: F → (D → E) makes the above diagram commute, for a given f: (F × D) → E, then g = Curry(apply ∘ (g × id_{D})) (by Axiom 2) = Curry(f). For the internal axiomatisation we have to expand our language further by introducing the typed λ-calculus:

E9. If e is an expression of type E and x is a variable of type D then (λx: D.e) is an expression of type (D → E).

Note that λx: D.[ ] is a binding operator and so x is not a free variable in λx: D.e. We define the denotation of (λx: D.e) whenever e: E satisfies the following conditions:

A) the denotation of e is defined for all values of its free variables.

B) if x_{0}: D_{0}, …, x_{m−1}: D_{m−1} is a list of variables of the indicated types which includes all the free variables of e then the function f: ∏_{i<m} D_{i} → E associated with e by: f(x_{0}, …, x_{m−1}) = e can be defined by an expression, α[e; x_{0}, …, x_{m−1}] built up using E3, E4, E7, E8.

Then if the free variables of (λx: D.e) are x_{0}, …, x_{n−1}, the value of (λx: D.e) at x_{0}, …, x_{n−1} is the function f: D → E given by f(x) = e. This is a continuous function since it is obtained from either α[e; x_{0}, …, x_{n−1}] or α[e; x_{0}, …, x_{n−1}] by fixing the values of x_{0}, …, x_{n−1}. So we see that (λx: D.e) satisfies condition A. We now check it also satisfies condition B. Let x_{0}: D_{0}, …, x_{m−1}: D_{m−1} be a list of variables including all the free variables of (λx: D.e). Now let D_{m} =^{def} D and let θ: (∏_{i<m} D_{i}) × D → ∏_{i≤m} D_{i} be the isomorphism ⟨π_{0} ∘ π_{0}, …, π_{m−1} ∘ π_{0}, π_{1}⟩ (which has inverse ⟨⟨π_{0}, …, π_{m−1}⟩, π_{m}⟩). Then we can take α[λx: D.e; x_{0}, …, x_{m−1}] to be Curry(α[e; x′_{0}, …, x′_{m−1}, x] ∘ θ) where x′_{0}: D_{0}, …, x′_{m−1}: D_{m−1}, x: D_{m} are a list of distinct variables such that x′_{i} is x_{i} unless x_{i} is x).

It follows from these remarks and (i) to (iv) above that any expression e for an element built up by E1–E9 obeys conditions A and B. On the other hand we can now see that the expression for morphisms can be viewed as abbreviations for expressions for elements, now that the function-space construction allows us to think of morphisms as elements. Suppose we just allow an expression-forming rules E1, E2, E5′ (which is E5 restricted to the case where α is a constant), E6, and E9. Then if α: B → C and β: A → B are abbreviations for e′ and e respectively, α ∘ β is one for λx: A.apply(e′, apply(e, x)); if α: A → B abbreviates e′ then α(e) abbreviates apply(e′, e); if α_{0}: (F → D_{0}), …, α_{n−1}: (F → D_{n−1}) abbreviates e_{0}, …, e_{n−1} respectively ⟨α_{0}, …, α_{n−1}⟩ abbreviates λv: F.⟨apply(e_{0}, v), …, apply(e_{n−1}, v)⟩; if α: F × D → E abbreviates e then Curry(α) abbreviates λv: F.λd: D.apply(e, ⟨v, d⟩).

The rules E1, E2, E5′, E6, E9 give us a typed λ-calculus and it is convenient to introduce a few more abbreviations. For expressions e′: ∏_{i<n} A_{i} → B, e_{0}: A_{0}, …, e_{n−1}: A_{n−1} e′(e_{0}, …, e_{n−1}) abbreviates apply(e′, ⟨e_{0}, …, e_{n−1}⟩); when D can be understood from the context (λx.e) abbreviates (λx: D.e); the expression (λx_{0}: D_{0}, x_{1}: D_{1}, …, x_{n−1}: D_{n−1}.e) abbreviates

(λx: ∏_{i<n} D_{i}.(λx_{0}: D_{0}(… (λx_{n−1}: D_{n−1}.e) …))(π_{0}(x)) … (π_{n−1}(x))).

Now the internal axiomatisation of the function space construction just consists of the familiar rules for the typed λ-calculus.

Internal Axiomatisation.

1. β-reduction: (λx.α[e; x])e′ = α(e′).

2. η-reduction: (λx.e(x)) = e (x not a free variable of e).

The above axioms are asserted for all expressions e and all values of their free variables. They are evidently true and we check that they imply the external axioms (together with our other axioms and a few elementary ones and principles of logic). Suppose f: (F × D) → E and calculate for each w in F × D.

(apply ∘ (Curry(f) × id_{D}))(w) = apply((Curry(f) × id_{D})(w))
= apply(Curry(f)(π_{0}(w)), π_{1}(w))
= (λv: F.λd: D.apply(f, ⟨v, d⟩))(π_{0}(w))(π_{1}(w))
= (λd: D.f(π_{0}(w), d))(π_{1}(w))  β-reduction
= f(π_{0}(w), π_{1}(w))  β-reduction
= f(w).

Then Axiom 1 follows by extensionality. For Axiom 2, suppose g: F → (D → E) and calculate for each v in F:

Curry(apply ∘ (g × id_{D}))(v) = (λv: F.λd: D.apply(apply ∘ (g × id_{D}), ⟨v, d⟩))(v)
= λd: D.apply((g × id_{D})(v, d))  β-reduction
= λd: D.g(v)(d)
= g(v)  η-reduction.

and then Axiom 2 follows by extensionality. Note by the way that all the operations such as composition, ∘, the two tupling operators, ⟨·, …, ·⟩, and Currying (Curry) are all continuous as we have ∘ = λf.λg.g ∘ f etc; also × acts continuously on morphisms.

As a functor exponentiation, →, is defined on morphisms by defining f → f′: (A → A′) → (B → B′) where f: B → A, f′: A′ → B′ by:

f → f′ = λx: A → A′.f′ ∘ x ∘ f.

Note that f: B → A rather than f: A → B which indicates that →: CPO^{2} → CPO is a bifunctor which is contravariant in its first argument and covariant in its second argument, which is to say that the following equations are true, where f: B → A, g: C → B, f′: A′ → B′, g′: B′ → C′:

(i) id_{D} → id_{E} = id_{D→E}, (ii) (f ∘ g) → (g′ ∘ f′) = (g → g′) ∘ (f → f′).

Again, exponentiation acts continuously on morphisms.

Now that we have the basic constructions on cpos and a language for expressing elements and morphisms we return to fixed-points and then see how to give a denotational semantics for Imp and Dec when extended by adding iteration and recursive declaration facilities. The least fixed-point, fix_{f}, of a continuous function f: D → D is itself a continuous function of f, fix: (D → D) → D as we have:

fix_{f} = ⨆_{n} f^{n}(⊥) = ⨆_{n}(λf.f^{n}(⊥))(f) = (⨆_{n} λf.f^{n}(⊥))(f)

showing that fix = ⨆_{n} λf.f^{n}(⊥), a continuous function. Often fix is called, Y, after the paradoxical combinator of combinatory logic; we will often use the abbreviation (μx: D.e) (or just μx.e when D is understood from the context) to stand for fix(λx.e) — clearly μx.e is the least element, x such that x = e. Sometimes we just define elements, x, recursively by writing x = e, meaning x = μx.e, or even f(x_{0}, …, x_{n−1}) = e for functions meaning f = μf.(λx_{0}, …, x_{n−1}.e).

Examples

1. In the case of the statement while b do s we will be given a meaning p_{⊥}: S_{⊥} → T_{⊥} for b (in the case that evaluation of b always terminates) and a meaning θ′: S_{⊥} → S_{⊥} for s and take the meaning of the statement to be θ = fix(F) where F: (S_{⊥} → S_{⊥}) → (S_{⊥} → S_{⊥}) is F = λθ: (S_{⊥} → S_{⊥}).λσ: S_{⊥}.cond(p_{⊥}(σ), θ(θ′(σ)), σ).

2. In the case of the recursive declaration letrec f(x) be e in e′ we shall take the meaning of f to be μg.G(g) where G(g)(v) is the value of e in the current environment, altered so that f and x have values g and v respectively.

3. Of course we can just define elements without using any particular programming language. So addition can be defined by taking over the usual primitive recursive definition as:

+ = μf: (N_{⊥} × N_{⊥} → N_{⊥}).λm: N_{⊥}.λn: N_{⊥}.(n = 0 → m | f(m, n − 1) + 1).

We can also define functions by minimalisation. Suppose we have p_{⊥}: N_{⊥}^{2} → T_{⊥} and wish to define f: N_{⊥} → N_{⊥} as f(m) = the smallest integer n such that p_{⊥}(m, n) = tt. Then

f = λn.(μh.λm.(p(n, m) → m | h(m + 1)))(0).

It should now be clear that in this way we can define (the minimal extension of) any partial recursive function or predicate over the integers. We can also define many functionals at higher types. For instance suppose we want to define sum: ((N_{⊥} → N_{⊥}) × N_{⊥}) → N_{⊥} so that sum(f, n) = f(0) + ⋯ + f(n − 1), then sum is defined recursively by: sum(f, n) = (n = 0 → 0 | f(n − 1) + sum(f, n − 1)), or, in other words: sum = μsum.λf.λn.(n = 0 → 0 | f(n − 1) + sum(f, n − 1)). Later on we will see that all the functions and functionals we can define are computable, in a sense to be described.

4. In the case of domains such as Tapes we can define some infinite elements by recursion: for example 010101 … is just μx.0.1.x. One way to obtain nonperiodic sequence is to take p: N→{0, 1} and define g: N → Tapes recursively by:

g(n) = (p(n) = 0 → 0.g(n + 1) | 1.g(n + 1)).

Then g(0) is p(0)p(1)p(2)p(3) . . ..

Similarly in the case of {P \atop ω} take p: N_{⊥} → T_{⊥} and define g: N_{⊥} → {P \atop ω} by:
g(n) = {g(n + 1) + 1} ∪ (p(n) → {0} | ⊥)

where ∪: {P \atop ω}^{2} → {P \atop ω} is the (continuous) union function and \{0\} is the singleton zero set. Then g(0) = {n ∈ ω | p(n) = tt}.

5. Simultaneous fixed-points are easily reduced to single ones. Suppose f_{i}: (∏_{i<n} D_{i}) → D_{i} (i < n) are continuous functions. The elements d_{0}, …, d_{n−1} of D_{0}, …, D_{n−1} respectively are simultaneous fixed-points of f_{0}, …, f_{n−1} iff

d_{0} = f_{0}(d_{0}, …, d_{n−1}),
⋮
d_{n−1} = f_{n−1}(d_{0}, …, d_{n−1}).

Then d_{0}, …, d_{n−1} are simultaneous fixed-points of f_{0}, …, f_{n−1} iff ⟨d_{0}, …, d_{n−1}⟩ is a fixed-point of ⟨f_{0}, …, f_{n−1}⟩ and we see that the least simultaneous fixed-points are d_{i} = (fix(⟨f_{0}, …, f_{n−1}⟩))_{i}.

For instance we can define functions g: N^{2} → N recursively by:

\begin{aligned}g(x, y) & = (x = 0 → 7 | g(x − 1, h(y))), \\ h(x) & = (x = 0 → 6 | g(x − 1, x + 1)) \end{aligned}

meaning that g, h should be the least simultaneous fixed points of the functions F_{0}, F_{1} where F_{0} = λg: (N^{2} → N), h: N → N.λx: N.λy: N.(x = 0 → 7 | g(x − 1, h(y))) and F_{1} = λg, h.λx.(x = 0 → 6 | g(x − 1, x + 1)).

The idea of making definitions with the aid of the least fixed-point operator, fix, leads to a major proof rule, due to Scott, called fixed-point induction (sometimes computational induction).

Definition 2. Let D be a cpo. A property P (a subset of D) is ω-inductive (= inclusive) iff whenever ⟨x_{n}⟩_{n∈ω} is an increasing sequence of elements in P, its lub, ⨆_{n} x_{n} is also in P.

Fixed-point Induction. Let P ⊆ D be ω-inductive and let f: D → D be continuous. Then we have: [P(⊥) ∧ (∀x: D.P(x) ⇒ P(fx))] ⇒ P(fix(f)).

The validity of this principle is clear: note that it can be rephrased as every subcpo closed under a continuous function contains fix_{f}. One idea behind fixed-point induction is to avoid integer reasoning to show ∀n ∈ ω.P(f^{n}(⊥)) when proving P(fix_{f}).

Examples. For f: D → D prove fix_{f} ⊑ f(fix_{f}) by using P(x) =^{def} x ⊑ fx. The opposite inclusion needs a separate axiom in any formal system.

It is important to be able to manufacture inclusive predicates.

1. Basic Relations. Let D be a cpo. Then ∅, D are inclusive predicates on D; x = y and x ⊑ y are inclusive relations on D × D.

2. Inverse Image. Let D_{0}, …, D_{n−1} be cpos and let R ⊆ ∏_{i<n} D_{i} be inclusive. Then if f_{i}: ∏_{j<m} E_{j} → D_{i} are i continuous functions (i < n) then

Q(y_{0}, …, y_{m−1}) =^{def} R(f_{0}(y_{0}, …, y_{m−1}), …, f_{n−1}(y_{0}, …, y_{m−1}))

is inclusive too. In particular taking D_{0} = D_{1} and R(x_{0}, x_{1}) ≡ x_{0} ⊑ x_{1} we find that inclusions of the form f_{0}(y_{0}, …, y_{m−1}) ⊑ f_{1}(y_{0}, …, y_{m−1}) are inclusive.

3. Logical. Let D be a cpo and if P, Q ⊆ D are inclusive so are P ∩ Q and P ∪ Q: If E is another cpo and R ⊆ D × E is inclusive with respect to its first argument then ∀y: E.R(x, y) is inclusive.

4. Products. Let D_{0}, …, D_{n−1} be cpos and let P_{0} ⊆ D_{0}, …, P_{n−1} ⊆ D_{n−1} be inclusive. Then ∏_{i<n} P_{i} ⊆ ∏_{i<n} D_{i} is inclusive where ∏_{i<n} P_{i} = {x ∈ ∏_{i<n} D_{i} | ∀i < n.P_{i}((x)_{i})}.

5. Exponentiation. Let D, E be cpos and let P ⊆ D, Q ⊆ E be inclusive. Then (P → Q) ⊆ (D → E) is inclusive where: (P → Q) = {f: D → E | ∀d: D.P(d) ⇒ Q(fd)}.

Unfortunately, as remarked above, we do not have time to pursue issues connected with proof much beyond stating the relevant axioms. Next we see that it is now possible to give the semantics of Dec and Imp with the added iterative and recursive declaration features.

For Imp we have the syntax of Chapter 1, including the iteration statement. The semantic domains are T_{⊥}, S_{⊥}, and now C = (S_{⊥} →S_{⊥}) the function space cpo. The denotational functions are B: BExp→(S_{⊥} → T_{⊥}) (where the range of BExp is the cpo (S_{⊥} → T_{⊥})), A: Act → C and C: Stat → C which is defined by structural induction on statements by:

C[[a]] = A[[a]]; (i) (ii) C[[dummy]] = λσ: S_{⊥}.σ; C[[(s_{1}; s_{2})]] = C[[s_{2}]] ∘ C[[s_{1}]]; (iii) (iv) C[[if b then s_{1} else s_{2}]] = λσ: S_{⊥}.(B[[b]](σ) → C[[s_{1}]](σ) | C[[s_{2}]](σ));

(v) C[[while b do s]] = μθ: C.λσ: S_{⊥}.(B[[b]](σ) → θ(C[[s]](σ)) | σ).

We have abstracted the free variables on the right-hand side of the definitions in Chapter 1 to make it a little clearer that the meaning of a statement is a function of the meanings of its components. Note that our discussion on the typed λ-calculus we are using as a metalanguage show that, by structural induction, each statement receives a meaning expressible in this typed λ-calculus providing each primitive expression of the form A[[a]] or B[[b]] is taken as a constant. This is, perhaps, a little awkward; ideally we might like to have a single expression in the metalanguage for the function C, and that would require us to take the syntax as a cpo too. It is most convenient to leave this idea for the time being and return to it when considering recursively specified domain equations.

Equations (i)–(iv) are just taken over from the equations we had when using ordinary sets to give the semantics. Equation (v) should be exactly what the reader expects given the discussion of the iteration statement in Chapter 1 and Example 1 above. Notice that the cpo C is too large in the sense that commands should never be nonstrict. This point will be taken up when we consider the strict function space construction in Chapter 3.

Turning to Dec, we have the syntax of Chapter 1, including the recursive declaration facility extended to functions of several arguments. We assume that there are fixed limits (m and n) on the arity of the function and operation symbols, as we have only considered finite products so far. For the semantic domains we take V to be a fixed cpo of values, IEnv to be (Id_{⊥} → V). FEnv to be (Fun_{j})_{⊥} → (V^{j} → V). Again we may question why nonstrict environments are allowed. The denotational functions are I_{i}: Op_{i} → (V^{i} → V) (i < n), B: BExp → ((IEnv × FEnv) → T) and E: Exp → ((IEnv × FEnv) → V) which is defined by structural induction:

(i) E[[x]] = λρ: IEnv, φ: FEnv.ρ[[x]]; (ii) E[[o_{i}(e_{0}, …, e_{i−1})]] = λρ: IEnv, φ: FEnv.I_{i}[[o_{i}]](E[[e_{0}]](ρ, φ), …, E[[e_{i−1}]](ρ, φ)) (i < n); (iii) E[[if b then e_{0} else e_{1}]] = λρ: IEnv, φ: FEnv.(B[[b]](ρ, φ) → E[[e_{0}]](ρ, φ) | E[[e_{1}]](ρ, φ)); (iv) E[[let x be e_{0} in e_{1}]] = λρ: IEnv, φ: FEnv.E[[e_{1}]](ρ[E[[e_{0}]](ρ, φ)/x], φ);

E[[let f_{j}(x_{0}, …, x_{j−1}) be e_{0} in e_{1}]] = (v)_{j}

λρ: IEnv, φ: FEnv.E[[e_{1}]](ρ, φ[λw: V^{j}.E[[e_{0}]](ρ[(w)_{0}/x_{0}] … [(w)_{j−1}/x_{j−1}], φ)/f_{j}]);

E[[letrec f_{j}(x_{0}, …, x_{j−1}) be e_{0} in e_{1}]] =

(vi)_{j}
λρ: IEnv, φ: FEnv.E[[e_{1}]](ρ, φ[μf: V^{j} → V.λw: V^{j}.E[[e_{0}]](ρ[(w)_{0}/x_{0}] … [(w)_{j−1}/x_{j−1}],
φ[f/f_{j}])/f_{j}]).

Here ·[·/·]: IEnv × V × Id_{⊥} → IEnv is defined by:

ρ[v/x] = λy: Id_{⊥}.((y = x) → v | ρ[[y]]),

and ·[·/·]: FEnv × (V^{j} → V) × (Fun_{j})_{⊥} → FEnv is defined by:

φ[g/f] = ⟨φ_{0}, …, φ_{j−1}, λf_{j}: (Fun_{j})_{⊥}.(f_{j} = f → g | (φ)_{j}(f_{j})), φ_{j+1}, …, φ_{m−1}⟩.

Again equations (i)–(v) are taken over from Chapter 1 and equation (vi) should be as expected from previous discussions. Again there is a slight awkwardness in treating syntax in terms of sets. Further this semantics corresponds to call-by-name (see Exercise 33, below) and the reader may wonder how call-by-value can be catered for in the present framework. Finally we note that the semantic equation for assignments in Chapter 1 carries over to the present situation without any alteration.

Exercises

1. Let D be a cpo. Use the external axiomatisation of Cartesian product to show that ⟨f_{0}, …, f_{n−1}⟩ ∘ g = ⟨f_{0} ∘ g, …, f_{n−1} ∘ g⟩ and then prove the functor laws for ∏. Define Δ_{D}: D → D × ⋯ × D (the diagonal map) by: Δ_{D} = ⟨id_{D}, …, id_{D}⟩ and show that: ⟨f_{0}, …, f_{n−1}⟩ = (f_{0} × ⋯ × f_{n−1}) ∘ Δ_{D}.

2. Prove the isomorphisms: U × D ≅ D × U ≅ D; D × E ≅ E × D; D × (E × F) ≅ (D × E) × F. Formulate and prove general versions of these commutative and associative laws for arbitrary finite products.

3. For any map δ: [m] → [n] (where [m] = {j ∈ N | j < m} for any m in N) and cpos D_{0}, …, D_{n−1} and E_{0}, …, E_{m−1} where E_{j} = D_{δ(j)} define the natural substitution map S_{δ}: ∏_{i<n} D_{i} → ∏_{j<m} E_{j}. Show that S_{δ} ∘ S_{δ′} = S_{δ′∘δ}. Show that for any expression, e, of the metalanguage whose free variables are included in the list x_{0}: D_{0}, …, x_{n−1}: D_{n−1} and also in the list y_{0}: E_{0}, …, y_{m−1}: E_{m−1} (given via a map δ: [m] → [n] as above) we have: α[e; x_{0}, …, x_{n−1}] = α[e; y_{0}, …, y_{m−1}] ∘ S_{δ}.

4. Investigate products ∏_{i∈S} D_{i} over any set S. Is it the case that a function of infinitely many arguments is continuous iff it is continuous in each of its arguments separately? [Hint Consider the case S = ω (= N) and D_{i} = O 0 .] When the D_{i} are all the same cpo, D, we obtain a power, D^{S}. Show that T^{ω} ≅ T × T^{ω}. Why are T^{ω} and Tapes not isomorphic?

5. Let D and E_{0}, …, E_{n−1} be cpos. Show that for any continuous function f: D → ∏_{i<n} E_{i} there are unique maps f_{i}: D → E_{i} (i < n) such that the following diagram commutes:

[figure: D^{n}; _{∏i<n} E; _{∏i<n} f_{i}; f; D; Δ]

6. Show that ∏_{i<n} D_{i} is also the product in CPO_{⊥}. [Hint Check everything is strict.]

7. Check the isomorphisms: ⟨·, …, ·⟩: ∏_{i<n}(D → E_{i}) ≅ D → ∏_{i<n} E_{i}; (D → U) ≅ U; (U → D) ≅ D; D → E^{S} ≅ (D → E)^{S}.

8. Let C, D, E be cpos. Define pair: C → (D → (C × D)) by pair = Curry(id_{C×D}) = λx.λy.⟨x, y⟩. Show that for any continuous f: C → (D → E) there is a unique g: C × D → E (namely Curry^{−1}(f)) such that the following diagram commutes:

[figure: D → (C × D); (D → E); (id_{D} → g); f; C; pair]

Show Curry = λf.(id × f) ∘ pair and Curry^{−1} = λg.apply ∘ ⟨g ∘ π_{0}, π_{1}⟩.

9. Show that exponentiation preserves strictness giving a bifunctor →: CPO_{⊥}^{2} →CPO_{⊥} which in contravariant in its first argument and covariant in its second argument.

10. Show that every continuous function, p: T^{n} → T, can be defined from tt, ff and parcond as the only constants using the typed λ-calculus (you will only need first-order terms — those with no λ’s). A collection of type symbols so are (σ × τ) and (σ → τ); the cpos T_{σ} are defined by: T_{0} = T, T_{σ×τ} = T_{σ} × T_{τ}, T_{σ→τ} = T_{σ} → T_{τ}. Show that every element of every T_{σ} can be defined from tt, ff and parcond using the typed λ-calculus. [Warning This last part is a good deal harder.]

11. Let X_{0}, …, X_{n−1}, Y be sets. Show any function f: X_{0} × ⋯ X_{n−1} → Y has a maximal extension to a continuous function g: ∏_{i<n}(X_{i})_{⊥} → Y_{⊥}. Is parcond_{D} always such a maximal extension?

12. Both Milner and Vuillemin have given definitions of sequentiality. These depend on viewing a function f: ∏_{i<n} D_{i} → E as being of n arguments (viewed as being more or less arguments may change its character according to these definitions!). Such a function is M-sequential if either it is constant or there is an integer i (with 0 ≤ i < n) such that f is strict in its i-th argument ((x)_{i} = ⊥ implies f(x) = ⊥) and the function obtained by fixing its i-th argument (to, say, a_{i})

(λx_{0}: D_{0}, …, x_{i−1}: D_{i−1}, x_{i+1}: D_{i+1}, …, x_{n−1}: D_{n−1}.f(x_{0}, …, x_{i−1}, a_{i}, x_{i+1}, …, x_{n−1}))

is M-sequential. Also such a function is V-sequential iff either it is a constant or there is an integer i (with 0 ≤ i < n) such that y ⊒ x and (y)_{i} = (x)_{i} implies f(y) = f(x). Which of the functions of several arguments we have considered are sequential in one or other of these senses? Show that if D_{0}, …, D_{n−1}, E are all flat cpos then the two definitions are equivalent. Show that all sequential functions p: T^{n} → T are λ-definable using as constants tt, ff and cond.

13. Define the minimalisation operator \overline{μ}: (N → T) → T in the typed λ-calculus, using the primitive sequential functions on N and T. What about the function ∂: (N→T)→T? What is the greatest existential quantifier \overline{∃}: (N → T) → T you can define using the primitive functions and parcond? (See Exercise 1.14, 1.15).

14. We can define elements of Tapes by simultaneous fixed-points using functions defined by first-order terms with (0 · −), (1 · −) as consists such as:

x = 0 · 0 · 1 · y,
y = 1 · 0 · 0 · x.

In this way only ultimately periodic functions can be defined. What happens in the case of Btrees if we allow as constants numerals (for the corresponding numbers), tip and mktree?

15 (Bekic̆). Let f: D × E → D, g: D × E → E be continuous functions. We can solve the simultaneous fixed-point equations:

x = f(x, y),
y = g(x, y).

by a method of elimination. First define a parameterised solution to the first equation by: h(y) = μx.f(x, y), then substitute in the second to obtain the equation y = g(h(y), y) = k(y), say. Then show that \overline{x}, \overline{y} are the least simultaneous fixed-points of the above equations where \overline{y} = μy.k(y) and \overline{x} = h(\overline{y}). What does this amount to when f(x, y) is independent of y? What if, further, g does not depend on x?

16. Theorem 1 in Chapter 1 shows the validity of the following principle of recursion induction (McCarthy, Park). Let f: D → D be continuous. Then:

∀x: D.(f(x) ⊑ x ⇒ Y f ⊑ x).

Establish this principle using fixed-point induction.

17. Give examples of non-inclusive predicates on {P \atop ω}, Fun. Show that if P ⊆ D is inclusive D − P need not be; if R ⊆ D × E is inclusive ∀y.R(x, y) need not be; if R ⊆ D × E, S ⊆ E × F are inclusive, S ∘ R need not be.

18. Show that R ⊆ ∏_{i<n} D_{i} is inclusive iff it is inclusive in each argument taken separately.

19. Show, using fixed-point induction, the following principle of simultaneous fixed-point induction. Let D_{0}, …, D_{n−1} be cpos, R ⊆ ∏_{i<n} D_{i} be inclusive and f_{i}: ∏_{i<n} D_{i} → D_{i} (i < n) be continuous functions. Then:

\begin{matrix}[R(⊥, …, ⊥) ∧ (∀x_{0}: D_{0}, …, x_{n−1}: D_{n−1}.R(x_{0}, …, x_{n−1}) ⇒ R(f_{0}(x_{0}, …, x_{n−1}), …, f_{n−1}(x_{0}, …, x_{n−1})))] \\ ⇒ R(Y (⟨f_{0}, …, f_{n−1}⟩)). \end{matrix}

20. Let f: D → D, g: D → D be continuous functions. Show f(Y (g ∘ f)) = Y (f ∘ g). Show that if f⊥ = g⊥ and f and g commute (f ∘ g = g ∘ f) then Y f = Y (f ∘ g) = Y g. This and the next few exercises should be tried using fixed-point induction or recursion induction, as appropriate. (Try Exercise 15 this way too).

21. Let f: D → D, g: D → D be continuous functions. Show that if f ∘ f ∘ g = g ∘ f and f⊥ = g⊥ then Y f = Y g. [Warning This is hard by fixed-point induction. The only known proof needs an inclusive predicate defined by the conjunction of three inequalities (order relations of the form t ⊑ u).]

22. Define h: N → N recursively by: h(x) = h(x) + 1. Show h = ⊥. For a: D, h: D → D, and p: D → T define g: D^{2} → D recursively by: g(x, y) = (p(x) → g(x, h(y)) | a). Show g = ⊥.

23. For p: D → T, h: D → D, k: D → D define f, g: D^{2} → D recursively by:

\begin{aligned}f(x, y) & = (p(x) → y | h(f(k(x), y))), \\ g(x, y) & = (p(x) → y | g(k(x), h(y))). \end{aligned}

Show h(f(x, y)) = f(x, hy) and then show f = g.

24. Suppose a: D, p: D → T, d: D → D, b: D × D → D are continuous functions which satisfy the following axioms:

Associativity  ∀x, y, z: D.b(x, b(y, z)) = b(b(x, y), z).
Commutativity  ∀x, y: D.b(x, y) = b(y, x).
Left Identity  ∀x: D.b(a, x) = x.
Bistrictness  ∀x: D.b(⊥, x) = b(x, ⊥) = ⊥.

Define f: D → D, g: D^{2} → D recursively by:

\begin{aligned}f(x) & = (p(x) → a | b(x, f(d(x)))), \\ g(x, y) & = (p(x) → y | g(d(x), b(x, y))). \end{aligned}

Show g(x, y) = b(f(x), y) and deduce f(x) = g(x, a). Interpret this result when D = N, a = 1, p = Z, d = (· − 1) and b = ×. Why does fixed-point induction on f not help to show that ∂ ∘ f(x) = ∂(x) for all x in D (termination)? What does help?

25. Let D be a cpo. Show that Y_{D} = μF: ((D → D) → D).λf: (D → D).f(F f).

26. If D and E are partial orders, we say a function f: D→E is continuous iff it is monotonic and preserves lubs of increasing ω-chains (that is, if ⟨x_{n}⟩_{n∈ω} is an increasing ω-chain in D such that ⨆_{D} x_{n} exists then f(⨆_{D} x_{n}) = ⨆_{E} f(x_{n})). Is it the case that if D is any partial order with a least element, but which is not a cpo then there is a continuous function f: D → D with no fixed-point? This seems to be an open question — a solution would help show the necessity of considering cpos.

27. A fixed-point operator of type D is a function F_{D}: (D → D) → D (not necessarily continuous) such that for all continuous f: D → D we have f(F f) = F f; it is invariant iff for every automorphism, θ: D → D, we always have: F f = θ^{−1}(F (θ ∘ f ∘ θ^{−1})). What are the (continuous, invariant) fixed-point operators on T^{ω}? Show Y_{D} is always invariant.

28. A strict monic is a monic in CPO_{⊥}, i.e. a strict continuous function, m: D →_{⊥} E such that for any f, g: C →_{⊥} D, m ∘ f = m ∘ g implies f = g. A strict order monic is a strict continuous function m: D →_{⊥} E such that for any f, g: C →_{⊥} D, m ∘ f ⊑ m ∘ g implies f ⊑ g. Show that m: D →_{⊥} E is a strict monic iff for all x, y in D, m(x) = m(y) implies x = y; show it is a strict order monic iff for all x, y in D, m(x) ⊑ m(y) implies x ⊑ y. Let P ⊆ D be an inclusive predicate such that P(⊥). Show that P is a cpo under the order inherited from D and that the natural inclusion map ι: P →_{⊥} D is a strict order monic. Show that m: C →_{⊥} D is a strict order monic iff it factors as C →^{θ} _{⊥} P →^{ι} _{⊥} D (i.e. m = ι ∘ θ) where P ⊆ D is an inclusive predicate on D such that P(⊥) and θ is an isomorphism. We conclude that the strict order monics are the categorical equivalent of inclusive predicates containing ⊥. What about the inclusive predicates?

29. Show that fixed-point induction can be reformulated in the following way: For every f: D → D, if m: C → D is a strict order monic and g: C → C is a (necessarily unique) continuous function such that the following diagram commutes:

[figure: D; D; f; C; C; g; m; m]

then m(Y g) = Y f.

30. A collection, F_{D}, of fixed-point operators (one for each cpo D) is uniform iff wherever f: D → D, g: E → E and h: D →_{⊥} E are such that the following diagram commutes:

[figure: E; E; g; D; D; f; h; h]

then h(F_{D}f) = F_{D}g. Show that the collection, Y_{D}, is uniform and that it is the only uniform collection. [Hint Use Exercise 29.] This is further justification of our choice of least fixed-points. Show that invariance of each of a collection of fixed-point operators (one for each cpo) can be rephrased as uniformly w.r.t. automorphisms. It is an open question whether Y is the only collection of fixed-point operators invariant over the embeddings (see Chapter 4).

31. Show that C[[while b do s]] = C[[if b then (s; while b do s) else dummy]]. Define the semantics of a construct until b do s and show the equivalence, C[[while b do s]] = C[[until ¬b do s]] (with the evident semantics for ¬b).

32. Define a syntactic substitution, [e_{0}/x]e_{1} of expressions for identifiers in expressions and prove that E[[let x be e_{0} in e_{1}]] = E[[[e_{0}/x]e_{1}]]. Define a syntactic substitution [e_{0}/f_{n}(x_{0}, …, x_{n−1})]e_{1} of expressions for function symbols with indicated identifiers as parameters in expressions so that for example, [e_{0}/f_{1}(x_{0})](f_{1}(e_{1})) = [[e_{0}/f_{1}(x_{0})]e_{1}/x_{0}]e_{0}. Show that

E[[let f_{n}(x_{0}, …, x_{n−1}) be e_{0} in e_{1}]] = E[[[e_{0}/f_{n}(x_{0}, …, x_{n−1})]e_{1}]]

and also that

E[[letrec f_{n}(x_{0}, …, x_{n−1}) be e_{0} in e_{1}]] = E[[letrec f_{n}(x_{0}, …, x_{n−1}) be e_{0} in [e_{0}/f_{n}(x_{0}, …, x_{n−1})]e_{1}]].

These last two equations show why our semantics is “call-by-name” — that Algol copy rule is valid. [Warning Make sure that free identifiers or function symbols are not captured by binding mechanisms when defining your syntactic substitution.]

33. Extend Imp to allow assignments and recursive assignments to functions thus:

s ::= f_{n}(x_{0}, …, x_{n−1}) := e | f_{n}(x_{0}, …, x_{n−1}) ⇒ e.

This is only possible because FEnv is part of the state. Given an alternative semantics of Imp without this extension in which FEnv is part of the environment so that S = IEnv and C has type C: Stat→(FEnv→C) (where C = S → S).

34. Write a few example programs and prove that they denote what you think they ought to.

35. Consider the combination of Imp and Dec given in Chapter 1. Can you define a syntactic substitution of expressions for identifiers in statements so that C[[x := e; s]] and C[[[e/x]s]] bear a suitably close relationship?

3. Other Constructions

In the last chapter we were able to give the semantics of recursively defined functions which take their arguments by call-by-name; this was accomplished with the aid of the product and function-space constructions. Now we will consider call-by-value as a prop for introducing the strict versions of these constructions. This will entail consideration of CPO_{⊥} rather than CPO.

Under the call-by-value regime, if the evaluation of an expression, e, in Exp does not terminate then neither does that of f_{1}(e). So we expect that f_{1} should denote a strict function. To ensure this we will define the cpo, (V →_{⊥} V) of the strict functions and when f_{1} is recursively defined we will take its denotation as the least fixed-point of a suitable functional, F: (V →_{⊥} V) → (V →_{⊥} V). In the case of functions of n arguments, if the evaluation of any one of the expressions e_{0}, …, e_{n−1} does not terminate then, under the call-by-value regime, neither does the evaluation of f_{n}(e_{0}, …, e_{n−1}) terminate. Thus the denotation of f_{n} should, perhaps, be an n-strict function, f_{n}: V^{n} →_{⊥} V (that is, if for some i, with i < n, (x)_{i} = ⊥ then f_{n}(x) = ⊥). For recursively defined functions this would lend us to consider cpos of n-strict functions of n arguments. In the case of arbitrary continuous functions of n-arguments we consider products such as V^{n}, and unary functions V^{n} → V rather than create special cpos of functions of n-arguments. In just the same way we will consider strict products and unary strict functions.

Let D_{0}, …, D_{n−1} be n cpos. Their strict product (= smash product), ⨂_{i<n} D_{i} is the subset, {x ∈ ∏_{i<n} D_{i} | (∀i < n.(x)_{i} ≠ ⊥) ∨ (x = ⊥)}, of ∏_{i<n} D_{i} with the coordinatewise ordering inherited from ∏_{i<n} D_{i}. Sometimes we write D_{0} ⊗ ⋯ ⊗ D_{n−1} for ⨂_{i<n} D_{i} or D^{◯^{n}} when the D_{i} are all the same cpo, D. The smash product is a cpo; indeed it has the same least element and the same lubs of increasing sequences as the Cartesian product. Thus it is even a subcpo of the Cartesian product and so the natural inclusion map ι: ⨂_{i<n} D_{i} →_{⊥} ∏_{i<n} D_{i} is continuous. There is another natural continuous map in the opposite direction, namely ⊗: ∏_{i<n} D_{i} →_{⊥} ⨂_{i<n} D_{i} where:

⊗(x) = \{ \begin{matrix}x & (∀i < n.(x)_{i} ≠ ⊥), \\ ⊥ & (otherwise). \end{matrix}

Note that ⊗ is n-strict. When we look at the universal property for the smash product we shall see that ⊗ is the universal n-strict map.

Let D and E be cpos. Their strict function space, D →_{⊥} E, is the set {f: D → E | f(⊥) = ⊥} of strict continuous functions from D to E, with the pointwise order inherited from D → E. Again we find that (D →_{⊥} E) is a subcpo of (D → E), meaning that it has the same least element and lubs of increasing sequences. Again the natural inclusion map ι: (D →_{⊥} E) → (D → E) is continuous. We now introduce our last piece of metalanguage:

E10. If e is an expression of type E and x is a variable of type D then (λ_{⊥}x: D.e) is an expression of type (D →_{⊥} E) which is to have the same denotation as (λx: D.(∂x → e | ⊥)) (but note the types are different). When D is clear from the context (λ_{⊥}x: D.e) may be abbreviated to (λ_{⊥}x.e).

For example this strict kind of abstraction allows us to define a map strict: (D → E) → (D →_{⊥} E) by:

strict = λf: D → E.λ_{⊥}d: D.f(d).

Whenever A is a subcpo of B we will include an anonymous constant, ι, for the inclusion map ι: A → B in our metalanguage. Often we will write e instead of ι(e) when no confusion thereby results. For example when f: D →_{⊥} E and x: D, we might write f(x) instead of ι(f)(x). Again we introduce the abbreviation (λ_{⊥}x_{0}: D_{0}, …, x_{n−1}: D_{n−1}.e) to stand for:

λ_{⊥}w: ⨂_{i<n} D_{i}.((λ_{⊥}x_{0}: D_{0}.(… (λ_{⊥}x_{n−1}: D_{n−1}.e) …))((w)_{0}) … ((w)_{n−1}));

when the D_{i} are clear from the context we might just write (λ_{⊥}x_{0}, …, x_{n−1}.e) instead. Thus, for example, we can define the composition map, ∘, of strict functions, of type ((E →_{⊥} F) ⊗ (D →_{⊥} E)) →_{⊥} (D →_{⊥} F) by (λ_{⊥}g, f.λ_{⊥}d.g(f(d))). Finally, we will often write e_{0} ⊗ ⋯ ⊗ e_{n−1} as an abbreviation for ⊗(e_{0}, …, e_{n−1}).

Turning to categorical considerations we first observe that ⊗: ∏_{i<n} D_{i} →_{⊥} ⨂_{i<n} D_{i} is universal in the sense that if f: ∏_{i<n} D_{i} →_{⊥} E is any n-strict continuous map then there is a unique strict continuous g: ⨂_{i<n} D_{i} →_{⊥} E such that the following diagram commutes:

[figure: _{⨂i<n} D_{i}; E; g; f; _{∏i<n} D_{i}; ⊗]

For if this diagram commutes for a given g we have g = f ∘ι as: g(w) = g(⊗(ι(w))) (as ⊗∘ι = id) = f(ι(w)). This proves uniqueness. For existence let g be the strict function f ∘ ι. Then if w ∈ ∏_{i<n} D_{i} then either (w)_{i} = ⊥ for some i, with i < n, or not. In the first case f(w) = ⊥ and g ∘ ⊗(w) = g(⊥) = ⊥; in the second case g ∘ ⊗(w) = (f ∘ ι)(w) = f(w), proving existence. This universal property shows how n-strict functions f: ∏_{i<n} D_{i} →_{⊥} E are to be replaced by strict functions, g: ⨂_{i<n} D_{i} →_{⊥} E (see Exercise 1).

One now easily sees that the following external axioms characterise this universal property:

External Axiomatisation.

1. ∀f: ∏_{i<n} D_{i} →_{⊥} E.(f n-strict) ⇒ f = (f ∘ ι) ∘ ⊗.

2. ∀g: ⨂_{i<n} D_{i} →_{⊥} E.g = (g ∘ ⊗) ∘ ι.

Internal Axiomatisation.

1. ∀x_{0}: D_{0}, …, ∀x_{n−1}: D_{n−1}.π_{i}(x_{0} ⊗ ⋯ ⊗ x_{n−1}) = (((∂x_{0}) and … and (∂x_{n−1})) → x_{i} | ⊥).

2. ∀w: ⨂_{i<n} D_{i}.w = π_{0}(w) ⊗ ⋯ ⊗ π_{n−1}(w).

These axioms are clearly true. To see they imply the external ones we begin by showing that they imply ⊗ is n-strict. It is given that ⊗ is strict (which is also a consequence of 2). Suppose x_{0}: D_{0}, …, x_{n−1}: D_{n−1} and some x_{i} is ⊥. Then by part 1, π_{i}(x_{0}⊗⋯⊗x_{n−1}) = ⊥ for all i (i < n) and so by part 2, x_{0}⊗⋯⊗x_{n−1} = ⊥. For part 1, suppose x_{0}: D_{0}, …, x_{n−1}: D_{n−1}. If some x_{i} is ⊥ then: (f ∘ ι) ∘ ⊗(x_{0}, …, x_{n−1}) = f ∘ ι(⊥) = ⊥ = f(x_{0}, …, x_{n−1}) as f is n-strict. Otherwise:

(f ∘ ι) ∘ ⊗(x_{0}, …, x_{n−1}) = f(π_{0}(x_{0} ⊗ ⋯ ⊗ x_{n−1}), …, π_{n−1}(x_{0} ⊗ ⋯ ⊗ x_{n−1}))
= f(x_{0}, …, x_{n−1})  by Axiom 1.

Finally we show that ⊗ ∘ ι = id, to prove the second external axiom. We have:

⊗ ∘ ι(w) = ⊗(π_{0}(w), …, π_{n−1}(w)) = w by Axiom 2.

Note that if D and E are flat cpos so is D ⊗ E. For example T ⊗ T is drawn in Figure VIII:

[figure: ⊥; ⟨tt, tt⟩; ⟨tt, ff ⟩; ⟨ff , tt⟩; ⟨ff , ff ⟩]

Figure VIII: The cpo T ⊗ T.

This idea will help us to consider syntax as a cpo, in a systematic way, as mentioned above. Note too, that it follows that when f: X_{0} ×⋯×X_{n−1} →Y is a function on sets, then f has a unique extension to a continuous function, f̂: (X_{0})_{⊥} ⊗ ⋯ ⊗ (X_{n−1})_{⊥} →_{⊥} Y_{⊥} and the extension, f_{⊥}, considered in Chapter 2 is just ι(f̂) ∘ ⊗. Conversely, every n-strict function on flat cpos is the extension of an ordinary function on the corresponding sets. So we see that the strict constructions allow us to import functions of several arguments over sets more accurately than the ordinary product and function space constructions. But, of course, we still need many continuous functions other than the n-strict ones; it is absolutely necessary to have cond: T × D × D → D for instance.

We conclude the discussion of the smash product construction by showing that it can be considered as a covariant functor, ⨂ : CPO_{⊥}^{n} → CPO_{⊥} by defining its action on morphisms f_{i}: D_{i} →_{⊥} E_{i} (i < n) by:

⨂_{i<n} f_{i} = ⊗ ∘ (∏_{i<n} f_{i}) ∘ ι

where we are considering ∏ as a functor, ∏: CPO_{⊥}^{n} → CPO_{⊥} (see Exercise 2.6). In this case the functor laws are:

(i)  ⨂_{i<n} id_{D_{i}} = id_{⨂ D_{i}},
(ii)  ⨂_{i<n}(g_{i} ∘ f_{i}) = (⨂_{i<n} g_{i}) ∘ (⨂_{i<n} f_{i}).

The universal property for the strict function space, D →_{⊥} E is specified in exactly the same way as that for the function space, D → E but using the smash product in place of the Cartesian one. Define apply: ((D →_{⊥} E) ⊗ D) →_{⊥} E by:

apply = λ_{⊥}f: D →_{⊥} E.x: D.f(x).

Then if f: F ⊗ D →_{⊥} E is any continuous function there is a unique mediating g: F →_{⊥} (D →_{⊥} E) such that the following diagram commutes:

[figure: (D →_{⊥} E) ⊗ D; F ⊗ D; g ⊗ id_{D}; E; apply; f]

In fact g must be Curry(f) where Curry: ((F ⊗ D) →_{⊥} E) →_{⊥} (F →_{⊥} (D →_{⊥} E)) is defined by:

Curry = λ_{⊥}f: (F ⊗ D) →_{⊥} E.λ_{⊥}v: F.λ_{⊥}d: D.f(v ⊗ d).

External Axiomatisation.

1. ∀f: (F ⊗ D) →_{⊥} E.f = apply ∘ (Curry(f) ⊗ id_{D}).

2. ∀g: F →_{⊥} (D →_{⊥} E).g = Curry(apply ∘ (g ⊗ id_{D})).

Internal Axiomatisation.

1. β_{⊥}-reduction: (λ_{⊥}x.e)(x) = (∂x → e | ⊥).

2. η_{⊥}-reduction: λ_{⊥}x.f(x) = f (f: D →_{⊥} E, x: D).

Note that 1 and 2 are largely axioms on ι (assuming ordinary β-reduction and η-reduction). Thus 1 may be rephrased as: ι(λ_{⊥}x.e) = λx.(∂x → e | ⊥) and 2 may be rephrased as: ι(f)(⊥) = ⊥.

As a functor, →_{⊥}, is defined just like →. For f: B →_{⊥} A, f′: A′ →_{⊥} B′ we define (f →_{⊥} f′): (A →_{⊥} A′) →_{⊥} (B →_{⊥} B′) by:

(f →_{⊥} f′) = λ_{⊥}x: A →_{⊥} A′.f′ ∘ x ∘ f.

We obtain a functor, →_{⊥}: CPO_{⊥}^{2} → CPO_{⊥} which is contravariant in its first argument and covariant in its second argument so that the functor laws are:

(i)  id_{D} →_{⊥} id_{E} = id_{(D→_{⊥}E)},
(ii)  (f ∘ g) →_{⊥} (g′ ∘ f′) = (g →_{⊥} g′) ∘ (f →_{⊥} f′).

for f, f′, g, g′ of the appropriate types. In category-theoretic jargon what we have essentially shown about ⊗, →_{⊥} and their relation to each other is that CPO_{⊥} equipped with ⊗ and →_{⊥} is a closed category.

It is now quite straightforward to change the semantics of Dec to correspond to call-by-value. We keep the same syntax as in Chapter 2. For the semantic domains we again take V to be a fixed cpo of values; we can now model IEnv more accurately as (Id_{⊥}→_{⊥}V_{⊥}) and FEnv should now be ∏_{j<m}(Fun_{j})_{⊥}→_{⊥}(V^{◯^{j}}→_{⊥}V). We assume the basic operation also take their arguments by value and so we have I_{i}: Op_{i} → (V^{◯^{i}} →_{⊥} V) (i < n). Next B: BExp → ((IEnv × FEnv) → T) and finally E: Exp → ((IEnv × FEnv) → V) is defined by structural induction:

(i) (as in Chapter 2);

E[[o_{i}(e_{0}, …, e_{n−1})]] = λρ: IEnv, φ: FEnv.I[[o_{i}]](E[[e_{0}]](ρ, φ) ⊗ ⋯ ⊗ E[[e_{i−1}]](ρ, φ)) (ii)_{i} (i < n);

(iii) (as in Chapter 2); (iv) (as in Chapter 2);

E[[let f_{j}(x_{0}, …, x_{j−1}) be e_{0} in e_{1}]] = (v)_{j}

λρ: IEnv, φ: FEnv.E[[e_{1}]](ρ, φ[(λ_{⊥}w: V^{◯^{j}}.E[[e_{0}]](ρ[(w)_{0}/x_{0}] … [(w)_{j−1}/x_{j−1}], φ))/f_{j}]) (j < m);

E[[letrec f_{j}(x_{0}, …, x_{j−1}) be e_{0} in e_{1}]] =

(vi)_{j}

λρ: IEnv, φ: FEnv.E[[e_{1}]](ρ, φ[μf: V^{◯^{j}} →_{⊥} V.(λ_{⊥}w: V^{◯^{j}}.E[[e_{0}]](ρ[(w)_{0}/x_{0}] … [(w)_{j−1}/x_{j−1}],

φ[f/f_{j}]))/f_{j}]) (j < m).

Here ·[·/·]: IEnv × V × Id_{⊥} → IEnv is defined by:

ρ[v/x] = λ_{⊥}y: Id_{⊥}.((v = x) → v | ρ[[y]])

and the definition of ·[·/·]: (FEnv × (V^{◯^{j}} →_{⊥} V) × (Fun_{j})_{⊥}) → FEnv is left to the reader.

In order to introduce our next construction suppose we want to specify V so that expressions can have either integers or truth-values as their values and then we can identify BExp with Exp. Then we expect that an expression evaluates to an integer, or to a truth-values or else evaluation does not terminate. So we expect V to be as in Figure IX:

[figure: …; …; ⊥; 0; 1; ⋯; n; ⋯; tt; ff]

Figure IX: The cpo N + T.

This cpo is called the (coalesced) sums of N and T and is useful whenever values of identifiers can be in any of several different cpos — that is they are, in a sense, of ambiguous type. We now turn to the general construction.

Let D_{0}, …, D_{n−1} be cpos. Their coalesced sum (= amalgamated sum), ∑_{i<n} D_{i} is the set:

( ⋃_{i<n}{⟨i, d⟩ | d ∈ D_{i} ∧ d ≠ ⊥}) ∪ {⊥}

with the order

x ⊑ y iff (x = ⊥) or (∃i < n.∃d, d′ ∈ D_{i}.d ⊑ d′ ∧ x = ⟨i, d⟩ ∧ y = ⟨i, d′⟩).

Thus the order is inherited from the D_{i} with the additional requirement that the ⊥_{D_{i}} are identified. A picture for the case n = 2 should help:

[figure: ⊥; ^{D^{0}}; ^{D^{1}}]
Figure X: The cpo D_{0} + D_{1}.

Sometimes we write D_{0} + ⋯ + D_{n−1} for ∑_{i<n} D_{i}. Note that the sum is a cpo as all non-trivial increasing chains essentially lie within one or other of the D_{i}. This is also the reason why the natural injection functions, in_{i}: D_{i} →_{⊥} ∑_{i<n} D_{i} (i < n) are continuous where:

in_{i}(d) = \{ \begin{matrix}⊥ & (d = ⊥), \\ ⟨i, d⟩ & (otherwise). \end{matrix}

These injections (sometimes written ⨿_{i}) show how the sum is a compound type of cpo which contains all its summands; this leads to the following universal property. Let f_{i}: ∑_{i<n} D_{i} →_{⊥} E such that for all i with i < n the following diagram commutes.

[figure: _{∑i<n} D_{i}; E; h; f_{i}; D_{i}; in_{i}]

What this says is that ∑_{i<n} D_{i} is the categorical sum in CPO_{⊥}; it is dual to the product. Clearly h is unique as we must have h(⊥) = ⊥ and h(⟨i, d⟩) = h(in_{i}(d)) = f_{i}(d), when d ≠ ⊥, and this determines h as a strict continuous function which makes the diagram commute. We write h as [f_{0}, …, f_{n−1}] and one easily checks that [·, …, ·]: (∏_{i<n}(D_{i} →_{⊥} E)) → ((∑_{i<n} D_{i}) →_{⊥} E) is continuous. Note the case n = 0 when the sum ∑_{i<0} D_{i} is just U and we see that for any cpo E there is a unique morphism [ ]: U → E (namely ⊥) showing that U is the initial object in CPO_{⊥}.

External Axiomatisation.

1. ∀f_{0}: D_{0} →_{⊥} E. . . . .∀f_{n−1}: D_{n−1} →_{⊥} E.∀i < n.[f_{0}, …, f_{n−1}] ∘ in_{i} = f_{i} (0 ≤ i < n).

2. ∀h: ∑_{i<n} D_{i} →_{⊥} E.h = [h ∘ in_{0}, …, h ∘ in_{n−1}].

To give the internal axiomatisation it is convenient to introduce a few more functions. First projection functions out_{i}: ∑_{i<n} D_{i} →_{⊥} D_{i} (i < n) are defined by:

out_{i} = [⊥, …, ⊥, λ_{⊥}x: D_{i}.x, ⊥, …, ⊥]

and next discriminator functions, is_{i}: ∑_{i<n} D_{i} →_{⊥} T are defined by:

is_{i} = [λ_{⊥}x_{0}.ff , …, λ_{⊥}x_{i−1}.ff , λ_{⊥}x_{i}.tt, λ_{⊥}x_{i+1}.ff , …, λ_{⊥}x_{n−1}.ff ].

Sometimes out_{i} is written as (· | D_{i}) when the D_{i} are all different.

Internal Axiomatisation.

1_{i}. ∀x: D_{i}.x = out_{i}(in_{i}(x)) (0 ≤ i < n).

2. ∀x: ∑_{i<n} D_{i}.x = (is_{0}(x) → in_{0}(out_{0}(x)) | (is_{1}(x) → in_{1}(out_{1}(x))

| … | (is_{n−1} → in_{n−1}(out_{n−1}(x)) | ⊥) …)).

To obtain the external axioms from the internal ones we must define [·, …, ·] in terms of the functions out_{i}, is_{i} by:

[·, …, ·] = λw: (∏_{i<n}(D_{i} →_{⊥} E)).λ_{⊥}x. ∑_{i<n} D_{i}.(is_{0}(x) → (w ↓ 0)(out_{0}(x)) | (is_{1}(x) → (w ↓ 1)(out_{1}(x)) | …
| (is_{n−1}(x) → (w ↓ n − 1)(out_{n−1}(x)) | ⊥) …)).

Finally to consider ∑ as a covariant functor ∑: CPO_{⊥}^{n} → CPO_{⊥} we define, for f_{i}: D_{i} →_{⊥} E_{i} (i < n):

∑_{i<n} f_{i} = [in_{0} ∘ f_{0}, …, in_{n−1} ∘ f_{n−1}]

where in_{i}: E_{i} →_{⊥} ∑ E_{i} and note the appropriate functor laws:

(i)  ∑_{i<n} in_{D_{i}} = id_{∑ D_{i}},
(ii)  ∑_{i<n}(g_{i} ∘ f_{i}) = (∑_{i<n} g_{i}) ∘ (∑_{i<n} f_{i}).

Returning to our example where V = N + T we can now see how to specify Dec in a bit more detail. We could take Op_{0} = {0, true, false}, Op_{1} = {succ, pred, zero} and Op_{n} = ∅ for n > 1. Then BExp could be given by the trivial grammar: BExp ::= Exp. The functions I_{n} (n < 2) are given by:

I[[0]] = inl(0); I[[true]] = inr(tt); I[[false]] = inr(ff ); I[[succ]] = inl ∘ (+1) ∘ outl; I[[pred]] = inl ∘ (−1) ∘ outl; I[[zero]] = inr ∘ (z) ∘ outl.

Note that when there are just two summands we often use (as here) inl, inr, outl, outr, isl, isr instead of respectively in_{0}, in_{1}, out_{0}, out_{1}, is_{0}, is_{1}. Finally B: BExp → ((IEnv × FEnv) → T) is specified by:

(i)  B[[e]] = λρ: IEnv, φ: FEnv.outr(E[[e]](ρ, φ)).

The other details are filled in as usual with whatever parameter-calling discipline is desired. Note that B and E are mutually recursive, and are still well-defined by structural induction on (the parse trees of) expressions.

The final construction considered here — lifting — does not seem to be of great significance by itself but, rather, is often useful in combination with other constructions in order to achieve an accurate model of computation. Categorically, lifting allows continuous functions to be turned into strict continuous functions.

Let D be a cpo. Its lifting D_{⊥} is the set {⟨o, d⟩ | d ∈ D} ∪ {⊥} with the ordering:

x ⊑ y iff (x = ⊥) or (∃d, d′ ∈ D.d ⊑ d′ ∧ x = ⟨o, d⟩ ∧ y = ⟨o, d′⟩).

Clearly this makes D_{⊥} a cpo; roughly speaking one notes that all non-trivial chains in D_{⊥} are (eventually) in D and the lub is then inherited from D. This observation also shows why the function up: D → D_{⊥} is continuous where:

up(d) = ⟨o, d⟩ (d ∈ D).

The cpo D_{⊥} can be pictured thus:

[figure: ⊥; D]

Figure XI: The cpo D_{⊥}.

The universal property for D_{⊥} says that up: D → D_{⊥} is the basic example of a continuous function from D: all others can be obtained from it via a factorisation through a strict function. For if f: D → E is any continuous function then there is a unique strict continuous function h: D_{⊥} →_{⊥} E such that the following diagram commutes:

[figure: D_{⊥}; E; h; f; D; up]

For we must have h(⊥) = ⊥ and, for each member, d, of D, h(⟨o, d⟩) = h(up(d)) = f(d). This proves uniqueness and existence too should now be clear. We write lift(f) for h and indeed lift: (D→E)→(D_{⊥} →E) is a continuous function.

External Axiomatisation.

1. ∀f: D → E.f = lift(f) ∘ up.

2. ∀h: D_{⊥} →_{⊥} E.h = lift(h ∘ up).

For the internal axiomatisation it is convenient to define as auxiliary functions, down: D_{⊥} →_{⊥} D and the “termination predicate” ∂: D_{⊥} →_{⊥} T by:

down = lift(id_{D}),
∂ = lift(λx: D.tt).

Internal Axiomatisation.

1. ∀x: D.x = down(up(x)).

2. ∀y: D_{⊥}.y = (∂y → up(down(y)) | ⊥).

To establish the external axiomatisation using the internal ones one notes that:

lift = λf: D → E.λ_{⊥}d: D_{⊥}.(∂d → f(down(d)) | ⊥).

To view (·)_{⊥} as a covariant functor: (·)_{⊥}: CPO → CPO_{⊥} we define for f: D → E:

f_{⊥} = lift(up ∘ f).

The functor laws are:

(i)  (id_{D})_{⊥} = (id_{D_{⊥}})
(ii)  (g ∘ f)_{⊥} = g_{⊥} ∘ f_{⊥}

A typical use of lifting occurs when we do not want to amalgamate the bottom elements of the summands of ∑_{i<n} D_{i} in the case where they play different computational roles. Instead we might use the separated sum ∑_{i<n}(D_{i})_{⊥}; on occasion we might prefer semi-separated sums such as D_{⊥} + E.

[figure: ⊥; D; E; ⊥; D; E]
Figure XII: The cpos D_{⊥} + E_{⊥} and D_{⊥} + E.

An example can be found in Exercise 21.

Exercises

1. Let D_{0}, …, D_{n−1}, E be cpos. Define the cpo, Strict_{n}(D_{0}, …, D_{n−1}; E) of n-strict continuous functions and establish the isomorphism:

Strict_{n}(D_{0}, …, D_{n−1}; E) ≅ (⨂_{i<n} D_{i}) →_{⊥} E.

Prove the functor laws for ⨂. What difficulties arise if you consider infinite smash products?

2 (Lehmann-Smyth). A morphism f: D →_{⊥} E is very strict if f(x) = ⊥ iff x = ⊥. Show that ⨂ is the categorical product in the subcategory of the very strict morphisms.

3. Show that ⨂ obeys commutative and associative laws. Show U ⊗ D ≅ U and O 0 ⊗ D ≅ D.

4. Let D_{0}, …, D_{n−1}, E be cpos. A continuous function, f: ∏_{i<n} D_{i} → E is (m, n) strict iff whenever any m of x_{0}, …, x_{n−1} are ⊥ then f(x_{0}, …, x_{n−1}) is ⊥ (x_{0}: D_{0}, …, x_{n−1}: D_{n−1}). Define a cpo Strict_{m,n}(D_{0}, …, D_{n−1}; E) and a product Prod_{m,n}(D_{0}, …, D_{n−1}) and prove:

Strict_{m,n}(D_{0}, …, D_{n−1}; E) ≅ Prod_{m,n}(D_{0}, …, D_{n−1}) →_{⊥} E.

5. Fill in the details on the connection between the external and internal axiomatisations of →_{⊥}. Show that f →_{⊥} g = Curry(g ∘ apply ∘ (id ⊗ f)) and use this to prove the functor laws for →_{⊥}. Why can’t →_{⊥} be extended to a bifunctor over CPO?

6. Establish the following isomorphisms: Curry: (D ⊗ E) →_{⊥} F ≅ D →_{⊥} (E →_{⊥} F); X_{⊥} →_{⊥} D ≅ D^{X} (X is a set); U →_{⊥} D ≅ D →_{⊥} U ≅ U; O 0 →_{⊥} D ≅ D; D →_{⊥} (∏_{i<n} E_{i}) ≅ ∏_{i<n}(D →_{⊥} E_{i}).

7. Formulate and prove the analogue of Exercise 2.9, but with →_{⊥} in place of →.

8. Make the necessary changes in the denotational semantics of Imp when we use the more accurate S_{⊥} →_{⊥} S_{⊥} in place of S_{⊥} → S_{⊥}.

9. Show that, with the semantics of call-by-value the following equivalence holds:

E[[let f_{j}(x_{0}, …, x_{j−1}) be e in f_{j}(a_{0}(), …, a_{j−1}())]] = E[[[a_{0}()/x_{0}] … [a_{j−1}()/x_{j−1}]e]]

where the a_{l} are constants (elements of Op_{0}) such that I_{0}[[a_{l}()]] ≠ ⊥. Show that the more general equivalence in Exercise 2.32 fails. What is the appropriate equivalence for calls of recursively defined functions?

10. Fill in the details on the connection between the external and internal axiomatisations of ∑. Show that h ∘ [f_{0}, …, f_{n−1}] = [h ∘ f_{0}, …, h ∘ f_{n−1}] and use this result to establish the functor laws for ∑. Formulate and prove the analogue of Exercise 2.5 for ∑ (the analogue of Δ is written as ∇ and is called the codiagonal function).

11. Show that CPO does not have any initial object or a binary categorical sum. What goes wrong if you attempt to extend ∑ to a functor over CPO?

12. Show that ∑ obeys suitable commutative and associative laws. Establish the isomorphisms: U + D ≅ D; T ≅ O 0 + O 0 ; N ≅ O 0 + N; D ⊗ (E + F) ≅ (D ⊗ E) + (D ⊗ F); T ⊗ D ≅ D_{⊥} + D_{⊥}. Why do the analogous isomorphisms for × fail?

13. Show that the flat cpo, X_{⊥}, associated with any set X can be characterised by the following universal property of the natural injection function, ι: X → X_{⊥}: if f: X → D is any function from X to the carrier of a cpo D then there is a unique h: X_{⊥} →_{⊥} D such that the following diagram commutes:

[figure: X_{⊥}; D; h; f; X; ι]

In the category of sets, the categorical sum of two sets X and Y is their disjoint union, X + Y =^{def} {⟨0, x⟩ | x ∈ X} ∪ {⟨1, y⟩ | y ∈ Y} and the categorical product is the ordinary Cartesian product. Show that for any sets X and Y: (X + Y)_{⊥} ≅ X_{⊥} + Y_{⊥} and (X × Y)_{⊥} ≅ X_{⊥} ⊗ Y_{⊥}.

14. Investigate infinite sums, ∑_{i∈S} D_{i}.

15. Let D be a cpo. Let D^{∗} =^{def} ∑_{i∈ω} D^{◯^{i}}, which is just the infinite sum, O 0 + D + (D ⊗ D) + · · ·. What is (N)^{∗}? Define the natural functions, nil: O 0 → D^{∗}, cons: D ⊗ D^{∗} → D^{∗}. Show that they are universal in the sense that if E is a cpo and we have nil′: O 0 →_{⊥} E, cons′: D ⊗ E →_{⊥} E then there is a unique h: D^{∗} →_{⊥} E such that the following two diagrams commute:

[figure: D^{∗}; E; h; nil′; O 0; nil; D^{∗}; E^{∗}; h; D ⊗ D^{∗}; D ⊗ E; id_{D} ⊗ h; cons; cons′]

Give internal and external axiomatisations of D^{∗} relating them to each other and the above universal property. [Hint For the internal axiomatisation you may find it helpful to introduce functions, isnil: D^{∗}→_{⊥}T, head: D^{∗} →_{⊥} D, and tail: D^{∗} →_{⊥} D^{∗}.] Show how (·)^{∗} can be considered as a covariant functor, (·)^{∗}: CPO_{⊥} → CPO_{⊥}. Establish the isomorphism, D^{∗} ≅ O 0 + D ⊗ D^{∗}.

16. Define λ: D^{∗}, ι: D →_{⊥} D^{∗}, ·: D^{∗} ⊗ D^{∗} →_{⊥} D^{∗}, by:

λ = nil(⊤),
ι = λ_{⊥}d: D.cons(d ⊗ λ),
· = λ_{⊥}x: D^{∗}, y: D^{∗}.(isnil(x) → y | cons(head(x), tail(x) · y)).

Note the infix notation used in the recursive definition of ·; in general e · e′ is to abbreviate ·(e ⊗ e′). Show that (D^{∗}, ·, λ) is a monoid in that the following equations hold:

(1) Identity ∀x: D^{∗}.λ · x = x · λ = x.

(2) Associativity ∀x, y, z: D^{∗}.x · (y · z) = (x · y) · z.

Show that (D, D^{∗}, λ, ι, ·) is the free monoid over D in the sense that if we have a structure (D, E, λ′, ι′, ·′) where E is a cpo, λ′: E, ι′: D →_{⊥} E, ·′: E ⊗ E →_{⊥} E and (E, λ′, ·′) is a monoid in the above sense then there is a unique h: D^{∗} →_{⊥} E such that the following diagram commutes:

[figure: D^{∗}; E; h; ι′; D; ι]

and such that h is a monoid homomorphism in that h(λ) = λ′ and for all x, y in D^{∗}, h(x · y) = h(x) ·′ h(y).

17. Show that the external axioms for the lifting construction follow from the internal ones and establish the functor laws. Show that lifting can be taken as a covariant functor (·)_{⊥}: CPO_{⊥} → CPO_{⊥}.

18. Establish the isomorphism ω ≅ ω_{⊥} and, more generally, X^{∞} ≅ (X_{⊥}) ⊗ X^{∞} (see Exercise 1.17). Show that Tapes ≅ Tapes_{⊥} + Tapes_{⊥}, D_{⊥} ⊗ E_{⊥} ≅ (D × E)_{⊥}, Btrees ≅ N + (Btrees_{⊥} ⊗ Btrees_{⊥}) and find a cpo D such that D ≅ N ⊗ D_{⊥} ⊗ D_{⊥}.

19. Establish the following universal property of the maps in_{i} ∘ up: D_{i} → ∑(D_{i})_{⊥}: if f_{i}: D_{i} → E (i < n) are continuous maps then there is a unique h: ∑(D_{i})_{⊥} →_{⊥} E such that, for all i, with i < n, the following diagram commutes:

[figure: ∑ (D_{i})_{⊥}; E; h; f_{i}; D_{i}; in_{i} ∘ up]

and show, too, that ∏_{i<n}(D_{i} → E) ≅ (∑_{i<n}(D_{i})_{⊥}) →_{⊥} E. Consider the semi-separated sum D_{⊥} + E in the analogous way.

20. Investigate ∑_{n∈ω}(D^{n})_{⊥} (= (D_{⊥})^{∗}) in an analogous way to D^{∗} (see Exercises 15 and 16). What happens in the other two cases, namely ∑ D^{n} and ∑(D^{◯^{n}})_{⊥}?

21. Suppose we want to specify Dec with Op_{0} = {0, true, false} and Op_{1} = {succ, pred, zero, isnum} where the elements of Op_{0} and the arithmetical elements of Op_{1} will have much the same meanings as in the text. However we want to model an evaluation mechanism which first tries to calculate the type (number or truth-value) of an expression and, if that terminates, it then tries to calculate its value. So, if the type of e is number (truth-value) that of pred(e) is number (evaluation does not terminate). If the type of e is number (truth-value) that of isnum(e) is truth-value (truth-value) and the value is tt (ff ). Give a denotational semantics which uses V = N_{⊥} + T_{⊥}, the separated sum.

4. The Category of CPOs Considered as a CPO Itself

The problem of finding recursively specified domains (and its solution) can be considered to be one of the main achievements of the present theory. In order to solve it, we will have to develop certain technical tools and that is the concern of the present chapter.

We have already seen several examples of cpos which satisfy recursive domain equations. For example N, the cpo of the integers, satisfies: N ≅ O 0 + N. Equations for T^{ω}, D^{∗}, X^{∞}, Btrees can be found in Exercises 2.4, 3.15, 3.18. The desire to solve such equations in general arises when we consider certain difficulties in denotational semantics. They often concern explicit or implicit forms of self-application where one has to make sense of expressions of the kind “x(x)”. Then if V is a cpo of possible values for x, it seems natural to require that V somehow contains its own function space, V → V. This is well-known to be impossible when V is a set and (V → V) is the partial order of all monotonic functions over V (see Exercise 1.19). However it is possible when V is a cpo and we restrict attention to the continuous functions over V.

As a concrete example consider the extension of Imp (see Exercise 1.3) where we add a syntactic class, Proc, of parameterless procedure variables (ranged over by p) and use them to add procedure declaration and calling clauses to the definition of Stat:

s ::= (proc p begin s end) | (call p).

The idea is that the declaration proc p begin s end should have the effect of assigning to p the command s, which is run when p is called. Thus we will want a cpo, approximately:

C = (S_{⊥} × PEnv) → (S_{⊥} × PEnv)

(a more accurate model would be (S_{⊥} ⊗ PEnv_{⊥}) →_{⊥} (S_{⊥} ⊗ PEnv)). But this is not a proper definition of PEnv and C as the definition is circular. What we will do is relax the equalities to isomorphisms and try to find cpos C and PEnv which satisfy the simultaneous recursive domain equations:

(1)  C ≅ (S_{⊥} × PEnv) → (S_{⊥} × PEnv),
(2)  PEnv ≅ (Proc_{⊥} →_{⊥} C).

Equivalently we could just try to find a cpo C satisfying the equation:

(3)  C ≅ (S_{⊥} × (Proc_{⊥} →_{⊥} C)) → (S_{⊥} × (Proc_{⊥} →_{⊥} C))

and then specify PEnv =^{def} (Proc_{⊥} →_{⊥} C).

The implicit self-application lies in the meaning of the statement call p. This will be a command, γ, which takes the current store σ (state plus procedure environment and so an element of S_{⊥} × PEnv) and applies the component of it corresponding to p, namely (σ ↓ 1)[[p]] to σ itself. Thus we have the implicit (and slightly indirect) self-application:

(σ ↓ 1)[[p]](σ).

Later on we shall consider the untyped λ-calculus where the self-application is completely explicit.

Our idea for solving such recursive domain equations is to consider them as a kind of fixed-point equation. Instead of looking for an element of a cpo, which satisfies a fixed-point condition we look for a cpo (an object in CPO_{⊥}) which satisfies the condition. We will be guided very explicitly by our earlier considerations on finding least fixed-points of continuous functions in cpos. There is a well-known analogy between quasi-orders (partial orders less the antisymmetry condition) and categories. Every quasiorder (D, ⊑) is a category if we take the elements of D to be the objects and stipulate that there is at most one morphism from an element, d, to another, e, which we write as (d → e); it exists iff d ⊑ e. Thus we can consider order relation as analogous to morphisms, the reflexivity relation d ⊑ d, is analogous to the identity, id_{D}: d→d and the law of transitivity: (c ⊑ d ∧ d ⊑ e ⇒ c ⊑ e) is analogous to composition: ((f: c → d ∧ g: d → e) ⇒ g ∘ f: c → e). One can perhaps see a morphism f: c → d as showing why c ⊑ d. It should be stressed that we are only offering an analogy as the reason for the particular mathematical development we are following. Some hints at a justification can be found in Chapter 4. More can be found in the detailed analysis of particular examples of semantics.

The analogue of a monotonic function, f, (where d ⊑ e implies f(d) ⊑ f(e)) is a functor F (where f: d → e implies F f: F d → F e and F preserves the identity and composition). Note that in forming a category-theoretic analogue one must add extra uniformity conditions. So we might expect to consider the category CPO_{⊥} and functors F: CPO_{⊥} →CPO_{⊥}. However this does not work for equations such as (3) since one cannot compose covariant and contravariant functors in such a cavalier way. The natural attempt at the definition of F would be to put, for each cpo D:

(4)  F (D) =^{def} (S_{⊥} × (Proc_{⊥} →_{⊥} D)) → (S_{⊥} × (Proc_{⊥} →_{⊥} D))

and for each f: D →_{⊥} E to define F (f): F (D) →_{⊥} F (E) by:

(5)  F (f) = (id_{S_{⊥}} × (id_{Proc_{⊥}} →_{⊥} f)) → (id_{S_{⊥}} × (id_{Proc_{⊥}} →_{⊥} f)).

However this is not a good definition; the expression on the right has the wrong type. Its type is (Y → X) →_{⊥} (X → Y) where X is [S_{⊥} × (Proc_{⊥} →_{⊥} D)] and Y is [S_{⊥} × (Proc_{⊥} →_{⊥} E)] but what is wanted is an expression of type (X → X) →_{⊥} (Y → Y). This would be obtained if the first occurrence of the variable f on the right hand side were replaced by an expression of type E →_{⊥} D, which should, presumably, involve f.

Luckily we can trace this to a somewhat questionable assumption in the analogy: there is no reason why any f: D → E should show why D ⊑ E. Indeed we have not discussed how one cpo could possibly be considered as an approximation to another. Now in modelling a given computational situation we might be faced with a choice between D and E. It may be that we can use both but in such a way that on the one hand the elements of D give only a degraded version of the information given by those in E, and on the other hand for each element in D there is an element in E which contains exactly the same information. Thus E can be used to paint a much finer picture than D. Of course, this does not mean E is better than D: it all depends on the circumstances which is the more appropriate. We try to capture these correspondences between elements of D and E as a pair of continuous functions, i: D → E, j: E → D. The first function shows how for any element d, of D there is an element i(d) in E with the same information as d; the second one shows how for any element e in E there is an element j(e) in D which contains less information than e and, since D is to be a degraded version of E, j(e) is the best approximation to e in D. Thus we expect the following two equations to hold:

\begin{matrix}∀d: D.j ∘ i(d) & = d, \\ ∀e: E.i ∘ j(e) & ⊑ e. \end{matrix}

For since i(d) contains the same information as d and j(i(d)) contains less than i(d) we have j(i(d)) ⊑ d. But since d is an approximation to i(d) and j(i(d)) is the best one we have j(i(d)) ⊒ d. This “demonstrates” the first equation. For the second we note that i(j(e)) contains the same information as j(e) which is an approximation to e. Conversely suppose we have i, j which satisfy the equations and rend the phrase “d approximates e” for an element d of D and an element e of E as “i(d) ⊑ e”. Then the second equation says that j(e) approximates e and also if d approximates e then d = j(i(d)) ⊑ j(e), showing that j(e) is the best approximation to e in D. This seems to be a reasonable argument for regarding such pairs ⟨i, j⟩ as giving one kind of approximation relation between domains and we make a suitable definition.

Definition 1. Let D and E be cpos and let i: D → E, j: E → D be continuous functions. Then ⟨i, j⟩ is a projection pair (from D to E) and i is an embedding and j is a projection and D is a projection of E provided only that j ∘ i = id_{D} and i ∘ j ⊑ id_{E}.

Examples

1. For n ∈ ω put [n] = {m ∈ ω | m < n}. Then the natural inclusion maps ι_{mn}: [m]_{⊥} → [n]_{⊥} (m ≤ n) are embeddings. The projection π_{mn}: [n]_{⊥} → [m]_{⊥} (m ≤ n) corresponding to ι_{mn} is defined by:

π_{nm}(l) = \{ \begin{matrix}l & (l < m), \\ ⊥ & (l = ⊥ or l ≥ m). \end{matrix}

2. The cpo Tapes is a projection of T^{ω}. With the aid of the evident functions cons: T × T^{ω} → T^{ω}, head: T^{ω} → T, tail: T^{ω} → T^{ω} we can define the projection pair, Tapes →^{i} T^{ω} →^{j} Tapes recursively by:

i(t) = cons(hd(t) = 0, i(tl(t))),
j(v) = (head(v) → 0 · j(tail(v)) | 1 · j(tail(v))).

3. For any cpos D, E we have the projection pair, (D →_{⊥} E) →^{ι} (D → E) →^{strict} (D →_{⊥} E).

The analysis of information in terms of events in Chapter 1 warns us that more subtle approximation relations between cpos can exist. For example it was shown there that, in a sense, {P \atop ω} is a degraded version of Tapes. But the discussion there only indicated a map j: Tapes → {P \atop ω} and none in the other direction: indeed it is not hard to show that {P \atop ω} is not a projection of Tapes. However projections will prove perfectly satisfactory for the solution of recursive domain equations.

Lemma 1. Let D →^{i} E →^{j} D be a projection pair. Then both i and j are strict. If D →^{i′} E →^{j′} D is another projection pair then i ⊑ i′ iff j ⊒ j′. Proof. First i(⊥_{D}) ⊑ i ∘ j(⊥_{E}) ⊑ ⊥_{E} showing i is strict. Second j(⊥_{E}) = j ∘ i(⊥_{D}) = ⊥_{D} showing j is strict.

If i ⊑ i′ then j ⊒ j ∘ i′ ∘ j′ ⊒ j ∘ i ∘ j′ = j′. Conversely, if j ⊒ j′ then i = i ∘ j′ ∘ i′ ⊑ i ∘ j ∘ i′ ⊑ i′.

The second part of this lemma shows that every embedding i has a unique corresponding projection, called its right adjoint, and written as i^{R}; further, it shows that every projection, j, has a unique corresponding embedding, called its left adjoint and written as j^{L}. It follows that i^{RL} = i and j^{LR} = j. Note that we are not claiming that i^{R} is a continuous function of i, nor that j^{L} is a continuous function of j, we are just introducing some notation. We write i: D ◁ E to indicate that i is an embedding and j: E ▷ D to indicate that j is a projection. With all this under our belts we now have a good idea what the category of cpos and approximations ought to be:

Definition 2. The category CPO^{E} has as objects the cpos and as morphisms the embeddings and composition is the usual composition of functions.

To see that this is a good definition note that id_{D}: D ◁ D as id_{D}^{R} = id_{D} and that if f: D ◁ E and g: E ◁ F then (g ∘ f): D ◁ F as (g ∘ f)^{R} = f^{R} ∘ g^{R}. The first claim is obvious; for the second calculate (f^{R} ∘g^{R})∘(g ∘f) = f^{R} ∘f = id_{D} and (g ∘f)∘(f^{R} ∘g^{R}) ⊑ (g ∘g^{R}) ⊑ id_{E}. We could have worked with CPO^{P}, the category of projections, instead of CPO^{E}. However this would not make any real mathematical difference as the two categories are dual and so, since the embeddings “go in the same way” as the approximation relation we chose CPO^{E}. Another possibility would be to use the (isomorphic) category of projection pairs and here the choice of CPO^{E} is on grounds of simplicity.

When an embedding is an inclusion map, ι: D ⊆ E the defining equations for a projection pair take on the simple form, ∀d: D.i(d) = d and ∀e: E.j(e) ⊑ e. Any embedding i: D ◁ E is essentially of this form, for if we let the image, i(D) be given the partial order inherited from E we find it in a subcpo of E as ⊥_{E} = i(⊥_{D}) and if ⟨i(d_{n})⟩_{n∈ω} is an increasing ω-chain so is ⟨j ∘ i(d_{n})⟩_{n∈ω} = ⟨d_{n}⟩_{n∈ω} and we see, by the continuity of i that ⨆_{E} i(d_{n}) = i(⨆_{D} d_{n}). It follows that the inclusion map ι: i(D) ⊆ E is continuous. Next one easily checks that θ: D → i(D), where θ(d) =^{def} i(d). In an isomorphism with inverse θ^{−1} = j ↑ (i(D)); it is clear that θ and θ^{−1} are monotonic and we have θ^{−1} ∘ θ(d) = j ∘ i(d) = d and θ ∘ θ^{−1}(i(d)) = i ∘ j ∘ i(d) = i(d). Now we have the factorisation of i:

[figure: D; i(D); θ; i; E; ι]

and ι is an embedding as ι^{R} = θ∘j for: (θ∘j)∘ι = θ∘j ∘ι∘θ∘θ^{−1} = θ∘j ∘i∘θ^{−1} = id and ι∘(θ∘j) = i∘j ⊑ id. Because of all this when i: D ◁ E we often use an identification convention where such element d, of D, is identified with its image i(d). Then D is identified with i(D) and i with the inclusion map, ι.

We now return to the pursuit of our analogy attempting to regard CPO^{E} as a kind of cpo in which the approximation relation are replaced by embeddings, i: D ◁ E. Corresponding to the idea of a least element ⊥ (for any x, ⊥ ⊑ x) we have the idea of an initial element ⊥ (for any D, there is a unique ⊥ ◁ D). The initial element must be U, the one-point cpo, and the morphism U ◁ D is just K_{⊥_{D}}, the only strict map from U to D. This is an embedding as K_{⊥_{D}}^{R} = K_{⊥_{U}}.

Turning to functors we see next how all our functors over CPO_{⊥}, whether covariant or contravariant, become covariant functor over CPO^{E}! The clue lies in the above remarks on the type of the function f: D →_{⊥} E when we tried to define a functor for equation (3). What was needed was an element of type E →_{⊥} D instead. This is now easy, given i: D ◁ E we will use j: E ▷ D.

Example 1 Products. Starting with ∏: CPO_{⊥}^{n} → CPO_{⊥} (see Exercise 2.6) we define ∏^{E}: (CPO^{E})^{n} → CPO^{E} by putting for cpos D_{0}, …, D_{n−1}:

∏_{i<n}^{E}D_{i} = ∏_{i<n} D_{i}

and for embeddings f_{i}: D_{i} ◁ E_{i} (i < n):

∏_{i<n}^{E}f_{i} = ∏_{i<n} f_{i}.

We must prove that the right hand side is also an embedding and so we show that (∏_{i<n} f_{i})^{R} = ∏_{i<n} f_{i}^{R}, by calculating:

(∏_{i<n} f_{i}^{R}) ∘ (∏_{i<n} f_{i}) = ∏_{i<n}(f_{i}^{R} ∘ f_{i})  functor laws for ∏
= ∏_{i<n} id_{D_{i}}  property of embeddings
= id_{∏ D_{i}}  functor laws for ∏
= id_{∏^{E}D_{i}}  definition of ∏^{E},

and

(∏_{i<n} f_{i}) ∘ (∏_{i<n} f_{i}^{R}) = ∏_{i<n}(f_{i} ∘ f_{i}^{R})
⊑ ∏_{i<n} id_{E_{i}}  ∏ acts monotonically on morphisms
= id_{∏^{E}E_{i}}.

The functor laws for ∏^{E} follow immediately from those for ∏.

Example 2 Exponentiation. Starting with →: CPO_{⊥}^{2}→CPO_{⊥} (see Exercise 2.9) we define the covariant functor →^{E}: (CPO^{E})^{2} → CPO^{E} by putting for cpos D and E:

(D →^{E} E) = (D → E)

and for f: D ◁ D′, g: E ◁ E′:

(f →^{E} g) = f^{R} → g,

using the idea hinted at above. To show f →^{E} g: (D → E) ◁ (D′ → E′) we prove that (f →^{E} g)^{R} = (f → g^{R}) by calculating:

(f → g^{R}) ∘ (f^{R} → g) = (f^{R} ∘ f) → (g^{R} ∘ g)  functor laws
= id_{D} → id_{E}
= id_{D→E}

and

(f^{R} → g) ∘ (f → g^{R}) = (f ∘ f^{R}) → (g ∘ g^{R})
⊑ id_{D′} → id_{E′}  → acts monotonically on morphisms
= id_{D′→E′}.

We should also check the functor laws:

(id_{D} →^{E} id_{E}) = id_{D} → id_{E} = id_{(D→E)} = id_{(D→^{E}E)}

and for f: D ◁ D′, f′: D′ ◁ D′′, g: E ◁ E′, g′: E′ ◁ E′′:

(f′ →^{E} g′) ∘ (f →^{E} g) = (f′^{R} → g′) ∘ (f^{R} → g)

= ((f^{R} ∘ f′^{R}) → (g′ ∘ g))

= (f′ ∘ f)^{R} → (g′ ∘ g)

= (f′ ∘ f) →^{E} (g′ ∘ g).

In order to avoid tediously checking the details for all our other functors we formulate a general result.

Definition 3. Let T: CPO_{⊥}^{m+n} →CPO_{⊥} (m, n ≥ 0) be contravariant in its first m arguments and covariant in its following n arguments. Then T is locally monotonic iff whenever f_{i}, f′_{i}: D′_{i}→D_{i} (i < m) and g_{j}, g′_{j}: E_{j} → E′_{j} (j < n) are such that f_{i} ⊑ f′_{i} (i < m) and g_{j} ⊑ g′_{j} (j < n) then:

T (f_{0}, …, f_{m−1}, g_{0}, …, g_{n−1}) ⊑ T (f′_{0}, …, f′_{m−1}, g′_{0}, …, g′_{n−1}).

Clearly all the functors ∏, →, ⨂, →_{⊥}, ∑, (·)_{⊥}, (·)^{∗} (see Exercise 3.15) are or can be regarded as locally monotonic functions. There are two other important examples. The covariant projection functor P_{i}: CPO_{⊥}^{n} → CPO_{⊥} (n ≥ 0,i < n) is defined by:

\begin{aligned}P_{i}(D_{0}, …, D_{n−1}) & = D_{i}, \\ P_{i}(f_{0}, …, f_{n−1}) & = f_{i}. \end{aligned}

Both the projection and constant functors are clearly locally monotonic.

Lemma 2. Every locally monotonic functor T: CPO_{⊥}^{m+n} → CPO_{⊥}, as in Definition 3 can be turned into a covariant functor T^{E}: (CPO^{E})^{m+n} → CPO^{E} by stipulating for cpos D_{0}, …, D_{m−1}, E_{0}, …, E_{n−1} that:

T^{E}(D_{0}, …, D_{m−1}, E_{0}, …, E_{n−1}) = T (D_{0}, …, D_{m−1}, E_{0}, …, E_{n−1})

and for embeddings, f_{i}: D_{i} ◁ D′_{i} (i < m), g_{i}: E_{i} ◁ E′_{i} (i < n) that

T^{E}(f_{0}, …, f_{m−1}, g_{0}, …, g_{n−1}) = T (f_{0}^{R}, …, f_{m−1}^{R}, g_{0}, …, g_{n−1}).

Proof. The proof is left to the reader.

It is now clear how to define the functor, F: CPO^{E} → CPO^{E} needed for equation (3). For a cpo D we write, as in equation (4):

F (D) = (S_{⊥} × (Proc_{⊥} →_{⊥} D)) → (S_{⊥} × (Proc_{⊥} →_{⊥} D))

but for an embedding f: D ◁ E we write:

F (f) = (id_{S_{⊥}} × (id_{Proc_{⊥}} →_{⊥} f^{R})) → (id_{S_{⊥}} × (id_{Proc_{⊥}} →_{⊥} f)).

What this means is that F is a composition of covariant functors over CPO^{E} as:

F = →^{E}(G, G), where
G = ×^{E}(K_{S_{⊥}}^{E}, →_{⊥}^{E}(K_{Proc_{⊥}}^{E}, Id^{E}))

and we leave it to the reader to check that these two definitions amount to the same thing.

When we want to solve simultaneous equations, such as (1), (2) we have to find simultaneous fixed-points of covariant functors over CPO^{E}. For example in this case we define F_{0}, F_{1}: (CPO^{E})^{2} → CPO^{E} by:

F_{0} = →^{E}(×^{E}(K_{S_{⊥}}^{E}, P_{0}^{E}), ×^{E}(K_{S_{⊥}}^{E}, P_{0}^{E}))
F_{1} = →_{⊥}^{E}(K_{Proc_{⊥}}^{E}, P_{1}^{E})

and then we have to find cpos C, PEnv such that:

C = F_{0}(C, PEnv)
PEnv = F_{1}(C, PEnv).

As may be expected, it will not prove much harder to solve such simultaneous equations than it is to solve ordinary ones.

Continuing with the analogy we now see what corresponds to lubs of increasing ω-chains, ⊔_{n∈ω}x_{n}. First of all the analogue of an increasing ω-chain, x_{0} ⊑ x_{1} ⊑ x_{2} ⊑ ⋯ is a (direct) ω-chain Δ = ⟨D_{m}, f_{mn}⟩ of cpos D_{n} and embeddings f_{mn}: D_{m} ◁ D_{n} (m ≤ n < ω) such that all the following triangles commute where l ≤ m ≤ n:

[figure: D_{l}; D_{m}; f_{lm}; f_{ln}; D_{n}; f_{mn}]

Clearly the embeddings f_{m(m+1)} determine all the others and sometimes we write (or define) an ω-chain as ⟨D_{m}, f_{m}⟩ where f_{m}: D_{m} ◁ D_{m+1} is f_{m(m+1)}; we can picture ω-chain as:

D_{0} ◁^{f_{0}} D_{1} ◁^{f_{1}} D_{2} ◁^{f_{2}} ⋯ ◁^{f_{n−1}} D_{n} ◁^{f_{n}} · · · .

An example of an ω-chain in ⟨[m], ι_{mn}⟩ which we might picture as:

[figure: ⊥; 0; 1; n; ^{[0]^{⊥}}; ^{[1]^{⊥}}; ^{[2]^{⊥}}; ^{[n]^{⊥}}; ^{[n + 1]^{⊥}}]

Figure XIII: A direct ω-chain.

Corresponding to an upper bound, x, of an increasing ω-chain, we clearly need for a chain Δ = ⟨D_{m}, f_{mn}⟩ not only a cpo D but also a whole collection ρ = ⟨ρ_{m}⟩_{m∈ω} of embeddings ρ_{m}: D_{m} ◁D which satisfy a suitable coherence condition. So we say that ρ: Δ→D is a cone from Δ to D if ρ is a sequence ⟨ρ_{n}⟩_{n∈ω} of embeddings ρ_{n}: D_{n} ◁ D such that all the following triangles commute where m ≤ n < ω:

[figure: D_{m}; D; ρ_{m}; D_{n}; f_{mn}; ρ_{n}]

Note that it is only necessary to check that they commute for the cases with n = m+1 as the other cases then follow using the commuting triangles for chains. For the chain Δ = ⟨[m], ι_{mn}⟩ we have the cone ρ: Δ → N where ρ_{m} = ι_{mω}.

Finally corresponding to the idea of a least upper bound of an increasing chain we have the idea of an initial (also called universal) cone. If ρ: Δ → D, ρ′: Δ → D′ are cones a morphism, θ: ρ ◁ ρ′ is defined to be an embedding θ: D ◁ D′ such that all the following triangles commute:

[figure: D_{m}; D; ρ_{m}; ρ′_{m}; D′; θ]

This, as may easily be verified, gives a category of cones from Δ and an initial cone is one from which there is exactly one morphism to any other cone. This specifies ρ up to an isomorphism.

In other words, ρ: Δ → D is initial (= universal) iff whenever ρ′: Δ → D′ is a cone there is exactly one embedding θ: D ◁ D′ (called the mediating morphism) which makes all the above triangles commute. Clearly this specifies D and also the ρ_{n} up to isomorphism, as we have already essentially remarked; when ρ: Δ → D is universal we sometimes write D = lim_{→} Δ (the direct limit of Δ) and in the light of the above remarks on isomorphism this should cause little confusion.

For example, as the reader no doubt expected, the cone ⟨ι_{mω}⟩_{m∈ω}: ⟨[m], ι_{mn}⟩ → N is universal as if ρ: ⟨[m], ι_{mn}⟩ → D is a cone then we must have for the mediating morphism, θ, that θ(⊥) = ⊥ and for m < ω, θ(m) = θ(ι_{mω}(m)) = ρ_{m}(m), which clearly determines θ and shows that it exists.

It is awkward to work with the category-theoretic definition directly and in order to show, following the analogy, that direct limits always exist we find an equivalent local order-theoretic condition. If ρ: Δ → D is a cone where Δ = ⟨D_{m}, f_{m}⟩ then the chain ⟨ρ_{m} ∘ ρ_{m}^{R}(x)⟩_{m∈ω} of the best approximations to an element of x at level m is increasing as we have:

ρ_{m} ∘ ρ_{m}^{R} = (ρ_{m+1} ∘ f_{m}) ∘ (ρ_{m+1} ∘ f_{m})^{R} = ρ_{m+1} ∘ f_{m} ∘ f_{m}^{R} ∘ ρ_{m+1}^{R} ⊑ ρ_{m+1} ∘ ρ_{m+1}^{R}.

It is natural to expect that if D is to be the direct limit then x is the limit of the chain and indeed we have:

Lemma 3. Let Δ = ⟨D_{m}, f_{mn}⟩ be a direct ω-chain of embeddings and let ρ: Δ→D be a cone of embeddings. Then if (⨆_{n} ρ_{n} ∘ ρ_{n}^{R}) = id_{D} it follows that ρ is universal. Proof. Suppose ρ′: Δ → D′ is a cone of embeddings. Then ⟨ρ′_{m} ∘ ρ_{m}^{R}⟩_{m∈ω} is an increasing ω-chain as ρ′_{m} ∘ ρ_{m}^{R} = ρ′_{m+1} ∘ f_{m} ∘ f_{m}^{R} ∘ ρ_{m+1}^{R} ⊑ ρ′_{m+1} ∘ ρ_{m+1}^{R} and so we may define θ: D → D′ by:

θ = ⨆_{m} ρ′_{m} ∘ ρ_{m}^{R}.

To prove θ is an embedding we note that ⟨ρ_{m} ∘ ρ_{m}^{′R}⟩_{m∈ω} must also be an increasing ω-sequence and prove that θ^{R} = ⨆_{m} ρ_{m} ∘ ρ_{m}^{′R} by calculating:

(⨆_{m} ρ_{m} ∘ ρ_{m}^{′R}) ∘ (⨆_{m} ρ′_{m} ∘ ρ_{m}^{R}) = ⨆_{m} ρ_{m} ∘ ρ_{m}^{′R} ∘ ρ′_{m} ∘ ρ_{m}^{′R}  composition is continuous

= ⨆_{m} ρ_{m} ∘ ρ_{m}^{R}

= id_{D}  by assumption

and

(⨆_{m} ρ′_{m} ∘ ρ_{m}^{R}) ∘ (⨆_{m} ρ_{m} ∘ ρ_{m}^{′R}) = ⨆_{m} ρ′_{m} ∘ ρ_{m}^{R} ∘ ρ_{m} ∘ ρ_{m}^{′R}

= ⨆_{m} ρ′_{m} ∘ ρ_{m}^{′R}

⊑ id_{D′}.

Next we must check θ is mediating:

θ ∘ ρ_{m} = ⨆_{n≥m} ρ′_{n} ∘ ρ_{n}^{R} ∘ ρ_{m}

= ⨆_{n≥m} ρ′_{n} ∘ ρ_{n}^{R} ∘ ρ_{n} ∘ f_{mn}

= ⨆_{n≥m} ρ′_{n} ∘ f_{mn}

= ρ′_{m}.

Finally we check uniqueness. Let θ′: D ◁ D′ be a mediating morphism. Then,

θ′ = θ′ ∘ id_{D} = θ′ ∘ (⨆_{m} ρ_{m} ∘ ρ_{m}^{R}) = ⨆_{m}(θ′ ∘ ρ_{m}) ∘ ρ_{m}^{R} = ⨆_{m} ρ′_{m} ∘ ρ_{m}^{R}.

It turns out that we can always construct the direct limit by using the criterion of Lemma 3.

Lemma 4. Let Δ = ⟨D_{m}, f_{mn}⟩ be a direct ω-chain of embeddings. Then there is a cone ρ: Δ → D of embedding such that ⨆_{m} ρ_{m} ∘ ρ_{m}^{R} = id_{D}. Proof. Let D be the subset of ∏_{m∈ω} D_{m} where, D = {d ∈ ∏_{m∈ω} D_{m} | ∀m.f_{m}^{R}(d_{m+1}) = d_{m}}, with the inherited coordinatewise order. Then D is a subcpo of the product with ⊥_{D} = ⟨⊥_{D_{m}}⟩_{m∈ω} and ⨆_{n} d^{(n)} = ⟨⨆_{n} d_{m}^{(n)}⟩_{m∈ω}. Now define a cone ρ: Δ → D by: putting for any d in D_{m}

ρ_{m}(d) = ⟨f_{mn}(d)⟩_{n∈ω},

where if m > n, f_{mn} =^{def} f_{nm}^{R}. One easily checks that ρ_{m}(d) is an element of D and that ρ_{m} is continuous; further ρ_{m} is an embedding as one can check that ρ_{m}^{R} is given by: ρ_{m}^{R}(d) = (d ↓ m).

As f_{m}^{R} ∘ ρ_{m+1}^{R}(d) = f_{m}^{R}(d ↓ (m + 1)) = (d ↓ m) = ρ_{m}^{R}(d) we have ρ_{m}^{R} = f_{m}^{R} ∘ ρ_{m+1}^{R} and so ρ_{m} = ρ_{m}^{RL} = (f_{m}^{R} ∘ ρ_{m+1}^{R})^{L} = ρ_{m+1}^{RL} ∘ f_{m}^{RL} = ρ_{m+1} ∘ f_{m} showing that ρ is a cone.

Finally as ρ_{m} ∘ ρ_{m}^{R} ⊑ id_{D} on the one hand and on the other for any d in D, (ρ_{m} ∘ ρ_{m}^{R}(d)) ↓ m = d_{m} we have, ⨆_{m} ρ_{m} ∘ ρ_{m}^{R} = id_{D}, which concludes the proof.

Theorem 1. For any direct ω-chain, Δ, of embeddings, lim_{→} Δ always exists. Indeed ρ: Δ→D is universal iff ⨆_{m} ρ_{m} ∘ ρ_{m}^{R} = id_{D}. Proof. By Lemma 4 a cone ρ: Δ → D satisfying the conditions of Lemma 3 exists and so lim_{→} Δ exists. Lemma 3 shows that if ρ′: Δ → D′ satisfies the condition that ⨆_{m} ρ′_{m} ∘ ρ_{m}^{′R} = id_{D} then it is universal. Conversely if ρ′ is universal then there is an isomorphism θ: ρ→ρ′ and so ⨆_{m} ρ′_{m}∘ρ_{m}^{′R} = ⨆_{m}(θ∘ρ_{m})∘(θ∘ρ_{m})^{R} = ⨆_{m} θ ∘ ρ_{m} ∘ ρ_{m}^{R} ∘ θ^{−1} = θ ∘ (⨆_{m} ρ_{m} ∘ ρ_{m}^{R}) ∘ θ^{−1} = θ ∘ θ^{−1} = id_{D}.

Suppose ρ: Δ → D is a chain where Δ = ⟨D_{m}, f_{mn}⟩. Then, as remarked earlier, we can consider that all the ρ_{m} are inclusions ρ_{m}: D_{m} ⊆ D. Then each f_{mn} is also an inclusion as for d in D_{m} we have f_{mn}(x) = ρ_{n}^{R} ∘ ρ_{n} ∘ f_{mn}(x) = ρ_{n}^{R} ∘ ρ_{m}(x) = ρ_{n}^{R}(x) = ρ_{n}^{R} ∘ ρ_{n}(x) = x. So we have D_{0} ⊆ D_{1} ⊆ ⋯ and D ⊇ ⋃_{m} D_{m}. Suppose now that ρ is universal; then each element x of D is the lub of its best approximants in D_{n} as: x = ⨆_{m} ρ_{m} ∘ ρ_{m}^{R}(x) = ⨆_{m} ρ_{m}^{R}(x), and so x ⊑ y iff ∀m.ρ_{m}^{R}(x) ⊑ ρ_{m}^{R}(y). Thus we can consider D as being ⋃_{m} D_{m} with lubs added to turn it into a cpo.

For example in the case where the D_{m} are all flat all chains of best approximants will be trivial (eventually constant) and we will have D = ⋃_{m} D_{m}, as is the case with the universal cone to N which we discussed above.

Continuing the analogy we now see what corresponds to continuous functions, which are those which preserve lubs of increasing ω-chains. Now monotonic functions preserves increasing ω-chains and upper bounds of them. Analogously, if F: CPO^{E} → CPO^{E} is a covariant functor and ρ: Δ → D is a cone where Δ = ⟨D_{m}, f_{mn}⟩ then F (ρ): F (Δ)→F (D) is also a cone where F (Δ) =^{def}⟨F (D_{m}), F (f_{mn})⟩ and F (ρ) =^{def}⟨F (ρ_{m})⟩_{m∈ω}. More generally for a covariant functor of several arguments, F: (CPO^{E})^{n} → CPO^{E} if ρ^{(i)}: Δ^{(i)} → D^{(i)} are cones where Δ^{(i)} = ⟨D_{m}^{(i)}, f_{mm′}^{(i)}⟩ (for i < n) then

F (ρ^{(0)}, …, ρ^{(n−1)}): F (Δ^{(0)}, …, Δ^{(n−1)}) → F (D^{(0)}, …, D^{(n−1)})

is a cone where

F (Δ^{(0)}, …, Δ^{(n−1)}) =^{def} ⟨F (D_{m}^{(0)}, …, D_{m}^{(n−1)}), F (f_{mm′}^{(0)}, …, f_{mm′}^{(n−1)})⟩

and

F (ρ^{(0)}, …, ρ^{(n−1)}) =^{def} ⟨F (ρ_{m}^{(0)}, …, ρ_{m}^{(n−1)})⟩_{m∈ω}.

Definition 4. A covariant functor, F: (CPO^{E})^{n}→CPO^{E} is continuous iff whenever ρ^{(i)}: Δ^{(i)}→D^{(i)} are universal cones (for i < n) so is F (ρ^{(0)}, …, ρ^{(n−1)}): F (Δ^{(0)}, …, Δ^{(n−1)}) → F (D^{(0)}, …, D^{(n−1)}). Note that this definition implies that F (lim_{→} Δ^{(0)}, …, lim_{→} Δ^{(n−1)}) ≅ lim_{→} F (Δ^{(0)}, …, Δ^{(n−1)}); essentially it is obtained from the latter condition by adding uniformity conditions on the morphisms.

Example. We show that exponentiation is continuous. Let ρ: Δ → D and ρ′: Δ′ → D′ be universal cones of embeddings. Then (ρ →^{E} ρ′): (Δ →^{E} Δ′) → (D →^{E} D′) is universal as we calculate:

⨆_{m}(ρ →^{E} ρ′)_{m} ∘ (ρ →^{E} ρ′)_{m}^{R} = ⨆_{m}(ρ_{m} →^{E} ρ′_{m}) ∘ (ρ_{m} →^{E} ρ′_{m})^{R}

= ⨆_{m}(ρ_{m}^{R} → ρ′_{m}) ∘ (ρ_{m} → ρ_{m}^{′R})

= ⨆_{m}(ρ_{m} ∘ ρ_{m}^{R}) → (ρ′_{m} ∘ ρ_{m}^{′R})

= (⨆_{m} ρ_{m} ∘ ρ_{m}^{R}) → (⨆_{m} ρ′_{m} ∘ ρ_{m}^{′R})

exponentiation acts continuously on morphisms

= id_{D} → id_{D′} by Theorem 1

= id_{D→^{E}D′}.

and by Theorem 1 that shows that ρ → ρ′ is universal.

Rather than consider all our other constructions separately we formulate a general result.

Definition 5. Let T: (CPO)_{⊥}^{m+n} → CPO_{⊥} be contravariant in its first m arguments and covariant in its following n arguments. Then T is locally continuous iff whenever ⟨f_{l}^{(i)}⟩_{l∈ω} is an increasing chain of continuous functions, f_{l}^{(i)}: D′_{i} →_{⊥} D_{i}, for i < m and also ⟨g_{l}^{(j)}⟩_{l∈ω} is an increasing chain of continuous functions g_{l}^{(j)}: E_{j} →_{⊥} E′_{j} for j < n then

T (f_{l}^{(0)}, …, f_{l}^{(m−1)}, g_{l}^{(0)}, …, g_{l}^{(n−1)}): T (D_{0}, …, D_{m−1}, E_{0}, …, E_{n−1}) →_{⊥} T (D′_{0}, …, D′_{m−1}, E′_{0}, …, E′_{n−1})

is an increasing chain of continuous functions with the lub, T (⨆_{l} f_{l}^{(0)}, …, ⨆_{l} f_{l}^{(m−1)}, ⨆_{l} g_{l}^{(0)}, …, ⨆_{l} g_{l}^{(n−1)}).

Clearly any locally-continuous functor is locally-monotonic. All our functors, ∏, →, ⨂, →_{⊥}, ∑, (·)_{⊥}, (·)^{∗}, P_{i}, K_{D} are locally-continuous.

Theorem 2. Let T: CPO_{⊥}^{m+n} → CPO_{⊥} be a locally continuous functor as in Definition 5. Then T^{E} is continuous. Proof. The proof is similar to the case of exponentiation and is left to the reader.

We should check that continuity is preserved under composition. Suppose F_{i}: (CPO^{E})^{m}→CPO^{E} (i < n) are n continuous functors of degree m and F: (CPO^{E})^{n}→CPO^{E} is also continuous. Then so is the composition F (F_{0}, …, F_{n−1}): (CPO^{E})^{m} → CPO^{E} of F with F_{0}, …, F_{n−1}. For suppose ρ^{(0)}, …, ρ^{(m−1)} are universal cones. Then as the F_{i} are all continuous the cones F_{i}(ρ^{(0)}, …, ρ^{(m−1)}) are also universal. But then as F is continuous the cone F (F_{0}(ρ^{(0)}, …, ρ^{(m−1)}), …, F_{n−1}(ρ^{(0)}, …, ρ^{(m−1)})) = F (F_{0}, …, F_{n−1})(ρ^{(0)}, …, ρ^{(m−1)}) is also universal.

This concludes all the basic technical material needed to solve recursive domain equations. We recapitulate the analogy, as developed so far, in a table.

Order  Morphism
x ⊑ y  f: D ◁ E
Quasi-order  Category
x ⊑ x  id_{D}: D ◁ D
(x ⊑ y ∧ y ⊑ z) ⇒ x ⊑ z  (f: D ◁ E ∧ g: E ◁ F) ⇒ (g ∘ f): D ◁ F
Least element  Initial element
⊥ ⊑ x  ∃!f: U ◁ D
Monotonic function  Covariant functor
x ⊑ y ⇒ fx ⊑ fy  f: D ◁ E ⇒ F f: F D ◁ F E
F (id_{D}) = id_{F D}
F (g ∘ f) = F (g) ∘ F (f)
(and several arguments)  (and several arguments)
Lub of ω-chain  Direct limit of ω-chain
x_{n} ⊑ ⨆_{n} x_{n}  ρ: Δ → lim_{→} Δ
(∀n.x_{n} ⊑ y) ⇒ ⨆_{n} x_{n} ⊑ y  (ρ′: Δ → E) ⇒ (∃!θ: ρ ◁ ρ′)
Continuous function  Continuous functor
f(⨆_{n} x_{n}) = ⨆_{n} f(x_{n})  (ρ universal) ⇒ (F (ρ) universal)
(and several arguments)  (and several arguments)

Exercises

1. Suppose we add a class Proc of (parameterless) procedure variables to the syntax of Imp and add procedure declaration of limited scope (rather than the unbounded scope considered in this chapter so far) and calling clauses to the syntax of Stat:

s ::= (letproc p be s in s) | (call p)

Show that it is possible to give a denotational semantics without needing any recursively specified cpos.

2. Show that {P \atop ω} × {P \atop ω} ◁ {P \atop ω}, T^{ω} × T^{ω} ◁ T^{ω}, Tapes ◁ Btrees, but that ({P \atop ω} → {P \atop ω}) ◁̸ {P \atop ω} (this is not easy), that {P \atop ω} ◁̸ Tapes, Tapes × Tapes ◁̸ Tapes, T^{ω} → T^{ω} ◁̸ T^{ω}.

3. Show that if D and E are finite and D ◁ E ◁ D then D ≅ E; show that T^{ω} ◁ N^{ω} ◁ T^{ω} but T^{ω} ≅ N̸^{ω}.

4. Show that π_{i}: ∏_{i} D_{i} ▷ D_{i}, (D → E) ▷ E, ⨿_{i}: D_{i} ◁ ∑_{i} D_{i}, D ⊗ E ◁ D × E, D ◁ D_{⊥}, D ◁ D^{∗}. When do we have O 0 ◁ D? Show that if D has a continuous glb operation, ⊓, then ⊓: D × D ▷ D.

5. For any continuous p: D → D let Fix_{p} be the cpo of the fixed-points of p, under the inherited order. Sometimes a p: D → D is called a projection if p = p ∘ p ⊑ id_{D}. Show that if p is a projection in this sense then ι: Fix_{p} ⊆ D is an embedding with ι^{R}(d) = p(d). Show that if i: C → D is an embedding then i ∘ j is a projection with i(C) = Fix_{i∘j}.

6. The cpo [0, 1] is the real interval with the usual ordering on the reals. Show that the Cantor middle third set is a projection of it and it is a projection of the Cantor middle third set. (The Cantor middle third set is the set of all elements of [0, 1] whose ternary expansion contains no 2’s.) What are the relations between [0, 1] and [−∞, +∞] and [0, +∞]?

7. Let Tapes_{n} (n ≤ ω) be the subcpo of Tapes consisting of all tapes of length ≤ n. Show that the inclusions Tapes_{m} ⊆ Tapes_{n} ⊆ Tapes (m ≤ n) are embeddings and hence find a universal cone to Tapes. Do the same sort of thing for {P \atop ω}, T^{ω}, ω and Btrees.

8. A pair D →^{i} E →^{j} D of continuous maps is an adjoint pair iff j∘i ⊒ id_{D} and i∘j ⊑ id_{E} and we say that i is the left adjoint and j is the right adjoint. Show that ⟨i, j⟩ is an adjoint pair iff (∀x: D, y: E.x ⊑ jy iff ix ⊑ y). Show that if D →^{i′} E →^{j′} D is another adjoint pair then i ⊑ i′ iff j ⊒ j′, proving that left and right adjoints are unique (and we have i^{R}, j^{L} as before). Let ⟨i, j⟩ be a fixed adjoint pair from now on. Show that i is an embedding iff i is 1-1 iff j is onto. If j ∘ i ⊒ id_{D} and i ∘ j = id_{E} we say that i (and also j ∘ i) is a closure, (f: D → D is a closure in general iff f = f ∘ f ⊒ id_{D}). Show that j is a closure iff i is onto iff j is into. Show i is an isomorphism iff it is an embedding and a closure. Show that i = i ∘ j ∘ i and j = j ∘ i ∘ j. Show that i is completely additive (preserves all lubs) and that j is completely multiplicative (preserves all glbs), generating strictness as ⊥ = ⨆_{D} ∅ = ⊓_{D} D. Show that i factorises as:

[figure: D; X; i′; i; E; i′′]

where i′ is a closure and i′′ is an embedding. What goes wrong with the general theory if we use left adjoints instead of embeddings? Can it be repaired? (This is an interesting open question which is probably not hard.)

9. Show that {P \atop ω} × {P \atop ω} and {P \atop ω} → {P \atop ω} are both closures of {P \atop ω}. Show that there are no non-trivial closures of Tapes or T^{ω}.

10. Find an increasing chain of isomorphisms, θ_{n}: D ≅ D such that ⨆_{n} θ_{n} is not an embedding or a projection; find a decreasing chain of isomorphisms θ_{n}: D ≅ D whose glb, ⊓_{n} θ_{n}, exists but is not an embedding or a projection. Show that neither of (·)^{L}, (·)^{R} are even monotonic.

11. Is ∏^{E}D_{i} the categorical product in CPO^{E}? What about the other constructions.

12. Define the natural “forgetful functor” V: CPO^{E} → CPO_{⊥} and show that if T: CPO_{⊥} → CPO_{⊥} is covariant and locally monotonic then T^{E} is the unique functor, F: CPO^{E} → CPO^{E} such that the following diagram of functors commutes:

[figure: CPO_{⊥}; CPO_{⊥}; T; CPO^{E}; CPO^{E}; F; V; V]

Extend this to covariant functors of several arguments. What can you do with general functors which may be mixed covariant and contravariant? [Hint Look at CPO^{D} which has as morphisms pairs D →^{f} _{⊥} E →^{g} _{⊥} D of strict continuous functions.]

13. Show that if ρ: Δ → D is universal, where Δ = ⟨D_{m}, f_{mn}⟩, then so is ρ^{−}: Δ^{−} → D where Δ^{−} = ⟨D_{m+1}, f_{(m+1)(n+1)}⟩ and ρ^{−} = ⟨ρ_{m+1}⟩_{m∈ω}. In other words dropping a few terms makes no difference to universality. What happens if we drop an infinite subset, but still leave an infinite subset?

14. Fill in the missing details in the proof of Lemma 3.

15. Suppose ρ: ⟨D_{m}, f_{mn}⟩ → D is a universal cone of embeddings and the ρ_{m} and f_{mn} are all inclusions. Suppose too that all increasing ω-chains in any of the D_{m} are trivial. Let ⋃_{m} D_{m} be the partial order where for x in D_{m}, y in D_{n}, x ⊑ y iff x ⊑_{D_{l}} y where l = max(m, n). Show that the monotonic inclusion map, ι: ⋃_{m} D_{m} → D is universal in the sense that if f: ⋃_{m} D_{m} → E is any other monotonic map then there is a unique continuous map h: D → E such that the following diagram commutes:

[figure: D; E; h; f; _{⋃n} D_{n}; ι]

Show that ι need not be continuous in general. What goes wrong if you drop the assumption on the D_{m}?

16. Try to axiomatise direct limits in CPO^{E} in something of the same style we axiomatised the other constructions such as ∏ and →.

17 Coincidence of Direct and Inverse Limits. A direct ω-chain in CPO_{⊥} is a structure Δ = ⟨D_{m}, f_{mn}⟩ where f_{mn}: D_{m} →_{⊥} D_{n} (m ≤ n) and then a cone ρ: Δ→D in CPO_{⊥} is a system of ρ_{m}: D_{m} →_{⊥} D making the appropriate triangles commute. Define a universal cone in CPO_{⊥} and show that if Δ is a direct ω-chain in CPO^{E} and ρ: Δ → D is a universal cone in CPO^{E} then it is universal in CPO_{⊥} too. An inverse ω-chain in CPO_{⊥} is a structure Δ = ⟨D_{m}, f_{mn}⟩ where f_{mn}: D_{n} →_{⊥} D_{m} (m ≤ n). Define cones ρ: D → Δ and universal cones ρ: D → Δ in CPO_{⊥} (and here we write D = lim_{←} Δ, the inverse limit). Show that if ρ: ⟨D_{m}, f_{mn}⟩ → D is a universal cone in CPO^{E} then ⟨ρ_{m}^{R}⟩_{m∈ω}: D → ⟨D_{m}, f_{mn}^{R}⟩ is a universal cone in CPO_{⊥}.

18 Inverse Limits. Show that both CPO and CPO_{⊥} have inverse limits of inverse ω-chains.

19 Equalisers. If f, g: D → E are morphisms (in any category) an equaliser is a morphism h: C → D such that f ∘ h = g ∘ h and (universal property) such that if h′: C′ → D is any morphism with that property then there is a unique θ: C′ → C such that h′ = h ∘ θ. Show that CPO, CPO_{⊥} but not CPO^{E} always have equalisers. Show that equalisers in CPO_{⊥} are order-monics. Are order-monics always equalisers? Show that embeddings are order-monics too, but the converse fails in general.

20 Direct Limits. Show that CPO does not have direct limits of direct ω-chains, but that CPO_{⊥} does. [Warning This is rather hard.]

21 Co-Equalisers. If f, g: D → E are morphisms (in any category) a co-equaliser is a morphism h: E → F such that h ∘ f = h ∘ g (universal property) such that if h′: E → F′ is any other morphism with that property then there is a unique θ: F→F′ such that h′ = θ∘h. Which of CPO, CPO_{⊥}, CPO^{E} always have co-equalisers? [Warning This is rather hard. The same difficulty as in Exercise 5 arises.]

22. We can generalise from sums of cpos over sets ∑_{i∈S} D_{i} to sums over cpos. Let D be a cpo, which can as remarked in this chapter be considered as a category. A functor F: D → CPO_{⊥} is continuous iff whenever ⟨d_{n}⟩_{n∈ω} is an increasing ω-chain in D with lub d then ρ: Δ → F (d) is universal where Δ = ⟨F (d_{n}), F (d_{n} → d_{n+1})⟩ and ρ_{n} = F (d_{n} → d). [Everything works just as well if we use functors F: D → CPO^{E} instead.]

Now if D is a cpo and F: D → CPO_{⊥} is an ω-continuous functor, then ∑_{D} F is defined as the set {⟨d, e⟩ | e ∈ F (d)} ordered by:

⟨d, e⟩ ⊑ ⟨d′, e′⟩ iff d ⊑ d′ and F (d → d′)(e) ⊑_{F (d′)} e′.

Show that ∑_{D} F is a cpo. Show that by suitable choice of D and F, the sum ∑_{D} F can be any one of: A_{⊥}, A_{⊥} + B_{⊥}, A × B, ∑_{i∈S}(A_{i})_{⊥}.

23. We can generalise from products of cpos over sets to products over cpos too. Let D be a cpo and let F: D → CPO_{⊥} be a continuous functor as in Exercise 22. A function f: D → ⋃_{d∈D} F (d) is well-typed iff ∀d ∈ D.f(d) ∈ F (d); further it is monotonic iff ∀d, d′ ∈ D.d ⊑ d′ → (F (d → d′)(f(d)) ⊑ f(d′)); further it is continuous iff whenever ⟨d_{n}⟩_{n∈ω} is an increasing ω-chain with lub d then f(d) = ⨆_{n} F (d_{n} → d)(f(d_{n})).

We define ∏_{D} F to be the set {f: D → ⋃_{d∈D} F (d) | f is well-typed, monotonic and continuous} with the pointwise ordering:

f ⊑ g iff ∀d ∈ D.f(d) ⊑_{F (d)} g(d).

Show that ∏_{D} F is a cpo. Show that by a suitable choice of D and F the product ∏_{D} F can be any one of: A × B, A → B, ∏_{i∈S} A_{i}.

24. Let D be a cpo and F: D → CPO_{⊥} be a continuous functor as used in Exercises 22 and 23. Using an informal notation which we will leave informal here, define the natural function, in: ∏_{D} λd: D.(F (d) →_{⊥} ∑_{D} F) by:

in(d) = λe: F (d).⟨d, e⟩.

Show in is well-defined. Show that if E is any cpo and f: ∏_{D} λd: D.(F (d) →_{⊥} E) then there is a unique continuous [f]: ∑_{D} F →_{⊥} E such that for all d in D the following diagram commutes:

[figure: F (d); _{∑D} F; in(d); f(d); E; [f]]

Show that [·]: [∏_{D} λd: D.(F (d) →_{⊥} E)] ≅ (∑_{D} F →_{⊥} E). Give internal and external axiomatisations for ∑_{D} F (perhaps without worrying too much about the details of the metalanguage). Investigate ∏_{D} F along similar lines.

5. Solving Recursive Domain Equations

With the aid of our grand analogy we can now solve recursive domain equations by following the idea of the fixed-point theorem. Let F: CPO^{E} → CPO^{E} be a continuous functor, which is analogous to a continuous function, f: D → D. One fixed-point of f is the lub of the increasing ω-chain ⟨f^{m}(⊥)⟩_{m∈ω}. As U is the analogous of ⊥, we should find a direct ω-chain Δ = ⟨F^{m}(U), f_{mn}⟩ and as direct limits are the analogue of lubs of ω-chains we should then consider a universal cone, ρ: Δ → (lim_{→} Δ). It remains to specify the f_{m} (= f_{m(m+1)}). Now f_{0} must be ⊥: U → F (U) and it seems natural to take f_{m} = T^{m}(⊥). With this choice we can calculate:

F (lim_{→} Δ) ≅ lim_{→}⟨F (F^{m}(U)), F (F^{m}(⊥))⟩  F is continuous

= lim_{→} Δ dropping a term does not affect direct limits — see Exercise 4.13.

and we have indeed the equation D ≅ F (D). Note that the f_{m} are determined by the requirement that the above proof works. A little analysis shows what the isomorphism actually is. As ρ: Δ → lim_{→} Δ is universal we have F ρ: F Δ → F (lim_{→} Δ) is universal as F is continuous and on the other hand ρ^{−}: Δ^{−} → lim_{→} Δ is universal too where Δ^{−} = ⟨F^{m+1}(U), F^{m+1}(⊥)⟩ and ρ^{−} = ⟨ρ_{m+1}⟩_{m∈ω} by the considerations of Exercise 4.13. But F Δ = Δ^{−} and so there is an isomorphism θ: F ρ ≅ ρ^{−}, which by the considerations of Theorem 4 is ⨆_{m} ρ_{m+1} ∘ (F ρ_{m})^{R}, and θ^{−1} is ⨆_{m}(F ρ_{m}) ∘ ρ_{m+1}^{R}. We usually write θ: F (lim_{→} Δ) ≅ lim_{→} Δ as η_{F}.

It is also quite easy to solve simultaneous equations. Suppose for example we have two continuous functors, F_{i}: (CPO^{E})^{2} → CPO^{E} (i = 0,1). Define Γ = ⟨C_{n}, f_{n}⟩, Δ = ⟨D_{n}, g_{n}⟩ by:

C_{0} = D_{0} = U;
C_{n+1} = F_{0}(C_{n}, D_{n}); D_{n+1} = F_{1}(C_{n}, D_{n});
f_{0} = ⊥; g_{0} = ⊥;
f_{n+1} = F_{0}(f_{n}, g_{n}); g_{n+1} = F_{1}(f_{n}, g_{n}).

Now we can calculate:

F_{0}(lim_{→} Γ, lim_{→} Δ) ≅ lim_{→} F_{0}(Γ, Δ) = lim_{→} Γ^{−} = lim_{→} Γ

and similarly

F_{1}(lim_{→} Γ, lim_{→} Δ) ≅ lim_{→} Δ.

All in all we have essentially proved that:

Theorem 1. Let F_{i}: (CPO^{E})^{n} → CPO (i < n) be n continuous functors then there are cpos D_{0}, …, D_{n−1} such that:

D_{i} ≅ F_{i}(D_{0}, …, D_{n−1}) (i < n).

Proof. A slight generalisation of the above consideration and left to the reader.

In view of our analogy it is now natural to ask if our solutions to recursive domain equations are initial (analogue of least) in some sense. However we postpone this discussion for a while as we can now solve many problems in denotational semantics by using the solution. We now present a series of typical examples of the use of recursive domain equations.

Example 1 The Integers. We have already seen that N satisfies the equation N ≅ O 0 + N and so N ≅ T (N) where T = +^{E}(K_{O 0}^{E}, Id^{E}). Then we calculate T (U), T^{2}(U), …, T^{n}(U), … are:

[figure: ⊥; ⟨0, ⊤⟩; T (U); ⊥; ⟨0, ⊤⟩; ⟨1, ⟨0, ⊤⟩⟩; T^{2}(U); ⊥; ⟨0, ⊤⟩; …; ⟨1, ⟨0, ⊤⟩⟩; ⟨1, …, ⟨1, ⟨0, ⊤⟩⟩ …⟩; T^{n}(U)]

Figure XIV.

So U ⊆ T (U) ⊆ T^{2}(U) ⊆ ⋯ ⊆ T^{n}(U) ⊆ · · ·. Further the embeddings T^{m}(⊥) are the inclusions as ⊥ is and T preserves inclusions. Since the T^{m}(U) are all discrete it follows that D = lim_{→}⟨T^{m}(U), T^{m}(⊥)⟩ is ⋃_{m} T^{m}(U) with the evident (flat) ordering (following the considerations of Chapter 4). Thus the solution D is isomorphic to N. Example 2 Procedures in Imp. We consider the extension of Imp discussed in Chapter 4. By Theorem 1 there are solutions to the simultaneous recursive domain equations say:

α: C ≅ (S × PEnv) → (S × PEnv),
β: PEnv ≅ (Proc_{⊥} →_{⊥} C).

The semantic functions B: BExp→(S→T), A: Act→(S→S) are assumed given, as before, and C: Stat→C is defined by structural induction: C[[a]] = α^{−1}(λσ: S, π: PEnv.⟨A[[a]](σ), π⟩); (i) (ii) C[[dummy]] = α^{−1}(λσ: S, π: PEnv.⟨σ, π⟩); C[[s_{0}; s_{i}]] = α^{−1}(α(C[[s_{1}]]) ∘ α(C[[s_{0}]])); (iii) (iv) C[[if b then e_{0} else e_{1}]] = α^{−1}(λσ: S, π: PEnv.B[[b]](σ) → α(C[[e_{0}]])(σ, π) | α(C[[e_{1}]])(σ, π));

(v) C[[while b do s]] = μγ: C.α^{−1}(λσ: S, π: PEnv.B[[b]](σ) → α(γ)(α(C[[s]])(σ, π)) | ⟨σ, π⟩); (vi) C[[proc p begin s end]] = α^{−1}(λσ: S, π: PEnv.⟨σ, π[C[[s]]/p]⟩); (vii) C[[call p]] = α^{−1}(λσ: S, π: PEnv.α(β(π)[[p]])(σ, π)). Here ·[·/·]: PEnv × C × Proc → PEnv is defined by:

π[γ/p] = β^{−1}(λp′: Proc.p′ = p → γ | β(π)[[p′]]).

It is annoying to continually write all the isomorphisms such as α, α^{−1}, β, β^{−1} above and we usually omit them. Example 3 An Applied λ-calculus. \underline{Syntax}.

1. Id — a set of identifiers, ranged over by x.

2. Exp — the set of expressions ranged over by e and given in terms of Id and Exp by the syntax:

e ::= x | 0 | true | false | succ | pred | zero | δ | (if e then e else e) | e(e) | λx.e.

\underline{Semantic Domains}. Expressions will have values in a domain of values, V, which should contain T and N and since explicit self-application is allowed its function space (V → V) is also included and we define V recursively by:

V ≅ T + N + (V → V)_{⊥}.

The use of the semi-separated sum is to differentiate the least function from ⊥; the idea is that δ which is to discriminate between functions and basic values (T + N) should be, in some sense, sequential. \underline{Denotations}. The denotation function is E: Exp → (Env → V) where Env = Id →_{⊥} V. It is defined by structural induction on expressions: E[[x]] = λρ: Env.ρ[[x]]; (i) E[[0]] = λρ: Env.in_{1}(0); (ii) (iii) E[[true]] = λρ: Env.in_{0}(tt); (iv) E[[false]] = λρ: Env.in_{0}(ff );

(v) E[[succ]] = λρ: Env.in_{2} ∘ up(λv: V.in_{1}((v | N) + 1)); (vi) E[[pred]] = λρ: Env.in_{2} ∘ up(λv: V.in_{1}((v | N) − 1)); (vii) E[[zero]] = λρ: Env.in_{2} ∘ up(λv: V.in_{0} ∘ Z(v | N)); (viii) E[[δ]] = λρ: Env.in_{2} ∘ up(λv: V.in_{0} ∘ is_{2}(v)); (ix) E[[if e_{0} then e_{1} else e_{2}]] = λρ: Env.((E[[e_{0}]](ρ) | T) → E[[e_{1}]](ρ) | E[[e_{2}]](ρ));

(x) E[[e_{0}(e_{1})]] = λρ: Env.down(out_{2}(E[[e_{0}]](ρ)))(E[[e_{1}]](ρ)); (xi) E[[λx.e]] = λρ: Env.in_{2}(up(λv: V.E[[e]](ρ[v/x])));

where · [·/·]: Env × V × Id → Env is defined much as usual.

Example 4 Input/Output. \underline{Syntax}. We extend Imp with a command for inputting from an input channel and outputting to an output channel (we assume one of each). So the syntactic sets are BExp, Act, as before and Stat is given by:

s ::= a | dummy | read | write | (s; s) | (if b then s else s) | (while b do s).

\underline{Semantic Domains}. As well as a flat cpo of states, S, there will be an input cpo I and one output cpo O (e.g. I = N and O = T). There are also two basic functions: read: I ⊗ S →_{⊥} S, write: S →_{⊥} O (for example read might put the input in a standard location and write might take the output from some standard location). Commands are now elements of a cpo C = S →_{⊥} R where R is a domain of results (or resumptions). The cpo R contains S, for final states, I →_{⊥} R, for reading and O ⊗ R_{⊥} for outputting. So it is recursively defined by:

R ≅ S + (I →_{⊥} R)_{⊥} + (O ⊗ R_{⊥}).

Note that in this case there is not implicit or explicit self-application as can be seen from the fact that on the right hand side R never occurs in the contravariant position of an exponentiation functor.

\underline{Denotations}. We have a given B: BExp → (S → T) and a given A: Act → (S → S) and C: Stat → C is defined by structural induction on statements. We only give a few of the equations here.

(iii) C[[read]] = λ_{⊥}σ: S.in_{1}(up(λ_{⊥}i: I.in_{0}(read(i ⊗ σ)))); (iv) C[[write]] = λ_{⊥}σ: S.in_{2}(write(σ) ⊗ up(in_{0}(σ))); C[[s_{0}; s_{1}]] = λ_{⊥}σ: S.C[[s_{0}]](σ) ∗ C[[s_{1}]]. (v)

Here ∗: R × C → R is defined recursively by:

r ∗ γ = (is_{0}(r) → γ(out_{0}(r))
| (is_{1}(r) → in_{1}(up(λ_{⊥}i: I.(down(out_{1}(r)))(i) ∗ γ))
| (is_{2}(r) → in_{2}((out_{2}(r) ↓ 0) ⊗ up(down(out_{2}(r) ↓ 1) ∗ γ))
| ⊥))).

Example 5 Dynamic Binding. This is a version of Dec in which, as well as the usual static binding mechanism in which, in an expression of the form (let x be e_{0} in e_{1}), the variable x is assigned the value of e_{0} calculated in the “definition-time” environment, we also include a more “dynamic” version in which the calculation of e_{0} is postponed until the value of x is required for the evaluation of e_{1} and then the “use-time” environment is used.

\underline{Syntax}.

1. Id — a class of identifiers ranged over by x.

2. Exp — a class of expressions ranged over by e and given by:

e ::= x | 0 | 1 | (e + e) | (let x bestat e in e) | (let x bedyn e in e).

For example let x bestat 2 in (let y bedyn x + 1 in (let x bedyn 10 in x + y)) where 2 abbreviates 1 + 1 and so on, will have value 21 whereas if static assignment had been used throughout the expression would have had value 13.

\underline{Semantic Domains}. The cpo of environments, Env, rather than being Id →_{⊥} N must give an identifier a function of Env itself in order that the value of the identifier may depend on the call-time environment. So we define Env recursively by:

Env ≅ Id_{⊥} →_{⊥} (Env → N).

\underline{Denotations}. The denotation function is E: Exp → (Env → N) and it is defined by structural induction on expressions; we only give a few of the equations.

E[[x]] = λρ: Env.ρ[[x]](ρ); (i)

(v) E[[let x bestat e_{0} in e_{1}]] = λρ: Env.E[[e_{1}]](ρ[λρ′: Env.E[[e_{0}]](ρ)/x]); (vi) E[[let x bedyn e_{0} in e_{1}]] = λρ: Env.E[[e_{1}]](ρ[λρ′: Env.E[[e_{0}]](ρ′)/x]).

Here ·[·/·]: Env × (Env → N) × Id → Id is defined as usual.

Example 6 Syntax Considered as a CPO. As a matter of fact we could have considered syntax as a cpo much earlier. For example, in the case of Imp, we would consider the flat cpo Stat_{⊥}. However we would have had to define various functions over Stat_{⊥} and it turns out that if we define Stat_{⊥} by a recursive domain equation we get them for free, so to speak. Further as the recursive domain equation follows the grammar closely, we have a reasonably systematic method. (The caveat is inserted as it is not so clear how to accommodate non-context-free grammars, although we will always expect to have some sort of phrase structure.)

\underline{Syntax}. There are three cpos of syntactic items.

1. BExp — a given flat cpo of boolean expressions ranged over by b.

2. Act — a given flat cpo of primitive actions ranged over by a.

3. Stat — a cpo of statements specified by the recursive domain equation:

Stat ≅ Act + O 0 + Stat ⊗ Stat + BExp ⊗ Stat ⊗ Stat.

Note how the definition follows the syntactical specification in Chapter 1. Each alternative is modelled by a (strict) sum and the various components of a clause are put together by the strict product. This gives a flat cpo, which is a kind of abstract syntax in that there is no commitment as to how particular statements are to be written.

It is particularly tedious when using such syntactical domains to continually make type conversions using in, out, ⟨·, ·⟩, (· ↓ i), up, down, etc. We therefore define some helpful extra functions:

isact = is_{0};
actof = out_{0};
mkact = in_{0};
isdum = is_{1};
dumof = out_{1};
mkdum = in_{1};
isseq = is_{2};
seqof_{0} = π_{0} ∘ out_{2};
seqof_{1} = π_{1} ∘ out_{2};
mkseq = in_{2} ∘ ⊗;
iscond = is_{3};
condof_{0} = π_{0} ∘ out_{3};
condof_{1} = π_{1} ∘ out_{3};
condof_{2} = π_{2} ∘ out_{3};
mkcond = in_{3} ∘ ⊗.

\underline{Semantic Domains}. There are the flat cpos, T, of truth-values and N, of integers and also the cpo C = (S →_{⊥} S) of commands.

\underline{Denotations}. The functions B: BExp →_{⊥} (S →_{⊥} T) and A: Act →_{⊥} C are assumed given and are now elements of cpos. The functions C: Stat →_{⊥} C is defined by recursion as:

C = λ_{⊥}s: Stat.(isact(s) → A[[actof (s)]] |
(isdum(s) → (λ_{⊥}σ: S.σ) |
(isseq(s) → C[[seqof_{1}(s)]] ∘ C[[seqof_{0}(s)]] |

(iscond(s) → λ_{⊥}σ: S.(B[[condof_{0}(s)]](σ) → C[[condof_{1}(s)]](σ) | C[[condof_{2}(s)]](σ)) | ⊥)))).

Once we have the idea of specifying syntax in this way we can explore other kinds of equations for Stat. For example we might want to allow partially specified programs such as (⊥; (a; ⊥)) (where s; s′ is mkseq(s, s′) and so on) other than ⊥. This in turn will lead to infinite programs as the limit of increasing chains of the partial ones. There is a standard choice available: replace every occurrence of a recursively specified domain, D, on the right hand side by (D)_{⊥} to allow non-strict combination with ⊥. So we would now specify Stat by:

Stat ≅ Act + O 0 + Stat_{⊥} ⊗ Stat_{⊥} + BExp ⊗ Stat_{⊥} ⊗ Stat_{⊥}

which is the same as (see Exercise 3.18):

Stat ≅ Act + O 0 + (Stat × Stat)_{⊥} + BExp ⊗ (Stat × Stat)_{⊥}.

It would then be necessary to make a few changes in the definitions of the auxiliary functions. For example we would put:

isseq = is_{2};
seqof_{0} = down ∘ π_{0} ∘ out_{2};
seqof_{1} = down ∘ π_{1} ∘ out_{2};
mkseq = in_{2} ∘ ⊗ ∘ ⟨up, up⟩.

But then with these changes made the denotational function would have exactly the same definition as before. Note that we now have some identifications such as: ⊥_{Stat}; ⊥_{Stat} = ⊥_{Stat} and (if ⊥_{BExp} then e_{0} else e_{1}) = ⊥_{Stat}, but not others such as (⊥_{Stat}; s) = ⊥_{Stat} which we might want. All this is a matter of the choice of domain equation.

We now see how our solution is initial and concentrate on a fixed functor F: CPO^{E} → CPO^{E} of one argument. Recall that the solution we constructed was obtained from a universal cone ρ: Δ → lim_{→} Δ where Δ = ⟨F^{m}(U), F^{m}(⊥)⟩. Let us choose a fixed ρ for F and call lim_{→} Δ, Fix_{F}. The isomorphism η_{F}: F (Fix_{F}) → Fix_{F} is η_{F} = ⨆_{m} ρ_{m+1} ∘ F (ρ_{m})^{R} and its inverse is ⨆_{m} F (ρ_{m}) ∘ ρ_{m+1}^{R}, as we saw above. Our solution of the domain equation, D ≅ F (D), clearly consists of the pair ⟨Fix_{F} , η_{F} ⟩.

Definition 1. A fixed-point of F is a pair ⟨D, α⟩ where α: F D ≅ D. A prefixed-point of F is a pair ⟨D, α⟩ where α: F D ◁ D.

Sometimes prefixed-points are called F -algebras for reasons to be seen below.

Definition 2. Let ⟨D, α⟩ and ⟨D′, α′⟩ be prefixed-points of F. A morphism h: ⟨D, α⟩→⟨D′, α′⟩ (sometimes called an F -homomorphism) is an embedding h: D ◁ D′ such that the following diagram commutes:

[figure: F D′; D′; α′; F D; D; α; F h; h]

We already know that ⟨Fix_{F} , η_{F} ⟩ is a fixed-point of F; we now find the analogue of the fixed-point theorem:

Theorem 2 The Initial Fixed-point Theorem. The fixed-point ⟨Fix_{F} , η_{F} ⟩ is the initial prefixed-point of F. Proof. Suppose α: F D ◁ D is a prefixed-point of F. Put F_{m} = F^{m}(U), f_{m} = F^{m}(⊥), Δ = ⟨F_{m}, f_{m}⟩ and then as ρ: Δ → Fix_{F} is the universal cone, each triangle:

[figure: F (Fix_{F}); Fix_{F}; η_{F}; ρ_{m+1}; F (F_{m}); F (ρ_{m})]

commutes.

For uniqueness, suppose h: Fix_{F} ◁ D is a morphism of F -algebras so that this square commutes:

[figure: F (D); D; α; F (Fix_{F}); Fix_{F}; η_{F}; F h; h]

Now h ∘ ρ_{0} = ⊥ and h ∘ ρ_{m+1} = h ∘ η_{F} ∘ F (ρ_{m}) = α ∘ F (h) ∘ F (ρ_{m}) = α ∘ F (h ∘ ρ_{m}). So each h ∘ ρ_{m} is determined and so too therefore is h as h = h ∘ id_{Fix_{F}} = ⨆_{m}(h ∘ ρ_{m}) ∘ ρ_{m}^{R}.

For existence define ρ′_{m}: F_{m} ◁ D by: ρ′_{0} = ⊥, ρ′_{m+1} = α ∘ F (ρ′_{m}). Then ρ′ =^{def} ⟨ρ′_{m}⟩_{m∈ω} is a cone from Δ to D, i.e. each of these triangles commutes:

[figure: F_{m}; F_{m+1}; f_{m}; ρ′_{m}; D; ρ′_{m+1}]

For ρ′_{1}∘f_{0} = ρ′_{1}∘⊥ = ⊥ = ρ′_{0} and then, by induction, ρ′_{m+2}∘f_{m+1} = α∘F (ρ′_{m+1})∘F (f_{m}) = α∘F (ρ′_{m}) = ρ′_{m+1}.

Hence there is a mediating h: Fix_{F} ◁ D from ρ to ρ′ so that all of these triangles commute:

[figure: F_{m}; Fix_{F}; ρ_{m}; ρ′_{m}; D; h]

But this makes the above homomorphism square commute. For both h ∘ η_{F} and α ∘ F h mediate between the universal cone F ρ and (ρ′)^{−}: F Δ → D as can be seen from the following two diagrams:

[figure: D; Fix_{F}; h; F (F_{m}); F (Fix_{F}); F ρ_{m}; ρ′_{m+1}; η_{F}; ρ_{m+1}; D; F (D); α; F (F_{m}); F (Fix_{F}); F ρ_{m}; ρ′_{m+1}; F h; F ρ′_{m}]

This concludes the proof.

What we would like next would be a proof rule, an axiomatisation, for recursively defined domains. However this is not available at present and constitutes an interesting open problem. There are techniques available for particular cones. Investigations of typeless λ-calculi have looked at the F^{m}(U) in detail by labelling expressions and subexpressions by integers, for example e^{(m)}, and then investigating E[[e^{(m)}]] =^{def} ρ_{m}^{R}(E[[e]]). Other investigations have used recursively defined inductive relations to establish the particular properties in question. The difficulty arises from contravariance as we are able to give a satisfactory axiomatisation for covariant functors F: CPO_{⊥} → CPO_{⊥} where F =^{def} T^{E}. That is we have a satisfactory solution when domain equations do not contain any occurrences of the recursively specified cpos in contravariant positions (such as the first argument of an exponentiation). Our solution will be a general form of structural induction.

We begin by looking at T -algebra in CPO_{⊥}, where the terminology will make good sense. We consider a fixed covariant locally continuous functor, T: CPO_{⊥} → CPO_{⊥}.

Definition 3. A T -algebra is a pair ⟨D, α⟩ where α: T D →_{⊥} D is a strict continuous function. A T - homomorphism, h: ⟨D, α⟩ → ⟨D′, α′⟩ between T -algebras is a strict continuous function, h: D →_{⊥} D′ such that the following diagram commutes:

[figure: T D′; D′; α′; T D; D; α; T h; h]

Example 1 The Integers. Consider the continuous algebras A = ⟨A, 0, succ⟩ where A is a cpo, 0 is an element of A, and succ: A →_{⊥} A is a strict continuous function. A morphism h: ⟨A, 0, succ⟩ → ⟨A′, 0′, succ′⟩ is a continuous function h: A →_{⊥} A′ such that h(0) = 0′ and h(succ(x)) = succ′(h(x)), for all elements x of A.

Now suppose for the purpose of this example that T: CPO_{⊥} → CPO_{⊥} is given by T (D) = O 0 + D (more accurately, by T = +(K_{O 0}, Id)). Any algebra ⟨A, 0, succ⟩ induces the T -algebra α_{A}: O 0 + A → A where α_{A} = [λ_{⊥}x.0, succ]; conversely any T -algebra α: O 0 +D→D induces the algebra A_{α} = ⟨D, α∘inl(⊤), α∘inr⟩. The correspondences are functorial as if h: A →_{⊥} A′ is a homomorphism then h: ⟨A, α_{A}⟩ → ⟨A′, α_{A′}⟩ is a T -homomorphism and conversely. Then we see that the functors are mutual inverses — that is the categories are isomorphic.

Note that we have already shown how the integers form a T -algebra α: O 0 + N → N where α = [λ_{⊥}x.0, strict((+1))], and indeed α is an isomorphism. One easily proves that ⟨N, α⟩ is the initial T -algebra by induction. For suppose ⟨D, α′⟩ is another T -algebra and h: ⟨N, α⟩ →_{⊥} ⟨D, α′⟩ is a T -homomorphism. Then h(⊥) = ⊥, h(0) = h ∘ α(inl(⊤)) = α′ ∘ (id_{O 0} + h)(inl(⊤)) = α′(inl(⊤)) and h(n + 1) = h ∘ α(inr(n)) = α′ ∘(id_{O 0} +h)(inr(n)) = α′(h(n)). So it follows by ordinary induction that h is determined. One easily shows the converse: that if h is defined by the above equation (namely h(0) = h∘α(inl(⊤)) and h(n+1) = α′(h(n))) then h is a T -homomorphism. We saw above that Fix_{T^{E}} was isomorphic to the integers. We now see that (among many other things), ⟨Fix_{T^{E}}, η_{T^{E}}⟩ is the initial T -algebra and so we see that ⟨N, α⟩ and ⟨Fix_{T^{E}}, η_{T^{E}}⟩ are isomorphic as algebras.

Theorem 3 The Initial Algebra Theorem. The T^{E}-algebra, ⟨Fix_{T^{E}}, η_{T^{E}}⟩ is the initial T -algebra. Proof. Define F_{m}, f_{m}, Δ, ρ as in the proof of Theorem 2. Let ⟨D, α⟩ be a T -algebra. Uniqueness of a possible T -homomorphism, h: ⟨Fix_{T^{E}}, η_{T^{E}}⟩ →_{⊥} ⟨D, α⟩ is proved just as in Theorem 2.

For existence define ρ′_{m}: F_{m} →_{⊥} D by ρ′_{0} = ⊥, ρ′_{m+1} = α ∘ T (ρ′_{m}) then, as in the proof of Theorem 2, ρ′ =^{def} ⟨ρ′_{m}⟩_{m∈ω} is a cone, ρ′: Δ → D. By Exercise 4.17, ρ is universal in CPO_{⊥} and so there is a unique mediating h: ρ → ρ′. The proof then finishes as in Theorem 2 using the fact that T ρ is universal in CPO_{⊥} as it is universal in CPO^{E} (being T^{E}ρ).

One application of this theorem is when T is chosen for the specification of a recursively defined syntactical cpo. For instance, continuing Example 6 above we can consider:

T = +(K_{Act}, K_{O 0}, ⊗(Id, Id), ⊗(K_{BExp}, Id, Id).

Then if one can take the semantic domain, here C = (S→_{⊥} S), and turn it into a T -algebra, ⟨C, α⟩ it follows that there is a unique homomorphism h: ⟨Stat, η_{T^{E}}⟩ → ⟨C, α⟩ which we can take as the semantics. This view of semantics is called initial-algebra semantics. To see that it is reasonable, we note that in this case following the ideas in Example 1 above, a T -algebra amounts to a structure ⟨C, mkact′, mkdum′, mkseq′, mkcond′⟩ where mkact′: Act →_{⊥} C is strict, mkdum′: O 0 →_{⊥} C is strict, mkseq′: C × C →_{⊥} C is bistrict and mkcond′: BExp × C × C →_{⊥} C is tristrict and we have already seen that for Stat we obtain the algebra ⟨Stat, mkact, mkdum, mkseq, mkcond⟩. Then a homomorphism h: ⟨Stat, …⟩ → ⟨C, …⟩ is a strict continuous function h: Stat →_{⊥} C such that:

h(mkact(a)) = mkact′(a)  (a: Act),
h(mkdum(⊤)) = mkdum′(⊤),
h(mkseq(s_{0}, s_{1})) = mkseq′(h(s_{0}), h(s_{1}))  (s_{0}, s_{1}: Stat),
h(mkcond(b, s_{0}, s_{1})) = mkcond′(b, h(s_{0}), h(s_{1}))  (b: BExp, s_{0}, s_{1}: Stat)

and this is just an abstract form of the usual semantics if we define:

mkact′ = A,
mkdum′ = λ_{⊥}x: O 0 .(λ_{⊥}σ: S.σ),
mkseq′ = λγ: C, γ′: C.γ′ ∘ γ,
mkcond′ = λb: BExp, γ: C, γ′: C.λ_{⊥}σ: S.(B[[b]](σ) → γ(σ) | γ′(σ))

and indeed with this definition it turns out that h = C. Of course it is equally easy to give an initial algebra semantics treatment of the other kinds of syntactic cpos considered above.

From now on, although it is not really essential, we assume that T preserves inclusions (that is if ι: D ⊆ E then T (ι): T (D) ⊆ T (E)). This is the case for all our covariant functors and also for each of the functors: →(K_{D}, Id), →_{⊥}(K_{D}, Id) (i.e. those obtained by fixing the contravariant argument of the exponentiation functor); further this property is preserved under the composition of functors.

Theorem 4 The Structural Induction Theorem. Let α: T D→_{⊥}D be a T -algebra. Then the following assertions are equivalent.

(1) ⟨D, α⟩ is the initial T -algebra.

(2) The morphism, α, is a strict order-monic and further for every strict order-monic m: P →_{⊥} D if P can be extended to a T -algebra ⟨P, β⟩ such that m: ⟨P, β⟩ → ⟨D, α⟩ is a T -homomorphism then m is an isomorphism.

(3) The morphism m is an order-monic and further for every ω-inductive P ⊆ D the following principle of structural induction holds:

(P(⊥) ∧ (∀x: T (D).T (P)(x) ⇒ P(αx))) ⇒ ∀x: D.P(x).

(4) The morphism α is an isomorphism and id_{D} = μh.α ∘ T (h) ∘ α^{−1}. Proof. (1) ⇒ (2). From Theorem 1 we know that in the initial T -algebra (Fix_{T^{E}}, η_{T^{E}}) η_{T^{E}} is an isomorphism; so α is as well. Now suppose m: P →_{⊥} D is a strict order-monic and also m: ⟨P, β⟩ → ⟨D, α⟩ is a T - homomorphism. As ⟨D, α⟩ is initial there is a T -homomorphism h: ⟨D, α⟩→⟨P, β⟩. Then m∘h: ⟨D, α⟩→⟨D, α⟩ is a T -homomorphism which must be id_{D} as ⟨D, α⟩ is initial. Now we have m ∘ (h ∘ m) = m ∘ id which shows that h ∘ m = id as m is a monic. Thus m is an isomorphism with inverse h.

(2) ⇒ (1). First we show α is an isomorphism. Considering the diagram:

[figure: T D; D; α; T (T D); T D; T α; T α; α]

we can apply (2) with P = T D and m = α. So α is an isomorphism.

Next let ⟨P, β⟩ be the initial T^{E}-algebra, viz. ⟨Fix_{T^{E}}, η_{T^{E}}⟩. Then as we now know that ⟨D, α⟩ is a T^{E}-algebra, as α is an embedding being an isomorphism, there must be an embedding m: P ◁ D which is a homomorphism. As every embedding is a strict order-monic, we can apply (2) to see that m is an isomorphism and hence an isomorphism of the T -algebra. So ⟨D, α⟩ is isomorphic to ⟨P, β⟩ which is the initial T^{E}-algebra and so, by Theorem 3, is the initial T -algebra.

(2) ⇒ (3). Let P ⊆ D be ω-inductive and suppose that P(⊥) and ∀x: T (D).T (P)(x) ⇒ P(αx). Then ι: P ⊆ D is a strict order-monic. Define β: T P → P:

β(x) = α ∘ T ι(x).

This is well-defined by the assumption and since T ι is an inclusion as T preserves inclusions. Next β is strict as β(⊥_{T P}) = α(T ι(⊥_{T P})) = α(⊥_{T D}) = ⊥_{D} = ⊥_{P}; also β is continuous as β(⨆_{T P} x_{n}) = α(T ι(⨆_{T P} x_{n})) = α(⨆_{T D}(T ι(x_{n}))) = ⨆_{D} α ∘ T ι(x_{n}) = ⨆_{P} β(x_{n}). Next the following diagram commutes:

[figure: T D; D; α; T P; P; β; T ι; ι]

For any x in T (P), ι ∘ β(x) = ι ∘ α ∘ T ι(x) = α ∘ T ι(x). So we can apply (2) to find that ι is an isomorphism. But the ι is onto and we have that P = D.

(3) ⇒ (2). Suppose m: P →_{⊥} D is a strict order-monic and there is a β: T P → P such that m: ⟨P, β⟩ → ⟨D, α⟩ is a T -homomorphism. Then m factorises as P →^{θ} Q →^{ι} D where θ is an isomorphism and ι is an inclusion and Q(⊥_{D}) holds and Q is ω-inductive and we have the following commuting diagram.

[figure: T P; P; β; T θ; θ; T D; D; α; T Q; Q; T θ^{−1} ∘ β ∘ θ; T ι; ι]

Now suppose x: T (D) and T (Q)(x) then αx = α ∘ T ι(x) (T ι is an inclusion) = ι ∘ (T θ^{−1} ∘ β ∘ θ)(x) = T θ^{−1} ∘ β ∘ θ(x) ∈ Q. So we may apply (3) to see that D ⊆ Q and so ι = id_{D} and m = θ is an isomorphism.

(1) ⇒ (4). We already know (1) implies α is an isomorphism. Let h = μh.α ∘ T h ∘ α^{−1}. Then h = α ∘ T h ∘ α^{−1} and so h ∘ α = α ∘ T h which shows that h: ⟨D, α⟩ → ⟨D, α⟩ is a T -isomorphism. But then we must have h = id_{D} as ⟨D, α⟩ is initial.

(4) ⇒ (2). Suppose m: P →_{⊥} D is a strict order-monic and m: ⟨P, β⟩ → ⟨D, α⟩ is a T -homomorphism. Let α^{−1} be the inverse of α. Let g = μg.β ∘ T g ∘ α^{−1}. Then g = β ∘ T g ∘ α^{−1} and so g ∘ α = β ∘ T g and we see that the following diagram commutes.

[figure: T P; P; β; T m; m; T P; P; β; T D; D; α; T g; g]

We now show that m ∘ g = id. It will then follow that m is an isomorphism with inverse g from the fact that m is a monic, as in the first part of the proof.

First we show that m ∘ g ⊑ id by fixed point induction on the definition of g. Clearly m ∘ ⊥ = ⊥ ⊑ id, as m is strict. Now suppose, for the sake of the induction that m ∘ g ⊑ id. Then: m ∘ (β ∘ T g ∘ α^{−1}) = (α ∘ T m) ∘ (T g ∘ α^{−1}) = α ∘ T (m ∘ g) ∘ α^{−1} ⊑ id (by the induction hypothesis).

Finally we use the hypothesis that id = μh.α ∘ T h ∘ α^{−1} to prove that id ⊑ m ∘ g by fixed-point induction on the definition of μh.α ∘ T h ∘ α^{−1}. Clearly ⊥ ⊑ m ∘ g. Suppose h ⊑ m ∘ g. Then: α ∘ T h ∘ α^{−1} ⊑ α ∘ T (m ∘ g) ∘ α^{−1} = α ∘ (T m ∘ T g) ∘ α^{−1} = (m ∘ β) ∘ T g ∘ α^{−1} = m ∘ g (as g = β ∘ T g ∘ α^{−1}). This concludes the proof.

Note that the only place the assumption that T preserves inclusions was used was in the proof of the equivalence of (2) and (3). If this were to fail we could just use (2) in place of (3). For information on strict order-monics consult Exercise 2.28. Part (4) is sometimes used in axiomatisations, but it is invariably used to derive a form of structural induction and we only include it for the sake of completeness.

So as our internal axiomatisation we can now just take Theorem 3.3. In this form the axioms are a little unfamiliar and we now see how they work out with a few examples.

Example 1 The Integers. Here we have the algebra α: O 0 + D ≅ D where T = +(K_{O 0}, Id), α = η_{T} and D = Fix_{T}. Now we can define 0 = α(inl(⊤)), succ = α ∘ inr and iszero = isl ∘ α^{−1}, pred = outr ∘ α^{−1}. Conversely α and α^{−1} can be defined in terms of them by: α = [λ_{⊥}x: O 0 .0, succ], α^{−1} = (λ_{⊥}n: D.iszero(n) → inl(⊤) | inr(pred(n))) as is easily verified.

The following axioms are equivalent to α^{−1} ∘ α = id, as is also easily verified (and α^{−1} ∘ α = id implies α is strict order-monic):

(1) pred(0) = ⊥,

(2) pred(succ(x)) = x,

(3) iszero(0) = tt,

(4) iszero(succ(x)) = (∂x → ff | ⊥).

We obtain essentially the usual form of induction by rewriting the main clause of the structural induction principle:

(∀x: T (D).T (P)(x) ⇒ P(αx)) ≡ ∀x: O 0 + D.(O 0 + P)(x) ⇒ P(αx)
≡ [∀x: O 0 .P(α ∘ inl(x))] ∧ [∀x: P.P(α ∘ inr(x))]
≡ P(⊥) ∧ P(0) ∧ ∀x: P.P(succ(x)).

Thus we obtain the following principle for all ω-inductive P ⊆ D (which is to say, all P ⊆ D):

(5) [P(⊥) ∧ P(0) ∧ (∀x: P.P(succ(x)))] ⇒ ∀x.P(x).

This together with (1)–(4) can be considered as a form of the Peano axioms adapted from the category of sets to CPO_{⊥}. Instead of proving that (N, 0, +1) was also the initial T -algebra we could just observe that it satisfies the above axioms (with (−1) and Z). Then the isomorphism with (D, η_{T}) follows from Theorem 4.

Example 2 Tapes. Here we consider T (D) = T ⊗ D_{⊥} and the initial algebra α: T ⊗ D_{⊥} →_{⊥} D. The appropriate auxiliary functions are cons = α ∘ ⊗(id_{T} × up): T × D → D; head = π_{0} ∘ α^{−1}: D →_{⊥} T; tail = down ∘ π_{1} ∘ α^{−1}: D →_{⊥} D. Then the equivalent axioms to α^{−1} ∘ α = id are:

(1) cons(⊥, x) = x,

(2) head(cons(t, x)) = t,

(3) tail(cons(t, x)) = (∂t → x | ⊥).

For structural induction we look at:

∀x: T ⊗ D_{⊥}.(T ⊗ P_{⊥})(x) ⇒ P(αx) ≡ ∀t: T.∀x: P_{⊥}.P_{⊥}(x) ⇒ P(α(t ⊗ x))
≡ [∀t: T.∀x: P.P(x) ⇒ P(α(t ⊗ up(x)))] ∧ ∀t: T.P(α(t ⊗ ⊥))
≡ [∀t: T.∀x: P.P(x) ⇒ P(cons(t, x))] ∧ P(⊥)

and we have the following structural induction principle for ω-inductive subsets of D:

[P(⊥) ∧ (∀t: T.∀x: P.P(x) ⇒ P(cons(t, x)))] ⇒ ∀x.P(x).

Again we can use this axiomatisation to show that ⟨D, α⟩ is isomorphic to an algebra with Tapes.

Example 3 Results as in Example 4. Here T = +(K_{S}, (→_{⊥}(K_{I}, Id))_{⊥}, ⊗(K_{O}, (Id)_{⊥})) and the initial algebra is, say, α: S + (I →_{⊥} R)_{⊥} + (O ⊗ R_{⊥}) →_{⊥} R. An auxiliary functions we define:

mkend = α ∘ in_{0}: S →_{⊥} R;
isend = is_{0} ∘ α^{−1}: R →_{⊥} T;
endof = out_{0} ∘ α^{−1}: R →_{⊥} S;
mkinp = α ∘ in_{1} ∘ up: (I →_{⊥} R) → R;
isinp = is_{1} ∘ α^{−1}: R →_{⊥} T;
inpof = down ∘ out_{1} ∘ α^{−1}: R → (I → R);
mkout = α ∘ ⊗ ∘ (id × up): O × R → R;
outof = π_{0} ∘ out_{2} ∘ α^{−1}: R →_{⊥} O;
restof = down ∘ π_{1} ∘ out_{2} ∘ α^{−1}: R →_{⊥} R;

The equation for α^{−1} ∘ α = id are:

(1) endof (mkend(σ)) = σ  (σ: S);
(2) inpof (mkinp(f)) = f  (f: I →_{⊥} R);
(3) mkout(⊥, r) = ⊥  (r: R);
(4) outof (mkout(o, r)) = o  (o: O, r: R);
(5) restof (mkout(o, r)) = (∂o → r | ⊥)  (o: O,r: R);
(6) isend(mkend(σ)) = (∂σ → tt | ⊥)  (σ: S);
(7) isend(mkinp(f)) = ff  (f: I →_{⊥} R);
(8) isend(mkout(o, r)) = (∂o → ff | ⊥)  (o: O, r: R);
(9) isinp(mkend(σ)) = (∂σ → ff | ⊥)  (σ: S);
(10) isinp(mkinp(f)) = tt  (f: I →_{⊥} R);
(11) isinp(mkout(o, r)) = (∂o → ff | ⊥)  (o: O, r: R).

For structural induction we look at: ∀x: S + (I →_{⊥} P)_{⊥} + (O ⊗ P_{⊥}).P(αx) ≡ A ∧ B ∧ C where:

A = ∀σ: S.P(α ∘ in_{0}(σ))
≡ ∀σ: S.P(mkend(σ))
B = ∀x: (I →_{⊥} P)_{⊥}.P(α ∘ in_{1}(x))
≡ P(⊥) ∧ ∀f: I →_{⊥} P.P(α ∘ in_{1} ∘ up(f))
≡ P(⊥) ∧ ∀f: I →_{⊥} R.[(∀i: I.P(fi)) ⇒ P(mkinp(f))]
C = ∀w: O ⊗ P_{⊥}.P(α ∘ in_{2}(w))
≡ ∀o: O.∀x: P_{⊥}.P(α ∘ in_{2}(o ⊗ x))
≡ P(⊥) ∧ ∀o: O.∀r: P.P(α ∘ in_{2}(o ⊗ up(r)))
≡ P(⊥) ∧ ∀o: O.∀r: R.(P(r) ⇒ P(mkout(o, r)))

and this gives us the following induction principle for ω-inductive subsets, P, of R:

[P(⊥) ∧ (∀σ: S.P(mkend(σ)))
∧ (∀f: I →_{⊥} R.[(∀i: I.P(fi)) ⇒ P(mkinp(f))])
∧ (∀o: O.∀r: R.(P(r) ⇒ P(mkout(o, r))))] ⇒ ∀r: R.P(r).

6. Algebraic Domains

Algebraicity is an important idea which formalises some intuitive ideas in CW/2 and Chapter 1 pp. 5– 8 of finiteness (finite amount of information) and objects as limits of their finite approximations. All of the previous constructions easily accommodate algebraicity except for exponentiation (which will need yet another axiom). Algebraicity allows definitions of computability to provide links with recursive function theory and allow results on definability. It allows easy consideration of constructions such as powerdomains and enables us to visualise domains as completions of structures of finite information.

Definition. Let D be a cpo. An element d is finite (= isolated = compact) iff for all increasing chains, ⟨x_{n}⟩ of elements of D, d ⊑ _{⨆n} x_{n} implies that there is an n such that d ⊑ x_{n}. Idea: finite — finite amount of information.

Examples 0. ⊥ is finite.

1. Every element in a discrete or a finite cpo is finite.

2. The finite elements in V_{ω}, {P \atop ω}, T^{ω}, Tapes, Trees, … are the evident ones.

3. For cpos D, E and finite elements d, e of D, E respectively. The step-functions (d ⇒ e) (or, sometimes, written e⃗[d, e]) defined by:

(d ⇒ e)(x) = \{ \begin{matrix}e & (x ⊒ d), \\ ⊥ & (otherwise) \end{matrix}

is continuous and finite.

4. If d, e are finite elements of D, so is d ⊔ e if it exists, but d ⊓ e need not be when it exists.

5. Finite ≠ Finite Height. e.g. V_{ω+1}:

[figure: 0; 1; n; ω; ω + 1; ⋮; ⋮]

or (K⊤) (= ⊥ ⇒ ⊤) in N → O 0 . But it is often the case as in {P \atop ω}, T^{ω}, Tapes, Trees, . . ..

Definition. A cpo is ω-algebraic (= countably algebraic) iff for every point x in D there is an increasing chain ⟨d_{n}⟩ of finite elements such that x = ⨆_{n} d_{n} and, furthermore, there are denumerably many finite elements altogether. Idea: Points are “real” (= finite) or “ideal” (= limits).

Examples 1. Discrete and finite cpos; V_{ω}, {P \atop ω}, T^{ω}, Tapes, Trees, . . ..

2. Origin of Names. Let A = ⟨A, +⟩ be an algebra with one binary operation +: A^{2} → A (say). The subalgebras are (essentially) the sets X ⊆ A such that X + X ⊆ X (i.e. closed under +). Under inclusion the subalgebras form a complete lattice which is ω-algebraic.

3. The interval [0, 1] under ≤ is a cpo which is not algebraic, similarly R (CW/3 p. 9) is not ω-algebraic. Can you add more points to [0, 1] (intervals to R) to make it ω-algebraic? These kinds of cpos can be dealt with by an idea of ω-continuity.

4. The example here is not ω-algebraic:

[figure: ⊥; 0; n; ω; ?; ⋮; ⋮]

Note. On the whole ω-continuous domains are not much used although there is hope [Nasser Saheb-Djahromi: Probabilistic Non-Determinism, CSR-7-77, Dept. of Computer Science, University of Edinburgh]. So we do not consider them in this part of the course.

Exercises 1 Alternative Definitions. One often sees the following alternative series of definitions. Let D be a partial order. A subset X of D is directed iff X ≠ ∅ and if d, e ∈ X then there is an x in X such that d ⊑ x and e ⊑ x. Then D is a dcpo iff it has a least element, ⊥, and every directed subset, X, has a lub, ⨆_{D} X. An element, d, of a dcpo D is finite iff for every directed set X, d ⊑ ⨆ X implies d ⊑ x for some member, x, of X. The dcpo D is algebraic iff for every element x, the set B_{x} = {d ∈ D | d finite ∧ d ⊑ x} is directed and has lub x; it is ω-algebraic if it is algebraic and has denumerably many finite elements. (If we want to talk about both sets of concepts at once we can write ω-cpo/dcpo ω-finite/dfinite etc.: only in the exercises will this be needed.)

Show that these two definitions of ω-algebraic coincide.

2 Topology. The order-topology on any cpo D has as open sets those sets O s.t.:

(1) x ∈ O ∧ x ⊑ y ⇒ y ∈ O,

(2) ⨆_{n} x_{n} ∈ O ∧ ⟨x_{n}⟩↑ ⇒ ∃n.x_{n} ∈ O.

Show that if D is ω-algebraic, the sets O_{d} = {x ∈ D | x ⊒ d} (d finite) form a denumerable subbasis of compact open sets for the order-topology.

3 Notions of Finiteness. Call the property of being ω-finite I_{0}. Define for a given ω-cpo D:

I_{1}(d) ≡ ∀ increasing ⟨d_{n}⟩.d = ⨆_{n} d_{n} ⇒ ∃n.d = d_{n}.

For some notions of finite height, first in any partial order, P is a ⊑ b are elements of P the interval [a, b] = {x | a ⊑ x ⊑ b} and a chain in P is just a totally ordered subset of P (i.e. X ⊆ P is a chain iff ∀x, y ∈ X.x ⊑ y ∨ y ⊑ x). So far in these notes only ω-chains were considered. Now define in D:

H_{0}(d) ≡ [⊥, d] is finite,
H_{1}(d) ≡ there is an upper bound on the cardinality of any chain in [⊥, d],
H_{2}(d) ≡ every chain in [⊥, d] is finite,
H_{3}(d) ≡ there is no increasing ω-chain ⟨d_{n}⟩ with d_{n} ⊑ d for all n,
H_{4}(d) ≡ there is no decreasing countably infinite chain d = d_{0} ⊒ d_{1} ⊒ d_{2} ….

Show that following implications and that these are all that hold for an arbitrary cpo.

I_{0} → I_{1}  H_{0} → H_{1} H_{2} ; ↗ ; ↘ ; H_{3}

What happens if D is given to be ω-algebraic?

Continuous Functions

We formalise CW/2 pp. 13, 14 and Chapter 1 p. 6. Idea (2) on p. 13 gives as “ε-δ” version of continuity. Note parts (1), (3) are true for ω-algebraic cpos.

Theorem 1. Let D and E be ω-algebraic cpos. Then f: D → E is continuous iff for all x in D and finite c in E:

c ⊑ f(x) ≡ ∃ finite b in D.b ⊑ x ∧ c ⊑ f(b).

Proof. ⇒) Suppose f is continuous.

Suppose c ⊑ f(x) for x in D, c finite in E. Then x = ⨆_{n} b_{n} where ⟨b_{n}⟩ is an increasing ω-chain of finite elements in E. So c ⊑ f(x) = ⨆_{n} f(b_{n}) by continuity. So as c is finite, for some n, c ⊑ f(b_{n}).

Suppose c ⊑ f(b) ∧ b ⊑ x for a finite b in D. Then, by monotonicity c ⊑ f(b) ⊑ f(x).

⇐) Suppose the equivalence holds. For monotonicity suppose x ⊑ y holds in D, and c ⊑ f(x) for a finite c. Then for a finite b in D, b ⊑ x ∧ c ⊑ f(b). So b ⊑ y (as x ⊑ y) ∧c ⊑ f(b). So c ⊑ f(y). So ∀ finite c in E.c ⊑ f(x) ⇒ c ⊑ f(y). So f(x) ⊑ f(y).

For continuity suppose ⟨x_{n}⟩ is an increasing ω-chain in D. By monotonicity, f(⨆_{n} x_{n}) ⊒ ⨆_{n} f(x_{n}). Suppose c ⊑ f(⨆_{n} x_{n}) for a finite c. Then for a finite b ⊑ ⨆_{n} x_{n}, c ⊑ f(b). Then for some n, b ⊑ x_{n} and so c ⊑ f(b) ⊑ f(x_{n}), by monotonicity, showing that for any finite c, c ⊑ f(⨆_{n} x_{n}) ⇒ c ⊑ ⨆_{n} f(x_{n}). Thus f(⨆_{n} x_{n}) ⊑ f(x_{n}).

Exercises

1. Reformulate the ε-δ condition as the conjunction of:

(1) f is monotonic,

(2) ∀x ∈ D.∀ finite c ∈ E.(c ⊑ f(x) ⇒ ∃ finite b ∈ D.b ⊑ x ∧ c ⊑ f(b)).

2. Use ε-δ to show that the identity is continuous, that the composition of continuous functions is continuous and that ⊓ if it always exists is continuous. Is the latter true in a general cpo?

3. Show that for a continuous f: D → E between ω-algebraic cpos, f: D → E is continuous iff:

f = ⨆{b ⇒ c | b, c finite elements of D, E respectively}.

Completion by Ideals

Every ω-algebraic cpo is determined by its basis (its set of finite elements). We investigate this determination.

Definition. A countable pointed quasiorder (ω-pq) is a structure ⟨P, ⊑, ⊥⟩ with P countable, ⊑ a quasiorder and ⊥ the least element.

If D is ω-algebraic B_{D} =^{def} ⟨{b ∈ D | b finite}, ⊑, ⊥⟩ is a countable pointed po. (all inherited from D); B_{D} is called the basis of D. (It is convenient to let the above equation define B_{D} for all cpos D.) Ideas: Let P be a countable pointed quasiorder. A subset X of P is an ideal iff:

(1) Pointed ⊥ ∈ X,

(2) Left Closed ∀y ∈ X.∀x ∈ P.x ⊑ y ⇒ x ∈ X.

An ideal is directed iff any two elements of the ideal have an upper bound in the ideal.

Exercise

1. Show that for any subset X of P there is a smallest ideal which contains it (called the generated ideal). Show that the directed ideals are just the ideals generated by (= least ideals containing) increasing ω-chains.

Completion

Let P be an ω-pq. Its completion by ideals is \overline{P} =^{def} \{X ⊆ P | X is a directed ideal of P\} ordered by inclusion: X ⊑ Y iff X ⊆ Y. Let [·]: P → \overline{P} be the monotonic map where [x] =^{def} \{y ∈ P | y ⊑ x\}.

Theorem 2.

(1) For any countable pointed quasiorder P, \overline{P} is ω-algebraic. Further for any other ω-algebraic cpo D and (strict) monotonic map f: P → D there is a unique continuous map f^{♯}: \overline{P} → D such that the following (strict) diagram commutes:

[figure: \overline{P}; D; f^{♯}; f; P; [·]]

(2) For any ω-algebraic D, D ≅ \overline{B_{D}}. (Further for any countable pointed quasiorder, B\overline{P} = \{[x] | x ∈

P} = [P], i.e. P/≡ where ≡ is the equivalence associated with the quasiorder.) Proof. (1) The least element of \overline{P} is \{⊥_{P}\}. ⨆ is ⋃ on increasing ω-chains, as is all obvious. For b ∈ P, [b] is finite as [b] ⊑ ⋃ X_{n} ⇒ b ∈ X_{n} for some X_{n}. For any directed ideal X there is a cofinal increasing chain x_{n} in X (i.e. ∀x ∈ X.∃n.x ⊑ x_{n}). Then X = ⋃[x_{n}] expresses the ideal as a lub of an increasing chain of finite elements of the form [x]. So every finite element has that form and \overline{P} is ω-algebraic.

Suppose the diagram commutes. Then:

f^{♯}(X) = f^{♯}(⨆_{n}[x_{n}])  x_{n} a cofinal chain in X

= ⨆_{n} f^{♯}([x_{n}])

= ⨆_{n} f(x_{n}).

So f^{♯} is determined. Conversely use this equation to determine f^{♯}, as the definition is independent of the choice of cofinal set and check the triangle (f^{♯} is strict iff f is).

(2) The isomorphism θ: D → \overline{B_{D}} is: θ(x) = \{b ∈ B_{D} | b ⊑ x\}. It has inverse θ^{−1}(X) = ⨆_{D} x_{n}. The last assertion is part of the proof of (1).

Examples

1. If, as with discrete cpos or finite ones, all points are finite then D ≅ B_{D} and \overline{B_{D}} ≅ B_{D}. (So D ≅ \overline{D}. Any other examples?)

2. V = \overline{ω} where ω = ⟨\{n ∈ ω\}, ≤⟩. What is \overline{ω × ω}? What is \overline{V_{ω}}?

3. {P \atop ω} = \overline{Finite Subsets of ω}, Tapes = \overline{Finite Tapes} etc, etc.

Exercises 1 Cantor Space. What is \overline{Rat} where Rat is the rationals in 0, 1 with the usual order? It is not [0, 1] as that is not ω-algebraic. Show [0, 1] ◁ \overline{Rat} showing projections need not preserve ω-algebraicity.

2 Infinite Words. Let Σ be a finite alphabet. Order (Σ ∪ {⊥})^{∗} by (1) ⊥ ⊑ x,

(2) If x ⊑ x′, y ⊑ y′ then xy ⊑ x′y′. Let Words = \overline{(Σ ∪ \{⊥\})^{∗}}. It is a domain of finite and infinite words. (Say Σ = \{0, 1\}.) What are the solutions to the equations x = 0x, x = x0, x = 0x0? Are they the same? Does Words have lubs/glbs of pairs of elements?

3. If f: P → P′ is a monotonic function of countable pointed quasiorders then \overline{f}: \overline{P} → \overline{P′} is defined by:

\overline{f}(X) = \{y ∈ P′ | ∃x ∈ X.y ⊑ f(x)\}.

Show this makes \overline{f} well-defined and continuous and indeed that \overline{f} = ([·]′∘f)^{♯}, the unique continuous g: \overline{P}→\overline{P′} s.t. the following diagram commutes:

[figure: \overline{P}; \overline{P′}; g; P; P′; f; [·]; [·]′]

Conclude that the correspondence f ↦ \overline{f} is functorial i.e. that \overline{g ∘ f} = \overline{g} ∘ \overline{f} and \overline{id_{P}} = id\overline{P}. Show that the correspondence is an isomorphism of P → P′, the monotonic functions from P to P′, and \overline{P} →_{fin} \overline{P′} the continuous functions from \overline{P} to \overline{P′} which preserves finiteness.

4. Show that the correspondence f to f^{♯} of the theorem is an isomorphism as is shown by the following axioms (external):

\begin{matrix}∀f: P → D.f = f^{♯} ∘ [·], \\ ∀g: \overline{P} → D.g = (g ∘ [·])^{♯}. \end{matrix}

Note that in the case P = B_{C} for C ω-algebraic we have (C → D) ≅ (B_{C} → D) showing that the continuous functions are just given by monotonic functions on their base.

5. A clumsier way to define completions is to use cofinal chains. If ⟨a_{n}⟩, ⟨b_{m}⟩ are increasing chains in an ω-pq P then they are cofinal, written ⟨a_{n}⟩ ∼ ⟨b_{m}⟩ iff:

(∀n.∃m.a_{n} ⊑ b_{m}) ∧ (∀m.∃n.b_{m} ⊑ a_{n}).

Show that \overline{P} ≅ the equivalence classes of cofinal chains in P ordered by:

[⟨a_{n}⟩]_{∼} ⊑ [⟨b_{m}⟩]_{∼} iff ∀n.∃m.a_{n} ⊑ b_{m}.

6. The definition of \overline{P} does not use the countability of P. Develop a version of Theorem 2, for arbitrary quasiorders, P, and algebraic dcpos D. Show that the map ⨆: \overline{D} → D (where D is any algebraic dcpo) defined by:

⨆(X) = ⨆_{D} x

is continuous and universal in the sense that if f: \overline{P} → D is any other continuous map then there is a unique monotonic map f^{♭}: P → D such that the following diagram commutes:

[figure: \overline{D}; \overline{P}; \overline{f^{♭}}; D; ⨆; f]

7. Show that there is a completion P̃, which retains existing ω-lubs. More precisely, a function f: P → Q of quasiorders is continuous if for every increasing chain ⟨x_{n}⟩ in P s.t. ⨆_{P} x_{n} exists, so does ⨆_{Q} f(x_{n}) and f(⨆_{P} x_{n}) = ⨆_{Q} f(x_{n}).

We want a cpo P̃ and a continuous map [·]: P → P̃ such that if f: P → D is any other continuous map with D a cpo then there is a unique continuous map f^{♯}: P̃ → D s.t. the following diagram commutes:

[figure: P̃; D; f^{♯}; f; P; [·]]

(Warning This is quite hard. If you solve it you should then be able to solve Exercises 20, 21 of Chapter 4.)

The following little lemma will be handy. Lemma 1. For any cpo D, if B ⊆ B_{D} has the property that every element in D is a lub of an increasing ω-chain of elements in B then B_{D} = B and D is ω-algebraic if B is denumerable. Proof. Easy exercise. I: Products. The product P × Q of two countable pointed quasiorders is defined as the Cartesian product with the coordinatewise ordering. As such it is also a countable pointed quasiordering. Fact. For any ω-algebraic cpos D and E, D × E is ω-algebraic and, indeed, B_{D×E} = B_{D} × B_{E}. Proof. If ⟨d, e⟩ ∈ B_{D} × B_{E} and ⟨x_{n}, y_{n}⟩ is an increasing chain in D × E s.t. ⟨d, e⟩ ⊑ ⨆_{n}⟨x_{n}, y_{n}⟩ then d ⊑ ⨆_{n} x_{n}, e ⊑ ⨆_{n} y_{n} and so for some n_{1}, n_{2} d ⊑ x_{n_{1}}, e ⊑ y_{n_{2}} and so for n = max(n_{1}, n_{2}), ⟨d, e⟩ ⊑ ⟨x_{n}, y_{n}⟩. Thus B_{D} × B_{E} ⊆ B_{D×E}.

If ⟨x, y⟩ ∈ D×E then x = ⨆_{n} d_{n} for an increasing ω-chain of D-finite elements and similarly y = ⨆_{n} e_{n}. Then ⟨x, y⟩ = ⨆_{n}⟨d_{n}, e_{n}⟩ expresses ⟨x, y⟩ as the lub of an increasing chain of elements of B_{D} × B_{E}. So by Lemma 1, B_{D} × B_{E} = B_{D×E} and D × E is ω-algebraic. Corollary. For any two countable pointed quasiorders, P, Q:

\overline{P × Q} ≅ \overline{P} × \overline{Q}.

Proof.

B_{\overline{P}×\overline{Q}} = B\overline{P} × B\overline{Q}  by the Fact
≅ (P/≡) × (Q/≡)  Theorem 2
≅ (P × Q)/≡
≅ B\overline{P×Q}  Theorem 2.

Exercises

1. Show that \overline{P} ←^{\overline{π_{0}}} \overline{P × Q} →^{\overline{π_{1}}} \overline{Q} form the universal pair of projection maps.

2. Show ω-algebraicity is preserved by finite and ω-products. II: Function Space. The function space construction does not preserve ω-algebraicity. Counterexamples 1.

[figure: ⊥; a; b; n; 2; 1; 0; ⋮; ⋮]

[figure: ⊥; 0; 0′; 1; 1′; 2; 2′; n; n′; ⋮; ⋮; ⋮; ⋮]

3.

[figure: ⊥; a; b; 0; 1; 2; n; …; …]

Open Problem. Is there a weaker condition than ω-algebraicity which will remove this blemish but keep all the other good points of ω-algebraicity? (One possibility is that the complete lattice of open sets (under inclusion) of the cpo is ω-algebraic.)

We will deal with function spaces by adding completeness axioms (lattice, etc.).

Exercise 1. Show \overline{P →^{monotonic} Q} ≠ \overline{P} →^{continuous} \overline{Q}.

This means that there is no evident way to turn B_{D} into a functor. However from the ε-δ Theorem 1, any continuous f: D → E is given by {⟨a, b⟩ ∈ B_{D} × B_{E} | b ⊑ f(a)} and we can use this to turn the countable pointed partial orders into a suitable category. Define a morphism R: P → Q of countable pointed partial orders as any R ⊂ P × Q such that:

(1) ∀a ∈ P.∃b ∈ Q.aRb.

(2) ∀a, a′ ∈ P.∀b, b′ ∈ Q.a′ ⊒ aRb ⊒ b′ ⇒ a′Rb′.

(3) ∀a, a′, a′′ ∈ P.∀b′, b′′ ∈ Q.(a ⊒ a′ ∧ a ⊒ a′′ ∧ a′Rb′ ∧ a′′Rb′′ ⇒ ∃b ⊒ b′, b′′.aRb). Provide a definition of identity and composition to obtain a category ω-PP and define the evident functor B: ω-ALG → ω-PP where ω-ALG is the category of ω-algebraic cpos and continuous functions. Define, too, a functor \overline{(·)}: ω-PP → ω-ALG and show that the two functors are a natural isomorphism of categories (see MacLane for a definition of this concept).

III: Disjoint Sum. For two given countable pointed quasiorders their disjoint sum is defined just as we did for cpos.

Fact. For any ω-algebraic cpos D and E, D+E is ω-algebraic with B_{D+E} = inl(B_{D})∪inr(B_{E}) = B_{D}+B_{E}. Proof. Left to the reader (the last part is by definition).

Corollary. For any two countable pointed quasiorders P and Q:

\overline{P + Q} ≅ \overline{P} + \overline{Q}.

IV: Smash Product. For two given countable pointed quasiorders their smash product is defined just as we did for cpos.

Fact. For any two ω-algebraic cpos D and E, D ⊗ E is ω-algebraic with B_{D⊗E} = B_{D} ⊗ B_{E}.

Corollary. For any two countable pointed quasiorders P, Q:

\overline{P ⊗ Q} ≅ \overline{P} ⊗ \overline{Q}.

V: Lifting. For one given countable pointed quasiorder P, its lifting (P_{⊥}) is defined just as we did for cpos.

Fact. For any one ω-algebraic cpo, D, D_{⊥} is ω-algebraic with B_{D_{⊥}} = (B_{D})_{⊥}.

Corollary. For any one countable pointed quasiorder P: (\overline{P})_{⊥} ≅ (\overline{P_{⊥}}).

Exercise 1. Show the following for two countable pointed quasiorders P, Q:

(1) \overline{P} →^{\overline{inl}} \overline{P + Q} ←^{\overline{inr}} \overline{Q} is a universal pair.

(2) \overline{P × Q} →^{\overline{⊗}} \overline{P ⊗ Q} is a universal bistrict map.

(3) \overline{P} →^{\overline{up}} \overline{P_{⊥}} is a universal continuous map. Here \overline{inl}, …, \overline{up} are defined by analogy with Chapter 3.

VI: Direct Limit of Embeddings.

Lemma 2. If f: D ◁ E then f(B_{D}) ⊆ B_{E}. Proof. Take d ∈ B_{D} and let ⟨x_{n}⟩ be an increasing ω-chain in E such that f(d) ⊑ ⨆_{n} x_{n}, then d = f^{R}(f(d)) ⊑ ⨆_{n} f^{R}(x_{n}) and so for some n, d ⊑ f^{R}(x_{n}). Then f(d) ⊑ f ∘ f^{R}(x_{n}) ⊑ x_{n} showing f(d) is finite.

Exercise 1. Show f^{R}(B_{E}) ⊆ B_{D} fails, in general.

Fact. Let Δ: D_{0} ◁^{f_{0}} D_{1} ◁^{f_{1}} D_{2} ◁^{f_{2}} ⋯ be a direct chain in CPO^{E} where the D_{i} are all ω-algebraic, with B_{D} = ⋃_{n} ρ_{n}(B_{D_{n}}). Proof. By the lemma ρ_{n}(B_{D_{n}}) ⊆ B_{D}. Take x in D. For each ρ_{n}^{R}(x) let ⟨d_{m}^{(n)}⟩_{m∈ω} be an increasing chain of elements of B_{D} s.t. ρ_{n}^{R}(x) = ⨆_{m} d_{m}^{(n)}. Then B′ = {ρ_{n}(d_{m}^{(n)}) | n, m ∈ ω} is a countable directed set of elements of ⋃_{n} ρ_{n}(B_{D_{n}}) with lub x as:

⨆ B′ = ⨆_{n∈ω} ⨆_{m∈ω} ρ_{n}(d_{m}^{(n)})

= ⨆_{n∈ω} ρ_{n}( ⨆_{m∈ω} d_{m}^{(n)})

= ⨆_{n∈ω} ρ_{n}(ρ_{n}^{R}(x))

= x

(the arguments for existence of the lub go “from x to ⨆ B′”).

Finally as B′ is countable and directed it has a cofinal increasing ω-chain. Using Lemma 2 the proof concludes.

Corollary. If F: CPO^{E} → CPO^{E} is continuous and preserves ω-algebraicity then Fix_{F} is ω-algebraic (and similarly for multiple fixed points). Proof. U is ω-algebraic so the F^{n}(U) are too as F preserves ω-algebraicity. Now apply VI to the definition of Fix_{F}.

Thus all the domain equations we solve have ω-algebraic solutions (except, perhaps, for those involving exponentiation).

Note. If the functor F is defined using +, ×, ⊗, (·)_{⊥}, projections and constant functors K_{D} where every point in D is finite then F preserves the property of being finite and we see that B_{Fix_{F}} = ⋃_{n} ρ_{n}(F^{n}(U)). So e.g. the domain of trees is the limit of the domains of finite trees.

Exercise 2. Suppose D is ω-algebraic and f: D → D is a closure. Show that the cpo of fixed-points of D is also ω-algebraic and that: B_{Fix_{f}} = f(B_{D}). Find a condition on projections, f, on D so that Fix_{f} is ω-algebraic if D is. Find a necessary and sufficient condition for Fix_{f} to be ω-algebraic when f is a retraction.

Completeness

The most obvious axiom is: every subset has a lub. This gives us the complete lattices, D, which have the top element ⊤_{D} =^{def} ⨆ D. This can be interpreted as “inconsistent” or “overloaded” and causes problems. For example the truth-values, T, not being a lattice, would have to be made into one by adding a top element giving:

[figure: ⊥; ⊤; tt; ff]

It is now unclear how the conditional function (· → · | ·): T × D × D → D is to be defined at the top element:

(1)  (⊤ → d | e) = ⊤,
(2)  (⊤ → d | e) = d ⊔ e.

Both result in the failure of natural identities which hold for the three-valued cpo of truth-values:

(1)  (p → (p → a | b) | c) = (p → a | c),
(2)  (p → (q → a | b) | (q → c | d)) = (q → (p → a | c) | (p → b | d)),

respectively.

Instead we adopt a compromise axiom.

Definition. Let D be a cpo. A subset, X, of D is consistent iff it has an upper bound in D, and then we write ↑S (and otherwise // = S). (A subset X is ω-consistent if every finite subset of X has an upper bound in D.) Then D is consistently complete iff every consistent subset has a lub. We want to consider the consistently complete ω-algebraic cpos and there are several equivalent axiomatisations.

Exercises

1. Consider the four statements about a cpo D:

(1) Every ω-consistent subset has a lub.

(2) (Consistent completeness) Every consistent subset has a lub.

(3) Every consistent pair of elements has a lub.

(4) Every nonempty subset has a glb. Show (2) ⇔ (4), (1) ⇔ (2) + D is a dcpo ⇔ (3) + D is a dcpo. Conclude that if D is an ω-algebraic cpo then (1) ⇔ (2) ⇔ (3) ⇔ (4).

2 Complete Lattices. Consider the following three statements about a cpo D:

(1) Every subset has a lub.

(2) Every subset has a glb.

(3) Every pair of elements has a lub. Show (1) ⇔ (2) ⇔ (3) + D is a dcpo. Conclude that if D is an ω-algebraic cpo then (1) ⇔ (2) ⇔ (3).

The evidence for consistent completeness is rather empirical: all our basic examples are consistently complete and all the constructions +, ×, ⊗, (·)_{⊥}, →, →_{⊥} preserves it.

Notice that the basis of a consistently complete ω-algebraic cpo is closed under lubs of consistent pairs. Conversely: if a countable pointed quasiorder, P has lubs of consistent pairs of elements, then \overline{P} is consistently complete.

Exercise 3. Prove this.

There is also an idea of a subbasis.

Definition. Let D be a cpo. A set X ⊆ D is a subbasis iff for any element x of D, x = ⨆{u ∈ X | u ⊑ x}.

Lemma 3. If a consistently complete cpo D has a denumerable subbasis of finite elements it is ω-algebraic. Proof. Apply Lemma 1 to the set, B, of lubs of consistent finite subsets of the subbasis.

Function Spaces

First consistent-completeness is preserved. Let E be consistently complete and suppose F ⊆ (D → E) has a lub, g. Then:

(⨆ F)(x) = ⨆_{f∈F} f(x).

For, the lub on the RHS exists as F (x) has g(x) as an upper bound. For continuity: (⨆ F)(⨆_{n} x_{n}) = ⨆_{f∈F} f(⨆_{n} x_{n}) = ⨆_{f∈F} ⨆_{n} f(x_{n}) and also, ⨆_{n}(⨆ F)(x_{n}) = ⨆_{n} ⨆_{f∈F} f(x_{n}) and we can interchange the order of the lubs.

Now if D, E are ω-algebraic and consistently complete so is D → E. We have seen it is consistently complete. We have seen that {d ⇒ e | d ∈ B_{D} ∧ e ∈ B_{E}} is a subbasis of finite elements (Example 3, p. 59, Exercise 3, p. 61). So by Lemma 3, it is ω-algebraic too: its basis is the lubs of consistent finite subsets of elements of the form d ⇒ e.

Exercises

1. Let d_{1}, …, d_{n} be finite elements of D and e_{1}, …, e_{n} be finite elements of E. Show

↑{d_{i} ⇒ e_{i} | 1 ≤ i ≤ n} iff ∀I ⊆ {1, …, n}.(↑{d_{i} | i ∈ I} ⇒ ↑{e_{i} | i ∈ I}).

2. Show (d ⇒ e) ⊑ ⨆{d_{i} ⇒ e_{i} | i = 1, …, n} iff

∃I ⊆ {1, …, n}.↑{d_{i} | i ∈ I} ∧ d ⊒ ⨆{d_{i} | i ∈ I} ∧ e ⊑ ⨆{e_{i} | i ∈ I}.

3 Product. If X ⊆ D × E is consistent where D, E are consistently complete then

⨆_{D×E} X = ⟨\begin{matrix}⨆ & D \\ x∈X \end{matrix}x_{0}, \begin{matrix}⨆ & E \\ x∈X \end{matrix}x_{1}⟩.

So product preserves consistent completeness.

Show ↑X iff ↑π_{0}(X) ∧ ↑π_{1}(X).

4 Sum. Show sum preserves consistent completeness. If X ⊆ D+E where D, E are consistently complete then ↑X iff (X ⊆ inl(D) ∧ ↑outl(X)) ∨ (X ⊆ inr(E) ∧ ↑outr(X)), and then ⨆ X = inl(⨆_{D} outl(X)) if X ⊆ inl(D) and ⨆ X = inr(⨆_{E} outr(X)) if X ⊆ inr(E).

5 Smash Product. Show smash product preserves consistent completeness: If X ⊆ D ⊗ E where D and E are consistently complete then ↑X iff ↑π_{0}(X) ∧ ↑π_{1}(X) and if ↑X then ⨆ X = (⨆_{D} π_{0}(X)) ⊗ (⨆_{E} π_{1}(X)).

6 Lifting. Show lifting preserves consistent completeness: If X ⊆ D where D is consistently complete then ↑X iff ↑down(X) and if ↑X then ⨆_{D_{⊥}} X = ⊥ if X ⊆ {⊥} and ⨆_{D_{⊥}} X = up(⨆_{D} down(X)) otherwise.

7 Strict Function Space. Show strict function space preserve consistent completeness and consistent completeness + ω-algebraicity. Treat this construction as we just did the function space. As subbasis we can take {d ⇒ e | d ∈ B_{D} ∧ e ∈ B_{E} ∧ d ≠ ⊥} or, more precisely, {d ⇒_{⊥} e | d ∈ B_{D} ∧ e ∈ B_{E}} where:

(d ⇒_{⊥} e)(x) = \{ \begin{matrix}e & (x ⊒ d ∧ x ≠ ⊥), \\ ⊥ & (otherwise). \end{matrix}

8 Direct Limits. Show that consistent completeness is preserved by direct limits of ω-chains in CPO^{E}. In particular if Δ = ⟨D_{n}, f_{n}⟩ is such a chain and ρ: Δ → D is a universal cone then for X ⊆ D, ↑X iff ∀n.↑_{D_{n}}ρ_{n}^{R}(X) and ⨆_{D} X = ⨆_{n} ρ_{n}(⨆_{D_{n}} ρ_{n}^{R}(X)) where ⟨ρ_{n}(⨆_{D_{n}} ρ_{n}^{R}(X))⟩_{n∈ω} is an increasing ω-chain.

If X ⊆ ⋃_{n≤m} ρ_{n}(D_{n}) we have a more constructive version:

↑X iff ↑_{D_{m}}ρ_{m}^{R}(X) and ⨆_{D} X = ρ_{m}(⨆_{D_{m}}ρ_{m}^{R}(X)).

9. Characterise ⊓ (glb) of nonempty sets in all the above constructions.

10. Show that if r: D → D is a retraction where D is consistently complete then Fix_{r} is also consistently complete.

We easily conclude that if F: CPO^{E} → CPO^{E} is continuous and preserves the combination, consistently complete + ω-algebraic then Fix_{F} is also consistently complete and ω-algebraic and similarly for multiple fixed-points. So all the domain equations we solve, as above, give consistently-complete ω-algebraic cpos.

Exercises 1 Stable Functions. Let D, E be consistently complete cpos and let f: D → E be a continuous function. Show the following two conditions are equivalent:

(1) Stability. ∀x ∈ D.∀y ∈ E.y ⊑ f(x) ⇒ [∃t ⊑ x.y ⊑ f(t) ∧ ∀u ⊑ x.y ⊑ f(u) ⇒ u ⊒ t]. Here the t whose existence is postulated is clearly unique and is written as m(f, x, y) and has the properties that, if y ⊑ f(x):

(a) y ⊑ f(m(f, x, y)),

(b) y ⊑ f(u) ∧ u ⊑ x ⇒ u ⊒ m(f, x, y). Thus m(f, x, y) is the part of x required for y.

(2) ∀X ⊆ D.(↑X ∧ X ≠ ∅) ⇒ f(⊓ X) = ⊓ f(X). Suppose further that D, E are ω-algebraic and that D obeys:

Axiom I : ∀d ∈ B_{D}.{x ∈ D | x ⊑ d} is finite.

Then show stability is also equivalent to:

(3) ∀x, y ∈ D.x ↑ y ⇒ f(x ⊓ y) = f(x) ⊓ f(y). Find examples of stable and nonstable functions. The stable order is defined by, for stable f, g: D → E (D, E consistently complete):

f ≤ g ≡ (f ⊑ g) ∧ ∀x ∈ D.∀y ∈ E.[y ⊑ f(x) ⇒ m(f, x, y) = m(g, x, y)].

Show it can also be defined by: f ≤ g ≡ (f ⊑ g) ∧ [∀x, y ∈ D.x ↑ y ⇒ f(x) ⊓ g(y) = f(y) ⊓ g(x)]. Show that the set of stable functions, ordered by ≤, is a cpo, given that ⊓ is continuous.

2 The Category SFP. There are weaker completeness conditions than consistent completeness which work. A strongly algebraic cpo D (SFP object) is one such that D ≅ lim_{→}_{CPO}^{E}⟨D_{n}, f_{n}⟩ where each D_{n} is finite. Show that the strongly algebraic cpos are closed under +, ×, ⊗, →, →_{⊥} and lim_{→}_{CPO}^{E}.

Conjecture. If D and (D → D) are ω-algebraic then D is strongly algebraic.

If true this would imply that SFP is the largest subcategory of the ω-algebraic cpos closed under exponentiation. Let D be a cpo. A minimal upper bound, u of a subset X of D is an upper bound which dominates no other upper bound; i.e. (∀x ∈ X.v ⊒ x) ∧ (u ⊒ v) ⇒ u = v. The set U(X) is the set of minimal upper bounds of X; U^{∗}(X) is the smallest set, Y, such that X ⊆ Y and if X ⊆ Y then U(X) ⊆ Y; i.e. U^{∗}(X) is the least set closed under U^{∗} and containing X. Show that the strongly algebraic cpos are just the ω-algebraic cpos D such that for every finite subset X of B_{D}:

(1) If v is an upper bound of X then for some u ∈ U(X), v ⊒ u.

(2) The set U^{∗}(X) is finite.

3 Other Completeness Conditions. There are completeness conditions stronger than consistent completeness but weaker than being a complete lattice. Let D be a cpo. For κ ≤ ω, we say a subset X of D is κ-consistent iff for every Y ⊆ D s.t. ∥Y ∥ < κ, Y has an upper bound in D. We say D is κ-consistently complete iff every κ-consistent subset has a lub. Show D κ-consistently complete implies D λ-consistently complete for κ ≤ λ ≤ ω. Show that if 2 ≤ κ < λ then there are κ-consistently complete cpos which are not λ-consistently complete (and 0- = 1- = 2- = complete lattice). Show that the κ-consistently complete ω-algebraic cpos are closed under +, ×, ⊗, →, →_{⊥}, lim_{→}_{CPO}^{E}.

7. Computability

We give a theory of computability for consistently complete ω-algebraic cpos — which from now on we will just call domains. The idea is to postulate a suitable recursive structure on the finite elements and define the computable elements to be the limits of effective chains of finite elements. We will use some standard ideas and notation from classical recursive function theory. Thus we assume n-tupling functions ⟨m_{0}, …, m_{n−1}⟩ and corresponding projections π_{i} = (·)_{i} (i < n) and φ_{m} = {m} is the mth pr. function in the standard enumeration, W_{m} is the mth re set, F_{m} is the mth finite set (and {|m_{0}, …, m_{n−1}|} is the code of {m_{0}, …, m_{n−1}}).

Definition 1. Let D be a domain. An enumeration ⟨D, ε⟩ of its basis is any surjection, ε: N → B_{D} (and we write ε_{m} for ε(m)).

Further it is effectively given, w.r.t. ε, (by an index ⟨c, b, u⟩) if

(1) The relation ε_{m} ↑ ε_{n} on m and n is recursive (and has index c).

(2) ε_{b} = ⊥.

(3) The relation ε_{n} = ε_{m} ⊔ ε_{m′} on m, m′, n is recursive (and has index u).

Examples

1. Truthvalues. ε_{0}, ε_{1}, ε_{2}, ε_{3}, … is ⊥, tt, ff , ff , ff , … with ε_{m} ⊑ ε_{n} ≡ m = 0∨n = m∨(m ≥ 2∧n ≥ 2), ε_{m} ↑ ε_{n} ≡ (ε_{m} ⊑ ε_{n} ∨ ε_{n} ⊑ ε_{m}), ε_{0} = ⊥, ε_{n} = ε_{m} ⊔ ε_{m′} ≡ (ε_{n} = ε_{max(m,m′)}) ∧ ε_{m} ↑ ε_{m′}.

2. Integers. ε_{0}, ε_{1}, ε_{2}, … is ⊥, 0, 1, . . ..

We always use these “natural” enumerations except where otherwise stated (and similarly in other cases).

Note that we can always insist that ε_{0} = ⊥ for starting with ε we change to ε′ where ε′_{0} = ⊥, ε′_{n+1} = ε_{n} and perform the evident (recursive) change in the index. Note too that ε_{m} ⊑ ε_{n} is recursive in m and n as it is equivalent to ε_{n} = ε_{m} ⊔ ε_{n}.

Exercises

1. Show that any finite domain can be effectively given as can Tapes, V_{ω}, {P \atop ω}, T^{ω}, Trees, . . ..

2. Let A = ⟨ω, +⟩ be a recursive algebras (i.e. +: ω^{2} → ω is recursive). Show that the lattice of subalgebras is effectively given. What about partial algebras and pr. functions?

3. Show that the partial order of consistent theories of propositional logic (over given letters P_{0}, P_{1}, …) is an effectively given domain. What happens with theories in the predicate calculus? What happens with equational theories? (They are sets of equations t = u closed under deduction; they are consistent if not every equation can be proved.)

There is a useful alternative definition in terms of subbases.

Lemma 1. Let D be a domain. Then it is effectively given iff there is an enumeration β_{0}, β_{1}, … of a subbasis of D such that

(1) ↑{β_{m_{0}}, … β_{m_{n−1}}} is a recursive predicate of {|m_{0}, …, m_{n−1}|},

(2) The relation β_{m} ⊑ ⨆{β_{m_{0}}, …, β_{m_{n−1}}} is recursive in m and {|m_{0}, …, m_{n−1}|}. Proof. ⇒) Clear, taking β = ε.

⇐) Define

ε_{\{|m_{0},...,m_{n−1}|\}} = \{ \begin{matrix}⨆_{i<n} β_{m_{i}} & (↑\{β_{m_{0}}, …, β_{m_{n−1}}\}), \\ ⊥ & (otherwise). \end{matrix}

The rest of the proof is left to the reader.

With the evident definition of an index of such a subbasis one notes from the above proof that there are recursive functions translating each type of index to the other (note that given the subbasis one finds a code for ⊥ by searching for an m s.t. β_{m} ⊑ ⨆ ∅).

Exercises

1. Show that one can replace condition (3) of the definition of an effectively given domain (making appropriate changes in the definition of index) by:

(3′) The relation ε_{m} = ε_{n} is recursive.

(4′) There is a recursive function, f, such that ε_{f(m,n)} = ε_{m} ⊔ ε_{n} wherever ε_{m} ↑ ε_{n}.

2. Show that one can develop a theory of weakly effectively given domains with the conditions (1), (4′), and: (3′′) (a) The relation ε_{m} = ε_{n} is re.

(b) The predicate ε_{m} = ⊥ is recursive.

3. What can you get in the way of a theory of effectively given ω-algebraic cpos? Try as axioms (3′′′) The relation ε_{n} ⊑ ε_{n} is recursive and there could also be a weaker version à la (3′′) (a), (b) with =

replaced by ⊑.

4. Show there are uncountably many domains which are not effectively given (and try to give at least one example!) Find domains which are weakly effectively given but not effectively given as ω-algebraic cpos.

5 SFP. Develop a theory of effectively given SFP objects with the definition that D is eff. given w.r.t. ε with index ⟨a, b⟩:

(1) The relation ε_{m} = ε_{n} is recursive in m and n (and has index a).

(2) There is a recursive function u such that for any m:

u(ε(F_{m})) = ε(F_{u(m)})

(and u has index b). Include a characterisation of eff. given SFP objects in terms of effective colimits of finite objects in

SFP^{E} (see the later development of effective colimits in CPO^{E} for some hints).

6. Let ⟨P, ⊑, ⊥⟩ be a countable pointed quasi-order with lubs of pairs of consistent elements. It is effectively given iff there is an enumeration (= surjection) ε: N → P and an index satisfying (1), (2), (3) of Definition 1. Show P effectively given iff \overline{P} is (and so D is effectively given iff B_{D} is).

The following definitions will prove useful on occasion.

Definition 1. Consider an enumeration ⟨D, ε⟩. The relations ∼ <, ≃ on N are defined by:

\begin{aligned}m∼ <n & ≡ ε(m) ⊑ ε(n), \\ m ≃ n & ≡ ε(m) = ε(n). \end{aligned}

A morphism of enumerations is a pair ⟨r, f⟩: ⟨D, ε⟩ → ⟨D′, ε′⟩ where r: N → N is recursive, f: D → D′ is continuous and the following diagram commutes:

[figure: D; D′; f; N; N; r; ε; ε′]

Exercises

1. Show the enumerations and their morphisms form a category. If ⟨r, f⟩: ⟨D, ε⟩ → ⟨D, ε′⟩ is a morphism then r clearly determines f. Show that any recursive r: N → N can be extended to a morphism iff it is monotonic w.r.t. ∼ <; show too that it is not enough that r preserves ≃.

2. Show that if D is finite then there is always a morphism from ⟨D, ε⟩ to ⟨D′, ε′⟩ (thus reducing ε to ε′); show this need not hold in general — e.g. when D = N.

3. Show that for any enumeration ⟨D, ε⟩ we have B_{D} ≅ ⟨N, ∼ <⟩/≃ (and deduce there are only countably many eff. given domains, to within isomorphism).

Computability

We use the idea that a computable element is just a limit of an effective chain of finite elements, imagining a machine generating more and more information about the element, but at any finite point in its computation, only having generated a finite amount. This is sometimes called the enumeration model of computation following the case where, for example, one enumerates all the elements of a set: at finite time one has generated a finite subset.

Definition. Let D be effectively given w.r.t. ε. An effective chain in D with index g is any increasing chain ⟨ε_{{g}_{n}}⟩_{n∈ω}. An element d is computable if there is an effective chain with lub d. We write C_{⟨D,ε⟩} for the set of computable elements of D (and C_{D} when ε is understood).

Exercises

1. Every finite element is computable.

2. The computable elements of Tapes are just the finite ones and the recursive infinite sequence (of 0’s and 1’s); the computable elements of {P \atop ω} are the re. sets, of T^{ω} are the pr. predicates. What about V_{ω}, Trees, . . ..

3. Show how to use the typed λ-calculus to define all computable elements of Tapes, {P \atop ω}, T^{ω}, . . .. [Hint Using the idea of generation just define appropriate functions f: N → Tapes so that for a given tape, t = t_{0}t_{1}t_{2} …, we have:

f(n) = t_{n}t_{n+1} ….

and use similar ideas in the other cases.]

4. Show that by varying ε one can vary C_{⟨Pω ω ω,ε⟩}. Kanda and Park have shown (When are two effectively given domains identical? Proc. 4th AI Conference.) that for some D, ε, ε′ we even have: C_{⟨D,ε⟩} ≅ C̸_{⟨D,ε′⟩}. Can we take D = {P \atop ω}?

Now there is a little technical difficulty if we want to enumerate all the computable elements as not all integers, g, are indexes as {g} may not be recursive and ⟨ε_{{g}(n)}⟩ may not be increasing. To avoid dealing with partial surjections (Exercise try working with them) we note that for any g there is an effectively obtainable g′ with range({g′}) = range({g}) ∪ {a code of ⊥}. Now define f: N → N by:

f(0) = a code of ⊥,
f(n + 1) = \{ \begin{matrix}a code of ε_{f(n)} ⊔ ε_{g′(n+1)} & (if ε_{f(n)} ↑ ε_{g′(n+1)}), \\ f(n) & (otherwise). \end{matrix}

This f is clearly recursive and an index for it is effectively obtainable (say via d) from m (via n); clearly for d(m) is an index of a computable element and:

⨆_{n} ε_{{d(g)}(n)} = ⨆_{n} ε_{{g}(n)}

if g is an index. We can now define our (total) enumeration:

Definition 1. Let ⟨D, ε⟩ be an enumerated domain. Then the enumeration ζ: N → C_{D} is defined by:

ζ_{g} = ⨆_{n} ε_{{d(g)}(n)}.

Exercises

1. Let D be effectively given w.r.t. ε. Show that the following conditions on an element d are all effectively equivalent.

(a) d is computable.

(b) {n | ε_{n} ⊑ d} is re.

(c) For some k, ⨆ ε(W_{k}) = d.

(d) For some k, ε(W_{k}) is directed and has lub d.

2. Use 1(c) to obtain another total enumeration ζ^{S} of C_{D}; this is the single-valued enumeration of Egli-Constable; ours, ζ, is the directed enumeration of Kanda-Park.

3. Show that as every finite element is computable there is a recursive function k such that the following diagram commutes:

[figure: B_{D}; C_{D}; ι; N; N; k; ε; ζ]

This will prove useful later.

4. (1) Show that the relation ε_{m} ⊑ ζ_{n}, is re. in m and n. Is it ever recursive (ignoring here — and below —

the case D = ⊥)?

(2) Show that the relation ζ_{m} // = ζ_{n} is re. in m and n. Is it ever recursive?

(3) Show that there is a recursive function, ⊔,

ζ_{m⊔n} = ζ_{m} ⊔ ζ_{n} (when ζ_{m} ↑ ζ_{n}).

(4) Show there is a recursive function, ⊓, of two arguments such that:

ζ_{m⊓n} = ζ_{m} ⊓ ζ_{n}.

(5) Are either of the relations ζ_{m} ⊑ ζ_{n}, ζ_{m} = ζ_{n} (or their negations) ever re?

5 Effective Limits. Show the lubs of increasing effective chains are computable and effectively obtainable. That is there is a recursive function, ⨆, of one argument such that if c is the index of an effective chain of computable elements (i.e. if {c} is recursive and ⟨ζ_{{c}(n)}⟩ is increasing) then:

ζ_{⨆ c} = ⨆_{n} ζ_{{c}(n)}.

6 Computable Open Sets. An open set O of an effectively given D, is computable iff given any effective chain of computable elements with index c with ζ_{⨆ c} in O one can effectively obtain from c an n s.t. ζ_{{c}(n)} ∈ O. Show that an open set O is computable iff

O = ⋃_{n∈W_{m}} O_{ε_{n}}

for some m. Show the computable open sets are closed under intersection and unions of re. collections of open sets. Note all proofs and closure properties are effective.

Computable Functions

To obtain a definition of computable function we effectivise the ε-δ version of continuity: given a finite amount of information about the input one can enumerate all the finite pieces of information about the output.

Definition. Let D and E be domains effectively given with respect to enumerations ε, ε′. Then a continuous function f: D → E is computable iff

Graph(f) = {⟨m, n⟩ | ε′_{n} ⊑ f(ε_{m})}

is re. (and g is an index for f if Graph(f) = W_{g}). We delay consideration of enumerating the computable functions until the discussion of function spaces.

Examples

1. The computable f: N→N are the constant functions and the (functions corresponding to) the partial recursive functions.

2. The identity is computable as:

Graph(id) = {⟨m, n⟩ | ε_{n} ⊑ ε_{m}}.

3. If D →^{f} E →^{g} F are computable w.r.t. ε, ε′ and ε′, ε′′ then g ∘ f is too w.r.t. ε, ε′′ as:

Graph(g ∘ f) = Graph(f) ∘ Graph(g)

(and an idea for g ∘ f is clearly effectively obtainable from those of g and f). Thus we have a category of enumerated effectively given domains and computable functions.

Exercises

1. What are the computable f: N→T? What about f: {P \atop ω}→{P \atop ω}? [Hint Read about enumeration operators in Rogers.] What about f: T^{ω} → T^{ω}, f: Tapes → Tapes? Are they all definable in the typed λ-calculus? [Hint Try using parcond if needed.] 2. Show that a continuous f: D → E can be extended to a morphism of enumerations ⟨D, ε⟩, ⟨E, ε′⟩ of effectively given domains iff f preserves finiteness and Graph(f) is recursive.

Another natural idea for a definition of the computability of a function f is that given a method of generating an argument x one can effectively obtain a method of generating the result f(x). But it turns out that this is a theorem:

Theorem 1. Let ⟨D, ε⟩, ⟨E, ε′⟩ be enumerations of effectively given domain. Then a continuous function f: D→E is computable w.r.t. ε, ε′ iff there is a recursive r: N→N such that the following diagram commutes:

[figure: D; E; f; N; N; r; ζ; ζ′]

Proof. ⇒) If f is computable then for any computable x with ζ(g) = x:

\begin{aligned}X & = \{n | ε′(n) ⊑ f(x)\} \\ & = \{n | ∃⟨m, n⟩ ∈ Graph(f).ε(m) ⊑ ζ(g)\}. \end{aligned}

and clearly X is re. (see Exercise 4, p. 73) and an index for it is effectively obtainable from one for Graph(f). Then one effectively obtains an index from X for f(x) (see Exercise 1, p. 72).

⇐) With k as in Exercise 3, p. 72, we have: ⟨m, n⟩ ∈ Graph(f) iff ε′_{m} ⊑ f(ε_{n}) iff ε′_{m} ⊑ f(ζ_{k(n)}) iff ε′_{m} ⊑ ζ(r(k(n))) and by Exercise 4, p. 73, this is clearly a partial recursive relation.

Of course the theorem says, among other things, that computable functions preserve computability. The theorem suggests a natural definition of morphisms ⟨r, f⟩: ⟨D, ζ⟩ → ⟨D′, ζ′⟩ of enumerations of computable elements as pairs r: N → N, f: D → D′ of recursive functions and continuous functions which make the diagram of the theorem commute. The theorem says that if ⟨r, f⟩ is a morphism then f is computable and if f is computable there is a recursive r making ⟨r, f⟩ a morphism; note the equivalence is effective. We shall have occasion in the exercises to greatly strengthen this result.

Exercises

1. Show that a continuous f: D→D′ of domains effectively given w.r.t. ε, ε′ is computable iff O′ ↦ f^{−1}(O′) effectively sends computable open sets in D′ to computable open sets in D.

2 (Rice-Shapiro). Show that for any X ⊆ C_{D} we have ζ^{−1}(X) re. iff there is a (necessarily unique) computable open set O with X = O ∩ C_{D}. This means that any partial recursive predicate on codes (= texts) for computable elements which respects extensional equality (m ≃_{ζ} n ≅ ζ(m) = ζ(n)) must be continuous on D. [Hint Apply the idea of the proof of the classical Rice-Shapiro theorem.]

3 (Myhill-Shepherdson). Let D, D′ be eff. given w.r.t. ε, ε′. Show that if r: N→N is a recursive function which respects extensional equality (i.e. m ≃_{ζ} n ⇒ r(m) ≃_{ζ′} r(n)) then there is a (necessarily unique) computable function f: D → D′ which makes ⟨r, f⟩ a morphism of enumerations of computable elements. [Hint By Theorem 1 the only problem is to prove continuity. This can be done by applying Exercise 2, or the Myhill-Shepherdson.] Again this shows how an intensional operator which respects extensional equivalence is (essentially) a computable function — providing more evidence for continuity.

Least Fixed-Points

Of course, we can also effectivise the least fixed-point construction. Let f: D → D be computable. Then with r as in Theorem 1 we have:

f^{n}(⊥) = ζ_{r^{n}(k(b))}.

Hence by Exercise 5, p. 73 we obtain an index of Y f and this index is effectively obtainable from an index for f.

Exercises

1. Let D be eff. given w.r.t. ε. Show that for any partial recursive function f there is a total recursive g, such that for any m:

(1) If f(n) ↓ then g(n) ≃_{ζ} f(n),

(2) If f(n) ↑ then g(n) ≃_{ζ} k(b).

2 Ershov-Kleene Fixed-Point Theorem. Show that for any partial recursive r there is an n (effectively obtainable from any index for r) such that if r(n) ↓ then r(n_{r}) ≃_{ζ} n_{r}.

Open Question. In case ⟨r, f⟩: ⟨D, ζ⟩ → ⟨D, ζ⟩ is a morphism do we have ζ_{n} = Y f? That is do intensional and extensional fixed-points coincide — the answer may depend on exactly how n_{r} is defined.

Remark. In “Gödel numbering of domain theoretic computable functions — a generalisation of Rogers Indexing Theory, Report 138, University of Leeds”, Kanda considers general systems of indexings, τ, where if D is eff. given w.r.t. ε then τ_{ε}: N → C_{D} is an enumeration of the computable elements of D. He gave axioms for such a system to be admissible (our ζ’s form an admissible system) and showed that if ζ, ζ′ are admissible then for any ⟨D, ε⟩ there is a recursive isomorphism

⟨r, id⟩: τ_{ε} → τ′_{ε}

effectively obtainable from the index of D.

We now turn to effectivising the concerns of Chapter 2, 3, 4, 5.

Products

Let D, E be eff. given domains w.r.t. ε, ε′ with indices ⟨c, b, u⟩ and ⟨c′, b′, u′⟩. Then we can define an enumeration ε′′ = ε × ε′ of B_{D×E} = B_{D} × B_{E} by Chapter 6:

ε × ε′(⟨m, n⟩) = ⟨ε_{m}, ε′_{n}⟩.

This makes D × E effectively given as we can see from:

(1) ε′′_{⟨m,m′⟩} ↑ ε′′_{⟨n,n′⟩} ≡ (ε_{m} ↑ ε_{n}) ∧ (ε′_{m′} ↑ ε′_{n′}).

(2) ε′′_{⟨b,b′⟩} = ⊥_{D×E}.

(3) ε′′_{⟨n,n′⟩} = ε′′_{⟨l,l′⟩} ⊔ ε′′_{⟨m,m′⟩} ≡ (ε_{n} = ε_{l} ⊔ ε_{m} ∧ ε′_{n′} = ε′_{l′} ⊔ ε′_{m′}).

Exercise

1. Show that ζ′′: N → C_{D×E} is recursively equivalent to ⟨ζ, ζ′⟩: N → (C_{D} × C_{E}) (= C_{D×E}) in that there are morphisms ⟨r, id⟩: ζ′′ → ⟨ζ, ζ′⟩ and ⟨\overline{r}, id⟩: ⟨ζ, ζ′⟩ → ζ′′.

Of course all this is effective in the indices of D and E and so there is a recursive x so that if i, j are indices of D and E then i × j is one of D × E. Note that the projections D ←^{π_{0}} D × E →^{π_{1}} E are computable as:

Graph(π_{0}) = {⟨m, n⟩ | ε_{n} ⊑ ε_{π_{0}(m)}},
Graph(π_{1}) = {⟨m, n⟩ | ε_{n} ⊑ ε_{π_{1}(m)}}.

Let C also be an effectively given domain, w.r.t. ε′′ and suppose f: C → D, g: C → E are computable w.r.t. ε′′, ε × ε′ as:

Graph(⟨f, g⟩) = {⟨m, n⟩ | ⟨m, n_{0}⟩ ∈ Graph(f) ∧ ⟨m, n_{1}⟩ ∈ Graph(g)}

and this is clearly an effective construction. As a consequence if f: D′ → D, g: E′ → E are computable so is f × g: D′ × E′ → D × E and the product construction is effective on the graphs.

Exercises

2. Carry out the same details for finite and effective denumerable products.

3. Show ⊓: D × D → D is computable (see Exercise 4) for any effectively given D as is B_{⊔}: D^{3} → D where B_{⊔}(x, y, z) = (x ⊓ z) ⊔ (y ⊓ z). If D is a complete lattice show ⊤ and ⊔ are computable.

4. For any eff. given D w.r.t. ε show // =_{n}: D → T is computable where:

// =_{n} (x) = \{ \begin{matrix}tt & (x // = ε_{n}), \\ ff & (x ⊒ ε_{n}), \\ ⊥ & (otherwise). \end{matrix}

Show also that cond, parcond: T × D × D → D, =: D × D → T (D discrete), ∂: D → T are all computable.

Function Spaces

Let D, E be effectively given domains w.r.t. ε, ε′ and indices i, j. Then by p. 68, Chapter 6 we can define an enumeration, β, of a subbasis of D → E by:

β_{⟨m,n⟩} = (ε_{m} ⇒ ε′_{n}).

By Exercise 2, p. 68, Chapter 6 we see that the conditions of Lemma 1 hold and we obtain an enumeration (ε → ε′) of (D → D′) as an effectively given domain, where:

(ε → ε′)_{\{|m_{0},...,m_{n−1}|\}} = \{ \begin{matrix}⨆_{a∈\{m_{0},...,m_{n−1}\}} ε_{(a)_{0}} ⇒ ε′_{(a)_{1}} & (↑\{β_{m_{i}} | i < n\}), \\ ⊥ & (otherwise). \end{matrix}

This is all effective and so we have a recursive function → s.t. if i, j are indices of D, E w.r.t. ε, ε′ then i → j is one of D → E w.r.t. ε → ε′.

Now we have an enumeration ζ: N → C_{(D→E)} of the computable elements of (D → E) and see further that

f: D → E is in C_{D→E} iff {m | (ε → ε′)_{m} ⊑ f} is re.

iff {{|m_{0}, …, m_{n−1}|} | ↑{β_{m_{0}}, …, β_{m_{n−1}}} ∧ ∀i < n.β_{m_{i}} ⊑ f} is re.

iff {{|m_{0}, …, m_{n−1}|} | ↑{β_{m_{0}}, …, β_{m_{n−1}}} ∧ ∀i < n.m_{i} ∈ Graph(f)} is re. iff Graph(f) is re. iff f is computable.

All this is effective and one recursively translates between indices m with f = ζ(m) and indices of f as a computable function. This gives us the enumeration of computable functions we shall use.

Exercises

1. Show there is a recursive function id so that if D has index i then id(i) is an index of id_{D}.

2. Let D, E, F be eff. given w.r.t. ε, ε′, ε′′ with indices i, j, k. Show there is a recursive function, ∘, such that if ζ: N → C_{(D→E)}, ζ′: N → C_{(E→F)}, ζ′′: N → C_{(D→F)} are the appropriate enumerations of C_{(D→E)} etc. w.r.t. (ε → ε′) etc. then for all m, n:

ζ_{m} ∘ ζ_{n} = ζ_{m∘_{i,j,k}n}

(where m ∘_{i,j,k} n means ∘(m, i, j, k, n)).

3. Let D be eff. given w.r.t. ε. Show that Y_{D}: (D → D) → D is computable w.r.t. (ε → ε) → ε and there is a recursive function Y s.t. if i is an index of D then Y_{D} has index Y (i).

4. Show that there are recursive functions π_{0}, π_{1}, ⟨·, ·⟩, × such that if D, E, C, D′, E′ are eff. given domains w.r.t. ε_{0}, ε_{1}, ε, ε′_{0}, ε′_{1} and indices i, j, k, l, m then:

\begin{aligned}π_{0}: D × E → D & = ζ_{π_{0}(⟨i,j⟩)}, \\ π_{1}: D × E → E & = ζ_{π_{1}(⟨i,j⟩)} \end{aligned}

and if f: C → D, g: C → E have indices a, b then

⟨f, g⟩ = ζ_{⟨a,b⟩_{i,j,k}}

and if f: D → D′, g: E → E′ have indices a, b then

f × g = ζ_{a×_{i,j,l,m}b}.

In general we will drop the indices of the spaces when they can be understood from the context. Continuing the study of function space we now see that eval: (D → E) × D → E is computable w.r.t. (ε → ε′) × ε, ε′. One way is to note that

eval = ⨆{⟨ε_{m} ⇒ ε′_{n}, ε_{m}⟩ ⇒ ε′_{n}}
= ⨆{⟨β_{⟨m,n⟩}, ε_{m}⟩ ⇒ ε′_{n}}
= ⨆{⟨(ε → ε′)_{{|⟨m,n⟩|}}, ε_{m}⟩ ⇒ ε′_{n}}
= ⨆{((ε → ε′) × ε)_{k} ⇒ ε′_{n} | k = ⟨{|⟨m, n⟩|}, m⟩}
= ⨆{(((ε → ε′) × ε) → ε′)_{k} | k = {|⟨⟨{|⟨m, n⟩|}, m⟩, n⟩|}}

and use Exercise 1, p. 72. Another way is to use the effective nature of Theorem 1. Of course this is all effective and we have a recursive eval with

eval = ζ_{eval(i,j)}.

Now let F be eff. given w.r.t. ε′′ and with index k. We check that if f: (F × D) → E is computable w.r.t. ε′′ × ε, ε′ then Curry(f): F → (D → E) is computable w.r.t. ε′′, (ε ⇒ ε′). For Curry(f) = ⨆{ε′′_{k} ⇒ (ε_{l} ⇒ ε′_{m}) | ε′_{m} ⊑ f(ε′′_{k}, ε_{l})}. This is all effective in Graph(f) and we see that Curry itself is computable (e.g. use Theorem 1). Finally we see there is a recursive curry with

Curry = ζ_{Curry(i,j,k)}.

Now we also see there is a recursive → s.t. if D′, D, E, E′ are eff. given w.r.t. ε′_{0}, ε_{0}, ε_{1}, ε′_{1} and indices i, j, k, l then for any computable f: D′ → D, g: E → E′ w.r.t. ε′_{0}, ε_{0} and ε_{1}, ε′_{1} and indices a, b we have:

f → g = ζ_{a→_{i,j,k,l}b}.

Exercises 1 Combinatory Logic. Given C, D, E, eff. given w.r.t. ε, ε′, ε′′ show K: D → (E → D), S: (C → D → E) → (C → D) → (C → E) by demonstrating the formulae:

\begin{aligned}K & = ⨆\{ε′_{m} ⇒ (ε′′_{n} ⇒ ε′_{m})\}, \\ S & = ⨆\{(ε_{l} ⇒ ε′_{m} ⇒ ε′′_{n}) ⇒ (ε_{l} ⇒ ε′_{m}) ⇒ (ε_{l} ⇒ ε′′_{n})\}. \end{aligned}

What is the formula for Y: (D → D) → D?

2 λ-calculus. Show that all typed λ-calculus expressions denote computable functions of their free variables.

3 Smash Product and Strict Function Space. Treat the smash product D ⊗ E of effectively given domains D, E w.r.t. ε, ε′ using the enumeration:

ε ⊗ ε′_{⟨m,n⟩} = ε_{m} ⊗ ε′_{n}.

showing that D ⊗ E is eff. given w.r.t. ε ⊗ ε′ and ⊗: D × E → D ⊗ E, ι: D ⊗ E → D × E being computable (and all indices are effectively obtainable from indices for D and E).

Treat the strict function space D →_{⊥} E w.r.t. the enumeration

β_{⊥⟨m,n⟩} = ε_{m} ⇒ ε′_{n}.

Show that by considering appropriate formulae that the following functions are all computable: ⊗: [(D →_{⊥} E) ⊗ (D′ →_{⊥} E′)] → (D ⊗ D′ →_{⊥} E ⊗ E′) and eval: (D →_{⊥} E) ⊗ D →_{⊥} E and Curry: (F ⊗ D →_{⊥} E) →_{⊥} (F →_{⊥} D →_{⊥} E) and →_{⊥}: (D′ →_{⊥} D) × (E →_{⊥} E′) → (D →_{⊥} E) →_{⊥} (D′ →_{⊥} E′) and that all indices are effectively obtainable from indices for D, E, D′, E′, F.

4. Let D, E be eff. given and show that each element of the projection pair (D→_{⊥}E)→(D→E)→(D→_{⊥}E) given in Chapter 4 is computable. Conclude f: D →_{⊥} E is computable iff it is computable as an element of D → E.

5. Show that if we turn ×, → into functors on CPO_{⊥} then they still act computably on morphisms.

6 Disjoint Sum. Let D, E be eff. given domain w.r.t. ε, ε′. Show that D + E is eff. given w.r.t. ε + ε′ where:

(ε + ε′)_{m} = \{ \begin{matrix}inl(ε_{n}) & (if m = 2n), \\ inr(ε′_{n}) & (if m = 2n + 1). \end{matrix}

Show that inl, inr, outl, outr, isl, isr, [·, ·], +, ∇ are all computable by demonstrating such appropriate formulae as:

∇ = ⨆({inl(ε_{m}) ⇒_{⊥} ε_{m}} ∪ {inr(ε′_{n}) ⇒_{⊥} ε′_{n}})

and note everything is recursive in the indices of D and E.

7 Lifting. Treat lifting.

8. Show that x ∈ D ⊗ E is computable iff (x)_{0} and (x)_{1} are; that x ∈ D + E is computable iff it is ⊥ or inl(d) for a computable d in D or inr(e) for a computable e in E; that x ∈ D_{⊥} is computable iff it is ⊥ or up(d) for a computable d in D. What about D^{∗}?

9. Treat iterated finite sums and smash products and effective denumerable sums and smash products.

10. Treat the (·)^{∗} functor.

11. Let D be effectively given w.r.t. ε and let r: D → D be a closure operation with recursive graph. Show Fix_{r} is effectively given w.r.t. ε_{m}^{R} = r(ε_{m}). What happens if r is only computable?

12. Show that the computable f: N^{◯^{m}} →_{⊥} N correspond exactly to the pr. functions of m arguments.

13. Show the computable f: A → B where A, B are N^{k}, (T^{ω})^{k}, (Tapes)^{k}, … etc. are definable in the typed λ-calculus using parcond (or, equally, parallel or). What difficulties do you find if you try to define the computable functions f: N^{k} → N which are Milner-Vuillemin sequential? Find a notion of effective sequentiality and show all of the effectively sequential f: N^{k} → N can be defined with parallel or (or equally parcond).

Easy Open Question. What basic stable functions (e.g. no parcond) are needed to define all computable stable f: N^{k} → N? Perhaps you will need a notion of effective stability.

14. Define type symbols, σ, recursively by saying: o, ι are symbols and (σ × τ) and (σ → τ) are if σ, τ are. Let D_{o} = T, D_{ι} = N and D_{σ×τ} = D_{σ} × D_{τ} and D_{σ→τ} = D_{σ} → D_{τ}. Show that every computable element of D_{σ} is definable by the typed λ-calculus using parcond and the (computable!) function ∃: D_{(ι→ι)→o} where:

∃f = \{ \begin{matrix}tt & (∃n.f(n) = tt), \\ ff & (f(⊥) = ff ). \end{matrix}

[Warning This is rather hard. See “Plotkin, LCF considered as a programming language, TCS, 5, pp. 223– 255” for ideas.]

What we have done so far is show that all our constructions ×, →, ⊗, →_{⊥}, +, (·)_{⊥} are computable.

Definition. Let T: CPO_{⊥}^{m} × CPO_{⊥}^{n} → CPO_{⊥} be a locally continuous functor contravariant in its first m arguments and covariant in its last n arguments. It is computable if there is a function ε_{T} on enumerations and two recursive functions both called T, such that:

(1) If D_{0}, …, D_{m−1}, E_{0}, …, E_{n−1} are eff. given w.r.t. ε_{0}, …, ε_{m−1}, ε′_{0}, …, ε′_{n−1} and have indices i_{0}, …, i_{m−1}, j_{0}, …, j_{n−1} then T (D_{0}, …, D_{m−1}, E_{0}, …, E_{n−1}) is eff. given w.r.t. ε_{T} (ε_{0}, …, ε_{m−1}, ε′_{0}, …, ε′_{n−1}) with index T (i_{0}, …, i_{m−1}, j_{0}, …, j_{n−1}).

(2) If D′_{k}, E_{l}, D_{k}, E′_{l} are eff. given w.r.t. ε′_{k}, \overline{ε}_{l}, ε_{k}, \overline{ε}′_{l} and indices i′_{k}, \overline{i}_{l}, i_{k}, \overline{i}′_{l} then if f_{k}: D′_{k} → D_{k}, g_{l}: E_{l} →E′_{l} are computable with indices a_{k}, b_{k} we have that T (… f_{k} …, … g_{l} …) is computable w.r.t. ε_{T} (… ε_{k} …, … \overline{ε}_{l} …), ε_{T} (… ε′_{k} …, … \overline{ε}′_{l} …) with index T_{...i′_{k}...,...\overline{i}_{l}...,...i_{k}...,...\overline{i}′_{l}...}(… a_{k} …, … b_{l} …).

Clearly too the projection functors and constant functors K_{D}, with D eff. given, are computable in this sense.

Embeddings

Unfortunately it is not enough to take the computable embeddings to be the embeddings which are computable as their right adjoints need not be computable (see Exercise 1 below).

Definition. Let D, E be eff. given w.r.t. ε, ε′. An embedding i: D ◁ E is computable w.r.t. ε, ε′ and with index ⟨a, b⟩ iff a is an index of i w.r.t. ε, ε′ (as a computable function) and b is an index of i^{R} w.r.t. ε′, ε.

Exercises 1 Category.

(1) For any eff. given D the embedding id: D ◁ D is computable, an index being eff. obtainable from one for D.

(2) For any eff. given D, E, F w.r.t. ε, ε′, ε′′ if f: D ◁ E, g: E ◁ F are computable embedding so is g ∘ f; indeed there is a recursive function, ∘, such that if a is an index for f, w.r.t. ε, ε′ and b is an index for g w.r.t. ε′, ε′′ then b ∘ a is one for g ∘ f w.r.t. ε, ε′′ and further an index for ∘ is effectively obtainable from ones for D, E, F.

2 Initial Object. For any eff. given ⟨D, ε⟩ the embedding ⊥: U ◁ D is computable, an index being effectively obtainable from one of D.

3. All the examples of embeddings in Chapter 4 are computable.

Theorem 2. Let i: D ◁ E be an embedding of eff. given domains D, E w.r.t. ε, ε′. Then i is computable iff for some recursive r we have that ⟨r, i⟩: ⟨D, ε⟩ → ⟨D, ε′⟩ i.e. that the following diagram commutes:

[figure: D; D′; i; N; N; r; ε; ε′]

Proof. ⇒) We know that for any finite a in D we have i(a) finite. Now:

\begin{aligned}i(a) = b & ≡ (b ⊑ i(a)) ∧ (i(a) ⊑ b) \\ & ≡ (b ⊑ i(a)) ∧ (a ⊑ i^{R}(b)). \end{aligned}

So as i and i^{R} are computable, the relation i(ε_{m}) = ε′_{n} is re. in m and n. But then it must be recursive as given m and n one searches for (and finds) a k with i(ε_{m}) = ε′_{k} and checks if ε_{k} = ε′_{n}.

⇐) We have ε′_{n} ⊑ i(ε_{m}) ≡ ε′_{n} ⊑ ε′_{r(m)} which is re. and also ε_{n} ⊑ i^{R}(ε′_{m}) iff i(ε_{n}) ⊑ ε′_{m} ≡ ε′_{r(n)} ⊑ ε′_{m} which is re.

Note the proof of the equivalence is effective.

Exercise

1. Find an embedding i: O 0^{ω} → (O 0_{⊥})^{ω} which is computable as a function but not as an embedding. [Hint Use the two embeddings of O 0 in O 0_{⊥}.] Is it the case the i^{R} computable implies i computable, in general? If not is the condition Graph(i^{R}) recursive strong enough?

Definition. Let F: (CPO^{E})^{n} → CPO^{E} be a covariant functor. It is computable if there is a function ε_{F} on enumerations and two recursive functions both called F such that

(1) If … D_{k} … are eff. given w.r.t. … ε_{k} … and indices … i_{k} … then F (… D_{k} …) is eff. given w.r.t. ε_{F} (… ε_{k} …) and index F (… i_{k} …).

(2) If … D_{k} …, … E_{k} …, are eff. given w.r.t. … ε_{k} …, … ε′_{k} … and indices … i_{k} …, … j_{k} … then if … f_{k}: D_{k} ◁ E_{k} … are computable embeddings w.r.t. … ε_{k} …, … ε′_{k} … with indices … a_{k} … then F (… f_{k} …) is computable w.r.t. ε_{F} (… ε_{k} …), ε_{F} (… ε′_{k} …) and has index F_{...i_{k}...,...j_{k}...}(… a_{k} …).

Clearly if T: CPO_{⊥}^{m} ×CPO_{⊥}^{n} →CPO_{⊥} is computable so is T^{E}: (CPO^{E})^{m+n} →CPO^{E}; further any composition of computable functors over CPO^{E} is also computable. We leave the proof of this assertion to the reader (for simplicity he should just consider the case m = n = 1).

Direct Limits

Definition. Let Δ = ⟨D_{m}, ε_{m}, f_{m}⟩ be a chain of eff. given domains D_{m} w.r.t. ε_{m}, and with f_{m}: D_{m} ◁D_{m+1} being computable embeddings w.r.t. ε_{m}, ε_{m+1}. Then Δ is effective, with index δ, if g = {δ} is a recursive function such that

(1) π_{0} ∘ g(m) is an index of D_{m} w.r.t. ε_{m}.

(2) π_{1} ∘ g(m) is an index of f_{m} w.r.t. ε_{m}, ε_{m+1}.

Definition. Let Δ = ⟨D_{m}, ε_{m}, f_{m}⟩ be an effective chain. Then an effective cone ρ: Δ → ⟨D, ε⟩ from Δ to an effectively given D w.r.t. ε is a cone ρ: ⟨D_{m}, f_{m}⟩ → D with ρ_{m}: D_{m} ◁ D computable w.r.t. ε_{m}, ε and such that:

(1) d is an index D w.r.t. ε.

(2) For any m, {ρ}(m) is an index of D_{m} w.r.t. ε_{m}.

Definition. Let Δ = ⟨D_{m}, ε_{m}, f_{m}⟩ be an effective chain, and let ρ: Δ → ⟨D, ε⟩ be an effective cone. Then ρ is effectively universal iff ρ: ⟨D_{m}, f_{m}⟩ → D is universal and if ρ′: Δ → ⟨D′, ε⟩ is any effective cone there is a mediating computable θ: D ◁ D′ w.r.t. ε, ε′ and an index for θ is effectively obtainable from one for ρ′ (and an index for ρ is ⟨a, b⟩ where a is an index for ρ as an effective cone and b is an index s.t. if m is an index for ρ′ then {a}(m) is one for θ w.r.t. ε, ε′).

Theorem 3. Let Δ = ⟨D_{m}, ε_{m}, f_{m}⟩ be an effective chain and let ρ: ⟨D_{m}, f_{m}⟩ → D be universal (see Chapter 4). Define ε: N → B_{D} by:

ε_{⟨m,n⟩} = ρ_{m}(ε_{m}(n))

(see Chapter 5). Then ρ: Δ → ⟨D, ε⟩ is effectively universal and an index for ρ is effectively obtainable from one for Δ. Proof. First we check that D is effectively given w.r.t. ε by the formulae:

ε_{⟨k,l⟩} ↑ ε_{⟨m,n⟩} ≡ ρ_{k}(ε_{k}(l)) ↑ ρ_{m}(ε_{m}(n)) 1.
≡ ρ_{r}[f_{kr}(ε_{k}(l))] ↑ ρ_{r}[f_{mr}(ε_{m}(n))]  where r = max(k, m)
≡ ρ_{r}[ε_{r}(g_{kr}(l))] ↑ ρ_{r}[ε_{r}(g_{mr}(n))]
= ε_{r}(g_{kr}(l)) ↑ ε_{r}(g_{mr}(n))

(where g_{m}: N → N is the recursive function for f_{m}: D_{m} ◁ D_{m+1} guaranteed effectively obtainable from any index of f_{m} by Theorem 2, and g_{ln} is an evident product of g_{m}’s).

2. If b is a code of ⊥_{D_{0}} then ⟨0, b⟩ is one of ⊥_{D}.

ε_{⟨i,j⟩} = ε_{⟨k,l⟩} ⊔ ε_{⟨m,n⟩} 3.
≡ ρ_{i}(ε_{i}(j))
= ρ_{k}(ε_{k}(l)) ⊔ ρ_{m}(ε_{m}(n))
≡ ρ_{r}(ε_{r}(g_{ir}(j)))
= ρ_{r}(ε_{r}(g_{kr}(l))) ⊔ ρ_{r}(ε_{r}(g_{mr}(n)))  where r = max(i, k, m)
≡ ε_{r}(g_{ir}(j))
= ε_{r}(g_{kr}(l)) ⊔ ε_{r}(g_{mr}(n))

and so, clearly, an index for D w.r.t. ε is effectively obtainable from one for Δ. To see that ρ_{m}: D_{m} → D is computable w.r.t. ε_{m}, ε just note that the following diagram commutes:

[figure: D_{m}; D; ρ_{m}; N; N; ⟨m, −⟩; ε_{m}; ε]

and apply Theorem 2. We have now essentially seen that ρ is an effective cone and an index for it is effectively obtainable from one for Δ.

Now let ρ′: Δ → ⟨D′, ε′⟩ be any other effective cone. The mediating θ: D ◁ D′ is given by the formula:

θ = ⨆ ρ′_{n} ∘ ρ_{n}^{R}

and by Exercises 5, p. 73, 1, p. 78 and since ρ′ and ρ are effective the function θ is computable. Equally the formula θ^{R} = ⨆ ρ_{n} ∘ ρ′_{n}^{R} shows θ^{R} to be computable and we see that θ is a computable embedding with index effectively obtainable from ρ′. Thus ρ is effectively universal with an index effectively obtainable from any one for Δ.

What this theorem says is that the inverse limit construction, lim_{→} is effective when viewed as a function from effective chains to universal cones.

Theorem 4 Continuity of Functors. Let T: CPO^{E} → CPO^{E} be a computable functor. Then it is effectively continuous in that if ρ: ⟨D, ε_{m}, f_{m}⟩→⟨D, ε⟩ is effectively universal so is T (ρ): ⟨T (D), ε_{T} (ε_{m}), T (f_{m})⟩→ ⟨T (D), ε_{T} (ε)⟩ and an index for T (ρ) is effectively obtainable from one for ρ. Proof. This is an effective version of Theorem 2, Chapter 4 and is left to the reader.

Algebras

The end of our long haul is now in sight! In what follows we let T: CPO^{E} → CPO^{E} be a computable functor.

Definition.

(1) A computable T -algebra with index ⟨a, b⟩ is ⟨D, ε, α⟩ where ⟨D, α⟩ is a T -algebra, D is eff. given w.r.t. ε with index a and α is computable w.r.t. ε_{T} (ε), ε with index b.

(2) An effectively-initial T -algebra with index ⟨a, b⟩ is a computable T -algebra ⟨D, ε, α⟩ with index a and with ⟨D, α⟩ initial such that for any computable T -algebra ⟨E, ε′, β⟩ with index a′ the unique T -homomorphism, θ: ⟨D, β′⟩ → ⟨E, β⟩ is computable w.r.t. ε, ε′ and has index {b}(a′).

Theorem 5 Effective Initial Solution of Recursive Domain Equations. The initial algebra ⟨Fix_{T} , η_{T} ⟩ is effectively initial (for a suitable ε). Proof. As U is eff. given w.r.t. the evident ε^{u} and by Exercise 2, p. 79 and as T is computable, the chain Δ = ⟨T^{n}(U), ε_{T} (ε^{u}), T^{n}(⊥)⟩ is effective. Let ρ: ⟨T^{n}(U), T^{n}(⊥)⟩ → D be universal and take ε as in Theorem 3. Then ρ: Δ → ⟨D, ε⟩ is effectively universal. Then T ρ: T Δ → ⟨T D, ε_{T} (ε)⟩ is also effectively universal, by Theorem 4. Further η_{T} = ⨆_{n} ρ_{n+1} ∘ (T ρ_{n})^{R} and so η_{T} is computable w.r.t. ε_{T} (ε), ε. Thus ⟨Fix_{T} , ε, η_{T} ⟩ is a computable T -algebra. Let ⟨D, ε, α′⟩ be any other one. Then following the proof of Theorem 1, Chapter 5 define ρ′_{m}: T^{n}(U) ◁ D by ρ′_{0} = ⊥ and ρ′_{m+1} = α ∘ T (ρ′_{m}). Then as in Theorem 1 we see ρ′ is a cone from ⟨T^{n}(U), T^{n}(⊥)⟩ to D and it is easily seen (by induction on n) to be an effective cone from Δ to ⟨D, ε⟩. But ρ: Δ → ⟨D, ε⟩ is effectively universal and so we can obtain an index for the mediating computable θ: Fix_{T} → D effectively from one for ρ and hence from one for ⟨D, ε⟩. But, as in the proof of Theorem 1, this θ is the required mediating T -homomorphism and we have seen that ⟨Fix_{T} , ε, η_{T} ⟩ is indeed effectively initial.

In fact this proof is also effective and, with suitable definitions, one obtains an index for the effectivelyinitial T -algebra from one for T. So: taking effectively-initial fixed-points of computable functors is itself an effective operation.

The above theorem easily extends to multiple fixed-points and we see that all the domains and functions we have considered in the notes are computable and so whatever the programming language for any program, P, and semantic function, M, defined by our methods we have that M(P) is computable. This gives the possibility of an operational semantics. For example if S = Id →_{⊥} N and M(P): S →_{⊥} S we have that given an index for σ we get one for M(P)(σ)(x) for any variable x and the required integer (if it exists) can be found by running a Turing Machine on this index.

However this is all only of theoretical interest. It would be more useful to patch up the various spotty results on definability mentioned in the exercises by showing that some (formally defined) metalanguage can define exactly the computable elements and that the language has a good operational semantics (as in, for example, the LCF paper) and then one can apply Mosses’ ideas to write a complete compiler-compiler.

Exercises

1. Give an effective version of Theorem 3, p. 54, Chapter 5.

2. Is there anything more one can say along the lines of Theorem 4, p. 55, Chapter 5 by considering effectiveness?

3. It is boring to continually mention indices. Can you formulate a metatheoretical assertion to the effect that if a proof is effective (in a suitable intuitionistic logic) then one obtains, via a Kleene realizability, a suitable statement on indices?

8. Nondeterminism and Parallelism

We show how to extend our theory to deal with problems of nondeterminism and parallelism. The interest of the latter is clear; that of the former arises when we try to reduce parallelism to nondeterminism and the idea is to explain a parallel construct c∥c′ in terms of the possible atomic actions of c and c′ and the set of their interleavings. It is surprising how many difficulties arise and we do not regard the theory as settled.

Discrete Powerdomains

Suppose we enrich the usual simple imperative language with a nondeterministic choice construct, c or c′. The idea is that an execution of c or c′ consists of a choice of c and an execution of c or a choice of c′ and an execution of c′. (This choice may be made by an implementation or forced by some external circumstance.) We regard c or c′ as correct, terminating (etc.). Now consider the following three programs (where loop =^{def} while true do sleep)

(1) x := 1,

(2) x := 1 or loop,

(3) loop.

Which should be considered equivalent? One view is that none are since (1) always terminates unlike (2) & (3) and (2) can terminate unlike (3). Another is that (1) = (2) ≠ (3) since (1) and (2) give the same set of results, if any. Another is that (1) ≠ (2) = (3) since (2) and (3) can both (unlike (1)) fail to terminate and so nothing can be guaranteed of either of them. All three views have their place: the first is “what actually happens”, the second for partial correctness properties (Hoare), the third for total correctness (Dijkstra). We shall give semantics for all three.

The Relational View

To this end let S be the countable set of states and suppose we want a semantics for the second view (the simplest case). Then for a given initial state σ a program c should give us a set X ⊆ S of final states (since we do not wish to record nontermination). Thus we could expect

C[[c]]: S → P(S)

(where, of course, P(S) is the set of all subsets of S). That is we use a nondeterministic function for our semantics. And it will also be natural to order P(S) by subset and use the induced pointwise order on C[[c]].

Exercise 1. Show that

S → P(S) ≅ P(S × S)

The set P(S × S) is the set of all relations over S; try rephrasing what we do below in terms of these relations.

In order to compare nondeterministic functions we note a very important fact which will prove a reliable guide in more general situations.

Fact 1. Let X and Y be countable sets. Then for any f: X → P(Y) there is a unique strict continuous, additive f^{†}: P(X) →_{SA} P(Y) (called the extension of f) such that the following diagram commutes.

[figure: P(X); P(Y); f^{†}; f; X; {·}]

Further (·)^{†}: (X → P(Y)) ≅ P(X) →_{SA} P(Y) is an isomorphism of partial orders.

Proof. Suppose g: P(X) →_{SA} P(Y) makes the diagram commute. ⇐) Then for any A ⊆ X we have

g(A) = g( ⋃_{a∈A}{a})
= ⋃_{a∈A} g({a})  g is strict, additive and continuous and A ⊆ X is countable

= ⋃_{a∈A} f(a)

showing uniqueness. Conversely using this formula to define f^{†} we see that f^{†} is clearly continuous and additive and makes the diagram commute as:

f^{†}({a}) = ⋃_{a′∈{a}} f(a′) = f(a).

It follows at once that † is a bijection with inverse λg.g ∘ {·} and as both † and its inverse are evidently monotonic they are therefore isomorphisms (of partial orders).

Exercise 2. Where was the countability of X and Y used in the above (if at all)? Can you extend the definitions of nondeterministic functions so that Fact 1 holds for arbitrary X?

Exercise 3. Noting that X → P(Y) ≅ X_{⊥} →_{⊥} P(Y) can you provide a variant of Fact 1 to apply to nondeterministic functions of type X_{⊥} → P(Y)?

Exercise 4. Show using Exercise 1 and Fact 1 that there is an isomorphism Λ: (X → P(Y)) ≅ P(Y) →_{SA} P(X) given by:

Λ(m)(B) = {a ∈ X | m(a) ∩ B ≠ 0}.

Definition 1. For any function f: P(Y) → P(X), its dual f̃: P(Y) → P(X) is defined by:

f̃(B) = X\f(Y \B).

Exercise 5. Show that ˜ f̃ = f, that f ⊑ g iff f̃ ⊒ g̃, that f is monotonic, continuous, additive, … iff f̃ is monotonic, dual-continuous, multiplicative, . . .. Conclude that ˜(·): [P(Y) → P(X)] → [P(Y) → P(X)] is an isomorphism and cuts down to an isomorphism of continuous and dual continuous functions, etc., etc.

Exercise 6. For any m: X → P(Y) and B ⊆ Y we define the weakest liberal precondition wlp(m, B) by

wlp(m, B) = {a ∈ X | m(a) ⊆ B}.

Show that λB.wlp(m, B) is the dual of Λ(m).

Composition. Now we can compose two nondeterministic primitives X →^{f} P(Y) and Y →^{g} P(Z) by defining f; g: X → P(Z) as

f; g = g^{†} ∘ f.

Exercise 7. Show that composition is associative with unit the singleton function. [Hint This is easy using Fact 1.]

Now consider the following little nondeterministic imperative language

c ::= a | skip | c; c | if b then c else c | while b do c | c or c

where we are given semantics A: ACom → (S → S) and B: BExp → (S → T) for atomic commands and Boolean expressions. Here is a semantics

C: Com → (S → P(S))

for the language:

C[[a]] = λσ ∈ S.{A[[a]]};
C[[skip]] = {·};
C[[c_{1}; c_{2}]] = C[[c_{1}]]; C[[c_{2}]];
C[[if b then c_{1} else c_{2}]] = λσ ∈ S.if B[[b]](σ) then C[[c_{1}]](σ) else C[[c_{2}]](σ);
C[[while b do c]] = μm ∈ S → P(S).λσ ∈ S.if B[[b]](σ) then C[[c]]; m else {σ};
C[[c_{1} or c_{2}]] = λσ ∈ S.C[[c_{1}]](σ) ∪ C[[c_{2}]](σ).

So all we need is singleton, extension (for composition) and binary union.

Exercise 8. Show that Cartesian Product, P(A) × P(B) →^{×} P(A × B) is strict continuous and additive in each argument. Show that for any f: A × B → P(C) there is a unique f^{†_{2}}: P(A) × P(B) → P(C) which is strict, continuous and additive in each argument and which makes the following diagram commute

[figure: P(A) × P(B); P(C); f^{†_{2}}; f; A × B; {·} × {·}]

Show too that †_{2} is given by: f^{†_{2}} = f^{†} ∘ × (and so × = {·}^{†_{2}}). What is the natural function from P(A × B) to P(A) × P(B)? What relationship do you thereby find between P(A × B) and P(A) × P(B)? Extend all this to products of several powersets.

Exercise 9. Let Σ be a finite alphabet. Consider the following little applicative language for denoting subsets of Σ^{∗}:

e ::= a | λ | e.e | e or e | μx.e | x

where a ranges over Σ, λ is the empty word, e.e′ is language product (the extension considered in the previous exercise of semigroup multiplication in Σ^{∗}) and the rest is obvious. Show that the closed expressions give exactly the context-free languages. How would you alter the notation to obtain exactly the regular languages?

Exercise 10. Nondeterministic phenomena arise even in deterministic languages when we perform dataflow analysis. This exercise gives a very rough picture. Consider the simple language

c ::= a | skip | c; c | if b then c else c | while b do c

where we are given A: ACom → (S → S) and B: BExp → (S → T) and define C: Com → (S → S_{⊥}) is usual. Suppose we try to represent S by a set R via a surjective representation function r: S → R (example S = N and R = {“odd”, “even”}). We regard the inverse of r as being of type r^{−1}: R → P(S). Now define abstractions A_{R}: ACom → (R → P(R)) and B_{R}: BExp → (S → P(T)) of the semantics of atomic commands and Boolean expressions by

\begin{matrix}A_{R}[[a]] = r^{−1}; \{·\} ∘ r ∘ A[[a]], \\ B_{R}[[b]] = r^{−1}; \{·\} ∘ B[[b]]. \end{matrix}

The exercise is to define an abstraction C_{R}: Com → (R → P(R)) of the semantics of commands and prove that

C_{R}[[c]] ⊇ r^{−1}; ({·} ∘ C[[c]]).

Reference. P. Cousot and R. Cousot. Abstract Interpretation: A Unified Lattice Model for Static Analysis of Program by Construction or Approximation or Fixpoints. 4th POPL.

The Egli-Milner Order

Now we turn to the first possibility where we want to record “what actually happens”. It is natural here to consider subsets of S_{⊥} but we must answer two questions.

A. What subsets should we consider?

B. How should they be ordered?

This situation is similar to that faced before when we had to decide which functions between cpo’s to consider and how to order them.

A. What Subsets? First since every program in our language must produce something (even if it is just ⊥) we consider only nonempty subset. (Variants with an empty subset are considered in the exercises — they provide inessential, but useful alternatives.) More importantly consider the following attempt to write a program to output an arbitrary integer:

x := 0; alarm := “off”; while alarm = “off” do x := x + 1 or alarm := “on”.

Clearly this can either produce an arbitrary integer or fail to terminate. This is not accidental as the following informal argument shows. Consider the tree of all possible execution paths. In the case of the above program it looks like this

[figure: ⟨0, “on”⟩; ⟨0, “off”⟩; ⟨1, “on”⟩; ⟨1, “off”⟩; ⟨2, “on”⟩; ⟨2, “off”⟩; ⟨3, “on”⟩; …; ⟨3, “off”⟩; …]

and here and in general it will be a finitely-branching tree, with the branching corresponding to the possible executions of nondeterministic constructs. Therefore if there are infinitely many different possible final states (e.g. all pairs ⟨n, “on”⟩) then there are infinitely many nodes in the tree and so by König’s Lemma there must be an infinite branch in the tree, that is, nontermination is possible. This is a major phenomenon when considering finite nondeterminism where at most finitely many choices can made at any one point.

Summing up we take, for countable X, the powerdomain P(X_{⊥}) to consist of all nonempty subsets of X_{⊥} which are either finite or contain ⊥ and consider next:

B. What Order? With products, the coordinatewise ordering was natural where each coordinate is increased to increase the order. Now the elementwise ordering is natural where each element is increased perhaps to a set of greater elements. So we expect

A ⊑_{EM} B

just when for each x in A there is a nonempty set Y_{x} such that

(1) ∀y ∈ Y_{x}.x ⊑ y,

(2) B = ⋃_{x∈A} Y_{x}.

Here is another way (due to Egli & Milner) of saying the same thing

\begin{aligned}A ⊑_{EM} B iff & (↓) ∀x ∈ A.∃y ∈ B.x ⊑ y, \\ & ∧ (↑) ∀y ∈ B.∃x ∈ A.x ⊑ y. \end{aligned}

Note that, putting Y_{x} = {y ∈ B | x ⊑ y} condition, (↓) says Y_{x} is nonempty and (1) above on Y_{x} is automatic and (2) follows from the new (↑). You can prove that the nonemptiness requirement, (1) and (2) imply (↓) and (↑). This definition makes sense for any preorder and always defines a preorder on subsets. In the case at hand where we want A, B ⊆ X_{⊥} then

A ⊑_{EM} B iff either (1) ⊥ ∉ A ∧ A = B,
or (2) ⊥ ∈ A ∧ A\{⊥} ⊆ B\{⊥}.

So P(X_{⊥}) equipped with ⊑_{EM} is even a cpo. (For it is clearly a partial order with least elements {⊥}. And if A_{0} ⊑ A_{1} ⊑ ⋯ is an increasing ω-chain then either ⊥ ∉ A_{n} for some A_{n}, when ⨆_{i} A_{i} = A_{n} or else ⊥ ∈ A_{n} for all n when ⨆_{i} A_{i} = ⋃_{n} A_{n}.)

Union. The binary union function ∪: P(X_{⊥})^{2} → P(X_{⊥}) is continuous. (Easy exercise)

Definition 2. A function f: P(X_{⊥}) → P(Y_{⊥}) is linear iff f(x ∪ y) = f(x) ∪ f(y).

Fact 2. Let X and Y be countable sets. Then for any f: X → P(Y_{⊥}) there is a unique strict continuous linear f^{†}: P(X_{⊥}) → P(Y_{⊥}) such that the following diagram commutes

[figure: P(X_{⊥}); P(Y_{⊥}); f^{†}; f; X; {·}]

further † is an isomorphism of X → P(Y_{⊥}) and the partial order of strict continuous linear function from P(X_{⊥}) to P(Y_{⊥}). Proof. For uniqueness we note that for finite A ⊆ Y_{⊥} we have

f^{†}(A) = ⋃_{a∈A} f(a)

as before and for infinite A = {⊥, a_{1}, a_{2}, …} we have

f^{†}(A) = f^{†}(⨆_{n}{⊥, a_{1}, …, a_{n}})

= ⨆_{n} f^{†}({⊥, a_{1}, …, a_{n}})

= ⨆_{n}[f^{†}({⊥}) ∪ ⋃_{i<n} f^{†}({a_{i}})]

= ⨆_{n}[{⊥} ∪ ⋃_{i<n} f(a_{i})]

= ⋃_{a∈A} f(a)

and the rest of the proof is an exercise for the reader.

Now the composition f; g: X → P(Z_{⊥}) of X →^{f} P(Y_{⊥}) and Y →^{g} P(Z_{⊥}) is defined as before by: f; g = g^{†} ∘ f and again it is associative with unit the singleton function. And, again as before we can define a semantics

C: Com → (S → P(S_{⊥}))

which looks just like it did before.

Exercise 11. Draw P(U), P(O 0 ), P(T), P(N_{⊥}).

Exercise 12. Show that P(N_{⊥}) is ω-algebraic and its finite elements are just those of finite cardinality. Is it also consistently complete?

Exercise 13. Try to find an analogue of S → P(S) ≅ P(S × S). [Hint Consider certain pairs ⟨T, R⟩ with T ⊆ S, R ⊆ S^{2}, the idea being that R is the relation and T is its “termination domain”.]

Exercise 14. Investigate analogue of Exercises 2, 3, 8 above.

Exercise 15. Show that P(S) ≅ P(S_{⊥})/⊑_{R} where

X ⊑_{R} Y iff (↓) ∀x ∈ X.∃y ∈ Y.x ⊆ y.

(If ⟨P, ⊑⟩ is a preorder and ≤ is a preorder on P including ⊑ then P/≤ is the partial order ⟨{a↓| a ∈ P}, ⊆⟩ where a ↓ =^{def}{b ∈ P | b ≤ a}. Note that natural monotonic map ↓: P → P/≤.) So there is a natural map P(S_{⊥}) → P(S). What is it?

It is possible to consider applicative programming languages for various classes of functions: f: P(X_{⊥}^{(1)})× ⋯×P(X_{⊥}^{(n)})→P(Y_{⊥}) which are continuous and perhaps n-strict and perhaps ⊆-monotonic or linear in each argument. For information see M. Hennessy “Powerdomain and Nondeterministic Recursive Definitions” (to appear).

The Smyth Order

Finally we consider the third possibility that (1) ≠ (2) = (3) (due to M. Smyth). Here we want to identify all sets containing ⊥ since nothing can be guaranteed of any of them. However we want to go even further; for example we want the program

(4) x := 1 or x := 2.

to have a smaller meaning than (1) above, the idea being that less can be guaranteed of it. So if in some context (1) fails to terminate so must (4), but the converse does not hold (consider the context C[ ] = [ ]; if x = 2 then loop else skip). Thus we want: {1, 2} ⊑ {1}.

For a formal definition we identify all sets containing ⊥ with a standard one which for convenience we take to be N_{⊥}. The remaining sets are the finite nonempty ones and so we take for any countable set X:

P_{S}(X_{⊥}) = ⟨{A ⊆ X_{⊥} | A = X_{⊥} or A is nonempty and finite, and A ⊆ X}, ⊇⟩.

Exercise 16. Show that P_{S}(X_{⊥}) is an ω-algebraic, consistently complete cpo and draw a few examples.

Clearly ∪: P_{S}(X_{⊥})^{2} →P_{S}(X_{⊥}) is again well-defined and continuous. It is left to the reader as of Exercise 17 to work out an analogue to Fact 2 thereby obtaining a third semantics for the simple imperative language.

Predicate Transformers

The Smyth order is strongly linked to Dijkstra’s ‘weakest precondition’ predicate transformers.

Definition 3. Let X and Y be countable sets. A predicate transformer is any p: P(Y) → P(X) which is continuous, strict and multiplicative. (The last condition means that for any A, B ⊆ Y we have p(A ∩ B) = p(A) ∩ p(B).)

We develop the theory by means of some exercises.

Exercise 18. Suppose m: X →P_{S}(Y_{⊥}). Define the weakest precondition function by putting for any B ⊆ Y

wp(m, B) = {a ∈ X | m(a) ⊆ B}.

Show that Ω(m) =^{def} λB.wp(m, B) is a predicate transformer. Show too that Ω is monotonic and that the following properties hold:

Ω({·}_{X}) = id_{P(X)},
Ω(m; m′) = Ω(m) ∘ Ω(m′),
Ω(m ∪ m′) = Ω(m) ∩ Ω(m′)

(where m ∪ m′ =^{def} λa ∈ X.m(a) ∪ m′(a) and for any p, q: P(Y) → P(X), p ∩ q =^{def} λB ⊆ Y.p(B) ∩ q(B)).

Exercise 19. Let p: P(Y)→P(X) be a predicate transformer. Show that p is a stable function in the sense of Chapter 6 Exercise 1 p. 69. That is show that if a ∈ p(Y) then there is a finite set M(p, a) such that

∀B ⊆ Y.a ∈ p(B) iff M(p, a) ⊆ B.

Show too that p is completely multiplicative in that if ⟨B_{λ}⟩_{λ∈Λ} is a collection of subsets of Y then

p(⋂_{λ} B_{λ}) = ⋂_{λ} p(B_{λ}).

Exercise 20. Let ST (X, Y) be X → P_{S}(Y) with the pointwise ordering and let PT (X, Y) be the set of predicate transformers p: P(Y) → P(X) with the pointwise ordering (p ⊑ q iff ∀B ⊆ Y.p(B) ⊆ q(B)). Show that

Ω: ST (X, Y) → PT (X, Y)

is even an isomorphism of partial orders. [Hint Use the previous exercise to find a definition of Ω^{−1}.] Exercise 21. Define a predicate transformer semantics

W: Com → PT (S, S)

(remember to prove that W[[c]] is always a predicate transformer!). Let C_{S}: Com → ST (S, S) be the evident semantics based on the Smyth Powerdomain. Show that the following diagram commutes.

[figure: Com; ST (S, S); C_{S}; W; PT (S, S); Ω]

These exercises demonstrate complete equivalence between the predicate transformer approach and the nondeterministic position approach using the Smyth powerdomain.

Exercise 22. Let DPT (X, Y) be the additive predicate transformers from Y to X (i.e. those ones p such that for all A, B ⊆ Y we have p(A ∪ B) = p(A) ∪ p(B).

Show that they correspond to the deterministic state transformation functions in the sense that Ω cuts down to an isomorphism

(X →_{P} Y) ≅ DPT (X, Y).

Exercise 23. Find a relational view of predicate transformers and Smyth nondeterministic state transformation functions.

References on Predicate Transformers

E. W. Dijkstra. A Discipline of Programming. Prentice-Hall, 1976.

G. D. Plotkin. Dijkstra’s Predicate Transformers and Smyth’s Powerdomains. Abstract Software Specifications (ed. D. Bjørner), LNCS Vol. 86, 1980.

Note the reversal of direction in the above between state transformation functions and predicate transformers. What we have is a duality between the category ST of state transformation functions and the category PT of predicate transformers. (A duality of categories K and L is an isomorphism K^{op} = L.)

Note that Exercises 4, 5, 6 give a duality theory for the relational case, there seems not to be such a theory for the Egli-Milner ordering.

General Powerdomains

We begin by generalising the relational powerdomain to an arbitrary ω-algebraic cpo D. The easy mathematics involved will make that needed for the other two cases more comprehensible. More importantly we will quickly be in a position to demonstrate the techniques made available by powerdomain for the denotational semantics of parallelism. As in the case of a simple nondeterministic language the form of the semantics remains unchanged for the other semantics; only the mathematical properties of the resulting models will differ.

How to Order Subsets of D

Let ∼ ⊑ be the desired preorder (with associated equivalence ≃); the intuition is that X ∼ ⊑ Y means that anything X can do Y can do better, and we look for various formalisations of this idea. We will restrict attention to nonempty X and Y. First we generalise a definition of Exercise 15.

Definition 4. For X, Y nonempty subsets of D,

X ⊑_{R} Y iff ∀x ∈ X.∃y ∈ Y.x ⊑ y

and let =_{R} be the associated equivalence.

Note that X ⊆ Y implies X ⊑_{R} Y. From the above discussion we would expect that

X ⊑_{R} Y implies X ∼ ⊑ Y.

Exercise 24. Show that if f: D → E is continuous and if for two nonempty subsets X and Y of D we have X ⊑_{R} Y then f(X) ⊑_{R} f(Y).

It may now seem natural that ∼ ⊑ should be preserved by continuous functions and since it should be ⊑_{R} on discrete cpos we define for all nonempty X, Y ⊆ D

X ∼ ⊑_{R} Y iff ∀f: D → O 0 .f(X) ⊑_{R} f(Y)

(and let ≃_{R} be the associated equivalence) and expect that

X ∼ ⊑ Y implies X ∼ ⊑_{R} Y.

Thinking of f: D→O 0 as an experiment or detectable property of D, one can understand X ∼ ⊑_{R} Y as meaning that any experiment which can succeed on X can also succeed on Y.

Exercise 25. Show that for any continuous f: D → P(Z) with Z countable we have: X ∼ ⊑_{R} Y implies ⋃ f(X) ⊆ ⋃ f(Y).

Thus there is no loss in considering only O 0 .

Now ∼ ⊑ cannot be ⊑_{R} if union is to work as a continuous function; for let X be a set containing an increasing sequence x_{0} ⊑ x_{1} ⊑ x_{2} ⊑ ⋯ but not containing any upper bound of x = ⨆_{n} x_{n}. Then X≠_{R}X ∪ {x} but X ∪ {x} = X ∪ {⨆_{n} x_{n}} ≃ ⨆_{n}(X ∪ {x_{n}}) (by assumption) = X. We therefore take ∼ ⊑ equal to ∼ ⊑_{R}. (The reader can adapt the argument given below to show that ∼ ⊑ should be ∼ ⊑_{R} for finitely generable sets.) The next theorem gives several characterisations of ∼ ⊑_{R} to increase the reader’s confidence in the naturality of the relation.

Theorem 1. Consider the following conditions on nonempty subsets X and Y of D.

(1) X ⊑_{R} Y,

(2) X ∼ ⊑_{R} Y,

(3) ∀x ∈ X.∀b ∈ B_{D}.(b ⊑ x ⇒ ∃y ∈ Y.b ⊑ y),

(4) ∀A ⊆ D.(A finite ∧ A ⊑_{R} X) ⇒ A ⊑_{R} Y. Then (1) ⇒ (2) ⇔ (3) ⇔ (4) and if X ⊆ B_{D} or Y is finite then (1) ⇔ (2). Proof. (1) ⇒ (2). Already known.

(2) ⇒ (3). Suppose b ⊑ x ∈ X. Then ⊤ ∈ (b ⇒ ⊤)(X) ⊑_{R} (b ⇒ ⊤)(Y) and so ⊤ ∈ (b ⇒ ⊤)(Y) and so b ⊑ some y in Y.

(3) ⇒ (4). Trivial.

(4) ⇒ (2). Left as an exercise.

(1) ⇔ (2) when X ⊆ B_{D} or Y is finite. Immediate from (3).

So for finite nonempty sets we have X ⊑_{R} Y ≡ X ∼ ⊑_{R} Y and condition (3) show how close ∼ ⊑_{R} is to being ⊑_{R} in general and (4) says any finite information about X’s possibilities is also true of Y.

There is no need in the relational case to consider any restriction on the sets allowed into the powerdomain; all are “computationally feasible”.

Definition 5. For any nonempty X ⊆ D put X^{∘} =^{def} {b ∈ B_{D} | ∃x ∈ X.b ⊑ x}. (Note that X^{∘} is an ideal in B_{D}.)

Now Theorem 1(3) shows that X ≃_{R} X^{∘}. Let X^{∘} = {b_{(1)}, b_{(2)}, …}. Let P_{(n)} be a program whose behaviour is b_{(n)}, if possible. (For example when D = Tapes P_{(n)} could be print b_{(n)}.) The set of computations of

letrec f(n) = P_{(n)} or f(n + 1) in f(0)

is X^{∘} since the possible nontermination of f(0), ⊥ is already accounted for in X^{∘}.

So we can take the powerdomain to be P_{R}(D) =^{def} ⟨P(D), ∼ ⊑_{R}⟩/⊑_{R} where P(D) is the set of all nonempty subsets of D. But a clearer picture is easily obtained.

Definition 6. For any X ⊆ D put Cl_{R}(X) =^{def} {x | ∀b ⊑ x.∃y ∈ X.b ⊑ y} (= {x | B_{x} ⊆ X^{∘}}).

Exercise 26. Show that Cl_{R} is a topological closure operator. That is (1) Cl_{R}(X) ⊇ X,

(2) Cl_{R}(Cl_{R}(X)) = Cl_{R}(X),

(3) Cl_{R}(X ∪ Y) = Cl_{R}(X) ∪ Cl_{R}(Y). In fact Cl_{R}(X) = X iff X is closed in the Scott topology of D.

Lemma 1. For nonempty subsets X and Y of D, (1) X ≃ Cl_{R}(X),

(2) X ≃ Y iff Cl_{R}(X) = Cl_{R}(Y),

(3) X ∼ ⊑_{R} Y iff Cl_{R}(X) ⊆ Cl_{R}(Y). Proof. An easy Exercise 27.

Lemma 2. The relational powerdomain P_{R}(D) is ⟨Closed nonempty subsets of D, ⊆⟩. Further P(D) is an ω-algebraic complete lattice: ⊥ = (⊥_{D}) and ⨆ χ = Cl_{R}(⨆_{X∈χ} X) (and X ⊔ Y = X ∪ Y) and the finite elements are those of the form Cl_{R}(A) = A^{∘} where A is a finite nonempty subsets of B_{D}. Proof. First the maps P(D) ⇀ ↽^{θ}_{δ} ⟨Closed nonempty subsets of D, ⊑⟩ defined by θ(X↓) = Cl_{R}(X), δ(X) = X↓ are well-defined using Theorem 1(2) and monotonic using 1(3). Therefore using 1(1) they are mutual inverses, showing they are isomorphisms. The rest is easy Exercise 28 (use X ≃ X^{∘}).

Clearly ∪ is continuous (since it is ⊔); also we have an “empty set”: ∅_{R} =^{def}{⊥} as ∀X ∈ P_{R}(D).{⊥} ⊆ X; also we can define a singleton function {·}_{R}: D → P_{R}(D) by

{d}_{R} =^{def} {d}↓ (corresponding to {x ∈ D | x ⊑ d} = Cl_{R}({d}))

and will often drop the suffix below.

Exercise 29. This exercise develops P_{R}(D) in terms of the basis. Show that for any nonempty sets X, Y: (1) X ≃_{R} X^{∘},

(2) X ≃_{R} Y iff X^{∘} = Y^{∘},

(3) X ⊑_{R} Y iff X^{∘} ⊆ Y^{∘}. Now show that P_{R}(D) is (isomorphic to) ⟨Nonempty ideals of B_{D}, ⊆⟩ with ⊥ = {⊥_{D}}, ⨆ χ = ⋃ χ and finite elements A^{∘} with A a finite nonempty subset of B_{D}.

Now we want to develop a suitable notion of function extension. In fact we can characterise P_{R}(D) as the free ω-complete cpo over D (ω-complete cpo being one with lubs of all countable sets).

Theorem 2. For any ω-complete cpo L and (strict) continuous f: D →_{(⊥)} L there is a unique (strict) additive and continuous f^{†}: P_{R}(D) →_{(S)A} L such that the following diagram commutes:

[figure: P_{R}(D); L; f^{†}; f; D; {·}]

Further (·)^{†}: D →_{(⊥)} L ≅ P_{R}(D) →_{(S)A} L is an isomorphism of partial orders. Proof. Let f: D → L be continuous and supposing g: P_{R}(D) → L is continuous, additive and makes the diagram commute. Then using the ideal characterisation of P_{R}(D) we have

g(X) = g( ⋃_{b∈X}{b})
= ⨆_{b∈X} g({b})  as X is nonempty and countable and g is continuous and additive

= ⨆_{b∈X} f(b).

So g is unique and is strict if f is. Thus defined g is clearly additive and continuous. To see the diagram commutes, we calculate:

g({x}) = g({b ∈ B_{D} | b ⊑ x})

= ⨆_{b⊑x} f(b)

= f(x)  as f is continuous.

Clearly (·)^{†} has inverse λg.g ∘ {·} and both are monotonic showing they are isomorphisms.

For ω-algebraic D, E and F we define the composition of non-deterministic functions as usual: if f: D → P_{R}(E) and g: E → P_{R}(F) then f; g = g^{†} ∘ f. Of course composition is associative continuous and the unit is the singleton function.

We can now note that P_{R} is (easily considered as) a locally ω-continuous functor over ω-ALG. For any f: D → E let P_{R}(f): P_{R}(D) → P_{R}(E) be the unique additive and continuous function such that

[figure: P_{R}(D); P_{R}(E); P_{R}(f); D; E; f; {·}; {·}]

commutes (by Theorem 2).

Exercise 30. Prove that P_{R} is a locally continuous functor which preserves strictness. [Naturally this is all immediate from Theorem 2.]

Hence we can solve domain equations in ω-ALG provided we do not have any function spaces; if we use the consistently complete ω-algebraic cpos we can also allow ourselves function-spaces as well, for since P_{R}(D) is always a complete lattice it cuts down to a functor on the latter category. This concludes the mathematics we need. A few exercises follow.

Exercise 31. Show that D is a closure of P_{R}(D) when D is itself an ω-complete cpo.

Exercise 32. Let D and E be ω-algebraic cpos. A relation between D and E is any R ⊆ B_{D} × B_{E} such that

(1) ∀a ∈ B_{D}.aR⊥,

(2) ∀a, a′ ∈ B_{D}.∀b, b′ ∈ B_{E}.a ⊒ a′Rb′ ⊒ b ⇒ aRb. The collection of such relations is written as Rel(D, E). Show that D→P_{R}(E) ≅ ⟨Rel(D, E), ⊑⟩. How should the composition of relations be defined? What is the identity relation for this composition? Reformulate this exercise in terms of relations R ⊆ D × E.

Exercise 33 Duality. Show that (D → P_{R}(E)) ≅ O(E) →_{STA} O(D) the partial order of strict, toppreserving, additive, continuous functions from O(E) to O(D) (here O(D), O(E) are the ω-algebraic complete lattices of the open subsets of D, resp. E ordered by subset (recall O(D) ≅ D → O 0 etc.). The isomorphism is Λ where

Λ(m)(V) = {d ∈ D | m(d) ∩ V ≠ ∅}.

Show that the strict functions from D to P_{R}(E) correspond under Λ to those g which reflect ⊤ (i.e. for all open V, g(V) = D implies V = E).

Establish the following equalities (the first two showing that Λ is a duality of categories):

(1) Λ({·}) = id,

(2) Λ(f; g) = Λ(f) ∘ Λ(g),

(3) Λ(f ∪ g) = Λ(f) ∪ Λ(g) (with the evident pointwise definitions).

For any m: D → P_{R}(E) and Scott-closed B ⊆ E define the weakest liberal precondition wlp(m, B) by:

wlp(m, B) = {d ∈ D | m(d) ⊆ B}.

How does wlp relate to Λ? Conclude that D→P_{R}(E) is isomorphic to the collection of strict ⊥-reflecting, ⊤- preserving, multiplicative, dual continuous maps from C(E) to C(D) (where C(D), C(E) are the partial orders of the Scott-closed subsets of D resp. E partially ordered by subset). Specialise this to a correspondence between D →_{⊥} P_{R}(E) and certain maps from P_{R}(E) to P_{R}(D).

Exercise 34. Extend Exercise 8 to general relational powerdomains.

Exercise 35. Let P ⊆ P_{R}(D) be ω-inductive. Show the following rule is valid:

\frac{∀d ∈ D.P(\{d\}) ∀X, Y ∈ P_{R}(D).P(X) ∧ P(Y) ⊃ P(X ∪ Y)}{∀X.P(X)}.

Exercise 36. Let P ⊆ D be ω-inductive. Show that an ω-inductive Q ⊆ P_{R}(D) can be defined by: Q(X) iff X ⊆ P. Show that Q(X) iff ∃d.X = Cl_{R}({d}) is ω-inductive. What about ∃d, d′.X = Cl_{R}({d, d′})?

Exercise 37. Show that if D is effectively given so is P_{R}(D) and the index of P_{R}(D) is effectively obtainable from that of D. Show that ∪: P_{R}(D)^{2} → P_{R}(D) is computable. Show that {·}: D → P_{R}(D) is computable. Show that if f: D → P_{R}(E) is computable (where E is also effectively given) then f^{†}: P_{R}(D) → P_{R}(E) is computable, an index for it being effectively obtainable from one for f. Conclude that P_{R} is computable.

Denotational Semantics

We consider languages where there are several processes sharing a common store. Later in the chapter we shall have a look at languages where processes communicate with each other along logical channels (lines, through ports, by broadcasting, etc.) and each has its own local store. A basic language is supplied by the grammar:

c ::= a | skip | c; c | if b then c else c | while b do c | c∥c

where atomic commands and Boolean expressions are as usual and we shall feel free to give specific examples without formal definition. The important construction c_{1}∥c_{2} conceived of as the concurrent execution of c_{1} and c_{2}. So c_{1}∥ ⋯ ∥c_{n} corresponds to Dijkstra’s parbegin c_{1}; ⋯; c_{n} parend.

When there is no interference between concurrent processes (perhaps achieved by additional syntactic constraints) there is a legitimate semantics of type C: Com → (S → P_{R}(S_{⊥})) with crucial clause:

C[[c_{1}∥c_{2}]] = (C[[c_{1}]]; C[[c_{2}]]) ∪ (C[[c_{2}]]; C[[c_{1}]]).

But this is not valid when there is interference. For example take S = N, c_{1} = skip, c_{2} = (x := 1), c_{3} = (c := x + 1; x := x − 1). Then C[[c_{1}∥c_{2}]](2) should be {1} whereas (assuming programs interruptible between but not during assignments) C[[c_{3}∥c_{2}]](2) should be {0, 1}. But these are different, C[[c_{1}]] and C[[c_{3}]] should be the same and so there can be no semantics of the form

C[[c_{1}∥c_{2}]] = φ(C[[c_{1}]], C[[c_{2}]]).

To get over this problem we have to account for the phenomenon of interruption. Stating c in σ we can reach in interruption point with an intermediate state σ′ and some more program to execute when control returns after the interruption. Of course we can also terminate with a final state and since c itself could be of the form c_{1}∥c_{2} several of each of these possibilities could occur. Let r be the meaning of c. Then r(σ) should be a set of things either states σ′ of pairs ⟨σ′, r′⟩ where σ′ is the interruption state and r′ is the meaning of the program remaining to execute. Thus we introduce R as a cpo of resumption given by the domain equations

R ≅ S_{⊥} →_{⊥} P_{R}(S_{⊥} + (S_{⊥} ⊗ R_{⊥})).

In fact this idea (and variations) is all that we need for the semantics of concurrency. It was introduced in a complicated form by Milner in

A. J. R. G. Milner. Processes: A Mathematical Model of Computing Agents, Logic Colloquium ’73. North Holland.

and independently by Bekic in H. Bekic. Towards a Mathematical Theory of Processes. Technical Report TR25.125, IBM Laboratory Vienna, 1971.

Powerdomains were not available in that paper (as a substitute for P_{R}(D) one used (O → D) where O is a suitable cpo of oracles e.g. Tapes or N^{ω}). In

G. D. Plotkin. A Powerdomain Construction, SIAM J. Comput. Vol. 5, No. 3, 1976 the present form was introduced and it was applied to a language for communicating processes in

G. Milne and A. J. R. G. Milner. Concurrent Processes and Their Syntax. JACM 1977.

Every resumption can be flattened to produce its corresponding state transformation. To define this we introduce a very handy notation which makes this and other definitions quite transparent. Let e_{1} be an expression of type P_{R}(S_{⊥} + (S_{⊥} ⊗ R_{⊥})) and let e_{2}[σ′] be an expression of type D (possibly with an occurrence of σ′, a variable of type S_{⊥}) and let e_{3}[σ′, r′] be another expression of type D (possibly with free occurrences of variables σ′, r′ of types S_{⊥} and R respectively). Then

cases e_{1}
first σ′.e_{2}[σ′]
second σ′, r′.e_{3}[σ′, r′]

is an expression of type D which means the same as:

[λ_{⊥}σ′.e_{2}[σ′], λ_{⊥}σ′, x.lift(λr′.e_{3}[σ′, r′])(x)]^{†}(e_{1}).

Now we may recursively define a flattening combinator | · |: R → (S_{⊥} → P(S)) by

|r|(σ) =cases r(σ)
first σ′.{σ′}
second σ′, r′.|r′|(σ′).

Exercise 38. Note that the cases construction is strict and linear in its first argument. Establish these two identities (where we have omitted some injection functions) where σ′ ∈ S, r′ ∈ R,

(1) cases {inl(σ′)} first σ′.e_{2} second σ, r′.e_{3} = e_{2},

(2) cases {inr(⟨σ′, up(r′)⟩)} first σ′.e_{2} second σ′, r′.e_{3} = e_{3}.

Now only one or two more combinators are needed.

Composition. We define ∗: R^{2} → R by

r_{1} ∗ r_{2}(σ) =cases r_{1}(σ)
first σ′.{inr(σ′ ⊗ up(r_{2}))}
second σ′, r′_{1}.{inr(σ′ ⊗ up(r′_{1} ∗ r_{2}))}.

Parallelism. We define ∥: R^{2} → R by

r_{1}∥r_{2}(σ) =cases r_{1}(σ)
first σ′.{inr(σ′ ⊗ up(r_{2}))}
second σ′, r′_{1}.{inr(σ′ ⊗ up(r′_{1}∥r_{2}))}
∪
cases r_{2}(σ)
first σ′.{inr(σ′ ⊗ up(r_{1}))}
second σ′, r′_{2}.{inr(σ′ ⊗ up(r_{1}∥r′_{2}))}.

Exercise 39. This parallel operator is one where “r_{1}∥r_{2} terminates when r_{1} and r_{2} do”; write one which terminates when one does.

Exercise 40. Establish whether ∗ is associative with identity λ_{⊥}σ.{inl(σ)} and whether ∥ is associative and commutative.

\underline{Semantics}. R: Com → R is defined by

R[[a]] = λ_{⊥}σ.{inl(A[[a]](σ))};

R[[skip]] = λ_{⊥}σ.{inl(σ)};

R[[c_{1}; c_{2}]] = R[[c_{1}]] ∗ R[[c_{2}]];

R[[if b then c_{1} else c_{2}]] = λ_{⊥}σ.if B[[b]](σ) then {inr(σ ⊗ up(R[[c_{1}]]))} else {inr(σ ⊗ up(R[[c_{2}]]))}; R[[while b do c]] = μr.λ_{⊥}σ.if B[[b]](σ) then {inr(σ ⊗ up(R[[c]] ∗ r))} else {inr(σ ⊗ up(λ_{⊥}σ.{inl(σ)}))}; R[[c_{1}∥c_{2}]] = R[[c_{1}]]∥R[[c_{2}]].

Exercise 41. In the semantics of conditional and while-loops there is an interruption point between the evaluation of the Boolean expression and the body. Give a semantics where no such point exists (essentially the so-called test and set idea).

Exercise 42. Give a semantics of the construct critical-section(c) (alternative syntax: [c]) which is c but with no interruption points.

Exercise 43. Give a semantics of assignment statements where there is an interruption point between the evaluation of the right-hand-side of an assignment and the updating of the variable.

Suppose atomic commands are assignments x := e where the class of expressions is, say, e ::= 0 | 1 | e + e | e ∗ e | · · ·. Give a semantics where expressions can be interrupted at any point during their evaluation. You may find it useful to use expression resumptions defined by

E ≅ S_{⊥} →_{⊥} P_{R}((N_{⊥} ⊗ S_{⊥}) + (S_{⊥} ⊗ E_{⊥})).

This exercise can be taken quite far by allowing recursive functions to be defined as in: letrec f(x) = e in e or commands in expressions as in begin c result e.

Synchronisation Methods

We consider these via some exercises.

Exercise 44. The when construct is b ⇒ c (alternative concrete syntax is: when b do c or await b; c). The idea is that b ⇒ c cannot execute unless b is true. Give this a semantics using as resumptions:

R ≅ S_{⊥} →_{⊥} P_{R}(S_{⊥} + S_{⊥} ⊗ R_{⊥})

the idea being that r(σ) = ∅_{R} corresponds to r’s “not being able to execute” i.e. deadlock. Your semantics should be such that the first interruption point of b ⇒ c is the first interruption point of c. (If it were instead just after b or just after c that would then corresponding to the semantics of b ⇒ skip; c and b ⇒ [c] (equivalently [b ⇒ c]; give alternative semantics for these two properties and establish the correspondence).

Add the operator c_{1}[]c_{2} which can execute just when c_{1} or c_{2} can.

Consider allowing interruption points during the execution of the conditional.

Exercise 45 Semaphores. Let SId be a finite set of semaphore identifiers ranged over by v; they will be integer semaphores. We introduce the commands P (v) (alternate syntax; Wait(v), Grab(v)) and V (v) (alternate syntax: Signal(v), Release(v)). In terms of the when construct — see previous exercise — P (v) means v > 0 ⇒ v := v − 1 and V (v) means v := v + 1 where the assignments are uninterruptible.

Give a resumption semantics, using resumptions:

R ≅ States →_{⊥} P_{R}(States + States ⊗ R_{⊥})

with the same idea as in the previous exercise but where

States = S_{⊥} × (Sid_{⊥} →_{⊥} N_{⊥} ⊗ T).

The point of the truth-values is to show whether the semaphore is busy or not. As the separation of identifiers is becoming clumsy, you might want to consider allowing only one set of identifiers but introduce a suitable declaration mechanism for variables and semaphores.

Exercise 46 I/O Devices. Add the construct print e where e is an arithmetic expression. As a resumption model you could take:

R ≅ S_{⊥} →_{⊥} P_{R}(S_{⊥} + N_{⊥} ⊗ R_{⊥} + S_{⊥} ⊗ R_{⊥}).

Define a suitable flattening function | · |: R → NS where NS is the domain of finite sequences of integers, given by the domain equation:

NS ≅ N_{⊥} + N_{⊥} ⊗ NS_{⊥}.

This clearly continues the ideas of Chapter 5, Example 4 allowing infinitely proceeding output and showing the connection between the present resumptions and those considered there. Adapt the ideas of that example to allow a read command. Extend all this to more sophisticated I/O devices. You may find points of contact with the semantics of communicating processes.

Exercise 47 Parallel For-Loops. Invent such a concept and give its semantics.

Exercise 48 Critical Regions. The idea here is to have “structured semaphores”. Each variable has attached to it a binary semaphore and the new syntactic construct is with x do c which means P (v); c; V (v) where v is the binary semaphore, and so there are no explicit semaphore. Give this a semantics. Strictly speaking there should also be a static semantics so that:

(1) There is no use of variables except inside with statements. The point of this is to ensure that processes obey the semaphores discipline of not accessing resources until they are owned by the process.

(2) No two parallel processes have common variables with left-hand-side occurrences. This ensures resources are uniquely allocated to processes at any one time (though the allocation can change as with statements are entered and exited).

Give such a static semantics (see Mike Gordon’s book for hints on how to do that).

Add when statements to your language and semantics. This allows the explanation of some well-known constructs. For example

with r when b do c  means  with r do (b ⇒ c)
region r do  means  with r do
begin … await b; c … end  … (b ⇒ c) …
with r do (b_{0} ⇒ c_{0}[] ⋯ []b_{n} ⇒ c_{n})

Exercise 49. This is a fairly substantial exercise, perhaps more of a mini-project. We think of a monitor as a class treated as a resource and you should begin by ignoring the parallel features and just find a semantics of classes.

\underline{Syntax}. \underline{Ground Types}. These are gt ∈ \{int, bool\}.

\underline{Types}. These are t ∈ Types = \{int, bool, proc int, proc bool\} for integer or boolean variables and call-by-value procedures with one argument being either integers or booleans.

\underline{Monitor Types}. These are mt ∈ MTypes = Id →_{fin} Types =^{def} ∑_{X:a finite subset of Id} X → Types.

\underline{Declarations}. These are d ∈ Dec where

d ::= var x: gt | proc x: gt; c | d within d | d; d | d init c | monitor m: mt d

For d within d and d; d see Mike Gordon’s book pp. 80, 135. The initialisation construct d init c is elaborated by elaborating d and then executing c (for initialisation purposes). Private declarations and initialisation are useful within monitor declarations.

\underline{Commands}.

c ::= (usual stuff) | c∥c | b ⇒ c | c [] c | d; c | p(e) | with m do c.

In the static semantics monitors are treated as resources so that any call of a monitor procedure or reference to a variable must be inside an appropriate with statement and also no concurrent access to such monitor resources is permitted.

Communicating Processes

Consider the following where α, β, γ range over a finite set Lab of communication channels

c ::= a | skip | α?x | α!e | c; c | if b then c else c | while b do c | c∥c | c\α | c[α/β] | c [] c

(there should be some static semantics to ensure concurrent processes do not use common variables). Here α?x means: input a value off α and update x to it and α!e means evaluate e and send the result along α. Let us look for a semantics where we intend synchronised communication so that the only communication actions are an uninterruptible sending and then receiving; c\α is c less the capability of communicating on α and c[α/β] is c but with the capabilities of communication over α transferred to β. See, for example

C. A. R. Hoare. Communicating Sequential Processes. CACM Vol. 21(8), pp. 666–677, 1978.

A. J. R. G. Milner. A Calculus of Communicating Systems, LNCS Vol. 92, 1980.

H. Ledgard. ADA: An Introduction. Springer-Verlag.

We take

R ≅ S_{⊥} →_{⊥} P_{R}(S_{⊥} + Lab_{⊥} ⊗ (N_{⊥} →_{⊥} S_{⊥} ⊗ R_{⊥})_{⊥} + Lab_{⊥} ⊗ N_{⊥} ⊗ R_{⊥} + S_{⊥} ⊗ R_{⊥}).

The Parallel Combinator

r_{1}∥r_{2}(σ) =cases r_{1}(σ)

first σ′.{in_{3}(σ′ ⊗ up(r_{2}))} second α, f.{in_{1}(α ⊗ up(λ_{⊥}n.f(n)_{1} ⊗ up(f(n)_{2}∥r_{2})))} third α, n, r′_{1}.{in_{2}(α ⊗ n ⊗ (up(r′_{1}∥r_{2})))} fourth σ′, r′_{1}.{in_{3}(σ′ ⊗ up(r′_{1}∥r_{2}))}

∪ cases r_{1}(σ)

first σ′.∅ second α, f.

cases r_{2}(σ) first σ′.∅ second β, g.∅ third β, n′, r′_{2}.

if α = β
then {in_{3}(f(n)_{1} ⊗ up(f(n)_{2}∥r′_{2}))}
else ∅

fourth σ′, r′_{2}.∅ third α, n, r′_{1}.

cases.r_{2}(σ) first σ′.∅ second β, f.

if α = β
then {in_{3}(f(n)_{1} ⊗ up(r′_{1}∥f(n)_{2}))}
else ∅

third β, n′, r′_{2}.∅ forth σ′, r′_{2}.∅

fourth σ′, r′_{1}.∅

∪ cases r_{2}(σ)

first σ′.{in_{3}(σ′ ⊗ up(r_{1}))} second α, f.{in_{1}(α ⊗ up(λ_{⊥}n.f(n)_{1} ⊗ up(r_{1}∥f(n)_{2})))} third α, n, r′_{2}.{in_{2}(α ⊗ n ⊗ up(r_{1}∥r′_{2}))} fourth σ′, r′_{2}.{in_{3}(σ′ ⊗ up(r_{1}∥r′_{2}))}.

The notation is now become barbaric! Exercise 50. Rewrite the above definition, without using the empty set. The Elision Combinator

r\α(σ) =cases r(σ)

first σ′.{in_{0}(σ′)} second β, f. if α = β then ∅ else {in_{1}(β ⊗ up(λ_{⊥}n.f(n)_{1} ⊗ up(f(n)_{2}\α)))} third β, n, r′.if α = β then ∅ else {in_{2}(β ⊗ n ⊗ up(r′\α))} fourth σ′, r′.{in_{3}(σ′ ⊗ up(r′\α))}.

It is here that the empty set is really needed.

The Substitution Combinator

r[α/β](σ) =cases r(σ)
first σ.{in_{0}(σ′)}
second γ, f.
if γ = β
then {in_{1}(α ⊗ up(λ_{⊥}n.f(n)_{1} ⊗ up(f(n)_{2}[α/β])))}
else {in_{1}(γ ⊗ up(f))}
third γ, n, r′.
if γ = β
then {in_{2}(α ⊗ n ⊗ up(r′[α/β]))}
else {in_{2}(γ ⊗ n ⊗ up(r′[α/β]))}
fourth σ, r′.{in_{3}(σ′ ⊗ up(r′[α/β]))}.

All the semantics R: Com → R is now obvious but for these two clauses (perhaps):

R[[α?x]](σ) = {in_{1}(α ⊗ up(λ_{⊥}n.σ[x = n] ⊗ up(λ_{⊥}σ.{in_{0}(σ)})))};
R[[α!e]](σ) = {in_{2}(α ⊗ E[[e]](σ) ⊗ up(λ_{⊥}σ.{in_{0}(σ)}))}.

Exercise 51. The same language can be used for other communication disciplines. For example the acts of inputting and outputting can be completely independent. Give this idea a semantics using as resumptions

R ≅ States_{⊥} →_{⊥} P_{R}(States_{⊥} + States_{⊥} ⊗ R_{⊥})

where States = S_{⊥} × (Lab_{⊥} →_{⊥} N_{⊥}).

Adapt this idea to the case where the channels are actually buffers holding sequences of integers.

Exercise 52. The above language is a mixture of those employed by Hoare and Milner. Give a semantics to Hoare’s CSP as in the CACM paper, but (at least at first) without his termination conventions. You may find it helpful to look for a denotational version of

G. D. Plotkin. An Operational Semantics for CSP. IFIP WG 2.2 Working Conference, Garmisch, 1982.

Exercise 53. Give a semantics to Milner’s CCS which is an applicative version of the above concurrent language:

t ::=nil | t + t | α?x.t | α!e.t | if b then t else t | let x be e in t | let … |
P | let P be t in t | letrec P be t in t | … | t|t | t\α | t[α/β].

The meaning of something is its set of communication capabilities, e.g. nil means ∅, having none. Give a semantics using:

R ≅ P_{R}(Lab_{⊥} ⊗ N_{⊥} ⊗ R_{⊥} + Lab_{⊥} ⊗ (N_{⊥} →_{⊥} R)_{⊥}).

Exercise 54. This is a mini-project. Formulate a version of Hewitt’s actors language and find a resumptionbased semantics.

As an exercise along these lines, take the language of Exercise 51 and think of α a “port in the ether”. Then α!e means send the value of e to α through the ether and α?e means take a value from the port α. One way to do this is to use

States = S_{⊥} × (Lab_{⊥} →_{⊥} M(N)_{⊥})

where M(N) is the set of finite multisets of integers.

General Powerdomains: The Plotkin Powerdomain

We now try to construct a powerdomain of an arbitrary ω-algebraic cpo D generalising the Egli-Milner approach in the discrete case. As a typical example we can take D = Tapes, the set of finite strings of 0’s and 1’s under the subsequence ordering. To see this in a computational setting we add a print instruction to our language:

c ::= print t

(where t ranges over {0, 1}) and desire a semantics such that C[[c]](σ) is the set of tapes that might be output. Here are some example programs:

(5) (print 0; loop) or (print 000; loop),

(6) (print 0; loop) or (print 00; loop) or (print 000; loop),

(7) alarm := “off”; (while alarm = “off” do x := x + 1 or alarm := “on”); (while x > 0 do print 0; x := x − 1); (while true do print 1),

(8) (while true do print 0) or (7).

Clearly (from an operational point of view) we expect (5), (6), (7), (8) to output the following sets

\begin{aligned}A_{5} & = \{0, 000\} = \{0\} ∪ \{000\}, \\ A_{6} & = \{0, 00, 000\} = \{0\} ∪ \{00\} ∪ \{000\}, \\ A_{7} & = \{⊥\} ∪ \{0^{n}1^{ω} | n ≥ 0\}, \\ A_{8} & = \{⊥\} ∪ \{0^{n}1^{ω} | n ≥ 0\} ∪ \{0^{ω}\}. \end{aligned}

So we may expect that (5) ≠ (6) and (7) ≠ (8) in the anticipated semantics. But this is not so: we will have both (5) = (6) (and A_{5} “=” A_{6}) and (7) = (8) (and A_{7} “=” A_{8}) and we can show: these identifications cannot be avoided in our present framework of cpos and continuous functions (under a few reasonable assumptions). The latter identification is particularly upsetting: A_{7} is a set of sequences which are guaranteed to contain a 1 if they contain a 0 but A_{8} is not such a set.

Investigating these points will lead us to an algebraic characterisation of powerdomains, generalising Facts 1, 2 above. It will be very easy using the completion ideas of Chapter 6 to show that such powerdomains exist. Unfortunately this does not give us much insight since under this presentation the powerdomains are not given as collections of sets. In order to do that we have to proceed in analogy with development of the Egli-Milner order considering what subsets we expect and how to order them.

Now what a powerdomain P of an ω-algebraic cpo D should supply us with is a binary union function: ∪: P^{2} → P and a singleton function {·}: D → P; what is more this data should be the universal such data in order to get an analogue of Fact 2 and Theorem 2 allowing us (for one thing!) to compose nondeterministic functions f: D → P. Let us turn these ideas into definitions.

Definition 7. A semilattice is a structure ⟨P, ∪⟩ where ∪: P^{2} → P is a binary function satisfying the following three axioms:

Associativity  ∀a, b, c ∈ P.a ∪ (b ∪ c) = (a ∪ b) ∪ c.
Commutativity  ∀a, b ∈ P.a ∪ b = b ∪ a.
Absorption  ∀a ∈ P.a ∪ a = a.

A function f: P → Q between semilattice is linear iff for all a, b in P we have f(a ∪ b) = f(a) ∪ f(b). A structure ⟨P, ⊑, ∪⟩ is a continuous semilattice iff ⟨P, ⊑⟩ is a cpo, ⟨P, ∪⟩ is a semilattice and ∪ is continuous (w.r.t. the ordering ⊑).

Exercise 55. Let P be a semilattice and define a relation by x ⊆ y iff x ∪ y = y. Show ⊆ is a partial order with lubs of pairs given by ∪; this gives 1-1 correspondence between semilattices and partial orders with lubs of pairs. Assuming P is a continuous semilattice show that ⊆ is ω-inductive.

Exercise 56. Show that the ω-complete cpos are exactly the continuous semilattices such that for all x, y

x ∪ y = x ⊔ y

and these are the continuous semilattices such that for all x, y

x ⊑ x ∪ y

and these are the same as the continuous semilattices such that for all x, y

x ⊆ y ⇒ x ⊑ y

and these are the same as the continuous semilattices such that for all x, y equivalence: x ⊆ y ⇔ x ⊑ y.

Also the additive, continuous f: D → E between ω-complete cpos are just linear, continuous f: D → E when D and E are viewed as these kinds of semilattice. One can then reinterpret Theorem 2 as saying that P_{R}(D) is just the free continuous semilattice over D where subset and approximation agree.

So a powerdomain of D should give us a map D →^{{·}} P with P a continuous semilattice and we will look for the universal one. Before doing so let us see why the above identifications of sets can be expected to hold. Let D →^{{·}} ⟨P, ∪⟩ be as expected with D = Tapes. Then we expect that the elements in P corresponding to A_{5} and A_{6} are {0} ∪ {000} and {0} ∪ {00} ∪ {000} respectively and calculate:

{0} ∪ {000} = ({0} ∪ {0}) ∪ {000} (by absorption)
⊑ ({0} ∪ {00}) ∪ {000}  since 0 ⊑ 00 and {·} is monotonic
⊑ ({0} ∪ {000}) ∪ {000}  same reason
= {0} ∪ {000}  by associativity and absorption.

Thus {0} ∪ {000} = {0} ∪ {00} ∪ {000} in any reasonable powerdomain (this is what was meant by A_{5} “=” A_{6}).

Turning to the second pair of sets, let A and B be the elements of P corresponding to A_{7} and A_{8}. We expect that B = A ∪ {0^{ω}} and A = A ∪ {⊥} ∪ {0^{n}1^{ω}} (any n). It follows from the second of these that A = A ∪ {0^{n}} (any n) — by a similar argument to the above that A_{5} = A_{6}. But then

B = A ∪ {0^{ω}}
= A ∪ ⨆_{n}{0^{n}}  {·} is continuous
= ⨆_{n}(A ∪ {0^{n}})  as union is continuous
= A.

Thus it seems that these identifications cannot be avoided in the framework of cpos and continuous functions; we hope later to sweeten this bitter pill. In his thesis Lehman suggested replacing partial orders by categories; how best to do this remains an interesting open problem.

Now we give a quick construction of the powerdomain. For any D put

F(D) =^{def} ⟨{A ⊆ B_{D} | A is finite and nonempty}, ⊑_{EM}⟩.

That is F(D) is the collection of finite nonempty sets of finite elements of D under the Egli-Milner ordering. As such it is a preorder (not, in general, a partial order) with a least element {⊥}. Following Chapter 6 we put

P(D) =^{def} \overline{F(D)}

and define D →^{{·}_{P}} P(D) by

{d}_{P} = {{b_{1}, …, b_{n}} | n > 0 and b_{i} ∈ B_{D} ∧ b_{i} ⊑ d, for i = 1, n}

and define the union function by

I ∪_{P} J = {A ∪ B | A ∈ I, B ∈ J}

Exercise 57. Verify that {·}_{P} and ∪_{P} are well-defined and continuous; check that {b}_{P} = [{b}] for b in B_{D} and [A] ∪_{P} [B] = [A ∪ B] for A, B in F(D).

The simple definition of union makes it clear that ⟨P(D), ∪_{P}⟩ is a semilattice; we shall drop the subscripts when clear from the context.

Theorem 3. P(D) is an ω-algebraic cpo which with ∪ is a continuous semilattice. Further {·}: D → P(D) is a (strict) continuous function which is universal in that if f: D → P is any (strict) continuous function to a continuous semilattice there is a unique linear (strict) continuous function f^{†}: P(D) → P such that the following diagram commutes

[figure: P(D); P; f^{†}; f; D; {·}_{P}]

Further † is an isomorphism between the continuous semilattice of the (strict) continuous functions from D to P and the continuous semilattice of the linear (strict) continuous function from P(D) to P (where the unions of the functions are defined pointwise). Proof. By construction P(D) = \overline{F(D)} is ω-algebraic and we know it is a continuous semilattice. We know the singleton function is continuous; to see it is strict note that {⊥_{D}} = [{⊥}] = [⊥_{F(D)}] = ⊥_{P(D)}.

Next suppose f: D → P is a (strict) continuous linear function from D to a continuous semilattice P. Since f^{†} is continuous it is enough to show it is determined on the finite elements of P(D) in order to demonstrate uniqueness. So let us calculate:

f^{†}([{b_{1}, …, b_{n}}]) = f^{†}([{b_{1}}] ∪_{P} ⋯ ∪_{P} [{b_{n}}])
= f^{†}({b_{1}}_{P} ∪_{P} ⋯ ∪_{P} {b_{n}}_{P})
= f^{†}({b_{1}}_{P}) ∪ ⋯ ∪ f^{†}({b_{n}}_{P})  as f^{†} is linear
= f(b_{1}) ∪ ⋯ ∪ f(b_{n})  as the diagram commutes.

Conversely define g: F(D) → P by:

g({b_{1}, …, b_{n}}) = f(b_{1}) ∪ ⋯ ∪ f(b_{n}).

This is monotonic, for if A ⊑_{EM} B then we can write A = {a_{1}, …, a_{n}} and B = {b_{1}, …, b_{n}} with a_{i} ⊑ b_{i} (i = 1, n) making it evident that g(A) ⊑ g(B). Now let f^{†} be the unique continuous extension of g to P(D). Since it is continuous we can check the above diagram commutes by looking only at the finite elements of D:

f^{†}({b}_{P}) = f^{†}([{b}]) = g({b}) = f(b).

(If f is strict this shows that f^{†}(⊥) = f^{†}({⊥}_{P}) = f(⊥) = ⊥ and so f^{†} is too.) It only remains to check that f^{†} is linear and by continuity it is enough to check that for the finite elements of P(D) and we note:

f^{†}([A] ∪_{P} [B]) = f^{†}([A ∪ B])

= ⋃_{a∈A} g(a) ∪ ⋃_{b∈B} g(b)

= g(A) ∪ g(B)

= f^{†}([A]) ∪ f^{†}([B]).

To complete the proof we note that (·)^{†} is monotonic, as if f ⊑ f′ then g ⊑ g′ (using an evident notation and so f^{†} ⊑ f′^{†}. It therefore follows as per Fact 1 that (·)^{†} is an isomorphism of partial orders with inverse. H = λh.h ∘ {·}_{P}. Note that H is linear:

H(h ∪ h′) = (h ∪ h′) ∘ {·}_{P}

= λd ∈ D.h ∪ h′({d}_{P}) = λd.h({d}_{P}) ∪ h′({d}_{P}) = H(h) ∪ H(h′).

It follows that † is linear:

(f ∪ f′)^{†} = (H(f^{†}) ∪ H(f′^{†}))^{†}
= H(f^{†} ∪ f′^{†})^{†}
= f^{†} ∪ f′^{†}

(and it is clear that strictness is also preserved).

The import of this theorem is that powerdomains conceived of as free continuous algebras always exist. They are built by making a free monotonic algebra (here F(D)/⊑_{EM} which is F(D), modulo ⊑_{EM}) and completing it to get the free continuous one. This is a very simple procedure and can be applied to any collection of equations and even inequations. Later on we shall take advantage of the idea to construct various other flavours of powerdomains. This by no means makes use of all the possibilities available and we do not really know what scope they have.

Exercise 58. Show that for f: D → P(E) the extension f^{†}: P(D) → P(E) is given by the formula:

f^{†}(I) = ⋃_{A∈I} ⋃_{a∈A} f(a).

It is easy to see that P is a locally continuous covariant functor on ω-ALG. It is already defined on objects and for morphisms f: D → E we define

P(f) = ({·}_{E} ∘ f)^{†}

as with the relational powerdomain.

Exercise 59. Show this does define a locally continuous functor. Find a formula for P(f).

It follows that we can solve domain equations in ω-ALG using +, ×, (·)_{⊥}, ⊗, P (just repeat the developments of Chapter 4 and 5 but in ω-ALG using the information given in Chapter 6). And with a little effort (using SFP) in ω-ALG we can add in → and →_{⊥}. For we know that SFP is closed under +, ×, (·)_{⊥}, ⊗, → and →_{⊥}. To see that it is closed under P we note that the above construction shows P(D) finite when D is. Therefore if D is an SFP object we can write D = lim_{→}⟨D_{n}, f_{n}⟩ in CPO^{E} and so in ω-ALG^{E} with the D_{n} finite and so P(D) = lim_{→}⟨P(D_{n}), P(f_{n})⟩ in ω-ALG^{E} (and hence CPO^{E}) with the P(D_{n}) finite, using the local continuity of P, by analogy with Chapter 4. This shows SFP closed under P and we can solve all our domain equations in SFP (again repeating Chapter 4/5 in SFP and using the information on SFP given in Chapter 6).

Exercise 60. The above discussion uses the fact that if all the D_{n} are ω-algebraic then D = lim_{→}⟨D_{n}, f_{n}⟩ in CPO^{E} iff D = lim_{→}⟨D_{n}, f_{n}⟩ in ω-ALG^{E}. Prove this.

Exercise 61. Prove directly using the minimal upper bound characterisation of SFP objects given in Chapter 6 p. 69 that P(D) is in SFP object if D is.

We now turn to the question of what P(D) looks like considered as a family of subsets of D. As before we need to see what sets we want and how to order them. We will then have to check that the resulting structure is isomorphic to P(D) as defined above.

Finitely Generable Sets

If we write down the execution tree of program (7) above we arrive at the following

[figure: ⋯; 1; 1; ⋮; 0; 1; 1; ⋮; 0; 0; 1; 1; ⋮]

where we have only indicated the effects of the print instructions. Thus A_{7} is obtained as the sequence of what is printed out along the branches. As a slight reformulation we might instead write what has been printed so far at a node

[figure: ⋯; ⊥; 1; 11; ⋮; ⊥; 0; 01; 011; ⋮; ⊥; 0; 00; 001; 0011; ⋮]

and then A_{7} is obtained as the lubs along the branches. We have here to deal with finitely branching trees. A generating finitarily branching tree is a finitarily branching tree with nodes labelled by elements of D so that the closer a node is to the root the smaller is its label. Every complete branch generates the lub of the labels of its nodes and the tree generates the set of elements of D generated by its nodes. What we do is take (the finite elements) of Tapes as our canonical finitarily branching tree.

Definition 8. Let D be an ω-algebraic cpo. A subset X of D is finitely generable (fg) iff there is a continuous function f: Tapes → D such that X = Bd(f) where the boundary of f is given by

Bd(f) = {f(w) | |w| = ω}

(that is it is the set of values of f on infinite tapes). We write F_{g}(D) for the collection of fg subsets of D.

Exercise 62. Show every finite nonempty set is finitely generable. Show that union of two fg sets is fg. Show that if f: D → E is continuous and X ⊆ D is fg then so is f(X). Show that {0^{ω}} ∪ {0^{n}1^{ω}} is fg.; show that {0^{n}1^{ω}} is not fg (and neither is N as a subset of N_{⊥}). How many fg subsets of D are there? Show that fg sets are not closed under intersection, complementation, infinite union or inverse functions (the last meaning that if Y ⊆ E is fg then f^{−1}(Y) need not be with f continuous).

Exercise 63. Show that a set is fg iff it is generated by a finitely branching generating tree.

Lemma 3. If X ⊆ D is finitely generable then it is Bd(f) for some f such that f(w) is finite when w is. Proof. Let X = Bd(g). Let b_{0}, b_{1}, … enumerate B_{D}. Define f by putting f(⊥) = ⊥ and for w ∈ B_{Tapes}, t ∈ {0, 1}

f(w ⌢ t) = the first b_{n} greater than f(w) and b_{n} ⊑ g(w ⌢ t) and b_{j} ⊑ b_{n} (s.t. ∀j ≤ |w|.b_{j} ⊑ g(w ⌢ t)).

Note that f(w) is well-defined and less than g(w) (for finite w). Then f is monotonic on finite tapes and so is uniquely extended to a continuous function on Tapes. Clearly, then, f ⊑ g. The converse is left as Exercise 64.

How to Order Our Sets

Let us denote by ∼ ⊑ the order we are looking for on subsets of any given ω-algebraic D. We expect that this contains ⊑_{EM} but know from the above that since A_{8} ⊑_{EM} A_{7} it cannot be identical with it.

Exercise 65. It would have been natural to take the collection of the fg sets of D with the natural singleton and union functions and preordered by ⊑_{EM} and then divide out by the induced equivalence to get a candidate powerdomain. But we know from the above investigation that something must go wrong even with D = Tapes: either we don’t get a cpo or singleton or union is not continuous. Which of these happens?

Exercise 66. Show that if f: D → E is continuous and for two subsets X and Y of D we have X ⊑_{EM} Y then f(X) ⊑_{EM} f(Y).

Following the last exercise it seems natural that ∼ ⊑ should be preserved by continuous functions and since it should be ⊑_{EM} on discrete cpos we expect that if we define for all subsets of D

X ∼ ⊑_{EM} Y iff ∀f: D → O 0 .f(X) ⊑_{EM} f(Y)

(and let ≃_{EM} be the associated equivalence) then X ∼ ⊑ Y implies X ∼ ⊑_{EM} Y. Thus we have: ⊑_{EM} ⊆ ∼ ⊑ ⊆ ∼ ⊑_{EM}. One can think of f^{∗}: D → O 0 as an experiment on D.

Exercise 67. Show that for any continuous f: D → P(X_{⊥}) with X countable we have: X ∼ ⊑_{EM} Y implies ⋃ f(X) ⊑_{EM} ⋃ f(Y).

We now study ∼ ⊑_{EM} with a view to arguing that it should be our choice of ∼ ⊑.

Theorem 4. Let D be an ω-algebraic cpo. Let X and Y be subsets of D and consider the following conditions.

(1) X ⊑_{EM} Y,

(2) X ∼ ⊑_{EM} Y,

(3) ∀x ∈ X.∀b ∈ B_{D}.(b ⊑ x ⇒ ∃y ∈ Y.b ⊑ y) ∧ ∀y ∈ Y.∃x ∈ X.x ⊑ y,

(4) ∀A ⊆ B_{D}.(A finite ∧ A ⊑_{EM} X) ⇒ A ⊑_{EM} Y.

Then we here (1) ⇒ (2) ⇔ (3) ⇒ (4) with (3) ⇔ (4) if X is finitely generable and (1) ⇔ (2) if Y is finite or if X is a subset of B_{D}. Proof. (1) ⇒ (2). Already known.

(2) ⇒ (3). That (2) implies the first conjunct is known from Theorem 1. For the converse take y ∈ Y. Define f: D → O 0 by f(d) = ⊤ iff d ⋢ y. Then ⊥ ∈ f(Y) and so ⊥ ∈ f(X); then for some x in X, f(x) = ⊥, which is to say x ⊑ y.

(3) ⇒ (2). Left as an exercise.

(3) ⇒ (4). Left as an exercise.

(4) ⇒ (3) when X is fg. Take b ⊑ x with b ∈ B_{D} and x ∈ X. Then {⊥, b} ⊑_{EM} X and so {⊥, b} ⊑_{EM} Y and so b ⊑ y for some y in Y. Next take y ∈ Y and f: Tapes → D generating X. Suppose for the sake of contradiction that for all x ∈ X we have x ⋢ y. Then for any infinite w in Tapes, f(w) ⋢ y and so there is a finite a ⊑ w with f(a) ⋢ y. Now as Tapes is a finitarily branching tree it follows by König’s Lemma that there is a finite cross section A of Tapes with A ⊆ B_{Tapes} and for all a in A, f(a) ⋢ y. Then f(A) ⊑_{EM} X and so f(A) ⊑_{EM} Y but then there must be an f(a) with f(a) ⊑ y giving us the required contradiction.

(2) ⇒ (1) when X is a subset of B_{D}. Immediate from (2) ⇒ (4).

(2) ⇒ (1) when Y is finite. Left as Exercise 68 [Hint Use (3)].

So for finite sets we have ⊑_{EM}=∼ ⊑=∼ ⊑_{EM} and indeed we know that for finite D we have P(D) = F(D)/⊑_{EM}.

Condition (3) shows how close ∼ ⊑_{EM} is to being ⊑_{EM} and condition (4) shows that for fg sets X ∼ ⊑_{EM} Y iff any finite Egli-Milner information about X (= picture of a cross-section of the development of X) is also about Y. In fact it is natural to expect any fg set is the limit of its cross-sections and we now show this is true w.r.t. ∼ ⊑_{EM}.

Definition 9. For f: Tapes → D define Bd_{n}(f) = {f(w) | |w| = n}.

Clearly for m ≤ n ≤ ω we have Bd_{m}(f) ⊑_{EM} Bd_{n}(f) ⊑_{EM} Bd(f).

Lemma 4. Let f: Tapes → D generate X. If A is a finite subset of B_{D} such that A ⊑_{EM} X then for some n, A ⊑_{EM} Bd_{n}(f). Further if Bd_{n}(f) ∼ ⊑_{EM} Y for all n then X ∼ ⊑_{EM} Y. Proof. As A ⊑_{EM} X for every infinite w in Tapes there is a finite v ⊑ w with a ⊑ f(v) for some a in A. Hence by König’s Lemma there is an n_{0} such that |v| ≥ n_{0} implies a ⊑ f(v) for some a in A. Equally as A ⊑_{EM} X for every a in A there is an infinite w with a ⊑ f(w) and hence a finite v_{a} ⊑ w with a ⊑ f(v_{a}). Now put n = max(n_{0}, max_{a∈A}(|v_{a}|)) and then A ⊑ Bd_{n}(f). The rest now follows using from Theorem 4 that (4) ⇒ (2) for fg X and (1) ⇔ (2) for finite subsets of finite elements.

Now assuming a similar property holds of ∼ ⊑ we can show it must be ∼ ⊑_{EM} at least as regards fg sets. Specifically, assume that:

∀f: Tapes → D.∀Y ⊆ D.(∀n.Bd_{n}(f) ∼ ⊑ Y) ⇒ Bd(f) ∼ ⊑ Y.

Now suppose X ∼ ⊑_{EM} Y with X fg. Then by Lemma 3 there is an f: Tapes → D with X = Bd(f) and Bd_{n}(f) ⊆ B_{D} for every n. Then for any n we have Bd_{n}(f) ∼ ⊑_{EM} Y; so by Theorem 4 we have Bd_{n}(f) ⊑_{EM} Y (since Bd_{n}(f) is a finite set of finite elements) and so Bd_{n}(f) ∼ ⊑ Y. Therefore by the assumption X = Bd(f) ∼ ⊑ Y. Thus we have established, under reasonable assumptions, that ∼ ⊑ is ∼ ⊑_{EM}.

Our proposed powerdomain according to this analysis is therefore ⟨F_{g}(D), ∼ ⊑_{EM}⟩/∼ ⊑_{EM}. Since we already have a proposal from Theorem 3 we must now prove that the two possibilities are isomorphic.

Lemma 5. Let A_{0} ⊑_{EM} A_{1} ⊑_{EM} ⋯ be an increasing sequence of elements of F(D). Then there is an f: Tapes → D with every A_{n} being some Bd_{m}(f) (with m ≥ n). Further Bd(f) = {⨆ a_{n} | ∀n.a_{n} ∈ A_{n}, a_{0} ⊑ a_{1} ⊑ ⋯}. Proof. Define a finitary tree T = {⟨a_{0}, …, a_{n}⟩ | a_{i} ∈ A_{i} and a_{0} ⊑ ⋯ ⊑ a_{n}} and label ⟨a_{0}, …, a_{n}⟩ by a_{n} for n > 0 and by ⊥ for n = 0. Then A_{n} is the set of labels of the set of nodes of depth n + 1. Finally pad out T so that it is (isomorphic to) B_{Tapes} and choose the labelling so that every A_{n} is the set of labels of some Tapes_{m} and use the labels to construct f. The last part is an easy König’s Lemma argument on T.

We also need a lemma about ω-algebraic cpos.

Lemma 6. Let P be a partial order with a least element. Suppose B ⊆ P is a countable subset of P such that:

(1) Every element of P is the lub of an increasing sequence of elements of B.

(2) Every increasing sequence of elements of B has a lub in P.

(3) If b ⊑ ⨆_{P} b_{i} where b_{0} ⊑ b_{1} ⊑ ⋯ and b and the b_{i} are all in B then b ⊑ some b_{n}. Then P is ω-algebraic and B its set of finite elements. Proof. To see P is a cpo let d_{0} ⊑ d_{1} ⊑ … be an increasing sequence in P. Let X = {b ∈ B | b ⊑ some d_{i}}. Then ⊥ is in X. Then one sees from (1) and (3) that X is directed. Hence as X is countable we can take a cofinal chain in X to show by (2) that d = ⨆ X exists. By (1) we have that d is an upper bound of every d_{n} and the definition of X shows it must be the least one.

Next take b in B and let d_{0} ⊑ d_{1} ⊑ ⋯ be an increasing sequence and suppose b ⊑ ⨆_{n} d_{n}. Define X as above. We know b ⊑ ⨆ X and hence as X is directed and countable it follows from (3) that b ⊑ some element of X ⊑ some d_{n}. Hence b is finite and so B_{0} ⊆ B.

Therefore by Chapter 6 Lemma 1, D is ω-algebraic.

It follows from Lemma 6 that F_{g}(D)/∼ ⊑_{EM} is ω-algebraic and its set of finite elements {A↓| A ∈ F(D)} (where, of course, A ↓= {X ∈ F_{g}(D) | X ∼ ⊑_{EM} A}). For condition (1) of that lemma is immediate from Lemma 3 and Lemma 4; condition (2) follows from Lemma 4 and Lemma 5; condition (3) from Lemma 5 and Lemma 4. But now we note

⟨B_{F_{g}(D)}/∼ ⊑_{EM}, ⊆⟩ ≅ ⟨F(D), ∼ ⊑_{EM}⟩/∼ ⊑_{EM}  since for A, B in F(D), A↓⊆ B ↓ iff A ∼ ⊑_{EM} B
= ⟨F(D), ⊑_{EM}⟩/⊑_{EM}  by remark after Theorem 4.

Therefore F_{g}(D)/∼ ⊑_{EM}= \overline{F(D)} = P(D) showing as promised that the two possibilities are indeed isomorphic.

Exercise 69. Show that we should define {·}_{P}: D → F_{g}(D)/∼ ⊑_{EM} and ∪_{P}: (F_{g}(D)/∼ ⊑_{EM})^{2} → F_{g}(D)/∼ ⊑_{EM} by {d}_{P} = {d} ↓ and A ↓ ∪_{P}B ↓= (A ∪ B) ↓ respectively. No particularly revealing formula for function extension is known.

Thus we have now greatly increased our understanding of powerdomains: the sets are the finitely generable sets, modulo ∼ ⊑_{EM} and the ordering is ∼ ⊑_{EM}; further the singleton and union functions have natural definitions and Lemma 5 shows us what lubs of increasing chains of finite elements look like.

Canonical Representatives and Scott-Compact Sets

We now explore the equivalence relation ≃_{EM} in order to obtain canonical (actually maximal) elements of the equivalence classes. Following Theorem 3(3) there is a very natural closure operation. For any set X define X^{∗} by:

X^{∗} = {y | (∃x ∈ X.x ⊑ y) ∧ (∀b ∈ B_{D}.b ⊑ y ⇒ ∃x ∈ X.b ⊑ x).

Proposition 1. For any set X ⊆ D we have

(1) X ⊆ X^{∗},

(2) X^{∗∗} = X^{∗},

(3) X ≃_{EM} Y iff X^{∗} = Y^{∗}

(and so (4) X ≃_{EM} X^{∗}). Proof. Exercise 70.

Thus (·)^{∗} is a closure operation and X^{∗} is the maximal member of its equivalence class. What we would like to prove now is that X^{∗} is fg; however it is open whether this is true in general but we can proceed further by considering the Scott-compact sets which, as we will see, generalise fg sets (Proposition 2) but are the fg sets, to within ≃_{EM}. (It should be noted that better results will be obtained later for special kinds of ω-algebraic cpos, the so-called 2/3 SFP ones.)

Exercise 71. This exercise looks at the convexity part of ≃_{EM} as illustrated by A_{5} = A_{6}.

Definition 10. Let P be a preorder. A subset X of P is convex iff ∀x, z ∈ X.∀y ∈ P.x ⊑ y ⊑ z ⇒ y ∈ X. The least convex set containing a given X ⊆ P is:

Con(X) = {y ∈ P | ∃x, z ∈ X.x ⊑ y ⊑ z}.

Show that Con(X^{∗}) = X^{∗} ⊇ Con(X) but equality does not always hold. Show that F(D)/∼ ⊑_{EM}≅ ⟨{Con(A) | A ∈ F(D)}, ⊑_{EM}⟩ and conclude that for finite D, we have P(D) ≅ ⟨{Con(A) | A ⊆ D, A ≠ ∅}, ⊑_{EM}⟩. Note that Con is not a topological closure operator (that is we do not always have Con(X∪Y) = Con(X)∪Con(Y)) and conclude the same for (·)^{∗}.

Definition 11. A set C ⊆ B_{D} covers X ⊆ D iff ∀x ∈ X.∃c ∈ C.c ⊑ x. A set X ⊆ D is Scott-compact iff whenever C covers X so does a finite subset of C.

The idea is to use compactness to replace König’s Lemma arguments.

Exercise 72. Show that X is Scott-compact iff it is compact in the Scott topology. Show that whenever C is finite and covers X then C ∪ X is Scott-compact. Conclude there are Scott-compact sets which are not fg; how many are there?

Proposition 2. Every finitely generable set is Scott-compact. Proof. Let X be fg with generating function f: Tapes → D. Let C cover X. Then for every infinite w in Tapes f(w) ⊒ some c in C. So f(v) ⊒ c for some finite v ⊑ w. Applying König’s Lemma we obtain a cross-section of such v’s and the corresponding c’s provide the needed finite subset of C.

This proposition makes it plain why sets like N ⊆ N_{⊥} are not fg.

Exercise 73. Show that if X ≃_{EM} Y then X is Scott-compact iff Y is.

So we know that for a fg X, X^{∗} is Scott-compact and so by Proposition 1 it is the maximal member of the equivalence class {Y ⊆ D | Y is Scott-compact and Y ≃_{EM} X}. This suggests that

P(D) ≅ ⟨(·)^{∗}-closed nonempty Scott-compact subsets of D, ∼ ⊑_{EM}⟩

and to establish this it only remains to show that every Scott-compact set is ≃_{EM}-equivalent to a fg set, which we now do.

Lemma 7. Let C ⊆ D be nonempty and Scott-compact. Then I(C) =^{def} {A ∈ F(D) | A ⊑_{EM} C} is a directed ideal and has ∼ ⊑_{EM}-lub C (that is if for some X ⊆ D we have ∀A ∈ I(C).A ∼ ⊑_{EM} X then C ∼ ⊑ X). Proof. To see I(C) is an ideal the only nontrivial point is to show that it is directed. Clearly {⊥} is in I(C) so it is nonempty. Suppose A and B are in I(C). Then C is covered by A and B and so as C is compact it is covered by {x ∈ B_{D} | ∃a ∈ A, b ∈ B, c ∈ C.a ⊑ x ∧ b ⊑ x ∧ x ⊑ c} and so by some finite subcollection, X, of the latter set. Thus we have an X in F(D) which is covered by both A and B and with X ⊑_{EM} C.

For any a in A there is a c in C with c ⊒ a and for that c there is an x in X so that c ⊒ x. But then there is an a′ such that a, x ⊑ a′ ⊑ c. Let A′ be the finite collection of these a′’s. Then A ⊑_{EM} X ∪ A′ ⊑_{EM} C and B covers X ∪ A′. Defining B′ similarly we find that A, B ⊑_{EM} X ∪ A′ ∪ B′ ⊑_{EM} C, concluding the proof that I(C) is directed.

Next suppose that ∀A ∈ I(C).A ∼ ⊑_{EM} X. We will show that C ∼ ⊑ X. Take any f: D → O 0 to show that f(C) ⊑_{EM} f(X). If ⊤ ∈ f(C) then for some c in C and finite a ⊑ c we have ⊤ = f(a) and so considering {a, ⊥} in I(C) we find that ⊤ ∈ f(X). finally suppose ⊥ ∉ f(C). Then {a ∈ B_{D} | f(a) = ⊤ ∧ ∃c ∈ C.a ⊑ c} covers C and so as C is compact it has a finite subcover, A, say. Then A ⊑_{EM} C and ⊥ ∉ f(A). So as A ⊑_{EM} X we have ⊥ ∉ f(X) either.

(Compare this last argument to the König’s Lemma argument in the last part of theorem).

Theorem 5. Every Scott-compact set is ≃_{EM}-equivalent to some fg set. Proof. Immediate from Lemmas 7, 4 and Theorem 4.

This establishes our desired characterisation of P(D) as the collection of (·)^{∗}-closed Scott-compact sets partially ordered by ⊑_{EM}. So we have our first characterisation of P(D) as a collection of subsets; the open problem is still to see if all (·)^{∗}-closed Scott-compact sets are actually finitely generable.

Exercise 74. Show that in terms of the latest characterisation of P(D) we have for x ∈ D, X, Y ∈ P(D), f: D → P(E), g: D → P(E):

\begin{aligned}\{x\}_{P} & = \{x\}, \\ X ∪_{P} Y & = (X ∪ Y)^{∗}, \\ f^{†}(X) & = ( ⋃_{x∈X} f(X))^{∗}, \\ P(g)(X) & = (g(X))^{∗}. \end{aligned}

The Lawson Topology

Our understanding of powerdomain is still incomplete in that we have not systematically considered the identification A_{7} = A_{8}. What seems to be wanted is a notion of limit of a sequence so that, for example:

lim_{n→∞} 0^{n}1^{ω} = 0^{ω}.

Attending to this desire will have several pleasant consequences: (·)^{∗}-closure will be explained in terms of these limits and convex closure; the X^{∗} will be fg; ∼ ⊑_{EM} will just be ⊑_{EM} on the X^{∗}. (But all this will only work for certain ω-algebraic cpos, remember.)

So let us say when ⟨x_{n}⟩ has limit x (or converges to x) writing:

lim_{n} x_{n} = x iff ∀b ∈ B_{D}.[b ⊑ x ⇔ ∀_{∞}n.b ⊑ x_{n}] ∧ [b ⋢ x ⇔ ∀_{∞}n.b ⋢ x_{n}]
(iff ∀b ∈ B_{D}.[b ⊑ x ⇒ ∀_{∞}n.b ⊑ x_{n}] ∧ [b ⋢ x ⇒ ∀_{∞}n.b ⋢ x_{n}])
(iff ∀b ∈ B_{D}.[b ⊑ x ⇒ ∀_{∞}n.b ⊑ x_{n}] ∧ [∃_{∞}n.b ⊑ x_{n} ⇒ b ⊑ x]).

(Here the notations ∀_{∞}n.P (n), ∃_{∞}n.P (n) mean that P holds for all but finitely many n, respectively infinitely many n.)

The elementary properties of these limits form an exercise.

Exercise 75.

(1) Let ⟨x_{n}⟩ and ⟨y_{n}⟩ be sequences with respective limits x and y. Show that if x_{n} ⊑ y_{n} for all n then x ⊑ y.

(2) Show that if ⟨x_{n}⟩ is an increasing sequence then it has limit, ⨆_{n} x_{n}. Show that if ⟨x_{n}⟩ is a decreasing sequence then it has limit x iff x = ⊓_{n} x_{n}.

(3) Show that if a sequence has limit x then any infinite subsequence has the same limit.

(4) Suppose lim_{n} x_{mn} = x_{m} for each m and lim_{m} x_{m} = x. Then there are functions r, r′ such that

lim_{m} x_{r(m)r′(m)} = x.

[Hint Choose r and r′ so that for any 1 ≤ m, b ⊑ x iff b ⊑ x_{r(m)r′(m)}.] Because of part (1) of this exercise, lim_{n} x_{n} is determined. Because of (2) and (4) if we put for any X ⊆ D

Cl(X) =^{def} {lim_{n} x_{n} | x_{n} is a sequence of elements of X with a limit}

then Cl(X) is the least set of elements of D containing X and closed under limits. Because of (3) we have that Cl(X ∪ Y) = Cl(X) ∪ Cl(Y) and so we have a topological closure operator. This topology is called the Lawson topology and the next few exercises discuss it (they will not be used in the main development).

Exercise 76.

(1) Show that a subbasis of the topology is provided by the sets P_{b} = {x ∈ D | x ⊒ b} and N_{b} = D\P_{b} (b ∈ B_{D}).

(2) Show one can define a metric as follows. Let b_{0}, b_{1}, … be an enumeration of B_{D}. Define

d(x, y) = \{ \begin{matrix}0 & (x = y), \\ \frac{1}{1 + μn.b_{n} ∈ B_{x} ⊕ B_{y}} & (x ≠ y) \end{matrix}

(where, of course, X ⊕ Y = (X\Y) ∪ (Y \X)).

Indeed show that this is even an ultrametric in the sense that the triangle inequality can be strengthened to

d(x, z) ≤ max(d(x, y), d(y, z)).

Show that lim_{n} x_{n} = x iff this is true in the metric. Show that ⟨x_{n}⟩ is a Cauchy sequence iff ∀m.(∀_{∞}n.b_{m} ⊑ x_{n}) ∨ (∀_{∞}n.b_{m} ⋢ x_{n}).

To proceed further we need to know that the Lawson topology is compact. What this means in terms of limits is that every sequence has a convergent subsequence. Strangely it turns out that an ω-algebraic cpo has compact Lawson topology iff it obeys 2 out of the 3 conditions needed to make it strongly algebraic!

Lemma 8. Every sequence ⟨x_{m}⟩ contains a subsequence, ⟨y_{m}⟩, such that for all finite b either (∀_{∞}m.b ⊑ y_{m}) or else ∀_{∞}m.b ⋢ y_{m}. Proof. Let b_{0}, b_{1}, … enumerate the finite elements of D. Put B_{n} = {b_{i} | 0 ≤ i ≤ n}. Say a partition ⟨P, Q⟩ of B_{n} is good if ∃m ≥ n.(∀b ∈ P.b ⊑ x_{m}) ∧ (∀b ∈ Q.b ⋢ x_{m}) and clearly every B_{n} has a good partition and so by König’s Lemma there is an infinite sequence ⟨P_{0}, Q_{0}⟩, ⟨P_{1}, Q_{1}⟩, … of good partitions of B_{0}, B_{1}, … with P_{0} ⊆ P_{1} ⊆ ⋯ and Q_{0} ⊆ Q_{1} ⊆ · · ·. Now choose a subsequence ⟨y_{m}⟩ of ⟨x_{n}⟩ so that (∀b ∈ P_{m}.b ⊑ y_{m}) ∧ (∀b ∈ Q_{m}.b ⋢ y_{m}).

Recall that in Chapter 6 we defined U(X) as the set of minimal upper bounds of X; we say U(X) is complete if every upper bound of X is greater than or equal to some element of U(X). Recall that if X is in F(D) then every element of U(X) is finite.

Theorem 6 The 2/3 SFP Theorem. The Lawson topology on D is compact iff every U({a, b}) with a, b finite is both complete and finite. Proof. ⇐) Suppose every such U({a, b}) is both complete and finite. Let ⟨x_{n}⟩ be a sequence and choose an infinite subsequence ⟨y_{m}⟩ according to Lemma 7. Let X = {b ∈ B_{D} | ∀_{∞}m.b ⊑ y_{m}}. We claim that X is directed. For if a, b are in X then since U({a, b}) is complete we have that almost all y_{m} are greater than both a and b and hence some minimal upper bound of a and b. Hence as U({a, b}) is finite it has an element c with c ⊑ y_{m} for infinitely many y_{m}. But then by the construction of ⟨y_{m}⟩ we have c ⊑ y_{m} for almost all y_{m}. Thus X is indeed directed and then one easily proves that lim_{m} y_{m} = ⨆ X (show this!).

⇒) We know from Exercise 75 that every decreasing sequence has a glb. Now take finite a, b and suppose x is an upper bound of a and b. Let C be {c ∈ B_{D} | x ⊒ c, c ⊒ a, c ⊒ b}. Clearly C ≠ ∅. Let c_{0}, c_{1}, … be an enumeration of C and let c_{r(n)} be defined by c_{r(0)} = c_{0}, r(n + 1) = μm > r(n).c_{r(n)} ⊒ c_{m} if that exists and r(n) otherwise. Then c = ⊓ c_{r(n)} exists. By construction c is less than x, a lower bound of C and an upper bound of the finite elements a and b. It is also in U({a, b}) as otherwise there is a finite c_{m} an upper bound of a, b and ⋢ c and m is some r(n), so c ⊑ c_{m} a contradiction. So U({a, b}) is complete.

Next suppose U({a, b}) is infinite for the sake of contradiction. Let c_{0}, c_{1}, … be an enumeration without repetitions of an infinite subset of U({a, b}). We can assume lim_{n} c_{n} = x exists by compactness. Now since a is less than all the c_{n}’s we have a ⊑ x and similarly b ⊑ x. Therefore some c in U({a, b}) is less than or equal to x and so c ⊑ almost all the c_{n} and choosing c_{m} ≠ c we get c ⊑ c_{m} contradicting the assumption that c_{m} is a minimal upper bound of a and b and concluding the proof.

Exercise 77.

(1) Show that the assumption of the 2/3 SFP Theorem are equivalent to saying that U(A) is finite and complete for any finite subset, A, of B_{D}; or equally that the intersection of Scott-compact sets is Scott-compact.

(2) Show that the metric of Exercise 76 is complete iff the Lawson topology is compact.

From now on we assume the Lawson topology is compact.

Lemma 9. Let X be a subset of D. Then Con(Cl(X)) is the least convex, Lawson closed set containing X. Proof. It is enough to show Y = Con(Cl(X)) Lawson-closed.

Let ⟨y_{n}⟩ be a convergent sequence in Y. Then there are ⟨x_{n}⟩, ⟨z_{n}⟩ in Cl(X) with x_{n} ⊑ y_{n} ⊑ z_{n}. By compactness we can assume ⟨x_{n}⟩ and ⟨z_{n}⟩ to be convergent. Then by Exercise 75(1) lim_{n} x_{n} ⊑ lim_{n} y_{n} ⊑ lim_{n} z_{n} and so lim_{n} y_{n} is in Y showing that Y is Lawson-closed as required.

Now we can see how well we can understand (·)^{∗}-closed and ∼ ⊑_{EM}.

Lemma 10. Let X be Scott-compact and let ⟨x_{n}⟩ be a convergent sequence in X. Then for some y in X, y ⊑ lim_{n} x_{n}. Proof. Suppose, for the sake of contradiction that no y in X is less than x =^{def} lim_{n} x_{n}. Then for any such y we have a finite a ⊑ y with a ⋢ x. By compactness, we can assume a finite collection {a_{1}, …, a_{n}} covering X with no a_{i} ⊑ x. But now some a_{i} is less than infinitely many x_{n} and so less than x, being the required contradiction.

Again the reader will appreciate how compactness replaces König’s Lemma if she proves Lemma 10, but restricted to fg sets.

Theorem 7.

(1) For any X ⊆ D, X^{∗} = {y | ∃ convergent sequence x_{n} ∈ X, z ∈ X, z ⊑ y ⊑ lim x_{n}}.

(2) For Scott-compact X, X^{∗} = Con(Cl(X)), but not for arbitrary X.

(3) For Scott-compact Y, X^{∗} ∼ ⊑_{EM} Y^{∗} iff X^{∗} ⊑_{EM} Y^{∗}, but not for arbitrary Y. Proof. (1) Let Y = {y | ∃ convergent sequence ⟨x_{n}⟩ ⊆ X, z ∈ X.z ⊑ y ⊑ lim_{n} x_{n}}. Clearly Y ⊆ X^{∗}. For the converse suppose y ∈ X^{∗}. There y ⊒ some z in X and taking b_{0} ⊑ b_{1} ⊑ ⋯ in B_{0} with lub y we obtain ⟨x_{n}⟩ in X with b_{n} ⊑ x_{n}; by compactness we can assume the ⟨x_{n}⟩ converges and clearly then y ⊑ lim_{n} x_{n}.

(2) Part (1) shows that X^{∗} ⊆ Con(Cl(X)); Lemma 10 and the easily established convexity of X^{∗} shows the converse conclusion. Finally a counterexample for arbitrary X is given by taking D = Tapes, X = {0^{n}1^{ω} | n ∈ ω}.

(3) Clearly ⊑_{EM} is included in ∼ ⊑_{EM}. Conversely suppose X^{∗} ∼ ⊑_{EM} Y^{∗}. If y ∈ Y^{∗} then by Theorem 4, some x in X^{∗} is less than y. If x ∈ X^{∗}, let b_{0} ⊑ b_{1} ⊑ … be an increasing sequence of finite elements with lub x. Then by Theorem 4 we find y_{0}, y_{1}, … in Y^{∗} with a_{n} ⊑ y_{n}. By compactness we can assume the ⟨y_{n}⟩ converges, say to y. By part (2) we have y in Y^{∗} and clearly x ⊑ y. For a counterexample for general Y take D = Tapes, Y = {0^{n}1^{ω} | n ∈ ω}, X = Y ∪ {0^{ω}}.

Proposition 2. Every Lawson-closed set is Scott-compact. Proof. This follows from general topological principles. For since the Lawson topology is compact any Lawson-closed set is Lawson-compact and so compact also in the coarser Scott topology. Alternatively suppose C is Lawson-closed and is covered by {x_{0}, x_{1}, …} ⊆ B_{D}. If C is not Scott-compact then for any n there is a c_{n} in C such that c_{n} ⋣ x_{0}, …, c_{n} ⋣ x_{n}. Taking c as the limit of a convergent subsequence of the c_{n} we find c ⊒ no x_{n}, the required contradiction.

Now we know that the nonempty (·)^{∗}-closed Scott-compact sets are just the nonempty convex-closed, Lawson closed sets (use Theorem 7(2) and Lemma 9 for one half on the proof and Proposition 2 and Theorem 7(2) for the other half). But putting this and Theorem 7(3) together with the above characterisation of P(D) we get another one:

P(D) = ⟨nonempty, convex and Lawson-closed sets, ⊑_{EM}⟩

and this is the clearest picture we can obtain of our sets.

As promised we now show that the X^{∗} are finitely generable.

Lemma 11. Every nonempty Lawson-closed set is fg (and so every (·)^{∗}-closed Scott-compact nonempty set is too). Proof. Let X be a nonempty Lawson-closed set. Let b_{0}, …, b_{n}, … be an enumeration without repetitions of B_{D} (if D is finite the whole lemma is trivial). Consider the tree with nodes those nonempty sequences ⟨⟨P_{0}, Q_{0}, a_{0}⟩, …, ⟨P_{k}, Q_{k}, a_{k}⟩, …, ⟨P_{m}, Q_{m}, a_{m}⟩⟩ where ⟨P_{k}, Q_{k}⟩ is a partition of {b_{i} | 0 ≤ i < k}, a_{k} ∈ U(P_{k}) and a_{k} ⊑ x for some x in X and for all b in Q_{k}, b ⋢ x and furthermore P_{0} ⊆ ⋯ ⊆ P_{k} ⊆ ⋯ and Q_{0} ⊆ ⋯ ⊆ Q_{k} ⊆ ⋯ and a_{0} ⊑ ⋯ ⊑ a_{k} ⊑ ⋯; label such a node by a_{m}. The nodes are to be ordered by the subsequence ordering (note that the root is ⟨⟨∅, ∅, ⊥⟩⟩). Now prune off all nodes not dominated by infinitely many nodes. This gives a generating tree for X.

Exercise 78. Prove this!

Exercise 79. Improve previous formulae for 2/3 SFP ω-algebraic D.

(1) Show that for X, Y ⊆ D we have

X ∪_{P} Y = Con(X ∪ Y).

Can the formula: P(g)(X) = g(X)^{∗} for g: D → E be improved similarly?

(2) Define the “big union” function ⋃_{P}: P(P(D)) → P(D) to be (id_{P(D)})^{†}. Is it true that for any χ in

P(P(D)) the formula

⋃_{P}χ = Con( ⋃_{X∈χ} X)

holds?

(3) Let X_{0} ⊑ X_{1} ⊑ ⋯ be an increasing chain in P(D). Show that

⨆ X_{n} = {⨆_{n} x_{n} | x_{n} ∈ X_{n}, x_{0} ⊑ x_{1} ⊑ ⋯}^{∗}.

Can this be improved to Con, even for X_{n} finite?

General Powerdomains: The Smyth Powerdomain

Now we consider the general form of the Smyth powerdomain; this will be dealt with rather briefly, leaving many points as exercises. The idea here is that the more elements a set contains, the smaller it should be in the order — just the dual of the relational case. In terms of semilattices we have the following natural observations:

Exercise 80. Let ⟨D, ⊑, ∪⟩ be a continuous semilattice. Show that the following statements are equivalent: (1) ∀x, y.x ⊆ y ⇒ x ⊒ y,

(2) ∀x, y.x ⊆ y ⇔ x ⊒ y,

(3) ∀x, y.x ∪ y ⊑ x,

(4) ∀x, y.x ∪ y = x ⊓ y and all imply that x ∪ ⊥ = ⊥ (but not conversely). Thus we have to do with cpos with a continuous meet operation and the linear maps are the multiplication ones.

As an order on sets one naturally defines the appropriate half of the Egli-Milner order for any cpo D.

X ⊑_{S} Y iff ∀y ∈ Y.∃x ∈ X.x ⊑ y

(and the associated equivalence is =_{S}). (Note that X covers C just means that X ⊑_{S} C.) The contextual variant is

X ∼ ⊑_{S} Y iff ∀f: D → O 0 .f(X) ⊑_{S} f(Y)

(and the associated equivalence is ≃_{S}). There is no controversy over choice of order since:

Exercise 81. Show that ⊑_{S} and ∼ ⊑_{S} are identical. Show that when D is ω-algebraic, X ⊑_{S} Y implies that:

∀A ⊆ B_{D}.(A a finite subset of B_{D} ∧ A ⊑_{S} X) ⇒ A ⊑_{S} Y

and the converse holds if X is finitely generable (or, more generally, Scott compact). [Plunder Theorem 4.] For a quick construction of the Smyth powerdomain for an ω-algebraic D, put:

F_{S}(D) = ⟨{finite nonempty subsets of B_{D}}, ⊑_{S}⟩.

This is a preorder with least element {⊥}. Put

\begin{aligned}P_{S}(D) & = \overline{F_{S}(D)}, \\ \{d\}_{S} & = \{\{b_{1}, …, b_{n}\} | ∃i.b_{i} ⊑ d\}, \\ I ∪_{S} J & = \{A ∪ B | A ∈ I, B ∈ J\}. \end{aligned}

You should verify that {·}_{S} and ∪_{S} are well-defined and continuous and that {b}_{S} = [{b}] for b in B_{D} and [A] ∪_{S} [B] = [A ∪ B] for A, B in F_{S}(D). Clearly too ⟨P_{S}(D), ∪_{S}⟩ is a semilattice and you should verify that ∪_{S} is the meet operation on the cpo P_{S}(D), as I ∪_{S} J = I ∩ J.

Exercise 82. Obtain the following universal characterisation of P_{S}(D) for ω-algebraic D:

If f: D → P is any (strict) continuous function to a cpo P with a continuous meet then there is a unique (strict) multiplicative continuous function f^{†}: P_{S}(D) → P such that the following diagram commute:

[figure: P_{S}(D); P; f^{†}; f; D; {·}_{S}]

Show further that (·)^{†} is an isomorphism of the continuous semilattice of (strict) continuous f: D → P and the continuous semilattice of (strict) multiplicative continuous g: P_{S}(D) → P. [Plunder Theorem 3.]

This exercise indicates that we can use relations t ⊑ u as well as equalities t = u when constructing free continuous algebras, since the Smyth case depends on the relation x ∪ y ⊑ x (note, as a joke, that this is inconsistent with the relational powerdomain requirement that x ∪ y ⊒ x as then we would have x = y).

Anyway, now we can view P_{S} as a locally continuous functor over ω-ALG putting:

P_{S}(f) = ({·} ∘ f)^{†}.

The usual arguments then show that P_{S} is a functor over SFP and so we can solve domain equations involving all the functors we know. In fact, however, as long as we don’t want P_{P} too we can work with consistent completeness as that is preserved by P_{S}; indeed as the next exercise demonstrates the situation is somewhat curious:

Exercise 83. Let D be ω-algebraic. Show that P_{S}(D) is consistently complete iff D is 2/3 SFP, demonstrating the formula

[A] ∪ [B] = [ ⋃_{a∈A} ⋃_{b∈B} U({a, b})]

which should be interpreted as implying that the left-hand-side exists when the set on the right is nonempty.

We now look for nicer description of P_{S}(D) as we did for the Egli-Milner case. From now on we fix an ω-algebraic D.

Lemma 12. Let f: Tapes → D generate X. If A is a finite subset of B_{D} such that A ⊑_{S} X then for some n, A ⊑_{S} Bd_{n}(f). Further if Bd_{n}(f) ⊑_{S} Y for all n then X ⊑_{S} Y (any Y ⊆ D). Proof. Exercise 84. [Plunder Lemma 4.]

Lemma 13. Let A_{0} ⊑_{S} A_{1} ⊑_{S} ⋯ be an increasing sequence in P_{S}(D). Then there is an f: Tapes → D with every A_{n} being ⊑_{S} some Bd_{n}(f). Proof. Exercise 85. [Plunder Lemma 5.]

It follows much as before that

P_{S}(D) = ⟨F_{g}(D), ⊑_{S}⟩/⊑_{S}

and the finite elements have the form A↓ for A in P_{S}(D).

Passing on to canonical representatives for any X ⊆ D we define:

X^{†} = {y | ∃x ∈ X.y ⊒ x}

and note that:

(1) X ⊆ X^{†},

(2) X^{††} = X^{†},

(3) (X ∪ Y)^{†} = X^{†} ∪ Y^{†},

(4) X =_{S} Y iff X ≃_{S} Y iff X^{†} = Y^{†},

(5) X ⊑_{S} Y iff X ∼ ⊑_{S} Y iff X^{†} ⊇ Y^{†}. Thus (·)^{†} is a topological closure operation (the topology is called the lower topology as the open sets are the downwards closed ones). Also X^{†} is the maximal member of the equivalence class of X and ⊑_{S} is just ⊇ on these maximal members. It would now be nice to know that X^{†} is fg if X is; however this too is an open problem and we consider the Scott compact subsets again.

Lemma 14. Let C ⊆ D be nonempty and Scott-compact. Then I_{S}(C) =^{def} {A ∈ F_{S}(D) | A ⊑_{S} C} is a directed ideal and has ⊑_{S}-lub C. Proof. Exercise 86. [Plunder Lemma 7.]

Together with Theorem 5 above this establishes that

P_{S}(D) = ⟨nonempty upper-closed Scott compact sets, ⊇⟩

which is not too bad a characterisation of the powerdomain. When D is 2/3 SFP we know, of course, that the nonempty upper-closed Scott-compact sets are exactly the nonempty upper-closed, Lawson-closed sets and they in turn are just the upper-closed finitely generable sets.

Exercise 87. Prove these last few assertions!

Exercise 88. Establish the following formulae for x ∈ D, X, Y ∈ P_{S}(D), f: D → P_{S}(E) and g: D → E;

\begin{aligned}\{x\}_{S} & = \{y ∈ D | y ⊒ x\}, \\ X ∪_{S} Y & = X ∪ Y, \\ f^{†}(X) & = ( ⋃_{x∈X} f(X)). \end{aligned}

Show that if X_{0} ⊇ X_{1} ⊇ ⋯ is an increasing chain in P_{S}(D) then:

⨆_{S}X = ⋂_{n} X_{n}.

[Hint Consider Y = ⨆_{S} X_{n}, which must exist as P_{S}(D) is a cpo.]

Duality

It was realised by M. Smyth that the duality theory connecting Smyth powerdomain and Dijkstra’s predicate transformers can be carried far beyond the simple case of discrete cpos to arbitrary ω-algebraic cpos (for example).

Definition 12. Let D and E be ω-algebraic. A predicate transformer from E to D is any strict continuous and multiplicative map

p: O(E) → O(D)

Exercise 89. Suppose m: D → P_{S}(E). Define the weakest precondition function by putting for any open V of E:

wp(m, V) = {x ∈ D | m(x) ⊆ V }.

Show that Ω(m) =^{def} λV.wp(m, V) is a predicate transformer. [Hint Use Scott-compactness.] Show too that Ω is monotonic and that the following properties hold:

Ω({·}_{S}) = id,
Ω(m; m′) = Ω(m) ∘ Ω(m′),
Ω(m ∪_{S} m′) = Ω(m) ∩ Ω(m′)

(where, of course, m; m′ = m′^{†} ∘ m and the other new operations are defined pointwise).

Exercise 90. Let ST (D, E) be the partial order D → P_{S}(E) of continuous functions from D to P_{S}(E). Let PT (E, D) be the partial order of predicate transformers with the pointwise ordering. Show that

Ω: ST (D, E) = PT (E, D)

is an isomorphism of partial orders with inverse given by

Ω^{−1}(p)(x) = ⋂{V ∈ O(E) | x ∈ p(V)}.

[Hint Show first that {A^{†} | A ∈ F_{S}(D) ∧ x ∈ p(A^{†})} is ⊑_{S}-directed and has lub Ω^{−1}(p)(x).]

Now show that Ω is an isomorphism of continuous semilattices and can be viewed as a duality of categories:

Ω: ST^{op} ≅ PT .

It is to be hoped that this duality will (together with that of Exercise 33 above) lay the foundations for a systematic investigation of the connection between denotational and axiomatic semantics. This however is a substantial programme of investigation which largely remains to be undertaken. This is further underlined by:

Exercise 91. Let DPT (E, D) be the additive transformers. Show that Ω cuts down to an isomorphism

Ω: ω-ALG ≅ DPT

of categories.

Exercise 92. The above does not yet generalise the case of a flat cpo since ST (X, Y) corresponds to X_{⊥} →_{⊥} P_{S}(Y_{⊥}) rather than X_{⊥} →P_{S}(Y_{⊥}). So put ST_{⊥}(D, E) = D→_{⊥} P_{S}(E) and find an appropriate strict version of the above exercises.

One can object that the above treatment of the duality is incomplete since the objects of PT should really be the complete lattices O(D) rather than the D themselves, and we do not yet know what complete lattices we are talking about. We now fill in this gap.

Definition 13. Let P be a partial order. An element x of P is an ω-prime (prime) iff whenever x ⊑ ⨆ Y where Y is a countable (finite) nonempty set then x ⊑ some element of Y. (Note that ⊥ is not a prime!) Then P is said to be ω-prime algebraic if every element of P is the lub of the ω-primes less than it and there are ω such ω-primes altogether.

Exercise 93. Show that not all ω-algebraic cpos are ω-prime algebraic and neither are all ω-prime algebraic cpos ω-algebraic.

But, for example, all ω-prime algebraic consistently complete cpos are ω-algebraic and then the ω-prime are exactly the finite primes and every finite element is a finite lub of ω-primes. Furthermore the ω-prime algebraic consistently complete cpos are completely distributive meaning that:

x ⊓ (⨆ Y) = ⨆_{y∈Y} (x ⊓ y)

in that when ⨆ Y exists then so does the right-hand side and then both sides are equal. Finally any ω-algebraic consistently complete cpo in which every finite element is a lub of primes is ω-prime algebraic.

Exercise 94.

(1) Show that if D is ω-algebraic then O(D) is an ω-prime algebraic complete lattice with ω-prime top element.

(2) Let L be an ω-prime algebraic complete lattice with ω-prime top element. Define

Pr(L) = ⟨ω-primes of L, ⊑⟩

and prove that:

(a) D ≅ \overline{Pr(O(D))^{op}},

(b) L ≅ O(\overline{Pr(L)^{op}}) (where for any preorder ⟨P, ⊑⟩, P^{op} is ⟨P, ⊒⟩ and the ideal completion of Chapter 6 is intended).

(3) Reformulate Exercise 89 in terms of an equivalence between the categories ST^{op} and the category of ω-prime algebraic complete lattices with ω-prime top elements and with morphisms the strict, continuous, additive functions. (We also call this a duality result.)

Exercise 95. Show that the duality of Exercise 94 cuts down to one of the 2/3 SFP objects and the ω-prime algebraic, ω-arithmetic complete lattices with ω-prime top element. (An ω-arithmetic complete lattice is one which is ω-algebraic and in which the glb of any two finite elements is finite.)

Exercise 96. Show that the duality of Exercise 94 cuts down to one of the consistently complete ω-algebraic cpos and the ω-prime algebraic, complete lattices in which the meet of any two ω-primes is an ω-prime.

We should also mention that much of the above has been inspired by the voluminous

A Compendium of Continuous Lattices by G. Gierz, J. D. Lawson, K. H. Hofmann, M. Mislove, K. Keimel, D. S. Scott.

which contains a great deal of further potentially computationally relevant material (Open Problem!!).

The Vietoris Topology

As long ago as 1921 Vietoris investigated nondeterministic functions in a topological setting. That this amounts to an alternative treatment of powerdomains was realised by M. Smyth and this includes predicate transformers both of the weakest precondition and (the dual of) the weakest liberal precondition variety. We now indicate some of the connections. Definition 14.

(1) Let X and Y be sets and suppose f: X → P(Y) is a multi-function from X to Y (i.e. from X to the collection of all subsets of Y). Then the strong inverse of f is Ω(f): P(Y) → P(X) where:

Ω(f)(B) = {a ∈ X | f(a) ⊆ B}

and the weak inverse of f is Λ(f): P(Y) → P(X) where:

Λ(f)(B) = {a ∈ X | f(a) ∩ B ≠ ∅}.

(2) Let X and Y be topological spaces in the above. Then f is upper semi-continuous if Ω(f)(V) is open when V is; it is lower semi-continuous if Λ(f)(V) is open when V is; it is continuous if it is both upper and lower semi-continuous.

Definition 15. Let X be a topological space. We define three topologies on P(X).

(1) The upper topology has basis {U_{O} | O is open in X} where U_{O} =^{def} {A ⊆ X | A ⊆ O}. Note that U_{O} ∩ U_{O′} = U_{O∩O′}.

(2) The lower topology has subbasis {L_{O} | O is open in X} where L_{O} =^{def} {A ⊑ X | O ∩ A ≠ ∅}.

(3) The Vietoris topology is the common refinement of the lower and upper topologies. It has a basis {V_{O_{1},...,O_{n}} | O_{1}, …, O_{n} are open in X} ∪ {{∅}} where

V_{O_{1},...,O_{n}} = {A ⊆ X | A ⊆ ⋃_{i} O_{i}, ∀i.A ∩ O_{i} ≠ ∅}

(where a basis for a topology is a collection of open sets such that every set is a union of basis sets; it need not be closed under intersections).

Exercise 97. Prove the above does define a basis for the Vietoris topology. Show the only topology contained in both the upper and lower topologies is the trivial one.

These topologies classify the various kinds of continuity possible for multi-functions in the following sense:

Exercise 98. Show that for a multi-function f: X → P(X)

(1) f is upper semi-continuous iff it is continuous (in the usual topological sense) relative to the upper topology.

(2) f is lower semi-continuous iff it is continuous relative to the lower topology.

(3) f is continuous iff it is continuous relative to the Vietoris topology.

The standard connection between topologies and preorders is given by:

Definition 16. Let X be a topological space. A preorder is defined on X by putting for all x, y in X:

x ⊑ y iff ∀ open V.x ∈ V ⇒ y ∈ V.

The preorders defined on P(X) relative to the upper, lower, Vietoris topologies will be denoted by ⊑_{U}, ⊑_{L}, ⊑_{V}.

Recall that in a cpo we recover the original partial order in the above way from the Scott topology. Now here is the connection between Vietoris’ ideas and ours:

Exercise 99. Let D be a cpo. Let ⊑_{S}, ⊑_{R}, ⊑_{EM} be defined as above on the collection of P(D) of all subsets of D removing any restriction to nonempty sets or ω-algebraic cpos. Regarding D as also being a topological space via the Scott topology show that:

(1) ⊑_{U} = ⊑_{S},

(2) ⊑_{L} = ⊑_{R},

(3) ⊑_{V} = ⊑_{EM}. Perhaps we should speak of the Egli-Milner-Vietoris ordering!

Just as we did with cpos, one normally works with the various topologies on P(X) by concentrating on particular kinds of sets e.g. closed or compact. For example metric spaces have been proposed by Nivat and his co-workers as a substitute for cpos e.g.

G. Comyn, M. Dauchet. Approximations of Infinitary Objects. ICALP ’82 and de Bakker and Zucker have used Vietoris topologies on compact subsets of metric spaces as a substitute for powerdomain in

Denotational Semantics of Concurrency. SIGACT, 1982.

We now make some connection with our powerdomains. We already know that, for example, P_{R}(D) is the partial order on the Scott-closed subsets of D derived from the lower topology. So in the sense we can derive our powerdomain from Vietoris’ ideas applied to ω-algebraic D’s and a clever choice of D’s. The converse also holds:

Exercise 100. Show that the Scott topology on P_{S}(D), P_{R}(D), P_{P}(D) are just the restrictions (to appropriate kinds of subsets) of the upper, lower and Vietoris topologies.

Exercises

Finally here are some exercises on miscellaneous topics.

Exercise 101 The Empty Set. This is a variation on powerdomains where one asks for an empty set, considering semilattices with a constant ∅ satisfying the law:

∅ ∪ x = x

and considering linear maps preserving ∅. Clearly in semilattices satisfying the “relational inequality”: x ∪ y ⊒ x, we must have ∅ = ⊥ and P_{R}(D) is the powerdomain we want, as shown by Theorem 2 restricted to strict functions, noting that here the strict linear maps also preserve ∅.

(1) The Plotkin Powerdomain. The situation here is a little curious. First show that for any ωalgebraic D →^{inr∘{·}_{P}} {∅}_{⊥} + P_{P}(D) is a strict continuous function such that any strict continuous f: D→A (where A is a continuous semilattice with ∅) has a unique strict, linear, continuous extension f^{†}: {∅}_{⊥} + P_{P}(D) → A. Second show that there is no continuous ε: D → P (a continuous semilattice with ∅) such that any other continuous f: D→A (a continuous semilattice with ∅) has a unique linear continuous extension f^{†}: P → A. [Hint Begin by proving that if it exists P must be {∅}_{⊥} + {1}_{⊥} when D = {1}_{⊥}.] You should also see why the natural candidate {∅}_{⊥} + P_{P}(D)_{⊥} does not work.

(2) The Smyth Powerdomain. Here everything goes smoothly. In semilattices satisfying “Smyth inequality”: x ∪ y ⊑ x we clearly have ∅ as the top element (since x = ∅ ∪ x ⊑ ∅). For any cpo D let D_{⊤} be D with a top element added and let D → D_{⊤} be the natural (anonymous) inclusion. Show that for any ω-algebraic D →^{{·}_{S}} →P_{S}(D) → P_{S}(D)_{⊤} is a (strict) continuous function such that any (strict) continuous f: D → A (where A is a cpo with a continuous meet and a top element) has a unique (strict) continuous, multiplicative, top-preserving extension f^{†}: P_{S}(D)_{⊤} → A.

Exercise 102 Bistrict Union. This is a variation where we ask for union to be bistrict so that

x ∪ ⊥ = ⊥ ∪ x = ⊥.

Clearly this is inconsistent with the relational cases, as then ⊥ = x ∪ ⊥ = x. Also it is implied in the Smyth case as x ∪ ⊥ = x ⊓ ⊥ = ⊥. So only the Egli-Milner case remains and variations with and without the empty set are possible.

(1) Show that for any ω-algebraic D there is a strict continuous ε: D → P (a continuous semilattice with bistrict union) such that any strict continuous f: D→A (a continuous semilattice with bistrict union) has a unique strict continuous linear extension f^{†}: P → A. Note what P is when D is flat. Show that all of this becomes false if the strictness qualifications are omitted. [Hint Consider D = ¶ and prove that if it exists then P = ¶.]

(2) Show that for any ω-algebraic D there is a strict continuous ε: D→P (a continuous semilattice with ∅ and bistrict union) such that any strict continuous f: D → A (a continuous lattice with ∅ and bistrict union) has a unique strict continuous linear extension f^{†}: P → A. And show all of this becomes false if the strictness condition is removed.

Exercise 103 Multisets — an Open Problem. Investigate multiset constructions M(D) where the appropriate laws are:

Associativity  x ∪ (y ∪ z) = (x ∪ y) ∪ z,
Commutativity  x ∪ y = y ∪ x

and one is considering M(D) as a free abelian semigroup. In this setting the convexity phenomena in powerdomains do not arise and the theory may well be very pleasant. This should be an interesting and straightforward problem.

Exercise 104 Cartesian Products and Multilinear Functions. Show the Cartesian product gives a continuous bilinear (= linear in each argument) function ×: P_{P}(D) × P_{P}(E) → P_{P}(D × E) and that satisfies the formula

{d}_{P} × {e}_{P} = {⟨d, e⟩}_{P}.

[Hint Establish that the product of fg sets is fg and that the formula X^{∗} ×Y^{∗} = (X ×Y)^{∗} holds for arbitrary sets.] Now show that this classifies the bilinear continuous functions in that to any such f: P_{P}(D)×P_{P}(E)→A such that the following diagram commutes:

[figure: P_{P}(D × E); A; g; f; P_{P}(D) × P_{P}(E); ×]

Also conclude that any continuous f: D × E → A has a unique bilinear continuous extension f^{†}: P_{P}(D) × P_{P}(E) → A.

Now carry this exercise on the Smyth powerdomain and redo Exercise 34 in the same style.

Exercise 105 Collapsing Morphisms. Find formulae for the natural functions α_{S}: P_{P}(D)→P_{S}(D) and α_{R}: P_{P}(D) → P_{R}(D) (the extensions of {·}_{S}, {·}_{R} to strict linear function on P_{P}(D)). Note that α_{S} and α_{R} are onto. Show that there are no such extensions β_{S}: P_{S}(D) → P_{P}(D), β_{R}: P_{R}(D) → P_{P}(D) of {·}_{P}.

Exercise 106 Computability. Show that P_{S} is a computable functor over the effectively given domains of Chapter 7 and show along the way that all associated functions are computable including Cartesian product. The same can be done for P_{P} but first one must set up a computability theory for SFP. This has been done by A. Kanda.

¶ Editorial Note: These seem to be intentionally left blank by the author.

Exercise 107 Arbitrary CPOs. It is possible to find powerdomains of arbitrary cpos. For example let D be a cpo. Let P be the preorder given by:

P = ⟨finite nonempty subsets of D, ⊑_{EM}⟩.

Then we can take P(D) = P̃ the completion keeping existing lubs given in Exercise 7, p. 63, Chapter 6. Show that in this way one obtains the free continuous semilattice over D. This would have provided another approach to powerdomains that would have been much more general but would have been even more abstract than the approach adopted.