# Graph Algebras and Derived Graph Operations

^{*}

## Abstract

**:**

## 1. Introduction

**Model theory:**- In [7], we coined the concept of graph algebra, introduced graph terms, and showed that graph term algebras are free graph algebras. There was, however, no model theory in the sense of traditional Universal Algebra. As a kind of “proof of concept”, we therefore generalize some basic model-theoretic concepts and results from traditional algebras to graph algebras. We concentrate on the concept of “generated subalgebra” and the related problem of characterizing monomorphic and epimorphic homomorphisms.To tackle this task, we make a substantial effort in Section 3 to revise and reformulate traditional set-theoretic definitions, constructions and proofs in Universal Algebra by means of more category-theoretic concepts and constructions. Relying on this reformulation, we can in Section 4 smoothly transfer concepts, definitions and results from traditional algebras to graph algebras. In particular, we prove that all monomorphic homomorphisms between graph algebras are regular.In [7], we adapted the original idea of sketch operations [4] and defined the arity of a graph operation as a single graph inclusion. This definition does not allow us, however, to consider projections as legal graph operations. To be closer to the traditional concept of operation in Universal Algebra, and to be able to define an appropriate concept of a derived graph operation, we therefore declare in this paper the arity of a graph operation as a span of graph inclusions. In Section 4.2, we clarify the relation between both versions and discuss to what extent they are equivalent.To prove that all monomorphic homomorphisms between graph algebras are regular, we also introduce partial graph algebras in Section 4.4. We define a so-called term completion procedure transforming partial graph algebras into total graph algebras. This procedure provides for each signature a free functor from the corresponding category of partial graph algebras to the corresponding category of graph algebras. The construction of graph term algebras turns out to be just a special case of this new procedure.
**Derived graph****operations:**To understand why the strong interconnection between “representation of data” and “representation of derived operations” breaks down in the case of graph operations and to find out how to define derived graph operations in an appropriate way, we include in the paper a more in-depth analysis of the concept term and discuss substitution calculi in general in Section 3.4.In Section 3.7, we recall the construction of syntactic Lawvere theories as it is described in [8], for example. In Section 5.1, we discuss finite product categories and elucidate that terms can be characterized as normal forms for finite product expressions; thus, Lawvere’s original slogan “composition is substitution” can be turned into the slogan “substitution is symbolic composition plus normalization”.Reviewing the relationship between finite products and tensor products, we identify copying in Section 5.2 as the cause of the problem. We argue that, in the case of graph operations, “copying of data”, as a computation of its own, has to be replaced by the “soldering” of input and (!) output ports of computations.In such a way, we end up in Section 5.3 with three mechanisms to construct new graph operations out of given ones: parallel composition, instantiation (“soldering” of input and output ports), and sequential composition.Finally, we introduce in Section 5.4 graph operation expressions with a structure as close as possible to the structure of terms. We define their semantics, i.e., the derived graph operations we have been looking for, by means of the three mechanisms of parallel composition, instantiation and sequential composition.

## 2. Notations and Preliminaries

- $dom(f;g):=\{x\in A\mid x\in dom(f),f(x)\in dom(g\left)\right\}$ and
- $f;g\left(a\right):=g\left(f\right(a\left)\right)\phantom{\rule{0.277778em}{0ex}}$ for all $\phantom{\rule{0.166667em}{0ex}}a\in dom(f;g)$.

- We consider any (total) map $f:A\to B$ as a partial map $f:A\phantom{\rule{6.99997pt}{0ex}}\circ \phantom{\rule{-13.00003pt}{0ex}}\u27f6\phantom{\rule{1.00006pt}{0ex}}B$ with $dom\left(f\right)=A$.

## 3. Algebras and Term Algebras

#### 3.1. Signatures, Algebras and Homomorphisms

**Definition 3.1**

**.**A signature $\mathsf{\Sigma}=(OP,ar)$ is given by

- A set$OP$of operation symbols,
- A map $ar$ assigning to each operation symbol $\mathtt{op}$ as its arity a pair $ar\left(\mathtt{op}\right)=({I}_{\mathtt{op}},{O}_{\mathtt{op}})$ of finite sets with ${I}_{\mathtt{op}}={I}_{n}$ for some $n\in \mathbb{N}$, and ${O}_{\mathtt{op}}=O=\left\{o\right\}$.

**Remark 3.1**

**.**There can be arbitrarily and finitely many disconnected inputs for an algebraic operation. We have decided to work with explicit sets of names for the “input positions”. In contrast to possibly multiple inputs, it is usually assumed that an algebraic operation has exactly one single output. For conformity reasons, we also introduce a name for the single output position. This brings us closer to graph algebras, where the single-output paradigm will be given up. The input as well as the output arity of a graph operation can be an arbitrary finite graph (see Definition 4.1).

**Definition 3.2**

**.**Let Σ be a signature. A Σ-algebra $\mathcal{A}=(A,O{P}^{\mathcal{A}})$ is given by

- A set A, called the carrier of $\mathcal{A}$, and
- A family$O{P}^{\mathcal{A}}=({\mathtt{op}}^{\mathcal{A}}:\phantom{\rule{0.166667em}{0ex}}{A}^{{I}_{\mathtt{op}}}\to {A}^{{O}_{\mathtt{op}}}\mid \mathtt{op}\in OP)$of maps called operations.

**Definition 3.3**

**.**Let Σ be a signature. A $\mathsf{\Sigma}$-homomorphism $h:\mathcal{A}\to \mathcal{B}$ between two Σ-algebras $\mathcal{A}$ and $\mathcal{B}$ is a map $h:A\to B$ satisfying the following homomorphism condition

**(HC)**with the requirement that the above right square of maps commutes. Note that, in the case of constant symbols $\mathtt{c}\in OP$ with ${I}_{\mathtt{c}}={I}_{0}$, the homomorphism condition turns into the equation ${\mathtt{op}}^{\mathcal{A}}\left(\right);h={\mathtt{op}}^{\mathcal{B}}\left(\right)$ if we apply our conventions in Section 2 concerning the tuple notation.

**Proposition 3.1**

**.**The assignments $\mathcal{A}\mapsto A$ for Σ-algebras and $(f:\mathcal{A}\to \mathcal{B})\mapsto (f:A\to B)$ for Σ-homomorphisms define a faithful forgetful functor

**Theorem 3.1**

**.**$\mathsf{Alg}\left(\mathsf{\Sigma}\right)$ inherits any small limit from the category $\mathsf{Set}$, i.e., the functor ${\mathbf{U}}_{\mathsf{\Sigma}}:\mathsf{Alg}\left(\mathsf{\Sigma}\right)\to \mathsf{Set}$ creates small limits. $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$ has therefore all small limits since $\mathsf{Set}$ does.

**Proof.**

**Remark 3.2**

**.**The proof of Theorem 3.1 is based on the convention in Section 2 that we consider ${A}^{I}$ as a shorthand notation for the collection (hom-set) $\mathsf{Set}(I,A)$ of all morphisms in $\mathsf{Set}$ from I to A. $\mathsf{Set}(I,A)$ is a set since $\mathsf{Set}$ is locally small. $\mathsf{Set}(I,A)$ is isomorphic to a corresponding exponential object in $\mathsf{Set}$, but this isomorphism does not play any role in this paper.

#### 3.2. Subalgebras

**Definition 3.4**

**.**Let $\mathsf{\Sigma}=(OP,ar)$ be a signature. A Σ-algebra $\mathcal{A}=(A,O{P}^{\mathcal{A}})$ is a $\mathsf{\Sigma}$-subalgebra of a Σ-algebra $\mathcal{B}=(B,O{P}^{\mathcal{B}})$, $\mathcal{A}\u2291\mathcal{B}$ in symbols, if $A\subseteq B$ and for all $\mathtt{op}\in OP$ and $\mathit{a}:{I}_{\mathtt{op}}\to A$ the following diagram commutes:

**Corollary 3.1**

**.**For Σ-algebras $\mathcal{A}$ and $\mathcal{B}$ such that $A\subseteq B$, we have that $\mathcal{A}$ is a Σ-subalgebra of $\mathcal{B}$ if, and only if, the inclusion map ${\iota}_{A,B}:A\hookrightarrow B$ establishes a Σ-homomorphism ${\iota}_{A,B}:\mathcal{A}\hookrightarrow \mathcal{B}$.

**Corollary 3.2**

**.**If the underlying map $f:\phantom{\rule{0.166667em}{0ex}}A\to B$ of a Σ-homomorphism $f:\mathcal{A}\to \mathcal{B}$ is injective (surjective), then $f:\mathcal{A}\to \mathcal{B}$ is a monomorphism (epimorphism) in $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$.

**Definition 3.5**

**.**Let $\mathcal{B}=(B,O{P}^{\mathcal{B}})$ be a Σ-algebra. We say a subset $A\subseteq B$ is closed in $\mathcal{B}$ if for all $\mathtt{op}\in OP$ and $\mathit{a}:{I}_{\mathtt{op}}\to A$ the result ${\mathtt{op}}^{\mathcal{B}}(\mathit{a};{\iota}_{A,B}):{O}_{\mathtt{op}}\to B$ of applying the operation ${\mathtt{op}}^{\mathcal{B}}$ in $\mathcal{B}$ to the input $\mathit{a};{\iota}_{A,B}:{I}_{\mathtt{op}}\to B$ factors through the inclusion map ${\iota}_{A,B}:A\hookrightarrow B$, i.e., there exists a map ${r}_{\mathit{a}}:{O}_{\mathtt{op}}\to B$ such that the following diagram commutes:

**Proposition 3.2**

**.**There is a one-to-one correspondence between Σ-subalgebras of $\mathcal{B}$ and closed subsets of $\mathcal{B}$.

**Remark 3.3**

**.**Let I be a set and M be an I-indexed family $({A}_{i}\subseteq B\mid i\in I)$ of subsets of a set B. We can describe this situation witha diagram $\delta :\phantom{\rule{0.166667em}{0ex}}\mathtt{MP}\left(I\right)\to \mathsf{Set}$ with $\mathtt{MP}\left(I\right)$ as a small graph given by $\mathtt{MP}{\left(\mathtt{I}\right)}_{V}:=I\cup \{\ast \}$, $\mathtt{MP}{\left(\mathtt{I}\right)}_{E}:=\{{e}_{i}:i\to \ast \mid i\in I\}$, and δ defined by ${\delta}_{i}:={A}_{i}$ for all $i\in I$, ${\delta}_{\ast}:=B$ and inclusion maps ${\delta}_{{e}_{i}}:={\iota}_{{A}_{i},B}:{A}_{i}\hookrightarrow B$ for all $i\in I$.

“If M is a family of closed subsets in $\mathcal{B}$, then its intersection $\cap M$ is closed as well”

**Corollary 3.3**

**.**For any set I, any Σ-algebra $\mathcal{B}$, and any diagram $\delta :\phantom{\rule{0.166667em}{0ex}}\mathtt{MP}\left(I\right)\to \mathsf{Alg}\left(\mathsf{\Sigma}\right)$ of Σ-subalgebras ${\delta}_{{e}_{i}}={\iota}_{{A}_{i},B}:{\mathcal{A}}_{i}\hookrightarrow \mathcal{B}$, $i\in I$ of $\mathcal{B}$ there is a unique Σ-subalgebra $\mathcal{L}=(L,O{P}^{\mathcal{L}})$ of $\mathcal{B}$ with $L={\bigcap}_{i\in I}{A}_{i}$ that is a Σ-subalgebra of ${\mathcal{A}}_{i}$ for all $i\in I$.

**Definition 3.6**

**.**For any Σ-algebra $\mathcal{B}$ and any map $f:\phantom{\rule{0.166667em}{0ex}}A\to B$, let $\mathcal{M}$ be the set of all Σ-subalgebras $\mathcal{X}$ of $\mathcal{B}$ such that f factors through the inclusion map ${\iota}_{X,B}:X\hookrightarrow B$, i.e., there exists a map ${f}_{\mathcal{X}}:\phantom{\rule{0.166667em}{0ex}}A\to X$ such that ${f}_{\mathcal{X}}\phantom{\rule{0.166667em}{0ex}};{\iota}_{X,B}=f$.

**Corollary 3.4**

**.**For any Σ-algebra $\mathcal{B}$ and any map $f:\phantom{\rule{0.166667em}{0ex}}A\to B$, we have $f\left(A\right)\subseteq R(f,\mathcal{B})$ for the (set-theoretic) image $f\left(A\right):=\left\{f\right(a)\mid a\in A\}$ of A with respect to the map f.

