Towards an Override in Topoi

Models of software systems are built in Z and VDM using partial functions between sets and certain operations on these partial functions : extension (⊔), restriction (◃), removal and override (†). Can these operations be given a categorial semantics? Doing so will show the 'nature' of the operations. The operation of override is found to depend on the 'shape' on X, the poset PX. The operations are developed in an elementary topos E. This is achieved by constructing each operation in the topos Set, of sets and total functions, and then using these constructions as the definition of the operations in an elementary topos. Each of the operations is thus given a categorical semantics. As an example the operation of override is considered in the topos Set↓, of total functions and commuting diagrams. Can models of software systems be built in topoi other than Set?


Prologue
The VDM (Jones 1990) and Z (Spivey 1992) notations have been used widely in the specification and development of software systems.These methods share with the Irish School of Constructive Mathematics (M ♣ C ), of which the Irish School of the VDM (VDM ♣ ) (Mac an Airchinnigh 1990; Mac an Airchinnigh 1991; Mac an Airchinnigh 1993) is a part, a collection of mathematical operations: extend, restriction, removal and override.These operations are fundamental for modelling dynamically varying systems (Hughes and Donnelly 1998;Hughes and Pahl 1997;Poppleton 1997).We would like to give a categorical semantics to these operations.
Let us start by considering the operation of 'overriding' or overwriting a total function f : X → Y between two sets X and Y by the partial function [x → y] where x ∈ X and y ∈ Y, the resulting function f † [x → y] will have the existing value of x in the function f replaced by the 'new' value y.Historically, the override operator was introduced to give meaning to the assignment statement of programming languages.
Can we express the overriden function in terms of composition alone?In other words does the determination problem or choice problem (Lawvere and Schanuel 1997, page 45)  G G Y This choice problem will only have a solution if When this is true h = 1 X † [x → x ], where 1 X denotes the identity function on the set X and x ∈ f −1 ({y}).Thus, in general we can not use composition in these ways to construct the operation of override.
Override can be defined in terms of removal ( −) and extension ( ).If X α Y and X β Y are two partial functions between the sets X and Y then α † β = − dom β α β.
Hence, override depends on the shape on X, the poset PX.
X = {r, g, b} {r, g} ∅ f f w w w w w w w w w w w w y y V V q q q q q q q q q q q q Removal depends also on the shape on X.

A B
(A\B) ỳ y y y y y y y y (A ∩ B) q q q q q q q q q Y Y w w w w w w w w w We are thus led deeper into category theory to find a solution . . .

Categorial Preliminaries
Category theory (Lane 1971) was founded by S. Eilenberg and S. Mac Lane in 1945 and came from their work in algebraic topology.Today category theory is influencing many parts of theoretical computer science (Barr and Wells 1995;Walters 1991).This section is inspired by Robert Goldblatt's (Goldblatt 1984) exceptional book.
In set theory, the most primitive concept is element.Sets are built out of elements, also tuples, functions, and other mathematical structures are just different kinds of sets.In category theory the most primitive concept is arrow.Each arrow has a source and target object.The internal structure of these objects is ignored.The properties of an arrow are described in terms of composition with other arrows.
A category C comprises 4. an operation assigning to each pair f, g of C-arrows with dom g = cod f , a C-arrow g • f , the composite of f and g, having dom(g • f ) = dom f and cod(f • g) = cod g, and such that the following condition obtains: Associative Law: Given the configuration The category Set has sets as objects and total functions between sets as arrows.Composition of arrows is settheoretic function composition.Identity arrows are identity functions.

The category Set
• ↓ • of functions has as objects the set functions is the function pair 1 X0 , 1 X1 .

Monic Arrows
An arrow The symbolism f : a b is used to indicate that f is monic.In the category Set, the monic arrows are just the injective functions.
2nd Irish Workshop on Formal Methods, 1998

Iso Arrows
In the category Set, the iso arrows are just the bijective functions. A

Isomorphic Objects
Object a and b are isomorphic in C denoted a ∼ = b, if there is a C-arrow f : a → b that is iso in C.

