Contents

The Network Satisfaction Problem for Relation Algebras with at most 4 Atoms

The project

Showcase

All papers

Manuel Bodirsky, Moritz Jahn, Simon Knäuer, Matěj Konečný and Paul Winkler

ICALP 2026 (LIPIcs, vol. 374)DOI 10.4230/LIPIcs.ICALP.2026.168Theoretical computer science: Automata, logic, semantics and theory of programming

  • article
  • pdfpages
  • dirtytalk
  • faktor
  • aligned-overset

CC BY-SA 4.0, published at drops.dagstuhl.de. “The Network Satisfaction Problem for Relation Algebras with at most 4 Atoms” by Manuel Bodirsky, Moritz Jahn, Simon Knäuer, Matěj Konečný, Paul Winkler, arXiv:2507.09324v2 (published in ICALP 2026, LIPIcs vol. 374, 10.4230/LIPIcs.ICALP.2026.168). Licensed under CC BY-SA 4.0. Typeset here by reflowtex from the authors' source.

The Network Satisfaction Problem for Relation Algebras with at most 4 Atoms

Manuel Bodirsky∗ , Moritz Jahn, Simon Knäuer, Matěj Konečný, Paul Winkler

28.10.2026

Abstract

Andréka and Maddux classified the relation algebras with at most 3 atoms, and in particular they showed that all of them are representable [AM94]. Hirsch and Cristiani showed that the network satisfaction problem (NSP) for each of these algebras is in P or NP-hard [CH04]. The literature contains many results on representations of relation algebras; in particular, some relation algebras with four atoms are not representable. We extend the result of Cristiani and Hirsch to relation algebras with at most 4 atoms: the NSP is always either in P or NP-hard. To this end, we construct universal, fully universal, or even normal representations for these algebras, whenever possible.

Contents

1 Introduction

1.1 Network Satisfaction Problems and CSP Complexity

1.2 Contributions

1.3 Significance for Constraint Satisfaction

2 Preliminaries

2.1 Structures

2.2 Constraint Satisfaction Problems and Universal Algebra

2.3 Relation Algebras

2.4 Representations

2.5 Networks

2.6 Normal Representations

2.7 Fully Universal Representations

2.8 The 2-Cycle Product

3 The Network Satisfaction Problem

3.1 The Network Consistency Problem

3.2 The Path Consistency Algorithm

3.3 Network Satisfaction Problems and CSPs

4 Representations for Algebras with at most 4 Atoms

4.1 Reduction to the Integral Case

4.2 Without Representation

4.3 Normal Representations

4.4 2-Cycle Product

4.5 Fully Universal Representations

4.6 Bounded Square Representations

4.7 Representable Algebras without Fully Universal Representation

5 NP-hard Algebras with at most 4 Atoms

5.1 Hardness for Bounded Square Representations

5.2 Symmetric Algebras with a Flexible Atom

5.3 Finitely Many Equivalence Classes

5.4 No Non-trivial Equivalence Relation

5.5 Hardness for 2-Cycle Products

5.6 Hardness via Primitive Positive Constructions

5.7 Hardness via Gadget Reductions

5.8 Hardness from Promise Constraint Satisfaction Problems

6 Tractable Algebras with at most 4 Atoms

6.1 Tractability from the Atom Structure

6.2 Tractability via Path Consistency

6.3 Divide and Conquer Algorithms

7 Open Problems

8 Summary and Tables

1 Introduction

Relation algebras are algebraic structures that can be used to abstractly reason about binary relations. They are certain expansions of Boolean algebras; besides the operations for union, intersection, and complement of binary relations, we also have a binary operation ◦ for composition of relations, and a unary operation ˘ for reversing the arguments of a binary relation. These operations need to satisfy certain natural identities; e.g., we require that (a ◦ b) ˘ = ˘b ◦ ˘a holds for all elements a and b of the relation algebra.

Similarly to the fundamental facts that every group is isomorphic to a permutation group, and every Boolean algebra is isomorphic to an algebra of sets, the initial hope was that every relation algebra has a representation, which consists of a set of binary relations on some set that behave as prescribed by the relation algebra [Tar41].

Example 1.1. We first look at a concrete structure from which a small relation algebra can be obtained. Consider the structure (Q; <), where Q is the set of rational numbers and < is the usual strict linear order on Q. For any two rational numbers x, y, exactly one of the following holds: x < y, x = y, or x > y. Thus, the relations <, =, and > form a partition of Q2. Moreover, ˘< = >, where ˘ denotes the usual converse operation on binary relations, defined by ˘R = {(y, x) | (x, y) ∈ R}.

This partition gives rise to a relation algebra A with three atoms, denoted by r, Id, and ˘r. Its domain A consists of all formal unions of these atoms, i.e., A = {0, r, ˘r, Id, r ∪ Id, ˘r ∪ Id, r ∪ ˘r, r ∪ ˘r ∪ Id}. The other Boolean operations are defined in the usual way.

Let ◦ denote the usual composition of binary relations, i.e.,

R ◦ S = {(x, z) | ∃y : (x, y) ∈ R and (y, z) ∈ S}.

In (Q; <), for example, we have < ◦ < = < and < ◦ > = (< ∪ > ∪ =). Accordingly, A has a binary operation, also denoted by ◦, satisfying, for example, r ◦ r = r and r ◦ ˘r = (r ∪ ˘r ∪ Id).

Note that A is a Boolean algebra with 8 elements, together with a binary operation ◦ and a unary operation ˘ . Instead of obtaining A from concrete relations on Q, one may also start with the abstract algebra A and ask whether it has a ‘representation’, similarly as above. Formally, we ask whether there exists a set D and an injective homomorphism h : A → P(D2) preserving the Boolean operations, converse, and composition. In particular, distinct atoms are mapped to disjoint binary relations, while formal unions such as r ∪ Id are mapped to the corresponding unions. In the present example, the ordered set (Q; <) provides such a representation: take D = Q and map r, Id, and ˘r to the relations <, =, and >, respectively. The value of h on all other elements of A is then determined by preservation of the Boolean operations; for example, h(r ∪ Id) = h(r) ∪ h(Id) = (< ∪ =).

Indeed, all relation algebras with at most 23 = 8 elements have a representation [AM94]. However, Lyndon [Lyn50] found a relation algebra with 256 elements which is not representable. Monk [Mon64] showed that this problem has no simple fix, because he proved that the class of representable relation algebras cannot be axiomatized by a finite set of identities, and not even by a finite set of first-order sentences, answering a question of Tarski. However, it follows from results of Tarski [Tar55] that there is an infinite set of identities that axiomatizes the representable relation algebras. We mention that (integral) relation algebras have also been discovered and studied with a different formalism and under the different name of hypergroups [Zie23] (also called polygroups [Com83c]).

1.1 Network Satisfaction Problems and CSP Complexity

Starting in the 90s, another generation of researchers investigated relation algebras motivated by applications in theoretical computer science, particularly for the theory of constraint satisfaction. In a constraint satisfaction problem, we are given a finite set of variables and a finite set of constraints, and the task is to determine whether there exists an assignment to the variables that satisfies all the constraints. Constraint satisfaction problems have been studied intensively if the variables take values from a fixed finite domain. Relation algebras allow us to formalize interesting constraint satisfaction problems where the variables may take values from an infinite domain.

Concretely, to every finite relation algebra A, we may associate the so-called network satisfaction problem, which is a computational problem where the input consists of a ‘constraint network’, i.e., a finite set of nodes V and a function labeling pairs of nodes with elements from the relation algebra, and the task is to decide whether there exists a representation of A where this network is satisfiable. Under certain representability conditions, e.g., if A has a square representation ([Bod21, Section1.5]; definitions may be found in Section 2), the network satisfaction problem for A is a constraint satisfaction problem as described above, but not necessarily for values from a finite set (the values rather come from the elements of the representation, which might be infinite). If there is a fully universal representation, then the network satisfaction problem is in NP. However, the complexity sometimes even drops to P (polynomial time). The computational complexity of the NSP has been shown to be NPc (NP-complete) or P for all relation algebras with at most 8 = 23 elements (called ‘small relation algebras’) by Cristiani and Hirsch [CH04].

Example 1.2. Let A be the relation algebra from Example 1.1. An A-network consists of finitely many nodes and a function f : V2 → A mapping each ordered pair to some element of the relation algebra. Under the representation over (Q; <), the label f(x, y) specifies the allowed relative position of the values assigned to x and y.

For instance, consider a network with nodes x, y, z and function f such that f(x, y) = r, f(y, z) = r ∪ Id, and f(z, x) = ˘r ∪ Id, and such that all other pairs are labeled by r ∪ ˘r ∪ Id. Under the representation over (Q; <), these constraints mean x < y, y ≤ z, and z ≥ x, respectively. This network is satisfiable, for example by assigning x = 0, y = 1, and z = 2.

On the other hand, if f(x, y) = r, f(y, z) = r, and f(z, x) = r, then the network is not satisfiable in this representation, since it would require x < y < z < x.

In fact, the representation over (Q; <) is normal, in particular fully universal; see Section 2 for the definitions. The fact that the representation is fully universal implies that the network satisfaction problem for A amounts to deciding whether a finite system of constraints over the signature {∅, <, ≤, >, ≥, =, =, Q2} can be satisfied over the rational numbers.

Hirsch [Hir96] asked whether the computational complexity of the network satisfaction problem can be classified for all finite relation algebras. Bodirsky and Knäuer [BK23] proved that the problem of deciding whether a given finite relation algebra has an NSP which is in P is undecidable, which can be interpreted as a negative answer to Hirsch’s question. The proof of the undecidability result relies on two earlier results, namely that there are finite relation algebras whose NSP is undecidable [Hir99], and that the question whether a finite relation algebra has a representation is undecidable [HH01]. The classification for relation algebras with a fully universal representation, however, remains wide open.

A particularly interesting subclass are the relation algebras that have a normal representation, i.e., a representation which is fully universal, square, and homogeneous [Hir96]. While this combination of assumptions still captures a rich class of relation algebras (including standard structures like Q, the random graph, the Henson graph, and the random tournament), it has a wide range of strong and useful consequences, as we will see below. A relational structure is homogeneous if every isomorphism between finite substructures can be extended to an automorphism of the structure. If a relation algebra A has a normal representation, then A has a countable normal representation B, and this representation is unique up to isomorphism. Moreover, one can express important properties of the automorphism group of B using A, and conversely, properties of A are reflected in this group. It is known that the question whether a given finite relation algebra has a normal representation is decidable [Bod18].

The NSPs for relation algebras with a normal representation fall into the scope of the so-called Bodirsky-Pinsker tractability conjecture in constraint satisfaction, namely the conjecture that CSPs of reducts of finitely bounded homogeneous structures are in P or NP-complete [BPP21]. Specifically, the conjecture states that the subclasses of NP that properly lie between P and NP and were constructed by Ladner [Lad75] (conditionally on P = NP) do not show up when classifying such NSPs. Such a dichotomy statement has been established for CSPs of finite structures [Zhu20] (announced independently by Bulatov [Bul17] and by Zhuk [Zhu17]). One of the motivations for the more general conjecture from [BPP21] is that many of the universal-algebraic methods used by both Bulatov and Zhuk can be applied for the more general class. And indeed, there exists a universal-algebraic condition which is a candidate for separating polynomial-time tractable from NP-complete CSPs for reducts of finitely bounded homogeneous structures, and this condition has numerous equivalent characterisations [BPP21, BOP18, BKO+17, BP16, Bod21]. If this condition applies, the CSP is provably NP-hard; if not, then the conjecture states that the CSP is in P. In our case, the tractability conjecture can be formulated as follows (for the definition of pp-constructability, see Section 2). Let NAE := {0, 1}3 \ {(0, 0, 0), (1, 1, 1)} be the ternary Boolean not-all-equal relation.

Conjecture 1.3. Let B be a normal representation of a finite relation algebra A. If B does not pp-construct ({0, 1}; NAE), then CSP(B) and NSP(A) are in P.1

1In the case where B is a normal representation of A, CSP(B) and NSP(A) are the same computational problem up to the translation between A-networks and A-structures.

We mention that the scope of the Bodirsky-Pinsker conjecture for relation algebras is larger than just the relation algebras with a normal representation: e.g., if a relation algebra has a representation which is homogenizable in the sense that we can add finitely many first-order definable relations to make it homogeneous, then its NSP is covered as well.

Homogeneous structures are also of central interest in model theory; via Fraïssé’s theorem, they are particularly easy to construct and provide a rich source of examples and counterexamples. It is conceivable that the class of homogeneous structures with a finite relational signature can be classified in some sense. There are uncountably many [Hen72], but the uncountable families usually have a particularly simple shape [Che98]. One of the approaches here is to fix some (typically binary) relational signature (e.g., focusing on graphs [LW80], digraphs [Che98], permutations [Cam96], metric spaces [Che20], etc.) and to then classify the homogeneous structures with this signature. One of the motivations for this research program is its success story of producing beautiful and interesting mathematical structures that have inspired research in the areas mentioned above. Systematically listing finite relation algebras and then testing for the existence of a normal representation is another approach that can produce interesting new examples of homogeneous (or homogeneizable) structures.

There are potentially further well-behaved subclasses of representable relation algebras beyond those admitting homogenizable or even normal representations. To identify such classes, it is natural to consider families of relation algebras that are both sufficiently representative and sufficiently small to allow for a detailed analysis. Restricting the number of atoms provides such a family.

1.2 Contributions

We extend the mentioned result of Hirsch and Cristiani on small relation algebras, and systematically study all relation algebras with at most 16 = 24 elements. An exhaustive list of the building blocks for such relation algebras has been computed by Maddux [Mad06b], confirming results of Comer [Com83c], namely a list for the integral symmetric relation algebras with four atoms (numbered 165–6565 by Maddux) and a list for the integral relation algebras with an asymmetric atom among its four atoms (numbered 137–3737 by Maddux).

We prove that the NSPs for these not so small relation algebras are in P or NP-hard. In the case where the algebra has a normal representation, our results confirm the mentioned tractability conjecture from [BPP21]. More formally, we obtain the following results.

Theorem 1.4. Let A be a finite relation algebra with at most four atoms. Then NSP(A) is in P or NP-hard.

Theorem 1.5. Let B be a normal representation of a finite relation algebra A with at most four atoms. If B does not pp-construct ({0, 1}; NAE), then CSP(B) and NSP(A) are in P.

For all but one of these algebras we also prove the containment of the NSP in NP; the one exceptional case is 5665. Actually, its NSP is also contained in NP, but the proof requires substantially different techniques and was published separately (see [BGPJ+25]).

In addition to our classification of NSP complexity, we revisit representability for all finite relation algebras with at most 4 atoms. Several of the algebras in the list do not have a representation (in which case the NSP is trivial and in P). We determine for each of the representable algebras A whether A has a normal representation, and if not, whether at least it has a fully universal (or even fully universal square) representation. This result is of independent interest in the theory of relation algebras; representations for all relation algebras with at most 3 atoms have been found in 1994 [AM94]. For this purpose, we present a combinatorial characterization for the existence of a fully universal square representation.

We think of this paper as exploratory work towards more general classifications of the complexity of NSPs, or representability questions, of suitable subclasses of relation algebras. Maddux’s list of relation algebras with at most four atoms is at the same time rich enough to display diverse behaviour, while remaining small enough for detailed analysis, including computer-assisted inspection.

We verified that in many cases, the existing methods apply (e.g. [BK23, BK22, BK20]). At the same time, we also needed to develop new methods (such as proving NP-hardness of the NSPs by reductions from the approximate graph coloring problem CSP(K3, K5) [BKO19]; a so-called promise constraint satisfaction problem, see Section 5.8), as well as several ad hoc arguments for concrete cases. Several of these deserve explicit mention.

• 2465 (Section 6.3.1); this algebra is related to the class of 3-edge-coloured cliques with no rainbow triangle, which exhibits some nice combinatorics, and has a fully universal representation. Our structural insights are then the basis for a polynomial-time algorithm for its NSP.

• 1737 (Sections 4.7.1 and 6.3.2); this algebra is related to the class of quasi-transitive oriented graphs, which has been studied in graph theory [BJH95]. There is no fully universal representation and we identify an atomic network with 4 vertices which is consistent but unsatisfiable. By working with the class of consistent atomic networks that exclude this 4-element network, we can construct a universal representation for 1737. Our structural insights are then also useful for the polynomial-time algorithm for the NSP of 1737 mentioned above.

• 5165 (Section 4.7.2); this algebra contains exactly one non-trivial equivalence relation, and in every representation, the equivalence relation can have at most 3 classes. Our representability results for this algebra follow a similar pattern as our results for 1737: while there is no fully universal representation, we can identify four atomic networks that are consistent but unsatisfiable. Excluding those, we can construct a universal representation; it follows that the NSP is in NP, and in fact it is NP-complete (Section 5.8).

• 5665 (Section 4.7.3); this relation algebra is similar to the previous one, but allows one extra triple compared to 5165. It has a representation, but not a fully universal one. Its NSP is NP-hard (Section 5.8).

There are already several thousand relation algebras with five atoms [Mad06b], making a direct extension of the present classification substantially more challenging. The four-atom examples are expected to correspond to large subclasses of the five-atom list, and analysing these subclasses will help to identify useful generalisations, by methods developed in this article; see Section 5.5.

1.3 Significance for Constraint Satisfaction

We believe that network satisfaction problems for relation algebras with a normal representation are an important class to test the mentioned tractability conjecture. The reason is that this approach can lead to CSPs with different behaviour, challenging the current methods. Previously, the Bodirsky–Pinsker conjecture has mainly been tested on structures obtained as follows: fix a homogeneous finitely bounded ‘base’ structure of fundamental interest (such as (Q; <) or the Rado graph), and study the CSP of all first-order reducts of it (see, e.g., [BK09, BP15a]). The advantage of this approach is that the model-theoretic properties of the entire class of structures obtained like this are inherited from the base structure, and the remaining task is mostly universal-algebraic. This advantage is at the same time a disadvantage, because by fixing a base structure we might overlook some phenomena that only appear for other base structures. The approach of the present article avoids this; and indeed, our study shows that new structures with different behaviour and interesting polynomial-time CSPs may show up.

2 Preliminaries

In this section we present the background from the theory of relation algebras that we need to state our results. Then we introduce some concepts and results from model theory and universal algebra that we need to prove our results.

Let N = {0, 1, . . . } denote the natural numbers and N+ = N \ {0} the positive integers.

2.1 Structures

A signature τ is a (possibly infinite) set of function and relation symbols; each symbol has an arity k ∈ N. A function symbol f ∈ τ of arity 0 is called a constant.

Definition 2.1. A τ-structure A is a set A (the domain of A)2 together with

2In this article it will be convenient and without harm to allow the empty set.

• a relation RA ⊆ Ak for every relation symbol R ∈ τ with arity k, and

• a function fA : Ak → A for every function symbol f ∈ τ with arity k.

If the signature τ only contains function symbols, then a τ-structure is called an algebra. If τ is just made up of relation symbols, then a τ-structure is called a relational structure. We will use A, B, . . . to denote algebras, and A, B, . . . to denote relational structures, and structures in general. If not stated otherwise, the underlying domains are A, B, . . . respectively. If the structure A is clear from the context, we will disregard the superscript and just write f for the function fA and R for the relation RA.

Definition 2.2. A τ-structure A is a substructure of a τ-structure B if A ⊆ B and

• for every R ∈ τ of arity k and a ∈ Ak: a ∈ RA if and only if a ∈ RB, and

• for every f ∈ τ of arity k and a ∈ Ak: fA(a) = fB(a).

The (inclusion-wise) smallest substructure of B that contains S ⊆ B is called the substructure of B generated by S.

Definition 2.3. Let A and B be τ-structures. The (direct) product C = A × B is the τ-structure where

• A × B is the domain of C,

• for every relation symbol R of arity n ∈ N and every tuple ((a1, b1), . . . , (an, bn)) ∈ (A × B)n, we have that ((a1, b1), . . . , (an, bn)) ∈ RC if and only if (a1, . . . , an) ∈ RA and (b1, . . . , bn) ∈ RB, and

• for every function symbol f of arity n ∈ N and every tuple ((a1, b1), . . . , (an, bn)) ∈ (A × B)n, we have that

fC((a1, b1), . . . , (an, bn)) := (fA(a1, . . . , an), fB(b1, . . . , bn)).

We write A2 for A × A and inductively define Ak+1 := A × Ak for k ≥ 2.

Definition 2.4. Let A and B be τ-structures. A homomorphism from A to B is a mapping ϕ : A → B such that for all a1, . . . , ak ∈ A and

• for every R ∈ τ with arity k: if (a1, . . . , ak) ∈ RA then (ϕ(a1), . . . , ϕ(ak)) ∈ RB and

• for every f ∈ τ with arity k: ϕ(fA(a1, . . . , ak)) = fB(ϕ(a1), . . . , ϕ(ak)).

Two structures A and B are called homomorphically equivalent if there is a homomorphism ϕ from A to B and from B to A. If ϕ is bijective and ϕ−1 is a homomorphism from B to A, then ϕ is called an isomorphism. In this case we say that A and B are isomorphic (A ∼ = B). The age of a relational structure B is the class of all finite structures A that are isomorphic to a substructure of B.

An isomorphism from A to A is called an automorphism. A relational τ-structure A is homogeneous, if for every isomorphism between finite substructures of A there exists an automorphism of A that extends this isomorphism. Homogeneous structures with a finite relational signature are ω-categorical (see, e.g., [Hod97]), i.e., all countable models of the first-order theory of the structure are isomorphic.

If R1, R2 ⊆ B2 are two binary relations, then R1 ◦ R2 denotes the composition

R1 ◦ R2 := {(x, z) ∈ B2 | there exists y ∈ B with (x, y) ∈ R1 and (y, z) ∈ R2}.

2.2 Constraint Satisfaction Problems and Universal Algebra

In this section, we introduce several basic concepts from universal algebra which we will later need for analysing the computational complexity of network satisfaction problems.

Let B be a structure with a finite relational signature τ. Then the constraint satisfaction problem CSP(B) is the problem of deciding for a given finite τ-structure A whether there exists a homomorphism to B. Note that a class of finite τ-structures is of the form CSP(B) if and only if it is closed under disjoint unions and its complement is closed under homomorphisms.

Example 2.5. Let NAE be the Boolean relation {0, 1}3 \ {(0, 0, 0), (1, 1, 1)}. Then CSP({0, 1}; NAE) is the positive not-all-equal 3-SAT problem and NP-complete [GJ78].

We work with classical first-order logic, using ⊤, ⊥, the Boolean operations ∧, ∨, →, and ¬, the quantifiers ∀, ∃, and equality. A formula is called primitive positive (shortly pp) if it is of the form

∃x1 · · · ∃xk(ψ1 ∧ · · · ∧ ψn),

where each ψi is atomic, i.e., of the form ⊤, ⊥, x = y, or R(xi1, . . . , xil) for some l-ary relation R in the signature.

Definition 2.6. Let A and B be structures with the relational signatures τ and σ, respectively. A primitive positive interpretation of dimension d of A in B is a partial surjection h : dom(h) ⊆ Bd → A (called the coordinate map) such that for every relation R, say of arity k, which can be defined by an atomic formula over A, the (k · d)-ary relation

h−1(R) := {(b11, . . . , b1d, . . . , bk1, . . . , bkd) ∈ Bk·d | (h(b11, . . . , b1d), . . . , h(bk1, . . . , bkd)) ∈ RA}

can be defined in B by a primitive positive formula ϕR. Since equality and ⊤ are always allowed as atomic formulas, there must in particular exist

• a σ-formula ϕ⊤ (called the domain formula) such that ϕ⊤(b1, . . . , bd) holds if and only if (b1, . . . , bd) is in the domain of h;

• a σ-formula ϕ= such that ϕ=(b1, . . . , bd, c1, . . . , cd) holds if and only if h(b1, . . . , bd) = h(c1, . . . , cd).

In this case we also say that B pp-interprets A. We say that B pp-constructs A if B pp-interprets a structure that is homomorphically equivalent to A.

The following is well-known.

Proposition 2.7 (see, e.g., [Bod21, Theorem 3.1.4]). If B pp-constructs A, then CSP(A) is log-space reducible to CSP(B). In particular, if B pp-constructs ({0, 1}; NAE), then CSP(B) is NP-hard.

An important tool to study primitive positive definability in finite and ω-categorical structures is the concept of a polymorphism.

Definition 2.8. Let τ be finite. A polymorphism of a τ-structure B is a homomorphism f from Bk to B. We write Pol(B) for the set of all polymorphisms of B.

Definition 2.9. Let B be a relational τ-structure. An operation f : Bn → B is called conservative if for all x1, . . . , xn ∈ B it holds that f(x1, . . . , xn) ∈ {x1, . . . , xn}. The set Pol(B) is conservative if every f ∈ Pol(B) is conservative. In this case, B is called conservative as well.

