*6.2. First-Order Sketch Conditions and Constraints*

Generalizing different variants of graph conditions [14,22–25] as well as universal conditions and negative universal conditions in DPF [18,21], we define general first-order sketch conditions, which are redundant in the sense that we introduce, for example, as well existential as universal quantification and as well a symbol *T* for "true" as the the empty conjunction ∅. We define fully fledged first-order conditions and do not restrict ourselves to the traditional approach in Graph Transformations to define tree-like first-order conditions only (even if we see the practical relevance of those tree-like conditions). We define first-order sketch conditions in full analogy to the Definition 8 of first-order feature expressions. We underline, however, that feature expressions are "finitary syntactic entities" while sketch conditions have rather the flavor of sets of structural requirements!

**Definition 27** (Sketch conditions: Syntax)**.** *For a category* Ct *and a functor* St: Ct → Set*, we define inductively and in parallel a family* ST(*K*) *of sets of first-order* St*- sketch conditions in context K, c* ∈ ST(*K*) *or K c in symbols, where K varies over all objects in* Ct*:*


**Remark 35** (Sketch conditions: Syntax)**.** *Non-monic morphisms ϕ* : *K* → *M are also used in [22–24] to express identifications.*

*For sketch conditions, we apply the same notational conventions as described in Remark 6 for feature expressions.*

*If* **0** *is an initial object in* Ct*, we call* **0** *c a closed* St*- sketch condition.*

**Remark 36** (GraTra: Conditions)**.** *If we drop in Definition 27 the "Implication" rule, we would obtain tree-like conditions analogously to the conditions in [23–25], where the tree structure is established by the context morphisms in the "Quantification" rule and the choice of the sets C in the "Conjunction" and/or "Disjunction" rule, respectively.*

*To cover also the tree-like conditions in [22], we have, in addition, to replace the "Quantification" rule by a rule like:*

*Guarded quantification: K* (*c*<sup>1</sup> → *Q*(*ϕ*, *M* : *c*2)) *for Q* ∈ {∃, ∀}*, any* quantifier free *condition K c*1*, any condition M c*<sup>2</sup> *and any morphism ϕ* : *K* → *M in* Ct*.*

*Those tree-like conditions can be seen as a generalizing modification of the* Q(uantifier)-trees *of the* language of diagrams *in [28].*

*In [23,25], only existential quantification* ∃(*ϕ*, *M* : *c*) *is used and* ∀(*ϕ*, *M* : *c*) *is encoded by* ¬∃(*ϕ*, *M* : ¬*c*)*. In [24], the symbols "*∃*" and "*∀*" are used in a bit unconventional, but consistent, way: In view of Definition 27, the symbol "*∃*" in [24] combines "disjunction and existential quantification" while "*∀*" combines conjunction and universal quantification. The conditions in [24] correspond to sketch conditions that can be generated by a single rule like:*

{∃(*ϕi*, *Mi* : *ci*) <sup>|</sup> *<sup>i</sup>* <sup>∈</sup> *<sup>I</sup>*}, {∀(*ϕi*, *Mi* : *ci*) <sup>|</sup> *<sup>i</sup>* <sup>∈</sup> *<sup>I</sup>*} ∈ ST(*K*)

*for any family* {*ϕ<sup>i</sup>* : *K* → *Mi* | *i* ∈ *I*} *of context morphisms and any conditions ci* ∈ ST(*Mi*)*, <sup>i</sup>* ∈ *I. <sup>T</sup> is encoded in [24] by the empty conjunction* <sup>∅</sup> *and <sup>F</sup> by the empty disjunction* ∅*, respectively.*

Generalizing the traditional approaches [14,22–25] to define a satisfaction relation between graph morphisms and graph conditions, we can define a satisfaction relation between context morphisms and sketch conditions.

More precisely, we consider interpretations (*τ* : *K* → *G*, G) of contexts *K* in St-sketches G = (*G*, *St*G) and define valid interpretations of St-sketch conditions in *K*.

**Definition 28** (Sketch conditions: Satisfaction)**.** *We define inductively and in parallel a family* |=*<sup>K</sup> of satisfaction relations between interpretations* (*τ*, G) *of contexts K in* St*-sketches* <sup>G</sup> = (*G*, *St*G) *and* St*-sketch conditions c* <sup>∈</sup> ST(*K*) *on K:*


*Universal quantification:* (*τ*, G) |=*<sup>K</sup>* ∀(*ϕ*, *M* : *c*) *iff for all* : *Y* → *G with ϕ*; = *τ we have* (, G) |=*<sup>M</sup> c*

