Next Article in Journal
Critical Success Factors of the Reliability-Centred Maintenance Implementation in the Oil and Gas Industry
Previous Article in Journal
MADICS: A Methodology for Anomaly Detection in Industrial Control Systems
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Novel Categorical Approach to Semantics of Relational First-Order Logic

by
Wolfgang Schreiner
1,
William Steingartner
2,* and
Valerie Novitzká
2
1
Research Institute for Symbolic Computation (RISC), Johannes Kepler University, Altenbergerstraße 69, A-4040 Linz, Austria
2
Faculty of Electrical Engineering and Informatics, Technical University of Košice, Letná 9, 042 00 Košice, Slovakia
*
Author to whom correspondence should be addressed.
Symmetry 2020, 12(10), 1584; https://doi.org/10.3390/sym12101584
Submission received: 30 August 2020 / Revised: 16 September 2020 / Accepted: 18 September 2020 / Published: 23 September 2020
(This article belongs to the Section Computer)

Abstract

:
We present a categorical formalization of a variant of first-order logic. Unlike other texts on this topic, the goal of this paper is to give a very transparent and self-contained account without requiring more background than basic logic and set theory. Our focus is to show how the semantics of first-order formulas can be derived from their usual deduction rules. For understanding the core ideas, it is not necessary to investigate the internal term structure of atomic formulas, thus we abstract atomic formulas to (syntactically opaque) relations; in this sense, our variant of first-order logic is “relational”. While the derived semantics is based on categorical principles (even the duality that arises from a symmetry between two ways of looking at something where there is no reason to choose one over the other), it is nevertheless “constructive” in that it describes explicit computations of the truth values of formulas. We demonstrate this by modeling the categorical semantics in the RISCAL (RISC Algorithm Language) system which allows us to validate the core propositions by automatically checking them in finite models.

1. Introduction

Most introductions to first-order logic first define the syntax of formulas, then formalize their meaning in the form established in the 1930s by Tarski [1] (essentially what we call today in programming language theory a “denotational semantics” [2]), then introduce a deduction calculus, and finally show the soundness and completeness of this calculus concerning the semantics: if a formula can be derived in the calculus, it is true according to the semantics, and vice versa. These relationships between truth and derivability have to be established because there is no self-evident link between the semantics of a formula and the deduction rules associated with it. Historically, deduction came first; the soundness of a deduction calculus was established by showing that it could not lead to apparent inconsistencies, i.e. that both a formula and its negation could not be derived in a deduction system. It was Tarski who first gave meaning to formulas that was independent of deduction.
However, as it did since the 1940s to many other mathematical areas, category theory [3,4,5,6,7], the general theory of mathematical structures, can bring and provide an alternative light also to first-order logic. It does so by considering logical notions as special instances of “universal” constructions, where a value of interest is determined
  • first, by depicting the core property that the value shall satisfy; and
  • second, by giving a criterion how to choose a canonical value from all values that satisfy the property.
It was eventually recognized that by such universal constructions the semantics of the connectives of propositional logic could be determined directly from their associated introduction and elimination rules. However, it took until the late 1960s until Lawvere gained the fundamental insight that this idea could be also applied to the quantifiers of first-order logic [8], thus establishing a direct relationship between its semantics and its proof calculus.
However, this insight has not yet obtained a foothold in basic texts on logic and its basic education. The main reason may be that the corresponding material is found mostly in texts on category theory and its applications where it is dispersed among examples of the application of categorical notions without a clear central presentation. Furthermore, the general treatment of first-order logic with terms and variables requires a complex mathematical apparatus [9] which is much beyond the scope of basic introductions. Reasonably compact introductions can be found, e.g., in Section 2.1.10 of [10], in [11], in Section 1.6 of [12] (however, in the context of type theory rather than classical first-order logic), in Section 9.5 of [3] (the treatment of quantifiers only), and in Section 7.1.12 of [7] (again only the treatment of quantifiers).
The goal of this paper is to give a compact introduction to a categorical version of first-order logic that is fully self-contained, only introduces the categorical notions relevant for the stated purpose, and presents them from the point of view of the intended application. For this purpose, it elaborates a simple but completely formalized syntactic and semantic framework of first-order logic that represents the background of the discussion, without gaps and inconsistencies. As a deliberate decision, this framework does not address the syntax and semantics of terms but abstracts atomic formulas to opaque relations; this allows for focusing the discussion on the essentials. However, to describe a reasonably close relative of first-order logic, this framework is (in contrast to other presentations) not based on relations of fixed arity, i.e., with a fixed number of variables; instead, we consider relations of infinite arity, i.e., with infinitely many variables. However, only finitely many variables may influence the truth value of the relation, which represents the effect that a classical atomic formula can only reference a finite number of variables. The overall result is a slick and elegant presentation. Because the duality has many manifestations in logic and it is agreed by all hands that a duality is like a “giant symmetry”—a symmetry between theories, we focus on this concept in our approach. For the implementation, we use the RISCAL—the RISC Algorithm Language [13], which is a specification language with an associated software system for describing mathematical algorithms, formally specifying their behavior based on mathematical theories, and validating the correctness of algorithms, specifications, and theories by the execution/evaluation of their formal semantics. The term “algorithm language” indicates that RISCAL is intended to model, rather than low-level code, algorithms (as can be found in textbooks on discrete mathematics) in a high-level language, and specifying the behavior of these algorithms by formal contacts. RISCAL has been developed to validate the correctness of mathematical theories, specifications, and programs, by checking instances of these artifacts on finite domains; applications of RISCAL are for instance in discrete mathematics, number theory, and computer algebra. Software based on formal logic plays an ever-increasing role in areas where a mathematically precise understanding of a subject domain and sound rules for reasoning about the properties of this domain are essential. A prime example is the formal modeling, specification, and verification of computer programs and computing systems, but there are many other applications in areas such as knowledge-based systems, computer mathematics, or the semantic web [14]. Furthermore, the intent of all our projects (namely LogTechEdu, SemTech [15], and others listed in Funding section) is to further advance education in computer science and related topics. In academical courses for computer science and mathematics, by utilizing the power of modern software based on formal logic and semantics, students shall engage with the material they encounter by actively producing the problem solutions rather than just passively taking them from the lecturer.
The remainder of this paper is structured as follows: in Section 2, we define a term-free variant of first-order logic and give it a semantics in the usual style based on set-theoretic notions. In Section 3, we introduce those categorical notions that are necessary for understanding the following elaboration and discuss their relationships. The core of this paper is Section 4 where we elaborate the categorical formulation of the semantics of our variant of first-order logic. In Section 5, we demonstrate that these semantics are constructive by modeling it in the RISCAL system [13], which allows us to automatically check the core propositions in particular finite models. Section 6 concludes our presentation and gives an outlook on our future work.

2. A Relational First-Order Logic