We will use the following important types of operations.

Definition 2.10. An operation f : Bk → B is called

• a binary symmetric operation if k = 2 and f(x, y) = f(y, x) for all x, y ∈ B;

• a majority operation if k = 3 and for all x, y ∈ B

f(x, x, y) = f(x, y, x) = f(y, x, x) = x;

• a minority operation if k = 3 and for all x, y ∈ B

f(x, x, y) = f(x, y, x) = f(y, x, x) = y;

• a weak near unanimity (WNU) operation if k ≥ 2 and for all x, y ∈ B

f(y, x, . . . , x) = f(x, y, x, . . . , x) = · · · = f(x, . . . , x, y).

The complexity of the CSP for finite conservative structures has been classified by Bulatov [Bul03] long before the resolution of the finite domain CSP dichotomy conjecture.

Theorem 2.11 (Bulatov [Bul03]). Let B be a finite conservative structure with a finite relational signature. If for every a, b ∈ B there exists a polymorphism f ∈ Pol(B) such that the restriction of f to {a, b} is a binary symmetric, a majority, or a minority operation, then CSP(B) is in P. Otherwise, ({0, 1}; NAE) has a pp-interpretation in B, and CSP(B) is NPc.

Definition 2.12 (see, e.g., [Bod21, Section 6.1]). Let S be an arbitrary set. An (operation) clone (over S) is a subset C of i∈N SSi, i.e., of functions from finite powers of S to S, satisfying the following two properties:

• C contains all projections, i.e., for all i, k ∈ N with 1 ≤ i ≤ k, the operation π(i, k) : Sk → S defined by π(i, k)(x1, . . . , xk) = xi is contained in C.

• C is closed under composition, i.e., for every n-ary operation f ∈ C and all m-ary functions g1, . . . , gn ∈ C, the operation f(g1, . . . , gn) defined by

f(g1, . . . , gn)(x1, . . . , xm) = f(g1(x1, . . . , xm), . . . , gn(x1, . . . , xn))

is contained in C.

Note that for every relational structure B, the set Pol(B) is a clone. Moreover, the set of projections on an arbitrary set S is a clone.

We give modern formulations of the following two classical results:

Theorem 2.13 (Post [Pos41]). Let C be a clone over a two-element set {a, b}. Then one of the following holds:

• C contains a binary symmetric, the ternary majority, the ternary minority operation, or the unary function f defined by f(a) = b and f(b) = a.

• C contains only the projections.

Theorem 2.14 (Schaefer [Sch78]). Let B be a structure over a two-element domain. Then one of the following holds:

• Pol(B) contains a binary symmetric, the ternary majority, or the ternary minority operation, and CSP(B) is contained in P.

• B pp-interprets ({0, 1}; NAE); in this case, CSP(B) is NP-hard.

Sometimes, it will be convenient to prove the existence of pp-interpretations algebraically; we then need the following definitions and Theorem 2.17.

Definition 2.15 (see, e.g., [Bod21, Definition 6.5.3.]). Let C and D be clones. A function ξ : C → D is called a clone homomorphism if

• ξ preserves arities, i.e., for every n-ary function f ∈ C, the function ξ(f) is also n-ary;

• ξ preserves the projections, i.e., ξ(π(i, k)C) = π(i, k)D for all k ∈ N and all i ∈ {1, . . . , k};

• for every n-ary function f ∈ C and all m-ary functions g1, . . . , gn ∈ D,

ξ(f(g1, . . . , gn)) = ξ(f)(ξ(g1), . . . , ξ(gn)).

Definition 2.16 (see, e.g., [Bod21, Section 9.5.1]). Let C1 and C2 be clones over countable sets C1 and C2. A function ξ : C1 → C2 is called uniformly continuous if for every finite G ⊆ C2 there is a finite set F ⊆ C1 such that for every k ∈ N and all operations f, g ∈ C1 with equal arity, f|Fk = g|Fk implies ξ(f)|Gk = ξ(g)|Gk.

Theorem 2.17 ([BP15b, Theorem 28]; see also [Bod21, Corollary 9.5.21]). Let B be a countable ω-categorical structure. Then the following are equivalent:

• There is a uniformly continuous clone homomorphism from Pol(B) to the clone of projections on a two-element set.

• B pp-interprets ({0, 1}; NAE); in this case, CSP(B) is NP-hard.

2.3 Relation Algebras

Definition 2.18. A relation algebra is an algebra A with domain A and signature {∪, ¯, 0, 1, Id, ˘, ◦} such that

1. the structure (A; ∪, ∩, ¯, 0, 1), with ∩ defined by x ∩ y := (¯x ∪ ¯y), is a Boolean algebra;

2. ◦ is an associative binary operation on A, called composition;

3. for all a, b, c ∈ A: (a ∪ b) ◦ c = (a ◦ c) ∪ (b ◦ c);

4. for all a ∈ A: a ◦ Id = a;

5. for all a ∈ A: ˘˘a = a;

6. for all a, b ∈ A: (a ∪ b)˘ = ˘a ∪ ˘b;

7. for all a, b ∈ A: (a ◦ b)˘ = ˘b ◦ ˘a;

8. for all a, b ∈ A: ¯b ∪ ˘a ◦ (a ◦ b) = ¯b.

Remark 2.19. It is easy to see that the axioms in Definition 2.18 imply ˘0 = 0, ˘Id = Id, Id ◦ a = a, c ◦ (a ∪ b) = (c ◦ a) ∪ (c ◦ b) for all a, b, c ∈ A and similar statements, which we will freely use in the following. Formal proofs can be found in [Mad06b, Chapter 6].

We denote the class of all relation algebras by RA. Since all the given axioms are universal, RA is closed under the formation of direct products (Definition 2.3). A relation algebra is called trivial if 0 = 1.

If A is a relation algebra with elements a and b, then we write a ≤ b if a ∩ b = a holds in A. Clearly, ≤ defines a partial order on A. An element b ∈ A \ {0A} is called an atom if there is no element a ∈ A \ {0A, b} with a ≤ b. The set of all atoms is denoted by A0. If a ∈ A0 satisfies a ≤ Id, it is called an identity atom and otherwise a diversity atom. We also write a2 for a ◦ a.

An element a ∈ A is called

• symmetric if ˘a = a;

• transitive if a2 ≤ a;

• reflexive if Id ≤ a;

• an equivalence relation if a is reflexive, symmetric and transitive.

A relation algebra A is called

• symmetric if all a ∈ A are symmetric;

• integral if 0 = 1 and x ◦ y = 0 implies x = 0 or y = 0 (see [Mad06a]);

• simple if 1 ◦ x ◦ 1 = 1 for all x = 0.

Remark 2.20. We mention that a relation algebra is simple in the sense given above if and only if it is simple in the sense of universal algebra (see, e.g., [BS81]); moreover, a relation algebra is simple if and only if it is not the direct product of two non-trivial relation algebras [JT52, Theorem 4.14].

Example 2.21. There is an up to isomorphism unique relation algebra with the elements {0, 1} (with Id = 1). This algebra is called 11 in [Mad06b]. Then (11)2 has two atoms and is the smallest non-simple relation algebra.

Every integral relation algebra is simple [JT52, Theorem 4.18(ii)]. The converse is not true as shown in Example 2.22. In fact, a simple relation algebra is integral if and only if Id is an atom [Mad06a, Theorem 353].

Example 2.22. The following relation algebra with four atoms is simple but not integral. It has atoms a, b, c, d, where a and b are identity atoms, and is uniquely given by requiring ˘c = d and the multiplication table given in Figure 1. We will later see that this is the only non-integral simple relation algebra with at most four atoms (Lemma 4.1).

◦ a b c ˘c a a 0 0 ˘c b 0 b c 0 c c 0 0 b ˘c 0 ˘c a 0

Figure 1: Multiplication table of the simple non-integral relation algebra from Example 2.22.

For a finite relation algebra A, the operation ◦ is completely determined by its restriction to the atoms. A tuple (x, y, z) ∈ (A0)3 is called an allowed triple if z ≤ x ◦ y. Otherwise, (x, y, z) is called a forbidden triple. We denote by

Cy(A) := {(x, y, z) ∈ A0 | z ≤ x ◦ y}

the set of all allowed triples. The following proposition shows that even less information is needed.

Proposition 2.23 (cycle law; [Mad06b, Theorem 294]). Let A be a relation algebra. For x, y, z ∈ A it holds that

z ≤ x ◦ y ⇐⇒ y ≤ ˘x ◦ z ⇐⇒ x ≤ z ◦ ˘y ⇐⇒ ˘y ≤ ˘z ◦ x ⇐⇒ ˘x ≤ y ◦ ˘z ⇐⇒ ˘z ≤ ˘y ◦ ˘x.

Moreover, for x, y, z ∈ A0 and

[x, y, z] := {(x, y, z), (˘x, z, y), (z, ˘y, x), (˘z, x, ˘y), (y, ˘z, ˘x), (˘y, ˘x, ˘z)},

either [x, y, z] ∩ Cy(A) = ∅ or [x, y, z] ⊆ Cy(A).

2.4 Representations

Definition 2.24. Let A = (A; ∪, ¯, 0, 1, Id, ˘, ◦) be a relation algebra. A structure B with signature A is called a representation of A if

1. 0B = ∅;

2. 1B = a∈A aB;

3. IdB = {(u, u) | u ∈ B};

4. for all a ∈ A we have (a)B = 1B \ aB;

5. for all a ∈ A we have (˘a)B = {(u, v) | (v, u) ∈ aB};

6. for all a, b ∈ A we have aB ∪ bB = (a ∪ b)B;

7. for all a, b ∈ A we have aB ◦ bB = (a ◦ b)B.

Relation algebras that have a representation are called representable.

Note that when constructing a representation of A, it is enough to describe how the atoms of A are interpreted in B, the other relations are then uniquely determined.

Example 2.25. Trivial relation algebras can be represented by structures with an empty domain. The relation algebra from Example 2.21 has a representation by a structure with one element.

Lemma 2.26 (see, e.g., [BK23]). Let B1 be a representation of A1 and B2 a representation of A2, and suppose that A1 ∩ A2 = ∅ and B1 ∩ B2 = ∅. Then A1 × A2 has a union representation, which is the (A1 × A2)-structure B1 ⊎ B2 with domain B1 ∪ B2 defined by (a1, a2)B1⊎B2 := aB11 ∪ aB22.

This lemma also has a converse.

Lemma 2.27 (see, e.g., [BK23]). If B is a representation of A1 × A2, then there exist a representation B1 of A1 and a representation B2 of A2 such that B is isomorphic to B1 ⊎ B2.

It is known that the question whether a given finite relation algebra is representable is undecidable [HH01]. A representation B is called square if 1B = B2.

Example 2.28. The non-integral relation algebra from Example 2.22 has a square representation B with the domain {0, 1} which is given by aB = {(0, 0)}, bB = {(1, 1)}, cB = {(0, 1)}, and dB = {(1, 0)}.

Example 2.29 (57). The relation algebra 57 is described in Table 3 by its allowed triples. It is a well-known combinatorial fact that every representation has at most five elements. In fact, up to isomorphism 57 has only one representation, namely the representation B with domain B = {0, . . . , 4}, where

IdB := {(x, x) | x ∈ B}, aB := {(x, x ±5 1) | x ∈ B2}, bB := B2 \ (IdB ∪aB).

Besides the union representation, there is another construction of representations that will be relevant.

Definition 2.30. Let (Ai)i∈I be a sequence of relation algebras with representations (Bi)i∈I with disjoint domains. Define B := i∈I Bi to be the i∈I Ai-structure with domain i∈I Bi where aB := {i∈I|a∈Ai} aBi.

If A is a relation algebra with representation B, then we can write 1B = i∈I E2i, and for every i ∈ I call B|Ei a square component of B.

Lemma 2.31 ([HH02, Lemma 3.7]). Let A be a relation algebra with representation B, and let {Bi | i ∈ I} be the set of square components of B. For i ∈ I, let Ai be the relation algebra with the representation Bi. Then B = i∈I Bi, and there is a surjective homomorphism mapping A to Ai.

Corollary 2.32. Let A be a simple representable relation algebra. Then A has a square representation.

Proof. Let B be a representation of A with square components {Bi | i ∈ I}. For i ∈ I, let Ai be the relation algebra with representation Bi. By Lemma 2.31 there is a surjective homomorphism hi from A to Ai for each i ∈ I. If hi were not injective, then its kernel would be a non-trivial congruence relation on A, in contradiction to A being simple (see Remark 2.20). Hence, hi is an isomorphism and Bi is a square representation of A.

A representation B of A is finitely bounded if there is a finite family F of finite structures with signature A such that a finite structure C with signature A embeds to B if and only if no member of F embeds to C.

2.5 Networks

If A is a relation algebra, then an A-network (V, f) consists of a finite set of variables V and a function f : V2 → A (see, e.g., [Bod21, Section 1.5.3]). If B is a representation of A, then (V, f) is called satisfiable in B if there exists a function s : V → B such that for all x, y ∈ V we have (s(x), s(y)) ∈ f(x, y)B. An A-network (V, f) is called

• atomic if for all x, y ∈ V we have that f(x, y) is an atom in A;

• consistent (also: path-consistent, 3-consistent, or closed) if for all x, y, z ∈ V we have

f(x, y) ≤ f(x, z) ◦ f(z, y) and f(x, x) ≤ Id . (2.1)

A representation B of A is called universal if every satisfiable A-network is satisfiable in B, and fully universal if every consistent atomic A-network is satisfiable in B. Clearly, every fully universal representation is also universal.

Example 2.33 (57 (cont.)). As pointed out in Example 2.29, every square representation B of 57 has exactly five elements and is unique up to isomorphism; therefore, it is in particular universal. Clearly, the consistent atomic 57-network depicted in Figure 2 is unsatisfiable in this representation (this network appears for example in [Hir99]). Hence, there is no fully universal representation of 57.

If (V, f) and (W, g) are A-networks such that W ⊆ V and g = f|W2, we say that (W, g) is a subnetwork of (V, f). A consistent atomic network (V, f) is called reduced if for all x, y ∈ V, the atom f(x, y) is an identity atom if and only if x = y.

Figure 2: The evil square; it plays an important role in various proofs that certain relation algebras, e.g., 57, do not have a fully universal square representation. (Throughout the paper, we will represent symmetric relations by undirected edges.)

Observation 2.34. Let B be a representation of a finite relation algebra A. Then B is finitely bounded if and only if there is a finite set F′ of consistent atomic A-networks such that a consistent atomic A-network (V, f) is satisfiable in B if and only if no member of F′ is isomorphic to a subnetwork of (V, f).

Proof. First note that every reduced atomic A-network has a corresponding structure with signature A on the same vertex set (simply define relations based on the network) satisfying axioms 1–6 from Definition 2.24, and conversely, every such structure comes from a reduced atomic A-network. Moreover, a reduced atomic A-network is consistent if and only if the corresponding structure satisfies the “⊆” inclusion of axiom 7 of Definition 2.24 (and a failure of this is witnessed on three vertices).

Consequently, a finite structure with signature A corresponds to a reduced consistent atomic A-network if and only if all its substructures on at most three vertices do, which happens if and only if all its substructures on at most three vertices satisfy axioms 1– 6 and the “⊆” inclusion of axiom 7 of Definition 2.24. Since A is finite, there are only finitely many structures with signature A on at most three vertices up to isomorphism.

Finally, if (V, f) is a consistent atomic A-network and (V′, f|V′) is its (unique) reduced subnetwork, then (V, f) is satisfiable in B if and only if (V′, f′) is.

Consequently, if there is a finite set F′ as in the statement, then we can assume that it consists of reduced networks and we can put F to be the set consisting of all structures corresponding to members of F′ together with all structures with signature A on at most three vertices which do not embed into B, and F witnesses that B is finitely bounded. Conversely, if B is finitely bounded witnessed by F, we can simply put F′ to be the set of all reduced consistent atomic A-networks whose corresponding structure is in F.

2.6 Normal Representations

A representation B of A is called normal if it is square, fully universal, and homogeneous. Note that in normal representations B of A, the orbits of Aut(B) are in one-to-one correspondence with the identity atoms of A, and the orbits of the component-wise action of Aut(B) on B2 are in one-to-one correspondence with the atoms of A. It follows from Theorem 2.39 below that the question whether a given finite relation algebra has a normal representation is decidable.

Theorem 2.35. All countable normal representations of a relation algebra A are isomorphic.

Proof. Let B be a countable normal representation. Clearly, every finite substructure of B describes a consistent atomic A-network. Conversely, the assumption that the representation is fully universal implies that every consistent atomic A-network describes a finite substructure of B. Hence, the age of B is fully specified by A. The statement now follows from the well-known fact in model theory that a countable homogeneous structure is up to isomorphism uniquely given by its age (this can be shown by a back-and-forth argument; see, e.g., [Hod97]).

Observation 2.36. Two countable ω-categorical structures A and B are homomorphically equivalent if and only if CSP(A) = CSP(B) (see, e.g., [BD13, Lemma 2]).

The following definition is standard in model theory when phrased for structures; we present here a relation algebra version.

Definition 2.37 (The Amalgamation Property). Let A be a relation algebra and let C be a class of consistent atomic A-networks. We say that C has

• AP(k, l, m) (the (k, l, m)-amalgamation property) if for any two networks (V1, f1), (V2, f2) ∈ C with |V1| = k, |V1 ∩ V2| = l, and |V2| = m, if f1(a, b) = f2(a, b) for all a, b ∈ V1 ∩ V2, then there exists a network (V1 ∪ V2, f) ∈ C with f(a, b) = fi(a, b) for all i ∈ {1, 2} and a, b ∈ Vi;

• AP(n) if the property AP(k, l, m) holds for all k, l, m with k + l + m = n;

• AP if the property AP(n) holds for all n;

• JEP (the Joint Embedding Property) if AP(k, 0, m) holds for all k, m ∈ N.

Remark 2.38. Each of the properties from Definition 2.37 can be verified by considering only reduced consistent atomic A-networks instead of all consistent atomic A-networks.

Theorem 2.39 ([Bod18, Theorem 8]). Let A be a relation algebra with k atoms and let C be the class of all consistent atomic A-networks. Then the following are equivalent.

• C has AP;

• C has AP(k + 1, k, k + 1);

• A has a normal representation.

In some cases we will have to describe the normal representation of relation algebra concretely. We introduce the following notation, which is used for example in Tables 4 and 5.

• Ka2: the normal representation of 12 with the elements 0 and 1 where a denotes the relation {(0, 1), (1, 0)}.

• Kaω: the normal representation of 22 with domain N where a denotes the relation {(x, y) ∈ N2 | x = y}.

• Za,b5: the up to isomorphism unique representation of 57 with the elements {0, 1, 2, 3, 4} where a denotes the undirected edge relation {(a, b) : |a − b| = 1mod 5}, and b denotes the edge relation of the complement graph.

• Ra,b: the normal representation of 77, which is obtained from the Rado graph, i.e., the countable homogeneous graph whose age is the class of all finite undirected graphs, and where a denotes the edge relation and b denotes the edge relation of the complement graph.

• Q: the normal representation of 13 whose elements are the rational numbers and where r denotes the strict linear order of the rationals.

• C3: the normal representation of 23 with three elements 0, 1, 2 and where r denotes the directed cyclic relation {(0, 1), (1, 2), (2, 0)}.

• C4: the normal representation of 1837 with four elements 0, 1, 2, 3, where r denotes the directed cyclic relation {(0, 1), (1, 2), (2, 3), (3, 0)} and a denotes the relation {(0, 2), (2, 0), (1, 3), (3, 1)}.

• T: the normal representation of 33, which is obtained from the homogeneous tournament whose age is the class of all finite tournaments, and where r denotes the edge relation of the tournament.

• ˆT: the normal representation of 1937 whose elements are T × {0, 1} such that a is the relation {((x, 0), (x, 1)), ((x, 1), (x, 0)) : x ∈ T}, and ((x, i), (y, j)) is in the relation r if and only if either i = j and (x, y) is in the relation r of T, or i = j and (y, x) is in the relation r of T.

• Pn for n ∈ N+: the directed graph with vertices {0, . . . , n} and edges E = {(k, k + 1) | 0 ≤ k ≤ n − 1}.

• Kc2 ⊠a Kb2 : the normal representation of 2565 with domain {0, 1, 2, 3} where c = {(0, 1), (1, 0), (2, 3), (3, 2)}, b = {(0, 2), (2, 0), (1, 3), (3, 1)}, and a = {(0, 3), (3, 0), (1, 2), (2, 1)}.

• Kcω ⊠a Kbω : the normal representation of 2965 with domain N × N where c = {((u, v), (u′, v′)) | u = u′}, b = {((u, v), (u′, v′)) | v = v′}, and a = N2\(Id ∪ c ∪ b).

• P: the normal representation of 1537, which is obtained from the homogeneous poset whose age is the class of all finite posets, and where r denotes the strict partial order relation in the poset.

• D2 and Dω: the normal representations of 2037 and 2237 which are obtained from the homogeneous bipartite tournament and the homogeneous ω-partite tournament, respectively. (These are the Fraïssé limits of orientations of complete bipartite resp. multipartite graphs.) In both cases, a ∪ Id is an equivalence relation. In D2 it has 2 equivalence classes, while in Dω it has infinitely many, and in both structures pairs of non-equivalent points lie in r ∪ ˘r.

• S(3): the normal representation of 2337, whose vertices are the points on the unit circle with rational argument and where (x, y) is in the relation r if and only if the angle from x to y is in the interval (0, 2π/3).

Representations as well as reduced atomic networks of the relation algebras with an asymmetric atom r and a symmetric atom a, i.e., 137–3737, can be viewed as oriented graphs (i.e., directed graphs with no directed 2-cycles), where r represents the edge relation and a represents the non-edge relation. This notation will be repeatedly used throughout the paper.

2.7 Fully Universal Representations

Some relation algebras do not have a normal representation, but still have a fully universal representation. Such representations can be conveniently constructed with the following theorem, which is essentially due to Comer [Com83b], but phrased there in a different formalism, and so we also sketch the proof.

Let C be a class of consistent atomic A-networks. We say that a representation B of A is C-universal if an atomic A-network is satisfiable in B if and only if it belongs to C.

Theorem 2.40. Let A be a finite relation algebra and let C be a class of consistent atomic A-networks. Then A has

• a C-universal representation if and only if C has AP(3, 2, n) for all n;

• a C-universal square representation if and only if C has the JEP and AP(3, 2, n) for all n.

Proof sketch. For both statements, the proof can be obtained by adapting the proof of Fraïssé’s theorem (see, e.g., [Hod97]). Starting from some consistent atomic network, we use AP(3, 2, n) to form a chain of larger and larger networks that eventually ‘realizes all 1-point extensions’. Finally, we take an infinite disjoint union over the resulting network for all possible starting networks, and obtain a fully universal representation. For the second statement, in our chain we interleave extension steps and joint embedding steps; in this case, we do not have to take a disjoint union, and obtain a fully universal square representation.

Corollary 2.41. Let A be a finite relation algebra. Then A has a

• fully universal representation if and only if the class of all consistent atomic A-networks has AP(3, 2, n) for all n;

• fully universal square representation if and only if the class of all consistent atomic A-networks has the JEP and AP(3, 2, n) for all n.

Hirsch and Hodkinson [HH02, Problem 9.3] ask whether the class of all relation algebras with a homogeneous representation is an elementary class, i.e., a class that can be described by first-order sentences in the language of relation algebras. The following remark shows that several related classes of relation algebras, all of which are of central importance in this article, are indeed elementary.

Remark 2.42. The following classes of finite relation algebras are elementary:

• those with a normal representation;

• those with a fully universal square representation;

• those with a fully universal representation.

Proof. We give an axiomatisation of the relation algebras with a fully universal representation; the other classes can be axiomatized similarly (using Theorem 2.39 and Theorem 2.40). First note that there exists a first-order formula ϕ in the language of Boolean algebras that expresses that an element is an atom. Besides the axioms of relation algebras, we add for every n ∈ N the first-order axiom

∀x1,1, x1,2, . . . , xn,n, x1,0, x0,1, x0,2, x2,0 (i,j)∈{1,...,n}2∪{(0,1),(0,2)}(xi,j = ˘xj,i ∧ ϕ(xi,j))

A relation algebra A that satisfies this sentence has the property that the class of consistent atomic A-networks has AP(3, 2, n).

2.8 The 2-Cycle Product

The 2-cycle product is a useful tool to construct more complex relation algebras from simpler ones; the construction preserves representability (and, as we will see, even fully universal representability, normal representability, etc.) and it will also be useful in complexity considerations later. In the dream situation that A and B are finite relation algebras with normal representations C and D, respectively, then the representation R for the cycle product A[B] that we construct will also be normal; moreover, the automorphism group of R can be described as a wreath product of Aut(C) and Aut(D).

