Universal Horn Sentences and the Joint Embedding Property

The finite models of a universal sentence $\Phi$ in a finite relational signature are the age of a structure if and only if $\Phi$ has the joint embedding property. We prove that the computational problem whether a given universal sentence $\Phi$ has the joint embedding property is undecidable, even if $\Phi$ is additionally Horn and the signature of $\Phi$ only contains relation symbols of arity at most two.


Introduction
The age of a relational structure D is a term from model-theory used for the class of all finite structures that can be embedded to D. Universal Horn sentences which describe the age of a relational structure are particularly relevant in theoretical computer science; we mention two contexts where they appear.
The constraint satisfaction problem (CSP) of a structure D with a finite relational signature τ is the problem of deciding whether a given finite τ -structure A has a homomorphism to D. If the domain of D is finite, then the CSP of D is clearly in NP. Moreover, finite-domain CSPs admit a dichotomy between P and NP [Bul17,Zhu17]. In the infinite, the situation is much more complicated and the CSP might even be undecidable, e.g., the solvability of Diophantine equations can be represented as the CSP of (Z; +, ·, {0}, {1}). What one usually does when studying infinite-domain CSPs is to restrict the set of admissible templates D in order to guarantee a certain upper bound on complexity while still being able to model interesting decision problems. One such restriction is requiring the age of D to be definable by a universal first-order sentence, we then say that D is finitely bounded. In this case, the CSP of D is in NP. For every satisfiable instance A, we can guess a finite structure B which admits a surjective homomorphism from A and embeds into D. To verify that B indeed embeds into D, we must only confirm that it satisfies the fixed universal sentence, which can be done in time polynomial in the size of A. If the age of D is definable by a universal Horn sentence, then the CSP of D is even guaranteed to be solvable in polynomial time by a Datalog program. Here, we would simply saturate the relations of A under application of the fixed set of Horn rules and reject if and only if we can derive the empty clause. A wide variety of decision problems are CSPs of reducts of finitely bounded structures, e.g., digraph acyclicity or satisfiability of a fixed connected MMSNP sentence [Bod21]. However, in general it is not clear which universal (Horn) sentences actually describe the age of a relational structure, and this question can be considered as an interesting decision problem if one intends to study the CSPs of reducts of finitely bounded structures.
Description logics are knowledge representation languages frequently used to formalize ontologies. To enable reference to concrete objects and predefined predicates on these objects, a description logic can be extended by a concrete domain, which is usually represented by a fixed relational structure. By a result in [BR21], if the age of a relational structure D is defined by a universal sentence Φ, then D yields a tractable concrete domain extension of the description logic EL if and only if Φ is equivalent to a universal Horn sentence. To enable user-definability of concrete domains for EL, one would need an algorithm accepting precisely those universal Horn sentences which describe the age of a relational structure.
We show that the question whether a given universal sentence is equivalent to a universal Horn sentence can be decided effectively. This motivates the question whether one can also decide which universal Horn sentences describe the age of a relational structure. By a classical result of Fraïssé, the finite models of a universal sentence Φ in a finite relational signature are the age of some structure if and only if Φ has the joint embedding property [Hod93]. The problem whether a given universal sentence Φ has the joint embedding property is undecidable by a result of [Bra19], but the theories used by Braunfeld to prove the undecidability are not universal Horn. We prove that the joint embedding property remains undecidable even if the given universal sentence is additionally Horn, and if the signature is binary. Our proof is based on the undecidability of universality of context-free languages and shorter than the argument of Braunfeld.