**Proof.**

**Remark 3.4**

**.**In category theory, the adjective well-powered is used for categories $\mathsf{C}$ where for all objects A in $\mathsf{C}$ the collection of all subobjects of A is a set.

**Definition 3.7**

**.**Let $\mathcal{B}$ be a Σ-algebra.

- 1.
- $\mathcal{B}$ is accessible via a map $f:A\to B$ if $\mathcal{R}(f,\mathcal{B})=\mathcal{B}$.
- 2.
- If $\mathcal{B}$ is accessible via an inclusion map ${\iota}_{A,B}:A\to B$, i.e., if $\mathcal{R}(A,\mathcal{B})=\mathcal{R}({\iota}_{A,B},\mathcal{B})=\mathcal{B}$, we also say that $\mathcal{B}$ is generated by A.
- 3.
- $\mathcal{B}$ is said to be generated if it is generated by the empty set, i.e., accessible via the unique map ${\iota}_{\varnothing ,B}:\varnothing \hookrightarrow B$ from the initial object ∅ in $\mathsf{Set}$ to B.

**Corollary 3.5.**

**Corollary 3.6.**

**Lemma 3.1**

**.**A Σ-homomorphism $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$ is an epimorphism in $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$ if $\mathcal{B}$ is accessible via the underlying map $f:\phantom{\rule{0.166667em}{0ex}}A\to B$, i.e., if $\mathcal{B}=\mathcal{R}(f,\mathcal{B})$.

**Proof.**

**Proposition 3.3**

**.**For any Σ-subalgebra ${\iota}_{\mathcal{A},\mathcal{B}}:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\hookrightarrow \mathcal{B}$ of a Σ-algebra $\mathcal{B}$ there exists a Σ-algebra $\mathcal{C}$ and parallel Σ-homomorphisms $g,h:\phantom{\rule{0.166667em}{0ex}}\mathcal{B}\to \mathcal{C}$ such that ${\iota}_{\mathcal{A},\mathcal{B}}:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\hookrightarrow \mathcal{B}$ is the equalizer of g and h.

**Proof.**

**Operations on**C

**:**We now extend C to a Σ-algebra $\mathcal{C}=(C,O{P}^{\mathcal{C}})$ by defining for each $\mathtt{op}$ in $OP$ a corresponding operation ${\mathtt{op}}^{\mathcal{C}}:\phantom{\rule{0.166667em}{0ex}}{\left(B{+}_{A}B\right)}^{{I}_{\mathtt{op}}}\to {\left(B{+}_{A}B\right)}^{{O}_{\mathtt{op}}}$. For any $\mathit{c}:{I}_{\mathtt{op}}\to B{+}_{A}B$ in ${\left(B{+}_{A}B\right)}^{{I}_{\mathtt{op}}}$, we do have four possible cases.

**Case 1**- $\mathit{c}$ factors through ${\kappa}_{1}$: There exists a map ${\mathit{b}}_{1}:{I}_{\mathtt{op}}\to B$ such that ${\mathit{b}}_{1};{\kappa}_{1}=\mathit{c}$ (see the right diagram above). ${\mathit{b}}_{1}$ is unique since ${\kappa}_{1}$ is a monomorphism. We simply set$${\mathtt{op}}^{\mathcal{C}}\left(\mathit{c}\right)={\mathtt{op}}^{\mathcal{C}}({\mathit{b}}_{1};{\kappa}_{1}):={\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{1}\right);{\kappa}_{1}$$
**Case 2**- $\mathit{c}$ factors through ${\kappa}_{2}$: Analogous to Case 1.
**Case 3**- Overlapping of Case 1 and 2: There exist maps ${\mathit{b}}_{1},{\mathit{b}}_{2}:{I}_{\mathtt{op}}\to B$ such that ${\mathit{b}}_{1};{\kappa}_{1}=\mathit{c}={\mathit{b}}_{2};{\kappa}_{1}$. Due to the pullback property of the square, there exists a unique $\mathit{a}:{I}_{\mathtt{op}}\to A$ such that ${\mathit{b}}_{1}=\mathit{a};{\iota}_{A,B}={\mathit{b}}_{2}$. The homomorphism property of ${\iota}_{\mathcal{A},\mathcal{B}}$ ensures ${\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{1}\right)={\mathtt{op}}^{\mathcal{B}}(\mathit{a};{\iota}_{A,B})={\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{2}\right)={\mathtt{op}}^{\mathcal{A}}\left(\mathit{a}\right);{\iota}_{A,B}$ and we obtain, finally, ${\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{1}\right);{\kappa}_{1}={\mathtt{op}}^{\mathcal{A}}\left(\mathit{a}\right);{\iota}_{A,B};{\kappa}_{1}={\mathtt{op}}^{\mathcal{A}}\left(\mathit{a}\right);{\iota}_{A,B};{\kappa}_{2}={\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{2}\right);{\kappa}_{2}$. That is, in the event of an overlapping, Case 1 and Case 2 define the same output ${\mathtt{op}}^{\mathcal{C}}\left(\mathit{c}\right)={\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{1}\right);{\kappa}_{1}={\mathtt{op}}^{\mathcal{B}}\left({\mathit{b}}_{2}\right);{\kappa}_{2}$. Note that there will always be an overlapping for constant symbols!
**Case 4**- $\mathit{c}$ factors neither through ${\kappa}_{1}$ nor through ${\kappa}_{2}$: This can only happen if ${I}_{\mathtt{op}}={I}_{n}$ with $n\ge 2$. Utilizing the operations in $\mathcal{B}$ to a maximal extent, Cases 1 and 2 define a partial map from ${\left(B{+}_{A}B\right)}^{{I}_{\mathtt{op}}}$ to ${\left(B{+}_{A}B\right)}^{{O}_{\mathtt{op}}}$. However, since we restrict ourselves to total operations, we have to find an ad hoc totalization trick to turn ${\mathtt{op}}^{\mathcal{C}}$ into a total operation. Employing (7), we may decide to utilize the operations in $\mathcal{B}$ to produce outputs in the left copy of B in $B{+}_{A}B$. We set$${\mathtt{op}}^{\mathcal{C}}\left(\mathit{c}\right):={\mathtt{op}}^{\mathcal{B}}(\mathit{c};k);{\kappa}_{1}$$

**Case 4**has no relevance for the homomorphism property of ${\kappa}_{1}$ and ${\kappa}_{2}$! Theorem 3.1 ensures, finally, that the inclusion Σ-homomorphism ${\iota}_{\mathcal{A},\mathcal{B}}:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$ is the equalizer of the Σ-homomorphisms ${\kappa}_{1},{\kappa}_{2}:\mathcal{B}\to \mathcal{C}$. □

**Proposition 3.4**

**.**For any Σ-homomorphism $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$, it holds that $\mathcal{B}$ is accessible via the underlying map $f:A\to B$; i.e., in other words, $\mathcal{B}$ is equal to the homomorphic image $\mathcal{R}(f,\mathcal{B})$ of $\mathcal{A}$ with respect to f, if, and only if, $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$ is an epimorphism in $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$.

**Proof.**

**Lemma 3.2**

**.**For any Σ-homomorphism $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$, the (set-theoretic) image $f\left(A\right)\subseteq B$ of the carrier A of $\mathcal{A}$ is closed in $\mathcal{B}$. We denote by $f\left(\mathcal{A}\right)$ the unique Σ-subalgebra of $\mathcal{B}$ with the carrier $f\left(A\right)$ and call it the (set-theoretic) image of $\mathcal{A}$ with respect to the $\mathsf{\Sigma}$-homomorphism f.

**Corollary 3.7**

**.**For any Σ-homomorphism $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$ we have $f\left(\mathcal{A}\right)=\mathcal{R}(f,\mathcal{B})$; thus, $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$ is an epimorphism in $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$ if, and only if, the map $f:\phantom{\rule{0.166667em}{0ex}}A\to B$ is surjective.

**Proof.**

**Remark 3.5**

**.**There is another, more constructive, way to construct the closed sets $R(A,\mathcal{B})$. We start with A and add all the elements from B that we can reach by successively applying the operations in $\mathcal{B}$ to elements that have already been reached. A categorical analysis, formalization, and generalization of this stepwise iterative construction can be found in [12], for example.

#### 3.3. Terms and Term Algebras

**Definition 3.8**

**.**The set ${T}_{\mathsf{\Sigma}}\left(X\right)$ of all $\mathsf{\Sigma}$-terms over a set X of variables is the smallest set of strings of symbols such that

**Variables:**- $\u2e22x\u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$, for all $x\in X$;
**Constants:**- $\u2e22\mathtt{c}\langle \rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$, for all $\mathtt{c}\in OP$ with ${I}_{\mathtt{c}}={I}_{0}$;
**Operations:**- $\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$, for all $\mathtt{op}\in OP$ with ${I}_{\mathtt{op}}={I}_{n}$, $n\ge 1$ and all maps $\mathit{t}=(\u2e22{t}_{1}\u2e23,\dots ,\u2e22{t}_{n}\u2e23)$ in ${T}_{\mathsf{\Sigma}}{\left(X\right)}^{{I}_{n}}$.

**Definition 3.9**

**.**For any set X of variables, any Σ-algebra $\mathcal{A}=(A,O{P}^{\mathcal{A}})$ and any map $\alpha :\phantom{\rule{0.166667em}{0ex}}X\to A$ (called a variable assignment), we can inductively define a map ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(X\right)\to A$:

**Variables:**- ${\alpha}^{\ast}\left(x\right):=\alpha \left(x\right)$, for all $\u2e22x\u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$;
**Constants:**- ${\alpha}^{\ast}\left(\mathtt{c}\langle \rangle \right):={\mathtt{c}}^{\mathcal{A}}\left(\right)\left(o\right)$, for all $\u2e22\mathtt{c}\langle \rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$;
**Operations:**- ${\alpha}^{\ast}\left(\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \right):={\mathtt{op}}^{\mathcal{A}}({\alpha}^{\ast}\left({t}_{1}\right),\dots ,{\alpha}^{\ast}\left({t}_{n}\right))\left(o\right)$, for all $\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$.

**Definition 3.10**

**.**For a set X of variables, we define the term $\mathsf{\Sigma}$-algebra over X ${\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)=({T}_{\mathsf{\Sigma}}\left(X\right),O{P}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)})$ by

**Constants:**- ${\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)}\left(\right)\left(o\right):=\u2e22\mathtt{c}\langle \rangle \u2e23$, for all $\mathtt{c}\in OP$ with ${I}_{\mathtt{c}}={I}_{0}$, and
**Operations:**- ${\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)}\left(\mathit{t}\right)\left(o\right):=\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23$, for all $\mathtt{op}\in OP$ with ${I}_{\mathtt{op}}={I}_{n}$, $n\ge 1$ and all maps $\mathit{t}=(\u2e22{t}_{1}\u2e23,\dots ,\u2e22{t}_{n}\u2e23)$ in ${T}_{\mathsf{\Sigma}}{\left(X\right)}^{{I}_{n}}$.

**Constants**and

**Operations**in Definition 3.9 via the requirement that the map ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(X\right)\to A$ should establish a $\mathsf{\Sigma}$-homomorphism ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)\to \mathcal{A}$:

**Constants:**- ${\alpha}^{\ast}\left(\mathtt{c}\langle \rangle \right)={\alpha}^{\ast}\left({\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)}\left(\right)\left(o\right)\right)=({\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)}\left(\right);{\alpha}^{\ast})\left(o\right)={\mathtt{c}}^{\mathcal{A}}\left(\right)\left(o\right)$, for all $\u2e22\mathtt{c}\langle \rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$;
**Operations:**- ${\alpha}^{\ast}\left(\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \right)={\alpha}^{\ast}\left({\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)}\left(\mathit{t}\right)\left(o\right)\right)=({\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)}\left(\mathit{t}\right);{\alpha}^{\ast})\left(o\right)={\mathtt{op}}^{\mathcal{A}}(\mathit{t};{\alpha}^{\ast})\left(o\right)$$={\mathtt{op}}^{\mathcal{A}}({\alpha}^{\ast}\left({t}_{1}\right),\dots ,{\alpha}^{\ast}\left({t}_{n}\right))\left(o\right)$, for all $\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$ where $\mathit{t}$ is the map in ${T}_{\mathsf{\Sigma}}{\left(X\right)}^{{I}_{n}}$ defined by $\mathit{t}=(\u2e22{t}_{1}\u2e23,\dots ,\u2e22{t}_{n}\u2e23)$.

