*4.1. Signatures, Algebras and Contexts*

Signatures Σ = (Ω, *in*, *out*) correspond to traditional many-sorted algebraic signatures and are given by a set Ω of operation symbols, a map *in* assigning to each operation symbol *ω* ∈ Ω an object *in*(*ω*) in Var*EQ*, its **arity**, and a map *out* : Ω → *S*. For convenience, we assume that *in*(*ω*) = {*x*1, *<sup>x</sup>*2, ... , *xn*}, *<sup>n</sup>* ≥ 0; thus, we can represent *in*(*ω*) as a list [*x*1:*s*1, *x*2:*s*2,..., *xn*:*sn*] of variable declarations (compare Example 11).

We have Carr*EQ* := Base*EQ*. As structures, we consider Σ**- algebras** A = (*A*, ΩA) with an *<sup>S</sup>*-set *<sup>A</sup>* = (*As* <sup>|</sup> *<sup>s</sup>* <sup>∈</sup> *<sup>S</sup>*) and a family <sup>Ω</sup><sup>A</sup> of operations *<sup>ω</sup>*<sup>A</sup> : *<sup>A</sup>in*(*ω*) <sup>→</sup> *Aout*(*ω*), *<sup>ω</sup>* <sup>∈</sup> <sup>Ω</sup>, where *Ain*(*ω*) is a shorthand for the set Set*S*(*in*(*ω*), *A*) of all *S*-maps from *in*(*ω*) into *A*.

A **homomorphism** *ς* : A→B between Σ-algebras A and B is given by an S-map *<sup>ς</sup>* = (*ς<sup>s</sup>* <sup>|</sup> *<sup>s</sup>* <sup>∈</sup> *<sup>S</sup>*) : *<sup>A</sup>* <sup>→</sup> *<sup>B</sup>* such that *<sup>ω</sup>*A; *<sup>ς</sup><sup>s</sup>* <sup>=</sup> *<sup>ς</sup>in*(*ω*); *<sup>ω</sup>*<sup>B</sup> for all *<sup>ω</sup>* <sup>∈</sup> <sup>Ω</sup> where the map *<sup>ς</sup>in*(*ω*) : *<sup>A</sup>in*(*ω*) <sup>→</sup> *<sup>B</sup>in*(*ω*) is defined by *<sup>ς</sup>in*(*ω*)(*τ*) :<sup>=</sup> *<sup>τ</sup>*; *<sup>ς</sup>* for all *<sup>S</sup>*-maps *<sup>τ</sup>* <sup>∈</sup> *<sup>A</sup>in*(*ω*).

Alg(Σ) is the category of all Σ-algebras and all homomorphisms between them.

We choose Cxt*EQ* := Carr*EQ* = Base*EQ* = Set*S*. The model functor of an Institution of Equations is defined in full analogy to Institutions of Statements.

An interpretation (*ι*, A) of a context *K* in Cxt*EQ*, i.e., of an *S*-set *K*, is given by a Σ-algebra A = (*A*, ΩA) and an *S*-map *ι* : *K* → *A*.

A morphism *ς* : (*ι*, A) → (, B) between two interpretations of *K* is given by a homomorphism *ς* : A→B such that *ι*; *ς* = for the underlying *S*-map *ς* : *A* → *B*.

For any context *K* in Cxt*EQ*, Int(*K*) denotes the category of all interpretations of *K* and all morphisms between them and Π*<sup>K</sup>* : Int(*K*) → Alg(Σ) is the corresponding projection functor. The fiber over a Σ-algebra A represents the semantics of a context *K* in A, i.e., the set *<sup>A</sup><sup>K</sup>* :<sup>=</sup> Set*S*(*K*, *<sup>A</sup>*) of all *<sup>S</sup>*-maps from *<sup>K</sup>* into the carrier of <sup>A</sup>.

Note that, in the case of the empty *S*-set *K* = **0** = (∅ | *s* ∈ *S*) the projection functor Π**<sup>0</sup>** : Int(**0**) → Alg(Σ) is an isomorphism.

Any *S*-map *ϕ*: *K* → *G* induces a functor Int(*ϕ*): Int(*G*) → Int(*K*) with:

$$\mathsf{Int}(\mathfrak{q}); \Pi\_{\mathsf{K}} = \Pi\_{\mathsf{G}} : \mathsf{Int}(\mathsf{G}) \to \mathsf{Alg}(\Sigma) \tag{6}$$

defined by simple pre-composition: Int(*ϕ*)(, B) := (*ϕ*; , B) for all interpretations (, B) of *G*, and for any morphism *ς* : (*ι*, A) → (, B) between two interpretations of *G* the same underlying *S*-map *ς* : *A* → *B* establishes a morphism Int(*ϕ*)(*ς*) := *ς* : (*ϕ*; *ι*, A) → (*ϕ*; , B) between the corresponding two interpretations of *K*.

The assignments *<sup>K</sup>* → Int(*K*) and *<sup>ϕ</sup>* → Int(*ϕ*) define a functor Int : Cxt*op EQ* → Cat. This is the **model functor** of an Institution of Equations.

#### *4.2. Terms and Equations*

To define equations, we need terms! For any *S*-set *K* the *S*-set *T*Σ(*K*) of all Σ**-terms on** *K* is defined inductively as the smallest *S*-set such that:


A Σ**-equation** (*K*, *t*<sup>1</sup> = *t*2) **in** *K* is given by two Σ-terms *t*1, *t*<sup>2</sup> ∈ *T*Σ(*K*)*<sup>s</sup>* for some *s* ∈ *S* and Eq(*K*) denotes the set of all Σ-equations (*K*, *t*<sup>1</sup> = *t*2) in *K*. In the usual way, the inductive definition of Σ-terms allows us to extend any *S*-map *ϕ*: *K* → *G* between *S*-sets to an *S*-map *ϕ*<sup>∗</sup> : *T*Σ(*K*) → *T*Σ(*G*) such that ⊆; *ϕ*<sup>∗</sup> = *ϕ*; ⊆ thus *ϕ* : *K* → *G* induces a map Eq(*ϕ*) : Eq(*K*) → Eq(*G*) with:

$$\mathbb{E}\mathfrak{q}(\mathfrak{q})(\mathsf{K},t\_{1}=t\_{2}):= (\mathsf{G},\mathsf{q}^{\*}(t\_{1})=\mathsf{q}^{\*}(t\_{2}))\tag{7}$$

for all Σ-equations (*K*, *t*<sup>1</sup> = *t*2) in *K*.

Since *id*∗ *<sup>K</sup>* = *idT*Σ(*K*) and (*ϕ*; *ψ*)<sup>∗</sup> = *ϕ*∗; *ψ*<sup>∗</sup> for all *ϕ* : *K* → *G*, *ψ* : *G* → *H*, the assignments *K* → Eq(*K*) and *ϕ* → Eq(*ϕ*) define a functor Eq : Cxt*EQ* → Set. This is the **sentence functor** of an Institution of Equations.

The semantics of terms is based on the **evaluation of terms** in algebras: Due to the inductive definition of Σ-terms, we can extend any interpretation *ι* : *K* → *A* of a context *K* in a Σ-algebra A = (*A*, ΩA) to an S-map *ι* ◦ : *T*Σ(*K*) → *A* such that:

In such a way, we can define the semantics *t* <sup>A</sup> of a Σ-term *t* ∈ *T*Σ(*K*), *s* ∈ *S* in a Σ-algebra A as a map *t* <sup>A</sup> : *<sup>A</sup><sup>K</sup>* <sup>→</sup> *As* defined by *<sup>t</sup>* A(*ι*) := *ι* ◦(*t*) for all *ι* : *K* → *A*. Thus, feature expressions represent derived properties while terms represent *derived operations*!