In this section, we introduce a simplified variant of first-order logic that abstracts from the syntactic structure of atomic formulas and thus copes without the concept of terms, constants, function symbols, predicate symbols, and all of the associated semantic apparatus. Towards this goal, atomic formulas are replaced by relations over assignments (maps of variables to values) that are constrained to only depend on a finite number of variables; we will call such relations “predicates”. Consequently, the semantics of every non-atomic formula is also a relation (i.e., a predicate, as mentioned).
We begin with some standard notions. First, we specify variables and the values that variables hold.
Axiom 1
(Variables and Values). Let Var denote an arbitrary infinite and enumerable set; we call the elements of this set variables. Furthermore, let Val denote an arbitrary non-empty set; we call the elements of these set values.
Next, we define assignments.
Definition 1
(Assignments). We define Ass : = Var Val as the set of all mappings of variables to values (a function space); we call the elements of this set assignments. Thus, for every assignment a Ass and every variable x Var , we have a ( x ) Val .
We note that assignment is similar to a concept of state in theory of formal semantics of programming languages (see, e.g., [16]) where the state is a function from variables to values: to each variable, the state associates its current value.
Definition 2
(Updates). Let a Ass be an assignment, x Var a variable, and v Val a value. We define the update assignment a [ x v ] Ass as follows:
a [ x v ] ( y ) : = v , if x = y ; a [ x ] , otherwise .
Consequently, a [ x v ] is identical to a except that it maps variable x to value v.
Based on this, we can formulate the following updating properties.
Proposition 1
(Update Properties). Let a Ass be an assignment, x , y Var variables, and v , v 1 , v 2 Val values. Then, we have the following properties:
a [ x a ( x ) ] = a , a [ x v 1 ] [ x v 2 ] = a [ x v 2 ] , x y a [ x v 1 ] [ y v 2 ] = a [ y v 2 ] [ x v 1 ] .
Proof. 
Directly from the definitions. □
The properties of assignments listed above (and only these) will be of importance in the subsequent proofs.
Now, we turn to the fundamental semantic notions.
Definition 3
(Relations). We define Rel : = P ( Ass ) as the set of all sets of assignments; we call the elements of this set “relations”. Consequently, a relation is a set of assignments.
Definition 4
(Variable Independence). We state that relation R Rel is independent of variable x Var , written as R x , if and only if the following holds:
a Ass , v 1 , v 2 Val . a [ x v 1 ] R a [ x v 2 ] R .
Consequently, if R x , the value of x in any assignment a does not influence whether a is in R. We say that R depends on x if R x does not hold.
We transfer the central syntactic property of atomic formulas (they can only refer to finitely many variables) to its semantic counterpart.
Definition 5
(Predicates). A relation R Rel is a predicate, if it only depends on finitely many variables. We denote by Pred the set of all predicates and by Pred x : = { P Pred | P x } the subset of all predicates that are independent of x.
Now, we are ready to introduce the central entities of our paper. First, we give a definition of the abstract syntax of formulas.
Definition 6
(Abstract Syntax of Formulas). We define F o r as that smallest set of abstract syntax trees in which every element F For is generated by an application of a rule of the following context-free grammar (where P Pred denotes an arbitrary predicate and x Var denotes an arbitrary variable):
F : : = P | | | ¬ F | F 1 F 2 | F 1 F 2 | F 1 F 2 | F 1 F 2 | x . F | x . F
We call the elements of this set formulas.
In this definition, the role of a classic atomic predicate p ( t 1 , , t n ) with argument terms t 1 , , t k in which n variables x 1 , , x n occur freely is abstracted to a predicate P that depends on variables x 1 , , x n .
Now, we establish the relationship between the syntax and semantics of formulas.
Definition 7
(Semantics of Formulas). Let F For be a formula. We define the relation F Rel , called the semantics of F, by induction on the structure of F:
P : = { a Ass | a P } : = { a Ass | true } : = { a Ass | false } ¬ F : = { a Ass | a F } F 1 F 2 : = { a Ass | a F 1 and a F 2 } F 1 F 2 : = { a Ass | a F 1 or a F 2 } F 1 F 2 : = { a Asss | a F 1 or a F 2 } F 1 F 2 : = { a Ass | a F 1 and a F 2 or a F 1 and a F 2 } x . F : = { a Ass | a [ x v ] F , for all v Val } x . F : = { a Ass | a [ x v ] F , for some v Val }
The above definition is well-defined in that every formula denotes a relation. To show that formulas indeed denote predicates, some more work is required.
Proposition 2
(Quantified Formulas and Variable Independence). For every variable x Var and formula F For , we have x . F x and x . F x , i.e., the semantics of quantified formulas do not depend on x.
Proof. 
We prove this proposition by reductio ad absurdum.
First, assume that x . F depends on x. Then, we have some assignment a x . F and some values v 1 , v 2 Val such that a [ x v 1 ] x . F and a [ x v 2 ] x . F . From a [ x v 2 ] x . F we have some v Val with a [ x v 2 ] [ x v ] F and thus a [ x v ] F . However, a [ x v 1 ] x . F implies a [ x v 1 ] [ x v ] F and thus a [ x v ] F , which represents a contradiction.
Now, assume that x . F depends on x. Then, we have some assignment a x . F and some values v 1 , v 2 Val such that a [ x v 1 ] x . F and a [ x v 2 ] x . F . From a [ x v 1 ] x . F , we have some v Val with a [ x v 1 ] [ x v ] F and thus a [ x v ] F . However, a [ x v 2 ] x . F implies a [ x v 2 ] [ x v ] F and thus a [ x v ] F , which represents a contradiction. □
Proposition 3
(Formula Semantics and Predicates). For every formula F For , we have F Pred , i.e., the semantics of F is a predicate.
Proof. 
The proof proceeds by induction over the structure of F.
  • If F = P , we have F = { a Ass | a P } = P Pred .
  • If F { , } , there are no x , a , v 1 , v 2 such that a [ x v 1 ] F and a [ x v 2 ] F because, for F = , the second condition must be false and for F = the first one; thus, F does not depend on any variable.
  • If F = ¬ F 1 , by the induction hypothesis, we may assume that F 1 depends only on the variables in some finite variable set X. From the definition of F , it is then easy to show that ¬ F 1 also depends only on the variables in X.
  • If F { F 1 F 2 , F 1 F 2 , F 1 F 2 , F 1 F 2 } , we may assume by the induction hypothesis that F 1 depends only on the variables in some finite set X 1 while P 2 only depends on the variables in some finite set X 2 . From the definition of F , it is then easy to show that F depends only on the variables in the finite set X 1 X 2 .
  • If F { x . F 1 , x . F 1 } , we may assume by the induction hypothesis that F 1 only depends on the variables in some finite variable set X. We are now going to show that F only depends on the variables in the finite set X \ { x } . Actually, we assume that this is not the case and show a contradiction. From this assumption and Proposition 2, we have a variable y x y X on which F depends; thus, we have an assignment a and values v 1 , v 2 such that a [ y v 1 ] F and a [ y v 2 ] F .
    If F = x . F 1 , from a [ y v 2 ] F , we have a v Val with a [ y v 2 ] [ x v ] F 1 and thus (since y x ) a [ x v ] [ y v 2 ] F 1 . From a [ y v 1 ] F , we know a [ y v 1 ] [ x v ] F 1 and thus a [ x v ] [ y v 1 ] F 1 . Thus, F 1 depends on a variable y X which contradicts the induction assumption.
    If F = x . F 1 , from a [ y v 1 ] F , we have a v Val with a [ y v 1 ] [ x v ] F 1 and thus (since y x ) a [ x v ] [ y v 1 ] F 1 . From a [ y v 2 ] F we know a [ y v 2 ] [ x v ] F 1 and thus a [ x v ] [ y v 2 ] F 1 . Thus, F 1 depends on a variable y X which contradicts the induction assumption.
This completes our proof. □
In the following, we transfer the classical model-theoretic notions to our framework.
Definition 8
(Satisfaction). Let a Ass be an assignment and F For be a formula. We define a F (read: a satisfies F) as follows:
a F : a F .
Definition 9
(Validity). Let F For be a formula. We define F (read: F is valid) as follows:
F : a Ass . a F .
Definition 10
(Logical Consequence). Let F , G For be formulas. We define F G (read: G is a logical consequence of F) as follows:
F G : a Ass . a F a G .
Definition 11
(Logical Equivalence). Let F , G For be formulas. We define F G (read: F and G are logically equivalent) as follows:
F G : a Ass . a F a G .
Proposition 4
(Logical Consequence and Logical Equivalence). Let F , G For be formulas. Then, we have the following equivalences:
  • ( F G ) ( F G )
  • ( F G ) ( F G )
  • ( F G ) ( F G )
  • ( F G ) ( F = G )