Preliminaries
The set {1, . . . , n} is denoted by [n]. We often use the bar notation for tuples; for a tupleā indexed by a set I, the value ofā at the position i ∈ I is denoted byā [i]. For a function f : A → B and a tuplē a ∈ A k , we set f (ā) := f (ā[1]), . . . , f (ā[k]) . We always use capital Fraktur letters A, B, C, etc to denote structures, and the corresponding capital Roman letters A, B, C, etc for their domains.
Let τ be a finite relational signature. An atomic τ -formula, or τ -atom for short, is a formula of the form R(x 1 , . . . , x n ) for R ∈ τ and (not necessarily distinct) variables x 1 , . . . , x n . Note that in this text equality atoms, i.e., expressions of the form x = y, are not permitted. A class C of relational τ -structures has the joint embedding property (JEP) if for every pair B 1 , B 2 ∈ C, there exists C ∈ C and embeddings If A is a τ -structure and Φ is a τ -sentence, we write A |= Φ if A satisfies Φ. If Φ and Ψ are τ -sentences, we write Φ |= Ψ if every τ -structure that satisfies Φ also satisfies Ψ. For universal sentences, this is equivalent to the statement that every finite τ -structure that satisfies Φ also satisfies Ψ, by a standard application of the compactness theorem of first-order logic. If Φ is a τ -sentence, we denote the class of all finite models of Φ by Φ <ω . Clearly, every universal formula can be written as ∀x 1 , . . . , x n . ψ where ψ is quantifier-free and in conjunctive normal form. Conjuncts of ψ are also called clauses; clauses are disjunctions of atomic formulas and negated atomic formulas. A clause φ is a weakening of a clause ψ if every disjunct of ψ is also a disjunct of φ. We sometimes omit universal quantifiers in universal sentences (all first-order variables are then implicitly universally quantified). It is well-known that a class C of finite τ -structures can be described by forbidding isomorphic copies of fixed finitely many finite τ -structures if and only if C = Φ <ω for some universal τ -sentence Φ. With this observation, it is easy to see that Braunfeld [Bra19] proved undecidability for the following decision problem. His proof is based on a reduction from the unrestricted tiling problem.
INPUT: A universal sentence Φ in a finite relational signature. QUESTION: Does Φ <ω have the JEP?
A universal sentence Φ is called Horn if its quantifier-free part is a conjunction of Horn clauses, i.e., disjunctions of positive or negative atomic formulas each having at most one positive disjunct. Every Horn clause can be written equivalently as an implication where φ 1 , . . . , φ n are atomic formulas (possibly n = 0), and φ 0 is either an atomic formula or ⊥ which stands for the empty disjunction. We refer to φ 1 ∧ · · · ∧ φ n as the premise, and to φ 0 as the conclusion of the Horn clause. A Horn clause over a signature τ is called a tautology if it holds in all τ -structures, i.e., if the conclusion equals one of the conjuncts of the premise.
We say that a Horn clause φ 1 ∧ · · · ∧ φ n ⇒ φ 0 can be applied to a structure A if φ 1 ∧ · · · ∧ φ n ∧ ¬φ 0 is satisfiable in A. Let Φ be a Horn sentence. We say that A is closed under application of Horn clauses from Φ if no conjunct of Φ is applicable to A, i.e., if A is a model of Φ.
Definition 1. Let Φ be a universal Horn sentence and ψ a Horn clause, both in a fixed relational signature τ . An SLD-derivation of ψ from Φ of length k is a finite sequence of Horn clauses ψ 0 , . . . , ψ k = ψ such that ψ 0 is a conjunct in Φ and each ψ i (1 ≤ i ≤ k) is a (binary) resolvent of ψ i−1 and a conjunct φ i from Φ, i.e., for some atomic formula ψ j i−1 , we have There exists an SLD-deduction of ψ from Φ, written as Φ ⊢ ψ, if ψ is a tautology or a weakening of a Horn clause that has an SLD-derivation from Φ up to renaming variables.
The following theorem presents a fundamental property of universal Horn sentences: that SLD-deduction is a sound and complete calculus for entailment of Horn clauses by Horn sentences.