**Variables**in Definition 3.9 simply requires that the map ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(X\right)\to A$ is an extension of the map $\alpha :\phantom{\rule{0.166667em}{0ex}}X\to A$ and thus the statement “Definition 3.9 defines ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(X\right)\to A$ uniquely” is transformed into the statement that the term $\mathsf{\Sigma}$-algebra ${\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)$ is a $\mathsf{\Sigma}$-algebra freely generated by X.

**Proposition 3.5**

**.**Given a set X of variables, the Σ-term algebra ${\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)$ has the following universal property: For any Σ-algebra $\mathcal{A}=(A,O{P}^{\mathcal{A}})$ and any map $\alpha :\phantom{\rule{0.166667em}{0ex}}X\to A$, there exists a unique Σ-homomorphism ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)\to \mathcal{A}$ such that ${\eta}_{X};{\alpha}^{\ast}=\alpha $.

**Corollary 3.8.**

#### 3.4. Substitutions

#### 3.4.1. Substitution Calculi

In Universal Algebra, we can formalize substitutions as maps $\sigma :\phantom{\rule{0.166667em}{0ex}}X\to {T}_{\mathsf{\Sigma}}\left(Y\right)$. For finite sets $X=\{{x}_{1},\dots ,{x}_{n}\}$ we may simply declare a substitution by listing the corresponding assignments $\{{x}_{1}\mapsto {t}_{1},\dots ,{x}_{n}\mapsto {t}_{n}\}$.(1) Substitution (declaration), i.e., an assignment of expressions to variables.

A common practice in Universal Algebra [14] is to denote the resulting term in ${T}_{\mathsf{\Sigma}}\left(Y\right)$ of applying a finite substitution $\{{x}_{1}\mapsto {t}_{1},\dots ,{x}_{n}\mapsto {t}_{n}\}$ to a term t in ${T}_{\mathsf{\Sigma}}\left(X\right)$ by(2) Substitution application, i.e., the replacement of occurrences of variables in a given expression by the expressions assigned to the variables by a substitution.

In the case of terms, “well-formedness” simply means that we consider only those strings of symbols as terms that can be generated inductively by the three rules in Definition 3.8.(3) Preservation of well formedness; i.e., replacing variables in a well-formed expression by well-formed expressions should result in a well-formed expression.

The composition of the two linkable finite substitutions $\{{x}_{1}\mapsto {t}_{1},\dots ,{x}_{n}\mapsto {t}_{n}\}$ from $X=\{{x}_{1},\dots ,{x}_{n}\}$ to ${T}_{\mathsf{\Sigma}}\left(Y\right)$ and $\{{y}_{1}\mapsto {r}_{1},\dots ,{y}_{m}\mapsto {r}_{m}\}$ from $Y=\{{y}_{1},\dots ,{y}_{m}\}$ to ${T}_{\mathsf{\Sigma}}\left(Z\right)$ results, for example, in the finite substitution(4) Composition of linkable substitutions.

For the two linkable finite substitutions above, this requirement can be expressed by the equation(5) The composition of substitutions is compatible with substitution application.

(6) The composition of substitutions is associative.

In Universal Algebra, we work exclusively with variables ranging over elements in sets, and thus variable assignments can be defined as maps $\alpha :\phantom{\rule{0.166667em}{0ex}}X\to A$ from a set of variables into the carrier set of a $\mathsf{\Sigma}$-algebra $\mathcal{A}$, as in Definition 3.9.(7) Variable assignments, i.e., assignments of semantic items to variables.

Definition 3.9 presents, for example, an inductive definition of the evaluation ${\alpha}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(X\right)\to A$ of $\mathsf{\Sigma}$-terms into elements in the carrier A of a $\mathsf{\Sigma}$-algebra $\mathcal{A}$ induced by a variable assignment $\alpha :\phantom{\rule{0.166667em}{0ex}}X\to A$.(8) evaluation of expressions, computing for each expression a unique semantic item or truth value.

For both new kinds of composition, it is desirable to have(9) The composition of substitutions with variable assignments as well as The composition of variable assignments with homomorphisms.

Finally, it would be reasonable to require(10) Compatibility with respect to substitution application and/or evaluation.

(11) Associativity for the three new possible combinations of the four kinds of composition, i.e., substitution–substitution–assignment, substitution–assignment–homomorphism, and assignment–homomorphism–homomorphism.

#### 3.4.2. Substitutions by Algebraic Extensions

- Feature (1):
- Substitutions$\sigma :\phantom{\rule{0.166667em}{0ex}}X\to {T}_{\mathsf{\Sigma}}\left(Y\right)$ simply become a special case of variable assignments and
- Feature (2):
- Substitution applications appear as a special case of term evaluations, namely as algebraic extensions ${\sigma}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{\mathcal{T}}_{\mathsf{\Sigma}}\left(X\right)\to {\mathcal{T}}_{\mathsf{\Sigma}}\left(Y\right)$. Applying a substitution $\sigma :\phantom{\rule{0.166667em}{0ex}}X\to {T}_{\mathsf{\Sigma}}\left(Y\right)$ to a $\mathsf{\Sigma}$-term $t\in {T}_{\mathsf{\Sigma}}\left(X\right)$ means nothing but to compute the $\mathsf{\Sigma}$-term ${\sigma}^{\ast}\left(t\right)\in {T}_{\mathsf{\Sigma}}\left(Y\right)$. As mentioned before, it is also common to use instead of ${\sigma}^{\ast}\left(t\right)$ the more informative notation in (10) in the case of finite sets of variables.
- Feature (3):
- Preservation of well formedness is implicitly ensured by the fact that the structures we define in Definition 3.10 (Term algebra) are indeed $\mathsf{\Sigma}$-algebras.

for example, is simply given by the compatibility of substitution application and evaluation, as well as associativity of map composition: $\sigma ;{(\delta ;{\beta}^{\ast})}^{\ast}=\sigma ;({\delta}^{\ast};{\beta}^{\ast})=(\sigma ;{\delta}^{\ast});{\beta}^{\ast}$ for arbitrary substitutions $\sigma :\phantom{\rule{0.166667em}{0ex}}X\to {T}_{\mathsf{\Sigma}}\left(Y\right)$, $\delta :\phantom{\rule{0.166667em}{0ex}}Y\to {T}_{\mathsf{\Sigma}}\left(Z\right)$ and assignments $\beta :\phantom{\rule{0.166667em}{0ex}}Z\to A$.substitution; (substitution; assignment) = (substitution; substitution); assignment,

**Remark 3.6**

**.**Of course, there is no need to utilize internalization of terms and uniqueness of algebraic extensions to establish a fully fledged substitution calculus for Universal Algebra! Instead, we could just separately work out each of the necessary definitions and proofs based on the inductive definition of terms analogous to Definition 3.9 (Evaluation of Terms). Internalization simply saves us a lot of work if it comes to substitutions!

**Definition 3.11**

**.**For any sets X, Y of variables and any substitution $\delta :\phantom{\rule{0.166667em}{0ex}}X\to {T}_{\mathsf{\Sigma}}\left(Y\right)$, we can inductively define a corresponding substitution application ${\delta}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(X\right)\to {T}_{\mathsf{\Sigma}}\left(Y\right)$ such that ${\eta}_{X};{\delta}^{\ast}=\delta $:

**Variables:**- ${\delta}^{\ast}\left(x\right):=\delta \left(x\right)$, for all $\u2e22x\u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$;
**Constants:**- ${\delta}^{\ast}\left(\mathtt{c}\langle \rangle \right):=\mathtt{c}\langle \rangle $, for all $\u2e22\mathtt{c}\langle \rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$;
**Operations:**- ${\delta}^{\ast}\left(\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \right):=\mathtt{op}\langle {\delta}^{\ast}\left({t}_{1}\right),\dots ,{\delta}^{\ast}\left({t}_{n}\right)\rangle $, for all $\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$.

**Remark 3.7**

**.**The composition of substitutions defined above, together with ${\eta}_{X}$ as the identity substitution for every set X, gives us a category of substitutions. In more abstract categorical terms, this is exactly the Kleisli category of the adjunction ${\mathbf{F}}_{\mathsf{\Sigma}}\u22a3{\mathbf{U}}_{\mathsf{\Sigma}}$, which is equivalent to the full subcategory of $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$ of all term Σ-algebras (see, for example, [15]).

#### 3.5. Two Model-Theoretic Implications of the Existence of a Free Functor

**Lemma 3.3**

**.**For every monic Σ-homomorphism $f:\phantom{\rule{0.166667em}{0ex}}\mathcal{A}\to \mathcal{B}$, the underlying map $f:A\to B$ is a monomorphism in $\mathsf{Set}$, i.e., injective.

**Proof.**

**Lemma 3.4**

**.**For any Σ-algebra $\mathcal{B}$ and any map $f:\phantom{\rule{0.166667em}{0ex}}A\to B$ we have $\mathcal{R}(f,\mathcal{B})=\mathcal{R}({f}^{\ast},\mathcal{B})$ for the algebraic extension ${f}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(A\right)\to B$. In such a way, $\mathcal{B}$ is accessible via $f:\phantom{\rule{0.166667em}{0ex}}A\to B$ if, and only if, $\mathcal{B}$ is accessible via ${f}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{T}_{\mathsf{\Sigma}}\left(A\right)\to B$.

**Proof.**

**Corollary 3.9.**

- 1.
- $\mathcal{B}$ is accessible via $f:A\to B$.
- 2.
- $\mathcal{B}$ is accessible via ${f}^{\ast}:{T}_{\mathsf{\Sigma}}\left(A\right)\to B$.
- 3.
- ${f}^{\ast}:{\mathcal{T}}_{\mathsf{\Sigma}}\left(A\right)\to \mathcal{B}$ is an epimorphism in $\mathsf{Alg}\left(\mathsf{\Sigma}\right)$.
- 4.
- ${f}^{\ast}:{T}_{\mathsf{\Sigma}}\left(A\right)\to B$ is an epimorphism in $\mathsf{Set}$, i.e., surjective.

#### 3.6. Terms and Derived Operations

**Definition 3.12**

**.**For any set X of variables, any Σ-algebra $\mathcal{A}$ and any Σ-term $t\in {T}_{\mathsf{\Sigma}}\left(X\right)$, we define a corresponding derived operation , i.e., the map

**Definition 3.13**

**.**For any family of maps ${f}_{j}:\phantom{\rule{0.166667em}{0ex}}{A}^{X}\to {A}^{O}$ with $1\le n,1\le j\le n$ we can construct a map $\langle \phantom{\rule{-3.0pt}{0ex}}\langle {f}_{1},\dots ,{f}_{n}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle :\phantom{\rule{0.166667em}{0ex}}{A}^{X}\to {A}^{{I}_{n}}$, ${I}_{n}:=\{{i}_{1},{i}_{2},\dots ,{i}_{n}\}$ defined by

**Definition 3.14**

**.**For any set X and any Σ-algebra $\mathcal{A}$ we define inductively for all Σ-terms $t\in {T}_{\mathsf{\Sigma}}\left(X\right)$ a corresponding derived operation ${t}^{\mathcal{A}}:\phantom{\rule{0.166667em}{0ex}}{A}^{X}\to {A}^{O}$ as follows:

**Variables:**- for all $\u2e22x\u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$, the (projection) map ${x}^{\mathcal{A}}:\phantom{\rule{0.166667em}{0ex}}{A}^{X}\to {A}^{O}$ is defined by ${x}^{\mathcal{A}}\left(\alpha \right)\left(o\right):={\pi}_{x}\left(\alpha \right)=\alpha \left(x\right)$ for all $\alpha \in {A}^{X}$;
**Constants:**- $\mathtt{c}{\langle \rangle}^{\mathcal{A}}:=\langle \phantom{\rule{-3.0pt}{0ex}}\langle \phantom{\rule{0.166667em}{0ex}}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle ;{\mathtt{c}}^{\mathcal{A}}$, for all $\u2e22\mathtt{c}\langle \rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$;
**Operations:**- $\mathtt{op}{\langle {t}_{1},\dots ,{t}_{n}\rangle}^{\mathcal{A}}:=\langle \phantom{\rule{-3.0pt}{0ex}}\langle {t}_{1}^{\mathcal{A}},\dots ,{t}_{n}^{\mathcal{A}}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle ;{\mathtt{op}}^{\mathcal{A}}$, for all $\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left(X\right)$, $n\ge 1$.

#### 3.7. Syntactic Lawvere Theories

#### 3.7.1. Construction of Lawvere Theories