Proof. 
Directly from the definitions. □
Thus, a logical consequence on the meta-level coincides with an implication on the formula level and with the subset relation on the semantic level. Furthermore, logical equivalence on the meta-level coincides with equivalence on the formula level and with the equality relation on the semantic level.
In the following, we establish a set-theoretic interpretation of the logical operations of our formula language.
Definition 12
(Complement). We define the complement R ¯ Rel of relation R Rel as the relation R ¯ : = Ass \ R . Consequently, an assignment is in R ¯ if and only if it is not in R.
Proposition 5
(Propositional Semantics as Set Operations). Let F , F 1 , F 2 For be formulas. We then have the following equalities:
P = P = Ass = ¬ F = F ¯ F 1 F 2 = F 1 F 2 F 1 F 2 = F 1 F 2 F 1 F 2 = F 1 ¯ F 2 F 1 F 2 = F 1 F 2 F 1 ¯ F 2 ¯
Proof. 
Directly from the definition of the semantics. □
While the above results are quite intuitive, a corresponding set-theoretic interpretation of quantified formulas is not. In the following, we only state the plain result without indication of how it can be intuitively understood; we will delegate this explanation to Section 4, where the categorical framework will provide us with adequate insight.
Proposition 6
(Quantifier Semantics as Set Operations). Let F For be a formula. We then have the following equalities:
x . F = { P Pred | P x P F } , x . F = { P Pred | P x F P } .
In other words, x . F is the weakest predicate P (“weakest” in the sense of the largest set) that is independent from x and that satisfies the property P F while x . F is the strongest predicate P (“strongest” in the sense of the smallest set) that is independent of x and that satisfies the property F P .
Proof. 
The proof is in two stages. First, we take an arbitrary assignment a Ass and show
a x . F P Pred . P x P F a P
⇒: We assume a x . F and prove for P : = x . F
P Pred
P x
P F
a P
From Proposition 3, we have (1). From Proposition 2, we have (2). From a x . F , we have (4). To show (3), we take arbitrary assignment a 0 P and show a 0 F . From a 0 P , we know a 0 [ x v ] F for v : = a 0 ( x ) . Since a 0 [ x a 0 ( x ) ] = a 0 , we thus know a 0 F .
⇐: We assume for some P Pred
P x
P F
a P
and prove a x . F . For this, we take arbitrary v Val and prove a [ x v ] F . From (6), it suffices to show a [ x v ] P . From (5), we know
v 1 , v 2 Val . a [ x v 1 ] P a [ x v 2 ] P
From (7) and a = a [ x a ( x ) ] , we know a [ x v 0 ] P for v 0 : = a ( x ) . Thus, with (8), we know a [ x v ] P .
Now, we take arbitrary a Ass and show
a x . F P Pred . P x F P a P
⇒: We assume a x . F and take arbitrary but fixed P Pred for which we assume
P x
F P
Our goal is to show a P . From a x . F , we know a [ x v ] F for some v Val . From (10), we thus know a [ x v ] P . From (9), we thus know a [ x a ( x ) ] P . Since a [ x a ( x ) ] = a , we thus know a P .
⇐: We assume
P Pred . P x F P a P
and prove a x . F . From (11) instantiated with P : = x . F and Propositions 3 and 2, it suffices to prove F x . F . Take arbitrary assignment a 0 F . Since a 0 [ x a ( x ) ] = a , we thus have a 0 [ x v ] F for v : = a ( x ) and thus a 0 x . F . □

3. Category Theory

In this section, we discuss those aspects of category theory that are relevant for the subsequent categorical formulation of our relational first-order logic.

3.1. Basic Notions

We begin with the basic notions of category theory.
Definition 13
(Category). A category C is a triple O , A , of the following components:
  • A class O of elements called C-objects or just objects.
  • A class A of elements called C-arrows or just arrows. Each arrow has a source object and a target object from O; we write f : a b to indicate that f is an arrow with source a and target b. We write C ( a , b ) to denote the class of all arrows of A with source a and target b (called the hom-class of all arrows from a to b). For every object x in O, A contains an arrow id x : x x called the identity arrow for x.
  • A composition—binary operation defined on arrows. For all arrows f : a b and g : b c , we have ( g f ) : a c . Furthermore, the composition satisfies the following axioms:
    -
    Associativity: ( h g ) f = h ( g f ) , for all arrows f : a b , g : b c , h : c d .
    -
    Identity: id b f = f = f id a , for all arrows f : a b .
Definition 14
(Isomorphism). Let C be a category and a , b be C-objects a , b . Then, we have a b (read: a and b are isomorphic) if there are C-arrows f : a b and g : b a , called isomorphisms, such that g f = id a and f g = id b .
Definition 15
(Subcategory). A category C is a subcategory of category 𝒟 if every C-object is also a 𝒟-object, every C-arrow is also a 𝒟-arrow, every identity arrow in C is also an identity arrow in 𝒟, and g C f = g D f for all C-arrows f : a b and g : b c , where C denotes the composition in C and D denotes the composition in 𝒟.

3.2. Object Constructions

We are now introducing constructions of categorical objects that will subsequently play an important role in the categorical formulation of relational first-order logic.
Definition 16
(Initial and Final Objects). Let C be a category. A C-object 0 is initial if for every C-object a there exists exactly one arrow 0 a : 0 a . A C-object 1 is final if for every C-object a there exists exactly one arrow 1 a : a 1 .
The following diagram illustrates the arrows of an initial object 0 and a final object 1 with respect to an arbitrary object a:
Symmetry 12 01584 i001
This construction of initial/final objects is “universal” in the sense that it describes a class of entities (objects and accompanying arrows) that share a common property and picks from this class an entity whose characterizing property is the existence of exactly one arrow from/to every entity of this class. This defines the entity uniquely up to isomorphism. Further instances of such constructions will be given later.
Definition 17
(Product and Coproduct). Let C be a category. Then, the triple a × b , π 1 , π 2 is a product of C-objects a and b if a × b is a C-object, the product object, with arrows π 1 : a × b a and π 2 : a × b b , the projections, such that for every triple c , f , g with C-object c and arrows f : c a and g : c b there exists exactly one arrow f , g : c a × b such that the following diagram commutes:
Symmetry 12 01584 i002
Dually, the triple ( a + b , ι 1 , ι 2 ) is a coproduct of C-objects a and b if a + b is a C-object, the coproduct object, with arrows ι 1 : a a + b and ι 2 : b a + b , the injections, such that, for every triple c , f , g with C-object c and arrows f : a c and g : b c , there exists exactly one arrow [ f , g ] : a + b c such that the following diagram commutes:
Symmetry 12 01584 i003
The product and the coproduct are thus defined by universal constructions analogous to those of the final and the initial element, respectively; thus, products and coproducts are also uniquely defined up to isomorphism.
Definition 18
(Product Arrow). Let C be a category with products a 1 × a 2 , π 1 , π 2 and b 1 × b 2 , π 1 , π 2 and arrows f : a 1 b 1 and g : a 2 b 2 , respectively. Then, the product arrow f × g : a 1 × a 2 b 1 × b 2 is the arrow f π 1 , g π 2 .
Definition 19
(Exponential). Let C be a category in which, for all C-objects, there exists a product object. Then, the tuple b a , eval a , b is an exponential of C-objects a and b if b a is a C-object, the exponential object, with arrow eval a , b : b a × a b , the evaluation arrow, such that for every C-object c with arrow f : c × a b there exists exactly one arrow curry f : c b a , the currying arrow, such that the following diagram commutes:
Symmetry 12 01584 i004
Since the exponential is also defined by a universal construction, it is uniquely defined up to isomorphism.

3.3. Functors and Adjunction

Moving on from individual categories, we will now discuss some concepts that address relationships between categories.
Definition 20
(Functor). Let C and 𝒟 be categories. A functor F : C 𝒟 is a map that takes every C-object a to a 𝒟-object F ( a ) and every C-arrow f : a b to a 𝒟-arrow F ( f ) : F ( a ) F ( b ) such that
  • F ( id a ) = id F ( a ) for every C-object a, and
  • F ( g C f ) = F ( g ) D F ( f ) for all C-arrows f : a b and g : b c .
Definition 21
(Adjunction, Left, and Right Adjoint). Let C and 𝒟 be categories with functors F : C 𝒟 and G : 𝒟 C . Then, we have F G (read: F , G is an adjunction, F is a left adjoint of G, G is a right adjoint of F) if for every C-object a and 𝒟-object b the arrow classes 𝒟 ( F ( a ) , b ) and C ( a , G ( b ) ) are isomorphic, i.e., there exists a bijection between them. This is equivalent to saying that, for every C-object a and 𝒟-object b, there exist two surjective mappings s 1 : 𝒟 ( F ( a ) , b ) C ( a , G ( b ) ) and s 2 : C ( a , G ( b ) ) 𝒟 ( F ( a ) , b ) , i.e.,
  • for every 𝒟-arrow g : F ( a ) b we have a C-arrow f : a G ( b ) with s 2 ( f ) = g and
  • for every C-arrow f : a G ( b ) , we have a 𝒟-arrow g : F ( a ) b with s 1 ( g ) = f .
Note. 
This equivalence is a consequence of the Cantor–Schröder–Bernstein theorem which states that there exists a bijective function between sets A and B if there exist injective functions f : A B and g : B A . This implies that such a bijective function also exists if there exist surjective functions f : A B and g : B A because, from these, we can define the injective functions f ( a ) : = such b . g ( b ) = a and g ( b ) : = such a . f ( a ) = b . While the theorem has been formulated for sets, it can also be generalized to classes.
The above formulation will become handy in proving that two functors represent an adjunction.
Proposition 7
(Equivalence of Adjunctions and Universals). Let C and 𝒟 be categories with functors F : C 𝒟 and G : 𝒟 C . Then, the condition F G is equivalent to each of the following two conditions:
1. 
For every C-object a, there is a C-arrow u : a G ( F ( a ) ) , the “universal arrow”, such that, for every 𝒟-object b and C-arrow f : a G ( b ) , there exists a 𝒟-arrow g b , f : F ( a ) b :
Symmetry 12 01584 i005
2. 
For every 𝒟-object b, there is a C-arrow v : F ( G ( b ) ) b , the “couniversal arrow”, such that, for every C-object a and 𝒟-arrow g : F ( a ) b , there is a C-arrow f a , g : a G ( b ) :
Symmetry 12 01584 i006
Proof. 
See the proof of Propositions 6 and 7 in [12]. □

