To understand domain and pointed cpo we first need to understand:
We'll find out that every domain is a cpo, and some are pointed. Once we understand all that, we'll go on to define continuous functions.
A partially ordered set (poset) consists of:
Some posets have a least element ⊥ (bottom), and some posets have a
greatest element "top".
Some pairs of elements have a "least upper bound" (lub) or "join"
(denoted here by U) and defined as follows:
Some pairs of elements have a "greatest lower bound" (glb) or "meet"
(denoted here by M), defined similarly.
Complete the definition for the meet operation.
Join and meet can be defined for sets as well as pairs.
Given X a subset of D, U(X) = z (i.e., the join over all elements
in set X is z) iff both of the following hold:
Note that z must be in D, but not necessarily in X.
Meet over a set is defined similarly.
Digression:
For the purposes of dataflow analysis, we are interested in lattices,
which are posets in which every pair of elements has both a join
and a meet.
Furthermore, a lattice is complete iff every subset of elements
has both a join and a meet (including infinite subsets if D is infinite).
End digression.
Let's look at some example sets and orderings,
and decide for each whether it is
a partially-ordered set, a lattice, or a complete lattice.
In each case, we use a picture to show the ordering;
a vertical line up from an item x to an item y means that x ⊆ y;
a horizontal line from x to y means that x ⊆ y and y ⊆ x.
Example 1: Some English words, ordered by "is a substring of".
Example 2: Some English words ordered by length
Example 3: Integers ordered by the usual "less than or equal to" ordering.
Example 4: The set of integers plus special top and bottom elements,
ordered as follows:
Given a partially-ordered set (D, ⊆), a subset X of D
is a chain iff ∀ a, b in X, either (a ⊆ b)
or (b ⊆ a).
Note that a chain can be finite or it can be infinite.
If a chain is finite, then it has both a least-upper and a
greatest-lower bound (in D);
however, this is not necessarily true if the chain is infinite.
For example, let D be the set of integers with their normal ordering.
The positive numbers form a chain that has no limit (no least upper
bound, no join) in D.
Definition:
A partially-ordered set (D, ⊆) is a complete partial order
(cpo) iff every chain in D has a least upper bound (in D).
Definition:
A partially-ordered set (D, ⊆) is a pointed cpo iff
it is a cpo and it has a least element (⊥).
Let's take a minute to consider the relationship between complete lattices,
complete partial orders, and pointed cpos.
Recall that for a complete lattice, every subset X of D has both a
meet (a greatest lower bound) and a join (a least upper bound), while
for a cpo, every chain has a least upper bound
This means that every complete lattice is a cpo, but not vice versa:
since in a lattice every subset has a least upper bound, and
every chain is a subset, it must be that every chain has a least upper
bound;
however, in a cpo there is no guarantee that even pairs of elements,
much less subsets, have a greatest lower bound, and there is no
guarantee that non-chain subsets have a least upper bound.
Similarly, every complete lattice is a pointed cpo, but not vice versa.
In a lattice every subset has a greatest lower bound;
since D itself is a subset of D, that means there is a greatest lower
bound for the whole set; i.e., it has a bottom element (which is what
is required for a pointed cpo beyond what is required for a cpo).
However, pointed cpos don't guarantee pairwise-meet or pairwise-join,
so they are not necessarily lattices, much less complete ones.
Recall that we started looking at partial orders because we wanted
to define domain (because that's what showed up in the
"amazing fact" about fixed points).
We're finally ready to define domains.
Every domain is a cpo.
Below are some (common) cpo constructors (i.e., ways to build
new domains out of simpler ones).
These are clearly cpos (every chain is of length 1), but are not pointed.
These are pointed cpos.
Here are some examples of lifted domains:
where ⊆D1xD2 is defined to be:
Note that the elements of D1 x D2 are pairs, with the first element from D1 and
the second from D2.
CLAIM 1: if D1 and D2 are cpos then so is D1 x D2.
PROOF: We must show that ⊆D1xD2 is reflexive,
anti-symmetric, and transitive, and that
all chains have least upper bounds.
The first part is left as an exercise; the second is done below.
In the proof, the symbol ⊆ is used without subscripts;
sometimes it means ⊆A, sometimes it means
⊆B, and sometimes it means ⊆D1xD2;
however, which it is should be clear from the context.
Chains in D1 x D2 are of the form:
such that, ∀ j: aj ⊆ aj+1 and
bj ⊆ bj+1.
Since D1 and D2 are cpos, there exist (x in A) and (y in B)
such that: x = lub of the ajs, and
y = lub of the bjs.
The element (x, y) of D1 x D2 is certainly an upper bound for the
(aj, bj) chain; we
must now show that is it the least upper bound.
We will do that by contradiction; i.e., we will assume that it is not
the least upper bound and show that leads to a contradiction.
If (x, y) is not the least upper bound for the
(aj, bj) chain, then
there is some (v, w) such that:
But then ∀ j, (aj ⊆A v) and
v ⊆A x, so x is not the
lub of the ajs, which
contradicts our assumption.
Complete the proof that D1 x D2 is a cpo by showing that
⊆D1xD2 is reflexive, anti-symmetric, and transitive.
CLAIM 2: if D1 and D2 are pointed cpos (with least elements
⊥A and ⊥B)
then D1 x D2 is also pointed, with least element
(⊥A, ⊥B).
Note: It is not necessary to "lift" D1 x D2 to get a pointed cpo.
Lifting D1 x D2 would produce a pointed cpo, but it would be
a different one:
the least element of D1 x D2 is the pair
(⊥A, ⊥B), while
the least element of Lift(D1 x D2) is a new element, ⊥, which
is ⊂ (⊥A, ⊥B).
where the numbers 0 and 1 are "tags" that tell where the element came from
(so if there is some x in both A and B, there will be two
elements in D1+D2: (0,x) and (1,x)).
The ordering ⊆A+B is defined as follows:
(1,b1) ⊆A+b (1, b2) iff
(b1 ⊆B b2)
all other elements are incomparable
CLAIM: if D1 and D2 are cpos then so is D1+D2.
The proof is left to you!
Note that D1+D2 is not pointed even if both D1 and D2 are (because
⊥A is not less than any item (1, *), and
⊥B is not less then any item (0, *)).
(we will define continuous functions soon!)
where ⊆A→B is defined as follows:
Caution: Remember that all domains are built starting with primitive
domains, which have flat orderings.
So f1 ⊆A→B f2
really comes down to "f1 is less defined than
f2".
If you think of a function as a set of ordered pairs (with
no pair for an element x that is mapped to bottom),
then f1 ⊆A→B f2
iff f1's set of pairs is a subset of f2's
set of pairs.
Here are some examples to illustrate ordering of functions.
f1(x) = x - 1
It is not true that f1 ⊆ f2;
they are both defined for the same set of inputs (all integers).
The fact that f1(x) is less than f2(x)
using the usual "less than" for integers is irrelevant;
the ordering that is relevant is the flat ordering, according to
which no two integers are comparable.
So f1(x) and f2(x) are not comparable, and
neither are f1 and f2 themselves.
f1(x) = if x <= 0 then ⊥ else x
Comparing f1 and f2 element-wise we have:
In this example, it is true that
f1 ⊂ f2,
because everywhere that f1 produces a value
other than ⊥ it produces the same value as f2,
and there are some places where f1 produces ⊥
while f2 produces non-⊥.
f1(x) = if x = 0 then ⊥ else x
In this example, it is not true that
f1 ⊆ f2, because different,
non-⊥ values are not comparable.
Partially Ordered Sets
Note that the ordering is "partial" (not total) because in general
there can be elements x, y in D that are incomparable.
x U y = z iff
Note that (1) says that z is an upper bound, and
(2) says that it is the least upper bound.
x M y = z iff ...
Examples
candycane
/ \
cane candy there then
\ / \ / \ / \
can and here the hen
\ / \ | /
an \ | /
he
This ordering is reflexive, anti-symmetric, and transitive, so
this is a poset.
However, not all pairs have a meet and join (e.g., and,
here) so this is not a lattice.
candy
/ | \
/ | \
can - the - hen
\ | /
\ | /
an
In this case, the ordering is reflexive, but not anti-symmetric
(e.g., can ⊆ the ⊆ can, but
can != the)
so this is not a poset (so it is certainly not a lattice).
.
.
.
2
|
1
|
0
|
-1
.
.
.
This ordering is reflexive, anti-symmetric, and transitive, so this is
a poset.
All pairs do have a meet (min) and a join (max), so this is also a lattice.
However, not all subsets have a meet and a join (all finite subsets
do have a meet and a join, but some infinite subsets do not;
e.g., the set of all positive integers has no join) so this
is not a complete lattice.
top
/ / \ \
... -2 -1 0 1 ...
\ \ / /
bottom
This is called a flat ordering, and
this example is a poset, a lattice, and a complete lattice.
Complete Partial Order (cpo)
Pointed CPO
Domain
B⊥ = ({true, false, ⊥}, true, false incomparable to each other, both ⊃ ⊥)
N⊥ = ({⊥,0,1,2,...}, all numbers incomparable to each other, all ⊃ ⊥)
({(a,b) | (a in A) and (b in B)}, ⊆D1xD2)
(a1, b1) ⊆D1xD2
(a2, b2) iff
(a1 ⊆A a2)
and (b1 ⊆B b2)
... ⊆ (ak, bk) ⊆
(ak+1, bk+1) ⊆ ...
( {(0,a) | a in A} union {(1,b) | b in B}, ⊆A+B)
(0,a1) ⊆A+B (0, a2) iff
(a1 ⊆A a2)
({continuous functions with domain A and co-domain B},
⊆A→B)
f1 ⊆A→B f2 iff
∀ a in A: f1(a) ⊆B f2(a)
f2(x) = x + 1
f2(x) = if x == 0 then ⊥ else x
f1: ... (-1, ⊥) (0, ⊥) (1, 1) (2, 2) ...
f2: ... (-1, -1) (0, ⊥) (1, 1) (2, 2) ...
f2(x) = if x = 0 then ⊥ else x+1
LHS | = g(lub{..., ak, ak+1, ...}) | |
= lub{..., fj(lub{...ak, ak+1, ...}), fj+1(lub{...ak, ak+1, ...}), ...}, | by def of g
| |
RHS | = lub{...g(ak, g(ak+1), ...} | |
= lub{lub{..., fj(ak), fj(ak+1), ...}, ...} | by def of g
| |
= lub{lub{fj(ak), fj(ak+1), ...}, lub{..., fj+1(ak), fj+1(ak+1), ...}, ...} | because lub is associative and commutative
| |
= lub{..., fj(lub{..., ak, ak+1, ...}), fj+1(lub{..., ak, ak+1, ...}), ...} | because all of the f's are continuous |
CLAIM: if D1 and D2 are both pointed cpos, then so is D1 → D2
PROOF: The function λa. ⊥B (where "⊥B" is the ⊥ element from D2) is of type A → B, and is continuous, and is ⊆ all other functions in D1 → D2 (since ⊥B is ⊆ all other elements in B). Therefore, that function is in D1 → D2, and is its least element.