Equations for terms are alpha-conversion plus:
let P = M; P | = | M | |
let P = P; M | = | M | |
(D D') M | = | D (D' M) | |
D let P = M; M' | = | let P = (D M); M' | (bv D ![]() |
D (M M') | = | (D M) M' | (bv D ![]() |
D (M1,...,Mn) | = | (D M1,...,D Mn) |
Equations for declarations are alpha-conversion plus:
let P = (D P) | = | D | (bv P = bv D) |
let (P1,...,Pn) = (M1,...,Mn); | = | let P1 = M1;...; let Pn = Mn; | (bv Pi ![]() |
(D; D'); D'' | = | D (D' D'') | |
D () | = | D | |
() D | = | D | |
D D' | = | D' D |
(bv D ![]() ![]() |
We shall write `
M =
M' : T in val' and `
D = D' : T in val' for the typed proof system given by the above
axioms.
Let val be the category with:
viewed up to alpha-conversion and provable equality.
is given by let-binding:
where x is the vector x1...xn, and T is the vector T1...Tn.
The category val has finite products, with (using alpha-conversion to avoid variable name clashes):
is given by pairing:
We shall now give a graphical presentation of a cartesian closed category, which allows us to draw data-flow diagrams for programs in val. These graphs are acyclic flow graphs, with edges labelled by base types and nodes labelled by constructors. These are described more formally in an appendix.
The symmetric monoidal structure is drawn:
Identity: | Composition: |
Tensor: | |
Symmetry: | |
The product structure is drawn:
Diagonal: | |
Terminal: | |
We can now present the axioms of a category with finite products in graphical form. First, we present the symmetric monoidal axioms, all of which are graph isomorphisms.
Left unit: | = | ||
Right unit: | = | ||
Associativity: | = | ||
Functoriality of tensor wrt identity: | = | ||
Functoriality of tensor wrt composition: | = | ||
Symmetry is an iso: | = | ||
Symmetry is natural: | = |
As well as the symmetric monoidal category axioms, we have diagonal and terminal natural transformations, so the category has finite products. The coherence conditions are multigraph isomorphisms:
Symmetry respects diagonal 1: | = | ||
Symmetry respects diagonal 2: | = | ||
Terminal repsects diagonal: | = |
The naturality conditions for the product structure are not multigraph isomorphisms, but are bisimulations (as discussed in an appendix):
Diagonal is natural: | = | ||
Terminal is natural: | = |
local rec x; let y:T = x; let x:T = M | = | let y:T = M | (x ![]() |
(local rec x; D) D' | = | local rec x; (D D') | (x ![]() |
D (local rec x; D') | = | local rec x (D; D') | (x ![]() |
local rec x; local rec y; D | = | local rec y; local rec x; D |
The recursive structure we have added allows us to find fixed points in
val, on objects from proc.
This is a familiar story to domain theorists, where it is common to
find fixed points on (non-strict) Cpo morphisms on
(pointed) Cpo objects.
To give a categorical account of recursive declarations, we borrow
Hasegawa's presentation of recursive
declarations, adapting Joyal, Street and
Verity's traced monoidal structure. However, there is a crucial
difference between our presentation and Hasegawa's: we are considering
call-by-value semantics (such as
the Cpo example above) where
Hasegawa is considering call-by-name. The call-by-value category
Cpo
has smash product as its
monoidal structure, so does not support a trace, whereas the call-by-name
equivalent has non-strict product, and so does support a trace.
A trace on a symmetric monoidal category is given by a natural transformation:
satisfying certain axioms. For example, Hasegawa shows that the category of pointed cpos with non-strict product has a trace given by fixed points.
As noted above, the category Cpo
(of pointed cpos with smash product) does not have a trace, since the
obvious fixed-point construction is the trivial one, since the fixed point
of any strict map is the constant bottom map, and smash producting bottom
with any other map yields bottom. Thus the attempt to duplicate Hasegawa's
construction in the call-by-value case yields the constant bottm natural
transformation, which fails to satisfy the trace axioms.
We need to generalize the trace construction to include cases such as
Cpo, and fortunately there is
an obvious such generalization.
Given a symmetric monoidal category C with a
full subcategory (not necessarily symmetric monoidal) TC
a partial trace is a natural transformation:
satisfying certain axioms (given in an appendix).
Adding local rec declarations gives the syntactic category val a partial trace (where TC is the full subcategory of traceable types) where the trace of
is given by a local rec declaration:
This trace is partial because of the condition that T has to be traceable.