Universal Horn Sentences and the JEP
This section deals with two separate topics. First, we discuss the semantical difference between universal sentences and universal Horn sentences which is described by the convexity condition. Second, we present some important observations about the JEP in the context of universal Horn sentences which we later use in the proof of our main result. Let τ be a relational signature.
We say that Φ is preserved in products if for every non-empty family (A i ) i∈I of models of Φ, the direct product I A i is also a model of Φ. The following is well known; e.g., the direction (3)⇒(1) is Corollary 9.1.7 in [Hod93]. Since we also need (4) we provide a proof for the convenience of the reader.
Theorem 2 (McKinsey). Let Φ be a universal sentence with relational signature τ . Then the following are equivalent.
1. Φ is convex; 2. Φ is equivalent to a universal Horn sentence; 3. Φ is preserved in products; 4. Φ is preserved in binary products of finite structures.
Proof: "1⇒2": We may assume that Φ is in prenex normal form and that its quantifier-free part φ is in conjunctive normal form. Every conjunct in φ is equivalent to an implication of the form i∈[n] φ i ⇒ j∈[k] ψ j . Since Φ is convex, we can replace the conjunct by i∈[n] φ i ⇒ ψ j for some j ∈ [k]. In this way, Φ can be rewritten into an equivalent universal Horn sentence.
"2⇒3": Corollary 9.1.6 in [Hod93]. "3⇒4": This direction is trivial. "4⇒1": Suppose that Φ has m variables and is not convex, i.e., We may assume that each A j is finite; otherwise we replace it with its substructure on the coordinates of t j while preserving the desired properties.
It follows by induction on j ∈ [k] that if Φ is preserved in binary products of finite structures, then We then obtain a contradiction for j = k. It is natural to consider the following question as a decision problem.
INPUT: A universal sentence Φ in a finite relational signature. QUESTION: Is Φ equivalent to a universal Horn sentence? Proposition 1. Deciding whether a given universal sentence Φ is equivalent to a universal Horn sentence is Π p 2 -complete. The problem is Π p 2 -hard even when the signature is limited to unary relation symbols.
Proof: We first prove containment in Π p 2 . For a given universal sentence Φ, let φ(x 1 , . . . , x n ) be the quantifier-free part of Φ. If Φ is not equivalent to a universal Horn sentence, then, by Theorem 2, Φ has two finite models A, B such that A × B is not a model of Φ. This means that there existst ∈ (A × B) n such that A × B |= φ(t). But then, by the definition of product of structures, there exist substructures Since models of Φ are preserved under taking substructures, we have A ′ |= Φ and B ′ |= Φ. Conversely, if there exist two models of Φ of size at most n whose product is not a model of Φ, then clearly Φ is not equivalent to a universal Horn sentence by Theorem 2.
The argument above shows that the following algorithm is sound and complete for the complement of the original problem. We first guess two models A and B of Φ of size at most n such that A × B is not a model of Φ. The latter can be verified in time polynomial in n by guessing a tuplet ∈ (A × B) n such that A × B |= φ(t). Verifying A |= Φ and B |= Φ iteratively would require a loop over up to n n many tuples, which would not yield an efficient procedure. Instead, we deal with the verification using a coNP oracle that guesses any potential tuple witnessing that B |= Φ or A |= Φ.
Since this shows that the complement of the original problem is in Σ p 2 , the original problem itself is in The Π p 2 -hardness can be shown by a reduction from the complement of the propositional ∃∀SAT problem. Consider an instance of propositional ∃∀SAT. We first obtain the signature τ = {C 1 , . . . , C k , C, L, R} consisting of unary symbols only. Let ψ(x, x k+1 , . . . , x ℓ ) be the quantifier-free τ -sentence obtained from Ψ(X 1 , . . . , X ℓ ) by replacing each propositional variable The idea is to show that: Φ is equivalent to ∀x, y C(y) ⇒ C(x) if (1) is not satisfiable, and otherwise Φ is not equivalent to any universal Horn sentence. "⇒": Suppose that (1) is satisfiable, i.e., there exists a map f : We define A R analogously by switching the roles of L and R in item 2 above. It follows directly from our assumption about f , item 1, and item 2 that A L |= Φ. We also clearly get A R |= Φ since the construction of A L and A R is symmetrical w.r.t. Φ. Now consider the structure A L × A R . We have that 2 , a 2 )). However, A L × A R |= L((a 1 , a 1 )) ∨ R((a 1 , a 1 )). Thus, Φ <ω is not preserved under products, which means that Φ is not equivalent to any universal Horn sentence by Theorem 2.
"⇐": Suppose that Φ is not equivalent to any universal Horn sentence. By Theorem 2, Φ <ω is not preserved in binary products of finite structures, i.e., there exist A, B ∈ Φ <ω such that A × B |= Φ.
First, suppose that either A |= C(a) for every a ∈ A or A |= ¬C(a) for every a ∈ A, and either B |= But then we clearly have A × B |= Φ, a contradiction to our original assumption.
Next suppose that, without loss of generality, there exist a 1 , a 2 ∈ A such that A |= ¬C(a 1 ) ∧ C(a 2 ).
be an arbitrary extension of f . We want to show that f ′ is a satisfactory assignment for Ψ(X 1 , . . . , X ℓ ). For this, we consider the map . By the definition of ψ and f ′′ , the map f ′ is a satisfying assignment for Ψ(X 1 , . . . , X ℓ ). We conclude that (1) is satisfiable.
In the context of the results in [BR21], the Π p 2 -hardness in Proposition 1 would also be interesting under the assumption that Φ <ω has the JEP. This can be achieved with a simple trick where we introduce a fresh binary symbol E into τ and expand the premise of the implication in Φ by the conjunction . As a consequence, Φ <ω is even closed under the formation of disjoint unions, which is a strong form of the JEP.
Corollary 1. Deciding whether a given universal sentence Φ such that Φ <ω has the JEP is equivalent to a universal Horn sentence is Π p 2 -hard, even when the signature is limited to binary relation symbols. The trick above is based on a general observation about connected clauses that we later use in our undecidability proof, in the form of Proposition 2.
Definition 2. A Horn clause φ ⇒ ψ is called connected if the graph with vertex set {x 1 , . . . , x n } where x i and x j form an edge if they appear jointly in a conjunct of φ, forms a connected graph on all variables occurring in φ ⇒ ψ in the usual graph-theoretic sense.
Proposition 2. Let Φ be a universal Horn sentence such that each conjunct in the quantifier-free part of Φ is connected. Then Φ <ω is closed under the formation of disjoint unions and therefore has the JEP.
Example 1. The class of all finite strict partial orders, defined by is the age of the set of all finite subsets of N partially ordered by set inclusion.
In fact, universal sentences preserved under disjoint unions can be fully characterized in terms of being equivalent to a universally quantified conjunction of connected clauses, see, e.g., Theorem 4.4 in [Com83]. One should not expect any similar normal form for universal sentences whose finite models have the JEP since this property is undecidable. However, there is a useful reformulation of the JEP for classes of finite structures defined by universal Horn sentences that greatly simplifies the presentation of our undecidability proof.
Definition 3. Let Φ be a universal Horn sentence over the relational signature τ , and let φ(x) and ψ(x,ȳ) be conjunctions of atomic τ -formulas. We write ψ(x,ȳ) ≤ Φ φ(x) if for every χ that is ⊥ or an atomic τ -formula with free variables amongx In our proofs later it will be useful to take a proof-theoretic perspective on the JEP.
Lemma 1. Let Φ be a universal Horn sentence over the relational signature τ . Then the following are equivalent: 1. Φ <ω has the joint embedding property.
We mention in passing that (1) and (2) are equivalent even if equality is permitted in Φ.

