5.3.3. Generalized Sketch Arrows and Sketch Implications

To be able to formulate a characterization of the validity of conditional Σ-equations by means of a closedness property, in the sense of Proposition 3, we have to consider more general sketch arrows based on the substitution of variables by terms. First, we extend the category Cxt*EQ* by Kleisli morphisms.

**Definition 25** (Generalized Context Morphisms)**.** *We consider an Institution of Equations* IE = (Cxt*EQ*, Eq, Int, |=) *and a signature* Σ = (Ω, *in*, *out*) *. A* Σ*- context morphism ϕ* : *K* → *G is given by an S-map ϕ* : *K* → *T*Σ(*G*)*. The composition ϕ*; *ψ* : *K* → *H of two* Σ*-context morphisms ϕ* : *K* → *G, ψ* : *G* → *H is given by the S-map ϕ*; *ψ*<sup>∗</sup> : *K* → *T*Σ(*H*) *where ψ*<sup>∗</sup> : *T*Σ(*G*) → *T*Σ(*H*) *is the usual translation of* Σ*-terms induced by the substitution <sup>ψ</sup>* : *<sup>G</sup>* <sup>→</sup> *<sup>T</sup>*Σ(*H*)*.* Cxt<sup>Σ</sup> *EQ denotes the category of all contexts and all* Σ*-context morphisms.*

By construction, Cxt*EQ* is a subcategory of Cxt<sup>Σ</sup> *EQ* for any signature Σ. Second, the sentence functor Eq : Cxt*EQ* <sup>→</sup> Set extends to a functor Eq<sup>Σ</sup> : Cxt<sup>Σ</sup> *EQ* → Set with:

$$\operatorname{Eq}^{\Sigma}(\mathfrak{q})(\mathsf{K}, t\_1 = t\_2) := (\mathsf{G}, \mathfrak{q}^\*(t\_1) = \mathfrak{q}^\*(t\_2))\tag{20}$$

for all Σ-context morphisms *ϕ* : *K* → *G*, i.e., for all *S*-maps *ϕ* : *K* → *T*Σ(*G*), and all Σ-equations (*K*, *t*<sup>1</sup> = *t*2) in *K*. Since *id*<sup>∗</sup> *<sup>K</sup>* = *idT*Σ(*K*) and (*ϕ*; *ψ*∗)<sup>∗</sup> = *ϕ*∗; *ψ*<sup>∗</sup> for all *S*-maps *ϕ*: *K* → *T*Σ(*G*), *ψ*: *G* → *T*Σ(*H*), this defines indeed a functor.

**Remark 31** (Generalized Sketch Implications)**.** *We will use, implicitly, strict* EqΣ*-sketch arrows to formulate a characterization of the validity of conditional* Σ*-equations by means of a closedness property in the sense of Proposition 3.*

*Besides this, it is very tempting to consider also "generalized sketch implications", defined by* EqΣ*-sketch arrows, and to study validity, entailment and factorization for those generalized sketch implications. In particular, it would be interesting to clarify the relation between those generalized sketch implications and the morphisms in the Lawvere theories for partial algebraic specifications we studied in [9].*

*For now, we overcome this temptation and postpone the study of generalized sketch implications to a following paper. We will concentrate on conditional* Σ*-equations and corresponding constructions and results.*

*Before this, we would like to add a short side note:* Σ*-terms appear on an "internal level" as constituents of* Σ*-equations and on an "external level" as constituents of generalized context morphisms. Our ongoing studies around* graph algebras *indicate that we will probably need closely related, but different, concepts for these distinct levels if we want to generalize the idea of operations to graphs (and other kinds of presheaves).*

To avoid headaches, we formulate explicitly the respective instance of Definition 23 for conditional Σ-equations (compare [7]).

