*5.1. Sketches of Statements: Syntax and Semantics*

To be prepared for the topics in Section 6, we introduce a very abstract and semanticsindependent concept of *sketch*.

**Definition 16** (Sketch)**.** *Let us have a category* Ct *of* contexts *and a functor* St : Ct → Set*, assigning to each K* ∈ Ct*Obj a set* St(*K*) *of all statements in context K.*

*An* St*- sketch* <sup>K</sup> = (*K*, *St*K) *is given by a context <sup>K</sup>* <sup>∈</sup> Ct*Obj and a set St*<sup>K</sup> <sup>⊆</sup> St(*K*) *of statements in context K.*

In this subsection, we consider the case Ct = Cxt, St = Stm with IS = (Cxt, Stm, Int, |=) an arbitrary Institution of Statements according to Theorem 1.

All definitions and constructions are, however, institution-independent; thus, they apply analogously to the case Ct = Cxt*EQ*, St = Eq with IE = (Cxt*EQ*, Eq, Int, |=) an arbitrary Institution of Equations according to Proposition 2.

**Example 36** (FOL: Sketches)**.** *We extend the sample context K in Example 31 to an* Stm*FOL-sketch* K *with the atomic statements (facts)* parent(*Anna*, *Uwe*, *Gabi*)*,* parent(*Uwe*, *Heinz*, *Dora*)*,* male(*Michael*) *and the proper first-order statements* ([*y* : *prs*],*sbl*,(*y* → *Michael*))*,* ([*y* : *prs*],*sbl*,(*y* → *Uwe*))*,* ([*y* : *prs*, *x* : *nat*], *younger*,(*y* → *Michael*, *x* → 12))*,* ([*y* : *prs*],*sbl*,(*y* → *Gabi*))*. The expression* [*y* : *prs*] *sbl, representing the property* being sibling of someone*, and the expression* [*y* : *prs*, *x* : *nat*] *younger, representing the property* younger than*, are defined in Example 26.*

**Example 37** (ALC: Sketches)**.** *Contexts in ALC are* sets *NO* of individual names *as already mentioned in Example 32. A* concept assertion *in ALC, i.e., a statement of the form a* : C *with a* ∈ *NO and* C *a (derived) concept, can be seen as a statement* ({*x*1}, C(*x*1),(*x*<sup>1</sup> → *a*)) *in NO where the assignment* (*x*<sup>1</sup> → *a*) *defines a binding β* : {*x*1} → *NO with β*(*x*1) = *a.*

*A* role assertion*, i.e., a statement of the form* (*a*, *b*) : R *where a*, *b* ∈ *NO and* R *is a role, can be seen as a statement* ({*x*1, *x*2}, R(*x*1, *x*2),(*x*<sup>1</sup> → *a*, *x*<sup>2</sup> → *b*)) *in NO. An* ABox *in ALC is a finite set of* assertional axioms*. Thus, a pair* (*NO*, A) *of a* set *NO* of individual names *and an ABox* A *of* assertional axioms *in NO is just an* Stm*ALC-sketch in our sense.*

**Example 38** (mFOL: Sketches)**.** *We extend the context* (*K*, *τ<sup>K</sup>* : *K* → *MmF*) *in Example 33 to an* Stm*mF-sketch with the atomic statements* un(*male* : *P*, *prs* : *S*)*,* bin(*less* : *P*, *nat* : *S*, *nat* : *S*)*,* bin(*age* : *P*, *prs* : *S*, *nat* : *S*) *and* trt(*parent* : *P*, *prs* : *S*, *prs* : *S*, *prs* : *S*)*.*

*Obviously, this* Stm*mF-sketch describes exactly the sample footprint* Ξ*FOL in Example 11! Actually, we can describe all FOL-footprints, declaring only unary, binary or tertiary predicate symbols, as* Stm*mF-sketches. This fact confirms that the mFOL-example establishes indeed a metalevel for the FOL-example.*

*We have to be aware, however, that not all* Stm*mF-sketches correspond to FOL-footprints. For each predicate symbol in a FOL-footprint, we have to declare an arity, and this arity should be unique! Therefore, only those* Stm*mF-sketches, with exactly one atomic statement for each element in τ*−<sup>1</sup> *<sup>K</sup>* (*P*) *correspond to FOL-footprints. To describe those requirements concerning the structure of sketches, we can utilize* sketch implications*, introduced in the next subsection, and/or* sketch constraints *introduced in Section 6.*