Initial Object
An object 0 is initial in category C if for every C-object a there is one and only one arrow from 0 to a in C.
In the category Set the empty set ∅, also denoted 0, is the unique initial object: for every set S, the empty function is the only function from 0 to S.

Terminal Object
An object 1 is terminal in a category C if for every C-object a there is one and only one arrow from a to 1 in C. Each one-element set is a terminal object in Set, since for every for every set S there is a function from S to a one-element set {0}, also denoted 1, mapping every element of S to 0, and this is the only total function from S to 1.

In the category Set
• ↓ • the terminal object is the identity function

Products
A product in a category C of two objects a and b is a C-object a×b together with a pair pr a : a×b → a, pr b : a×b → b of C-arrows, called projection arrows, such that for any pair of C-arrows of the form Dashed arrows in commutative diagrams are used to represent arrows that are asserted to exist uniquely when the rest of the diagram is filled in appropriately.
In the category Set, the product of two sets X and Y is there cartesian product set with the pair of projection functions given by the rules pr X ( x, y ) = x and pr Y ( x, y ) = y.
The product of the Set , and is the function with the function pairs pr X0 , pr X1 , pr Y0 , pr Y1 as projections.

Co-products
In Set, the co-product of X and Y is their disjoint union given by the rules i X (x) = x, 0 and i Y (y) = y, 1 .
The co-product of the Set , and is the function with the function pairs i X0 , i X1 , i Y0 , i Y1 as injections.

Pullback
In Set, the pullback with f and g as the projections f ( x, y ) = x and g ( x, y ) = y.

Exponentiation
In Set, the exponentiation of the sets X and Y is the set Y X of all functions with domain X and codomain Y Y X = {f : X → Y} with the evaluation function ev : Y X × X → Y given by the rule
2nd Irish Workshop on Formal Methods, 1998

Cartesian Closed Category
A cartesian closed category C is a category with 1. a terminal object 1.
2. products, that is, a product object a × b for every pair of C-objects a and b.

exponentiation.
The categories Set and Set • ↓ • are cartesian closed.

Subobjects
The concept of subobject or part of a C-object d has two ingredients: 1. a part has a shape, a C-object a.
2. a monic arrow f : a d from the shape of the part to the object d which determines how the shape a is inserted into the object d.
A subobject of a set X in the category Set with shape S is an injective function f : S → X.This function determines a subset of the set X the image of f by Im f = {f (x): x ∈ S}.The function f induces a bijection between S and Im f , so S ∼ = Im f .There is an inclusion function from the image of f into the set X, denoted Im f → X.Thus in Set a subobject of a set X can be identified with a subset of X and an inclusion function from this subset into the set X.
given by the commutative diagram where i and j are injective functions.As i and j are injective functions we can identify them with inclusions, so that S 0 ⊂ X 0 , S 1 ⊂ X 1 and f is the restriction of g, that is, f (x) = g(x) for x ∈ S 0 .

Subobject Classifier
If C is a category with terminal object 1, then a subobject classifier or truth-value object for C is a C-object Ω together with a C-arrow true : 1 → Ω that satisfies the following axiom.Ω-axiom.For each monic f : a d there is one and only one C-arrow If the set S is a subobject of the set X in Set then we have the inclusion S → X.An element x of X can be classified now in two ways.Either 1. x ∈ S, or 2nd Irish Workshop on Formal Methods, 1998 Towards an Override in Topoi 2. x ∈ S.
So we introduce the 2-element set {0, 1}, denoted 2, and define χ S : X → 2 as We can now form the square where true(0) = 1.The subobject classifer for Set is the function true from 1 to 2. The diagram is a pullback square in Set.Thus, a part S → X of a set X has a characteristic function χ S : X → 2.
Consider the category Set will be the inclusion where S 0 ⊆ X 0 , S 1 ⊆ X 1 , and h(x) = f (x) for x ∈ S 0 .An element x of X 0 can be classified now in three ways.Either So we introduce a 3-element set {0, 1, 2}, denoted 3, and define Ψ: X 0 → 3 by We can now form the cube e e e where true(0) = 1, t (0) = 2 and where t(2) = t(1) = 1 and t(0) = 0.The base of the cube displays the subobject classifer • , which is the pair t , true .The front and back faces of the cube 2nd Irish Workshop on Formal Methods, 1998 are each pullbacks in Set.The whole diagram exhibits