3.4. Object Constructions by Adjunction

We conclude this section by demonstrating that the previously described object conjunctions can be also considered as applications of functors that are determined as left respectively right adjoints to certain basic functors.
Proposition 8
(Initial and Final Object by Adjunction). Let 1 be the “singleton” category with a single object (and consequently a single arrow id : ); this category is uniquely defined up to isomorphism. Let C be a category with the constant functor C : C 1 ; in addition, this functor is uniquely defined up to isomorphism. Then, the following holds:
  • Let C-object 0 be initial and the “initial object functor” I 0 : 1 C be defined by I 0 ( ) : = 0 and I 0 ( id ) : = id 0 . Then, we have I 0 C , i.e., the initial object functor is a left adjoint of the constant functor.
  • Let C-object 1 be final and the “final object functor” F 1 : 1 C be defined by F 1 ( ) : = 1 and F 1 ( id ) : = id 1 . Then, we have C F 1 , i.e., the final object functor is a right adjoint of the constant functor.
Proof. 
For showing the first statement, we take the initial object 0 with initial object functor I 0 . We show I 0 C , i.e., that C ( I 0 ( ) , a ) and 1 ( , C ( a ) ) are isomorphic, for arbitrary C-object a. This follows from 1 ( , C ( a ) ) = 1 ( , ) , C ( I 0 ( ) , a ) = C ( 0 , a ) , and the fact that there exists exactly one 1 -arrow id : and, since 0 is initial, exactly one C-arrow f : 0 a .
For showing the second statement, we take the final object 1 with final functor F 1 . We prove C F 1 , i.e., that 1 ( C ( a ) , ) and C ( a , F 1 ( ) ) are isomorphic, for arbitrary C-object a. This follows from 1 ( C ( a ) , ) = 1 ( , ) , C ( a , F 1 ( ) ) = C ( a , 1 ) , and the fact that there exists exactly one 1 -arrow id : and, since 1 is final, exactly one C-arrow f : a 1 . □
Proposition 9
(Product and Coproduct by Adjunction). Let C be a category. Let the “product category” C × C be the category whose objects ( a , b ) are pairs of C-objects a and b, whose arrows ( f , g ) : ( a , c ) ( b , d ) are pairs of C-arrows f : a b and g : c d , where the identity arrows are pairs of identity arrows, and where composition is component-wise composition. Let the “diagonal functor” Δ : C C × C be defined by Δ ( a ) = ( a , a ) for every C-object a and Δ ( f ) = ( f , f ) for every C-arrow f : a b . Then, the following holds:
  • Assume that every pair of C-objects a and b has a product a × b and let the “product functor” P : C × C C be defined by P ( a , b ) : = a × b . Then, we have Δ P , i.e., the product functor is a right adjoint of the diagonal functor.
  • Assume that every pair of C-objects a and b has a coproduct a + b and let the “coproduct functor” C : C C × C be defined by C ( a , b ) : = a + b . Then, we have C Δ , i.e., the coproduct functor is a left adjoint of the diagonal functor.
Proof. 
For showing the first statement, we take arbitrary category C and functor P satisfying the stated assumption. We show Δ P , i.e., that, for arbitrary C-objects p , a , b , the arrow classes ( C × C ) ( Δ ( p ) , ( a , b ) ) and C ( p , P ( a , b ) ) are isomorphic. Since Δ ( p ) = ( p , p ) and P ( a , b ) = a × b , it suffices to find surjections s 1 : ( C × C ) ( ( p , p ) , ( a , b ) ) C ( p , a × b ) and s 2 : C ( p , a × b ) ( C × C ) ( ( p , p ) , ( a , b ) ) . First, we define s 1 ( f , g ) : = f , g where f , g : p a × b is the unique C-arrow given to us by Definition 17 with property f = π 1 f , g and g = π 2 f , g . Now, we show that, for every C-arrow h : p a × b , there exist some C-arrows f : p a and g : p b with s 1 ( f , g ) = h . We take f : = π 1 h and g : = π 2 h . Due to the uniqueness of f , g , the equalities f = π 1 h and g = π 2 h imply h = f , g and thus s 1 ( f , g ) = h . Second, we define s 2 ( h ) : = ( π 1 h , π 2 h ) . Now, we show that, for every ( C × C ) -arrow ( f , g ) : ( p , p ) ( a , b ) , i.e., for all C-arrows f : p a and g : p b , there exists some C-arrow h : p a × b with s 2 ( h ) = ( f , g ) , i.e., π 1 h = f and π 2 h = g . Definition 17 can be used to define h.
For showing the second statement, we take arbitrary category C and functor C satisfying the stated assumption. We prove C Δ , i.e., that, for arbitrary C-objects a , b , c , the arrow classes C ( C ( a , b ) , c ) and ( C × C ) ( ( a , b ) , Δ ( c ) ) are isomorphic. Since C ( a , b ) = a + b and Δ ( c ) = ( c , c ) , it suffices to find surjections s 1 : C ( a + b , c ) ( C × C ) ( ( a , b ) , ( c , c ) ) and s 2 : ( C × C ) ( ( a , b ) , ( c , c ) ) C ( a + b , c ) . First, we define s 1 ( h ) : = ( h ι 1 , h ι 2 ) . Now, we prove that for every ( C × C ) -arrow ( f , g ) : ( a , b ) ( c , c ) , i.e., for all C-arrows f : a c and g : b c , there exists some C-arrow h : a + b c with s 1 ( h ) = ( f , g ) , i.e., h ι 1 = f and h ι 2 = g . Definition 17 can be used to define h. Second, we define s 2 ( f , g ) : = [ f , g ] where [ f , g ] : a + b c is the unique C-arrow given to us by Definition 17 with property f = [ f , g ] ι 1 and g = [ f , g ] ι 2 . Now, we show that, for every C-arrow h : a + b c , there exist some C-arrows f : a c and g : b c with s 2 ( f , g ) = h . We take f : = h ι 1 and g : = h ι 2 . Due to the uniqueness of [ f , g ] , the equalities f = h ι 1 and g = h ι 2 imply h = [ f , g ] and thus s 2 ( f , g ) = h . □
Proposition 10
(Exponential by Adjunction). Let C be a category in which, for every pair of C-objects a and b, there exists a product object b × a and an exponential object b a . For every C-object a, let the “(unary) product functor” P a : C C be defined by P a ( b ) : = b × a and the “(unary) exponential functor” E a : C C be defined by E a ( b ) : = b a . Then, we have P a E a , i.e., the exponential functor is a right adjoint of the product functor.
Proof. 
We take arbitrary category C, C-object a, and functors P a and E a satisfying the assumption. We show P a E a , i.e., that, for arbitrary C-objects b , c , the arrow classes C ( P a ( c ) , b ) and C ( c , E a ( b ) ) are isomorphic. Since P a ( b ) = b × a and E a ( b ) = b a , it suffices to find surjections s 1 : C ( c × a , b ) C ( c , b a ) and s 2 : C ( c , b a ) C ( c × a , b ) . First, we define s 1 ( f ) : = curry f . Now, we show that, for every C-arrow g : c b a , there exists some C-arrow f : c × a b with s 1 ( f ) = g , i.e., curry f = g . We define f : = eval a , b ( g × id a ) and show curry f = g . From the definition of f, we know that the C-arrow g : c b a satisfies the equality f = eval a , b ( g × id a ) . However, Definition 19 implies that the only such C-arrow is curry f ; thus, curry f = g . Second, we define s 2 ( g ) : = eval a , b ( g × id a ) . Now, we show that, for every C-arrow f : c × a b , there exists some C-arrow g : c b a with s 2 ( g ) = f , i.e., eval a , b ( g × id a ) = f . We define g : = curry f from which Definition 19 proves the goal. □
We are now ready to discuss the central aspects of categorical logic.

4. A Categorical Semantics

Based on the concepts introduced in the previous sections, this section elaborates a categorical semantics of our relational version of first-order logic. We advise the reader to consult Figure 1 to grasp the overall framework and the relationship between its various categories and functors.

4.1. Syntactic Category and Formula Functors