**Example 39** (CT: Sketches)**.** *These are just the sketches, as we know them from Category Theory, with the essential difference that we are not restricting ourselves to commutative, limit and colimit statements only. We do not need to encode, for example, the concept* monomorphism *by means of pullbacks but can define it directly as a property of edges utilizing the* Ξ*CT-expressions we discussed in Example 29.*

*As an example, we consider the context G from Example 34 and extend it to an* Stm*CT-sketch* G = (*G*, *St*G) *visualized above. St*<sup>G</sup> *contains the atomic statements* cmp(*a*, *b*,*e*)*,* cmp(*a*, *b*, *f*)*,* cmp(*c*, *d*, *g*) *and the proper first-order statements:*

(*xv*, *f nl*,(*xv* → 3))*,* (*xv*<sup>1</sup> *xe* → *xv*2, *mon*,(*xe* → *b*))*,* (*xv*<sup>1</sup> *xe* → *xv*2, *mon*,(*xe* → *g*))*.*

**Example 40** (RM: Sketches)**.** *We extend the sample context* (*K*, *τK*) *from Example 35 to an* Stm*RM-sketch* K = (*K*, *St*K)*. First, we declare two tables, i.e., St*<sup>K</sup> *contains two atomic statements* tb(3)(*γ*1)*,* tb(3)(*γ*2) *with bindings γ*<sup>1</sup> *and γ*<sup>2</sup> *visualized by the following typed graphs:*

*Then, we declare for each table a primary key, i.e., we add two atomic statements* pk(*γ*3)*,* pk(*γ*4) *with bindings <sup>γ</sup>*3*, <sup>γ</sup>*<sup>4</sup> *given by Empl: <sup>T</sup> eid: <sup>c</sup> Int: <sup>D</sup> and Addr: <sup>T</sup> <sup>A</sup>*.*ssn: <sup>c</sup> Int: <sup>D</sup> . Moreover, we declare a foreign key* fk(*γ*5) *with <sup>γ</sup>*<sup>5</sup> *depicted by Empl: <sup>T</sup> <sup>E</sup>*.*ssn: <sup>c</sup> A*.*ssn: c xt*2*: T .*

*Int: <sup>D</sup> We could also require that each employee has a name and add an atomic statement* tot(*γ*6)

*with <sup>γ</sup>*<sup>6</sup> *given by Empl: <sup>T</sup> name: <sup>c</sup> String: <sup>D</sup> . Analogously to the requirements in Example 38, we do have the requirement that a table*

*identifier can only appear once in a* tb(n)*-statement. There are, however, other database specific requirements: Any table should have exactly one primary key, a foreign key has to refer to a primary key, and others. As said before, to describe those kinds of structural requirements, we need* sketch implications *and/or* sketch constraints*.*

For any context *K* in Cxt, any set *S* ⊆ Stm(*K*) of statements in *K* and any interpretation (*ι*, U) of context *K* in a Ξ-structure U we define, relying on Definition 14:

(*ι*, U) |=*<sup>K</sup> S* iff (*ι*, U) |=*<sup>K</sup>* (*X*, *Ex*, *γ*) for all (*X*, *Ex*, *γ*) ∈ *S*. (11)

Be aware that the statements in *S* may have different variable declarations *X*.

**Definition 17** (Interpretation of sketch)**.** *A valid interpretation (model) of an* Stm*-sketch* <sup>K</sup> = (*K*, *St*K) *is an interpretation* (*ι*, <sup>U</sup>) *of context K such that* (*ι*, <sup>U</sup>) <sup>|</sup>=*<sup>K</sup> St*K*.*

*We denote by* Int(K) *the full subcategory of* Int(*K*) *determined by all valid interpretations of* K *and by* Π<sup>K</sup> : Int(K) → Sem(Ξ) *we denote the corresponding restriction of the projection functor* Π*<sup>K</sup>* : Int(*K*) → Sem(Ξ)*.*

