Feder and Vardi in their groundbreaking work  formulated the famous dichotomy conjecture for finite-domain constraint satisfaction problems, which has recently been resolved [12, 27]. Their motivation to study finite-domain CSPs was the question which fragments of existential second-order logic might exhibit a complexity dichotomy in the sense that every problem that can be expressed in the fragment is either in P or NP-complete. Existential second-order logic without any restriction is known to capture NP  and hence does not have a complexity dichotomy by an old result of Ladner . Feder and Vardi proved that even the fragments of monadic SNP and monotone SNP do not have a complexity dichotomy since every problem in NP is polynomial-time equivalent to a problem that can be expressed in these fragments. However, the dichotomy for finite-domain CSPs implies that monotone monadic SNP (MMSNP) has a dichotomy, too [16, 24].
MMSNP is also known to have a tight connection to a certain class of infinite-domain CSPs : an MMSNP sentence is equivalent to a connected MMSNP sentence if and only if it describes an infinite-domain CSP. Moreover, every problem in MMSNP is equivalent to a finite disjunction of connected MMSNP sentences. The infinite structures that appear in this connection are tame from a model-theoretic perspective: they are reducts of finitely bounded homogeneous structures (see Section 4.1). CSPs for such structures are believed to have a complexity dichotomy, too; there is even a known hardness condition such that all other CSPs in the class are conjectured to be in P . The hardness condition can be expressed in several equivalent forms [2, 1].
In this paper we investigate a candidate for a logic that still has a complexity dichotomy and whose expressive power is strictly larger than connected MMSNP. Our minimum requirement for what constitutes a logic is relatively liberal: we require that the syntax of the logic should be decidable. The same requirement has been made for the question whether there exists a logic that captures the class of polynomial-time problems (see, e.g., [21, 20]). The idea of our logic is to modify monotone SNP so that only CSPs for model-theoretically tame structures can be expressed in the logic; the challenge is to come up with a definition of such a logic which has a decidable syntax. We would like to require that the (universal) first-order part of a monotone SNP sentence describes an amalgamation class. We mention that the Joint Embedding Property (JEP), which follows from the Amalgamation Property (AP), has recently be shown to be undecidable . In contrast, we show that the AP is decidable (Section 5). For binary signatures and classes of finite structures described by forbidding finitely many induced substructures, this was a folklore fact in model theory. We use the so-called dual encoding, which originates from constraint satisfaction and is now also well-known in universal algebra, to reduce the general problem of deciding the AP to the binary case. The fact that the AP is decidable for classes described by finitely many forbidden substructures should be of independent interest in model theory.
We call our new logic Amalgamation Monotone SNP (AMSNP). This logic contains connected MMSNP; it also contains the more expressive logic of (connected) guarded monotone SNP, a logic introduced in the context of knowledge representation  (see Section 6). Every problem that can be expressed in AMSNP is a CSP for some countably infinite -categorical structure . In Section 7 we present an example application of this fact: every problem that can be expressed in AMSNP can be solved in polynomial time on instances of bounded treewidth.
2 Constraint Satisfaction Problems
Let be structures with a finite relational signature ; each symbol is equipped with an arity . A function is called a homomorphism from to if for every and we have ; in this case we write . We write for the class of all finite -structures such that .
If is the 3-clique, i.e., the complete undirected graph with three vertices, then is the graph 3-colouring problem, which is NP-complete .
If then is the digraph acyclicity problem, which is in P.
If for then is the Betweenness problem, which is NP-complete .
The union of two -structures is the -structure with domain and the relation for every . The intersection is defined analogously. A disjoint union of and is the union of isomorphic copies of and with disjoint domains. As disjoint unions are unique up to isomorphism, we usually speak of the disjoint union of and , and denote it by . A structure is connected if it cannot be written as a disjoint union of at least two structures with non-empty domain. A class of structures is closed under inverse homomorphisms if whenever and homomorphically maps to we have . If is a finite relational signature, then it is well-known and easy to see  that for a countably infinite -structure if and only if is closed under inverse homomorphisms and disjoint unions.
3 Monotone SNP
Let be a finite relational signature, i.e., is a set of relation symbols , each equipped with an arity . An SNP (-) sentence is an existential second-order (-) sentence with a universal first-order part, i.e., a sentence of the form
where is a quantifier-free formula over the signature . We make the additional convention that the equality symbol, which is usually allowed in first-order logic, is not allowed in (see ). We write for the class of all finite models of .
for the SNP -sentence given below.
A class of finite -structures is said to be in SNP if there exists an SNP -sentence such that ; we use analogous definitions for all logics considered in this paper. We may assume that the quantifier-free part of SNP sentences is written in conjunctive normal form, and then use the usual terminology (clauses, literals, etc).
An SNP -sentence with quantifier-free part and existentially quantified relation symbols is called
monotone if each literal of with a symbol from is negative, i.e., of the form for .
monadic if all the existentially quantified relations are unary.
connected if each clause of is connected, i.e., the following -structure is connected: the domain of is the set of variables of the clause, and if and only if is a disjunct of the clause.
The SNP sentence from Example 4 is monotone, but not monadic, and it can be shown that there does not exist an equivalent MMSNP sentence . The following is taken from  and a proof can be found in Appendix 0.A for the convenience of the reader.
Every sentence in connected monotone SNP describes a problem of the form for some relational structure . Conversely, for every structure , if is in SNP then it is also in connected monotone SNP.
4 Amalgamation Monotone SNP
In this section we define the new logic Amalgamation Monotone SNP (AMSNP). We first revisit some basic concepts from model theory.
4.1 The Amalgamation Property
Let be a finite relational signature and let be a class of -structures. We say that is finitely bounded if there exists a finite set of finite -structures such that if and only if no structure in embeds into . Note that is finitely bounded if and only if there exists a universal -sentence (which might involve the equality symbol) such that for every finite -structure we have if and only if . We say that has
the Joint Embedding Propety (JEP) if for all structures there exists a structure that embeds both and .
the Amalgamation Property (AP) if for any two structures such that induce the same substructure in and in (a so-called amalgamation diagram) there exists a structure and embeddings and such that for all .
Note that since is relational, the AP implies the JEP. A class of finite -structures which has the AP and is closed under induced substructures and isomorphisms is called an amalgamation class.
The age of is the class of all finite -structures that embed into . We say that is finitely bounded if is finitely bounded. A relational -structure is called homogeneous if every isomorphism between finite substructures of can be extended to an automorphism of . Fraïssé’s theorem implies that for every amalgamation class there exists a countable homogeneous -structure with ; the structure is unique up to isomorphism, also called the Fraïssé-limit of . Conversely, it is easy to see that the age of a homogeneous -structure is an amalgamation class. A structure is called a reduct of a structure if is obtained from by restricting the signature.
4.2 Defining Amalgamation SNP
As we have mentioned in the introduction, the idea of our logic is to require that the class of all finite structures satisfying the first-order part of an SNP sentence is an amalgamation class. We later show that the amalgamation property is decidable (Section 5).
Let be a finite relational signature. An Amalgamation SNP -sentence is an SNP sentence such that the class of finite models of the first-order part of is an amalgamation class. If is additionally monotone, we call an Amalgamation Monotone SNP (AMSNP) -sentence.
The monotone SNP sentence from Example 4 describing is in AMSNP (we leave the easy proof to the reader).
The graph property to be an interval graph can be expressed in ASNP. To see this, let and let be the binary relation and the binary relation . It can be shown that is homogeneous (using the technique from Section 5.1). Let be the set of all universal sentences with three variables that hold in the structure . Then is an Amalgamation SNP sentence that holds on a finite graph if and only if the graph is an interval graph. Clearly, the property to be an interval graph is not preserved by removing edges and hence this property cannot be expressed in AMSNP.
Note that since the class of finite models of the first-order part of an amalgamation SNP sentence has the JEP and since equality is not allowed in SNP, we have that is closed under disjoint unions. It can be shown as in the proof of Theorem 3.1 that every Amalgamation SNP sentence can be rewritten into an equivalent connected Amalgamation SNP sentence, and that every AMSNP sentence can be rewritten into an equivalent connected AMSNP sentence.
4.3 AMSNP and CSPs
We present the link between AMSNP and infinite-domain CSPs.
For every AMSNP -sentence there exists a reduct of a finitely bounded homogeneous structure such that .
Let be the set of existentially quantified relation symbols of . Let , for a quantifier-free formula in conjunctive normal form, be the first-order part of . Let be the class of all finite -structures that satisfy ; by assumption, is an amalgamation class. Moreover, is finitely bounded because is a universal -sentence. Let be the Fraïssé-limit of ; then is a finitely bounded homogeneous structure. Let be its -reduct.
Claim 1. If is a finite -structure such that , then .
Let be a homomorphism. Let be the -expansion of where of arity denotes . Then satisfies : to see this, let and let be a conjunct of . Since we have in particular that and so there must be a disjunct of such that . Then one of the following cases applies.
is a -literal and hence must be negative since is a monotone SNP sentence. In this case implies since is a homomorphism.
is a -literal. Then by the definition of we have that if and only if .
Hence, . Since the conjunct of and were arbitrarily chosen, we have that . Hence, satisfies .
Claim 2. If is a finite -structure such that , then .
If has an expansion that satisfies the first-order part of , then there exists an embedding from into by the definition of . This embedding is in particular a homomorphism from to . ∎
The proof of the following theorem can be found in Appendix 0.B.
Let be a reduct of a finitely bounded homogeneous structure . Then there exists an AMSNP sentence such that .
AMSNP has a complexity dichotomy if and only if the infinite-domain tractability conjecture is true.
5 Deciding Amalgamation
In this section we show how to algorithmically decide whether a given existential second-order sentence is in Amalgamation SNP or in AMSNP. Our proof is based on the so-called dual encoding.
5.1 The Dual Encoding
The dual encoding is a standard technique from constraint satisfaction. It can be phrased using the notion of (primitive positive) bi-interpretations; since we do not need this concept here we avoid to define it and refer to a survey article that discusses primitive positive interpretations in connection with the dual encoding .
Let be a relational structure with maximal arity . Then there exists a structure of with a binary signature such that the following holds.
If has a finite signature, then has a finite signature.
is homogeneous if and only if is homogeneous.
If is finitely bounded, then is finitely bounded. Moreover, if for a finite set of finite structures then we can effectively compute from a finite set of finite structures such that .
is the class of substructures of for .
We define the structure with domain as follows:
for every relation of the structure has the unary relation
for all the structure has the binary relation
The proof of the 4 items can be found in Appendix 0.D.
5.2 Deciding Amalgamation
The following was known for binary signatures (the first author has learned the fact from Gregory Cherlin), but we are not aware of any published proof in the literature. Since we reduce the general case to the binary case, we give the proof in Appendix 0.C for the convenience of the reader.
Let be a finite relational signature, and let be a finite set of finite relational -structures. Then there is an algorithm that decides whether has the amalgamation property.
Let be the maximal arity of the relations in . Define
Claim 1. is an amalgamation class if and only if is an amalgamation class. Claim 2. for some finite set of finite structures that can be computed from . For a proof of these claims, see Appendix 0.D. Since has a binary relational signature we have reduced the statement to the binary situation (Theorem 0.C.1). ∎
There is an algorithm that decides for a given existential second-order sentence whether it is in Amalgamation SNP or in AMSNP.
6 Guarded Monotone SNP
In this section we revisit an expressive generalisation of MMSNP introduced by Bienvenu, ten Cate, Lutz, and Wolter  in the context of ontology-based data access, called guarded monotone SNP (GMSNP). It is equally expressive as the logic MMSNP introduced by Madelaine 111MMSNP relates to MMSNP as Courcelle’s MSO relates to MSO .. We will see that every GMSNP sentence is equivalent to a finite disjunction of connected GMSNP sentences (Proposition 1), each of which lies in AMSNP (Theorem 6.1).
A monotone SNP -sentence with existentially quantified relations is called guarded if each conjunct of can be written in the form
are atomic -formulas, called body atoms,
are atomic -formulas, called head atoms,
for every head atom there is a body atom such that contains all variables from (such clauses are called guarded).
We do allow the case that , i.e., the case where the head consists of the empty disjunction, which is equivalent to (false).
Our next proposition is well-known for MMSNP and can be extended to guarded SNP, too. See Appendix 0.E for the proof.
Every GMSNP sentence is equivalent to a finite disjunction of connected GMSNP sentences.
It is well-known and easy to see  that each of can be reduced to in polynomial time. Conversely, if each of is in P, then is in P, too. It follows in particular that if connected GMSNP has a complexity dichotomy into P and NP-complete, then so has GMSNP. The proof of the following theorem can be found in Appendix 0.F.
For every sentence in connected GMSNP there exists an AMSNP sentence such that .
The following shows that the containment of connected GMSNP in AMSNP is strict.
is in AMSNP (see Example 6) but not in GMSNP. Indeed, suppose that is a GMSNP sentence which is true on all finite directed paths. We assume that the quantifier-free part of is in conjunctive normal form. Let be the existentially quantified relation symbols of , let , and let be the number of variables in . A directed path of length , viewed as a -structure, satisfies , and therefore it has an -expansion that satisfies . Note that there are different -expansions of a path of length (for each vertex and each edge of the path we have to decide which of the predicates holds), and hence there must be with such that the substructures of induced by and by are isomorphic. We then claim that the directed cycle satisfies : this is witnessed by the -expansion inherited from which satisfies . Hence, does not express digraph acyclicity. ∎
7 Application: Instances of Bounded Treewidth
If a computational problem can be formulated in AMSNP, then this has remarkable consequences besides a potential complexity dichotomy. In this section we show that every problem that can be formulated in AMSNP is in P when restricted to instances of bounded treewidth. The corresponding result for Monadic Second-Order Logic (MSO) instead of AMSNP is a famous theorem of Courcelle . We strongly believe that AMSNP is not contained in MSO (consider for instance the Betweenness Problem from Example 3), so our result appears to be incomparable to Courcelle’s.
In the proof of our result, we need the following concepts from model theory. A first-order theory is called -categorical if all countable models of are isomorphic . A structure is called -categorical if its first-order theory (i.e., the set of first-order sentences that hold in ) is -categorical. Note that with this definition, finite structures are -categorical. Another classic example is the structure . The definition of treewidth can be treated as a black box in our proof, and we refer the reader to .
Let be an AMSNP -sentence and let . Then the problem to decide whether a given finite -structure of treewidth at most satisfies can be decided in polynomial time with a Datalog program of width .
Since structures that are homogeneous in a finite relational language are -categorical  and first-order reducts of -categorical structures are -categorical , Theorem 4.1 implies that the problem to decide whether a finite -structure satisfies can be formulated as CSP for an -categorical structure . Then the statement follows from Corollary 1 in . ∎
In Theorem 7.1 it actually suffices to assume that the core of has treewidth at most .
The proof of the following corollary can be found in Appendix 0.F.
Let be a GMSNP -sentence and let . Then there is a polynomial-time algorithm that decides whether a given -structure of treewidth at most satisfies .
8 Conclusion and Open Problems
Amalgamation monotone SNP is a strict extension of connected MMSNP  and connected GMSNP  and a candidate for an expressive logic with a complexity dichotomy: every problem in AMSNP is NP-complete or in P if and only if the infinite-domain tractability conjecture for reducts of finitely bounded homogeneous structures holds. See Figure 1.
We presented an application of AMSNP concerning the evaluation of computational problems on classes of structures of bounded treewidth. We also proved that the syntax of AMSNP is algorithmically decidable. We have not determined the precise computational complexity of checking the syntax of AMSNP, and leave this for future work. The following problems concerning AMSNP are open.
Is every CSP in Monadic Second-Order Logic (MSO) also in AMSNP?
Can we decide algorithmically whether a given AMSNP sentence is equivalent (over finite structures) to a fixed-point logic sentence (this then implies that the problem is in P)? We refer to  for a recent article on the power of fixed-point logic for infinite-domain CSPs.
Is every problem in NP polynomial-time equivalent to a problem in Amalgamation SNP (without monotonicity)?
-  L. Barto, M. Kompatscher, M. Olšák, T. V. Pham, and M. Pinsker. Equations in oligomorphic clones and the constraint satisfaction problem for -categorical structures. Journal of Mathematical Logic, 19(2):#1950010, 2019. An extended abstract appeared at the Proceedings of the 32nd Annual ACM/IEEE Symposium on Logic in Computer Science – LICS’17.
-  L. Barto and M. Pinsker. The algebraic dichotomy conjecture for infinite domain constraint satisfaction problems. In Proceedings of the 31th Annual IEEE Symposium on Logic in Computer Science – LICS’16, pages 615–622, 2016. Preprint arXiv:1602.04353.
-  M. Bienvenu, B. ten Cate, C. Lutz, and F. Wolter. Ontology-based data access: A study through disjunctive Datalog, CSP, and MMSNP. ACM Transactions of Database Systems, 39(4):33, 2014.
-  M. Bodirsky. Constraint satisfaction with infinite domains. Dissertation, Humboldt-Universität zu Berlin, 2004.
-  M. Bodirsky. Complexity classification in infinite-domain constraint satisfaction. Mémoire d’habilitation à diriger des recherches, Université Diderot – Paris 7. Available at arXiv:1201.0856, 2012.
-  M. Bodirsky and V. 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).
M. Bodirsky and P. Jonsson.
A model-theoretic view on qualitative constraint reasoning.
Journal of Artificial Intelligence Research, 58:339–385, 2017.
-  M. Bodirsky, F. Madelaine, and A. Mottet. A universal-algebraic proof of the complexity dichotomy for Monotone Monadic SNP. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 105–114, 2018. Preprint available under ArXiv:1802.03255.
-  M. Bodirsky, M. Pinsker, and A. Pongrácz. Projective clone homomorphisms. Accepted for publication in the Journal of Symbolic Logic, Preprint arXiv:1409.4601, 2014.
-  M. Bodirsky and J. Rydval. Temporal constraint satisfaction problems in fixed point logic, 2019. Preprint.
-  S. Braunfeld. Towards the undecidability of atomicity for permutation classes via the undecidability of joint embedding for hereditary graph classes, 2019. Preprint available at arXiv:1903.11932.
-  A. 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, 2017, pages 319–330, 2017.
-  G. Cherlin, S. Shelah, and N. Shi. Universal graphs with forbidden subgraphs and algebraic closure. Advances in Applied Mathematics, 22:454–491, 1999.
-  B. Courcelle and J. Engelfriet. Graph Structure and Monadic Second-Order Logic: A Language-Theoretic Approach. Cambridge University Press, 40 W. 20 St. New York, NY, United States, 2012.
-  R. Fagin. Generalized first–order spectra and polynomial–time recognizable sets. Complexity of Computation, 7:43–73, 1974.
-  T. Feder and M. Y. Vardi. The computational structure of monotone monadic SNP and constraint satisfaction: a study through Datalog and group theory. SIAM Journal on Computing, 28:57–104, 1999.
-  T. Feder and M. Y. Vardi. Homomorphism closed vs. existential positive. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 311–320, 2003.
-  J. Foniok and J. Nešetřil. Generalised dualities and maximal finite antichains in the homomorphism order of relational structures. European J. Combin., 29(4):881–899, 2008.
-  M. Garey and D. Johnson. A guide to NP-completeness. CSLI Press, Stanford, 1978.
-  M. Grohe. The quest for a logic capturing PTIME. In Proceedings of ACM/IEEE Symposium on Logic in Computer Science (LICS), pages 267–271, 2008.
-  Y. Gurevich. Toward logic tailored for computational complexity. Computation and Proof Theory, pages 175–216, 1984.
-  W. Hodges. Model theory. Cambridge University Press, 1993.
-  J. Hubička and J. Nešetřil. Homomorphism and embedding universal structures for restricted classes. Multiple-Valued Logic and Soft Computing, 27(2-3):229–253, 2016. arXiv:0909.4939.
-  G. Kun. Constraints, MMSNP, and expander relational structures. Combinatorica, 33(3):335–347, 2013.
-  R. E. Ladner. On the structure of polynomial time reducibility. Journal of the ACM, 22(1):155–171, 1975.
-  F. Madelaine. Universal structures and the logic of forbidden patterns. Logical Methods in Computer Science, 5(2), 2009.
-  D. 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, 2017, pages 331–342, 2017. https://arxiv.org/abs/1704.01914.
Appendix 0.A Proofs for Connected Monotone SNP
To prove Theorem 3.1, suppose first that is a connected monotone SNP sentence. To show that describes a problem of the form it suffices to show that the class of structures that satisfy is closed under disjoint unions and inverse homomorphisms. Let be of the form where is a quantifier-free first-order -formula where .
Suppose that and are -structures that satisfy . In other words, there is a -expansion of and a -expansion of such that these expansions satisfy . We claim that the disjoint union of and also satisfies ; otherwise, there would be a clause in and elements of such that is false in . Since and satisfy , there must be such that and . But then is disconnected, a contradiction. Closure under inverse homomorphism follows from monotonicity.
For the second part of the statement, suppose that describes a problem of the form for some infinite structure . In particular, the class of structures that satisfy is closed under inverse homomorphisms. Then it follows from results of Feder and Vardi  that is equivalent to a monotone SNP sentence. Moreover, the class of structures that satisfy is closed under disjoint unions. Consider the SNP sentence where is the conjunction of the following clauses (we assume without loss of generality that ).
For each relation symbol , say of arity , and each , add the conjunct to .
Add the conjunct to .
Add the conjunct to .
For each clause of with variables , add to the conjunct
Clearly, is monotone if is monotone. We claim that the connected monotone SNP sentence is equivalent to . Suppose first that is a finite structure that satisfies . Then there is a -expansion of that satisfies . The expansion of by the relation shows that also satisfies .
Now suppose that is a finite structure with domain that satisfies . Then there is a -expansion of that satisfies . Write for connected -structures . Note that the clauses of force that the relation denotes in the structure , for each . Let be the -reduct of . Then satisfies , because if there was a clause from violated in then the corresponding clause in would be violated in . Hence, for every , and since is closed under disjoint unions, we also have that . ∎
Appendix 0.B From CSPs to AMSNP Sentences
Let be a reduct of a finitely bounded homogeneous structure . In this section we construct an AMSNP sentence such that , thus proving Theorem 4.2.
Let be the signature of and the signature of . We may assume without loss of generality that contains a binary relation that denotes the equality relation; it is easy to see that an expansion by the equality relation preserves finite boundedness. Consider the structure with the domain where
To show that is homogeneous, let be an isomorphism between finite substructures of . Let be the set of all first entries of elements of the first structure. Define by picking for an element of the form and defining by . This is well-defined: if is defined on and on , then , and hence . The same consideration for shows that is a bijection, and in fact an isomorphism between finite substructures of . By the homogeneity of there exists an extension of . For each pick a permutation of that extends the bijection given by . Then the map given by is an automorphism of that extends . Since is finitely bounded, there exists a universal -formula such that . Note that might contain the equality symbol (which we do not allow in SNP sentences) and that symbols from might appear positively (which is not allowed in monotone SNP sentences).
Let be the formula obtained from by
replacing each occurrence of the equality symbol by the symbol ;
joining conjuncts that imply that denotes an equivalence relation;
joining for every of arity the conjunct
(implementing indiscernibility of identicals for the relation ).
We claim that . To see this, let be a finite -structure. If satisfies , then every induced substructure of with the property that implies that at most one of and is an element of , satisfies , and hence is a substructure of . This in turn means that is in . The implications in this statement can be reversed which shows the claim.
Let be the formula obtained from by
replacing each occurrence of by a new symbol ;
joining for every of arity the conjunct
Let be the structure obtained from by renaming each relation to ; let be the signature of . By construction, the sentence obtained from by quantifying all relation symbols of is a monotone SNP -sentence.
To show that is an AMSNP sentence, first observe that the class of -reducts of the models of the first-order part of equals . The amalgamation property for follows from the amalgamation property of . To show that the class of finite models of the first-order part of has the amalgamation property, let and be two -structures from . Consider the amalgam of the -reducts of and and note that it can be expanded to a -structure such that both and embeds into it; this proves that is an amalgamation class.
We claim that a finite -structure satisfies if and only if . If then has a -expansion that satisfies . Let be the -reduct of . By the construction of this means that is in . But then , which implies for a -structure that also . Conversely, suppose that . Then a. Let be the -structure defined as in Claim 1 of the previous theorem. Let be the -structure that appears by adding a copy for each to . This structure satisfies and is therefore a witness for . ∎
Appendix 0.C Deciding Amalgamation in the Binary Case
Let be a finite binary relational signature, and let be a finite set of finite relational -structures. Then there is an algorithm that decides whether has the amalgamation property.
Let be the maximal size of a structure in , and let be the number of isomorphism types of two-element structures in . It is well-known and easy to prove that has the amalgamation property if and only if it has the so-called 1-point amalgamation property, i.e., the amalgamation property restricted to diagrams where . Suppose that is such an amalgamation diagram without amalgam. Let . Let and . Let be a -structure with domain such that and are substructures of . Since by assumption is not an amalgam for , there must exist such that the substructure of induced by embeds a structure from .
Note that the number of such -structures is bounded by since they only differ by the substructure induced by and . So let be a list of sets witnessing that all of these structures embed a structure from . Let be the substructure of induced by and be the substructure of induced by . Suppose for contradiction that has an amalgam ; we may assume that this amalgam is of size at most . Depending on the two-element structure induced by in , there exists an such that the structure induced by in embeds a structure from , a contradiction. ∎
Appendix 0.D Proofs Related to the Dual Encoding Lemma
We prove that the structure satisfies the five items from the dual encoding lemma (Lemma 1).
1.: It is clear from the definition of that the signature of is finite if the signature of is finite.
2.: Suppose that is homogenous, and let be an isomorphism between finite substructures of . For any finite we write for the set of all coordinates of elements of . If , then we define ; since preserves the relations this gives a well-defined map . Note that .
Claim. The map is an isomorphism between finite substructures of . Indeed, if is such that , for some and some relation of , then and thus . We therefore have that which proves the claim.
By the homogeneity of there is an extension of to an automorphism of , and is an automorphism of which extends .
To prove the converse, suppose that is homogeneous, and let be an isomorphism between finite substructures of . Then defined by is an isomorphism between the substructure of induced by and the substructure of induced by , and hence can be extended to an automorphism of . Clearly, the map given by is a bijection and extends . To see that it is an automorphism of , suppose that . Pick so that . Hence, . Also note that
for every and hence . This implies that
and hence .
3.: Suppose that is finitely bounded with signature , i.e., for some finite set of finite -structures. For , note that does not embed into . Otherwise, suppose that is such an embedding. Then the map is an embedding of into : if for , let be the unary relation symbol introduced in for . Pick any and note that . Hence, . Also note that for every
and hence . By the definition of , this implies that , and we conclude that
Let be the finite set of structures of the form for together with finitely many structures in the signature of (of size at most three) that ensure that for every structure
holds for all and ;
implies that for all and ;
and imply that for all and .
implies that .
In particular, every relation is an equivalence relation. We write for the equivalence class of with respect to . Note that every element of is uniquely determined by the equivalence classes of . Clearly, no structure in embeds into . We claim that every structure embeds into . Let be the following -structure. The elements of are the equivalence classes of all the equivalence relations in , for , but is identified with if holds in . We define if ; this is well-defined by the structures in introduced for item (d). Note that is an embedding from into .
The structure embeds into : suppose otherwise that there is an embedding from into . Then is an embedding from into , a contradiction. Hence, and it follows that , which concludes the proof of 4.
4.: We first show that every structure is a substructure of for some . We may assume that is a substructure of . Let be the (finite) substructure of induced by the set of all entries of tuples from . Then is a substructure of as required.
Conversely, it suffices to observe that if is an embedding then is an embedding of into . ∎
We finally show the claims from the proof of Theorem 5.1. Claim 1 states that is an amalgamation class if and only if is an amalgamation class.
If is an amalgamation class, then there exists a homogeneous countably infinite -structure whose age equals . By Lemma 1 (2) it follows that is homogeneous, too, and hence the age , which equals by Lemma 1 (4), is an amalgamation class.
Conversely, if is an amalgamation class then there exists a Fraïssé-limit . We claim that is of the form for some structure with age . To see this, note that the properties (a.-d.) from the proof of Lemma 1 hold in and hence every element of is uniquely determined by the equivalence classes with respect to the equivalence relations . The elements of are the equivalence classes of . For we write for the equivalence class of with respect to and define as the set of all tuples such that there exist such that . The structure is homogeneous by Lemma 1, and hence is an amalgamation class. We claim that . Suppose for contradiction that has a substructure isomorphic to a structure from . Then embeds into , a contradiction to the definition of . Conversely, if , then