We start by introducing the “syntactic category” S Y N = For , A , as follows:
  • The objects of this category are the formulas in the set For which was introduced in Definition 6.
  • The arrow class A consists of all pairs F 1 , F 2 of formulas F 1 , F 2 for which F 1 F 2 holds, i.e., for which F 2 is a logical consequence of F 1 , as described in Definition 8. The source object of such an arrow is F 1 , and its target object is F 2 . The existence of an arrow f : F 1 F 2 thus indicates F 1 F 2 . The identity id F : F F indicates the fact F F .
  • The composition ∘ denotes relational composition: for all arrows f : F 1 F 2 and g : F 2 F 3 , and the existence of the arrow ( g f ) : F 1 F 3 indicates the transitivity of the relation ⊧.
For every variable x, S Y N x is that subcategory of S Y N whose objects are formulas whose semantics are independent of x (see Definition 4).
For reasons explained below, we will exclude from the syntactic category negations and equivalences, i.e., formulas of form ( ¬ F ) and ( F 1 F 2 ) . We may do so by considering them as the following syntactic shortcuts:
( ¬ F ) ( F ) , ( F 1 F 2 ) ( F 1 F 2 ) ( F 2 F 1 ) .
The validity of these shortcuts can be easily shown by proving the corresponding logical equivalences. Consequently, negations and equivalences need subsequently not be considered any more and their semantics need not be explicitly defined.
For the other kinds of formulas, we introduce the following (families of) “formula functors” where 1 is the “singleton” category with a single object ∗ (see Proposition 8):
true : 1 S Y N false : 1 S Y N and : S Y N × S Y N S Y N or : S Y N × S Y N S Y N imp F For : S Y N S Y N forall x Var : S Y N S Y N x exists x Var : S Y N S Y N x
These functors map formulas to formulas, and logical consequences to logical consequences. The formula mappings are naturally defined as follows:
true ( ) : = false ( ) : = and ( F 1 , F 2 ) : = F 1 F 2 or ( F 1 , F 2 ) : = F 1 F 2 imp F 1 ( F 2 ) : = F 1 F 2 forall x ( F ) : = x . F exists x ( F ) : = x . F
As for the mapping of consequences, we notice that all functors are covariant in their S Y N arguments. It is exactly for this reason that negation and equivalence (which do not allow covariance in their arguments) are not modeled as formula functors and that implication (which is only covariant in its second argument) is not modeled by a binary functor but by a family of unary functors.
Thus, we have for all formulas F , F 1 , F 2 , G , G 1 , G 2 and every variable x the following (easy to prove) properties:
( F 1 G 1 ) ( F 2 G 2 ) and ( F 1 , F 2 ) and ( G 1 , G 2 ) ( F 1 G 1 ) ( F 2 G 2 ) or ( F 1 , F 2 ) or ( G 1 , G 2 ) ( F 2 G 2 ) imp F 1 ( F 2 ) imp F 1 ( G 2 ) ( F G ) forall x ( F ) forall x ( G ) ( F G ) exists x ( F ) exists x ( G )
Therefore, the object maps of these functors naturally induce the necessary logical consequences.

4.2. Semantic Category and Predicate Functors

Next, we introduce the “semantic category” S E M = Pred , B , as follows:
  • The objects of this category are the predicates in the set Pred which was introduced in Definition 5 (thus S E M -objects are relations, i.e., sets).
  • The arrow class B consists of all pairs P 1 , P 2 of predicates P 1 , P 2 for which P 1 P 2 holds, i.e., for which P 1 is a subset of P 2 . The source object of such an arrow is P 1 , its target object is P 2 . The existence of an arrow f : P 1 P 2 thus indicates P 1 P 2 . The identity id P : P P indicates the fact P P .
  • The composition ∘ denotes relational composition: for all arrows f : P 1 P 2 and g : P 2 P 3 , the existence of the arrow ( g f ) : P 1 P 3 indicates the transitivity of the relation ⊆.
For every variable x, S E M x is the subcategory of S E M whose objects are predicates that are independent of x (see Definition 4).
Corresponding to the various kinds of formula constructions, we will have the following “predicate functors” (respectively families of functors):
TRUE : 1 S E M FALSE : 1 S E M AND : S E M × S E M S E M OR : S E M × S E M S E M IMP P Pred : S E M S E M FORALL x Var : S E M S E M x EXISTS x Var : S E M S E M x
These functors map predicates to predicates and subset relations to subset relations (their detailed definitions will be given later). As we will see, these functors are covariant in their S E M -arguments, i.e., we have for all predicates P , P 1 , P 2 , Q , Q 1 , Q 2 and every variable x the following properties:
( P 1 Q 1 ) ( P 2 Q 2 ) AND ( P 1 , P 2 ) AND ( Q 1 , Q 2 ) ( P 1 Q 1 ) ( P 2 Q 2 ) OR ( P 1 , P 2 ) OR ( Q 1 , Q 2 ) ( P 2 Q 2 ) IMP P 1 ( P 2 ) IMP P 1 ( Q 2 ) ( P Q ) FORALL x ( P ) FORALL x ( Q ) ( P Q ) EXISTS x ( P ) EXISTS x ( Q )
Therefore, the object maps of these functors (defined by the respective predicate operations) naturally induce appropriate arrow maps (the corresponding subset relations).

4.3. The Semantic Functor

Now, we introduce the “semantic functor”
: S Y N S E M
defined as follows:
  • For every S Y N -object F, i.e., formula F, F denotes the semantics of F as defined in Definition 7, which according to Proposition 3 is a predicate, i.e., indeed a S E M -object.
  • For every S Y N -arrow f : F 1 F 2 , i.e., every pair of formulas F 1 and F 2 with F 1 F 2 , we have the S E M -arrow f : F 1 F 2 , i.e., the fact F 1 F 2 , which is a direct consequence of Definition 10 which introduces the ⊧ relation.
This semantic functor establishes the relationship between the previously introduced formula functors and predicate functors by the following identities on S E M -objects, i.e., predicate identities that will hold for all formulas F , F 1 , F 2 and every variable x:
true ( ) = TRUE ( ) false ( ) = FALSE ( ) and ( F 1 , F 2 ) = AND ( F 1 , F 2 ) or ( F 1 , F 2 ) = OR ( F 1 , F 2 ) imp F 1 ( F 2 ) = IMP F 1 ( F 2 ) forall x ( F ) = FORALL x ( F ) exists x ( F ) = EXISTS x ( F )

4.4. Categorical Semantics of First-Order Relational Logic

We are now going to elaborate in detail the semantic functors from which all of the above can be shown; this elaboration is inspired from and indeed directly derived from the well-known logical inference rules of first-order logic. The resulting definitions are based on the categorical notions introduced in Section 3, i.e., final and initial objects, products and coproducts, exponentials, and left and right adjoints, respectively. This gives us for every logical operation a “universal” definition of its semantics. Nevertheless, this semantics is also “constructive” in the sense that it is explicitly defined from well-known set-theoretic operations.

4.4.1. Logical Constants

The role of the logical constants in reasoning is exhibited by the following two “rules” which follow directly from Definition 8 (these rules are propositions that are valid for every formula F; they mimic the corresponding inference rules of first-order logic):
F F
In other words, ⊤ is a logical consequence of every formula F, i.e., ⊤ is the “weakest” formula. Dually, every formula F is a logical consequence of ⊥, i.e., ⊥ is the “strongest” formula. This implies that true ( ) = is the final object of category S Y N and false ( ) = is its initial one (see Definition 16). Then, Proposition 8 implies C S Y N true and false C S Y N , i.e., functor true is the right adjoint of the constant functor C S Y N : S Y N 1 while functor false is its left one.
Correspondingly, TRUE ( ) is the final object of category S E M (the “weakest” predicate, i.e., the predicate which is a superset of every predicate) and FALSE ( ) is its initial object (the “strongest” predicate, i.e., the predicate which is a subset of every predicate). By Proposition 8, we then have C S E M TRUE and FALSE C S E M , i.e., functor TRUE is the right adjoint of the constant functor C S E M : S E M 1 while functor FALSE is its left one.
Therefore, corresponding to the above rules for formulas, we have the following rules for every predicate P:
P TRUE ( ) FALSE ( ) P
Since final and initial objects are unique, these rules actually represent implicit but unique definitions of TRUE ( ) and FALSE ( ) which can be explicitly written as
TRUE ( ) : = { P | P Pred } FALSE ( ) : = { P | P Pred }
i.e., TRUE ( ) is the union of all predicates and FALSE ( ) is their intersection. Thus, we have derived alternative characterizations = TRUE ( ) and = FALSE ( ) that are both constructive and universal (Proposition 5 gives us = Ass and = from which it is easy to verify these equalities).

4.4.2. Conjunction and Disjunction