**Remark 21** (Traditional presentations)**.** *If* Base *has an initial object* **0***, we can consider sketches* (**0**, *St*) *with St only containing* closed formulas*, i.e., statements of the form* (**0**, *Ex*, *id***0**) *(see Remark 15). As discussed before, the projection functor* Π**<sup>0</sup>** : Int(**0**) → Sem(Ξ)*, due to Definition 13, is an isomorphism. In such a way,* (**0**, *St*) *is not only determining the interpretation subcategory* Int(**0**, *St*) Int(**0**) *but can also be seen as a* presentation (specification) *of the corresponding full subcategory* Sem(Ξ,(**0**, *St*)) := Π**0**(Int(**0**, *St*)) *of* Sem(Ξ) *isomorphic to* Int(**0**, *St*)*.*

*In other words: due to Remark 18, we can describe* Sem(Ξ,(**0**, *St*)) *as the full subcategory of* Sem(Ξ) *given by all* Ξ*-structures* U = (*U*, Φ<sup>U</sup> ) *in* Sem(Ξ) *such that* U |= (**0**, *Ex*, *id***0**) *for all closed formulas* (**0**, *Ex*, *id***0**) *in St.*

**Example 41** (FOL: Interpretations)**.** *If we interpret the symbolic literals in Kprs* = {*Anna*, *Michael*, *Dora*, *Heinz*, *Sorin*, *Gabi*, *Uwe*} *by the real persons in our family in December 2021, we will not obtain a valid interpretation of the* Stm*FOL-sketch* K *in Example 36 since the statement* ([*y* : *prs*],*sbl*,(*y* → *Gabi*)) *is not satisfied by this interpretation. If we use, however, the statement* ([*y* : *prs*], ¬*sbl*,(*y* → *Gabi*)) *instead, the interpretation becomes valid.*

*Note that the statement* ([*y* : *prs*],*sbl*,(*y* → *Uwe*)) *is satisfied by the interpretation even if there is no witness for this statement in the context. Uwe's only sister Brita is not present in the context K!*