**Objects:**- As objects, we choose canonical finite sets of variables$${X}_{0}=\varnothing \phantom{\rule{1.em}{0ex}}\mathrm{and}\phantom{\rule{1.em}{0ex}}{X}_{n}:=\{{x}_{1}^{n},{x}_{2}^{n},\dots ,{x}_{n}^{n}\}\phantom{\rule{0.277778em}{0ex}}\mathrm{for\; all}\phantom{\rule{0.166667em}{0ex}}n\in \mathbb{N}\phantom{\rule{0.277778em}{0ex}}\mathrm{with}\phantom{\rule{0.277778em}{0ex}}n\ge 1\phantom{\rule{0.166667em}{0ex}}.$$For all $n\ge 2$, we assume ${X}_{n}$ to be equipped with a fixed total order ${x}_{1}^{n}<{x}_{2}^{n}<\dots <{x}_{n}^{n}$; thus, we can reuse the tuple notation to represent maps as discussed in Section 2.
**Morphisms:**- Morphisms are all tuples $({t}_{1},\dots ,{t}_{n}):{X}_{m}\to {X}_{n}$ representing a substitution (declaration) $\mathit{t}:{X}_{n}\to {T}_{\mathsf{\Sigma}}\left({X}_{m}\right)$.
**Identities:**- The identity on ${X}_{n}$ is the tuple $({x}_{1}^{n},\dots ,{x}_{n}^{n}):{X}_{n}\to {X}_{n}$ representing the substitution ${\eta}_{{X}_{n}}:{X}_{n}\to {T}_{\mathsf{\Sigma}}\left({X}_{n}\right)$.
**Composition:**- The composition of two tuples $({r}_{1},\dots ,{r}_{m}):{X}_{k}\to {X}_{m}$ and $({t}_{1},\dots ,{t}_{n}):{X}_{m}\to {X}_{n}$ is the tuple $({\mathit{r}}^{\ast}\left({t}_{1}\right),\dots ,{\mathit{r}}^{\ast}\left({t}_{n}\right)):{X}_{k}\to {X}_{n}$ representing the substitution $\mathit{t};{\mathit{r}}^{\ast}:{X}_{n}\to {T}_{\mathsf{\Sigma}}\left({X}_{k}\right)$ where ${\mathit{r}}^{\ast}:{T}_{\mathsf{\Sigma}}\left({X}_{m}\right)\to {T}_{\mathsf{\Sigma}}\left({X}_{k}\right)$ is the application of the substitution $\mathit{r}:{X}_{m}\to {T}_{\mathsf{\Sigma}}\left({X}_{k}\right)$ according to Definition 3.11 (compare also (11)).
**Laws:**- Identity and associativity law are ensured by Feature (5), composition of substitutions is compatible with substitution application (compare also (12)).

#### 3.7.2. Properties of Lawvere Theories

- The product of two objects ${X}_{n}$ and ${X}_{m}$ is defined by ${X}_{n}\times {X}_{m}:={X}_{n+m}$ with projections ${\pi}_{1}:=({x}_{1}^{n+m},\dots ,{x}_{n}^{n+m}):{X}_{n+m}\to {X}_{n}$ and ${\pi}_{2}:=({x}_{n+1}^{n+m},\dots ,{x}_{n+m}^{n+m}):{X}_{n+m}\to {X}_{m}$.
- The tuple of two morphisms $({t}_{1},\dots ,{t}_{n}):{X}_{k}\to {X}_{n}$ and $({r}_{1},\dots ,{r}_{m}):{X}_{k}\to {X}_{m}$ in $\mathsf{L}\left(\mathsf{\Sigma}\right)$ is given by

**Remark 3.8**

**.**The tentative reader has surely realized that ${X}_{n+m}$ is not the product but the sum of ${X}_{n}$ and ${X}_{m}$ in the category $\mathsf{Set}$ and that $({t}_{1},\dots ,{t}_{n},{r}_{1},\dots ,{r}_{m})$ represents the cotuple $[\mathit{t},\mathit{r}]:{X}_{n+m}\to {T}_{\mathsf{\Sigma}}\left({X}_{k}\right)$ of the two maps $\mathit{t}:{X}_{n}\to {T}_{\mathsf{\Sigma}}\left({X}_{k}\right)$ and $\mathit{r}:{X}_{m}\to {T}_{\mathsf{\Sigma}}\left({X}_{k}\right)$ in $\mathsf{Set}$. However, by choosing the direction of morphisms $({t}_{1},\dots ,{t}_{n}):{X}_{k}\to {X}_{n}$ in $\mathsf{L}\left(\mathsf{\Sigma}\right)$ in accordance with the direction of their semantics, $\langle \phantom{\rule{-3.0pt}{0ex}}\langle {t}_{1}^{\mathcal{A}},\dots ,{t}_{n}^{\mathcal{A}}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle :{A}^{{X}_{k}}\to {A}^{{X}_{n}}$, ${X}_{n+m}$ indeed becomes the categorical product of ${X}_{n}$ and ${X}_{m}$ in $\mathsf{L}\left(\mathsf{\Sigma}\right)$. In other words, it is much more convenient for us to describe $\mathsf{L}\left(\mathsf{\Sigma}\right)$ as a category with finite products instead of a category with finite sums. In this way, we avoid, especially, the needless use of opposite categories.

## 4. Graph Algebras and Graph Term Algebras

#### 4.1. Graph Signatures, Graph Algebras, and Homomorphisms

**Two****different kinds of input items.**This is evident due to working with graphs that consist of both vertices and edges. Instead of a single set, we therefore declare a graph as the input arity.**Arbitrarily****many output items.**A single output is assumed for algebraic operations, but graph operations can produce arbitrarily large finite graphs as output. Similar to the input, the output arity is chosen to be a graph.**Output****is often related to the input.**In the case of the composition operation $\mathtt{comp}$ above, the relation between the two arity graphs ${\mathtt{I}}_{\mathtt{comp}}$ and ${\mathtt{O}}_{\mathtt{comp}}$ is clear from the labelling: the output edge $o{e}_{1}$ has the same source and target as the input edges $i{e}_{1}$ and $i{e}_{2}$, respectively. Instead of always requiring coherent labeling, we introduce a third arity graph ${\mathtt{B}}_{\mathtt{comp}}$, called the boundary of $\mathtt{comp}$, to encompass the connection between input and output in a fitting way.

**Definition 4.1**

**.**A graph signature $\mathsf{\Gamma}=(OP,ar)$ is given by

- A set $OP$ of operation symbols,
- A map $ar$ assigning to each operation symbol $\mathtt{op}$ in $OP$ its arity span , i.e., a span $ar\left(\mathtt{op}\right)={\mathtt{I}}_{\mathtt{op}}\stackrel{{l}_{\mathtt{op}}}{\hookleftarrow}{\mathtt{B}}_{\mathtt{op}}\stackrel{{r}_{\mathtt{op}}}{\hookrightarrow}{\mathtt{O}}_{\mathtt{op}}$ of inclusion graph homomorphisms between finite graphs such that the sets ${\left({\mathtt{O}}_{\mathtt{op}}\right)}_{V}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{V}$ and ${\left({\mathtt{I}}_{\mathtt{op}}\right)}_{V}$ as well as the sets ${\left({\mathtt{O}}_{\mathtt{op}}\right)}_{E}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{E}$ and ${\left({\mathtt{I}}_{\mathtt{op}}\right)}_{E}$ are disjoint. The graphs ${\mathtt{I}}_{\mathtt{op}}$, ${\mathtt{B}}_{\mathtt{op}}$, and ${\mathtt{O}}_{\mathtt{op}}$ are referred to as the input arity, boundary arity, and output arity of $\mathtt{op}$, respectively.

**Remark 4.1**

**.**In contrast to traditional operations, we use explicit names to identify the input and output “positions” of a graph operation. Names can, however, be chosen arbitrarily, and we should be prepared to rename, if necessary, the arities of a graph operation.

**Remark 4.2**

**.**For all finite graphs $\mathtt{J}$ used in arity spans, we assume that the corresponding sets ${\mathtt{J}}_{V}$ and ${\mathtt{J}}_{E}$ are equipped with a fixed total order. Relying on our conventions in Section 2, this allows us to represent any graph homomorphism $\mathit{b}=({\mathit{b}}_{V},{\mathit{b}}_{E}):\mathtt{J}\to \mathtt{G}$ as a pair of tuples ${\mathit{b}}_{V}=(b{v}_{1},\dots ,b{v}_{n})$, ${\mathit{b}}_{E}=(b{e}_{1},\dots ,b{e}_{m})$, where $n=\left|{\mathtt{J}}_{V}\right|$, $m=\left|{\mathtt{J}}_{E}\right|$ and $b{v}_{i}$ ($b{e}_{j}$) the image of the i-th (j-th) element in ${\mathtt{J}}_{V}$ (${\mathtt{J}}_{E}$), $1\le i\le n$, $1\le j\le m$. For any arity span $\mathtt{I}\stackrel{l}{\hookleftarrow}\mathtt{B}\stackrel{r}{\hookrightarrow}\mathtt{O}$, we assume that $\mathtt{B}$ inherits the order from $\mathtt{I}$ and $\mathtt{O}$, respectively.

**Example 4.1**

**.**We define a signature ${\mathsf{\Gamma}}_{cat}$ with an operation symbol $\mathtt{comp}$ to denote operations composing two edges and an operation symbol $\mathtt{id}$ to denote operations, assigning to vertices corresponding identity edges.

**Definition 4.2**

**.**Let $\mathsf{\Gamma}=(OP,ar)$ be a graph signature. A (graph) $\mathsf{\Gamma}$-algebra $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$ is given

- By a graph$\mathtt{G}$, called the carrier of $\mathcal{G}$, and
- By a family$O{P}^{\mathcal{G}}=({\mathtt{op}}^{\mathcal{G}}:\phantom{\rule{0.166667em}{0ex}}{\mathtt{G}}^{{\mathtt{I}}_{\mathtt{op}}}\to {\mathtt{G}}^{{\mathtt{O}}_{\mathtt{op}}}\phantom{\rule{0.166667em}{0ex}}\phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\phantom{\rule{0.166667em}{0ex}}\mathtt{op}\in OP)$of maps such that the following diagram commutes for all$\mathtt{op}$in$OP$and all graph homomorphisms$\mathit{b}\in {\mathtt{G}}^{{\mathtt{I}}_{\mathtt{op}}}$.

**Example 4.2**

**.**We consider the graph signature ${\mathsf{\Gamma}}_{cat}$ in Example 4.1.

**Example 4.3**

**.**Graph algebras can serve as a conceptual tool to give a precise meaning to statements like “let $\mathsf{C}$ be a category with chosen pullbacks”.

**Remark 4.3**

**.**Given a “set of indices” I and a “carrier set” A, we do have a projection map ${\pi}_{i}:{A}^{I}\to A$ at hand for any index $i\in I$, as described in Section 2.

**Definition 4.3**

**.**Let $\mathsf{\Gamma}$ be a graph signature. A $\mathsf{\Gamma}$-homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$ between two $\mathsf{\Gamma}$-algebras $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$ and $\mathcal{H}=(\mathtt{H},O{P}^{\mathcal{H}})$ is a graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to \mathtt{H}$ satisfying the following homomorphism condition:

**(HC)**via the requirement that the above right square of maps commutes. Note that in the case of constant symbols $\mathtt{c}\in OP$, ${\mathtt{I}}_{\mathtt{c}}=\mathbf{0}$, the homomorphism condition turns into the equation ${\mathtt{op}}^{\mathtt{G}}(\left(\right),\left(\right));\phi ={\mathtt{op}}^{\mathtt{H}}(\left(\right),\left(\right))$ if we apply our conventions in Section 2 and Remark 4.2 concerning the tuple notation.

**Example 4.4**

**.**In the case of ${\mathsf{\Gamma}}_{cat}$-algebras as defined in Example 4.2, the homomorphism conditions for the operation symbols $\mathtt{comp}$ and $\mathtt{id}$, according to Definition 3.3, are nothing but the usual requirements for functors to be compatible with composition and identities, respectively.

**Proposition 4.1**

**.**The assignments $\mathcal{G}\to \mathtt{G}$ and $(\phi :\mathcal{G}\to \mathcal{H})\mapsto (\phi :\mathtt{G}\to \mathtt{H})$ define a faithful forgetful functor:

**Theorem 4.1**