Undecidability of the JEP
In this section we prove that the problem of deciding whether the class of all finite models of a given universal Horn sentence Φ has the joint embedding property is undecidable. Our proof is based on a reduction from the problem of deciding the universality of a given context-free grammar. As usual, the Kleene plus of Σ, denoted by Σ + , is the set of all finite words over Σ of length ≥ 1. A context-free grammar (CFG) is a 4-tuple G = (N, Σ, P, S) where • N is a finite set of non-terminal symbols, • Σ is a finite set of terminal symbols, • P is a finite set of production rules of the form A → w where A ∈ N and w ∈ (N ∪ Σ) + , • S ∈ N is the start symbol.
Note that with this definition the empty word, i.e., the word ǫ of length 0, can never be an element of L(G); some authors use a modified definition that also allows rules that derive ǫ, but for our purposes the difference is not essential. Example 2. Let G := ({S}, {a, b}, {S → aSb, S → ab}, S). Then it follows by a simple induction that L(G) = {a n b n | n ≥ 1} because every accepting derivation path in → G is of the form S → G · · · → G a n−1 Sb n−1 → G a n b n .
The idea of the reduction is to compute from a given context-free grammar G a universal Horn sentence which consists of two parts, Φ 1 and Φ 2 : the sentence Φ 2 only depends on Σ and entails many Horn clauses witnessing failure of the JEP via Lemma 1; the sentence Φ 1 can be computed efficiently from G and is such that Φ 1 <ω is closed under the formation of disjoint unions and prevents all the failures of the JEP of Φ 1 ∧ Φ 2 <ω if and only if G is universal, i.e., L(G) = Σ + .
Theorem 3. For a given universal Horn sentence Φ the question whether Φ <ω has the JEP is undecidable even if the signature is limited to at most binary relation symbols.
Proof: The universality problem for context-free grammars is known to be undecidable [Har78] (Lemma 8.4.2, page 259). Here, we assume that (A → A) ∈ P for every A ∈ N . Note that this assumption does not influence L(G) at all.
Encoding context-free grammars into ages of relational structures. Let τ 1 be the signature that contains the unary symbols I and T , and the binary relation symbol R a for every element a ∈ N ∪ Σ. Let Φ 1 be the universal Horn sentence that contains, for every (A → a 1 . . . a n ) ∈ P , the Horn clause and additionally the Horn clause Note that each conjunct of Φ 1 is connected, which means that Φ 1 <ω has the JEP by Proposition 2. The following correspondence can be shown via a straightforward induction.
Claim 1. For every w = a 1 . . . a n ∈ (N ∪ Σ) + , we have Proof: "⇒": Suppose that A → * G a 1 . . . a n for A ∈ N . Then there is a path in → G from A to a 1 . . . a n of length λ ≥ 1. We prove the statements by induction on λ.
In the induction base λ = 1 we have (A → a) ∈ P in which case (4) is a conjunct of Φ 1 . In the induction step λ −→ λ + 1, we assume that the claim holds for all paths of length ≤ λ, and that there exists a path of length λ + 1 from A to a 1 . . . a n , i.e., there exists (A → a 1 . . . a k−1 Ba ℓ+1 . . . a n ) ∈ P and a path of length λ from B to a k . . . a ℓ . By the induction hypothesis, after renaming of variables we have that By the construction of Φ 1 , after renaming of variables we also have that We can now apply an SLD derivation step to (6) with (5) to obtain (4). "⇐": Suppose that Φ 1 |= (4). By Theorem 1, there is an SLD-deduction of (4) from Φ 1 . If (4) is a tautology, then n = 1 and a 1 = A in which case the statement is true because (A → A) ∈ P for every A ∈ N . Otherwise, (4) is a weakening of a Horn clause ψ that has an SLD-derivation from Φ 1 modulo renaming variables. Note that the removal of any atom from the premise of (4) would make it disconnected. The same also applies to ψ since its atomic subformulas are among the atomic subformulas of (4). Since every Horn clause in Φ 1 is connected, and SLD-derivations modulo renaming variables clearly preserve connectedness, it cannot be the case that (4) was obtained from ψ by adding an atom to the premise. Next, note that Φ 1 ∧ i∈[n] R ai (x i , x i+1 ) is satisfiable for every a 1 . . . a n ∈ (N ∪ Σ) + . Thus, it also cannot be the case that (4) was obtained from ψ by adding an atom to the conclusion. Hence, we may assume that (4) and ψ are equal. We prove the claim by induction on the length λ of a shortest possible SLD-derivation for ψ.
In the base case λ = 0, ψ must be a conjunct of Φ 1 . By the construction of Φ 1 , we get that (A → a 1 . . . a n ) ∈ P and thus A → * G a 1 . . . a n . In the induction step λ −→ λ + 1, we assume that the claim holds if ψ has an SLD-derivation of length ≤ λ. Suppose that ψ requires an SLD-derivation of length λ + 1. By the construction of Φ 1 , there must exist (B, a k . . . a ℓ ) ∈ P such that Φ 1 contains a conjunct of the form (2) that is used in the last step in a x 1 x 2 x 3 x 4 x 5 x x 3 x 4 x 5 x 6 x 3 x 4 x 5 x x 3 x 4 x 5 x 6 Q Q Q Q Q y I U T Figure 1: An illustration of the situation in Claim 2 for n = 6.
Creating candidates for failure of the JEP. Let τ 2 be the signature which contains all symbols from τ 1 except for the ones coming from N and additionally the unary symbol U and the binary symbol Q. The sentence Φ 2 consists of the following Horn clauses for every a ∈ Σ: The proof of the following claim is left to the reader (a straightforward consequence of Theorem 1), see Figure 1 for an illustration of Claim 2.
Claim 2. Let φ(x) be a conjunction of (τ 2 \ {Q})-atoms. Then if and only if there exists a 1 . . . a n ∈ Σ + such that φ has a subformula of the form where the variables need not be distinct.
Now we are ready for the main part of the proof. We set Φ := Φ 1 ∧ Φ 2 .
Proof: "⇒": Suppose that Φ <ω has the JEP. Let a 1 . . . a n ∈ Σ + . Consider the formulas φ 1 (y) and φ 2 (x 1 , . . . , x n+1 ) given by and φ 2 : By Claim 2, we have Since Φ <ω has the JEP, by Lemma 1(2), we have that Φ ∧ φ 1 or Φ ∧ φ 2 is not satisfiable. Note that every Horn clause in Φ 1 contains an R a -atom for some a ∈ N ∪ Σ in its premise, and φ 1 contains none. Also note that every Horn clause in Φ 2 contains an I-atom or an R a -atom for some a ∈ N ∪ Σ in its premise, and φ 1 contains none. Hence, the τ -structure with domain {y} and whose relations are described by the atomic formula U (y) is closed under application of Horn clauses from Φ, i.e., Φ ∧ φ 1 is satisfiable. Since one of the formulas Φ ∧ φ 1 and Φ ∧ φ 2 is not satisfiable, we must have Next, note that every Horn clause in Φ 2 contains a U -atom in its premise, φ 2 contains no U -atom, and no Horn clause in Φ 1 contains a U -atom in its conclusion. We claim that then Suppose, on the contrary, that Φ 1 ∧ φ 2 is satisfiable. Let A be any finite model of Φ 1 ∧ φ 2 . We assume that U A = ∅, otherwise we remove all elements from U A . Then A still satisfies φ 2 because φ 2 does not contain any U -atoms, and A remains closed under application of Horn clauses from Φ 1 because no Horn clause in Φ 1 contains a U -atom in its conclusion. But then A is also closed under application of Horn clauses from Φ 2 because every Horn clause in Φ 2 contains a U -atom in its premise. We conclude that A |= Φ ∧ φ 2 , a contradiction to (13). Hence (14) holds. Finally, note that (3) is the only Horn clause in Φ 1 which contains an Ior T -atom in its premise, and that no Horn clause in Φ 1 contains an Ior T -atom in its conclusion. We claim that then Suppose, on the contrary, that (15) does not hold. Then there exists a finite τ -structure . We may assume that A = {x 1 , . . . , x n+1 } because the models of a universal sentence are always closed under taking substructures. We may also assume that I A = T A = ∅, otherwise we remove all elements from these relations. Then A remains closed under application of Horn clauses from Φ 1 because no Horn clause in Φ 1 contains an Ior T -atom in its conclusion. Now consider the structure A ′ obtained from A by adding x 1 to I A and x n+1 to T A . Then A ′ is closed under application of Horn clauses from Φ 1 because (3) is the only Horn clause in Φ 1 that has an Ior T -atom in its premise and it cannot be applied to A ′ since (x 1 , x n+1 ) / ∈ R A ′ S . But then A ′ |= Φ 1 ∧ φ 2 , a contradiction to (14). Hence (15) holds. Now it follows from Claim 1 and (15) that a 1 . . . a n ∈ L(G) and we are done. "⇐": We prove the contrapositive and assume that Φ <ω does not have the JEP. Then there exists a counterexample to Lemma 1(2), i.e., there exists a Horn clause ψ of the following form where χ is either ⊥ or an atomic τ -formula with free variables amongx 1 such that and, for both i ∈ {1, 2}, We choose ψ minimal with respect to the number of its atomic subformulas. Our proof strategy is as follows. First we show that ψ encodes a single word w ∈ Σ + in the sense of Claim 2. Then we show that the word w may not be contained in L(G), because otherwise a part of the counterexample would encode w in the sense of Claim 1 which would lead to a contradiction.
Proof of Observation 1: First, we claim that Φ 1 ⊢ ψ or Φ 2 ⊢ ψ. By Theorem 1, we have Φ ⊢ ψ. Note that χ(x 1 ) cannot be a subformula of φ 1 (x 1 ), by (17). Also note that χ(x 1 ) cannot be a subformula of φ 2 (x 2 ) as these two formulas have no common variables. Hence, χ(x 1 ) is not a subformula of φ 1 (x 1 ) ∧ φ 2 (x 2 ), i.e., ψ is not a tautology. Let ψ ′ be a Horn clause such that ψ is a weakening of ψ ′ and ψ ′ has an SLDderivation ψ ′ 0 , . . . , ψ ′ k = ψ ′ from Φ. Note that the Horn clauses in Φ have the property that, depending on whether they come from Φ 1 or from Φ 2 , they either contain no Q-atoms or no R A -atoms for A ∈ N . This applies in particular to ψ ′ 0 which is a conjunct from Φ. Since the conclusion of each Horn clause in Φ 1 is an R A -atom for A ∈ N and the conclusion of each Horn clause in Φ 2 is a Q-atom, the property of ψ ′ 0 from above propagates inductively to every ψ ′ i for i ∈ [k]. But this means that ψ ′ has an SLD-derivation from Φ 1 or from Φ 2 . Hence, ψ has an SLD-deduction from Φ 1 or from Φ 2 , which concludes the claim.
Next, we claim that Φ 2 ⊢ ψ. Suppose, on the contrary, that Φ 1 ⊢ ψ. Let φ ′ 1 and φ ′ 2 be the formulas obtained from φ 1 and φ 2 , respectively, by removing all Q-atoms. Since Φ 1 ⊢ ψ, the SLD-derivation sequence ψ ′ 0 , . . . , ψ ′ k from the paragraph above contains no Q-atoms. Thus, all Q-atoms occurring in ψ come from the weakening step, which means that Since ψ ′ 0 is a Horn clause from Φ 1 , it follows from the minimality assumption for ψ that either χ is an R A -atom for some A ∈ N , or χ is ⊥. In both cases, (18), (19), and (17) witness that Φ 1 <ω does not have JEP through an application of Lemma 1. But this is in contradiction to Proposition 2. Thus, Φ 1 ⊢ ψ does not hold, and Φ 2 ⊢ ψ holds instead. This concludes the claim.
Since Φ 2 ⊢ ψ, the premise φ 1 ∧ φ 2 of ψ can only contain symbols from τ 2 , otherwise we could remove all (τ 1 \ τ 2 )-atoms and get a contradiction to the minimality of ψ. Since ψ ′ 0 is a Horn clause from Φ 2 , it also follows from the minimality assumption for ψ that either χ is an Q-atom, or χ is ⊥. Thus, ψ only contains symbols from τ 2 .
Proof of Observation 2: By Observation 1, ψ has an SLD-deduction from Φ 2 . Recall from the proof of Observation 1 that ψ cannot be a tautology. By the minimality of ψ, we may assume that there exists an SLD-derivation of ψ from Φ 2 . Consider any SLD-derivation ψ 0 , . . . , ψ k of ψ from Φ 2 . Note that, by the construction of Φ 2 , for every i ∈ [k], if there exists a variable y in ψ i−1 such that 1. every Q-atom contains y in its first argument, 2. every U -atom contains y in its only argument, then ψ i also satisfies item 1 and item 2 for the same variable y. Since every possible choice of ψ 0 from Φ 2 initially satisfies these two conditions, it follows via induction that item 1 and item 2 must hold for ψ = ψ k for some y. Also note that (8) is the only Horn clause in Φ 2 that is not connected, but the lack of connectivity is only because the variable y satisfying item 1 and item 2 is isolated from the remaining variables. It follows by induction that this is also true for ψ. We claim that ψ 0 is of the form (10). Suppose, on the contrary, that ψ 0 is of the form (9) or (8). Then the conclusion of ψ is a Q-atom. By our assumption, the conclusion of ψ may only contain variables from x 1 . Thus, also the variable y that satisfies item 1 and item 2 for ψ is contained inx 1 . Since the second variable in the conclusion of ψ is connected to all remaining variables and the variables of φ 1 and φ 2 are disjoint, φ 2 must be the empty conjunction. This leads to a contradiction to (17). Thus our claim holds. The claim implies that χ equals ⊥.
Since y satisfies item 1 for ψ, if ψ contains any Q-atom in the premise, then ψ is connected. But then, since the variables of φ 1 and φ 2 are disjoint while ψ is connected, either φ 1 or φ 2 must be the empty conjunction. Since χ equals ⊥, this leads to a contradiction to (18). Thus, ψ does not contain any Q-atoms at all.
If some variables among x 1 , . . . , x n+1 are identified in (20), then we still have (21) even if we perform the same identification of variables. But then we get a contradiction to (18). Thus, L(G) = Σ + , which concludes the proof of Claim 3.
We have thus found a reduction from the undecidable universality problem for G to the decidability problem of the JEP for Φ <ω ; note that Φ is universal Horn and can be computed from G in polynomial time.

Open Problems
An important open question about universal sentences over relational signatures is the decidability of the amalgamation property (AP), which is a strong form of the joint embedding property, and which is of fundamental importance in constraint satisfaction [Bod21]. Unlike the JEP, the AP is decidable if all relation symbols in the signature are at most binary (see, e.g., [KL87,BKS20]). For general relational signatures, we ask the following question.
Question 1. Is it decidable whether the class of finite models of a given universal Horn sentence Φ has the amalgamation property?