The role of conjunction in reasoning is exhibited by the following rules for arbitrary formulas F 1 , F 2 , F (the first two ones mimic the logical inference rules of “elimination”, and the last one mimics the inference rule of “introduction”):
F 1 F 2 F 1 F 1 F 2 F 2 ( F F 1 ) ( F F 2 ) ( F F 1 F 2 )
Dually, we have the following rules for disjunction:
F 1 F 1 F 2 F 2 F 1 F 2 ( F 1 F ) ( F 2 F ) ( F 1 F 2 F )
These rules (whose soundness can be established with the help of Definition 8) state that ( F 1 F 2 ) is the “weakest” formula F for which both ( F F 1 ) and ( F F 2 ) hold and that ( F 1 F 2 ) is the “strongest” formula F for which both ( F 1 F ) and ( F 2 F ) hold. Thus, and ( F 1 , F 2 ) = ( F 1 F 2 ) is the product of the S Y N -objects F 1 and F 2 and or ( F 1 , F 2 ) = ( F 1 F 2 ) is their coproduct (see Definition 17). Furthermore, by Proposition 9, we have Δ S Y N and and or Δ S Y N i.e., functor and is the right adjoint of the diagonal functor Δ S Y N : S Y N S Y N × S Y N while functor or is its left one.
Correspondingly AND ( P 1 , P 2 ) is the product of the S E M -objects P 1 and P 2 (the “weakest” predicate P for which both ( P P 1 ) and ( P P 2 ) hold) and OR ( P 1 , P 2 ) is their coproduct (the “strongest” predicate P for which ( P 1 P ) and ( P 2 P ) hold). By Proposition 9, we then have Δ S E M AND and OR Δ S E M i.e., functor AND is the right adjoint of the diagonal functor Δ S E M : S E M S E M × S E M , while functor OR is its left one.
Thus, we have, corresponding to the rules for formulas, the following rules for all predicates P 1 , P 2 , P :
AND ( P 1 , P 2 ) P 1 AND ( P 1 , P 2 ) P 2 ( P P 1 ) ( P P 2 ) ( P AND ( P 1 , P 2 ) )
Dually, we have
P 1 OR ( P 1 , P 2 ) P 2 OR ( P 1 , P 2 ) ( P 1 P ) ( P 2 P ) ( OR ( P 1 , P 2 ) P )
Since products and coproducts are uniquely defined, these rules actually represent implicit but unique definitions of AND ( P 1 , P 2 ) and OR ( P 1 , P 2 ) which can be explicitly written as follows:
AND ( P 1 , P 2 ) : = { P Pred | P P 1 P P 2 } OR ( P 1 , P 2 ) : = { P Pred | P 1 P P 2 P }
This gives us alternative characterizations F 1 F 2 = F 1 F 2 = AND ( F 1 , F 2 ) and F 1 F 2 = F 1 F 2 = OR ( F 1 , F 2 ) that are both constructive and universal (Proposition 5 implies F 1 F 2 = F 1 F 2 and F 1 F 2 = F 1 F 2 from which it is not difficult to verify these equalities).

4.4.3. Implication