Remark 2.43. We note here an unfortunate clash of notation: while the relation algebra notation would suggest C[D] as a name for R, it is standard in model theory to write D[C] for this structure (see, e.g., Cherlin [Che87]), and indeed this notation is more suggestive, since we can imagine this structure as the structure obtained from D by replacing each element by a copy of C. We will follow the model-theoretic convention.

Definition 2.44. Let A and B be two finite relation algebras such that A0 ∩ B0 = {Id}. The 2-cycle product A[B] is defined to be the up to isomorphism unique relation algebra C such that C0 = A0 ∪ B0 and

Cy(C) = Cy(A) ∪ Cy(B) ∪ (a, b, b) | a ∈ A0 \ {Id}, b ∈ B0 \ {Id}.

Remark 2.45. If C = A[B] is a 2-cycle product of relation algebras A and B, then 1A is an equivalence relation of C. Moreover, for any representation C of C and two distinct equivalence classes C1, C2 of 1CA with x, y ∈ C1 and z ∈ C2 we have bC(x, z) if and only if bC(y, z) for all b ∈ B.

If N is an atomic C-network, we then write N⧸1A for the atomic B-network (V, g) whose variables V are the equivalence classes of 1NA and where g(C1, C2) := f(x1, x2) for some (equivalently, for any) x1 ∈ C1 and x2 ∈ C2.

Theorem 2.46 ([Mad06a, Theorem 5], see also [Com83b]). Let A and B be two finite representable integral relation algebras such that A0 ∩ B0 = {Id} and |A0|, |B0| ≥ 2. Let C and D be square representations of A and B, respectively.3 Then A[B] is representable and has the representation D[C] on the domain D × C defined as follows.4 For all a ∈ A0 \ {Id}, b ∈ B0 \ {Id}:

3It follows from Corollary 2.32 that every simple representable relation algebra has a square representation.

4Warning: we intentionally write D[C] rather than C[D]: see Remark 2.43.

IdD[C] := {((u0, v0), (u1, v1)) | u0 = u1, v0 = v1}

Example 2.47 (22[57]). Denote the non-identity atom of 22 by b and the non-identity atoms of 57 by a and c. Then the algebras 22 and 57 have the representations Kbω and Za,c5, respectively. The cycle product 22[57] is the algebra 1765, which has the representation Za,c5[Kbω] (depicted in Figure 3).

Figure 3: A representation of 1765 = 22[57] is given by Za,c5[Kbω].

3 The Network Satisfaction Problem

The network satisfaction problem for a fixed finite relation algebra A is the following computational problem, denoted by NSP(A) : The input consists of an A-network (V, f). The task is to decide whether A has a representation B such that there exists a function s : V → B which satisfies (s(x), s(y)) ∈ f(x, y)B for all x, y ∈ V; in this case the A-network is called satisfiable.

We can reduce the complexity classification for network satisfaction problems to the case where the relation algebra is simple.

Lemma 3.1 ([BK23, Lemma 2.10]). Let A and B be finite representable relation algebras. Then there exists a polynomial-time reduction from NSP(A) to NSP(A × B).

This lemma has a converse; we are not aware of any reference for this lemma, but it will be highly useful in our classification project.

Lemma 3.2. Let A1 and A2 be finite representable relation algebras such that NSP(A1) is in P and NSP(A2) is in P. Then NSP(A1 × A2) is in P. The same statement holds if we replace P by NP.

Proof. Let (V, f) be an (A1 × A2)-network. For i ∈ {1, 2}, we compute an Ai-network (V, fi) as follows. Define fi(x, y) := f(x, y)i. We run our polynomial-time algorithm for NSP(Ai) on (V, fi). We claim that (V, f) is satisfiable if and only if one of (V, f1) and (V, f2) is satisfiable.

For i ∈ {1, 2}, let Bi be a representation of Ai. Suppose that A1 has some representation B′1 such that there exists a function s1 : V → B′1 which satisfies (s1(x), s1(y)) ∈ f1(x, y)B′1 for all x, y ∈ V. We may suppose without loss of generality that B′1 ∩ B2 = ∅. From Lemma 2.26 we know that B′1 ⊎ B2 is a representation of A1 × A2. Then (s1(x), s1(y)) ∈ f(x, y)B′1⊎B2, and hence (V, f) is satisfiable. If (V, f2) is satisfiable, the proof that (V, f) is satisfiable is analogous.

Now suppose that conversely (V, f) is satisfiable, i.e., there exists a representation B of A1 × A2 and a function s : V → B with (s(x), s(y)) ∈ f(x, y)B for all x, y ∈ V. By Lemma 2.27, there are representations B1 of A1 and B2 of A2 such that B is isomorphic to B1 ⊎ B2. Since f is a total function on V2, the image of s must fully lie in B1 or in B2; suppose without loss of generality that the image is in B1. Then the representation B1 together with s shows that (V, f1) is satisfiable.

Remark 3.3. In order to show that the network satisfaction problem for relation algebras A with at most four atoms are in P or NPc, it suffices to prove this for simple relation algebras A, since by Remark 2.20, the result then follows by Lemma 3.1 and Lemma 3.2.

The remarkable aspect of the following lemma is that it also applies to relation algebras that do not have a fully universal representation. Also, for this lemma, we are not aware of any reference.

Lemma 3.4. Let A be a finite simple relation algebra such that the maximum cardinality of all square representations of A equals n ∈ N. Then NSP(A) is in NP. If A additionally has a square representation with at least three elements, then NSP(A) is NP-complete.

Proof. Containment in NP: for a given A-network (V, f), non-deterministically guess a square representation B of A (we have to choose from finitely many finite options) and then guess the mapping s : V → B; whether the mapping satisfies the required properties can be verified in polynomial time. We claim that (V, f) is satisfiable if and only if for some non-deterministic choice the function s has the required properties. Indeed, if A has such a square representation B and a map then clearly (V, f) is satisfiable. Conversely, if there exists some representation B of A where (V, f) is satisfiable, then 1B is an equivalence relation 1B = i∈I E2i; the structure B induces on each equivalence class Ei a square representation of some relation algebra Ai. By Lemma 2.31 we have a homomorphism from A to Ai, and by the simplicity of A the homomorphism is in fact an isomorphism. Therefore, (V, f) is also satisfiable in some square representation of A.

NP-hardness: by reduction from n-colouring, which is NP-hard for n ≥ 3. A given undirected graph G is reduced to the network (V(G), f) where f(x, y) = a∈A\Id a if (x, y) ∈ E(G), and f(x, y) = 1 otherwise.

Lemma 3.5. Let A be a finite relation algebra with a finitely bounded universal representation B. Then NSP(A) is in NP.

Proof. By Observation 2.34 there is a finite set F′ of consistent atomic A-networks such that a consistent atomic A-network (V, f) is satisfiable in B if and only if no member of F′ is isomorphic to a subnetwork of (V, f).

For a given A-network (V, f), non-deterministically guess an atomic network (V, g) with g(x, y) ≤ f(x, y) for all x, y ∈ V and verify, in polynomial time, that (V, g) is consistent and that no subnetwork of (V, g) is isomorphic to a member of F′.

3.1 The Network Consistency Problem

Unlike the network satisfaction problem of a finite relation algebra A, which can be undecidable [Hir99], the network consistency problem for A, denoted by NCP(A), which we introduce below, is always in NP (in fact, it is expressible in the logic monotone SNP; see [Bod21, BGP24]).

The input of the network consistency problem consists of an A-network (V, f). The task is to decide whether there exists a consistent atomic network (V, s) (which will also be called the solution to the given problem instance) on the same set of vertices V such that for all x, y ∈ V we have s(x, y) ≤ f(x, y). In this case, we say that (V, s) is solvable, and unsolvable otherwise. Note that if an A-network (V, f) is unsolvable, then it is also unsatisfiable as an instance of the network satisfaction problem.

Lemma 3.6. If A is a finite relation algebra with a fully universal representation, then the network satisfaction problem for A equals the network consistency problem for A.

Proof. Let B be the fully universal representation of A. Let N be an A-network. If N is satisfiable in B, then the network consistency problem clearly has a solution. Otherwise, if the network consistency problem has a solution, then the solution is satisfiable in B, since B is fully universal, and hence N is a positive instance to NSP(A).

Corollary 3.7. Let A be a finite relation algebra with a fully universal representation B. Then NSP(A) is in NP.

Remark 3.8. The converse of Lemma 3.6 is true as well: If NSP(A) = NCP(A), then there exists a fully universal representation (which in general might not be square). To see this, we may pick by assumption for every isomorphism type of a consistent atomic A-network a representation of A where the network is satisfiable. Let (Bi)i∈I be the (countable) collection of structures obtained in this way. Then the disjoint union over all the Bi (a special case of Definition 2.30) is a representation of A and clearly this representation is fully universal.

Lemma 3.9. Let A be a relation algebra with a fully universal square representation B having n ∈ {3, 4, . . . } elements. Then NSP(A) is NP-complete.

Proof. We have already established containment in NP. NP-hardness can be shown by reduction from n-colouring as in the proof of Lemma 3.4.

Remark 3.10. If the square representation B of some relation algebra A has n ∈ {3, 4, . . . } elements, then we obtain a one-dimensional pp-interpretation of Kn, the complete graph on n vertices, in B by defining the interpreting formula for the edge relation as ϕ(x, y) := 1B(x, y). It is well-known that Kn for n ≥ 3 in turn pp-constructs ({0, 1}; NAE), which verifies the tractability conjecture (Conjecture 1.3) for the algebras 23 and 17.

Remark 3.11. It is well-known that if A is a relation algebra and S ⊆ A is such that every element of A can be obtained from S using repeated applications of ◦, ˘, and intersection, then the network satisfaction problem can be reduced to the special case that in the input network (V, f) the image of f is restricted to S ∪ {1, Id}: for instance, if a, b ∈ S, and the input network (V, f) is such that

• f(x, y) = a ◦ b, then we define a new network (V ∪ {z}, g) where z is a new variable and g is defined as follows: g(u, v) := f(u, v) for all (u, v) ∈ V2 \ {(x, y), (y, x)}, g(x, z) := a, g(z, y) := b, and g(u, v) := 1 otherwise.

• f(x, y) = a ∩ b, then we define a new network (V ∪ {z}, g) where z is a new variable and g is defined as follows: g(u, v) := f(u, v) for all (u, v) ∈ V2 \ {(x, y)}, g(x, z) := Id, g(x, y) := a, g(z, y) := b, and g(u, v) := 1 otherwise.

It is then easy to see that (V, f) is satisfiable in some representation if and only if (V ∪ {z}, g) is satisfiable in some representation.

3.2 The Path Consistency Algorithm

The path consistency algorithm is a particularly natural polynomial-time algorithm in the context of the network consistency problem and the network satisfaction problem for a fixed relation algebra A. The input to the algorithm is an A-network (V, f); the algorithm repeatedly considers three variables u, v, w and improves f(u, v) by intersecting it with f(u, w) ◦ f(w, v), see Algorithm 1.

Algorithm 1 Path Consistency (PC)

Input: Relation algebra A and A-network N = (V, f)

1: f(x, x) ← f(x, x) ∩ Id

2: repeat

3: for (x, y, z) ∈ V3 do

4: f(x, y) ← f(x, y) ∩ (f(x, z) ◦ f(z, y))

5: end for

6: until N does not change

7: if f(x, y) = 0 for some x, y ∈ V then

8: return N is unsolvable

9: else

10: return N

11: end if

Remark 3.12. If the algorithm returns ‘unsolvable’ on a given A-network N, then N does not have a solution when viewed as an instance of NCP(A). Therefore, N is an unsatisfiable instance of NSP(A).

The output network N of the algorithm is called path consistent. We say that path consistency solves NSP(A) if (V, f) is satisfiable if and only if the algorithm does not return ‘unsolvable’.

Example 3.13. It is easy to see that if A is the relation algebra from Example 2.22, then path consistency solves NSP(A). Since Example 2.22 is the only simple non-integral relation algebra with at most four atoms (Lemma 4.1), we can later focus on integral relation algebras (see Remark 3.3).

3.3 Network Satisfaction Problems and CSPs

If B is a fully universal representation of a finite relation algebra A, then it is easy to see that CSP(B) is essentially the same problem as NSP(A) (which then equals NCP(A)).

However, sometimes a different constraint satisfaction problem can be used to obtain polynomial-time tractability results for NSP(A).

Definition 3.14. Let A be a relation algebra. The atom structure of A is the finite relational structure A0 with domain A0 and the following relations:

• for every b ∈ A the unary relation bA0 := {a ∈ A0 | a ≤ b},

• the binary relation EA0 := {(a1, a2) ∈ A20 | ˘a1 = a2}, and

• the ternary relation RA0 := Cy(A).

Clearly, the atom structure A0 of a relation algebra A is conservative: if f ∈ Pol(A0) has arity k and a1, . . . , ak ∈ A0, then A0 contains the relation bA0 for b = a1 ∪ · · · ∪ ak. So f must preserve this relation, which means that f(a1, . . . , ak) ∈ bA0 = {a1, . . . , ak}. The utility of atom structures is explained by the following:

Proposition 3.15 ([BK23, Proposition 2.16]). Let A be a finite relation algebra with a fully universal representation B. Then there is a polynomial-time reduction from NSP(A) to CSP(A0).

Hence, if CSP(A0) is in P, then so is NSP(A). The good news here is that there is a complete complexity classification of finite domain CSPs, as we mentioned in the introduction; since A0 is conservative, we can even apply Theorem 2.11. The bad news is that CSP(A0) might be NPc, while NSP(A) is still in P; this happens for instance for the point algebra 13 [VKvB89]. So we need more tools to prove polynomial-time tractability.

Viewing network satisfaction problems of relation algebras with fully universal representations as CSPs is not only useful for proving polynomial-time tractability, but also NP-hardness in a number of cases. This will mainly be done in Section 5.6, but we introduce a key concept here:

Definition 3.16. Let B be a normal representation of a finite relation algebra A and X ⊆ A0. An operation f : Bn → B is called X-canonical (with respect to B) if there exists a function f : Xn → A0 such that for all x, y ∈ Bn and a1, . . . , an ∈ X, if (xi, yi) ∈ aBi for all i ∈ {1, . . . , n}, then (f(x), f(y)) ∈ f(a1, . . . , an)B. The function f is called the behaviour of f on X. An operation f is called canonical (with respect to B) if it is A0-canonical.

A binary X-canonical function f is called X-symmetric if the behaviour of f on X is symmetric. A ternary X-canonical function f is called an X-majority if the behaviour of f on X is a majority operation, and it is called an X-minority if the behaviour of f on X is a minority operation.

4 Representations for Algebras with at most 4 Atoms

In this section we revisit the representability for relation algebras with at most 4 atoms. By Lemma 2.26 (also see Remark 2.20) we can focus on simple relation algebras. In Section 4.1 we will show that we may even focus on integral relation algebras. Exhaustive lists of these algebras have been computed by Maddux [Mad06b]. There are

• 2 integral relation algebras with two atoms (Table 1),

• 3 integral asymmetric relation algebras with three atoms (Table 2),

• 7 integral symmetric relation algebras with three atoms (Table 3),

• 37 integral asymmetric relation algebras with four atoms (Table 4), and

• 65 integral symmetric relation algebras with four atoms (Table 5).

Since the identity atom behaves the same in all the algebras, it is not needed to distinguish the algebras and it is therefore not shown in the lists. The fact that there are exactly 102=37+65 integral relation algebras with four atoms was already known to Comer [Com83c] (discovered in a different formalism with different terminology, but equivalent by a result from [Com84]; also see [Zie23]).

We will first recall results of Maddux which show that 31 of these relation algebras do not have a representation; the smallest algebras that are not representable have 4 atoms. We will then see that all the remaining 71 integral relation algebras do have a representation; this fact should be considered to be known and we do not claim originality. Several authors contributed representations, including S. Comer, P. Hertzel, P. Jipsen, R. Kramer, E. Lukács, and R. Maddux,5 and to the best of our knowledge not all of the respective work has been published. For us it will also be important whether there exists a fully universal representation, or even a normal representation, because this is relevant for analyzing the complexity of the NSP, as we have explained earlier. We test which of the relation algebras with at most 4 atoms have a normal representation, using Theorem 2.39. If they do not have a normal representation, we search for a fully universal representation using Theorem 2.40. It turns out that there are only 9 integral representable relation algebras that do not have a fully universal square representation. Some of them have the property that the cardinality of all square representations is bounded by some finite n ∈ N, which is useful because of Lemma 3.4. The remaining algebras will have to be inspected closely in a case-by-case fashion. See Figure 4.

5We are grateful for helpful email exchange with P. Jipsen and R. Maddux.

Atoms Elements RAs Simple Int. Sym./Asym. Repr. F.u.s. Norm. Flex. 0 1 1 1 1 1/0 1 1 1 0 1 2 1 1 1 1/0 1 1 1 1 2 4 3 2 2 2/0 2 2 2 1 3 8 13 10 10 7/3 7/3 6/3 6/3 2/1 4 16 119 103 102 65/37 45/26 37/25 34/23 10/5

Figure 4: The number of (simple, integral) relation algebras with 0–4 atoms and 1–16 elements. For the integral relation algebras, we specify how many of them have a (fully universal square) representation, which of them are normal and which have a flexible atom (see Definition 4.3), each time distinguishing the number of symmetric and the number of asymmetric relation algebras.

4.1 Reduction to the Integral Case

In this section we show that there is up to isomorphism only one simple non-integral relation algebra with at most four atoms. This fact might be known, but we are not aware of a reference in the literature.

Proposition 4.1. The algebra from Example 2.22 is up to isomorphism the only simple non-integral relation algebra with at most four atoms.

Proof. The simple relation algebras with at most three atoms have been determined by Andréka and Maddux [AM94], and all of them are integral. So let A be a simple non-integral relation algebra with four atoms. We already mentioned that a simple relation algebra is integral if and only if Id is an atom [Mad06a, Theorem 353]. Hence, A contains at least two identity atoms a and b. Denote the other two atoms of A by c and d. For two distinct identity atoms x and y, we have x ◦ y ≤ x ◦ Id = x and x ◦ y ≤ Id ◦y = y, so x ◦ y ≤ x ∩ y = 0. In particular, a ◦ b = b ◦ a = 0. Moreover, observe that

a = a ◦ Id = a ◦ x≤Id x atom x = x≤Id x atom a ◦ x.

Since a ◦ x = 0 for all identity atoms x = a, we conclude that a = a ◦ a. Analogously, we obtain b ◦ b = b.

◦ a b c d a a 0 b 0 b c d

It follows from a ≤ a ◦ Id and the cycle law that Id ≤ ˘a ◦ a, particularly ˘a ◦ a = 0. It is easy to show that ˘a has to be an identity atom too. Since x ◦ a = 0 for all identity atoms x = a, we conclude that ˘a = a. Analogously, we get ˘b = b.

We know that a ◦ c ≤ Id ◦c = c and a ◦ d ≤ Id ◦d = d. Assume towards a contradiction that a ◦ c = 0 and a ◦ d = 0. It follows that ˘c ◦ a = 0 and ˘d ◦ a = 0, which implies 1 ◦ a ◦ 1 = a, a contradiction to A being simple. Since c and d are indistinguishable up to this point, we can assume without loss of generality that a ◦ d = d.

As above, we also know that b ◦ c = c or b ◦ d = d. Assume the latter holds. Then 0 = (a ◦ b) ◦ d = a ◦ (b ◦ d) = a ◦ d = d, contradicting the associativity of ◦; hence, b ◦ c = c and b ◦ d = 0. Suppose that a ◦ c = c holds, then 0 = (a ◦ b) ◦ c = a ◦ (b ◦ c) = a ◦ c = c, which is again a contradiction.

◦ a b c d a a 0 0 d b 0 b c 0 c d

Next, suppose to the contrary that d = ˘d (and thus also c = ˘c). Then d ◦ a = (a ◦ d)˘ = ˘d = d. Similarly, we get c ◦ a = 0, c ◦ b = c, and d ◦ b = 0. It follows that 1 ◦ a ◦ 1 = (a ∪ d) ◦ 1 = (a ◦ 1) ∪ (d ◦ 1) = (a ∪ d) ∪ (d ◦ c) ∪ (d ◦ d). Since this expression has to equal 1 due to A being simple, we infer that b ≤ d ◦ c or b ≤ d ◦ d. By applying the cycle law, this implies c ≤ b ◦ d = 0 or d ≤ b ◦ d = 0, which are both contradictions. Hence, c = ˘d.

It follows that c ◦ a = (a ◦ d)˘ = c, d ◦ a = (a ◦ c)˘ = 0, c ◦ b = (b ◦ d)˘ = 0, and d ◦ b = (b ◦ c)˘ = d. We can now compute c ◦ c = c ◦ (b ◦ c) = (c ◦ b) ◦ c = 0 ◦ c = 0. Hence, also d ◦ d = (c ◦ c)˘ = 0.

For the last two missing entries in our table, observe that d ◦ c = d ◦ (c ◦ a) = (d ◦ c) ◦ a ≤ 1 ◦ a = a ∪ c and d ◦ c = (a ◦ d) ◦ c = a ◦ (d ◦ c) ≤ a ◦ 1 = a ∪ d; hence, d ◦ c ≤ a. Assume towards a contradiction that d ◦ c = 0. Then 1 ◦ d ◦ 1 = 1 ◦ d = d ∪ (c ◦ d), and this union has to equal 1 by the simplicity of A. In particular, a ≤ c ◦ d. By the cycle law, this implies ˘d ≤ a ◦ c = 0, a contradiction. Hence, d ◦ c = a. With an analogous argument, we obtain c ◦ d = b :

◦ a b c d a a 0 0 d b 0 b c 0 c c 0 0 b d 0 d a 0

Hence, A is isomorphic to the relation algebra in Example 2.22.

4.2 Without Representation

Comer [Com83c] states that at least 28 of the 102 integral relation algebras with four atoms are not representable. Results of Maddux [Mad06b] imply that in fact 31 do not have a representation. (And, as we have mentioned earlier, all others turn out to have a representation.)

Theorem 4.2. The following 31 integral relation algebras have no representation:

• the 11 asymmetric relation algebras 1437, 1637, 2137, 2437–2937, 3237, 3437;

• the 20 symmetric relation algebras 2165–2365, 3565–3865, 4065–4565, 4765–5065, 5465, 5865, 6065.

Therefore, their NSPs are trivial and in P.

Proof. See Chapters 6.64, 6.66, and (for the cases 3237 and 6065) 6.55 in [Mad06b].

4.3 Normal Representations

Examples of finite relation algebras with a normal representation include those with a flexible atom (see, e.g., [BK22]).

Definition 4.3. Let A be a relation algebra. An atom a ∈ A0 is called a flexible atom if a ≤ x ◦ y holds for all x, y ∈ A0\{Id}.

The relation algebras with a flexible atom are listed in Figure 5. Note that if a relation algebra has a flexible atom then it has a normal representation, as one can, when applying Theorem 2.39, always use a flexible atom for all undetermined values.

Name Flexible Atoms Name Flexible Atoms 22 a 3265 a 33 r, ˘r 3365 a 67 a 3465 a 77 a, b 5565 a 3137 a 5765 a 3337 a 5965 a 3537 a 6165 a 3637 r, ˘r 6365 a 3737 a, r, ˘r 6465 a, b 6565 a, b, c

Figure 5: Integral relation algebras with at most four atoms and at least one flexible atom.

With the criterion presented in Theorem 2.39 it is easy to see (by hand; we verified the condition in all cases by a computer program) that the following relation algebras with at most four atoms have a normal representation:

12, 22, 13, 23, 33, 17, 27, 37, 47, 67, 77, 137–1237, 1537, 1837–2037, 2237–2337, 3137, 3337, 3537–3737, 165–865, 1065, 1165, 1365, 1465, 1665, 1865–2065, 2565–2965, 3265–3465, 4665, 5265, 5365, 5565, 5765, 5965, 6165–6565. (4.1)

In Figure 7, we give for every representable algebra which is not in (4.1) a counterexample for the condition in Theorem 2.39 using the notation of Figure 6.

Figure 6: A 2-point-amalgamation diagram of size 5.