Topoi
It is a category whose structure is sufficiently like Set that in it the interpretations of basic set-theoretical constructions behave much as they do in Set itself.

The categories Set and Set
• ↓ • are topoi.Why is topos theory useful to us?
• The 'natural logic' in a topos is intuitionistic logic.

• Intuitionistic logic fits naturally with the School of Constructive Mathematics.
• There is no conflict with 'classical continuous' Mathematics.
What more could we ask for in Computer Science?

Towards Override on Partial Arrows between Objects in a Topos
We wish to generalize the basic operations: extend, removal, restriction and override to topoi.To achieve this we must construct each of the operations in the topos Set and use these constructions as the definitions of the operations in a topos E. In doing this we will have given a categorical semantics to the operations.
Towards an Override in Topoi

Partial Functions and Partial Arrows
In the topos Set a partial function f from a set A to a set B, written f : A B, is a function from a subset of A to B i.e. dom f → A and f : dom f → B. In a topos E a partial arrow f from an object a to an object b, written f : a b, is a E-arrow f : dom f → b, and there is a E-monic dom f a, see Goldblatt (Goldblatt 1984, page 267).

Extend in Set and E
Given two partial functions f : A B and g : A B from a set A to a set B in the topos Set, where the two partial functions have disjoint domains, i.e. dom f ∩ dom g = ∅, then we can extend the partial function f by the partial function g, written f g : A B. This extension is the pair of co-product functions [f, g] : dom f dom g → B of functions f and g, and also [i 1 , i 2 ] : domf dom g → A of the inclusion function i 1 : dom f → A and i 2 : dom g → A. The co-product in Set is the disjoint union of two sets, but dom f dom g ∼ = dom f ∪ dom g when dom f ∩ dom g = ∅.
Hence, when we have the disjointness condition the co-product diagram in Set becomes g g y y y y y y y y y y y y

B
We would like to define in a general topos E the extension of one partial arrow f : a b by another partial arrow g : a b.To achieve this we must generalize the disjoint domains condition to a topos.In Set the diagram is a pullback square precisely when dom f ∩ dom g = ∅.Thus, in a general topos E we define the disjointness condition to be when the diagram is a pullback square in E, see Goldblatt (Goldblatt 1984, page 199).Given two partial arrows f : a b and g : a b with this condition we define their extension, written f g : a b, to be the pair of co-product arrows [f, g] : dom f + dom g → b of arrows f and g, and also [m, n] : dom f +dom g → a of subobjects m : dom f a and n : dom g a, which are given by the partial arrows f : a b and g : a b a Irish Workshop on Formal Methods, 1998

Restrict in Set and E
In Set if we have a partial function f : A B from a set A to a set B and we have a subset S of A then we can restrict the partial function f by the subset S of A, written S f : A B. This restriction is the pair of composite functions j, k in the diagram If in a topos E we have a partial arrow f : a b from an object a to an object b and we have a subobject n : s a of object a, then we can form the intersection of the subobjects m : dom f a and n : s a.To do this we form the pullback of m : dom f a and n : s a The composite arrow m ∩ n = m • j = n • k is the intersection of the subobjects m and n.We can then define the restriction of the partial arrow f : a b by the subobject n : s a, written n f : a b, to be the pair of composite arrows in the diagram

Removal in Set and E
In Set if we have a partial function f : A B from a set A to a set B and we have a subset S of A then we can remove the subset S of A from the partial function f , written − S f : A B. This removal is the pair of composite functions j, k in the diagram How can the set dom f \ S be characterized?The set dom f \ S is the only subset of the set dom f which satisfies the equations These equations must be presented categorically if we wish to generalize the operation of removal to a topos.
2nd Irish Workshop on Formal Methods, 1998 If in a topos E we have a partial arrow f : a b from an object a to an object b and we have a subobject n : s a of object a, then to form the removal of the subobject n : s a from the partial arrow f : a b, written − n f : a b, we must find a subobject l : dom f \ s dom f of the object dom f which has two properties: 1. composing the subobject m : dom f a, which is given by the partial arrow f : a b, after the required subobject l : dom f \ s dom f to form a subobject m • l : dom f \ s a of a, this subobject must be disjoint from subobject n : s a, i.e. the diagram 2. the co-product arrow [l, j] : dom f \ s + dom f ∩ s → dom f of the required subobject l : dom f \ s dom f of object dom f and the subobject j : dom f ∩ s dom f , formed from the intersection of the subobjects m : dom f a and n : s a, see above, must be an E-iso, i.e. the arrow [l, j] from the diagram If such a subobject l : dom f \ s dom f exists then we can define the removal of the subobject n : s a from the partial arrow f : a b, to be the pair of composite arrows in the diagram

Override in Set and E
Given two partial functions f : A B and g : A B from a set A to a set B in the topos Set, then we can override the partial function f by the partial function g, written f † g : A B. This is the partial function formed by the expression − dom g f g.This expression is always defined in the topos Set because we can always form the removal of the subset dom g of A from the partial function f , i.e. the partial function − dom g f : A B. If in a topos E we have two partial arrows f : a b and g : a b from an object a to an object b and we can form the removal of the subobject n : dom g a, which is given by the partial arrow g : a b, from the partial arrow f : a b, i.e. the partial arrow − n f : a b, then we can override the partial arrow f by the partial arrow g, written f † g : a b, this is the extension of the partial arrow − n f by the partial arrow g.We may perform this extension because the partial arrow − n f will be disjoint from the partial arrow g by definition.
2nd Irish Workshop on Formal Methods, 1998

Consider the Set
given by the picture : , given by the inclusion given by the picture : Let us look at the combined picture : Thus, the pair α 0 †β 0 , α 1 †β 1 is not a Set .We have the subobject inclusions given by the picture : We can now define a Set There may be choices for β.The following picture defines β and shows α again : Now the pair α 0 † β0 , α 1 † β1 will be a Set • ↓ • -arrow.

Epilogue
The basic operations: extend, restriction, removal and override have been introduced to topoi and hence given a categorical semantics.There are many questions yet to answer: • can override be defined by universal properties?
• in which topoi can a subobject n : s a of topos object a be removed from a partial arrow f : a b between objects a and b?, • if PA(a, b) denotes the collection of all partial arrows f : a b between objects a and b, and override is defined for each pair of partial arrows in PA(a, b) then does collection PA(a, b) with the operation override form an algebraic structure?For example, in the topos Set the collection of partial functions between two sets with the operation override forms a monoid (Mac an Airchinnigh 1990, page 99), • in the topos Set the operations have many inter-relationships, e.g. if S is a subset of set A and f : A B is a partial function between sets A and B then In which topoi do these relationships hold?
There are many directions now opened up for future development: 2nd Irish Workshop on Formal Methods, 1998 have a solution?Consider first the determination problem Y g? Towards an Override in Topoi When this is true g = 1 Y † [f (x) → y], where 1 Y denotes the identity function on the set Y. Now consider the choice problem X

2nd
Irish Workshop on Formal Methods, 1998 1. a collection of things called C-objects; 2. a collection of things called C-arrows; 3. operations assigning to each C-arrow f a C-object dom f the domain of f and a C-object cod f the codomain of f .If a = dom f and b = cod f then we display this as f : a → b or a f → b;

5
. an assignment to each C-object b of a C-arrow 1 b : b → b, called the identity arrow on b, such that Identity Law: For any C-arrows f : a → b and g : b → c

A
category C has exponentiation if it has a product for any two C-objects, and if for any given C-objects a and b there is a C-object b a and a C-arrow ev : b a × a → b, called an evaluation arrow, such that for any C-object c and C-arrow g : c × a → b, there is a unique C-arrow ĝ : c → b a making b a × a ev 4 4