{'fraction_non_alphanumeric': 0.0586549940310386, 'fraction_numerical': 0.009709510545165142, 'mean_word_length': 3.8678934624697336, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Novel Categorical Approach to Semantics of Relational First-Order Logic

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.


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 agr eed 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.

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: 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: 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: 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 For 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): 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: 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

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.
∈ 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.
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 → Thus, F 1 depends on a variable y ∈ X which contradicts the induction assumption.
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: Definition 11 (Logical Equivalence). Let F, G ∈ For be formulas. We define F ≡ G (read: F and G are logically equivalent) as follows: Proposition 4 (Logical Consequence and Logical Equivalence). Let F, G ∈ For be formulas. Then, we have the following equivalences: 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: 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: 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
(1) 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 and prove a ∈ ∀x. F . For this, we take arbitrary v ∈ Val and prove a[ From (7) and 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 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.
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 and thus a 0 ∈ ∃x. F .

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.

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 : Furthermore, the composition satisfies the following axioms: 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 D if every C -object is also a D-object, every C -arrow is also a D-arrow, every identity arrow in C is also an identity arrow in D, 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 D.

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: 1 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: 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: 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 : 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: Since the exponential is also defined by a universal construction, it is uniquely defined up to isomorphism.

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 D be categories. A functor F : C → D is a map that takes every C -object a to a D-object F(a) and every C -arrow f : Definition 21 (Adjunction, Left, and Right Adjoint). Let C and D be categories with functors F : C → D and G : D → 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 D-object b the arrow classes D(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 D-object b, there exist two surjective mappings s 1 : D(F(a), b) → C (a, G(b)) and s 2 : C (a, G(b)) → D(F(a), b), i.e., • for every D-arrow g : 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 D be categories with functors F : C → D and G : D → 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 D-object b and C -arrow f : a → G(b), there exists a D-arrow g b, f : F(a) → b: 2. For every D-object b, there is a C -arrow v : F(G(b)) → b, the "couniversal arrow", such that, for every C -object a and D-arrow g : F(a) → b, there is a C -arrow f a,g : Proof. See the proof of Propositions 6 and 7 in [12].

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.
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 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.

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.

Syntactic Category and Formula Functors
We start by introducing the "syntactic category" SYN = 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 : 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, SYN x is that subcategory of SYN 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: 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): As for the mapping of consequences, we notice that all functors are covariant in their SYN 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: Therefore, the object maps of these functors naturally induce the necessary logical consequences.

Semantic Category and Predicate Functors
Next, we introduce the "semantic category" SEM = Pred, B, • as follows: • The objects of this category are the predicates in the set Pred which was introduced in Definition 5 (thus SEM -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, SEM x is the subcategory of SEM 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): 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 SEM -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: Therefore, the object maps of these functors (defined by the respective predicate operations) naturally induce appropriate arrow maps (the corresponding subset relations).

The Semantic Functor
Now, we introduce the "semantic functor" : SYN → SEM defined as follows: • For every SYN -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 SEM -object.
• For every SYN -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 SEM -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 SEM -objects, i.e., predicate identities that will hold for all formulas F, F 1 , F 2 and every variable x:

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.

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): 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 SYN and false( * ) = ⊥ is its initial one (see Definition 16).
Then, Proposition 8 implies C SYN true and false C SYN , i.e., functor true is the right adjoint of the constant functor C SYN : SYN → 1 while functor false is its left one.
Correspondingly, TRUE( * ) is the final object of category SEM (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 SEM TRUE and FALSE C SEM , i.e., functor TRUE is the right adjoint of the constant functor C SEM : SEM → 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 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).

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"): Dually, we have the following rules for disjunction: 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 SYN -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 ∆ SYN and and or ∆ SYN i.e., functor and is the right adjoint of the diagonal functor ∆ SYN : SYN → SYN × SYN while functor or is its left one.
Correspondingly AND(P 1 , P 2 ) is the product of the SEM -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 ∆ SEM AND and OR ∆ SEM i.e., functor AND is the right adjoint of the diagonal functor ∆ SEM : SEM → SEM × SEM , while functor OR is its left one.

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"): 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 SYN -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 : SYN → SYN × SYN 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 SEM -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 : SEM → SEM × SEM 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: 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: 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).

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): 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: 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 : SYN → SYN x and exists x∈Var : SYN → SYN x from the category SYN of all formulas to the subcategory SYN 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 : SYN x → SYN whose maps are just identities, i.e., I x (G) = G and I x ( f : This allows us to express above rules as 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 SYN , respectively SYN 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 : SEM → SEM x and EXISTS x∈Var : SEM → SEM x from the category SEM of all predicates to the subcategory SEM x of all those predicates that do not depend on x with the semantic "injection" functor J x : SEM x → SEM whose maps are just identities, i.e., J x (Q) = Q and 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 SEM , respectively SEM 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: Definition 5), this can also be written as follows: 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.

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. ; 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. Subsequ describe their categorical semantics by a pair of theorems: the first theorem claims that the setsemantics is equivalent to an implicit definition of the categorical semantics while the second claims equivalence to the corresponding constructive definition. Choosing small paramete N = 2 and M = 1 (i.e., relations with variables x 0 , x 1 , x 2 and values 0, 1), RISCAL can easily c validity of all claims, as demonstrated by the following output: 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.

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. 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".