Relation Algebra (a1, a2, a3), (b1, b2, b3), (c1, c2, c3) Fully Universal 57 (a, a, b), (a, b, a), (a, b, b) No, Figure 2 1337 (a, a, a), (r, a, r), (a, r, r) Yes, Prop. 4.7 1737 (r, r, r), (r, ˘r, r), (a, a, ˘r) No, Lemma 4.18 3037 (a, a, a), (r, ˘r, a), (r, a, ˘r) Yes, Prop. 4.8 965 (a, b, b), (b, b, a), (a, b, a) No, Prop. 4.6 1265 (a, b, b), (b, b, a), (a, b, a) No, Prop. 4.6 1565 (a, c, c), (c, c, a), (a, c, a) No, Prop. 4.6 1765 (a, c, c), (c, c, a), (a, c, a) No, Prop. 4.6 2465 (a, a, a), (b, a, b), (a, c, c) Yes, Prop. 4.9 3065 (a, a, a), (b, b, c), (a, b, c) Yes, Prop. 4.10 3165 (a, a, a), (b, b, c), (a, b, c) Yes, Prop. 4.10 3965 (a, b, b), (b, b, a), (a, c, c) No, Prop. 4.13 5165 (b, a, a), (a, c, c), (a, c, b) No, Lemma 4.23 5665 (a, b, b), (b, c, a), (b, b, a) No, Prop. 4.27 6265 Remark 4.4 No, Prop. 4.14

Figure 7: Integral relation algebras with at most four atoms which do not have a normal representation; the second row shows a counterexample for the condition in Theorem 2.39, using the notation of Figure 6 (except for the last row for 6265, where we need a separate argument). In the third column we give (forward) references concerning the existence of a fully universal representation.

Remark 4.4. The algebra 6265 has the AP(5), but not the AP(6). This proves that the bound in Theorem 2.39 is optimal in the case of k = 4. The algebra 6265 is the only relation algebra with four atoms which admits this behavior. It is the unique relation algebra in which every triple which is not a 1-cycle is allowed. In some way it is the four-atom extension of 57. We note a further similarity between the two algebras: 57 is the only relation algebra with three atoms in which AP(4) holds but AP(5) does not, showing that the bound is optimal in the case of k = 3. The optimality of the bound in Theorem 2.39 for all k can be shown using relation algebras that are analogous to 6265.

We present the counterexample for AP(6) in 6265 by a matrix M ∈ (A0)6×6, where we choose V = {0, . . . , 5} and denote mij = f(i, j). The claim is that entries marked by a question mark ? cannot be filled by an atom of 6265 such that the resulting atomic network is consistent.

M = Id a b c a a a Id a a b b b a Id b c c c a b Id a b a b c a Id ? a b c b ? Id (4.2)

4.4 2-Cycle Product

In this section we discuss how representability properties of relation algebras translate to their cycle products, and apply our results to the case of integral relation algebras with four atoms.

Lemma 4.5. Let A, B be finite integral relation algebras with A0 ∩ B0 = {Id} and representations C and D. Then

(i) if C and D are fully universal, then D[C] is a fully universal representation of A[B].

(ii) if C and D are square, then D[C] is a square representation of A[B].

(iii) if C and D are normal, then D[C] is a normal representation of A[B].

Proof. (i): Suppose that C and D are fully universal. Let N = (V, f) be a consistent atomic A[B]-network. By Remark 2.45 we know that 1A is an equivalence relation of A[B]. Then (1A)N is an equivalence relation on V. Let C1, . . . , Ck be its equivalence classes. Then Ni := (Ci, f|Ci) is a consistent atomic A-network. The relation (1A)D[C] is also an equivalence relation and each class induces a fully universal representation Ci of A. So each Ni can be satisfied in a class of (1A)D[C].

By Remark 2.45 the contraction N⧸1A is well-defined. This contraction can be regarded as a consistent atomic B-network. Since D is fully universal we find suitable equivalence classes of (1A)D[C] such that the contraction is satisfiable. So D[C] is fully universal.

(ii): Let (u0, v0), (u1, v1) ∈ D × C. If (u0, v0) = (u1, v1) then ((u0, v0), (u1, v1)) ∈ IdD[C]. If u0 = u1 then (u0, u1) ∈ bD for some b ∈ B0 \ {Id} since D is square. Then ((u0, v0), (u1, v1)) ∈ bD[C]. Finally, assume that u0 = u1 and v0 = v1. Then for some a ∈ A0 \ {Id} we have (v0, v1) ∈ aC since C is square, and hence ((u0, v0), (u1, v1)) ∈ aD[C].

(iii): It remains to show that D[C] is homogeneous. Let f be a partial isomorphism of D[C]. First, note that f preserves the relations aD[C] for a ∈ A, in particular it preserves the equivalence classes (Ci)i∈I of (1A)D[C]. Each of these classes is isomorphic to the normal representation C of A, which is homogeneous. Thus, for each i ∈ I, there is at most one j ∈ I with f(Ci) ∩ Cj = ∅, and the restriction of f to Ci can be extended to an isomorphism gi between Ci and Cj. Moreover, since B is square, there is no i′ = i with f(Ci′) ∩ Cj = ∅. Hence, f induces a partial isomorphism on the contracted structure D[C]⧸1A, which is isomorphic to the homogeneous structure D, and can thus be extended to an automorphism h of D[C]⧸1A. If dom(f) ∩ Ci = ∅, let gi be a function which maps Ci isomorphically to h(Ci). It is easy to see that the function α := i∈I gi is an automorphism of D[C] that extends f.

To obtain a relation algebra from 137–3737 as a 2-cycle product, we have to multiply an algebra from 13–33 with 12 or with 22. See the first three lines of Figure 8 for all such products. Since all these algebras have a normal representation (see (4.1)), the 2-cycle product has a normal representation as well. A description of these representations can be found in the first twelve entries of Table 4.

To obtain a relation algebra from 165–6565 as a 2-cycle product, we can restrict ourselves to the case where we multiply algebras from 17–77 with 12 or with 22, see the last seven lines of Table 8. Except for 57, all factors have a normal representation, so the corresponding products have a normal representation. One can find descriptions of the representation in the first 20 rows of Table 5. In the following proposition we consider the four relation algebras with 57 as a factor.

Proposition 4.6. The relation algebras 965, 1265, 1565, and 1765 do not have a fully universal representation.

Proof. Let C be a representation of a finite relation algebra B ∈ {965, 1265, 1565, 1765}. First consider the case that B is of the form B = 57[A] for some relation algebra A. Then 1A is an equivalence relation of B and (1A)C is an equivalence relation on C. Consider any equivalence class C of (1A)C. By an analogous argument as in [AM94, Theorem 4.5] one can show that the induced substructure of C by C is isomorphic to the unique representation of 57 (see Example 2.29). After renaming the edges accordingly, it follows that the network in Figure 2 is not satisfiable. This settles the cases of 965 = 57[12] and 1265 = 57[22].

Now consider the case where B = A[57]. Then the contraction C⧸(1A)C is well-defined. Again, by the same argument as in [AM94, Theorem 4.5], it follows that this contraction is isomorphic to the unique representation of 57. So with adequate naming, the atomic network shown in Figure 2 is again not satisfiable. This settles the cases of 1565 = 57[12] and 1765 = 57[22]. Note that in these cases the atoms of 57 are named a and c in Table 5.

12 22 A 12[A] A[12] 22[A] A[22] 13 137 737 237 837 23 337 937 437 1037 33 537 1137 637 1237 17 165 165 265 565 27 365 265 465 665 37 565 365 665 765 47 765 465 865 865 57 1565 965 1765 1265 67 1665 1065 1865 1365 77 1965 1165 2065 1465

Figure 8: Not-so-small relation algebras formed by 2-cycle products of small relation algebras.

4.5 Fully Universal Representations

We are now left with relation algebras that are representable (as we will see), but that do not have a normal representation. In this section we investigate which of them have at least a fully universal representation, using Corollary 2.41.

We start with the relation algebra 1337, which is also known as the left linear point algebra [Dün05, BK07].

Proposition 4.7. 1337 has a fully universal square representation.

Proof. We verify the conditions of Corollary 2.41. For any two disjoint consistent atomic 1337-networks, we may connect all vertices by a and obtain another consistent atomic 1337-network. So 1337 has the JEP.

To verify AP(3, 2, n), let (V, f) be a reduced consistent atomic 1337-network, and let x, y ∈ V. We have to verify that for all atoms p, q of 1337 different from Id such that f(x, y) ≤ p ◦ q we can find a consistent atomic network (V ∪ {z}, g), for some new node z / ∈ V, such that g|V2 = f, g(x, z) = p, and g(z, y) = q. Without loss of generality we can assume that if a ∈ {p, q} then p = a. Let W := V \ {x, y}.

• p = q = a. Define g(z, v) = a for all v ∈ W.

• (p, q) ∈ {(a, ˘r), (r, r)}. Define g(z, v) = f(y, v) for all v ∈ W.

• (p, q) = (r, ˘r). Set g(z, v) = ˘r for all v ∈ W.

• (p, q) = (a, r). For all v ∈ W, define g(z, v) = r if f(y, v) = r and g(z, v) = a otherwise.

• (p, q) = (˘r, ˘r). For all v ∈ W, we set g(z, v) = f(x, v).

• (p, q) = (˘r, r). For all v ∈ W, define g(z, v) = r if r ∈ {f(x, v), f(y, v)} and g(z, v) = a otherwise.

In each case it is straightforward to check that g(u, v) ≤ g(u, z) ◦ g(z, v) for all u, v ∈ V, and hence that the resulting atomic network is consistent.

The reduced consistent atomic networks of 3037 can be viewed as oriented graphs that do not embed the oriented graph ({0, 1, 2}; {(0, 1), (0, 2)}).

Proposition 4.8. 3037 has a fully universal square representation.

Proof. For any two disjoint consistent atomic 3037-networks, we may connect all vertices by a and obtain another consistent atomic 3037-network. So 3037 has the JEP.

Let (V, f) be a reduced consistent atomic 3037-network, and let x, y ∈ V. We have to verify that for all atoms p, q of 3037 different from Id such that f(x, y) ≤ p ◦ q we can find a consistent atomic network (V ∪ {z}, g), for some new node z / ∈ V, such that g|V2 = f, g(x, z) = p, and g(z, y) = q. Without loss of generality we can assume that if a ∈ {p, q} then p = a.

We prove the statement by considering the following cases. Define W := V \ {x, y}.

• If p = q = a then define g(z, u) := a for all u ∈ W

• If p, q ∈ {r, ˘r}, then define g(z, u) := ˘r for all u ∈ W.

• If (p, q) = (a, r), then define g(z, u) := a for all u ∈ W.

• If (p, q) = (a, ˘r), we let X be the set of all vertices v ∈ W such that f(y, v) = r. Observe that f(u, v) = a for all u, v ∈ X. Define g(z, v) = r for all v ∈ X and g(z, v) = a for all v ∈ W \ X.

In each of the cases it is easy to check that the resulting atomic network is consistent.

The consistent atomic networks of the relation algebra 2465 can be viewed as edge-3-colourings of cliques that avoid ‘rainbows’, i.e., triangles that carry all three colors.

Proposition 4.9. 2465 has a fully universal square representation.

Proof. It is clear that the class of all consistent atomic 2465-networks has the JEP, since we may add the same atom between all vertices from one consistent atomic 2465-network and another one, and in this way clearly avoid rainbows.

To verify that the class of reduced consistent atomic 2465-networks has AP(3, 2, n) for all n ∈ N, let (V, f) be a reduced consistent atomic 2465-network, and let x, y ∈ V. We have to verify that for all atoms p, q of 2465 different from Id such that f(x, y) ≤ p ◦ q we can find a consistent atomic network (V ∪ {z}, g), for some new node z / ∈ V, such that g|V2 = f, g(x, z) = p, and g(z, y) = q. We distinguish two cases:

• p = q. Then define g(z, v) := p for all v ∈ V. Then clearly no triangle containing z is rainbow.

• p = q. Then f(x, y) ∈ {p, q}, as otherwise {v, x, y} forms a rainbow. Say that f(x, y) = q. In this case for every vertex v ∈ V \ {x, y}, define g(z, v) := f(x, v).