The satisfaction of graph/sketch conditions by a graph/context morphism is a powerful and practical useful tool to control the application of transformation rules. This is extensively demonstrated and validated in the Graph Transformation literature as in [14,22–25], for example. In DPF, we used until now only non-nested negative application conditions to control the application of non-deleting model transformation rules [18,21]. The paper paves the way for utilizing arbitrary first-order conditions to control model transformations in DPF. In this paper, we will, however, not explore this promising direction of applying first-order sketch conditions. We rather concentrate on two other aspects of diagrammatic modeling techniques–namely "syntactic structure" of models and "deducing information from and reason about models" in a diagrammatic manner.

Developing and applying DPF, we realized that typing mechanisms are not powerful enough to formalize all relevant restrictions concerning the syntactic structure of models. To overcome this deficiency, we introduced "universal constraints" and "negative universal constraints" [18,21] analogous to the non-nested graph constraints in [14].

Fortunately, sketch conditions and their satisfaction, as defined in Definition 28, now give us also more powerful general first-order sketch constraints at hand to describe the syntactic structure of models. The simple, but crucial, observation is that an assertion (*τ*, G) |=*<sup>K</sup> c* can be interpreted as well as an assertion concerning the structure of G.

**Definition 29** (Sketch constraints)**.** *An* St*- sketch K- constraint* (*c*, *τ*) *on context G is given by a context K, a sketch condition K c in context K and a context morphism τ* : *K* → *G.*

*An* St*-sketch* <sup>G</sup> = (*G*, *St*G) *satisfies the K-constraint* (*c*, *<sup>τ</sup>*)*,* <sup>G</sup> <sup>|</sup>=*<sup>K</sup>* (*c*, *<sup>τ</sup>*) *in symbols, if, and only if,* (*τ*, G) |=*<sup>K</sup> c.*

**Remark 37** (Attached Statements)**.** *Only at this point and a few days before the paper deadline, we realized that it may be beneficial to apply the "reinterpretation principle" in Definition 29 also to structures. That is, for any* Ξ*-structure* U = (*U*, Φ<sup>U</sup> )*, context K, morphism ι* : *K* → *U and statement* (*X*, *Ex*, *γ*) *in K we can define:*

$$\mathcal{U} \left| =\_{\mathcal{K}} \left( (X, \operatorname{Ex}, \gamma), \iota \right) \quad \text{iff} \quad (\iota, \mathcal{U}) \left| =\_{\mathcal{K}} (X, \operatorname{Ex}, \gamma) \right. \tag{23}$$

*and may call the pair* ((*X*, *Ex*, *γ*), *ι*) *a statement attached to* U *or a statement about* U*. To realize this idea, would, however, require a major revision of the paper.*

If the sketch condition *c* does not contain any statements, as it usually the case in the area of Graph Transformations (compare Example 50), G |=*<sup>K</sup>* (*c*, *τ*) is just an assertion about the structure of the context *G*. In all other cases, G |=*<sup>K</sup>* (*c*, *τ*) tells us also something about the presence or non-presence of statements as well as the relations between the statements in G.

Due to rule "Statement", all statements reappear as conditions. The following simple corollary illustrates that the requirement for strict sketch arrows to preserve statements "on the nose" encodes a structural constraint on the target.

**Corollary 6** (Strict Sketch Arrow vs. Sketch Constraint)**.** *A context morphism ϕ* : *K* → *G constitutes a strict* St*-sketch arrow <sup>ϕ</sup>* : <sup>K</sup> <sup>→</sup> <sup>G</sup> *between two* St*-sketches* <sup>K</sup> = (*K*, *St*K) *and* <sup>G</sup> = (*G*, *St*G) *if, and only if,* <sup>G</sup> <sup>|</sup>=*<sup>K</sup>* ( *St*K, *ϕ*)*.*

**Remark 38** (General constraints)**.** *A K-constraint* (*c*, *τ*) *is, in general, only a local constraint, in the sense that it constrains the structure of* G *"around the image" of K w.r.t. τ. Thus, in case K* = *G and τ* = *idG,* (*c*, *idG*) *is an assertion about the structure of* G *as such.*

*If* Ct *has an initial object* **0***, any closed condition* **0** *c gives rise to a sketch constraint* (*c*, !*G*) *with* !*<sup>G</sup>* : **0** → *G the initial morphism into G.* (*c*, !*G*) *is a general constraint, in the sense that the statement* G |=**<sup>0</sup>** (*c*, !*G*) *can be seen as a characterization of the overall structure of* G*. In the Graph Transformation literature, only general constraints have been considered [23,25].*