The role of implication in reasoning is exhibited by the following rules for arbitrary formulas F 1 , F 2 , F (the first rule mimics the logical inference rules of “implication elimination” or “modus ponens”, the last one mimics the inference rule of “implication introduction”):
( F 1 F 2 ) F 1 F 2 ( F F 1 F 2 ) ( F F 1 F 2 )
These rules (whose soundness can be established with the help of Definition 8) state that ( F 1 F 2 ) is the “weakest” formula F for which ( F F 1 F 2 ) holds. Thus, imp F 1 ( F 2 ) = ( F 1 F 2 ) is the exponential of the S Y N -objects F 1 and F 2 (see Definition 19). Proposition 10 then gives us and F 1 imp F 1 , i.e., functor imp F 1 is the right adjoint of the unary conjunction functor and F 1 : S Y N S Y N × S Y N with object map and F 1 ( F 2 ) : = and ( F 1 , F 2 ) = F 1 F 2 .
Correspondingly, IMP P 1 ( P 2 ) is the product of the S E M -objects P 1 and P 2 (the “weakest” predicate P for which ( P P 1 P 2 ) holds; Proposition 10 then gives us AND P 1 IMP P 1 , i.e., functor IMP P 1 is the right adjoint of the unary functor AND P 1 : S E M S E M × S E M with object map AND P 1 ( P 2 ) : = AND ( P 1 , P 2 ) = P 1 P 2 .
Thus, corresponding to above rules for formulas, we have the following rules for all predicates P 1 , P 2 , P :
IMP P 1 ( P 2 ) P 1 P 2 ( P P 1 P 2 ) ( P IMP P 1 ( P 2 ) )
Since exponentials are uniquely defined, these rules represent an implicit but unique definition of IMP P 1 ( P 2 ) which can be explicitly written as follows:
IMP P 1 ( P 2 ) : = { P Pred | P P 1 P 2 }
This gives us an alternative characterization F 1 F 2 = IMP F 1 ( F 2 ) that is both constructive and universal (Proposition 5 implies F 1 F 2 = F 1 ¯ F 2 from which it is possible to verify this equality).

4.4.4. Universal and Existential Quantification

The role of universal quantification in reasoning is exhibited by the following rules for arbitrary formulas F , G provided that the semantics G of G do not depend on x (see Definition 4):
x . F F ( G F ) ( G x . F )
The first rule mimics the logical inference rule of “universal elimination”, the second one mimics the inference rule of “universal introduction” (except that our version of first-order logic does not involve terms and variables and thus copes without variable substitutions). This pair of rules in a nutshell yields that ( x . F ) is the “weakest” formula G from which F is a logical consequence and whose semantics do not depend on x. Dually, we have for existential quantification the following pair of rules:
F x . F ( F G ) ( x . F G )
These rules state that ( x . F ) is the “strongest” formula G that is a logical consequence of F and whose semantics G does not depend on x.
We are now going to derive appropriate categorical characterizations of the corresponding functors forall x Var : S Y N S Y N x and exists x Var : S Y N S Y N x from the category S Y N of all formulas to the subcategory S Y N x of all those formulas whose semantics do not depend on x. For this, we may notice that, from above rules, the relations ( G F ) and ( F G ) involve two kinds of relations, a more general relation F that may depend on x and a more special relation G that is independent of x. In order to bring all relations to the “same level”, we introduce a syntactic “injection” functor I x : S Y N x S Y N whose maps are just identities, i.e., I x ( G ) = G and I x ( f : F G ) = f : F G . This allows us to express above rules as
I x ( forall x ( F ) ) F ( I x ( G ) F ) ( G forall x ( F ) )
and dually
F I x ( exists x ( F ) ) ( F I x ( G ) ) ( exists x ( F ) G )
Now, the first set of rules matches the assumptions of the second part of Proposition 7 for F : = I x and G : = forall x (considering that the satisfaction relation ⊧ denotes the existence of an arrow in categories S Y N , respectively S Y N x ); thus, we have I x forall x . Likewise, the second set of rules matches the assumptions of the first part of that proposition for F : = exists x and G : = I x ; thus, we have exists x I x . Summarizing, the universal functor forall x is the right adjoint of the injection functor I x while the existential functor exists x is its left adjoint.
These considerations can be easily transferred to categorical characterizations of the corresponding functors FORALL x Var : S E M S E M x and EXISTS x Var : S E M S E M x from the category S E M of all predicates to the subcategory S E M x of all those predicates that do not depend on x with the semantic “injection” functor J x : S E M x S E M whose maps are just identities, i.e., J x ( Q ) = Q and J x ( f : P Q ) = f : P Q . We then have
J x ( FORALL x ( P ) ) P ( J x ( Q ) P ) ( Q FORALL x ( P ) )
and dually
P J x ( EXISTS x ( P ) ) ( P J x ( Q ) ) ( EXISTS x ( P ) Q )
Now, the first set of rules matches the assumptions of the second part of Proposition 7 for F : = J x and G : = FORALL x (considering that the subset relation ⊆ denotes the existence of an arrow in categories S E M , respectively S E M x ); thus, we have J x FORALL x . Likewise, the second set of rules matches the assumptions of the first part of that proposition for F : = EXISTS x and G : = J x ; thus, we have EXISTS x J x . Summarizing, the universal functor FORALL x is the right adjoint of the injection functor J x while the existential functor EXISTS x is its left adjoint.
The above rules say that FORALL x ( P ) is the weakest predicate Q that does not depend on x for which ( J x ( Q ) Q ) holds while EXISTS x ( P ) is the strongest predicate Q that does not depend on x for which ( Q J x ( Q ) ) holds. Since left and right adjoints are uniquely defined, these rules represent implicit but unique definitions of FORALL x ( P ) and EXISTS x ( P ) which can be explicitly written as follows:
FORALL x ( P ) : = { Q Pred x | J x ( Q ) P } EXISTS x ( P ) : = { Q Pred x | P J x ( Q ) }
From J x ( Q ) = Q and Q Pred x Q Pred Q x (see Definition 5), this can also be written as follows:
FORALL x ( P ) : = { Q Pred | Q x Q P } EXISTS x ( P ) : = { Q Pred | Q x P Q }
Thus, we have derived alternative characterizations x . F = FORALL x ( F ) and x . F = EXISTS x ( F ) that are both constructive and universal. This is exactly the characterization whose correctness we have proved in Proposition 6.

5. An Implementation of the Categorical Semantics

In this section, we describe how the constructions that we have theoretically modeled in Section 2 can be actually implemented. For this purpose, we use RISCAL (RISCAL is developed at JKU, Linz, Austria, https://www3.risc.jku.at/research/formal/software/RISCAL/, see [13]), the RISC Algorithm Language [13,17], a specification language, and an associated software system for modeling mathematical theories and algorithms in a specification language based on first-order logic and set theory. The language is based on a type system where all types have finite sizes (specified by the user); this allows for fully automatically deciding formulas and verifying the correctness of algorithms for all possible inputs. To this end, the system translates every syntactic phrase into an executable form of its denotational semantics; the RISCAL model checker evaluates these semantics to determine the results of algorithms and the truth values of formulas such as the postconditions of algorithms. Since the domains of RISCAL models have (parameterized but) finite size, the validity of all theorems and the correctness of all algorithms can be fully automatically checked; the system has been mainly employed in educational scenarios [18,19]. Figure 2 gives a screenshot of the software with the RISCAL model that is going to be discussed below.
Figure 3 and Figure 4 list a RISCAL model of the categorical semantics over a domain of N + 1 variables (identified with the natural numbers 0 , , N ) with M + 1 values, for arbitrary model parameters N , M N 0 ; all theorems over these domains are decidable and can be checked by RISCAL. The RISCAL definition of domains, functions, and predicates closely correspond to those given in this paper; in particular, we have a domain Pred of predicates (since the number of variables is finite, by definition all relations are predicates) and predicate functions TRUE, FALSE, AND, OR, IMP, FORALL, EXISTS. Different from the categorical formulation, IMP is a binary function, not a family of unary functions; likewise, FORALL and EXISTS are binary functions whose first argument is a variable. Furthermore, we introduce functions NOT and EQUIV for the semantics of negation and conjunction and show by theorems Not and Equiv that they can be reduced to the other functions.
All other logical operations are first defined in their usual set-theoretic form. Subsequently, we describe their categorical semantics by a pair of theorems: the first theorem claims that the set-theoretic semantics is equivalent to an implicit definition of the categorical semantics while the second theorem claims equivalence to the corresponding constructive definition. Choosing small parameter values N = 2 and M = 1 (i.e., relations with variables x 0 , x 1 , x 2 and values 0 , 1 ), RISCAL can easily check the validity of all claims, as demonstrated by the following output:
RISC Algorithm Language 2.6.4 (10 December 2018)
http://www.risc.jku.at/research/formal/software/RISCAL
(C) 2016-, Research Institute for Symbolic Computation (RISC)
This is free software distributed under the terms of the GNU GPL.
Execute "RISCAL -h" to see the available command line options.
-----------------------------------------------------------------
Reading file /usr2/schreine/papers/CategoricalLogic2019/catlogic.txt
Using N=2.
Using M=1.
Computing the value of Ass...
Computing the value of TRUE...
Computing the value of FALSE...
Type checking and translation completed.
Executing True1().
Execution completed (3 ms).
Executing True2().
Execution completed (1 ms).
Executing False1().
Execution completed (0 ms).
Executing False2().
Execution completed (1 ms).
Executing And1(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65536 inputs.
PARALLEL execution with 4 threads (output disabled).
...
Execution completed for ALL inputs (18,373 ms, 65,536 checked, 0 inadmissible).
Executing And2(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65,536 inputs.
PARALLEL execution with 4 threads (output disabled).
46273 inputs (36446 checked, 0 inadmissible, 0 ignored, 9827 open)...
Execution completed for ALL inputs (3576 ms, 65536 checked, 0 inadmissible).
Executing Or1(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65536 inputs.
PARALLEL execution with 4 threads (output disabled).
...
Execution completed for ALL inputs (26,889 ms, 65,536 checked, 0 inadmissible).
Executing Or2(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65,536 inputs.
PARALLEL execution with 4 threads (output disabled).
42,676 inputs (32,887 checked, 0 inadmissible, 0 ignored, 9789 open)...
Execution completed for ALL inputs (3907 ms, 65,536 checked, 0 inadmissible).
Executing Imp1(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65,536 inputs.
PARALLEL execution with 4 threads (output disabled).
...
Execution completed for ALL inputs (48,592 ms, 65,536 checked, 0 inadmissible).
Executing Imp2(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65,536 inputs.
PARALLEL execution with 4 threads (output disabled).
...
Execution completed for ALL inputs (9462 ms, 65,536 checked, 0 inadmissible).
Executing Not(Set[Array[ℤ]]) with all 256 inputs.
PARALLEL execution with 4 threads (output disabled).
Execution completed for ALL inputs (28 ms, 256 checked, 0 inadmissible).
Executing Equiv(Set[Array[ℤ]],Set[Array[ℤ]]) with all 65,536 inputs.
PARALLEL execution with 4 threads (output disabled).
Execution completed for ALL inputs (354 ms, 65,536 checked, 0 inadmissible).
Executing Forall1(ℤ,Set[Array[ℤ]]) with all 768 inputs.
PARALLEL execution with 4 threads (output disabled).
Execution completed for ALL inputs (1315 ms, 768 checked, 0 inadmissible).
Executing Forall2(ℤ,Set[Array[ℤ]]) with all 768 inputs.
PARALLEL execution with 4 threads (output disabled).
Execution completed for ALL inputs (512 ms, 768 checked, 0 inadmissible).
Executing Exists1(ℤ,Set[Array[ℤ]]) with all 768 inputs.
PARALLEL execution with 4 threads (output disabled).
Execution completed for ALL inputs (1299 ms, 768 checked, 0 inadmissible).
Executing Exists2(ℤ,Set[Array[ℤ]]) with all 768 inputs.
PARALLEL execution with 4 threads (output disabled).
Execution completed for ALL inputs (461 ms, 768 checked, 0 inadmissible).
These values are, however, the largest ones with which model checking is realistically feasible; choosing, for example, N = 3 and M = 2 gives for the checking theorem And1 about 4 × 10 9 possible inputs whose checking on a single processor core would take RISCAL more than two decades.

6. Conclusions

In this paper, we developed a novel categorical interpretation of the semantics of a relational (term-less) variant of first-order logic [20] with the goal to aid the intuitive understanding of these formulas and to lay the seed of tools that illustrate the meaning of these formulas by the visualization of their semantics. The main advantage of this formulation is the (in comparison to other previous approaches) much more explicit illustration of the various logical constructions (connectives and quantifiers) as categorical notions; this may provide an alternative route to teaching semantics for first-order logic. Furthermore, since this categorical semantics is constructive, we could directly implement (and thus validate) it in the RISCAL software.
We hope that this paper, by its self-contained nature and by focusing on the core principles of categorical logic rather than attempting an exhaustive treatment, contributes to the more widespread dissemination of categorical ideas to students and researchers of logic, its applications, and its automation; in particular, it may provide an alternative view on the semantics of first-order logic by complementing the classical formulation and thus help to gain deeper insights.
It remains to be shown, however, whether and how this view can be indeed helpful and illuminating in educational scenarios, i.e., in courses on logic and its applications. In previous works [21,22,23,24], we have strived to improve the understanding of the formal semantics of programming languages by developing corresponding tools with appropriate visualization techniques, partially also based on categorical principles. Other work of ours [25] has extended this work towards the visualization of the semantics of first-order formulas by pruned evaluation trees, however, based on the classical formulation. Future work of us will investigate how the categorical principles outlined in this paper can be transferred to corresponding novel tools and visualization techniques for education in semantics and logic—for instance, in describing software component systems whose semantics are described both from the categorical and the logical side, or elaborating a precise logical definition of contracts that have to be satisfied for a successful composition of components.

Author Contributions

Conceptualization, W.S. (Wolfgang Schreiner), W.S. (William Steingartner) and V.N.; methodology, W.S. (Wolfgang Schreiner) and W.S. (William Steingartner); software, W.S. (Wolfgang Schreiner); validation, W.S. (Wolfgang Schreiner) and W.S. (William Steingartner); formal analysis, W.S. (Wolfgang Schreiner) and W.S. (William Steingartner); investigation, W.S. (Wolfgang Schreiner), W.S. (William Steingartner) and V.N.; resources, W.S. (Wolfgang Schreiner); data curation, W.S. (Wolfgang Schreiner); writing—original draft preparation, W.S. (Wolfgang Schreiner); writing—review and editing, W.S. (William Steingartner); visualization, W.S. (Wolfgang Schreiner); supervision, W.S. (Wolfgang Schreiner) and W.S. (William Steingartner); project administration, W.S. (Wolfgang Schreiner) and W.S. (William Steingartner); funding acquisition, W.S. (Wolfgang Schreiner) and W.S. (William Steingartner). All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the the project KEGA 011TUKE-4/2020: “A development of the new semantic technologies in educating of young IT experts”, also in the frame of the initiative project “Semantic Modeling of Component-Based Program Systems” under the bilateral program “Aktion Österreich–Slowakei, Wissenschafts- und Erziehungskooperation” and by the Johannes Kepler University Linz, Linz Institute of Technology (LIT), Project LOGTECHEDU “Logic Technology for Computer Science Education”.

Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

References

  1. Tarski, A. The Semantic Conception of Truth: In addition, the Foundations of Semantics. Philos. Phenomenol. Res. 1944, 4, 341–376. [Google Scholar] [CrossRef]
  2. Schmidt, D.A. Denotational Semantics—A Methodology for Language Development; Allyn and Bacon: Boston, MA, USA, 1986. [Google Scholar]
  3. Awodey, S. Category Theory, 2nd ed.; Oxford University Press: Okford, UK, 2010. [Google Scholar]
  4. Barr, M.; Wells, C. Category Theory for Computing Science; Prentice-Hall, Inc., Division of Simon and Schuster One Lake Street: Upper Saddle River, NJ, USA, 1990. [Google Scholar]
  5. Brandenburg, M. Einführung in Die Kategorientheorie; Springer Spektrum: Berlin/Heidelberg, Germany, 2017. (In German) [Google Scholar]
  6. Pierce, B.C. Basic Category for Computer Scientists; MIT Press: Cambridge, MA, USA, 1991. [Google Scholar]
  7. Spiwak, D.I. Category Theory for the Sciences; MIT Press: Cambridge, MA, USA, 2014. [Google Scholar]
  8. Lawvere, F.W. Adjointness in Foundations. Dialectica 1969, 23, 281–296. Available online: http://www.tac.mta.ca/tac/reprints/articles/16/tr16.pdf (accessed on 9 March 2020). [CrossRef] [Green Version]
  9. Jacobs, B. Categorical Logic and Type Theory; Studies in Logic and the Foundations of Mathematics; Elsevier: Amsterdam, The Netherlands, 1999; Volume 141. [Google Scholar]
  10. Abramsky, S. Logic and Categories As Tools For Building Theories. J. Indian Counc. Philos. Res. Issue Log. Philos. Today 2010, 27, 277–304. [Google Scholar]
  11. Poigné, A. Category Theory and Logic. In Proceedings of the Category Theory and Computer Programming: Tutorial and Workshop, Guildford, UK, 16–20 September 1985; Lecture Notes in Computer Science; Springer: Berlin, Germany; Volume 240, pp. 103–142. [CrossRef]
  12. Abramsky, S.; Tzevelekos, N. Introduction to Categories and Categorical Logic. In New Structures for Physics; Lecture Notes in Physics; Springer: Berlin, Germany, 2010; Volume 813, pp. 3–94. [Google Scholar] [CrossRef] [Green Version]
  13. RISCAL. The RISC Algorithm Language (RISCAL). Available online: https://www3.risc.jku.at/research/formal/software/RISCAL/ (accessed on 9 July 2020).
  14. Schreiner, W.; Reichl, F.X. Mathematical Model Checking Based on Semantics and SMT. Trans. Internet Res. 2020, 16, 4–13. [Google Scholar]
  15. Semtech. Semantic Technologies for Computer Science Education. Available online: https://www3.risc.jku.at/projects/SemTech/ (accessed on 15 July 2020).
  16. Nielson, H.R.; Nielson, F. Semantics with Applications: An Appetizer; Undergraduate Topics in Computer Science; Springer: London, UK, 2007. [Google Scholar]
  17. Schreiner, W. The RISC Algorithm Language (RISCAL)—Tutorial and Reference Manual (Version 1.0); Technical Report; RISC, Johannes Kepler University: Linz, Austria, 2017. [Google Scholar]
  18. Schreiner, W. Validating Mathematical Theories and Algorithms with RISCAL. In Proceedings of the 11th Conference on Intelligent Computer Mathematics (CICM 2018), Hagenberg, Austria, 13–17 August 2018; Rabe, F., Farmer, W., Passmore, G., Youssef, A., Eds.; Lecture Notes in Computer Science/Lecture Notes in Artificial Intelligence; Springer: Berlin, Germany, 2018; Volume 11006, pp. 248–254. [Google Scholar] [CrossRef]
  19. Schreiner, W.; Brunhuemer, A.; Fürst, C. Teaching the Formalization of Mathematical Theories and Algorithms via the Automatic Checking of Finite Models. In Proceedings of the Post-Proceedings ThEdu’17, Theorem Proving Components for Educational Software, Gothenburg, Sweden, 6 August 2017. [Google Scholar]
  20. Schreiner, W.; Novitzká, V.; Steingartner, W. A Categorical Semantics of Relational First-Order Logic; Technical Report; RISC, Johannes Kepler University: Linz, Austria, 2019. [Google Scholar]
  21. Schreiner, W.; Steingartner, W. Visualizing Execution Traces in RISCAL; Technical Report; RISC, Johannes Kepler University: Linz, Austria, 2018. [Google Scholar]
  22. Steingartner, W.; Eldojali, M.A.M.; Radaković, D.; Dostál, J. Software support for course in Semantics of programming languages. In Proceedings of the IEEE 14th International Scientific Conference on Informatics, Poprad, Slovakia, 14–16 November 2017; pp. 359–364. [Google Scholar]
  23. Steingartner, W.; Novitzká, V. Categorical Semantics of Programming Langages. In Selected Topics in Contemporary Mathematical Modeling; Monographs; Czestochowa University of Technology: Czestochowa, Poland, 2017; Volume 331, Chapter 11; pp. 167–192. [Google Scholar]
  24. Steingartner, W.; Novitzká, V. Learning tools in course on semantics of programming languages. In Proceedings of the MMFT 2017—Mathematical Modelling in Physics and Engineering, Poraj, Poland, 18–21 September 2017; pp. 137–142. [Google Scholar]
  25. Schreiner, W.; Steingartner, W. Visualizing Logic Formula Evaluation in RISCAL; Technical Report; RISC, Johannes Kepler University: Linz, Austria, 2018. [Google Scholar]
Figure 1. A Categorical Semantics of Relational First-Order Logic.
Figure 1. A Categorical Semantics of Relational First-Order Logic.
Symmetry 12 01584 g001
Figure 2. The RISCAL Software.
Figure 2. The RISCAL Software.
Symmetry 12 01584 g002
Figure 3. A RISCAL Model of the Categorical Semantics (Part 1).
Figure 3. A RISCAL Model of the Categorical Semantics (Part 1).
Symmetry 12 01584 g003
Figure 4. A RISCAL Model of the Categorical Semantics (Part 2).
Figure 4. A RISCAL Model of the Categorical Semantics (Part 2).
Symmetry 12 01584 g004

Share and Cite

MDPI and ACS Style

Schreiner, W.; Steingartner, W.; Novitzká, V. A Novel Categorical Approach to Semantics of Relational First-Order Logic. Symmetry 2020, 12, 1584. https://doi.org/10.3390/sym12101584

AMA Style

Schreiner W, Steingartner W, Novitzká V. A Novel Categorical Approach to Semantics of Relational First-Order Logic. Symmetry. 2020; 12(10):1584. https://doi.org/10.3390/sym12101584

Chicago/Turabian Style

Schreiner, Wolfgang, William Steingartner, and Valerie Novitzká. 2020. "A Novel Categorical Approach to Semantics of Relational First-Order Logic" Symmetry 12, no. 10: 1584. https://doi.org/10.3390/sym12101584

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop