1. Introduction
Allegories, introduced by Freyd and Scedrov [
1], are enriched categories modeled upon the category of sets and binary relations,
, in such a way that allows for other realizations of allegorical axioms than
, while still preserving many of the useful
properties. This is similar to the way in which toposes generalize the category,
, of sets. For a logician, allegories can be seen as the generalizations (with some axioms relaxed) of the relation algebra [
2]. Because of the deep relationship between relational databases and relational algebra and also a lively research program of using category theory for conceptual modeling (see e.g., [
3,
4,
5,
6,
7,
8,
9,
10]), it is surprising that allegories were hardly ever used for database modeling. The use of allegories for this purpose was suggested in [
9], and recently, the new allegorical data model was introduced by the authors in [
11]; barring that, the authors were unable to secure more references.
In the majority of works applying category theory to conceptual database modeling, the arrows in a category are interpreted as functional dependencies. While this approach was successfully used, e.g., in tackling the view update problem ([
12,
13]) and in the treatment of incomplete data ([
14]), the advantage of using the allegories instead of plain categories is that they furnish interpreting the arrows as arbitrary binary relationships (including non-functional ones), and makes the use of auxiliary constructs, like spans or power sets, unnecessary.
Conceptual database modeling is an important part of the database design process, assisting in creating better database schema and applications and also isolating the designer from the technical details of a particular database technology, which might be relational, object-oriented, XML,
etc. One of the rationales for using category theory (and allegories, in particular) for conceptual modeling instead of plain first-order logic or relational algebra is that it allows one to abstract away also some ontological and logical commitments [
11]: the data model formulated in terms of an allegory can be interpreted both in the allegory of (sharp) relations, but also in some allegory of fuzzy relations; thus, the database designer can, to some extent, free herself from the dependence on the particular choice of logic.
A desired feature of the conceptual model is the possibility of extending the model to increase its expressivity, when such a need arises. An example of such an extension is adding the modalities and many world interpretations, useful e.g., in the context of temporal or distributed databases. A main contribution of this paper is adding support for modal operators to the allegorical conceptual data model described in [
11]. Here, we add the many world semantics to the model using only the language of allegories. This means that we are doing it independently of a concrete allegory; we can do it, e.g., for both sharp and fuzzy relations.
For both the allegorical model to be useful and the introduction of many worlds semantics to be possible requires more structure than provided by the plain allegories. A structure we work with here and which we conjecture to be minimal is that of a complete distributive allegory with all relational products (which are just products in the subcategory of maps). Our sentences are equalities between type safe terms formed using language of these categories. In particular, when our model is interpreted in
, this language is sufficient to express any first-order sentence (
cf. [
2]). The specification of the model resembles the algebraic sketch (see, e.g., [
15]), but is a lot more expressive; in fact, limits and colimits in the subcategory of maps (arrows that are like total functions) are definable within our formalism (see [
1]).
The many worlds semantics of the allegorical conceptual model is introduced as the family of interpretations of the model in a family of allegories (each corresponding to the “world”), as well as a special allegory providing a kind of common interpretation and within which one can define the modal operators using only the allegorical operators, together with the structure connecting “worlds” with one another and the common interpretation.
The structure of this paper is as follows. In
Section 2, we recall some basic facts about category theory and allegories, as well as the definition (slight extension) of the allegorical conceptual model from [
11]. In
Section 3, we develop our modal extension and its semantics, and finally, in
Section 4, we give some examples of modal specifications and queries.
2. Preliminaries
We recall some basic categorical definitions in order to fix the clean, but somewhat idiosyncratic, notation we use. The bulk of this preliminaries is taken, first by introductory material on allegories, which are not widely known and for which [
1] is the basic textbook, and, then, by modified definitions of an allegorical conceptual data model from [
11].
The reader might be disturbed by our consequent use of the term “set” where “class” might be more appropriate. We do it consciously, in order not to clutter the presentation with the set-theoretical considerations. The reader should also remember that while we use the operator to compose arrows in diagrammatic order, we also denote by the composition in the assignment order (i.e., ), of any two actual maps (that is, procedures that assign values to values) whenever those maps are not used as arrows in a category.
2.1. Categories and Graphs
A graph,
, consists of a set of vertices,
, a set of arrows,
, and a pair of maps
called source and target, respectively. We denote by
the set of arrows with source
A and target
B, where
. A graph morphism
from a graph,
, to a graph,
, is a pair of maps:
such that
,
, for all
. A composition of graph morphisms is defined componentwise,
i.e.,
.
A category, , is a graph with associative arrow composition , defined whenever (note the diagrammatic order), and identity map such that for all . We write . When using single letter arrow names, we will often omit the semicolon composition operator abbreviating . A graph morphism between categories is called a functor when it maps identity arrows to identity arrows and respects composition, i.e., and .
2.2. Allegories
An allegory [
1]
is a category enriched with intersection and reciprocation operators, respectively, for all
:
We require these operators to satisfy the following conditions: Intersections make each hom-set a meet semi-lattice (see, e.g., [
16]), where we denote the associated partial order by ⊑,
i.e.,
, for all
. In addition,
and
are to satisfy:
for all
such that the above formulas are well-defined.
Allegories generalize the allegory,
, of sets (objects) and binary relations (arrows). Because of this, we may refer to arrows in any allegory as “relations”. In
, we write
iff
. The identity in
is
; intersection is the set intersection,
i.e.,
; reciprocation is defined by
; and the composition of relations
such that
is defined by:
We distinguish the following classes of arrows in allegory:
If , then R is called total.
If , then R is called functional.
If R is functional and total, it is called a map. A set of all maps in an allegory, , is denoted by: .
If , then R is called injective.
If , then R is called surjective.
A family
with a common source,
A, is called jointly monic if:
. For any maps
with target
A, if
for all
i, then
.
For any , we denote by and the top and bottom elements of , respectively, if they exist. In , we have , .
Suppose that the top element
exists. An object,
C, together with maps
(called projections on components), where the arrow
,
, is called a relational product iff:
Relational products are products in
, and they are unique up to an isomorphism. On the other hand, a product in
is not necessarily a relational product (see, e.g., [
17]). Let
be such that
,
,
. Then, the unique map,
, such that
,
can be expressed explicitly as:
In an allegory,
, there might be a canonical choice of a relational product of each
. In such a case, we denote the canonical product object by
and the projections by
and
. In
, the canonical relational product is the usual Cartesian product.
A distributive allegory is an allegory,
, in which for all hom-sets,
, there exists a bottom element,
, and a binary operation:
which together with
makes
a distributive lattice with
as the infimum and
as the supremum. In addition, we require that
and
satisfy:
for all
such the above formulae are type-correct. One proves easily that:
A locally complete distributive allegory is a distributive allegory in which each of the hom-sets is a complete lattice, and moreover, the following infinite distributive laws hold:
for any arrow
R and a family
such that the above formulas make sense. As a consequence, each of the hom-sets in a complete distributive allegory,
, is a locale (a complete lattice in which finite meets distribute over any joins) or, equivalently, a complete Heyting algebra. More precisely, the above distributivity condition implies the existence of a binary hom-set operator, →, called implication, defined uniquely by the property:
for all
R,
S and
T in the same hom-set. The implication can be expressed explicitly by the formula:
We denote for brevity
. A hom-set,
, is a Boolean algebra if and only if one of the equivalent conditions below hold for all
:
If this is the case, then
. It is immediate that
is a locally complete distributive allegory with the union defined as a set union,
i.e.,
, and in which every hom-set is a Boolean algebra where
.
It is worth noting that a locally complete distributive allegory is a division allegory [
1], that is, a distributive allegory with a partial binary operation
(called a right division), defined if and only if both arguments have the same targets, and satisfying for all arrows
R,
S and
T:
In a distributive allegory which is locally complete, the (unique) operation satisfying the above axioms is given by
. In the present paper, we do not utilize this operation, but it would be easy to extend the language of the conceptual model considered here with the right division operator, in order to increase its expressivity.
The allegorical conceptual data model introduced in [
11] requires that the allegories in which the model is interpreted contain canonical relational products of all pairs of objects and top and bottom elements in all hom-sets. Here, because the modal structure imposed on the model in this paper requires the locally complete distributive allegories anyway for the definitions to make sense, we enrich the language of specification to include unions and implications and, thus, require from the allegories in which models are interpreted to be distributive. For an easy reference, we call such allegories PTBDI (product, top, bottom distributive and containing implications) allegories. In particular,
is a locally complete PTBDI allegory.
2.3. Allegorical Conceptual Data Model
Before we can recall the definition of the model, we need first the following two auxiliary notions:
Definition 1. An extended set of objects of a graph is defined as a groupoid (i.e., a set with a binary operation ([18], Chapter V)) with operation ⊗
generated by ,
i.e., if ,
then ,
etc. Definition 2. Let be a graph. A set,
,
of allegorical terms associated to (cf. [11]) is defined as the smallest set of expressions such that: for all ,
for all objects ,
if , then ,
if are such that , then ,
if are such that and , then , and .
We omit unnecessary parentheses when writing elements of .
In the above conditions, we used the functions defined in an obvious way using induction on the structure of terms as the extension of source and target functions, i.e., ,
,
,
,
and so on, for any terms t, ,
.
We are now ready to formulate the definition of our conceptual model.
Definition 3. An allegorical conceptual data model, , consists of a finite graph, , and a finite set, , of equations of the form , where .
We write the equations of the form as . Equations allow us to specify constraints and dependencies between data elements.
Example 1. A conceptual model loosely based on an example HR database of Oracle is depicted in Figure 1 (graph ) and Figure 2 (equations ). Equation (a)
states that the arrows in the list are (total) maps; Equation (b)
states that maps ,
,
,
and are jointly monic (that is an is uniquely determined by the values of these attributes). Equation (c)
makes a linear order and transitive (it is meant as a transitive closure of the chain of commands) and irreflexive relation. The first two equations in Equation (d)
specify that is an injective map (i.e., each department has a manager, and no manager manages two different departments). Then, the last of equations in (d)
link relations and by specifying that either an employee is a manager of the department he/she works in or he/she is under the departmental manager. Finally, Equation (e)
limits the wages by enforcing that an employee doing a certain job type may not earn less than the minimal wage nor more than the maximal wage associated with the given job type. The model is intended to be interpreted in some PTBDI allegory. Each interpretation corresponds to some actual realization and state of the database. The choice of allegory determines the kind of database; different interpretations in the same allegory may be interpreted as different states of the same database. Interpretation of the allegorical conceptual model in is the typical choice. In order to formulate the precise definition of interpretation, we first need the following simple observation:
Figure 1.
An example of an allegorical conceptual model graph.
Figure 1.
An example of an allegorical conceptual model graph.
Figure 2.
Equations specifying the properties of relations from
Figure 1.
Figure 2.
Equations specifying the properties of relations from
Figure 1.
Lemma 4. Let be a graph, and let be a PTBDI allegory. Let be a graph morphism. Then, can be extended to a map using induction on the ⊗-groupoid structure of ; that is, by defining for all . Similarly, can be extended to a map using induction on the structure of terms in ; that is, by defining , , and so on.
The following remark clarifies the above lemma. Suppose that:
is a subgraph contained in a graph
, and that
is a graph morphism from
into a PTBDI allegory,
, such that
. Consequently, by the above definition of the extension
of
, we have
, where
. Note that even if
T is intended to be interpreted as a composition of
R and
S, this intention cannot be communicated through the structure of the graph,
, and hence, it does not introduce any inconsistency in the extension of
. On the other hand, the intended identification of
T with the composition of
R and
S can be declared through equations. In particular, if
, then
F cannot be an interpretation of
, as defined below.
Definition 5. Let be an allegorical conceptual data model, and let be a PTBDI allegory. A graph morphism is called an interpretation of in if for all equations . A set of all interpretations of is denoted by , and the set of all interpretations in an allegory is denoted by .
Reasoning about data is furnished by the following semantic definition of a derived equality:
Definition 6. Let be an allegorical conceptual model. We write , where F is an interpretation of if . We write (the equality holds in ) if for any interpretation F of .
3. Modal Terms and Modal Interpretations
Recall that a modal similarity type consists of a set, , of symbols and a map called an arity. A frame with modal similarity type is a set, , together with a family of relations.
Let
be a graph, and let
be a modal similarity type. We extend the set,
, of allegorical terms associated with
to a set,
, of modal allegorical terms of modal similarity type
by introducing new term constructors called modal operators: for each
, such that
, and each term
such that
and
also terms
. We also declare:
(i.e., modal operators associate arrows with arrows from the same hom-set) so that the terms with modal operators can be used as subterms. Arity zero modal operators (that is, modal constants) require special treatment. For all such that , and all pairs of objects , we declare to be a term in with and .
Definition 7. Let be a frame of similarity type ;
let be a locally complete PTBDI allegory, and let be an allegorical conceptual data model. A modal interpretation of in with frame consists of a family of interpretations ,
a map and a map ,
where we denote ,
satisfying, for all and :We denote by the set of all modal interpretations of in with frame .
The last of the equalities (10) specifies
to be a unique map which makes a diagram in
Figure 3 commute (
cf. Equation (4)). In fact, Formula (10c) could be taken as a definition of
, because it guarantees by itself that
is an injective map. Indeed,
as defined by Equation (10c) is a map because
and
are maps and
,
are projections for a relational product. It remains to prove that
:
Similarly, exchanging
A and
B, we prove the inequality
Hence,
as desired.
Observe that a modal interpretation
defines a family of maps
given explicitly by:
Alternatively,
is determined by the commutativity of the following family of diagrams (for all
):
Figure 3.
The construction of injection for a relational product (note that and ).
Figure 3.
The construction of injection for a relational product (note that and ).
Lemma 8. satisfies the following properties:- (1)
For all , such that and , if , then .
- (2)
For all , such that and , we have and .
- (3)
For all such that , we have .
- (4)
For all ,
the following properties hold:
Proof. ad. 1: Suppose that
. Then:
ad. 2: follows immediately from the distributivity of composition over union. The composition does not distribute over the intersection. However, it is well known (see, e.g., [
1]) that in any allegory
and
if
R is functional, that is, if
. Hence, the result follows from the injectivity of
and
, which implies the functionality of
and
.
ad. 4: , as
is functional. The first of Equations (5) implies that
. Inequality
holds trivially. Then, (
cf. Figure 3):
☐
Note that does not in general preserve identities, tops, bottoms and relational product projections, and thus, it is not an interpretation. The objects , for should be considered a representation of “total domains”—the collections of all possible values (whatever that means in a general allegory). On the other hand, is an interpretation of the conceptual model of the database in the concrete world (say a moment of time), and in particular objects represent actual values stored in the database in the world m.
Note also that does not preserve implications in general. This is obvious, as, in particular, in , the complement in the arrow-set is much larger than the embedding in of the complement of in . However, Lemma 10 alleviates that a bit. First, we need the following general result, interesting on its own.
Lemma 9. Let and be injective maps in some allegory, ,
and suppose that the meet semilattice of arrows contains the top element, .
Let .
Consider the following statements (see the diagram below for illustration):- (1)
for some .
- (2)
and ,
- (3)
.
Statement (1) implies Statements (2) and (3), and Statement (3) implies Statements (1) and (2). Proof. If , then, because and the composition is monotonic, we must also have . Furthermore, as and, similarly, . This finishes the proof of the first set of implications.
Assume now that
. We will prove first that
. Because
is functional,
i.e.,
, and composition is monotonic, we have
. Similarly,
. In order to prove the other inequalities, we first define for any arrow,
T, the domain of
T:
Recall ([
1]) that
has the following properties:
It follows from Formula (13c) that
if and only if
. By assumption, however,
, and so, by the transitivity of the order relation and the monotonicity of
(Equation (13b)), it is enough to prove that
. However, by Equation (13a), we have:
In order to prove that
, first note that because reciprocation is monotonic and
, if
, then
, and hence, by the just proven result,
. Taking the reciprocation of both sides of this inequality yields
as desired.
Now, we are ready to prove the last implication. Assuming , itfollows from the just proven result that . Hence, defining yields , as desired. ☐
Lemma 10. For all such that and ,
we have: Proof. Using explicit Formula (8) for an implication in a locally complete distributive allegory, and the distributivity law (6), we have:
In the second equality, in order to change the ⨆ subscript, we made use of the fact that
. Note that by Lemma 9
for some
. It follows immediately, because extending the set of which the supremum is taken increases the supremum value that:
Then, because the injectivity of
and
implies that
if and only if
, we have that:
It remains to prove that:
The above inequality is equivalent to the conjunction of
(which holds by the monotonicity of
) and
. Using explicit Formula (8) for implication and the fact that decreasing the set for which the supremum is taken decreases the supremum value, we have:
The last expression is identical to (**), which is equal (as shown above) to
. ☐
The following immediate corollary to Lemma 10 shows that for certain safe expressions,
preserves implications:
Corollary 11. For all with the same source and target and all ,
we have: We are now ready to define the interpretation of the modal formulas
in the allegory
using the interpretation
.
Definition 12. Let be a frame of similarity type ;
let be a locally complete PTBDI allegory, and let be an allegorical conceptual data model. A modal interpretation of in with frame defines for all a map defined by induction on the structure of terms in as follows (we omit the subscript whenever is clear from the context):If orthen .
, , , , .
If is such that and ,
then: If is such that and are such that and ,
then:
Remark 1. Note that preserves neither top elements, relational projections and identities nor implications (because does not preserve them either). Note, however, that by definition, and for all .
Example 2. Here, we construct an allegorical counterpart of the basic modal logic. Let be a frame of similarity type .
Let be an allegorical conceptual data model and consider a modal interpretation .
We denote customarily and for all .
Let ,
.
Then:Note that the above formulas are the same as in the definition of satisfaction of modal operators in the (first-order) basic modal logic (see, e.g., [19,20]). Example 3. In this example, we will consider modal interpretations in the allegory where L is a locale, of locale-valued relations (see, e.g., [1]). In ,
objects are sets, and for any ,
the hom-set consists of maps .
Locale-valued relations are usually interpreted as fuzzy relations, where the value, ,
gives the degree to which the relation, R, between a and b actually holds. Composition for such that ,
is given by:For all ,
the identity morphisms are given explicitly by if and if .
The intersection, union and reciprocation operators are defined in by ,
,
.
Let us now consider the formulas defining modal interpretation in the same setting as in Example 2, but with instead of .
Then: Sometimes, the modal operators associated directly to the frame relations are not enough. For instance (see Example 4), the counterpart of until and since operators from temporal logic cannot be expressed using the formalism described so far. Therefore, we allow one to extend the set of terms, , to the set, , using an arbitrary set of constructors corresponding to the set of operators, Ω, instead of using only the constructors tied in a canonical way to frame relations and attaching to those operators arbitrary (though defined using frame relations) semantics.
Example 4. Let be a frame of similarity type , such that ≤ is a linear order. Let be an allegorical conceptual data model. We extend to by adding two new term constructors: For all terms such that and , also ( until ) and ( since ).
Let ,
and let .
Then, the semantics of and is given by:where we denote .
In particular, if ,
then for all and ,
those definitions boil down to the classical definition of the since and until temporal modalities: Formal equalities between terms from can be used to specify the dependencies between data from different “worlds”, where the “world” can mean, depending on the application, a time moment or perhaps a database server instance. Here is the precise definition.
Definition 13. Let ; let be a frame of similarity type , and let the modal interpretation . We say that a formal equality is satisfied in modal interpretation at if , which we denote by . We say that a formal equality is satisfied in modal interpretation , which we denote by if for all .