**.**$\mathsf{Alg}\left(\mathsf{\Gamma}\right)$ inherits any small limit from the category $\mathsf{Graph}$, i.e., the functor ${\mathbf{U}}_{\mathsf{\Gamma}}:\mathsf{Alg}\left(\mathsf{\Gamma}\right)\to \mathsf{Graph}$ creates small limits. $\mathsf{Alg}\left(\mathsf{\Gamma}\right)$ therefore has all small limits since $\mathsf{Graph}$ does.

#### 4.2. Comparison with the Old Definitions

#### 4.2.1. Comparison of Arity Declarations

#### 4.2.2. Equivalence of Graph Operations

#### 4.2.3. Equivalence of Homomorphism Conditions

**Remark 4.4**

**.**For any map $f:A\to B$, its graph is usually defined as the binary relation $\left\{\right(a,f\left(a\right))\mid a\in A\}\subseteq A\times B$. Often, the story is even turned, and maps are introduced as those binary relations $f\subseteq A\times B$ that are left-total and right-unique.

**Example 4.5**

**.**Figure 5 shows the pushout of arity declarations for the operation symbol $\mathtt{pb}$. Constructing the graph of pullback operations, as described in Example 3, considers for any chosen pullback the whole pullback square, and not just the pullback span.

**Example 4.6**

**.**In general, any chosen (co)limits of diagrams of a fixed shape $\mathtt{I}$ in a category $\mathsf{C}$ give rise to a corresponding graph operation on $gr\left(\mathsf{C}\right)$ where the arity $\mathtt{B}$ is simply given by all the vertices in $\mathtt{I}$ while arity $\mathtt{O}$ represents the shape of the corresponding (co)cones.

**Remark 4.5**

**.**Starting with a span of arities as in Definition 4.1, we obtain a corresponding commutative square of arities via a simple pushout construction. That this square becomes, moreover, in any topos, a pullback is an essential side effect.

#### 4.3. Graph Subalgebras

**Definition 4.4**

**.**Let $\mathsf{\Gamma}=(OP,ar)$ be a graph signature. A $\mathsf{\Gamma}$-algebra $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$ is a $\mathsf{\Gamma}$-subalgebra of a $\mathsf{\Gamma}$-algebra $\mathcal{H}=(\mathtt{H},O{P}^{\mathcal{H}})$ if $\mathtt{G}\u2291\mathtt{H}$ and and the inclusion graph homomorphism ${\iota}_{\mathtt{G},\mathtt{H}}=({\iota}_{{\mathtt{G}}_{V},{\mathtt{H}}_{V}},{\iota}_{{\mathtt{G}}_{E},{\mathtt{H}}_{E}}):\mathtt{G}\to \mathtt{H}$ establishes a $\mathsf{\Gamma}$-homomorphism ${\iota}_{\mathtt{G},\mathtt{H}}:\mathcal{G}\to \mathcal{H}$.

**Corollary 4.1**

**.**If the underlying graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to \mathtt{H}$ of a $\mathsf{\Gamma}$-homomorphism $\phi :\mathcal{G}\to \mathcal{H}$ is injective (surjective), then $\phi :\mathcal{G}\to \mathcal{H}$ is a monomorphism (epimorphism) in $\mathsf{Alg}\left(\mathsf{\Gamma}\right)$.

**Corollary 4.2**

**.**For any set I, any $\mathsf{\Gamma}$-algebra $\mathcal{H}$, and any diagram $\delta :\phantom{\rule{0.166667em}{0ex}}\mathtt{MP}\left(I\right)\to \mathsf{Alg}\left(\mathsf{\Gamma}\right)$ of $\mathsf{\Gamma}$-subalgebras ${\delta}_{{e}_{i}}={\iota}_{{\mathtt{G}}_{i},\mathtt{H}}:{\mathcal{G}}_{i}\hookrightarrow \mathcal{H}$, $i\in I$ of $\mathcal{H}$ there is a unique $\mathsf{\Gamma}$-subalgebra $\mathcal{L}=(\mathtt{L},O{P}^{\mathcal{L}})$ of $\mathcal{H}$ with $\mathtt{L}={\bigcap}_{i\in I}{\mathtt{G}}_{i}$, i.e., ${\mathtt{L}}_{V}={\bigcap}_{i\in I}{\left({\mathtt{G}}_{i}\right)}_{V}$ and ${\mathtt{L}}_{E}={\bigcap}_{i\in I}{\left({\mathtt{G}}_{i}\right)}_{E}$, that is a $\mathsf{\Gamma}$-subalgebra of ${\mathcal{G}}_{i}$ for all $i\in I$.

**Definition 4.5**

**.**For any $\mathsf{\Gamma}$-algebra $\mathcal{H}$ and any graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to \mathtt{H}$, let $\mathcal{M}$ be the set of all $\mathsf{\Gamma}$-subalgebras $\mathcal{X}$ of $\mathcal{H}$ such that $\phi $ factors through the inclusion graph homomorphism ${\iota}_{\mathtt{X},\mathtt{H}}:\mathtt{X}\hookrightarrow \mathtt{H}$; i.e., there exists a graph homomorphism ${\phi}_{\mathtt{X}}:\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to X$ such that ${\phi}_{\mathcal{X}}\phantom{\rule{0.166667em}{0ex}};{\iota}_{\mathtt{X},\mathtt{H}}=\phi $.

**Corollary 4.3**

**.**For any $\mathsf{\Gamma}$-algebra $\mathcal{H}$ and any graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to \mathtt{H}$, we have $\phi \left(\mathtt{G}\right)\u2291\mathtt{R}(\phi ,\mathcal{H})$ for the set-theoretic image $\phi \left(\mathtt{G}\right)$ of $\mathtt{G}$ with respect to $\phi $.

**Definition 4.6**

**.**Let $\mathcal{H}$ be a $\mathsf{\Gamma}$-algebra.

- 1.
- $\mathcal{H}$is accessible via a graph homomorphism $\phi :\mathtt{G}\to \mathtt{H}$ if $\mathcal{R}(\phi ,\mathcal{H})=\mathcal{H}$.
- 2.
- If$\mathcal{H}$is accessible via an inclusion graph homomorphism${\iota}_{\mathtt{G},\mathtt{H}}:\mathtt{G}\to \mathtt{H}$, i.e., if$\mathcal{R}(\mathtt{G},\mathcal{H})=\mathcal{R}({\iota}_{\mathtt{G},\mathtt{H}},\mathcal{H})=\mathcal{H}$, we say also that$\mathcal{H}$is generated by $\mathtt{G}$.
- 3.
- $\mathcal{H}$is said to be generated if it is generated by the empty graph, i.e., accessible via the unique graph homomorphism ${\iota}_{\mathbf{0},\mathtt{H}}:\mathbf{0}\hookrightarrow \mathtt{H}$ from the initial object $\mathbf{0}$ in $\mathsf{Graph}$ to $\mathtt{H}$.

**Corollary 4.4.**

**Corollary 4.5.**

**Lemma 4.1**

**.**A $\mathsf{\Gamma}$-homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$ is an epimorphism in $\mathsf{Alg}\left(\mathsf{\Gamma}\right)$ if $\mathcal{H}$ is accessible via the underlying graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to \mathtt{H}$, i.e., if $\mathcal{H}=\mathcal{R}(\phi ,\mathcal{H})$.

**Proof.**

**Proposition 4.2**

**.**For any $\mathsf{\Gamma}$-subalgebra ${\iota}_{\mathtt{G},\mathtt{H}}:\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$ of a $\mathsf{\Gamma}$-algebra $\mathcal{H}$ there exists a $\mathsf{\Gamma}$-algebra $\mathcal{K}$ and parallel $\mathsf{\Gamma}$-homomorphisms $\psi ,\varphi :\phantom{\rule{0.166667em}{0ex}}\mathcal{H}\to \mathcal{K}$ such that ${\iota}_{\mathtt{G},\mathtt{H}}:\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$ is the equalizer of $\psi $ and $\varphi $ in $\mathsf{Alg}\left(\mathsf{\Gamma}\right)$.

**Proof.**

**Graph Operations on $\mathtt{K}$:**We extend $\mathtt{K}$ to a partial $\mathsf{\Gamma}$-algebra $\mathcal{K}=(\mathtt{K},O{P}^{\mathcal{K}})$ (see Definition 4.7) by defining for each $\mathtt{op}$ in $OP$ a corresponding partial graph operation ${\mathtt{op}}^{\mathcal{K}}:\phantom{\rule{0.166667em}{0ex}}{\mathtt{K}}^{{I}_{\mathtt{op}}}\phantom{\rule{6.99997pt}{0ex}}\circ \phantom{\rule{-13.00003pt}{0ex}}\u27f6\phantom{\rule{1.00006pt}{0ex}}{\mathtt{K}}^{{O}_{\mathtt{op}}}$ according to

**Case 1**,

**Case 2**, and

**Case 3**.

**Proposition 4.3**

**.**For any $\mathsf{\Gamma}$-homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$, it holds that $\mathcal{H}$ is accessible via the underlying graph homomorphism $\phi :\mathtt{G}\to \mathtt{H}$; i.e., in other words, $\mathcal{H}$ is equal to the homomorphic image $\mathcal{R}(\phi ,\mathcal{H})$ of $\mathcal{G}$ with respect to $\phi $, if, and only if, $\phi :\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$ is an epimorphism in $\mathsf{Alg}\left(\mathsf{\Gamma}\right)$.

**Proof.**

**Example 4.7**

**.**We consider a ${\mathsf{\Gamma}}_{cat}$-homomorphism $\phi :\mathcal{G}\to \mathcal{H}$ between two finite ${\mathsf{\Gamma}}_{cat}$-algebras $\mathcal{G}$ and $\mathcal{H}$, as depicted below.

#### 4.4. Partial Graph Algebras and Their Term Completion

**Definition 4.7**

**.**A partial (graph) $\mathsf{\Gamma}$-algebra $\mathcal{G}$ is a pair $(\mathtt{G},O{P}^{\mathcal{G}})$ given

- By a graph$\mathtt{G}$, called the carrier of $\mathcal{G}$, and
- By a family$O{P}^{\mathcal{G}}=({\mathtt{op}}^{\mathcal{G}}:\phantom{\rule{0.166667em}{0ex}}{\mathtt{G}}^{{\mathtt{I}}_{\mathtt{op}}}\phantom{\rule{6.99997pt}{0ex}}\circ \phantom{\rule{-13.00003pt}{0ex}}\u27f6\phantom{\rule{1.00006pt}{0ex}}{\mathtt{G}}^{{\mathtt{O}}_{\mathtt{op}}}\phantom{\rule{0.166667em}{0ex}}\phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\phantom{\rule{0.166667em}{0ex}}\mathtt{op}\in OP)$of partial maps such that the following diagram commutes for all$\mathtt{op}$in$OP$and all graph homomorphisms$\mathit{b}\in dom\left({\mathtt{G}}^{{\mathtt{I}}_{\mathtt{op}}}\right)$.

**Definition 4.8**

**.**A $\mathsf{\Gamma}$-homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathcal{G}\to \mathcal{H}$ between two partial $\mathsf{\Gamma}$-algebras $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$ and $\mathcal{H}=(\mathtt{H},O{P}^{\mathcal{H}})$ is a graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{G}\to \mathtt{H}$ satisfying the following homomorphism condition

**Proposition 4.4**

**.**The assignments $\mathcal{G}\to \mathtt{G}$ and $(\phi :\mathcal{G}\to \mathcal{H})\mapsto (\phi :\mathtt{G}\to \mathtt{H})$ define a faithful forgetful functor

**Remark 4.6**

**.**In addition to our notational conventions in Section 2 and Remark 4.2, we will rely on the following syntactic representation of inputs of graph operations: For any graph $\mathtt{G}$ and any $\mathtt{op}$ in $OP$ an input $\mathit{b}=({\mathit{b}}_{V},{\mathit{b}}_{E})\in {\mathtt{G}}^{{\mathtt{I}}_{\mathtt{op}}}$ is represented by two strings, representing the vertices and the edges in $\mathtt{G}$, respectively, separated by the symbol “|”

**Definition 4.9**