**Definition 26** (Closedness for Conditional Equations)**.** *An* Eq*-sketch* E = (*X*, *E*) *is closed w.r.t. the underlying* Eq*-sketch arrow* (*Y*, *Prem*) → (*Y*, *Conc*) *of a conditional* Σ*-equation* (*Y*, *Prem*) ⇒ (*Y*, *Conc*) *if, and only if, for all* Σ*-context morphisms ι* : *Y* → *X, i.e., all substitutions ι* : *Y* → *T*Σ(*X*)*, it holds that ι* <sup>∗</sup>(*Prem*) ⊆ *E implies ι* <sup>∗</sup>(*Conc*) ⊆ *E.*

In addition, here is the respective specialized instance of Proposition 3.

**Corollary 5** (Validity ∼= Closedness for Conditional Equations)**.** *For any* Eq*-sketch arrow* (*Y*, *Prem*) → (*Y*, *Conc*)*, the following two statements are equivalent for any* Σ*-algebra* A*:*


**Remark 32** (Sketch Arrows as Deduction Rules)**.** *The most natural thing to do, if a structure is not closed w.r.t. a certain construction, is to repair this flaw by simply adding the missing parts. Applying this universal "repairing principle" to the closedness property in Definition 26, means nothing but to add new* Σ*-equations to a given set of* Σ*-equations by deploying* Eq*-sketch arrows as deduction rules.*

*To apply an* Eq*-sketch arrow* (*Y*, *Prem*) → (*Y*, *Conc*) *as a deduction rule, we have, first, to find a match of the left-hand side* (*Y*, *Prem*) *of the rule in an* Eq*-sketch* E = (*X*, *E*)*, i.e., a substitution ι* : *Y* → *T*Σ(*X*) *such that ι* <sup>∗</sup>(*Prem*) ⊆ *E. Second, we apply the rule for this match and generate the* Eq*-sketch* (*X*, *E* ∪ *ι* ∗(*Conc*))*. The resulting commutative square becomes a pushout in the category of all strict* EqΣ*-sketch arrows if E* <sup>∩</sup> *<sup>ι</sup>* <sup>∗</sup>(*Conc* \ *Prem*) = ∅*.*

$$(Y, Perm) \xrightarrow{id\_Y} (Y, Conc)$$

$$(X, E) \xrightarrow{id\_X} (X, E \cup \iota^\*(Conc))$$

**Remark 33** (Answer to Question 1)**.** *Based on the concepts* sketch*,* sketch implication*,* sketch arrow *and the related general definitions and results, we presented so far, we can give a kind of reasonable answer to Question 1 (p.3):*

*Each sketch implication has an underlying sketch arrow and, the other way around, each sketch arrow gives rise to a sketch implication. Due to Proposition 3 (Validity* ∼= *Closedness), the validity of sketch implications in semantic structures can be, moreover, equivalently expressed by a closedness property of sketch encodings of semantic structures w.r.t. sketch arrows.*

*Each sketch arrow of the form* P → C *can be utilized as a rule allowing us to deduce new sketches from given sketches (as exemplified in Remark 32). Proposition 3 and Theorem 2 (Semantic Deduction Theorem) ensure that those deductions are sound and that they allow us, moreover, to deduce sketch implications semantically entailed by a given set of sketch implications.*

#### **6. Sketch Conditions and Constraints**

In the preceding sections, we identified two main motivations to develop concepts and tools, deploying the expressiveness of first-order logic, to describe and reason about the structure of sketches. First, there is the need for those tools to specify the syntactic structure of software models. The second, more general, motivation concerns the structure of sketch encodings of semantic structures. If we use first-order tools to axiomatize the semantic structures we are interested in, it would be good to have corresponding first-order tools to axiomatize and reason about the sketch encodings of those semantic structures.

Software models are usually graph-based structures, thus we should not ignore the concepts and tools, developed in the area of Graph Transformations, to describe and axiomatize the structure of graphs. Therefore, we discuss in this section also four representative first-order based approaches to describe and axiomatize the structure of (different kinds of) graphs [22–25] . We will present a universal and fully first-order mechanism to describe the structure of sketches which unifies and generalizes all these approaches.