We claim that (V ∪ {z}, g) is consistent. Suppose for contradiction that we found a rainbow triangle containing z. It cannot contain x (as in every triangle {v, x, z} we have that f(x, v) = f(x, z), so it is {v, w, z} for some v, w ∈ V \ {x}. But then this triangle is isomorphic to {x, v, w}, which cannot be rainbow.

In the relation algebras 3065 and 3165 the relation c ∪ Id is an equivalence relation. In every fully universal representation every class of (c ∪ Id)B has infinitely many elements.

Proposition 4.10. If A ∈ {3065, 3165}, then A has a fully universal square representation.

Proof. For any two disjoint consistent atomic A-networks, we may connect all vertices by a and obtain another consistent atomic A-network. So A has the JEP.

Let (V, f) be a reduced consistent atomic A-network, and let x, y ∈ V. We have to verify that for all atoms p, q ∈ A0 such that f(x, y) ≤ p ◦ q we can find a consistent atomic network (V ∪ {z}, g), for some new node z / ∈ V, such that g|V2 = f, g(x, z) = p, and g(z, y) = q. Without loss of generality we can assume that if c ∈ {p, q} then p = c.

We prove the statement by considering the following cases. Define W := V \ {x, y}.

• If p = c (and so q = c), define g(z, v) = a for all v ∈ W.

• If p = c, let X be the set of all vertices v ∈ W such that f(v, x) = c and observe that f(v, u) = c for all u, v ∈ X, and if v ∈ X and f(u, v) = c for some u ∈ W, then u ∈ X. Define g(z, v) = c for all v ∈ X and g(z, v) = a for all v ∈ W \ X. Note that if q = c then f(x, y) = c, and so for all v ∈ W we have f(v, x) = c if and only if f(v, y) = c.

In each case and for each of the algebras 3065 and 3165 it is straightforward to check that g(u, v) ≤ g(u, z) ◦ g(z, v) for all u, v ∈ V and hence the resulting atomic network is consistent.

4.6 Bounded Square Representations

In this section we show the relation algebras 3965 and 6265 have representations, and that the size of all square representations of these algebras is bounded by some finite number. Via Lemma 3.4, this implies hardness of the respective NSPs (see Proposition 5.2). We first need to introduce Ramsey numbers.

Definition 4.11. Let c ∈ N+ and n1, . . . , nc ∈ N+. The Ramsey number R = R(n1, . . . , nc) denotes the smallest natural number such that if the edges of a complete graph of order R are colored with c different colors, then for some i ∈ {1, . . . , c}, the graph must contain a complete subgraph of order ni whose edges are all in color i. Ramsey’s theorem assures that this number always exists.

Lemma 4.12. Let A ∈ RRA be a finite relation algebra with an equivalence relation e ∈ A. Furthermore, let S be the set of atoms a ∈ A0 such that a ≤ e ◦ e. If S = ∅ and for every a ∈ S, the triple (a, a, a) is forbidden, then in every square representation B of A, the number of equivalence classes of eB is bounded by R( 3, . . . , 3 |S| times ) − 1 < ∞.

Proof. Let B be a square representation of A and eB an equivalence relation. It holds that

n := R( 3, . . . , 3 |S| times ) < ∞,

since A is finite. Assume that eB has n classes and choose representatives x1, . . . , xn of those. For 1 ≤ i < j ≤ n and every xi, xj there exists a relation a ∈ S such that (xi, xj) ∈ aB. If we again interpret the relations as colors then from the definition of the Ramsey number it follows, that there exists an atom a ∈ S ⊆ A0 such that xi, xj, xk ∈ B with (xi, xj), (xj, xk), (xi, xk) ∈ aB exist. However, this contradicts the fact that (a, a, a) is a forbidden triple. So eB cannot have n classes.

In [GG55] it was proved that R(3, 3, 3) = 17.

Proposition 4.13. A = 3965 has a square representation B with 7 elements, but it has no fully universal representation. Moreover, all square representations have at most 16 elements.

Proof. It is straightforward to verify that the following structure B is a representation of A :

B = Z7,

However, 3965 does not have AP(3, 2, 4); see Figure 9. Hence, it does not have a fully universal representation by Theorem 2.40.

Figure 9: Failure of AP(3, 2, 4) for 3965.

Figure 10: Failure of AP(3, 2, 6) for 6265. Edges colored blue, red, and black

are labeled a, b, and c, respectively.

By Lemma 4.12 for e = Id it follows that every square representation of A has size at most 16 = R(3, 3, 3) − 1.

Proposition 4.14. 6265 has a square representation B with 13 elements, but no fully universal representation. All square representations have at most 16 elements.

Proof. We learned the following representation B of 6265 from P. Jipsen:

B = Z13,

However, 6265 does not have AP(3, 2, 6); see Figure 10. By Theorem 2.40, there is no fully universal representation. By Lemma 4.12 for e = Id it follows that every square representation of A has size at most 16 = R(3, 3, 3) − 1.

4.7 Representable Algebras without Fully Universal Representation

In this section we treat representable relation algebras which have infinite representations, but no fully universal representations.

4.7.1 The Relation Algebra 1737

The reduced consistent atomic 1737-networks can be viewed as oriented graphs that do not embed the oriented graph P2 = ({0, 1, 2}; {(0, 1), (1, 2)}). These structures have been studied before and are called quasi-transitive oriented graphs [BJH95]. First, we will identify one consistent atomic network on four vertices which is not satisfiable, and then we will construct a representation in which all consistent atomic networks avoiding the unsatisfiable one are satisfiable.

Let (A, f) be an atomic 1737-network. An induced a-path in (A, f) is a sequence of distinct vertices a0, . . . , an−1 ∈ A such that f(ai, aj) = a if and only if |i − j| = 1. An induced a-path a0, . . . , an−1 is independent from some b ∈ A if for every i ∈ {0, . . . , n − 1} we have that f(ai, b) / ∈ {Id, a}.

Lemma 4.15. Let (A, f) be a consistent atomic 1737-network, and let a0, . . . , an−1 ∈ A be an induced a-path in (A, f). Then for every x ∈ A such that a0, . . . , an−1 is independent from x we have that f(x, ai) = f(x, aj) for every i, j ∈ {0, . . . , n − 1}.

Proof. For every i < n − 1 we have that f(x, ai) = f(x, ai+1), as otherwise x, ai, ai+1 would be a forbidden triple. The lemma now follows by transitivity of equality.

Lemma 4.16. Let (A, f) be a consistent atomic 1737-network and let a0, . . . , an−1 ∈ A be an induced a-path in (A, f). Then for all i, i′, j, j′ ∈ {0, . . . , n − 1} such that i < j − 1 and i′ < j′ − 1, it holds that f(ai, aj) = f(ai′, aj′).

Proof. Let 0 ≤ ℓ < n and fix an arbitrary k < ℓ − 1 and observe the following properties (all follow directly from the fact that (A, f) does not contain the single forbidden triple):

1. If ℓ + 1 < n then f(ak, aℓ) = f(ak, aℓ+1),

2. if k < ℓ − 2 then f(ak, aℓ) = f(ak, aℓ−1),

3. if k < ℓ − 2 then f(ak, aℓ) = f(ak+1, aℓ), and

4. if k > 0 then f(ak, aℓ) = f(ak−1, aℓ).

Now we can prove the statement of the lemma by repeated applications of the first or second, and the third or fourth points (depending on the order of j and j′, and i and i′ respectively).

Corollary 4.17. Two induced a-paths are isomorphic if and only if they have the same number of vertices.

This justifies that we can call the 1737-network (P, fP) with P = {0, 1, 2, 3}, fP(0, 1) = fP(1, 2) = fP(2, 3) = a, and fP(0, 2) = fP(0, 3) = fP(1, 3) = r the induced a-path on 4 vertices. Note that when viewed as an oriented graph, (P, fP) is acyclic, and is in fact the irreflexive variant of the poset sometimes called N. The N-free posets are known as series-parallel [VTL82]. In Section 6.3.2 we will employ a decomposition theorem for these posets in order to obtain an algorithm for NSP(1737).

Lemma 4.18. The induced a-path on 4 vertices is a consistent atomic 1737-network which is unsatisfiable.

Proof. Clearly, (P, fP) is consistent and atomic. Assume for a contradiction that there is some square representation B of 1737 satisfying (P, fP). That is, there is a map s : P → B such that for every x, y ∈ P it holds that (s(x), s(y)) ∈ fP(x, y)B. Since B is a representation of 1737 and r ≤ ˘r ◦ ˘r, there is some x ∈ B with (s(0), x) ∈ ˘rB and (x, s(2)) ∈ ˘rB. If (s(1), x) ∈ rB or (x, s(1)) ∈ rB then one of (s(1), x, s(0)) and (s(2), x, s(1)) is a forbidden triple; hence, (s(1), x) ∈ aB. But now every selection for the edge (s(3), x) leads immediately to a contradiction.

Corollary 4.19. Every atomic 1737-network containing an induced a-path on at least 4 vertices is unsatisfiable.

Let C be the class of all finite consistent atomic 1737-networks containing no induced a-path on 4 vertices.

Lemma 4.20. C has JEP.

Proof. Pick arbitrary (V1, f1), (V2, f2) ∈ C with V1 ∩ V2 = ∅. Put V = V1 ∪ V2 and define a 1737-network (V, g) with g|V21 = f1, g|V22 = f2 and g(x, y) = a if x ∈ V1 and y ∈ V2 or x ∈ V2 and y ∈ V1. It is straightforward to verify that (V, g) ∈ C.

We will spend the remainder of this section proving the following lemma.

Lemma 4.21. C has AP(3, 2, n).

Before we proceed with a proof of Lemma 4.21, observe that assuming it holds, we obtain a universal square representation of 1737. In fact, using Theorem 2.40 we immediately obtain the following.

Theorem 4.22. There is a square representation B of 1737 such that the following are equivalent for every atomic 1737-network (A, f):

1. (A, f) is satisfiable,

2. (A, f) is satisfiable in B,

3. there is a consistent atomic 1737-network (A, g) containing no induced a-path on 4 vertices such that g(x, y) ≤ f(x, y) for every x, y ∈ A.

Proof of Lemma 4.21. Pick some reduced (A, f) ∈ C with z / ∈ A, pick x, y ∈ A and some non-identity atoms p, q of 1737 such that f(x, y) ≤ p ◦ ˘q. Put B = A ∪ {z}. We will show that there is (B, g) ∈ C such g(x, z) = p, g(y, z) = q, and g restricted to A2 is equal to f. We distinguish four cases:

1. If p = q then we can define g(v, z) = p for every v ∈ A which clearly works. So p = q.

2. If f(x, y) = p then we can put g(v, z) = f(v, y) for every v ∈ A \ {y} (essentially making z a copy of y), and g(y, z) = q. Note that g(x, z) = f(x, y) = p, so we only need to verify that (B, g) ∈ C. Assume for a contradiction that this is not the case, that is, (B, g) contains either the forbidden triple, or the induced a-path on 4 vertices. Since (A, f) ∈ C, it follows that the hypothetical forbidden picture contains z. If it does not contain y then we obtain an isomorphic subnetwork of (A, f) by exchanging z for y, hence it contains both y and z. However, it is easy to verify that neither the forbidden triple, nor the induced a-path on 4 vertices contain a pair of vertices connected in the same way to every other vertex, which is a contradiction.

3. If f(y, x) = q then we can put g(v, z) = f(v, x) for every v ∈ A \ {x} (essentially making z a copy of x), and g(x, z) = p. Note that g(y, z) = f(y, x) = q, and we can use the same argument as in the previous case to prove that (B, g) ∈ C.

4. If none of the above holds, observe that f(x, y) ∈ {r, ˘r}. By symmetry, we can assume that f(x, y) = r. Since p = q, we get that at least one of them is different from a, and so either p = g(x, z) = ˘r, or q = g(y, z) = r. In fact, in both cases it follows that p = ˘r and q = r. In other words, (x, y, z) is a cyclically oriented triangle.

Note that as (A, f) ∈ C, all induced a-paths in (A, f) have at most 3 vertices. Observe that there is no v ∈ A for which there are both an induced a-path v = a0, . . . , an−1 = x independent from y and an induced a-path v = b0, . . . , bm−1 = y independent from x for some n, m ∈ {2, 3}. This is clear if f(x, v) = a or f(y, v) = a. So m = n = 3. Note that f(y, a1) = a and f(x, b1) = a. If f(a1, b1) = a then x, a1, b1, y is an induced a-path on 4 vertices, a contradiction. So f(a1, b1) = a, but then x, a1, v, b1, y is an induced a-path, again a contradiction. We put

g(v, z) = f(y, v) if there is an induced a-path v = a0, . . . , an−1 = x independent from y f(x, v) if there is an induced a-path v = a0, . . . , an−1 = y independent from x f(v, x) otherwise.

By the paragraph above, this is well-defined. It is easy to see that g(x, z) = p and g(y, z) = q, so we only need to prove that (B, g) ∈ C. Observe that for v ∈ A we have that g(v, z) = a if and only if f(x, v) = f(y, v) = a. We will use this below. Suppose for a contradiction that (B, g) / ∈ C. We need to distinguish four cases.

(a) First assume that there are u, v ∈ A such that g(u, v) = r, g(v, z) = r, and g(u, z) = a. We know that f(x, u) = f(y, u) = a. It follows that f(x, v) = a and f(y, v) = a (both cannot be equal to a at the same time as g(v, z) = a, and if only one is equal to a then we find an induced a-path on vertices x, y, u, v). If there is an induced a-path v = a0, . . . , an−1 = x independent from y, then we know that n = 3. Clearly, f(a1, y) = a. If f(a1, u) = a then we have the induced a-path v, a1, x, u, and if f(a1, u) = a then we find the induced a-path v, a1, u, y. So there is no induced a-path v = a0, . . . , an−1 = x independent from y, and similarly we can prove that there is no induced a-path v = a0, . . . , an−1 = y independent from x. Consequently, r = g(v, z) = f(v, x), but as we also have r = g(u, v) = f(u, v) and a = f(x, u), it follows that (A, f) induces the forbidden triple on u, v, x, a contradiction.

(b) If there are u, v ∈ A such that g(u, v) = ˘r, g(v, z) = ˘r, and g(u, z) = a then we can proceed analogously as in the previous case. One can also use the fact that changing the direction of all edges, that is, exchanging r and ˘r, preserves membership in C and reduces this case to the previous one.

(c) Next assume that there are u, v ∈ A such that g(u, v) = a, g(v, z) = r, and g(z, u) = r. As g(v, z) and g(u, z) are not equal to a, we know that at most one of f(x, u) and f(y, u) is equal to a and at most one of f(x, v) and f(y, v) is equal to a. If f(x, u) = f(y, v) = a then we find an induced a-path on vertices x, u, v, y, similarly if f(x, v) = f(y, u) = a. So these cases do not happen. It follows that g(u, z) = f(y, u) if and only if g(v, z) = f(y, v) (and in this case we get that f(y, u) = ˘r and f(y, v) = r, so the triple u, v, y is forbidden), that g(u, z) = f(x, u) if and only if g(v, z) = f(x, v) (and in this case the triple u, v, x is forbidden), and that g(u, z) = f(u, x) if and only if g(v, z) = f(v, x) (and in this case the triple u, v, x is again forbidden). In all cases, we arrived to a contradiction.

(d) The above three points imply that all triples in (B, g) are allowed, and so (B, g) contains an induced a-path on 4 vertices. Clearly, this path contains z. There are two possibilities, either z is an endpoint of this path, or it is not.

If z is an endpoint, call the other vertices of the path u, v, w such that f(u, v) = f(v, w) = g(w, z) = a. As g(w, z) = a, we know that f(x, w) = f(y, w) = a. Now, since g(u, z), g(v, z) = a, it follows that at most one of f(x, u) and f(y, u) is equal to a and similarly for f(x, v) and f(y, v). On the other hand, we know that a ∈ {f(x, u), f(x, v)} (as otherwise u, v, w, x would be an induced a-path on 4 vertices in (A, f), and similarly a ∈ {f(y, u), f(y, v)}. It follows that either f(x, u) = f(y, v) = a, or f(x, v) = f(y, u) = a. In the first case x, u, v, y is an induced a-path on 4 vertices in (A, f), and in the second case x, v, u, y.

So z is not an endpoint. Call the other vertices of the path u, v, w such that f(u, v) = g(v, z) = g(z, w) = a. Then we know that f(v, x) = f(v, y) = f(w, x) = f(w, y) = a, and at least one of f(u, x) and f(u, y) is not equal to a. If f(u, x) = a then u, v, x, w is an induced a-path on 4 vertices in (A, f), and if f(u, y) = a then u, v, y, w is an induced a-path on 4 vertices in (A, f), a contradiction. Consequently, (B, g) ∈ C.

4.7.2 The Relation Algebra 5165

The relation algebra 5165 is given by the facts that b ∪ Id is an equivalence relation and (a, a, a) and (c, c, c) are forbidden triples. We will find a universal, but not fully universal representation B of 5165 such that a finite 5165-network is satisfiable in some representation of 5165 if and only if it is satisfiable in B. This representation will not be fully universal, and we will characterize the consistent atomic 5165-networks which are satisfiable by means of four forbidden subnetworks on four vertices. These will be the following:

Put A = {0, 1, 2, 3} and define four atomic 5165-networks (A, f1), (A, f2), (A, f3), and (A, f4) as follows:

1. f1(0, 1) = f1(1, 2) = f1(2, 3) = f1(3, 0) = a, and f1(0, 2) = f1(1, 3) = c,

2. f2(0, 1) = f2(1, 2) = f2(2, 3) = f2(3, 0) = c, and f2(0, 2) = f2(1, 3) = a (so (A, f1) and (A, f2) only differ by swapping a with c),

3. f3(0, 1) = f3(1, 2) = f3(2, 3) = a, and f3(0, 2) = f3(0, 3) = f3(1, 3) = c

4. f4(0, 1) = f4(2, 3) = b, f4(0, 2) = f4(1, 3) = a, f4(0, 3) = f4(1, 2) = c.

Note that (b ∪ Id) ◦ (b ∪ Id) = b ∪ Id =: e is an equivalence relation. Abusing notation, if (A, f) is a consistent atomic 5165-network, we will also consider e as an equivalence relation on (A, f) whose equivalence classes are the maximal subsets of A such that the range of the restriction of f is {b, Id}.

Lemma 4.23. All networks (A, f1), (A, f2), (A, f3), and (A, f4) are consistent, but none is satisfiable in any representation of 5165.

Proof. Consistency is easy to check. Since (A, f1) and (A, f2) only differ by swapping a and c, it is enough to verify unsatisfiability for (A, f1), (A, f3), and (A, f4).

We start with (A, f1). Assume for a contradiction that there is some representation C of 5165 satisfying (A, f1), that is, there is a map s : A → C such that for every x, y ∈ A it holds that (s(x), s(y)) ∈ f1(x, y)C. Since C is a representation of 5165, it follows that there exists x ∈ C such that (s(0), x) ∈ bC and (s(2), x) ∈ aC. It follows that (s(3), x) ∈ cC (it cannot be in aC because of the triple (s(2), s(3), x), it cannot be in bC because of the triple (s(0), s(3), x), and clearly s(3) = x). By an analogous argument we get (s(1), x) ∈ cC, but then (s(1), s(3), x) is a forbidden triple in C, a contradiction.

Note that the verbatim same argument works also when one puts f1(0, 3) = c instead, which proves that (A, f3) is not satisfiable.

Finally, we look at (A, f4). Analogously as for (A, f1) we assume that it is satisfiable in some C, obtain a map s : A → C, and find a vertex x ∈ C such that (s(0), x), (s(2), x) ∈ cC. It follows that (s(1), x), (s(3), x) ∈ aC, and so the triple (s(1), s(3), x) is forbidden, a contradiction.

Corollary 4.24. Let (A, f) be a consistent atomic 5165-network with at least 4 equivalence classes of e. Then (A, f) contains one of (A, f1), (A, f2), or (A, f3) as a subnetwork, and hence is unsatisfiable.

Proof. Find B ⊆ A of size 4 such that no two vertices of B are equivalent. Consequently, for every x = y ∈ B it holds that f(x, y) ∈ {a, c}. It is easy to verify that every such (B, f|B2) is isomorphic to one of (A, f1), (A, f2), or (A, f3).

Comer [Com83a, Proposition 3] gave a representation of 5165. He left the proof as an exercise to the reader. We will verify his representation and prove that, in fact, Comer’s representation is universal (every satisfiable 5165-network is satisfiable in this representation).

Proposition 4.25. There is a square representation B of 5165 such that a consistent atomic 5165-network is satisfiable in B if and only if it avoids (A, f1), (A, f2), (A, f3), and (A, f4). Consequently, B is a finitely bounded universal representation of 5165.

Proof. First, we will construct B and prove that it is a representation of 5165. We will follow the construction by Comer. Let B := Q be the rational numbers with a partition B0, B1, B2 such that for all i ∈ {0, 1, 2} the set Bi is dense, cofinal and coinitial in Q, i.e.,

∀x ∈ Q ∃y ∈ Bi : x ≤ y (cofinal),

Examples of such sets could be:

B0 = p q ∈ Q | q ≡3 0 and Bi = p q ∈ Q | p = 0, q ≡3 i for i ∈ {1, 2}.

We now define a representation B with domain B :

IdB := {(x, x) | x ∈ Q},

Obviously, every relation of B is symmetric. We will now compute the composition table of B. For the rest of the proof, we omit specifying B in the superscript of the relations, addition will always be modulo 3, and the variable i will always be in {0, 1, 2}. Note that Id ◦ d = d ◦ Id = d for all d ∈ {a, b, c}.

For x, z ∈ Q the following holds:

(x, z) ∈ b ◦ b ⇐⇒ ∃y ∈ Q ((x, y), (y, z) ∈ b)

Since a ◦ b, a ◦ c, and b ◦ c are unions of a, b, c, and Id, which are all symmetric, it follows that a ◦ b = b ◦ a, a ◦ c = c ◦ a, and b ◦ c = c ◦ b, which concludes the proof that B is indeed a representation of 5165.

Next, we prove that a consistent atomic 5165-network (C, f) is satisfiable in B if and only if it avoids (A, f1), (A, f2), (A, f3), and (A, f4). Clearly, if (C, f) contains one of (A, f1), (A, f2), (A, f3), and (A, f4) then it is not satisfiable at all by Lemma 4.23.

So assume that (C, f) is a consistent atomic 5165-network which avoids (A, f1), (A, f2), (A, f3), and (A, f4). We will find a partition C = C1 ⊔ C2 ⊔ C3 and a linear order on C such that any increasing function ϕ : C → B such that ϕ[Ci] ⊆ Bi witnesses that B represents (C, f).

By Corollary 4.24 we know that (C, f) has three (possibly empty) equivalence classes of e; put C1 ⊔ C2 ⊔ C3 = C to be the classes. Note that, for fixed 1 ≤ i < j ≤ 3 and for every x ∈ Bi, y ∈ Bj, the relation of (x, y) in B only depends on the order of x and y. Consequently, for every 1 ≤ i < j ≤ 3 and for every x ∈ Ci, y ∈ Cj, the value f(x, y) determines the order of ϕ(x) and ϕ(y) for every possible function ϕ : C → B which maps Ck → Bk for every k ∈ {1, 2, 3} and witnesses that B represents (C, f). Let < be the binary relation on C obtained from this. Clearly it is antisymmetric. If there is a linear extension of < then we are done.

Assume for a contradiction that there is no such linear extension. It follows that there is a sequence c0, c1, . . . , cn−1 ∈ C such that, for every 0 ≤ i < n, ci < ci+n1. We can assume that c0, c1, . . . , cn−1 ∈ C is the shortest such sequence. Observe that, for every 0 ≤ i < n, we have that ci and ci+n1 are in different classes of e in C. Also note that from the minimality of n it follows that < is not defined on any pair ci, cj with |i − j| ≥ 2. Consequently, we have that n ∈ {3, 4}.

If n = 3 then we have that, without loss of generality c0 ∈ C1, c1 ∈ C2, and c2 ∈ C3. However, from the definition of relations in B it follows that (c0, c1, c2) is a forbidden monochromatic triple, a contradiction.

So n = 4, and we have that c0, c2 ∈ Ci and c1, c3 ∈ Cj for some i = j ∈ {1, 2, 3}. Consequently, from the definition of relation on B we get that f(c0, c1) = f(c2, c3) = f(c0, c3) = f(c1, c2) ∈ {a, c}. This implies that for D = {c0, c1, c2, c3} we have that (D, f|D2) is isomorphic to (A, f4), a contradiction.

Hence there is a linear extension of <. Note that since all Bi’s are dense, cofinal and coinitial, and C is finite, there exists a desired function ϕ.

4.7.3 The Relation Algebra 5665

The relation algebra 5665 has almost the same forbidden triples as 5165, but additionally allows the triple (a, b, b) (and so b is no longer an equivalence relation). This relation algebra has a representation, which according to R. Maddux and P. Jipsen (personal communication) was found by E. Lukács. However, it does not have a fully universal one (Proposition 4.27).

Proposition 4.26. 5665 has a square representation.

Proof. Let S0, S1, . . . , S5 be a partition of the open interval B := (0, 1) ∩ Q such that Si is dense in (0, 1) for each i ∈ {0, . . . , 5}. In what follows, all operations with indices of the sets Si are performed in Z6. Let B be the structure with domain B, where, for i, j ∈ {0, . . . , 5}, x ∈ Si and y ∈ Sj with x < y,

(x, y), (y, x) ∈ aB ⇐⇒ j − i ∈ {2, 5},

To prove that B is indeed a representation of 5665, one needs to compute the composition table as in Proposition 4.25. We will only exemplarily show that b ◦ b = a ∪ b ∪ Id; the other cases can be treated very similarly.

For one direction, suppose that (x, z) ∈ b ◦ b with x < z. By the definition of b ◦ b, there is some y ∈ B such that (x, y) ∈ b and (y, z) ∈ b. Let i, j, k ∈ {0, . . . , 5} such that x ∈ Si, y ∈ Sj and z ∈ Sk. If y < x < z, we have

k − i = (k − j) + (j − i) = (k − j) − (i − j) ∈ {0, 1} − {0, 1} = {0, 1, 5};

if x < y < z, we have

k − i = (k − j) + (j − i) ∈ {0, 1} + {0, 1} = {0, 1, 2};

and if x < z < y, we have

k − i = (k − j) + (j − i) = −(j − k) + (j − i) ∈ −{0, 1} + {0, 1} = {0, 5} + {0, 1} = {0, 1, 5}.

Thus, (k − i) ∈ {0, 1, 2, 5} and consequently (x, z) ∈ a ∪ b.

In the other direction, let (x, z) ∈ a ∪ b ∪ Id with x ≤ z and let i, k ∈ {0, . . . , 5} be such that x ∈ Si and z ∈ Sk. If (x, z) ∈ Id, i.e. x = z, choose an arbitrary y ∈ Si different from x to obtain (x, y) ∈ b, (y, z) ∈ b and hence (x, z) ∈ b ◦ b. For the case (x, z) ∈ a, we distinguish two cases: If k − i = 2, choose an arbitrary y ∈ Si+1 with x < y < z; if k − i = 5, choose an arbitrary y ∈ Si with x < z < y. If (x, z) ∈ b, we can choose an arbitrary y ∈ Si with x < y < z. In all cases, it holds that (x, y) ∈ b and (y, z) ∈ b.

Figure 11: AP(3, 2, 4) fails for 5665.

Proposition 4.27. 5665 does not have a fully universal representation.

Proof. Consider the diagram from Figure 11. It is easy to see that all assignments of atoms to the dashed edges induce one of the forbidden triples (a, a, a), (c, c, c), or (c, b, b), so 5665 does not have AP(3, 2, 4). Hence, it does not have a fully universal representation by Theorem 2.40.

Recently, it was shown that the algebra 5665 has a finitely bounded universal representation [BGPJ+25] (this was posed as a question in an early preprint of this paper); hence, its NSP is contained in NP by Lemma 3.5. The representation is closely connected to the generic circular triangle-free graph studied in [BGP25]. The construction involves deeper results about signed graphs and requires substantially different techniques.

5 NP-hard Algebras with at most 4 Atoms

In this section we present NP-hardness results for relation algebras with at most 4 atoms. If the relation algebra has a normal representation, it falls into the scope of the tractability conjecture (Conjecture 1.3); in order to confirm the conjecture for the relation algebras with a normal representation, we also explain how to obtain a pp-construction of ({0, 1}; NAE) in each of these cases.

For the relation algebras with at most 3 atoms, a classification has already been established by [CH04], with two corrections in [BK20]; in particular, 67 is NP-complete.

For the relation algebras with 4 atoms, the NSP for 1537 has been shown to be NP-complete by Broxvall and Johnsson [BJ03]: it has a normal representation (Section 4.3) and in the countable normal representation, the relation r denotes a homogeneous strict partial order. The CSP of all reducts of this representation have been classified by Broxvall and Johnsson [BJ03], and the hardness result follows since the maximal tractable classes presented in Section 4 there do not cover all the relations of 1537. We thus have the following.

Proposition 5.1. NSP(1537) is NP-complete.

The hardness proof given in [BJ03] is a primitive positive construction of the Betweenness relation Betw on Q; since the (Q; Betw) primitively positively interprets ({0, 1}; NAE) (see, e.g., [BP11]), this confirms the tractability conjecture for the normal representation of 1537. The remaining hardness proofs are grouped in the following subsections according to the applied proof method.

5.1 Hardness for Bounded Square Representations

We have already studied representations of 3965 and 6265 in Section 4.6 (they do not have fully universal representations).

Proposition 5.2. NSP(3965) and NSP(6265) are NP-complete.

Proof. The statement follows from Lemma 3.4 together with Proposition 4.13 and Proposition 4.14, respectively.

5.2 Symmetric Algebras with a Flexible Atom

The network satisfaction problem for finite symmetric relation algebras with a flexible atom is in P or NPc [BK22]. The tractability conjecture (Conjecture 1.3) has already been confirmed for this case (compare to [BK23, Theorem 9.1]). To determine which of the two cases applies in the concrete cases of relation algebras with four atoms in this article, we need the following proposition.

Proposition 5.3 ([BK22, Theorem 2.21 and Proposition 6.1]). Let A ∈ RA be a finite, symmetric, integral relation algebra with a flexible atom and B a normal representation of A. If B does not have a binary injective polymorphism, then CSP(B) is NP-complete.

Proposition 5.4 ([BK23, Lemma 4.3]). Let A ∈ RA be a finite symmetric relation algebra with a normal representation B that has a binary injective polymorphism. Then A has all 1-cycles.

Proposition 5.5. Let A ∈ {3265, 3365, 5565, 5765, 5965, 6365, 6465}, then NSP(A) is NP-complete.

Proof. All the relation algebras appear in Figure 5, so they have a flexible atom. Moreover, they are symmetric and except for the case of 5965 they lack the 1-cycle (c, c, c). The algebra 5965 does not have the 1-cycle (b, b, b). Thus, A has no binary injective polymorphism by Proposition 5.4, and therefore, by Proposition 5.3, the NSP is NPc.

Theorem 5.6 ([BK22, Theorem 9.1]). Let A be a finite symmetric relation algebra with a flexible atom and atom structure A0. Then CSP(A0) and NSP(A) are polynomial-time equivalent.

Proposition 5.7. NSP(3465) is NP-complete.

Proof. We want to show that there is no polymorphism of the atom structure A0 of 3465 such that its restriction to {b, c} is a binary symmetric, majority or minority operation. By Theorem 2.11, CSP(A0) is NPc and by Theorem 5.6, NSP(A) is NPc.

First, assume that m is a binary symmetric polymorphism of A0 when restricted to {b, c}. We consider the case that m(b, c) = m(c, b) = b. This implies m(Id, c) = m(c, Id) = Id as otherwise (m(Id, c), m(b, c), m(b, c)) would equal a forbidden triple (recall that A0 is conservative). But now (m(Id, c), m(c, Id), m(c, c)) = (Id, Id, c) is a forbidden triple, a contradiction. Similar reasoning can be applied in the case of m(b, c) = m(c, b) = c. So m cannot exist.

Next, assume for contradiction that there exists a polymorphism m which is a majority when restricted to {b, c}. If we apply m to the allowed triples (b, b, b), (b, c, a), (c, c, a), we obtain

(m(b, b, c), m(b, c, c), m(b, a, a)) = (b, c, m(b, a, a)) ∈ CyA0

and hence m(b, a, a) = a. If we apply m to the allowed triples (c, c, Id), (b, b, b), (c, c, Id), we obtain

(m(c, b, c), m(c, b, c), m(Id, b, Id)) = (c, c, m(Id, b, Id)) ∈ CyA0

and hence m(Id, b, Id) = Id. By permuting the triples, we analogously get m(Id, Id, b) = Id. Using this, we apply m to the allowed triples (Id, b, b), (b, c, a), (Id, b, b) and get

(m(Id, b, Id), m(b, c, b), m(b, a, b)) = (Id, b, m(b, a, b)) ∈ CyA0,

hence m(b, a, b) = b. Putting it all together, we apply m to the allowed triples (Id, b, b), (Id, a, a), (b, b, a) and get

(m(Id, Id, b), m(b, a, b), m(b, a, a)) = (Id, b, a) ∈ CyA0,

which is a contradiction.

Finally, assume towards a contradiction that there is a polymorphism m that is a minority when restricted to {b, c}. If we apply m to the allowed triples (b, c, a), (b, b, b), (c, c, a), we obtain

(m(b, b, c), m(c, b, c), m(a, b, a)) = (c, b, m(a, b, a)) ∈ CyA0

and hence m(a, b, a) = a. Applying m to the allowed triples (c, c, Id), (b, b, Id), (b, b, b), we get

(m(c, b, b), m(c, b, b), m(Id, Id, b)) = (c, c, m(Id, Id, b)) ∈ CyA0

and hence m(Id, Id, b) = Id. Finally, applying m to the allowed triples (Id, b, b), (Id, b, b), (b, c, a) yields

(m(Id, Id, b), m(b, b, c), m(b, b, a)) = (Id, c, m(b, b, a)) ∈ CyA0;

since (Id, c, x) is only allowed for x = c, this implies m(b, b, a) = c, contradicting the conservativity of m.

5.3 Finitely Many Equivalence Classes

An equivalence relation E ⊆ B2 is called proper if E is a proper subset of B2; it is called trivial if it is the equality relation on B, and non-trivial otherwise.

Theorem 5.8 ([BK20, Theorem 23]). Let A ∈ RRA be a finite relation algebra with normal representation B and a non-trivial proper equivalence relation e ∈ A such that eB has only finitely many classes. Then CSP(B) is NP-complete.

The proof of Theorem 5.8 in [BK20] already confirms the tractability conjecture (Conjecture 1.3) in this case.

Relation Algebra Equivalence Relation Forbidden Triples 337 a ∪ Id (r, r, r) 437 a ∪ Id (r, r, r) 737 r ∪ ˘r ∪ Id (a, a, a) 937 r ∪ ˘r ∪ Id (a, a, a) 1137 r ∪ ˘r ∪ Id (a, a, a) 1837 a ∪ Id (r, r, r) 2037 a ∪ Id (r, r, r) 165 a ∪ Id (b, b, b), (c, c, c) 265 a ∪ Id (b, b, b), (c, c, c) 365 a ∪ b ∪ Id (c, c, c) 465 a ∪ b ∪ Id (c, c, c) 1065 a ∪ b ∪ Id (c, c, c) 1165 a ∪ b ∪ Id (c, c, c) 2565 a ∪ Id (b, b, b), (c, c, c) 2665 a ∪ Id (b, b, b), (c, c, c) 2865 a ∪ Id (b, b, b), (c, c, c)

Figure 12: Relation algebras where Theorem 5.8 applies.

Proposition 5.9. Let

A ∈ {337, 437, 737, 937, 1137, 1837, 2037, 165, 265, 365, 465, 1065, 1165, 2565, 2665, 2865},

then NSP(A) is NP-complete.

Proof. Use Lemma 4.12 to see that the conditions for Theorem 5.8 are satisfied. Figure 12 shows the choice of e for each of the relation algebras.

5.4 No Non-trivial Equivalence Relation

A permutation group is called primitive if it does not preserve a non-trivial proper equivalence relation. Note that if A is a finite relation algebra with a normal representation B, then Aut(B) is primitive if and only if A does not contain equivalence relations besides 1 and Id.

Theorem 5.10 ([BK20, Theorem 29]). Let A be a relation algebra with a normal representation B. If Aut(B) is primitive and a ∈ A0 is symmetric such that (a, a, a) is forbidden in A, then CSP(B) and NSP(A) are NP-complete.

The proof of Theorem 5.10 in [BK20] already confirms the tractability conjecture (Conjecture 1.3) in this case.

Proposition 5.11. If A ∈ {2337, 3637, 4665}, then NSP(A) is NP-complete.

Proof. The relation algebras 2337, 3637, and 4665 have normal representations (see (4.1)). In the case of 2337 and 3637, the triple (a, a, a) is forbidden, and in the case of 4665 the triple (c, c, c) is forbidden. Moreover, each of the three algebras does not contain equivalence relations besides 1 and Id. We verify this for 4665, and leave the proof for the other two algebras to the reader.

(a ∪ Id)2 = a ∪ c ∪ Id, (b ∪ Id)2 = a ∪ b ∪ Id, (c ∪ Id)2 = b ∪ c ∪ Id .

Furthermore, since (a, b, c) is an allowed triple,

(a ∪ b ∪ Id)2 = (a ∪ c ∪ Id)2 = (b ∪ c ∪ Id)2 = 1.

So the statement follows from Theorem 5.10.

5.5 Hardness for 2-Cycle Products

The following two lemmas imply that if a relation algebra is a 2-cycle product of two relation algebras A and B, and A or B has an NP-complete NSP, then the network satisfaction problem for the 2-cycle product has an NP-complete NSP as well.

Lemma 5.12. Let A and B be finite relation algebras such that NSP(A) and NSP(B) are both in NP. Then NSP(A[B]) is in NP as well.

Proof. Let N = (V, f) be an A[B]-network. The algorithm proceeds as follows: First, guess an equivalence relation W ⊆ V2. Replace f(x, y) by f(x, y) ∩ A for all (x, y) ∈ W, replace f(x, y) by f(x, y) ∩ B for all (x, y) ∈ V2\W and check whether f(x, y) = ∅ for all x, y ∈ V. Let C1, . . . , Ck be the equivalence classes of W. For all i ∈ {1, . . . , k} and all (x, y, z) ∈ Ci × Ci × (V\Ci), replace f(x, z) and f(y, z) by f(x, z) ∩ f(y, z) until a stable state is reached. Again, verify that this replacement did not yield ∅ on any edge. Next, check whether each of the classes can be satisfied in some representation of A. If this is the case, let C1, . . . , Ck be respective representations. Finally, consider the contraction N⧸W = V⧸W, f⧸W and check whether it is satisfiable in some representation of B. If this is the case, let D be such a representation. If all conditions were satisfied up to this point, the structure D[C1, . . . , Ck], which is obtained from D by replacing, for every i ∈ {1, . . . , k}, the element xi ∈ V⧸W which represents the class Ci by Ci, is a representation of A[B] which satisfies N.

Observe that if N is satisfiable then any satisfying assignment gives an equivalence relation W ⊆ V2 which, if guessed at the beginning by the algorithm, will lead to the algorithm identifying N as satisfiable, which proves correctness of the algorithm.

Lemma 5.13. Let A and B be finite representable relation algebras such that A0 ∩ B0 = {Id}. Then there is a polynomial-time reduction from NSP(A) to NSP(A[B]) and from NSP(B) to NSP(A[B]).

Proof. Let N = (V, f) be a given A-network or B-network, respectively. Since A, B ⊆ C := A[B] we know that N is also a C-network. We will show that N is a satisfiable A- or B-network, respectively, if and only if it is a satisfiable C-network.

For the first direction, we will only consider the case of N being an A-network, but the other case is analogous. Suppose that N is satisfiable in a square representation C of A, then choose any square representation D of B. Then D[C], which by Theorem 2.46 is a representation of C, also satisfies the C-network N. If N is only satisfiable in a non-square representation B of A, then consider the union over all structures D[Bi], where {Bi | i ∈ I} are the square components of B. This shows one direction for both cases.

For the converse, first suppose that N is an A-network which is satisfiable in a representation B of C. Since f only maps to A, N is also satisfiable in the A-reduct of B which is a (not necessarily square) representation of A.

Next, let N be a B-network which is satisfiable in a representation B of C. By Remark 2.45, 1A is an equivalence relation in C, so the contracted structure B⧸e is well-defined and a representation of B which satisfies N.

The proof of the following lemma will be important to show that our complexity dichotomy confirms the tractability conjecture (Conjecture 1.3). It can be shown analogously to the previous lemma.

Lemma 5.14. If A and B are normal representations of A and B, respectively, then B[A] pp-constructs A and B.

Proposition 5.15. If A ∈ {1037, 565, 665, 965, 1265, 1365, 1565, 1665, 1765, 1865}, then NSP(A) is NP-complete. If A has a normal representation B, then B pp-constructs ({0, 1}; NAE).

Proof. In every case, the algebra A is the 2-cycle product with one component being from 23, 17, 27, 57, and 67 (see Figure 8). The NSP of these algebras is NP-hard as stated in Table 2 and 3, so NSP(A) is NP-hard as well by Theorem 5.13. The NP-membership of NSP(A) follows from Lemma 5.12, as the NSP of both components of the 2-cycle product is in NP.

Since the normal representations of 23, 17, 27, and 67 all pp-construct ({0, 1}; NAE) (see Remark 3.10 and the already mentioned results in [BK20]), so do the representations of the respective algebras with normal representations (1037, 565, 665, 1365, 1665, and 1865) by Lemma 5.14 and the transitivity of pp-constructibility.

5.6 Hardness via Primitive Positive Constructions

In the following, we will prove the NP-hardness of seven NSPs by means of pp-interpretations. For that we will use various concepts from Section 2.2 as well as Definition 3.16. For the first three cases, we will infer from the nonexistence of certain polymorphisms that the respective normal representation pp-interprets ({0, 1}; NAE); the argument is summarized in the following proposition.

Proposition 5.16. Let A be a finite relation algebra with a normal representation B. If there are two distinct elements x, y ∈ A0 such that every f ∈ Pol(B) is {x, y}-canonical, but not {x, y}-symmetric, a {x, y}-majority, or a {x, y}-minority, then NSP(A) is NP-complete.

Proof. Since B is a normal representation of A, NSP(A) = CSP(B) is contained in NP. Because every polymorphism of B is {x, y}-canonical, the function ξ with domain Pol(B) given by

f → (the behaviour of f on {x, y})

is well-defined. Note that, since the behaviour of f on {x, y} is conservative, ξ(Pol(B)) is a clone on the two-element set {x, y}. It is easy to see that ξ is a clone homomorphism. Note that if we have four vertices x1, x2, x3, x4 ∈ B with xB(x1, x2) and yB(x3, x4), then, for any f ∈ Pol(B), the values of f on tuples with components from {x1, x2, x3, x4} suffice to determine ξ(f); hence, ξ is uniformly continuous (see Definition 2.16). By assumption, Pol(B) contains no {x, y}-symmetric operation, no {x, y}-minority and no {x, y}-majority. Since the behaviour of f on {x, y} is conservative, ξ(Pol(B)) also does not contain the function f satisfying f(x) = y and f(y) = x. Thus, by Post’s Theorem 2.13, ξ(Pol(B)) is the projection clone. Since B is homogeneous, it is in particular ω-categorical. It follows from Theorem 2.17 that B pp-constructs ({0, 1}; NAE) and CSP(B) = NSP(A) is NP-hard.

The relation algebra 1937 has a normal representation B with domain T × {0, 1} and the following relations:

• aB := {(x, 0), (x, 1) | x ∈ T} ∪ {(x, 1), (x, 0) | x ∈ T}.

• rB := (x,y)∈ET (x, 0), (y, 0), (x, 1), (y, 1), (y, 0), (x, 1), (y, 1), (x, 0).

Proposition 5.17. NSP(1937) is NP-complete.

Proof. Let B be the normal representation of 1937 defined above. Observe that the relation

R = {(x1, x2, y1, y2) ∈ B4 | (a ∪ Id)B(x1, x2) and (a ∪ Id)B(y1, y2)

has the following pp-definition in B (see Figure 13):

(a ∪ Id)(x1, x2) ∧ (a ∪ Id)(y1, y2) ∧ ∃z1, z2, z3, z4(a ∪ Id)(z1, z2) ∧ (a ∪ Id)(z3, z4)

Figure 13: In every solution g to this 1937-network, we have g(x1, x2) = g(y1, y2).

Hence, every polymorphism of B preserves R, and thus is {a, Id}-canonical.

Assume that there is an {a, Id}-symmetric polymorphism m : Then either m(a, Id) = m(Id, a) = a or m(a, Id) = m(Id, a) = Id. In both cases, we obtain a contradiction, because (m(a, Id), m(Id, a), m(a, a)) would either be equal to (a, a, a) or to (Id, Id, a), which are both forbidden triples. Next, assume that there is an {a, Id}-majority m : Then (m(Id, a, a), m(a, Id, a), m(a, a, Id)) = (a, a, a), which is a forbidden triple, a contradiction to m being a polymorphism. Finally, assume that there is an {a, Id}-minority m : We consider (m(Id, a, Id), m(a, ˘r, a), m(a, r, a)), which has to be an allowed triple. Since the first entry has to be a, we conclude that this expression is equal to (a, ˘r, r) (recall that m is conservative). In particular, we obtain m(a, r, a) = r. Hence, the fact that (m(a, r, a), m(Id, r, a), m(a, a, Id)) has to be allowed implies that m(Id, r, a) = ˘r, which contradicts the fact that every polymorphism of B is conservative. It follows from Proposition 5.16 that CSP(B) = NSP(1937) is NP-complete.

The consistent reduced atomic 2765-networks are exactly those in which c only appears in rainbow triangles, i.e., in triples (x, y, z) such that {x, y, z} = {a, b, c}.

Let R = (R; ER) be the Rado graph. The algebra 2765 has a normal representation B with domain R × {0, 1} and the following relations (see Figure 14):

aB = (x,y)∈ER (x, 0), (y, 0), (x, 1), (y, 1) ∪ (x,y)∈ER (x, 0), (y, 1), (x, 1), (y, 0) ,

Figure 14: Detail from the normal representation B of 2765. Here, (x, y) ∈ ER and (x′, y′) ∈ ER.

Proposition 5.18. NSP(2765) is NP-complete.

Proof. Let B be the normal representation of 2765 as defined above. Observe that the relation

R = {(x1, x2, y1, y2) ∈ B4 | (c ∪ Id)B(x1, x2) and (c ∪ Id)B(y1, y2) and cB(x1, x2) ⇐⇒ cB(y1, y2)}

has the following pp-definition in B (see Figure 15):

(c ∪ Id)(x1, x2) ∧ (c ∪ Id)(y1, y2) ∧ ∃z1, z2(c ∪ Id)(z1, z2) ∧ (a ∪ Id)(x1, z1) ∧ (a ∪ Id)(z1, y1)

Figure 15: In every solution g to this 2765-network, we have g(x1, x2) = g(y1, y2).

This implies that the polymorphisms of the normal representation are {c, Id}-canonical.

Assume that there is a {c, Id}-symmetric polymorphism m : Then either m(c, Id) = m(Id, c) = c or m(c, Id) = m(Id, c) = Id. In both cases, we obtain a contradiction since (m(c, Id), m(Id, c), m(c, c)) would either be equal to (c, c, c) or to (Id, Id, c), which are both forbidden triples. Next, assume that there is a {c, Id}-majority m : Then (m(Id, c, c), m(c, Id, c), m(c, c, Id)) = (c, c, c), which is a forbidden triple, a contradiction to m being a polymorphism. Finally, assume that there is a {c, Id}-minority m : Since (m(b, c, b), m(Id, c, Id), m(b, Id, b)) has to be an allowed triple, m(Id, c, Id) = c and m(b, Id, b) ∈ {b, Id}, it follows that m(b, c, b) = c. Analogously, since (m(c, a, a), m(c, Id, Id), m(Id, a, a)) has to be an allowed triple, we infer m(c, a, a) = c. Hence, (m(c, a, a), m(a, b, c), m(b, c, b)), which has to be an allowed triple, is one of (c, a, c), (c, b, c), and (c, c, c), which are all forbidden, a contradiction.

It follows from Proposition 5.16 that CSP(B) = NSP(2765) is NP-complete.

In the relation algebra 2965, both b ∪ Id and c ∪ Id denote an equivalence relation with infinitely many infinite classes.

Proposition 5.19. NSP(2965) is NP-complete.

Proof. Let B be the normal representation of 2965 (see (4.1)). It can be checked by various case distinctions that the relation

R = {(x1, x2, y1, y2) ∈ B4 | (b ∪ c)B(x1, x2) and (b ∪ c)B(y1, y2) and bB(x1, x2) ⇐⇒ bB(y1, y2)}

has the following pp-definition in B (see Figure 16):

(b ∪ c)(x1, x2) ∧ (b ∪ c)(y1, y2) ∧ ∃z1, z2, z3, z4, z5, z6(b ∪ c)(z2, z3) ∧ (b ∪ c)(z6, y1) ∧ (b ∪ c)(x1, z1)

Figure 16: In every solution g to this 2965-network, we have g(x1, x2) = g(y1, y2).

This implies that the polymorphisms of the normal representation are {b, c}-canonical. It is easy to see that there cannot be a {b, c}-symmetric polymorphism. Assume for contradiction that there exists a {b, c}-majority m. Then m(a, b, a) = b, since otherwise (m(a, b, a), m(b, b, c), m(c, b, b)), which has to be an allowed triple, would equal (a, b, b), which is a contradiction. But now we get (m(a, b, a), m(a, a, a), m(b, c, b)) = (b, a, b), which is also a contradiction to m being a polymorphism. As a last step assume for contradiction that there exists a {b, c}-minority m. Then (m(b, b, c), m(b, c, b), m(b, a, a)) is either (c, c, b) or (c, c, a), which are both forbidden triples, a contradiction. It follows from Proposition 5.16 that NSP(2965) is NP-complete.

We take a different approach for the following two hardness proofs, in which we will directly give a pp-interpretation of a structure with NP-hard CSP in the normal representation of the respective relation algebra.

The consistent atomic 3337-networks can be seen as oriented graphs that do not embed a directed 3-cycle. Hence, 3337 has the flexible atom a and therefore a normal representation. The classification from [BK22] cannot be applied here since only symmetric relation algebras are covered there.

Proposition 5.20. There is a primitive positive interpretation of ({0, 1}; NAE) in the normal representation B of 3337; consequently, NSP(3337) is NP-complete.

Proof. We present a primitive positive interpretation in B of the structure ({0, 1}; NAE). It then follows from Proposition 2.7 that NSP(3337) is NP-hard; it is contained in NP since 3337 has a normal representation.

We work with the terminology from Definition 2.6. The dimension of the interpretation is d = 2. The domain formula is given by ϕ⊤(x0, x1) := (r ∪ ˘r)(x0, x1). The coordinate map h : (r ∪ ˘r)B → {0, 1} is given by h(x0, x1) = 0 if rB(x0, x1) and h(x0, x1) = 1 if (˘r)B(x0, x1). For the interpretation of the relations = and NAE, consider the gadget network in Figure 17, which allows us to encode equal orientation of two disjoint (r ∪ ˘r)-edges.

Figure 17: In this 3337-network, a directed edge stands for r, and an undirected edge stands for (r ∪ ˘r). In every solution g to it, we have g(x0, x1) = g(y0, y1).

Let E(x0, x1, y0, y1) be the formula ∃u0∃u1∃u2∃u3 ψ, where ψ is the conjunction of all the relations depicted in Figure 17. Then our defining formula for equality is given by

ϕ=(x0, x1, y0, y1) := ∃z0, z1E(x0, x1, z0, z1) ∧ E(y0, y1, z0, z1).

(ϕ= can obviously be transformed into an equivalent pp-formula by renaming the existentially bound variables in the occurrences of E and subsequently shifting them to the front.) By the observation about the gadget network, it is clear that ϕ=(x0, x1, y0, y1) holds if and only if h(x0, x1) = h(y0, y1). The auxiliary variables z0 and z1 are needed since {x0, x1} and {y0, y1} are not necessarily disjoint.

The defining formula of NAE is given by

ϕNAE(x0, x1, y0, y1, z0, z1) := ∃v0, v1, v2, q0, . . . , q5E(x0, x1, q0, q1) ∧ E(y0, y1, q2, q3)

The auxiliary variables q0, . . . , q5 are needed since some of x0, x1, y0, y1, z0, z1 might be equal. Now ϕNAE(x0, x1, y0, y1, z0, z1) holds in B if and only if there are v0, v1, v2 ∈ B such that (x0, x1) has the same orientation as (v0, v1), (y0, y1) has the same orientation as (v1, v2), and (z0, z1) has the same orientation as (v2, v0). Since the only forbidden triple of 3337 is the directed 3-cycle, it is clear that this in turn holds if and only if h(x0, x1), h(y0, y1), and h(z0, z1) are not all equal.

The consistent atomic 3537-networks may be viewed as oriented graphs that do not embed the oriented graph T3 := ({0, 1, 2}; {(0, 1), (1, 2), (0, 2)}). Like 3337, it has a as a flexible atom and thus a normal representation; its NSP is NP-complete as well.

Proposition 5.21. There is a primitive positive interpretation of ({0, 1}; NAE) in the normal representation B of 3537; consequently, NSP(3537) is NP-complete.

Proof. We present a primitive positive interpretation in B of the structure ({0, 1}; R, S), where R := {0, 1}3 \ {(0, 0, 0)} and S := {(0, 1), (1, 0)}. It is easy to verify that this structure does not have a binary symmetric, ternary majority or ternary minority polymorphism; thus, the statement follows from Schaefer’s Theorem 2.14.

We again use the terminology from Definition 2.6. The dimension of the interpretation is d = 2. The domain formula is given by ϕ⊤(x0, x1) := (r ∪ ˘r)(x0, x1). The coordinate map h : (r ∪ ˘r)B → {0, 1} is given by h(x0, x1) = 1 if rB(x0, x1) and h(x0, x1) = 0 if (˘r)B(x0, x1). For the interpretation of the relations =, R, and S, consider the following gadget network, which allows us to encode equal orientation of two disjoint (r ∪ ˘r)-edges; see Figure 18.

Figure 18: An edge stands for (r ∪ ˘r). In every solution g to this 3537-network, we have g(x0, x1) = g(y0, y1).

Figure 19: In every solution g to this 3537-network, at least one of g(p1, q1), g(p2, q2) and g(p3, q3) is equal to r.

Figure 20: An edge stands for (r ∪ ˘r). In every solution g to this 3537-network, we have g(q0, q1) = g(p0, p1).

Let E(x0, x1, y0, y1) be the conjunction of all the relations depicted in Figure 18. Then our defining formula for equality is given by

ϕ=(x0, x1, y0, y1) := ∃z0, z1, z2, z3E(x0, x1, z0, z1) ∧ E(y0, y1, z2, z3) ∧ E(z0, z1, z2, z3).

As in the proof of Proposition 5.20, it is clear that ϕ=(x0, x1, y0, y1) holds if and only if h(x0, x1) = h(y0, y1). For the defining formula for R, we need yet another gadget network.

Our defining formula ϕR(x0, x1, y0, y1, z0, z1) for R is given by

ϕR := ∃p1, p2, p3, p4, q1, q2, q3E(x0, x1, p1, q1) ∧ E(y0, y1, p2, q2) ∧ E(z0, z1, p3, q3) ∧ ψ,

where ψ is the conjunction of all relations depicted in Figure 19. By the observation about this network, it is clear that ϕR(x0, x1, y0, y1, z0, z1) holds if and only if at least one of h(x0, x1), h(y0, y1), and h(z0, z1) is equal to 1. Finally, for the relation S, consider yet another gadget network, shown in Figure 20, which encodes inequality between the orientations of two disjoint (r ∪ ˘r)-edges. So a defining formula for S is ϕS(x0, x1, y0, y1) given by

ϕS := ∃q0, q1, p0, p1, zE(x0, x1, q0, q1) ∧ E(y0, y1, p0, p1) ∧ ψ,

where ψ denotes the conjunction of all relations depicted in Figure 20.

Let H = (V; E) be the Henson graph, i.e., the countable homogeneous graph whose age is the class of all finite undirected triangle-free graphs. We obtain a (normal) representation B = Hb,a of 67: we set bB := E, aB := {(u, v) ∈ V2 \ E | u = v}, IdB := {(u, v) ∈ V2 | u = v}, and extend to all other relations by taking the respective Boolean combinations. It is known that NSP(67) is NPc [BK20].

Proposition 5.22. The normal representations of 3137 and 5265 pp-construct ({0, 1}; NAE); consequently, NSP(3137) and NSP(5265) are NP-complete.

Proof. Let B be the normal representation of 3137. Consider the structure H := (B; E), where E := (r ∪ ˘r)B. Clearly, the age of H is the class of all finite undirected triangle-free graphs. Hence, CSP(H) = CSP(H), where H is the Henson graph. Moreover, H is ω-categorical since it is a first-order reduct of the ω-categorical structure B. It follows from Observation 2.36 that H is homomorphically equivalent to H. Since H pp-constructs ({0, 1}; NAE), it follows that H pp-constructs ({0, 1}; NAE) by the transitivity of pp-constructibility. Since B pp-defines H, we obtain that B pp-constructs ({0, 1}; NAE). For 5265, the proof is completely analogous when we define E := cB.

5.7 Hardness via Gadget Reductions

Algebras considered in this section do not have a normal representation and hence do not fall within the scope of the tractability conjecture (Conjecture 1.3). We will show the NP-hardness of their NSPs by many-one reductions from computational problems which are known to be NP-hard. We start with the algebra 3065 and yet another reduction from the Henson graph:

Proposition 5.23. NSP(3065) is NP-complete.

Proof. Recall that 3065 has a fully universal representation (Proposition 4.10), so NSP(3065) = NCP(3065). Let H be the Henson graph and let A = (A; E) be an instance of CSP(H). Define the network N = (A, f) by f(x, x) = Id, f(x, y) = b if E(x, y), and f(x, y) = a ∪ Id otherwise, for all x, y ∈ A. It follows immediately that A homomorphically maps to H if and only if N is a satisfiable 3065-network.

Figure 21: The 3037-network E(x0, x1, y0, y1) encodes equal orientation of two (r ∪ ˘r)-edges: In every solution g to it, we have g(x0, x1) = g(y0, y1).

Figure 22: The 3037-network S(p1, p2, p3, p4, q1, q2, q3) : In every solution g to it, at least one of g(p1, q1), g(p2, q2), and g(p3, q3) is equal to r.

Figure 23: The 3037-network T(p0, p1, q0, q1) : In every solution g to it, we have that g(p0, p1) = r implies g(q0, q1) = ˘r.

We have already shown that 3037 has a fully universal representation (Proposition 4.8). Recall that the reduced consistent atomic networks of 3037 can be viewed as oriented graphs that do not embed the oriented graph ({0, 1, 2}; {(0, 1), (0, 2)}).

Proposition 5.24. NSP(3037) is NP-complete.

Proof. Since 3037 has a fully universal representation, NSP(3037) = NCP(3037) is contained in NP. We show its NP-hardness by a reduction from the variant of SAT where each clause is of the form (x ∨ y ∨ z) or of the form (¬x ∨ ¬y). Let ϕ be an instance of this problem and let V be the set of variables occurring in ϕ. We will construct an instance (V′, f) of NCP(3037) such that (V′, f) is satisfiable if and only if ϕ is satisfiable.

Consider the 3037-networks E(x0, x1, y0, y1), S(p1, p2, p3, p4, q1, q2, q3), and T(p0, p1, q0, q1), which are depicted in Figure 21, Figure 22, and Figure 23, respectively.

The network (V′, f) is defined as follows: For every variable x ∈ V, we add two fresh variables x0 and x1 to V′.

For each clause of the form (x ∨ y ∨ z), we add seven fresh variables p1, p2, p3, p4, q1, q2, q3 to V′ and impose the constraints E(x0, x1, p1, q1), E(y0, y1, p2, q2), E(z0, z1, p3, q3) and S(p1, p2, p3, p4, q1, q2, q3) on f.

For each clause of the form (¬x ∨ ¬y), we add four fresh variables p0, p1, q0, q1 to V′ and impose the constraints E(x0, x1, p0, p1), E(y0, y1, q0, q1) and T(p0, p1, q0, q1) on f.

It follows immediately from the observations about the gadget networks above that if a function g is a solution to (V′, f), then the function s : V → {0, 1} defined by s(x) = 0 if g(x0, x1) = r and s(x) = 1 if g(x0, x1) = ˘r is a solution to ϕ. Conversely, if s : V → {0, 1} is a solution to ϕ, then it is easy to see that the partial function g defined by g(x0, x1) = r if s(x) = 0 and g(x0, x1) = ˘r if s(x) = 1 can be extended to a solution to (V′, f).

Figure 24: The 3165-network E(x0, x1, y0, y1) : In every solution g to it, we have g(x0, x1) = g(y0, y1).

Figure 25: The 3165-network S(p1, p2, p3, p4, q1, q2, q3) : In every solution g to this 3165-network, at least one of g(p1, q1), g(p2, q2) and g(p3, q3) is equal to c.

Figure 26: The 3165-network T(p1, p2, p3) : In every solution g to it, we have that g(p1, p2) = b or g(p2, p3) = b.

Recall that 3165 has a fully universal representation (Proposition 4.10) and that the relation c ∪ Id is an equivalence relation.

Proposition 5.25. NSP(3165) is NP-complete.

Proof. The proof is similar to that of Proposition 5.24. Since 3165 has a fully universal representation, NSP(3165) = NCP(3165) is contained in NP. We show its NP-hardness by a reduction from the variant of SAT where each clause is of the form (x ∨ y ∨ z) or of the form (¬x ∨ ¬y). Let ϕ be an instance of this problem and let V be the set of variables occurring in ϕ. We will construct an instance (V′, f) of NCP(3165) such that (V′, f) is satisfiable if and only if ϕ is satisfiable.

Consider the 3165-networks E(x0, x1, y0, y1), S(p1, p2, p3, p4, q1, q2, q3), and T(p1, p2, p3), which are depicted in Figure 24, Figure 25, and Figure 26, respectively.

For every variable x ∈ V, we add two fresh variables x0 and x1 to V′.

For each clause of the form (x ∨ y ∨ z), we add seven fresh variables p1, p2, p3, p4, q1, q2, q3 to V′ and impose the constraints of E(x0, x1, p1, q1), E(y0, y1, p2, q2), E(z0, z1, p3, q3) and S(p1, p2, p3, p4, q1, q2, q3) on f.

For each clause of the form (¬x ∨ ¬y), we add three fresh variables p1, p2, p3 to V′ and impose the constraints of E(x0, x1, p1, p2), E(y0, y1, p2, p3) and T(p1, p2, p3) on f.

It follows immediately from the observations about the gadget networks above that if a function g is a solution to (V′, f), then the function s : V → {0, 1} defined by s(x) = 0 if g(x0, x1) = b and s(x) = 1 if g(x0, x1) = c is a solution to ϕ. Conversely, if s : V → {0, 1} is a solution to ϕ, then it is easy to see that the partial function g defined by g(x0, x1) = b if s(x) = 0 and g(x0, x1) = c if s(x) = 1 can be extended to a solution to (V′, f).

5.8 Hardness from Promise Constraint Satisfaction Problems

In this section, we introduce a new technique for showing NP-hardness of the NSP based on a recent hardness result from the area of promise constraint satisfaction problems [BKO19].

Proposition 5.26. Let A be a representable finite relation algebra with two symmetric atoms p, q such that (p, p, p) and (q, q, q) are forbidden and (p, q, q) is an allowed triple. Then NSP(A) is NP-hard.

Proof. We will reduce PCSP(K3, K5), which is known to be NP-hard [BKO19, Theorem 6.5], to NSP(A). Its instances are undirected graphs which are either 3-colorable or not even 5-colorable, and the problem is to decide which of these two cases apply. So let G = (V; E) be an instance of this problem. We construct the following A-network (V, f) :

• For every x ∈ V, we set f(x, x) = Id.

• For every edge (x, y) ∈ E, we set f(x, y) = p ∪ q.

• For all remaining pairs of distinct vertices (x, y), we set f(x, y) = p ∪ q ∪ Id.

Let B be a representation of A. Since (p, q, q) is an allowed triple, there are elements w1, w2, w3 ∈ B such that (w1, w2) ∈ pB, (w2, w3) ∈ qB and (w3, w1) ∈ qB. If G is 3-colorable, then there is a mapping c : V → {1, 2, 3} witnessing its 3-colorability. It is easy to see that s : x → wc(x) satisfies (V, f) in B. If G is not even 5-colorable, then any solution to (V, f) has at least six elements. Since R(3, 3) = 6, this solution has to contain either the triple (p, p, p) or the triple (q, q, q), which is a contradiction, so (V, f) is not satisfiable in this case.

Recall that both 5165 and 5665 are representable, but do not have a fully universal representation (Sections 4.7.2 and 4.7.3).

Corollary 5.27. NSP(5165) is NP-complete and NSP(5665) is NP-hard.

Proof. Both 5165 and 5665 are representable (Proposition 4.25 and Proposition 4.26) and the two atoms p := a and q := c satisfy the condition of Proposition 5.26. It follows that both problems are NP-hard.

By Proposition 4.25, the algebra 5165 has a finitely bounded universal representation and thus, by Lemma 3.5, NSP(5165) is in NP.

Remark 5.28. Proposition 5.26 also shows that the NSP for each of the algebras 17, 57, 165, 265, 565, 1065, 1265, 1565, 1665, 1765, 3965, 5565, 6265, and 6365 is NP-hard (which was already established earlier), since each of them is representable and has two atoms satisfying the condition of Proposition 5.26.

6 Tractable Algebras with at most 4 Atoms

In this section we present polynomial-time algorithms for the network satisfaction problem for all the remaining integral relation algebras with at most four atoms.

6.1 Tractability from the Atom Structure

A polynomial-time reduction of NSP(A) to the CSP of the atom structure (Definition 3.14) has been presented in Proposition 3.15; we can then use the complexity classification of the CSPs of finite conservative structures (Theorem 2.11). In this section we apply this technique to concrete relation algebras; we proceed in the order of increasing difficulty. The polynomial-time tractability result from Theorem 2.11 will be used to study the NSP mostly via the following lemma.

Lemma 6.1. Let A be a relation algebra with a fully universal representation and atom structure A0. If A0 has a polymorphism f which is binary symmetric or a ternary weak near unanimity operation, then NSP(A) is in P.

Proof. Since A0 is conservative, every ternary WNU polymorphism restricted to two elements is either a majority or a minority operation. Hence, Theorem 2.11 implies that CSP(A0) is in P. Proposition 3.15 implies that NSP(A) is in P as well.

12, 22 Id a Id Id a a a a 47, 77 Id a b Id Id a b a a a b b b b b

865, 1465 Id a b c Id Id a b c a a a b c b b b b c c c c c c 2065 Id a b c Id Id a b c a a a a a b b a b c c c a c c 5365, 6165, 6565 Id a b c Id Id a b c a a a a a b b a b c c c a c c

Figure 27: Binary symmetric polymorphisms of the atom structures for the relation algebras 12, 22, 47, 77, 865, 1465, 2065, 5365, 6165, and 6565.

Proposition 6.2. Let A ∈ {12, 22, 47, 77, 865, 1465, 2065, 5365, 6165, 6565}. Then NSP(A) is in P.

Proof. In Figure 27 we present binary symmetric polymorphisms of A0. The statement therefore follows from Lemma 6.1.

The relation algebras 33 and 3737 are trivial in the sense that they do not have any forbidden triples of non-identity atoms; all of their non-identity atoms are flexible. It follows that all atomic 33- and 3737-networks which do not contain a triple of the form (Id, Id, x) or (Id, x, y) for x, y ∈ A0\{Id} and x = y are satisfiable. This can be checked in polynomial-time, e.g., by the Path Consistency Algorithm. For completeness reasons, we nevertheless give ternary weak near unanimity polymorphisms of their respective atom structures:

Proposition 6.3. Let A ∈ {33, 3737}. Then NSP(A) is P.

Proof. Let f : A30 → A0 be the operation6 defined by

6For 33, this construction is from [Knä18, Proposition 5.10].

• f(Id, Id, x) = f(Id, x, Id) = f(x, Id, Id) = x for all x ∈ A0,

• f(x, x, y) = f(x, y, x) = f(y, x, x) = x for all x, y ∈ A0\{Id},

• f(Id, x, y) = f(y, Id, x) = f(x, y, Id) = x for all x, y ∈ A0\{Id} and,

• in the case of 3737, f(r, ˘r, a) = f(a, r, ˘r) = f(˘r, a, r) = f(˘r, r, a) = f(r, a, ˘r) = f(a, ˘r, r) = a.

It is then easy to verify that f preserves all the relations of the atom structure; by definition, it is a weak near unanimity operation and hence the statement follows from Lemma 6.1.

The normal representation B of 37 has the property that aB ∪ IdB is an equivalence relation with infinitely many classes of size two.

Proposition 6.4 ([BMPP19]). Let B be the normal representation of 37. Then the atom structure A0 has a ternary polymorphism h which satisfies h(b, ·, ·) = h(·, b, ·) = h(·, ·, b) = b and which satisfies h(x, x, y) = h(x, y, x) = h(y, x, x) = y for all x, y ∈ {a, Id}.

Corollary 6.5. NSP(37) is in P.

Proof. Note that the operation h specified in Proposition 6.4 satisfies the conditions from Lemma 6.1 which shows that NSP(37) is in P.

The normal representation B of 765 has the property that aB ∪ IdB is an equivalence relation with infinitely many classes of size two. Moreover, aB ∪ bB ∪ IdB is an equivalence relation with infinitely many classes of infinite size.

Proposition 6.6. NSP(765) is in P.

Proof. Let h be the ternary operation on the atom structure A0 of 765 which satisfies h(c, ·, ·) = h(·, c, ·) = h(·, ·, c) = c and fulfils on A0\{c} the condition specified in Proposition 6.4. By considering all cases, it is easy to see that h is a near unanimity polymorphism of the atom structure of 765. Thus, Lemma 6.1 shows that NSP(765) is in P.

The relation algebra 537 has a normal representation, namely (T; r)[Ka2].

Proposition 6.7. NSP(537) is in P.

Proof. Let f be the following ternary operation on the atom structure A0 of 537 :

• f is a minority operation on the edges {a, Id}, {r, ˘r},

• f(x, y, z) = r if r ∈ {x, y, z} ⊆ {a, r, Id},

• f(x, y, z) = ˘r if ˘r ∈ {x, y, z} ⊆ {a, ˘r, Id}, and

• f(˘d, d, z) = f(˘d, z, d) = f(z, ˘d, d) = d for d ∈ {r, ˘r} and z ∈ {a, Id}.

One can confirm that f is a weak near unanimity polymorphism of A0. Thus, Lemma 6.1 shows that NSP(537) is in P.

The relation algebra 637 has the normal representation (T; r)[Kaω]. The relation algebra 2237 has the equivalence relation a. The consistent atomic 2237-networks can be seen as oriented graphs that do not embed the oriented graph ({0, 1, 2}; {(0, 1)}); this algebra has a normal representation too. The polymorphism given in the proof of the next proposition is similar to the one above.

Proposition 6.8. NSP(637) and NSP(2237) are in P.

Proof. Let f be the function defined as in Proposition 6.7 with the exception that (a, a, Id), (a, Id, a), and (Id, a, a) are mapped to a instead of Id. One can confirm that f is a weak near unanimity polymorphism of the atom structures of both 637 and 2237. Thus, Lemma 6.1 shows that NSP(637) and NSP(2237) are in P.

The relation algebra 1237 has a normal representation, namely Kaω[T].

Proposition 6.9. NSP(1237) is in P.

Proof. Let f be the ternary operation on the atom structure A0 of 1237 which satisfies

• f(Id, Id, Id) = Id,

• f(x, y, z) = a if a ∈ {x, y, z},

• f is a minority operation on the edge {r, ˘r},

• f(˘d, d, Id) = f(˘d, Id, d) = f(Id, ˘d, d) = d for d ∈ {r, ˘r}, and

• f(x, y, z) = d if {x, y, z} = {d, Id} for d ∈ {r, ˘r}.

Then f is a weak near unanimity polymorphism of the atom structure of 1237. Thus, Lemma 6.1 shows that NSP(1237) is in P.

The relation algebra 1965 has the equivalence relation b ∪ Id with infinitely many classes of size two. Since also the triple (a, b, c) is forbidden, it is easy to see that the normal representation of 1965 is the cycle product representation Rc,a[Kb2].

Proposition 6.10. NSP(1965) is in P.

Proof. Let f be the ternary operation on the atom structure A0 of 1965 such that

• f(x, y, z) = a if a ∈ {x, y, z},

• f is a minority operation on the edge {b, Id}, and

• f(x, y, z) = c otherwise.

Then f is a weak near unanimity polymorphism of the atom structure of 1965. Thus, Lemma 6.1 shows that NSP(1965) is in P.

Remark 6.11. We mention (without proof) that the CSP of the atom structure of every relation algebra with at most four atoms not mentioned in this section is NP-complete. To check this we used a computer program to verify the conditions given in Theorem 2.11.

6.2 Tractability via Path Consistency

In this section we prove that the network satisfaction problem for the algebras 137, 237, and 837 can be solved by the path consistency procedure (Section 3.2), and hence are polynomial-time tractable.

Let N = (V, f) be an A-network. Recall from Remark 3.12 that if the path consistency procedure returns ‘unsatisfiable’, then N is unsatisfiable. We may therefore suppose that f(u, v) = 0 for all u, v ∈ V and that N is path consistent.

Remark 6.12. Note that if u, v ∈ V are such that f(u, v) = Id, then f(u, w) = f(v, w) for every other w ∈ V; we may therefore replace all occurrences of v by u and remove v from the instance. The resulting network is still path consistent. We may thus assume that f(u, v) = Id for all u, v.

We already discussed a certain equivalence relation which arises in 2-cycle products of relation algebras in Remark 2.45. It inspires the following lemma which provides useful structural information about networks which are path consistent.

Lemma 6.13. Let A and B be two finite integral relation algebras such that A0 ∩ B0 = {Id}. Then for every A[B]-network N = (V, f) which is path consistent it holds that

u ∼ v : ⇐⇒ f(u, v) ≤ 1A

is an equivalence relation on V2. Moreover, if u, v ∈ C1 and x, y ∈ C2 are in two distinct equivalence classes and c ≤ f(u, x) for some Id = c ∈ B0, then c ≤ f(v, y).

Proof. It is clear that ∼ is an equivalence relation. We first show that c ≤ f(u, y). We point out that for all α ∈ A and β ∈ B we have c ≤ α ◦ β if and only if c ≤ β. By the path consistency algorithm we have

f(y, u) ≤ f(y, x) ◦ f(x, u) ≤ a∈A0 a ◦ a≤f(x,u) a∈A0 a ∪ b≤f(x,u) b∈B0 b

So we have ˘c ≤ f(y, u) if and only if

˘c ≤ b≤f(x,u) b∈B0 b.

But this is false by assumption. So ˘c ≤ f(y, u) and therefore c ≤ f(u, y). Similarly, one can show that c ≤ f(v, y).

The relation algebra 137 has a normal representation, namely Q[Ka2].

Proposition 6.14. Path Consistency solves NSP(137).

Proof. Let N = (V, f) be a path-consistent 137-network such that f(x, y) = 0 for all x, y ∈ V. Since 137 has a fully universal representation, it suffices to show that N has a solution (V, g) when viewed as an instance of NCP(137). By Remark 6.12 we may assume that f(x, y) = Id for all x, y ∈ V.

First, observe the set of all pairs (u, v) ∈ V2 such that f(u, v) ≤ a ∪ Id is an equivalence relation, which we denote by ∼. For each equivalence class C, we consider the subinstance (C, f|C2), which can be viewed as an instance of NSP(12). Since 12 can be solved by PC, and N is path consistent, each of these subinstances has a solution gC.

We want to extend these solutions to the whole network. Let u, v ∈ V be from different classes. If f(u, v) = 1 for all such u and v, then

we may pick any linear order on the components and define g(u, v) := r if the component of u is smaller than the component of v with respect to this order. So assume there are u and v such that f(u, v) = 1. We set g(u, v) := r for all u, v such that f(u, v) ≤ a ∪ r ∪ Id. Since f(u, v) = f(v, u)˘, the assignment is well-defined. By Lemma 6.13, if u, v ∈ C1 and x, y ∈ C2 are in two distinct equivalence classes of ∼, then f(u, x) = f(v, y).

We define a partial order on the classes of ∼ by setting C1 ≤ C2 if there exists u ∈ C1 and v ∈ C2 such that g(u, v) = r. To see that this relation is transitive, suppose that g(u, v) = r and g(v, w) = r. Then, since the network is path consistent, we have

f(u, w) ≤ f(u, v) ◦ f(v, w)

hence, we already assigned g(u, w) = r.

For the remaining pairs (u, v) ∈ V2 where f(u, v) is not yet an atom, we have r ∪ ˘r ≤ f(u, v). Hence, we can arbitrarily extend the partial order on the classes to a total order, and set g(u, v) := r if the component of u is smaller than the component of v with respect to this order. The resulting atomic network (V, g) is a solution of (V, f).

The relation algebra 237 has a normal representation, namely Q[Kaω].

Proposition 6.15. Path Consistency solves NSP(237).

Proof. The proof is almost the same as for Proposition 6.14, with the only difference that we view the equivalence classes of a ∪ Id as instances of NSP(22) instead of NSP(12).

The relation algebra 837 has a normal representation, namely Kaω[Q].

Proposition 6.16. Path Consistency solves NSP(837).

Proof. Let N = (V, f) be an 837-network which is path consistent such that f(x, y) / ∈ {0, Id}.

Observe that the set of all pairs u, v such that f(u, v) ≤ r ∪ ˘r ∪ Id form an equivalence relation. On each equivalence class C, we create an instance of NCP(13) on the 13-network (C, f|C2). If for some class C the resulting instance of NCP(13) is unsatisfiable, then N is unsatisfiable as well. Otherwise, for each equivalence class C the subnetwork (C, f|C2) has a solution gC. For all u, v ∈ V in different equivalence classes we have a ≤ f(u, v). We define g : V2 → V as the common extension of all the functions gC such that g(u, v) := a if u and v are from distinct components. Then (V, g) is a solution for N.

6.3 Divide and Conquer Algorithms

In this section, we prove that NSP(2465) and NSP(1737) are in P. The algorithms we present are similar in spirit to a known algorithm for NSP(1337) ([BK02, BK07]).

Remark 6.17. The network satisfaction problem for 1337 cannot be solved by Datalog (this can be seen from the techniques in [Bod21, Section 8.6]), and hence in particular not by the path consistency procedure, but it can be expressed in fixed point logic and hence is in P [Bod21]. It thus solves Problem 1 of Hirsch and Cristiani [CH04]: ‘Find a (finite) relation algebra A with no universal representation7 but where the complexity of NSP(A) is polynomial.’ The existence of problems whose complement is closed under homomorphisms and that are in fixed point logic, but not in Datalog, is one of the main results of [DK08]).

7Hirsch and Cristiani [CH04] call a representation B of a finite relation algebra A universal if every consistent A-network with f(x, y) = 0 for all vertices x, y is satisfiable in B. Note that this definition differs from our usage.

6.3.1 The Relation Algebra 2465

We need the following facts about consistent atomic 2465-networks (V, f). If d ∈ {a, b, c}, let Gd be the graph Gd := (V; {(x, y) | f(x, y) ∈ {d, Id}}). The following is straightforward.

Lemma 6.18. Let (V, f) be a consistent atomic 2465-network. If C1 and C2 are different connected components of Gd, for some d ∈ {a, b, c}, then f is constant on all pairs (x, y) for x ∈ C1 and y ∈ C2.

The following lemma is due to Sebastian Meyer (personal communication).

Lemma 6.19. Let (V, f) be a consistent atomic 2465-network such that the image of f is not {Id}. Then at least one of the graphs Ga, Gb, and Gc is disconnected.

Proof. By induction on |V|. If |V| = 1 then the image of f must be {Id}, so suppose that |V| ≥ 2. The case |V| = 2 is clear. For the case that |V| ≥ 3, suppose for contradiction that all of Ga, Gb, and Gc are connected. Let x ∈ V. By the inductive assumption there exists d ∈ {a, b, c} such that the graph Gd\{x} is disconnected. We may assume without loss of generality that d = a and that U1, . . . , Uk, for k ≥ 2, are the connected components of Ga\{x}. For each Ui, i ∈ {1, . . . , k}, we may choose ui ∈ Ui such that f(x, ui) = a, because Ga is connected. Moreover, there exists vb ∈ V \ {x} such that f(x, vb) = b, because Gb is connected; similarly, there exists vc ∈ V \ {x} such that f(x, vc) = c.

There are the following two cases to consider:

• vb, vc ∈ Ui, for some i ∈ {1, . . . , k}. Let j ∈ {1, . . . , k} \ {i}. If f(vb, uj) = c, then {x, vb, uj} induces a rainbow. Otherwise, f(vb, uj) = b, and then f(vc, uj) = b by Lemma 6.18. In this case, {x, vc, uj} induces a rainbow.

• vb ∈ Ui and vc ∈ Uj, for distinct i, j ∈ {1, . . . , k}. If f(vb, vc) = b, then f(ui, vc) = b by Lemma 6.18. Then {x, ui, vc} induces a rainbow. Otherwise, f(vb, vc) = c; this case can be treated similarly.

Note that all relations of the relation algebra 2465 can be generated from the following relations: Id = a ∪ b ∪ c and Rd := (d ∪ Id) for d ∈ {a, b, c}. For example, a = Rb ◦ Rc. Similarly we can obtain b and c. We can then obtain all others by appropriately intersecting the ones that we already have. It therefore suffices to present an algorithm for the NSP restricted to networks with the relations R := {Ra, Rb, Rc, Id, Id, 1} (see Remark 3.11).

Definition 6.20. Let (V, g) be a 2465-network such that the image of g is contained in R and let d ∈ {a, b, c}. A d-cut of (V, g) is a partition of V into k ≥ 2 disjoint sets C1, . . . , Ck such that if g(x, y) ∈ {Rd, Id}, then x and y must lie in the same part. A d-cut is valid if for all distinct i, j ∈ {1, . . . , k} there exists di,j ∈ {a, b, c} \ {d} such that di,j ≤ g(u, x) for all u ∈ Ci and x ∈ Cj.

Definition 6.21. A non-identity solution to an A-network (V, g) is a solution (V, f) such that there are x, y ∈ V with f(x, y) = Id.

Lemma 6.22. Let (V, g) be a 2465-network such that (V, g) has a non-identity solution and the image of g is contained in R. Then there is a valid d-cut in (V, g) for some d ∈ {a, b, c}.

Proof. Let (V, f) be a non-identity solution of (V, g). By Lemma 6.19, there exists d ∈ {a, b, c} such that Gd is disconnected. Let C1, . . . , Ck ⊆ V be the connected components of Gd. Clearly, it is a d-cut of (V, g). Lemma 6.18 implies that it is valid.

Note that the condition from Lemma 6.22 can be checked in polynomial time: to check whether (V, g) has a valid d-cut, we first compute the connected components of the graph (V; {(x, y) | g(x, y) ∈ {Rd, Id}} (e.g., via depth-first search). If the connected components provide a valid d-cut we are done. Otherwise, there exist two components Ci and Cj that witness that the cut is not valid. In this case, we merge Ci and Cj into one component. If the resulting d-cut is valid, we are done. Otherwise, we repeat contracting components. If the procedure ends up with a single component, then there does not exist a valid d-cut.

Proposition 6.23. NSP(2465) is in P.

Proof. Let (V, g) be a given 2465-network. As we have explained earlier, we may assume without loss of generality that the image of g is contained in R.

1. If there is no pair of variables labelled Id, then answer ‘satisfiable’ (we may map all of V to the same point in a representation of 2465).

2. Otherwise, if for every d ∈ {a, b, c} there is no valid d-cut in (V, g) return ‘unsatisfiable’ (there is no solution by Lemma 6.22).

3. Otherwise, let C1, . . . , Ck be a valid d-cut in (V, g), for some d ∈ {a, b, c}, and recursively solve the subinstances induced on each of C1, . . . , Ck.

4. If a recursive call returns ‘unsatisfiable’, then return ‘unsatisfiable’.

5. Otherwise, return ‘satisfiable’ (a consistent atomic network (V, f) with f(x, y) ≤ g(x, y) for all x, y ∈ V can be obtained from solutions for C1, . . . , Ck by setting f(x, y) := di,j for every x ∈ Ci and y ∈ Cj with i = j).

The proof that this algorithm is correct follows by induction on the number of variables of the instance. The running time is in O(n2) if n is the size of the input.

6.3.2 The Relation Algebra 1737

We now present a polynomial-time algorithm for NSP(1737) (note that 1737 has no fully universal representation by Lemma 4.18, and so this problem is different from NCP(1737)). Recall from Section 4.7.1 that the consistent atomic 1737-networks can be represented as oriented graphs that do not contain P2 = ({0, 1, 2}, {(0, 1), (1, 2)}) as an induced subgraph.

We need a structural result about such graphs proved by Bang-Jensen and Huang [BJH95]; they obtain even more general results for directed graphs, but we only need and only state their result for oriented graphs (i.e., the special case of directed graphs without directed cycles of length two). If G = (V; E) is an oriented graph, then G denotes the undirected graph

G := (V, {(x, y) | (x, y) / ∈ E, (y, x) / ∈ E}).

Theorem 6.24 ([BJH95, Theorem 3.5]). Let G be an oriented graph with no induced P2. If G is not strongly connected, then it is obtained from a transitive oriented graph by substituting its vertices with strongly connected oriented graphs with no induced P2. If G is strongly connected, then it is obtained from a strongly connected tournament by substituting its vertices with not strongly connected oriented graphs with no induced P2.

Lemma 6.25 ([BJH95, Lemma 3.4]). Let G be an oriented graph with no induced P2. If G is strongly connected then G is not connected, and between each pair of components of G all edges in G go in the same direction.

The following is an easy consequence of these results.

Theorem 6.26. Let G be an oriented graph with no induced P2 with at least two vertices.

• If G is not strongly connected then it is obtained from a transitive oriented graph by substituting its vertices by strongly connected oriented graphs with no induced P2.

• If G is strongly connected then G is not connected, and G is obtained from a (strongly connected) tournament by substituting its vertices by oriented graphs C1, . . . , Ck such that each Ck contains no induced P2 and each Ck is connected.

Proof. If G = (V; E) is not strongly connected then this is exactly what Theorem 6.24 tells us. If G is strongly connected then G is not connected by Lemma 6.25. Let A and B be two distinct connected components of G. By Lemma 6.25, A × B is contained in E(G), or B × A is contained in E(G). Consequently, after contracting each connected component of G (which correspond to Ck) to a vertex, we obtain a tournament. Since G is strongly connected, the tournament needs to be strongly connected as well.

By Lemma 4.18, the induced a-path on 4 vertices is not satisfiable. Consequently, the satisfiable atomic 1737-network do not contain long induced a-paths, which has strong structural consequences which we now explain.

Partially ordered sets (posets) (V; E) that do not contain distinct elements u, v, a, b such that (u, v), (a, v), (a, b) ∈ E and all other pairs of distinct elements from {u, v, a, b} are not in E, are called N-free. It is well-known that a poset is N-free if and only if it is series-parallel, i.e., is contained in the smallest class C of posets that contains the one-element poset, is closed under isomorphism, and is closed under the following two operations [VTL82]: if (V1; E1), (V2; E2) ∈ C are such that V1 ∩ V2 = ∅, then C also contains

• (V1 ∪ V2; E1 ∪ E2 ∪ V1 × V2) (series composition), and

• (V1 ∪ V2; E1 ∪ E2) (parallel composition).

Observe that 1737 is generated by the three relations Rr := r ∪ Id, Ra := a ∪ Id, and Id. It therefore suffices to present an algorithm for the NSP restricted to networks from R := {Rr, Ra, Id, Id, 1} (see Remark 3.11). If (V, f) is a 1737-network such that the image of f is contained in R, then we define the following two graphs:

• G := (V; {(x, y) | f(x, y) ∈ {Rr, Id}}) and

• H := (V; {(x, y), (y, x) | f(x, y) ∈ {Ra, Id}}).

Definition 6.27. Let (V, g) be a 1737-network such that the image of g is contained in R. An a-cut is a partition of V into k ≥ 2 disjoint sets C1, . . . , Ck such that

• each Ci, for 1 ≤ i ≤ k, is a union of connected components of H, and

• for all distinct i, j ∈ {1, . . . , k} there exists di,j ∈ {r, ˘r} such that di,j ≤ g(x, y) for all x ∈ Ci and y ∈ Cj.

Note that, given a 1737-network (V, g) such that the image of g is contained in R, one can in polynomial time either find an a-cut, or correctly say that it does not exist. To do this, we will keep a partition C of V such that each part is a union of connected components of H. We start by computing the connected components of H and partitioning V to these components. Then, while there are some distinct C, C′ ∈ C with no d ∈ {r, ˘r} such that d ≤ g(x, y) for all x ∈ C and y ∈ C′, we merge C and C′. This procedure either finds an a-cut, or ends up with C = {V}, in which case it is easy to see by induction that all merges were necessary and thus there is no a-cut.

Definition 6.28. Let (V, g) be a 1737-network such that the image of g is contained in R. Let C1, C2 be a partition of V into two non-empty disjoint sets such that for all i ∈ {1, 2} it holds that Ci is a union of strongly connected components of G, and there is d ∈ {r, ˘r, a} such that d ≤ g(x, y) for all x ∈ C1 and y ∈ C2. We say that C1, C2 is an s-cut if d = r, and it is a p-cut if d = a.

Similarly as above, there are polynomial-time algorithms which, given a 1737-network (V, g) such that the image of g is contained in R, either find a p-cut or an s-cut, or correctly say that such a cut does not exist. Both of these algorithms start by computing the strongly connected components D1, . . . , Dk of G.

The algorithm for p-cuts then puts C = D1, and while there are x ∈ C and y ∈ Dj for some j such that y ∈ V \ C and there is an edge between x and y in G, it adds Dj to C. If, after the loop finishes, C = V, then the algorithm puts C1 = C and C2 = V \ C. Otherwise, it returns that there is no p-cut. It is easy to see that both answers are correct.

The algorithm for s-cuts first puts C to be the union of all components Di for which there are no x ∈ Di and y ∈ V \ Di with (y, x) being an edge of G and then, while there are x ∈ C and y ∈ Dj for some j such that y / ∈ C and (y, x) is an edge of G or an edge of H, it adds Dj to C. If, after the loop finishes, C = V, then the algorithm puts C1 = C and C2 = V \ C. Otherwise, it returns that there is no s-cut. It is easy to see that both answers are correct.

Lemma 6.29. Every 1737-network (V, g) with a satisfiable non-identity solution (V, f) (Definition 6.21) such that the image of g is contained in R has an a-cut, a p-cut, or an s-cut.

Proof. Note that the set of pairs x, y such that f(x, y) = Id forms an equivalence relation. Let V′ be the set of its equivalence classes (we will use [x] to denote the equivalence class of x). Then G′ = (V′, {([x], [y]) | f(x, y) = r}) is an oriented graph with at least two vertices (since the image of f is not {Id}) and with no induced P2 and no induced a-path on 4 vertices (since (V, f) is satisfiable atomic). By Theorem 6.26, either G′ is not strongly connected, or G′ is not connected.

If G′ is not connected, let C′1, . . . , C′k be the connected components of G′ and, for each i ∈ {1, . . . , k}, let Ci consist of those x ∈ V such that there is [y] ∈ C′i with f(x, y) = Id. We will show that C1, . . . , Ck is an a-cut of (V, g): First observe that if x and y are in the same connected component of H, then [x] and [y] are in the same connected component of G′, and thus each Ci is a union of connected components of H. Next, from Theorem 6.26 we know that G′ is obtained from a tournament T on vertex set {1, . . . , k} by substituting vertex i by the elements of C′i for all i ∈ {1, . . . , k} (Theorem 6.26 does not explicitly promise that we are substituting exactly by the graphs C′i, but it promises that the graphs we are substituting by are connected in the “non-edge” relation, and the only possibility is that these are the graphs C′i). Put

di,j = r if (i, j) is an edge of T, and ˘r otherwise.

Since T is a tournament, this is well-defined. By definition of substitution we have f(x, y) = di,j for all x ∈ Ci and y ∈ Cj for all i = j ∈ {1, . . . , k}. Since f(x, y) ≤ g(x, y) for all x, y ∈ V, and since T is a tournament, it follows that C1, . . . , Ck is indeed an a-cut.

So G′ is not strongly connected. Let C′1, . . . , C′k be the strongly connected components of G′. By Theorem 6.26 we know that there is a transitive oriented graph T with vertex set {1, . . . , k} such that G′ is obtained from T by substituting vertex i by C′i for every i ∈ {1, . . . , k}. Moreover, since (V, f) is satisfiable atomic, it contains no induced a-path on 4 vertices, and so G′, and thus also T, are N-free. Hence, by the fact mentioned above, the poset obtained from T by adding all the loops is series-parallel. Consequently, one can split T into disjoint non-empty sets T1, T2 such that either there is an oriented edge from every member of T1 into every member of T2 (series composition), or there are no edges between T1 and T2 at all (parallel composition).

Let C1 be the set of all x ∈ V for which there is i ∈ T1 and [y] ∈ C′i with f(x, y) = Id, and put C2 = V \ C1. Observe that both C1 and C2 are non-empty and that they are unions of strongly connected components of G (as if x and y are in the same strongly connected component of G, then [x] and [y] are in the same strongly connected component of G′). It is then easy to see that C1, C2 is an s- or p-cut (based on whether there are edges between T1 and T2).

Theorem 6.30. NSP(1737) is in P.

Proof. Let (V, g) be a given 1737-network. As we have explained earlier, we may assume without loss of generality that the image of g is contained in R.

1. If there is no pair of variables labelled Id, then answer ‘satisfiable’ (we may map all of V to the same point in a representation of 1737).

2. Otherwise, if there is no a-cut, no s-cut, and no p-cut in (V, g), return ‘unsatisfiable’.

3. If there is an e-cut C1, . . . , Ck, for e ∈ {a, s, p}, recursively solve the subinstances induced on each of C1, . . . , Ck.

4. If a recursive call returns ‘unsatisfiable’, then return ‘unsatisfiable’.

5. Otherwise, return ‘satisfiable’.

We prove the correctness of the algorithm by induction over the recursion tree of the recursive procedure. Clearly, if the algorithm answers ‘satisfiable’ in Step 1, this answer is correct. If the algorithm returns unsatisfiable in Step 2 then indeed there is no solution by Lemma 6.29. If the algorithm returns ‘unsatisfiable’ in Step 4 then this is the correct answer by the inductive assumption. The interesting part is to prove that the answer ‘satisfiable’ is correct in Step 5. For this, we construct a solution (V, f) for (V, g) from the solutions (Ci, fi) of the subnetworks induced on C1, . . . , Ck as follows:

• if u, v ∈ Ci for some i ∈ {1, . . . , k}, then f(u, v) := fi(u, v),

• otherwise u ∈ Ci and v ∈ Cj, for some distinct i, j ∈ {1, . . . , k}. In this case, put f(u, v) := di,j (see Definitions 6.27 and 6.28).

It is easy to see that if (V, f) contains a copy of P2 then this copy fully lies in (Ci, fi) for some i ∈ {1, . . . , k}. Hence, by induction, there is no copy of P2 in (V, f). Similarly, if (V, f) contains an induced a-path on 4 vertices, then all 4 vertices must lie in (Ci, fi) for some i ∈ {1, . . . , k}. Hence, (V, f) indeed witnesses that (V, g) is satisfiable.

It remains to argue that the algorithm runs in polynomial time. By a standard recursion tree analysis, it is enough to verify that one stage without including the recursive calls runs in polynomial time, and this follows from the observations that one can find a-, s-, and p-cuts in polynomial time (or determine that they do not exist).

7 Open Problems

We view our complexity dichotomy for the network satisfaction problem for relation algebras with at most 16 elements as an encouraging basis for a more general classification result without any restriction on the number of elements, at least for the finite relation algebras with a normal representation. The following other problems are also left open.

Question 7.1. Is the existence of a fully universal representation for a given finite relation algebra effectively decidable?

Problem 7.2. Obtain a similar classification for the network consistency problem.

For relation algebras with a fully universal representation, the NSP and the NCP have the same complexity. For most of the other representable algebras, the argument which we present here for the NSP can be easily adapted to the NCP, the exception being 1737. Finally, for algebras with no representation, additional efforts are required, since the NSP is trivial, whereas the NCP is generally not.

Question 7.3. What is smallest relation algebra A such that NSP(A) is not in NP?

Problem 7.4. Obtain a similar classification for the variant of the network satisfaction problem where the inputs are restricted to networks (V, f) such that the range of f consists only of atoms and 1.

8 Summary and Tables

In Tables 1–5 we present Maddux’s lists of integral relation algebras, together with references and comments about their representability and the computational complexity of their network satisfaction problem, thus summarizing the findings of our work. The first column is the numbering introduced by Maddux. The following columns are labelled by triples (omitting brackets and commas for space reasons). An entry of the table contains a triple of the form xyz if it is an allowed triple of the relation algebra, i.e., if z ≤ x ◦ y (see Section 2.3); this uniquely describes the relation algebra thanks to the cycle law (Proposition 2.23).

In the tables, we use the following abbreviations (definitions can be found in Section 2):

• none: no representation exists

• ¬f.u.: the relation algebra is representable, but there is no fully universal representation.

• f.u.: there exists a fully universal square representation, but no normal representation.

• normal (n): there exists a normal representation, but the algebra has no flexible atom. In particular, the normal representations in Table 4 correspond to homogeneous directed graphs [Che98, Lac82].

• flex: there is a flexible atom (which implies the existence of a normal representation).

In cases where the representations admit a particularly simple description, we include them explicitly in the tables; formal definitions are given at the end of Section 2.6.

In [BK20] it has been noted that in the case of 27 and 67 the claims about the complexity of the NSP from [CH04] are incorrect, and we state the corrected results.

#2 aaa Representability NSP Complexity 12 normal, Ka2 P, [CH04], Prop. 6.2 22 aaa flex, Kaω P, [CH04], Prop. 6.2

Table 1: Integral relation algebras with two atoms.

#3 rrr rr˘r Representability NSP Complexity 13 rrr normal, Q P, [VKvB89] 23 rr˘r normal, C3 NPc, [CH04], Lemma 3.9 33 rrr rr˘r flex, T P, [CH04], Prop. 6.3

Table 2: Integral asymmetric relation algebras with three atoms.

#7 aaa bbb abb baa Representability NSP Complexity 17 abb normal, Kb2[Ka2] NPc, [CH04], Lemma 3.9 27 aaa abb normal, Kb2[Kaω] NPc, [BK20], Prop. 5.9 37 bbb abb normal, Kbω[Ka2] P, [CH04], Corollary 6.5 47 aaa bbb abb normal, Kbω[Kaω] P, [CH04], Prop. 6.2 57 abb baa ¬f.u., Za,b5, Example 2.33 NPc, [CH04], Lemma 3.4 67 aaa abb baa flex, Hb,a NPc, [BK20], Prop. 5.11 77 aaa bbb abb baa flex, Ra,b P, [CH04], Prop. 6.2

Table 3: Integral symmetric relation algebras with three atoms.

References

[AM94] Hajnal Andréka and Roger D. Maddux. Representations for small relation algebras. Notre Dame Journal of Formal Logic, 35(4):550–562, 1994.

[BD13] Manuel Bodirsky and Víctor Dalmau. Datalog and constraint satisfaction with infinite templates. Journal on Computer and System Sciences, 79:79–100, 2013. A preliminary version appeared in the proceedings of the Symposium on Theoretical Aspects of Computer Science (STACS’05).

[BGP24] Manuel Bodirsky and Santiago Guzmán-Pro. Hereditary first-order model checking, 2024. Preprint available under https://arxiv.org/abs/2411.10860.

[BGP25] Manuel Bodirsky and Santiago Guzmán-Pro. The Generic Circular Triangle-Free Graph. Journal of Graph Theory, 109(4):426–445, 2025.

[BGPJ+25] Manuel Bodirsky, Santiago Guzmán-Pro, Moritz Jahn, Matěj Konečný, and Paul Winkler. Circular chromatic numbers, balanceability, relation algebras, and network satisfaction problems, 2025. Preprint available under https://arxiv.org/abs/2512.06878.

[BJ03] Mathias Broxvall and Peter Jonsson. Point algebras for temporal reasoning: Algorithms and complexity. Artificial Intelligence, 149(2):179–220, 2003.

[BJH95] Jørgen Bang-Jensen and Jing Huang. Quasi-transitive digraphs. Journal of Graph Theory, 20(2):141–161, 1995.

[BK02] Manuel Bodirsky and Martin Kutz. Pure dominance constraints. In Proceedings of the Symposium on Theoretical Aspects of Computer Science (STACS), pages 287–298, 2002.

[BK07] Manuel Bodirsky and Martin Kutz. Determining the consistency of partial tree descriptions. Artificial Intelligence, 171:185–196, 2007.

[BK09] Manuel Bodirsky and Jan Kára. The complexity of temporal constraint satisfaction problems. Journal of the ACM, 57(2):1–41, 2009. An extended abstract appeared in the Proceedings of the Symposium on Theory of Computing (STOC).

[BK20] Manuel Bodirsky and Simon Knäuer. Hardness of network satisfaction for relation algebras with normal representations. In Relational and Algebraic Methods in Computer Science, pages 31–46. Springer International Publishing, 2020.

[BK22] Manuel Bodirsky and Simon Knäuer. The complexity of network satisfaction problems for symmetric relation algebras with a flexible atom. Journal of Artificial Intelligence Research, 75, 2022.

[BK23] Manuel Bodirsky and Simon Knäuer. Network satisfaction problems solved by k-consistency. In 50th International Colloquium on Automata, Languages, and Programming, ICALP 2023, July 10-14, 2023, Paderborn, Germany, pages 116:1–116:20, 2023.

[BKO+17] Libor Barto, Michael Kompatscher, Miroslav Olšák, Trung Van Pham, and Michael Pinsker. The equivalence of two dichotomy conjectures for infinite domain constraint satisfaction problems. In Proceedings of the 32nd Annual ACM/IEEE Symposium on Logic in Computer Science – LICS’17, 2017. Preprint arXiv:1612.07551.

[BKO19] Jakub Bulín, Andrei A. Krokhin, and Jakub Opršal. Algebraic approach to promise constraint satisfaction. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, STOC 2019, Phoenix, AZ, USA, June 23-26, 2019, pages 602–613, 2019.

[BMPP19] Manuel Bodirsky, Barnaby Martin, Michael Pinsker, and András Pongrácz. Constraint satisfaction problems for reducts of homogeneous graphs. SIAM Journal on Computing, 48(4):1224–1264, 2019. A conference version appeared in the Proceedings of the 43rd International Colloquium on Automata, Languages, and Programming, ICALP 2016, pages 119:1-119:14.

[Bod18] Manuel Bodirsky. Finite relation algebras with normal representations. In Relational and Algebraic Methods in Computer Science - 17th International Conference, RAMiCS 2018, Groningen, The Netherlands, October 29 - November 1, 2018, Proceedings, pages 3–17, 2018.

[Bod21] Manuel Bodirsky. Complexity of Infinite-Domain Constraint Satisfaction. Lecture Notes in Logic (52). Cambridge University Press, Cambridge, United Kingdom; New York, NY, 2021.

[BOP18] Libor Barto, Jakub Opršal, and Michael Pinsker. The wonderland of reflections. Israel Journal of Mathematics, 223(1):363–398, 2018.

[BP11] Manuel Bodirsky and Michael Pinsker. Reducts of Ramsey structures. AMS Contemporary Mathematics (Model Theoretic Methods in Finite Combinatorics), 558:489–519, 2011.

[BP15a] Manuel Bodirsky and Michael Pinsker. Schaefer’s theorem for graphs. Journal of the ACM, 62(3):52 pages (article number 19), 2015. A conference version appeared in the Proceedings of STOC 2011, pages 655-664.

[BP15b] Manuel Bodirsky and Michael Pinsker. Topological Birkhoff. Transactions of the American Mathematical Society, 367:2527–2549, 2015.

[BP16] Libor Barto and Michael Pinsker. The algebraic dichotomy conjecture for infinite domain constraint satisfaction problems. In Proceedings of the 31st Annual IEEE Symposium on Logic in Computer Science – LICS’16, pages 615–622, 2016. Preprint arXiv:1602.04353.

[BPP21] Manuel Bodirsky, Michael Pinsker, and András Pongrácz. Projective clone homomorphisms. Journal of Symbolic Logic, 86(1):148–161, 2021.

[BS81] Stanley N. Burris and Hanamantagouda P. Sankappanavar. A Course in Universal Algebra. Springer Verlag, Berlin, 1981.

[Bul03] Andrei A. Bulatov. Tractable conservative constraint satisfaction problems. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 321–330, Ottawa, Canada, 2003.

[Bul17] Andrei A. Bulatov. A dichotomy theorem for nonuniform CSPs. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, pages 319–330, 2017.

[Cam96] Peter J. Cameron. The random graph. R. L. Graham and J. Nešetřil, Editors, The Mathematics of Paul Erdös, 1996.

[CH04] Matteo Cristiani and Robin Hirsch. The complexity of the constraint satisfaction problem for small relation algebras. Artificial Intelligence Journal, 156:177–196, 2004.

[Che87] Gregory Cherlin. Homogeneous digraphs I. The imprimitive case. Logic Colloquium 1985, 1987.

[Che98] Gregory L. Cherlin. The classification of countable homogeneous directed graphs and countable homogeneous n-tournaments. AMS Memoir, 131(621), January 1998.

[Che20] Gregory Cherlin. Homogeneous ordered graphs and metrically homogeneous graphs, 2020. Preprint.

[Com83a] Stephen Comer. Constructions of color schemes. Acta Universitatis Carolinae. Mathematica et Physica, 24, 01 1983.

[Com83b] Stephen D. Comer. Extension of polygroups by polygroups and their representations using color schemes. In Ralph S. Freese and Octavio C. Garcia, editors, Universal Algebra and Lattice Theory, pages 91–103, Berlin, Heidelberg, 1983. Springer Berlin Heidelberg.

[Com83c] Stephen D. Comer. A remark on chromatic polygroups. Congressus Numerantium, 38:85–95, 1983.

[Com84] Stephen D. Comer. Combinatorial aspects of relations. Algebra Universalis, 18(1):77–94, February 1984.

[DK08] Anuj Dawar and Stephan Kreutzer. On datalog vs. LFP. In Luca Aceto, Ivan Damgård, Leslie Ann Goldberg, Magnús M. Halldórsson, Anna Ingólfsdóttir, and Igor Walukiewicz, editors, Automata, Languages and Programming, 35th International Colloquium, ICALP 2008, Reykjavik, Iceland, July 7-11, 2008, Proceedings, Part II - Track B: Logic, Semantics, and Theory of Programming & Track C: Security and Cryptography Foundations, volume 5126 of Lecture Notes in Computer Science, pages 160–171. Springer, 2008.

[Dün05] Ivo Düntsch. Relation algebras and their application in temporal and spatial reasoning. Artificial Intelligence Review, 23:315–357, 2005.

[GG55] R. E. Greenwood and A. M. Gleason. Combinatorial relations and chromatic graphs. Canadian Journal of Mathematics, 7:1–7, 1955.

[GJ78] Michael Garey and David Johnson. A guide to NP-completeness. CSLI Press, Stanford, 1978.

[Hen72] C. Ward Henson. Countable homogeneous relational systems and categorical theories. Journal of Symbolic Logic, 37:494–500, 1972.

[HH01] R. Hirsch and I. Hodkinson. Representability is not decidable for finite relation algebras. Transactions of the American Mathematical Society, 353(4):1387–1401, 2001.

[HH02] Robin Hirsch and Ian Hodkinson. Relation Algebras by Games. North Holland, 2002.

[Hir96] Robin Hirsch. Relation algebras of intervals. Artificial Intelligence Journal, 83:1–29, 1996.

[Hir99] Robin Hirsch. A finite relation algebra with undecidable network satisfaction problem. Logic Journal of the IGPL, 7(4):547–554, 1999.

[Hod97] Wilfrid Hodges. A shorter model theory. Cambridge University Press, Cambridge, 1997.

[JT52] Bjarni Jónsson and Alfred Tarski. Boolean algebras with operators. American Journal of Mathematics, 74(1):127–162, 1952.

[Knä18] Simon Knäuer. Constraint satisfaction over the random tournament, 2018. Master Thesis at the Institute of Algebra, TU Dresden.

[Lac82] A. H. Lachlan. Finite homogeneous simple digraphs. Stud. Logic Found. Math., 107:189–208, 1982. J. Stern (Ed.), Logic Colloquium 1981.

[Lad75] Richard E. Ladner. On the structure of polynomial time reducibility. Journal of the ACM, 22(1):155–171, 1975.

[LW80] Alistair H. Lachlan and Robert E. Woodrow. Countable ultrahomogeneous undirected graphs. Transactions of the AMS, 262(1):51–94, 1980.

[Lyn50] R. Lyndon. The representation of relational algebras. Annals of Mathematics, 51(3):707–729, 1950.

[Mad06a] Roger D. Maddux. Finite symmetric integral relation algebras with no 3-cycles. In Renate A. Schmidt, editor, Relations and Kleene Algebra in Computer Science, 9th International Conference on Relational Methods in Computer Science and 4th International Workshop on Applications of Kleene Algebra, RelMiCS/AKA 2006, Manchester, UK, August 29-September 2, 2006, Proceedings, volume 4136 of Lecture Notes in Computer Science, pages 2–29. Springer, 2006.

[Mad06b] Roger Duncan Maddux. Relation Algebras: Volume 150. Studies in logic and the foundations of mathematics. Elsevier Science, London, England, May 2006.

[Mon64] Donald Monk. On representable relation algebras. Michigan Mathematical Journal, 11(3):207 – 210, 1964.

[Pos41] Emil Leon Post. The Two-Valued Iterative Systems of Mathematical Logic. H. Milford, Oxford university press, London, 1941.

[Sch78] Thomas J. Schaefer. The complexity of satisfiability problems. Proceedings of the Tenth Annual ACM Symposium on Theory of Computing, STOC 1978, San Diego, California, USA, pages 216–226, 1978.

[Tar41] Alfred Tarski. On the calculus of relations. J. Symbolic Logic, 6, 1941.

[Tar55] Alfred Tarski. Contributions to the theory of models. Koninklijke Nederlandse Akademie van Wetenschappen, Proceedings, 58:56–64, 1955.

[VKvB89] Marc Vilain, Henry Kautz, and Peter van Beek. Constraint propagation algorithms for temporal reasoning: A revised report. Readings in Qualitative Reasoning about Physical Systems, pages 373–381, 1989.

[VTL82] Jacobo Valdes, Robert E. Tarjan, and Eugene L. Lawler. The recognition of series parallel digraphs. SIAM Journal on Computing, 11(2):298–313, 1982.

[Zhu17] Dmitriy N. Zhuk. A proof of CSP dichotomy conjecture. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, pages 331–342, 2017. https://arxiv.org/abs/1704.01914.

[Zhu20] Dmitriy Zhuk. A proof of the CSP dichotomy conjecture. J. ACM, 67(5):30:1–30:78, 2020.

[Zie23] Paul-Hermann Zieschang. Hypergroups. Springer, 2023.