**.**Let $\mathsf{\Gamma}=(OP,ar)$ be a graph signature and $\mathcal{K}=(\mathtt{K},O{P}^{\mathcal{K}})$ be a partial $\mathsf{\Gamma}$-algebra. We define the $\mathsf{\Gamma}$-term completion ${\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$ of the graph $\mathtt{K}$ with respect to the partial $\mathsf{\Gamma}$-algebra $\mathcal{K}$ as the smallest graph satisfying the following three conditions:

**Generators:**- $\mathtt{K}\u2291{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$
**Constants:**- For all constants$\mathtt{c}$in$OP$, such that$dom\left({\mathtt{c}}^{\mathcal{K}}\right)=\varnothing $, the graph${\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$contains
- $\langle {\mathtt{c}}_{ov}\u2e22\phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle \u2e23$as a vertex, for each vertex$ov$in${\mathtt{O}}_{\mathtt{c}}$;
- $\u2e22{\mathtt{c}}_{oe}\langle \phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle \u2e23$as an edge, for each edge$oe$in${\mathtt{O}}_{\mathtt{c}}$, where$s{c}^{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathtt{c}}_{oe}\langle \phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle \right):={\mathtt{c}}_{s{c}^{{\mathtt{O}}_{\mathtt{c}}}\left(oe\right)}\langle \phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle $and$t{g}^{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathtt{c}}_{oe}\langle \phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle \right):={\mathtt{c}}_{t{g}^{{\mathtt{O}}_{\mathtt{c}}}\left(oe\right)}\langle \phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle $

**Operations:**- For all$\mathtt{op}$in$OP$with${\mathtt{I}}_{\mathtt{op}}\ne \mathbf{0}$and any$\mathit{t}\in {\mathtt{T}}_{\mathsf{\Gamma}}{\left(\mathcal{K}\right)}^{{\mathtt{I}}_{\mathtt{op}}}$such that there is no$\mathit{b}\in dom\left({\mathtt{op}}^{\mathcal{K}}\right)\subseteq {\mathtt{K}}^{{\mathtt{I}}_{\mathtt{op}}}$with$\mathit{t}=\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$,${\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$contains
- $\u2e22{\mathtt{op}}_{ov}\langle syn\left(\mathit{t}\right)\rangle \u2e23$as a vertex, for each vertex$ov$in${\left({\mathtt{O}}_{\mathtt{op}}\right)}_{V}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{V}$;
- $\u2e22{\mathtt{op}}_{oe}\langle syn\left(\mathit{t}\right)\rangle \u2e23$as an edge, for each edge$oe$in${\left({\mathtt{O}}_{\mathtt{op}}\right)}_{E}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{E}$, where

**Remark 4.7**

**.**The construction of $\mathsf{\Gamma}$-terms in Definition 4.9 can be organized as a successive application of term-construction steps starting with the graph $\mathtt{K}$: A term-construction step in the case

**Constants**means that we construct, in parallel, for a constant symbol $\mathtt{c}$ the terms for all vertices and edges in ${\mathtt{O}}_{\mathtt{c}}$. Analogously, a term-construction step in the case

**Operations**means that we construct for an operation symbol $\mathtt{op}$ and an input $\mathit{t}$, in parallel, the terms for all vertices and edges in ${\mathtt{O}}_{\mathtt{op}}\setminus {\mathtt{B}}_{\mathtt{op}}$. Each term-construction step extends an intermediate graph $\mathtt{T}$ to a graph ${\mathtt{T}}^{\prime}$. This extension is, however, nothing but the construction of the following pushout:

- 1.
- The term notation provides a uniform mechanism to create unique identifiers for the new graph items introduced by applying a non-deleting injective graph -transformation rule [9].
- 2.
- At the same time, the term notation encodes all the information necessary to uniquely identify the pushout that has been creating the new items.

**Definition 4.10**

**.**We can extend any partial $\mathsf{\Gamma}$-algebra $\mathcal{K}=(\mathtt{K},O{P}^{\mathcal{K}})$ to a total $\mathsf{\Gamma}$-algebra ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)=({\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right),O{P}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)})$ as follows:

**Constants:**- For all constants$\mathtt{c}$in$OP$:
**Utilizing**$\mathcal{K}$**:**- If${\mathtt{c}}^{\mathcal{K}}$is defined, we simply reuse it:$${\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\right)={\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}({\mathbf{0}}_{\mathtt{K}};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}):={\mathtt{c}}^{\mathcal{K}}\left({\mathbf{0}}_{\mathtt{K}}\right);{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$$
**Completion:**- If${\mathtt{c}}^{\mathcal{K}}$is not defined, i.e.,$dom\left({\mathtt{c}}^{\mathcal{K}}\right)=\varnothing $we set
- ${\left({\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\right)\right)}_{V}\left(ov\right):=\u2e22{\mathtt{c}}_{ov}\langle \phantom{\rule{0.166667em}{0ex}}\phantom{\rule{0.166667em}{0ex}}\rangle \u2e23$for each vertex$ov$in${\mathtt{O}}_{\mathtt{c}}$and
- ${\left({\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\right)\right)}_{E}\left(oe\right):=\u2e22{\mathtt{c}}_{oe}\langle \phantom{\rule{0.166667em}{0ex}}\phantom{\rule{0.166667em}{0ex}}\rangle \u2e22$for each edge$oe$in${\mathtt{O}}_{\mathtt{c}}$.

**Operations:**- For all$\mathtt{op}$in$OP$with${\mathtt{I}}_{\mathtt{op}}\ne \mathbf{0}$and any$\mathit{t}\in {\mathtt{T}}_{\mathsf{\Gamma}}{\left(\mathcal{K}\right)}^{{\mathtt{I}}_{\mathtt{op}}}$:
**Utilizing**$\mathcal{K}$**:**- If there is a$\mathit{b}\in dom\left({\mathtt{op}}^{\mathcal{K}}\right)\subseteq {\mathtt{K}}^{{\mathtt{I}}_{\mathtt{op}}}$with$\mathit{t}=\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$, we reuse${\mathtt{op}}^{\mathcal{K}}$:$${\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left(\mathit{t}\right)={\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}(\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}):={\mathtt{op}}^{\mathcal{K}}\left(\mathit{b}\right);{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$$
**Completion:**- If there is no$\mathit{b}\in dom\left({\mathtt{op}}^{\mathcal{K}}\right)\subseteq {\mathtt{K}}^{{\mathtt{I}}_{\mathtt{op}}}$with$\mathit{t}=\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$, we set$${\left({\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left(\mathit{t}\right)\right)}_{V}\left(ov\right):=\left\{\begin{array}{cc}\hfill {\mathit{t}}_{V}\left(ov\right)\hfill & ,\phantom{\rule{0.277778em}{0ex}}if\phantom{\rule{0.277778em}{0ex}}ov\in {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{V}\hfill \\ \hfill \u2e22{\mathtt{op}}_{ov}\langle syn\left(\mathit{t}\right)\rangle \u2e23\hfill & ,\phantom{\rule{0.277778em}{0ex}}if\phantom{\rule{0.277778em}{0ex}}ov\in {\left({\mathtt{O}}_{\mathtt{op}}\right)}_{V}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{V}\hfill \end{array}\right.$$$${\left({\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left(\mathit{t}\right)\right)}_{E}\left(oe\right):=\left\{\begin{array}{cc}\hfill {\mathit{t}}_{E}\left(oe\right)\hfill & ,\phantom{\rule{0.277778em}{0ex}}if\phantom{\rule{0.277778em}{0ex}}oe\in {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{E}\hfill \\ \hfill \u2e22{\mathtt{op}}_{oe}\langle syn\left(\mathit{t}\right)\rangle \u2e23\hfill & \hfill ,\phantom{\rule{0.277778em}{0ex}}if\phantom{\rule{0.277778em}{0ex}}oe\in {\left({\mathtt{O}}_{\mathtt{op}}\right)}_{E}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{E}.\end{array}\right.$$

**Utilizing**$\mathcal{K}$” are defined in such a way that we obtain

**Corollary 4.6**

**.**For any partial $\mathsf{\Gamma}$-algebra $\mathcal{K}=(\mathtt{K},O{P}^{\mathcal{K}})$, the inclusion graph homomorphism ${\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}:\mathtt{K}\to {\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$ constitutes a $\mathsf{\Gamma}$-homomorphism ${\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}:\mathcal{K}\to {\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$ in $\mathsf{PAlg}\left(\mathsf{\Gamma}\right)$, and thus, due to (21), ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)=\mathcal{K}$ if $\mathcal{K}$ is a total $\mathsf{\Gamma}$-algebra.

**Proposition 4.5**

**.**For any partial $\mathsf{\Gamma}$-algebra $\mathcal{K}=(\mathtt{K},O{P}^{\mathcal{K}})$, the total $\mathsf{\Gamma}$-algebra ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)=({\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right),O{P}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)})$ has the following universal property: for any total $\mathsf{\Gamma}$-algebra $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$ and any $\mathsf{\Gamma}$-homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathcal{K}\to \mathcal{G}$ there exists a unique $\mathsf{\Gamma}$-homomorphism ${\phi}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)\to \mathcal{G}$ such that the defining condition ${\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast}=\phi $ is satisfied.

**Proof.**

**Generators:**- In this base case, the defining condition forces ${\phi}_{V}^{\ast}\left(kv\right)={\phi}_{V}\left(kv\right)$ for all $kv\in {\mathtt{K}}_{V}$ and ${\phi}_{E}^{\ast}\left(kv\right)={\phi}_{E}\left(ke\right)$ for all $ke\in {\mathtt{K}}_{E}$.
**Constants:**- In the second base case, we have, for all constants $\mathtt{c}$ in $OP$:
**Utilizing**$\mathcal{K}$**:**- If ${\mathtt{c}}^{\mathcal{K}}$ is defined, the definition of operations in ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$, the defining condition and the assumption that $\phi $ is a $\mathsf{\Gamma}$-homomorphism ensure that ${\phi}^{\ast}$ satisfies the homorphism condition for the constant $\mathtt{c}$:$$\begin{array}{cc}\hfill {\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\right);{\phi}^{\ast}\phantom{\rule{1.em}{0ex}}& ={\mathtt{c}}^{\mathcal{K}}\left({\mathbf{0}}_{\mathtt{K}}\right);{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast}={\mathtt{c}}^{\mathcal{K}}\left({\mathbf{0}}_{\mathtt{K}}\right);\phi ={\mathtt{c}}^{\mathcal{G}}({\mathbf{0}}_{\mathtt{K}};\phi )\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& ={\mathtt{c}}^{\mathcal{G}}({\mathbf{0}}_{\mathtt{K}};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast})={\mathtt{c}}^{\mathcal{G}}({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast})\hfill \end{array}$$
**Completion:**- If ${\mathtt{c}}^{\mathcal{K}}$ is not defined, the definition of operations in ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$ and the required homomorphism condition for ${\phi}^{\ast}$ forces for each vertex $ov$ in ${\mathtt{O}}_{\mathtt{c}}$$$\begin{array}{cc}\hfill {\phi}_{V}^{\ast}\left({\mathtt{c}}_{ov}\langle \phantom{\rule{0.166667em}{0ex}}|\phantom{\rule{0.166667em}{0ex}}\rangle \right)\phantom{\rule{1.em}{0ex}}& ={\phi}_{V}^{\ast}\left({\left({\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\right)\right)}_{V}\left(ov\right)\right)={\left({\mathtt{c}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\right);{\phi}^{\ast}\right)}_{V}\left(ov\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& ={\left({\mathtt{c}}^{\mathcal{G}}({\mathbf{0}}_{{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast})\right)}_{V}\left(ov\right)={\left({\mathtt{c}}^{\mathcal{G}}\left({\mathbf{0}}_{\mathtt{G}}\right)\right)}_{V}\left(ov\right)\phantom{\rule{0.166667em}{0ex}}.\hfill \end{array}$$

**Operations:**- We have, for all $\mathtt{op}$ in $OP$ with ${\mathtt{I}}_{\mathtt{op}}\ne \mathbf{0}$ and any $\mathit{t}\in {\mathtt{T}}_{\mathsf{\Gamma}}{\left(\mathcal{K}\right)}^{{\mathtt{I}}_{\mathtt{op}}}$,
**Utilizing**$\mathcal{K}$**:**- If there is a $\mathit{b}\in dom\left({\mathtt{op}}^{\mathcal{K}}\right)\subseteq {\mathtt{K}}^{{\mathtt{I}}_{\mathtt{op}}}$ with $\mathit{t}=\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$, then the definition of operations in ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$, the defining condition and the assumption that $\phi $ is a $\mathsf{\Gamma}$-homomorphism ensure that ${\phi}^{\ast}$ satisfies the homomorphism condition for $\mathit{t}$:$$\begin{array}{cc}\hfill {\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left(\mathit{t}\right);{\phi}^{\ast}\phantom{\rule{1.em}{0ex}}& ={\mathtt{op}}^{\mathcal{K}}\left(\mathit{b}\right);{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast}={\mathtt{op}}^{\mathcal{K}}\left(\mathit{b}\right);\phi ={\mathtt{op}}^{\mathcal{G}}(\mathit{b};\phi )\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& ={\mathtt{op}}^{\mathcal{G}}(\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)};{\phi}^{\ast})={\mathtt{op}}^{\mathcal{G}}(\mathit{t};{\phi}^{\ast})\hfill \end{array}$$
**Completion:**- If there is no $\mathit{b}\in dom\left({\mathtt{op}}^{\mathcal{K}}\right)\subseteq {\mathtt{K}}^{{\mathtt{I}}_{\mathtt{op}}}$ with $\mathit{t}=\mathit{b};{\iota}_{\mathtt{K},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}$, the induction hypothesis is that ${\phi}^{\ast}$ is already defined on a subgraph $\mathtt{T}\u2291{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$ and that $\mathit{t}\left({\mathtt{I}}_{\mathtt{op}}\right)\u2291\mathtt{T}$. This ensures $\mathit{t};{\phi}^{\ast}\in {\mathtt{G}}^{{\mathtt{I}}_{\mathtt{op}}}$. In the induction step, we extend ${\phi}^{\ast}$ to the graph ${\mathtt{T}}^{\prime}\u2291{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$. The definition of operations in ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)$ and the required homomorphism condition for ${\phi}^{\ast}$ forces for each vertex $ov$ in ${\left({\mathtt{O}}_{\mathtt{op}}\right)}_{V}\setminus {\left({\mathtt{B}}_{\mathtt{op}}\right)}_{V}$$$\begin{array}{cc}\hfill {\phi}_{V}^{\ast}\left({\mathtt{op}}_{ov}\langle syn\left(\mathit{t}\right)\rangle \right)\phantom{\rule{1.em}{0ex}}& ={\phi}_{V}^{\ast}\left({\left({\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left(\mathit{t}\right)\right)}_{V}\left(ov\right)\right)={\left({\mathtt{op}}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{K}\right)}\left(\mathit{t}\right);{\phi}^{\ast}\right)}_{V}\left(ov\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& ={\left({\mathtt{op}}^{\mathcal{G}}(\mathit{t};{\phi}^{\ast})\right)}_{V}\left(ov\right)\phantom{\rule{0.166667em}{0ex}}.\hfill \end{array}$$

#### 4.5. Graph Terms and Graph Term Algebras

**Definition 4.11**

**.**Let $\mathtt{X}$ be a graph and $\mathcal{X}=(\mathtt{X},O{P}^{\mathcal{X}})$ be the corresponding unique partial $\mathsf{\Gamma}$-algebra where all graph operations are completely undefined.

**Graph terms**- : We denote the graph${\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathcal{X}\right)$, according to Definition 4.9, also by${\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)$and call it the graph of all (graph) $\mathsf{\Gamma}$-terms on $\mathtt{X}$.
**Graph term algebra**- : We denote the term completion$\mathsf{\Gamma}$-algebra${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathcal{X}\right)$, due to Definition 4.10, also by${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)=({\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right),O{P}^{{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)})$and call it the$\mathsf{\Gamma}$-term graph algebra on $\mathtt{X}$.

**Proposition 4.6**

**.**Given a graph $\mathtt{X}$, the $\mathsf{\Gamma}$-term graph algebra ${\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)$ has the following universal property: For any total $\mathsf{\Gamma}$-algebra $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$ and any graph homomorphism $\phi :\phantom{\rule{0.166667em}{0ex}}\mathtt{X}\to \mathtt{G}$, there exists a unique $\mathsf{\Gamma}$-homomorphism ${\phi}^{\ast}:\phantom{\rule{0.166667em}{0ex}}{\mathcal{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)\to \mathcal{G}$ such that the defining condition ${\iota}_{\mathtt{X},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)};{\phi}^{\ast}=\phi $ is satisfied.

**Substition Calculus:**- Graph term algebras manifest the “internalization approach” in the case of graph algebras. Relying on Proposition 4.6, we can indeed obtain a fully fledged substitution calculus, meeting the requirements formulated in Section 3.4.1. Based on the idea that a substitution (declaration) is now given by a graph homomorphism $\sigma :\mathtt{X}\to {\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathtt{Y}\right)$ and that a variable assignment is a graph homomorphism $\alpha :\mathtt{X}\to \mathtt{G}$ for a $\mathsf{\Gamma}$-algebra $\mathcal{G}=(\mathtt{G},O{P}^{\mathcal{G}})$, we can simply transfer all the discussions, definitions and results from Section 3.4.2 to graph algebras. We will spare the reader this copy–paste exercise.
**No appropriate concept of Derived Operation:**- In traditional Universal Algebra, we do have a one-to-one correspondence between the “internal view” of terms as elements of free algebras and the “external view” of terms as an appropriate representation of derived operations (compare Definitions 3.12 and 3.14). It took us a while to realize that this one-to-one correspondence breaks down when it comes to graph algebras and even longer to understand the reasons. We discuss and address this problem in the next section.

## 5. Derived Graph Operations

**Lemma 5.1**

**.**For a given graph $\mathtt{X}$, any subgraph $\mathtt{O}\u2291{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)$ defines a span $\mathtt{X}\phantom{\rule{0.166667em}{0ex}}\stackrel{{l}_{\mathtt{O}}}{\hookleftarrow}\phantom{\rule{0.166667em}{0ex}}{\mathtt{B}}_{\mathtt{O}}\phantom{\rule{0.166667em}{0ex}}\stackrel{{O}_{\mathtt{O}}}{\hookrightarrow}\phantom{\rule{0.166667em}{0ex}}\mathtt{O}$ of graph inclusions with ${\mathtt{B}}_{\mathtt{O}}:=\mathtt{X}\cap \mathtt{O}$. Moreover, we obtain for all graphs $\mathtt{G}$ a map ${\delta}_{\mathtt{O}}^{\mathtt{G}}:{\mathtt{G}}^{\mathtt{X}}\to {\mathtt{G}}^{\mathtt{O}}$ defined by ${\delta}_{\mathtt{O}}^{\mathtt{G}}\left(\mathit{b}\right):={\iota}_{\mathtt{O},{\mathtt{T}}_{\mathsf{\Gamma}}\left(\mathtt{X}\right)};{\mathit{b}}^{\ast}$ for all $\mathit{b}\in {\mathtt{G}}^{\mathtt{X}}$ and satisfying the commutativity requirement for graph operations in Definition 4.2.

**Variables**and

**Constants**, and the induction step

**Operations**, which is implicitly split into two steps—(1)

**Tupling**and (2)

**Symbolic Sequential Composition**of a tuple with an operation symbol. This splitting becomes apparent in Definition 3.14 (Construction of Derived Operations).

**Variables**turns into a step

**(Built-in) Projections**. Besides this, there is nothing wrong with any of the steps except the step

**Tupling**.

**Example 5.1**

**.**To illustrate the problems with tupling, we consider the composition of four edges. We are interested in a “graph operation expression” built up of three copies of the operation symbol $\mathtt{comp}$, as defined in Example 4.1. The input arity of the expression should be the graph ${iv}_{1}\stackrel{{ie}_{1}}{\to}{iv}_{2}\stackrel{{ie}_{2}}{\to}{iv}_{3}\stackrel{{ie}_{3}}{\to}{iv}_{4}\stackrel{{ie}_{4}}{\to}{iv}_{5}$ and the output arity should be the graph ${iv}_{1}\stackrel{oe}{\to}{iv}_{5}$5 with $oe$ representing the composition of the four edges in the input arity.

#### 5.1. Reconstruction of Syntactic Lawvere Theories

#### 5.1.1. Categories with Finite Products

- $\mathsf{C}$ has an empty product (terminal object) $\mathbf{1}$, i.e., for any object A in $\mathsf{C}$ there is a morphism $\langle \phantom{\rule{-3.0pt}{0ex}}\langle \phantom{\rule{0.166667em}{0ex}}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle :A\to \mathbf{1}$ such that$$g;\langle \phantom{\rule{-3.0pt}{0ex}}\langle \phantom{\rule{0.166667em}{0ex}}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle =\langle \phantom{\rule{-3.0pt}{0ex}}\langle \phantom{\rule{0.166667em}{0ex}}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle :B\to \mathbf{1}\phantom{\rule{1.em}{0ex}}\mathrm{for}\phantom{\rule{4.pt}{0ex}}\mathrm{all}\phantom{\rule{4.pt}{0ex}}\mathrm{morphisms}\phantom{\rule{0.277778em}{0ex}}g:B\to A.$$
- For any family ${A}_{1},\dots ,{A}_{n}$, $n\ge 1$ of objects, there is an object ${A}_{1}\times \dots \times {A}_{n}$ together with projections ${\pi}_{i}:{A}_{1}\times \dots \times {A}_{n}\to {A}_{i}$, $1\le i\le n$ such that
- For any object B and any family ${f}_{i}:B\to {A}_{i}$, $1\le i\le n$ of morphisms, there is a morphism $\langle \phantom{\rule{-3.0pt}{0ex}}\langle {f}_{1},\dots ,{f}_{n}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle :B\to {A}_{1}\times \dots \times {A}_{n}$ with$$\langle \phantom{\rule{-3.0pt}{0ex}}\langle {f}_{1},\dots ,{f}_{n}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle ;{\pi}_{i}={f}_{i}\phantom{\rule{1.em}{0ex}}\mathrm{for}\phantom{\rule{4.pt}{0ex}}\mathrm{all}\phantom{\rule{0.277778em}{0ex}}1\le i\le n.$$
- Finally, for all morphisms $g:C\to B$, the following equation holds$$g;\langle \phantom{\rule{-3.0pt}{0ex}}\langle {f}_{1},\dots ,{f}_{n}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle =\langle \phantom{\rule{-3.0pt}{0ex}}\langle g;{f}_{1},\dots ,g;{f}_{n}\rangle \phantom{\rule{-3.0pt}{0ex}}\rangle \phantom{\rule{0.166667em}{0ex}}.$$

#### 5.1.2. Categories Based on Finite Product Expressions

**Objects:**- As objects, we choose the same canonical finite sets of variables as for $\mathsf{L}\left(\mathsf{\Sigma}\right)$$${X}_{0}=\varnothing \phantom{\rule{1.em}{0ex}}\mathrm{and}\phantom{\rule{1.em}{0ex}}{X}_{n}:=\{{x}_{1}^{n},{x}_{2}^{n},\dots ,{x}_{n}^{n}\}\phantom{\rule{0.277778em}{0ex}}\mathrm{for\; all}\phantom{\rule{0.166667em}{0ex}}n\in \mathbb{N}\phantom{\rule{0.277778em}{0ex}}\mathrm{with}\phantom{\rule{0.277778em}{0ex}}n\ge 1\phantom{\rule{0.166667em}{0ex}}.$$
**Morphisms:**- Morphisms are all finite product expressions inductively defined as follows
**Symbolic Projections:**- $\u2e22{x}_{i}^{n}\u2e23:{X}_{n}\to {X}_{1}$ is an fp-expression for all $n\ge 1$, $1\le i\le n$.
**Constant and Operation Symbols:**- $\u2e22op\u2e23:{X}_{n}\to {X}_{1}$ with $n\in \mathbb{N}$ is an fp-expression if $\mathtt{op}$ is an n-ary operation symbol in $OP$.
**Empty Symbolic Tuples:**- $\u2e22\langle \rangle \u2e23:{X}_{n}\to {X}_{0}$ is an fp-expression for all $n\in \mathbb{N}$.
**Non-empty Symbolic Tuples:**- $\u2e22\langle e{x}_{1},\dots ,e{x}_{n}\rangle \u2e23:{X}_{m}\to {X}_{n}$ is an fp-expression for all $m\ge 0$, $n\ge 1$ and all families $\u2e22e{x}_{i}\u2e23:{X}_{m}\to {X}_{1}$, $1\le i\le n$ of fp-expressions.
**Symbolic Sequential Composition:**- $\u2e22e{x}_{1};e{x}_{2}\u2e22:{X}_{n}\to {X}_{m}$ is an fp-expression for all $n,k,m\in \mathbb{N}$ and all fp-expressions $\u2e22e{x}_{1}\u2e23:{X}_{n}\to {X}_{k}$, $\u2e22e{x}_{2}\u2e23:{X}_{k}\to {X}_{m}$.
**Symbolic Identities:**- $\u2e22\langle {x}_{1}^{n},\dots ,{x}_{n}^{n}\rangle \u2e23:{X}_{n}\to {X}_{n}$ is the identity on ${X}_{n}$ for all $n\ge 1$ and $\u2e22\langle \phantom{\rule{0.166667em}{0ex}}\rangle \u2e23:{X}_{0}\to {X}_{0}$ is the identity on ${X}_{0}$.

**Remark 5.1**

**.**Inspired by logic circuit diagrams, term graphs [20], and string diagrams [21], we will use informal computation diagrams to visualize the computations represented by fp-expressions. A computation diagram consists of “computation units”, “(data-flow) edges”, and input and output “ports”.

**Example 5.2**

**.**Let $\mathsf{\Sigma}$ be a signature with two binary operation symbols, “+” and “*”. Both fp-expressions $\u2e22+\u2e23:{X}_{2}\to {X}_{1}$ and $\u2e22\langle {x}_{1}^{2},{x}_{2}^{2}\rangle ;+\u2e23:{X}_{2}\to {X}_{1}$ are equivalent, according to the Equations (24)–(26), and represent simple “tree-like” computation diagrams as depicted below. The picture below also visualizes the effect of symbolic composition.

**Definition 5.1**

**.**For any set ${X}_{n}$, $n\in \mathbb{N}$, we inductively define for all $\mathsf{\Sigma}$-terms $t\in {T}_{\mathsf{\Sigma}}\left({X}_{n}\right)$ a corresponding finite product expression $pe\left(t\right):\phantom{\rule{0.166667em}{0ex}}{X}_{n}\to {X}_{1}$ as follows:

**Variables:**- $pe(\u2e22{x}_{i}^{n}\u2e23):=\u2e22{x}_{i}^{n}\u2e23$, for all$n\ge 1$, $1\le i\le n$.
**Constants:**- $pe(\u2e22\mathtt{c}\langle \rangle \u2e23):=\u2e22\langle \rangle ;\mathtt{c}\u2e23$, for all$\u2e22\mathtt{c}\langle \rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left({X}_{n}\right)$.
**Operations:**- $pe(\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23):=\u2e22\langle pe\left({t}_{1}\right),\dots ,pe\left({t}_{n}\right)\rangle ;\mathtt{op}\u2e23$, for all$\u2e22\mathtt{op}\langle {t}_{1},\dots ,{t}_{n}\rangle \u2e23\in {T}_{\mathsf{\Sigma}}\left({X}_{n}\right)$, $n\ge 1$.

**Example 5.3**

**.**From the five fp-expressions in Example 5.2, the two expressions $\u2e22\langle {x}_{1}^{2},{x}_{2}^{2}\rangle ;+\u2e23$ and $\u2e22\langle {x}_{1}^{1},{x}_{1}^{1}\rangle ;+\u2e23$ are fp-expressions in normal form, while $\u2e22\langle \langle {x}_{1}^{2},{x}_{2}^{2}\rangle ;+\rangle \u2e23$ is a symbolic tuple in normal form.

#### 5.1.3. Substitutions Revisited

This perception may open a path to develop, in the future, an appropriate substitution calculus for derived graph operations.substitution application ≅ symbolic composition plus normalization.

#### 5.2. Analysis of Finite Product Expressions

#### 5.2.1. Finite Products vs. Tensor Products

#### 5.2.2. Copying vs. Soldering

#### 5.3. Three Mechanisms to Construct New Graph Operations

#### 5.3.1. Parallel Composition

**Remark 5.2**

**.**In the case that all the arity spans $a{r}_{i}={\mathtt{I}}_{i}\stackrel{{l}_{i}}{\hookleftarrow}{\mathtt{B}}_{i}\stackrel{{r}_{i}}{\hookrightarrow}{\mathtt{O}}_{i}$ are canonical arity spans, in the sense of Remark 4.2, we can also construct the arity $ar=a{r}_{1}+\dots +a{r}_{k}=\mathtt{I}\stackrel{i}{\hookleftarrow}\mathtt{B}\stackrel{r}{\hookrightarrow}\mathtt{O}$ as a canonical arity span.

**Example 5.4**

**.**We consider a ${\mathsf{\Gamma}}_{cat}$-algebra $\mathcal{C}=(gr\left(\mathsf{C}\right),O{P}^{\mathcal{C}})$ given by a category $\mathsf{C}$ as described in Example 4.2. The upper part of Figure 14 is the same as the upper part of Figure 7 and shows the arity $ar\left(comp\right)+ar\left(comp\right)$ of the parallel composition ${\mathtt{comp}}^{\mathcal{C}}+{\mathtt{comp}}^{\mathcal{C}}$ of the composition operation in $\mathcal{C}$ with itself.

#### 5.3.2. Instantiation

**Remark 5.3**

**.**For a canonical arity span $\mathtt{I}$ and a canonical input arity graph ${\mathtt{I}}^{\prime}$, we have that ${\mathtt{I}}^{\prime}$ and $\mathtt{O}\setminus \mathtt{B}$ are disjoint. In such a way, we can simply define ${\mathtt{O}}_{V}^{\prime}={\mathtt{B}}_{V}^{\prime}\cup ({\mathtt{O}}_{V}\setminus {\mathtt{B}}_{V})$ and ${\mathtt{O}}_{E}^{\prime}={\mathtt{B}}_{E}^{\prime}\cup ({\mathtt{O}}_{E}\setminus {\mathtt{B}}_{E})$ such that ${\mathtt{I}}^{\prime}$ becomes a canonical arity span as well.

**Example 5.5**

**.**There are four different instances of the composition operation ${\mathtt{comp}}^{\mathcal{C}}$ in a ${\mathsf{\Gamma}}_{cat}$-algebra $\mathcal{C}=(gr\left(\mathsf{C}\right),O{P}^{\mathcal{C}})$ as described in Example 4.2.

**Example 5.6**

**.**The lower part of Figure 7 visualizes the arity of the instance $({\mathtt{comp}}^{\mathcal{C}}+{\mathtt{comp}}^{\mathcal{C}})/\phi $ of the parallel composition ${\mathtt{comp}}^{\mathcal{C}}+{\mathtt{comp}}^{\mathcal{C}}$ in Example 5.4. It shows that instantiation indeed provides the “soldering effect” we need to solve the problems with “tupling” as exemplified in Example 5.1! The output arity of the graph operation $({\mathtt{comp}}^{\mathcal{C}}+{\mathtt{comp}}^{\mathcal{C}})/\phi $ consists of two successive arrows; thus, we can indeed compose it with ${\mathtt{comp}}^{\mathcal{C}}$ (see Example 5.7).

**Remark 5.4**

**.**Note that $\phi $ is not required to be surjective! The items in ${\mathtt{I}}^{\prime}\setminus \phi \left(\mathtt{I}\right)$ have no influence on the output produced by $\omega /\phi $ and are ignored. Specifically, they do not appear in ${\mathtt{B}}^{\prime}=\phi \left(\mathtt{B}\right)$ and thus not in ${\mathtt{O}}^{\prime}$ either.

**Corollary 5.1**

**.**Let a graph $\mathtt{G}$ and a graph operation $\omega :\phantom{\rule{0.166667em}{0ex}}{\mathtt{G}}^{\mathtt{I}}\to {\mathtt{G}}^{\mathtt{O}}$ with a canonical arity span $\mathtt{I}$ be given. For any canonical input arity graphs ${\mathtt{I}}^{\prime}$, ${\mathtt{I}}^{\prime \prime}$ and any graph homomorphisms $\phi :\mathtt{I}\to {\mathtt{I}}^{\prime}$, $\psi :{\mathtt{I}}^{\prime}\to {\mathtt{I}}^{\prime \prime}$, we have

**Proof.**

**Hypothesis 5.1**

**.**It should not be a problem to prove a more general result about the interplay of parallel composition and instantiation.

#### 5.3.3. Sequential Composition

- For canonical arity spans $a{r}_{1}$ and $a{r}_{2}$, we can have an equality ${\mathtt{O}}_{1}={\mathtt{I}}_{2}$ only if ${\omega}_{1}$ is a built-in projection.
- There are two kinds of output items produced via the sequential composition of two graph operations. First, the output items produced by ${\omega}_{2}$. Second, the output items produced by ${\omega}_{1}$ and implicitly transferred by ${\omega}_{2}$, i.e., the items in ${\mathtt{B}}_{2}\setminus ({\mathtt{B}}_{1}\cap {\mathtt{B}}_{2})={\mathtt{B}}_{2}\setminus {\mathtt{B}}_{1}$. In other words, the resulting arity will not satisfy the disjointness condition in Definition 4.1 if ${\mathtt{B}}_{2}\setminus {\mathtt{B}}_{1}$ is non-empty!

- We obtain an epi-mono factorization of ${l}_{2};\varrho :{\mathtt{B}}_{2}\to {\mathtt{I}}_{2}$ by constructing the image of ${\mathtt{B}}_{2}$ with respect to $\varrho :{\mathtt{I}}_{2}\to {\mathtt{O}}_{1}$. The resulting restriction ${\varrho}_{\mathtt{B}}:{\mathtt{B}}_{2}\to \varrho \left({\mathtt{B}}_{2}\right)$ of $\varrho $ becomes an isomorphism since $\varrho $ is an isomorphism.
- The boundary arity of ${\omega}_{1}{;}^{\varrho}{\omega}_{2}$ can now be constructed by simple intersection (pullback): $\mathtt{B}:={\mathtt{B}}_{1}\cap \varrho \left({\mathtt{B}}_{2}\right)$ and $l:={l}_{2}^{\varrho};{l}_{1}$.
- To be able to define ${\mathtt{O}}_{2}^{\varrho}$ as an extension of $\mathtt{B}$ such that ${\mathtt{O}}_{2}^{\varrho}\setminus \mathtt{B}$ consists of canonical sets of output vertices and output edges, according to Remark 4.2, we first have to reindex the output vertices/edges in $\varrho \left({\mathtt{B}}_{2}\right)\setminus \mathtt{B}=\varrho \left({\mathtt{B}}_{2}\right)\setminus {\mathtt{B}}_{1}\subseteq {\mathtt{O}}_{1}\setminus {\mathtt{B}}_{1}$. We construct a graph ${\mathtt{B}}_{2}^{\varrho}$, isomorphic to $\varrho \left({\mathtt{B}}_{2}\right)$ with ${\left({\mathtt{B}}_{2}^{\varrho}\right)}_{V}={\mathtt{B}}_{V}\cup {\mathtt{P}}_{V}$ and ${\left({\mathtt{B}}_{2}^{\varrho}\right)}_{E}={\mathtt{B}}_{E}\cup {\mathtt{P}}_{E}$, where ${\mathtt{P}}_{V}=\{o{v}_{1},\dots ,o{v}_{{n}^{\mathtt{P}}}\}$ and ${\mathtt{P}}_{E}=\{o{e}_{1},\dots ,o{e}_{{m}^{\mathtt{P}}}\}$ for ${n}^{\mathtt{P}}=|{\left(\varrho \left({\mathtt{B}}_{2}\right)\right)}_{V}\setminus {\mathtt{B}}_{V}|$ and ${m}^{\mathtt{P}}=|{\left(\varrho \left({\mathtt{B}}_{2}\right)\right)}_{E}\setminus {\mathtt{B}}_{E}|$.
- We can define an isomorphism $\iota :\varrho \left({\mathtt{B}}_{2}\right)\to {\mathtt{B}}_{2}^{\varrho}$ that is the identity on $\mathtt{B}$ such that, in addition, ${\iota}_{V}$ restricted to ${\left(\varrho \left({\mathtt{B}}_{2}\right)\right)}_{V}\setminus {\mathtt{B}}_{V}$ is an order-preserving map from ${\left(\varrho \left({\mathtt{B}}_{2}\right)\right)}_{V}\setminus {\mathtt{B}}_{V}$ to ${\mathtt{P}}_{V}$ while ${\iota}_{E}$ restricted to ${\left(\varrho \left({\mathtt{B}}_{2}\right)\right)}_{E}\setminus {\mathtt{B}}_{E}$ is an order-preserving map from ${\left(\varrho \left({\mathtt{B}}_{2}\right)\right)}_{E}\setminus {\mathtt{B}}_{E}$ to ${\mathtt{P}}_{E}$. The construction ensures that ${r}_{1}^{\ast};\iota $ becomes an inclusion graph homomorphism ${r}_{1}^{\ast};\iota :\mathtt{B}\to {\mathtt{B}}_{2}^{\varrho}$.
- We construct ${\mathtt{O}}_{2}^{\varrho}$ via a pushout of the span ${\mathtt{O}}_{2}\stackrel{{\varrho}_{\mathtt{B}}^{-1};{}_{}}{\leftarrow}$