**Example 42** (mFOL: Interpretations)**.** *An interpretation of the sample context* (*K*, *τK*) *assigns to each element in τ*−<sup>1</sup> *<sup>K</sup>* (*S*) :<sup>=</sup> {*prs*, *nat*} *and <sup>τ</sup>*−<sup>1</sup> *<sup>K</sup>* (*P*) := {parent, male, age, less}*, respectively, a set. Since* Base*mF is the slice category* SET/*MmF, a certain set can either serve as a sort or as a predicate.*

*Our choice of* Sem(Ξ*mF*) *in Example 23 ensures, in addition, that the valid interpretations of the sample* Stm*mF-sketch from Example 38 are in one-to-one correspondence to the* Ξ*FOL-structures in* Sem(Ξ*FOL*) = Str(Ξ*FOL*)*. We do have such a semantical one-to-one correspondence for any FOL-footprint, declaring only unary, binary or tertiary predicate symbols, and the corresponding* Stm*mF-sketch. This confirms that the mFOL-example establishes a meta-level for the FOL-example also w.r.t. semantics.*

*It is maybe worth mentioning that any* Stm*mF-sketch with two different atomic statements for, at least, one element in τ*−<sup>1</sup> *<sup>K</sup>* (*P*) *has no valid interpretation at all in* Sem(Ξ*mF*)*.*

**Example 43** (Category Theory: Interpretations)**.** *Since we defined in Example 24 a very liberal semantics, we do have interpretations* (*ι*, U)*,* U = (*U*, Φ<sup>U</sup> *CT*) *of the sample* Stm*CT-sketch* <sup>G</sup> = (*G*, *St*G) *in Example 39, where the graph homomorphism <sup>ι</sup>* : *<sup>G</sup>* <sup>→</sup> *<sup>U</sup> maps the edges <sup>e</sup> and <sup>f</sup> to different edges in U even if both are declared as the composition of a and b.*

*If we would have also included into the sketch* G *the* general statement (**0**, *guc*, !*G*) *with the closed expression* **0** *guc expressing the property* composititon is always unique *(see Example 29),* (*ι*, U) *could be only a valid interpretation of* G *if ι identifies e and f .*

**Example 44** (RM: Interpretations)**.** *Analogously to Example 42, our choice of* Sem(Ξ*RM*) *in Example 25 ensures that the valid interpretations of "well-formed"* Stm*RM-sketches, i.e.,* Stm*RMsketches representing database schemata, formalize exactly the traditional semantics of database schemata as outlined in Subsection 3.1.5.*

Morphisms between sketches are defined by means of semantic entailment in a certain Institution of Statements IS = (Cxt, Stm, Int, |=).

**Definition 18** (Statement entailment)**.** *For any context K in* Cxt *and any sets S*, *T* ⊆ Stm(*K*) *of statements in K, we say that S entails T in a* Ξ*- structure* U*, S* <sup>U</sup> *<sup>K</sup> T in symbols, if, and only if, for all interpretations* (*ι*, U) *of K in* U*:* (*ι*, U) |=*<sup>K</sup> S implies* (*ι*, U) |=*<sup>K</sup> T.*

*S entails T, S <sup>K</sup> T in symbols, if, and only if, S* U *<sup>K</sup> T for all* Ξ*-structures* U *in* Sem(Ξ)*.*

**Definition 19** (Sketch morphism)**.** *An* IS*-morphism ϕ* : K G *between two* Stm*-sketches* <sup>K</sup> = (*K*, *St*K)*,* <sup>G</sup> = (*G*, *St*G) *is a morphism <sup>ϕ</sup>* : *<sup>K</sup>* <sup>→</sup> *<sup>G</sup> in* Cxt *such that St*<sup>G</sup> *<sup>G</sup>* Stm(*ϕ*)(*St*K)*. An* IS*-morphism <sup>ϕ</sup>* : <sup>K</sup> <sup>G</sup> *is called strict if St*<sup>G</sup> <sup>⊇</sup> Stm(*ϕ*)(*St*K)*.*

Sk(IS)*<sup>m</sup> denotes the category of all* Stm*-sketches and all* IS*-morphisms between them. Its subcategory of all* Stm*-sketches and all strict* IS*-morphisms is denoted by* Sk(IS)*<sup>m</sup> s .*

We will consider three different kinds of directed relationships between sketches distinguished by three different kinds of arrow-symbols. We choose the arrow-symbol "" for sketch morphisms since it is the kind of directed relationship we will mention the least.

If IS is clear from the context, we will also use the shorthand notations Sk*<sup>m</sup>* and Sk*<sup>m</sup> s* instead of Sk(IS)*<sup>m</sup>* and Sk(IS)*<sup>m</sup> <sup>s</sup>* , respectively.

IS-morphisms *ϕ* : K G with *K* = *G* and *ϕ* = *idK* simply reflect statement entailments. For any IS-morphism *<sup>ϕ</sup>* : <sup>K</sup> <sup>G</sup>, the condition *St*<sup>G</sup> *<sup>G</sup>* Stm(*ϕ*)(*St*K) ensures, due to the satisfaction condition that the functor Int(*ϕ*) : Int(*G*) → Int(*K*) restricts to a functor from Int(G) into Int(K). In such a way, the assignments K → Int(K) extend to a functor IntSk : (Sk*m*)*op* <sup>→</sup> Cat.

According to well-known general results (see Corollary 4.3 in [2]), we know that Sk*<sup>m</sup>* has whatever limits or colimits the category Cxt has since limits and colimits in the category Sk*<sup>m</sup>* of Stm-sketches and IS-morphisms are constructed by means of limits and colimits in the category Cxt, respectively (compare Propositions 5 and 6). This ensures also that we do have *amalgamation* [1,2,38]: IntSk : (Sk*m*)*op* <sup>→</sup> Cat maps all colimits in Cxt that are preserved by the inclusion Cxt Base, to limits in Cat.

The Theory of Institutions gives us "for free" Stm-sketches, IS-morphisms, the category Sk*<sup>m</sup>* as well as the *extended model functor* IntSk : (Sk*m*)*op* <sup>→</sup> Cat.

However, to employ sketches as a specification formalism and to develop deduction calculi for sketches, we need a number of other concepts, constructions and results.

#### *5.2. Sketches of Statements vs. Structures*

In the Introduction, we discussed, among other things, two central motivations for the development of our framework: (1) We want to be able to give a general abstract account of the concept of free structures generalizing concepts like a group generated by a set of generators and a set of defining relations. (2) We want to provide an alternative general mechanism to encode structures "syntactically" that avoids the kind of circularity inherent to the technique of "signature extensions".

In the remaining part of this section, we outline proposals to meet these objectives.

#### 5.2.1. Freely Generated Structures

To reconstruct the concept of a group generated by a set of generators and a set of defining relations, we need operations only. Those cases of free algebras are discussed in Section 5.3.1.
