{'fraction_non_alphanumeric': 0.056077180188392584, 'fraction_numerical': 0.006168337891218474, 'mean_word_length': 3.6523183488832345, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Instantiation Schemes for Nested Theories

This paper investigates under which conditions instantiation-based proof procedures can be combined in a nested way, in order to mechanically construct new instantiation procedures for richer theories. Interesting applications in the field of verification are emphasized, particularly for handling extensions of the theory of arrays.


Introduction
Proving the satisfiability or unsatisfiability of a first-order formula (possibly modulo some background theory) is an essential problem in computer science -in particular for the automatic verification of complex systems, and instantiation schemes can be used for this purpose. Such schemes can be viewed as functions Θ that map a set of formulae (or clauses) S to a set of ground (i.e. without variable) instances Θ(S) of S. An instantiation scheme Θ is refutationally complete if for all sets of clauses S, Θ(S) is satisfiable exactly when S is. Examples of refutationally complete instantiation schemes include [22,24,17,5]. It is clear that an instantiation scheme that is refutationally complete does not always terminate, as Θ(S) may be infinite, but schemes that are both complete and terminating can be defined for specific classes of clause sets, that are thus decidable. A trivial and well-known example is the Bernays-Schönfinkel class (i.e. the class of purely universal formulae without function symbols of arity distinct from 0, see, e.g., [11]), since in this case the set of ground instances is finite. Other examples include the class of stratified clause sets [1] and many classes of clause sets of the form G ∪ A, where G is a set of ground formulae and A is the set of axioms of a specific theory, for instance the theory of arrays [6]. In this last case, of course, only the axioms in A need to be instantiated.
Instantiation schemes can also be defined for specific theories for which decision procedures exist. Then, the theory is not axiomatized, but directly handled by an external prover -used as a "black box". In this case, the instantiation procedure should preserve the validity of the formula modulo the considered theory. Such procedures are appealing, because it is usually much easier to check the validity of a ground set than that of a non-ground set (see for instance [7]).
Frequently, one has to handle heterogeneous problems, defined on complex theories for which no instantiation procedure exists. Such theories are frequently obtained by combining simpler theories. For instance the theory describing a data-structure (arrays, list, etc.) may be combined with the theory modeling the elements it contains (e.g., integers). Most systems rely on the Nelson-Oppen method (and its numerous refinements) to reason on combination of theories. This scheme allows one -under certain conditions -to combine independent decision procedures (see, e.g., [27]), but it is of no use for reasoning on theories that include axioms containing function or predicate symbols from both theories. As an example, consider the following formula: ∀i, j : nat, i ≤ j ⇒ select(t, i) ≤ select(t, j), that states that an array t is sorted. This formula uses symbols from the theory of integers (the predicate ≤) and from the theory of arrays (the function select, which returns the value stored in a certain array at a certain index).
In this paper, we show how to construct automatically instantiation schemes for such axioms, by combining existing instantiation schemes. More precisely, from two complete instantiation procedures Θ N and Θ A for the theory of integers and for the theory of arrays respectively, we construct a new procedure Θ which is able to handle a particular class of "mixed" axioms, containing function symbols from both theories (including for instance the axioms for sorted arrays and many others). Θ will be complete and terminating if both Θ N and Θ A are (as proven in Section 3.3). This approach is not restricted to specific theories such as Θ N and Θ A ; on the contrary it is generic and applies to a wide range of theories and some examples are provided in Section 4. The conditions that must be satisfied by the considered theories and by their instantiation procedures are very precisely identified (see Section 3.2).

Comparison with Related Work
There is an extensive amount of work on the combination of (usually disjoint) theories, using mainly refinements or extensions of the Nelson-Oppen method (see, e.g., [27,8]). For instance, [14] shows that many decidable fragments of first-order logic can be combined with any disjoint theory, even if these fragments do not fulfill the stable infiniteness condition in general. A related result is presented in [15] for the theory of lists (with a length function). However, these results do not apply to non-disjoint theories as the ones we consider in this paper, and they cannot handle nested combinations of arbitrary theories.
Reasoning on the combination of theories with mixed axioms has been recognized as an important problem and numerous solutions have been proposed in many specific cases. Most existing work focuses on testing the satisfiability problem of ground formulae in combinations or extensions of existing theories. In contrast, our method aims at reducing non-ground satisfiability to ground satisfiability tests, via instantiation.
For instance, [7,6] define a decision procedure for extensions of the theory of arrays with integer elements, which is able to handle axioms such as the one above for sorted arrays. As we shall see in Section 4, our approach, when applied to these particular theories, permits to handle a strictly more expressive class of quantified formulae. [19] focuses on arrays with integer indices and devises a method to combine existing decision procedures (for Presburger arithmetic and for the theory of arrays). This method is able to handle some important specific features of arrays such as sortedness or array dimension. Similarly to our approach, theirs is based on an instantiation of the axioms. As we shall see, some of its features can be tackled with our method and others (such as Injectivity) are out of its scope. However, our method is generic in the sense that it applies to a wide class of theories and axioms (in particular, it applies to axioms that are not considered in [19]). It is essentially syntactic, whereas that of [19] is more of a semantic nature.
A logic devoted to reasoning with arrays of integers is presented is [21] and the decidability of the satisfiability problem is established by reduction to the emptiness problem for counter automata. In Section 4 we shall show that the expressive power of this logic is again incomparable with the one we obtain with our approach. [18] proposes an instantiation scheme for sets of clauses possibly containing arithmetic literals, which can handle some of the axioms we consider. However termination is not guaranteed for this scheme, in contrast to ours.
Slightly closer to our approach is the work described in [25,26], which defines the notion of the (stably) local extension of a theory and shows that the satisfiability problem in a (stably) local extension of a theory A can be reduced to a mere satisfiability test in A. The notion of a local extension is a generalization of the notion of a local theory [16]. The idea is that, for testing the satisfiability of a ground formula G in the local extension of a theory, it is sufficient to instantiate the variables occurring in the new axioms by ground terms occurring either in G or in the axioms. This condition holds for numerous useful extensions of base theories, including for instance extensions with free functions, with selector functions for an injective constructor, with monotone functions over integers or reals etc. Our approach departs from these results because our goal is not to extend basic theories, but rather to combine existing instantiation procedures. Note also that the notion of a local extension is a semantic one, and that this property must be established separately for every considered extension. In our approach we define conditions on the theories ensuring that they can be safely combined. These conditions can be tested once and for all for each theory, and then any combination is allowed. The extensions we consider in this paper are not necessarily local thus do not fall under the scope of the method in [25,26]. However, an important restriction of our approach compared to [25,26] is that the theories must be combined in a hierarchic way: intuitively there can be function symbols mapping elements of the first theory B (the "base" theory) to elements of the second one N (the "nesting" theory), but no function symbols are allowed from N to B.
Extensions of the superposition calculus [3] have been proposed to handle first-order extensions of a base theory (see for example [4,2]). The superposition calculus is used to reason on the generic part of the formulae whereas the theory-specific part is handled by an external prover. These proof procedures can be used to reason on some the formulae we consider in the present paper. However, we are not aware of any termination result for these approaches (even completeness requires additional restrictions that are not always satisfied in practice). Our approach uses an instantiation-based approach instead of superposition, and ensures that termination is preserved by the combination, at the cost of much stronger syntactic restrictions on the considered formulae.

Organization of the Paper
The rest of the paper is structured as follows. Section 2 contains general definitions and notations used throughout the present work. Most of them are standard, but some are more particular, such as the notions of ω-clauses or specifications. Section 3 describes our procedure for the nested combination of instantiation schemes, and introduces conditions to ensure that completeness is preserved. Section 4 shows some interesting applications of these results for theories that are particularly useful in the field of verification (especially for extensions of the theory of arrays). Section 5 concludes the paper and gives some lines of future work.

Preliminaries
In this section, we first briefly review usual notions and notations about firstorder clausal logic. Then we introduce the rather nonstandard notion of an ω-clause (a clause with infinitely many literals). We define the notion of specifications and provide some examples showing how usual theories such as those for integers or arrays can be encoded. Finally we introduce the notion of instantiation methods.

Syntax
Let S be a set of sort symbols and F be a set of function symbols together with a ranking function rnk : F → S * ×S. For every f ∈ F , we write f : s 1 ×· · ·×s n → s if rnk(f ) = s 1 , . . . , s n , s. If n = 0 then f is a constant symbol of sort s. We assume that F contains at least one constant symbol of each sort. To every sort s ∈ S is associated a countably infinite set X s of variables of sort s, such that these sets are pairwise disjoint. X = s∈S X s denotes the whole set of variables. For every s ∈ S, the set of terms of sort s is denoted by T s (X ) and built inductively as usual on X and F : The set of terms is defined by T(X ) def = s∈S T s (X ). An atom is an equality t ≃ s between terms of the same sort. A literal is either an atom or the negation of an atom (written t ≃ s). If L is a literal, then L c denotes its complementary: (t ≃ s) c def = (t ≃ s) and (t ≃ s) c def = (t ≃ s). A clause is a finite set (written as a disjunction) of literals. We assume that S contains a sort bool and that F contains a constant symbol true of sort bool. For readability, atoms of the form p ≃ true will be simply denoted by p (thus we write, e.g., a ≤ 2 instead of (a ≤ 2) ≃ true). An atom is equational iff it is of the form t ≃ s where t, s = true.
The set of variables occurring in an expression (term, atom, literal or clause) E is denoted by Var(E). E is ground iff Var(E) = ∅. The set of ground terms of sort s is denoted by T s and the set of ground terms by T def = s∈S T s . A substitution is a function that maps every variable to a term of the same sort. The image of a variable x by a substitution σ is denoted by xσ. The domain of a substitution σ is the set 1 dom(σ) def = {x ∈ X | xσ = x}, and its codomain cod(σ) is the set of elements the variables in the domain are mapped to. Substitutions are extended to terms, atoms, literals and clauses as usual: A ground instance of an expression E is an expression of the form Eσ, where σ is a ground substitution of domain Var(E).

Definition 1.
A substitution σ is pure iff for all x ∈ X , xσ ∈ X . In this case, for any term t, tσ is a pure instance of t. A substitution σ is a renaming if it is pure and injective. ♦ A substitution σ is a unifier of a set of pairs It is well-known that all unifiable sets have a most general unifier (mgu), which is unique up to a renaming.

Semantics
An interpretation I is a function mapping: • Every sort symbol s ∈ S to a nonempty set s I .
• Every function symbol f : s 1 × . . . × s n → s ∈ F to a function f I : D I denotes the domain of I, i.e., the set s∈S s I . As usual, the valuation function E → [E] I maps every ground expression E to a value defined as follows:

ω-Clauses
For technical convenience, we extend the usual notion of a clause by allowing infinite disjunction of literals: An ω-clause is a possibly infinite set of literals. ♦ The notion of instance extends straightforwardly to ω-clauses: if C is an ωclause then Cσ denotes the ω-clause {Lσ | L ∈ C} (recall that the domain of σ may be infinite). Similarly, the semantics of ω-clauses is identical to that of standard clauses: if C is a ground ω-clause, then [C] I def = true iff there exists an L ∈ C such that [L] I = true. If C is a non-ground ω-clause, then I |= C iff for every ground substitution of domain Var(C), [Cσ] I = true. The notions of satisfiability, models etc. are extended accordingly. If S, S ′ are two sets of ω-clauses, we write S S ′ if for every clause C ′ ∈ S ′ there exists a clause C ∈ S such that C ⊆ C ′ .
Of course, most of the usual properties of first-order logic such as semidecidability or compactness fail if ω-clauses are considered. For instance, if C stands for the ω-clause

Specifications
Usually, theories are defined by sets of axioms and are closed under logical consequence. In our setting, we will restrict either the class of interpretations (e.g., by fixing the interpretation of a sort int to the natural numbers) or the class of clause sets (e.g., by considering only clause sets belonging to some decidable fragments or containing certain axioms). This is why we introduce the (slightly unusual) notion of specifications, of which we provide examples in the following section: Definition 4. A specification A is a pair (I, C), where I is a set of interpretations and C is a class of clause sets. A clause set S ∈ C is A-satisfiable if there exists an I ∈ I such that I |= S. S and S ′ are A-equisatisfiable if they are both For the sake of readability, if A is clear from the context, we will say that a set of clauses is satisfiable, instead of A-satisfiable. We write (I, C) ⊆ (I ′ , C ′ ) iff I = I ′ and C ⊆ C ′ . By a slight abuse of language, we say that C occurs in A if there exists S ∈ C such that C ∈ S.
In many cases, I is simply the set of all interpretations, which we denote by I fol . But our results also apply to domain-specific instantiation schemes such as those for Presburger arithmetic. Of course, restricting the form of the clause sets in C is necessary in many cases for defining instantiation schemes that are both terminating and refutationally complete. That is why we do not assume that C contains every clause set. Note that axioms may be included in C. We shall simply assume that C is closed under inclusion and ground instantiations, i.e., for all S ∈ C if S ′ ⊆ S and S ′′ only contains ground instances of clauses in S, then S ′ , S ′′ ∈ C. All the classes of clause sets considered in this paper satisfy these requirements.
We shall restrict ourselves to a particular class of specifications: those with a set of interpretations that can be defined by a set of ω-clauses. From now on, we assume that all the considered specifications are ω-definable.

Examples
Example 6. The specification of first-order logic is defined by A fol def = (I fol , C fol ) where: • I fol is the set of all interpretations (i.e. Ax(I fol ) def = ∅).
• C fol is the set of all clause sets on the considered signature.
Example 7. The specification of Presburger arithmetic is defined as follows: • Ax(I Z ) contains the domain axiom: k∈N (x ≃ s k (0) ∨ x ≃ −s k (0)) and the usual axioms for the function symbols 0 : int, − : int → int, s : int → int, p : int → int, + : int × int → int, and for the predicate symbols ≃ k : int × int → bool (for every k ∈ N) ≤: int × int → bool and <: int × int → bool: ≃ k denotes equality modulo k (which will be used in Section 4.1.1); x, y denote variables of sort int and k is any natural number. Note that the domain axiom is an infinite ω-clause, while the other axioms can be viewed as standard clauses.
• C Z is the class of clause sets built on the set of function symbols 0 : int, s : int → int, p : int → int and on the previous set of predicate symbols.
In the sequel, the terms s k (0) and p k (0) will be written k and −k respectively.

Example 8. The specification of arrays is A
where select : array×ind → elem and store : array×ind× elem → array (x is a variable of sort array, z, z ′ are variables of sort ind and v is a variable of sort elem).
• C A is the class of ground clause sets built on select, store and a set of constant symbols.
It should be noted that reals can be also handled by using any axiomatization of real closed fields.

Instantiation Procedures
An instantiation procedure is a function that reduces the A-satisfiability problem for any set of A-clauses to that of a (possibly infinite) set of ground Aclauses.
Definition 9. Let A = (I, C) be a specification. An instantiation procedure for A is a function Θ from C to C such that for every S ∈ C, Θ(S) is a set of ground instances of clauses in S. Θ is complete for A if for every S ∈ C, S and Θ(S) are A-equisatisfiable. It is terminating if Θ(S) is finite for every S ∈ C.♦ If Θ is complete and terminating, and if there exists a decision procedure for checking whether a ground (finite) clause set is satisfiable in I, then the Asatisfiability problem is clearly decidable. Several examples of complete instantiation procedures are available in the literature [24,17,5,18,23,1,7,13,12]. Our goal in this paper is to provide a general mechanism for constructing new complete instantiation procedures by combining existing ones.

Definition
Theories are usually combined by considering their (in general disjoint) union. Decision procedures for disjoint theories can be combined (under certain conditions) by different methods, including the Nelson-Oppen method [27] or its refinements. In this section we consider a different way of combining specifications. The idea is to combine them in a "hierarchic" way, i.e., by considering the formulae of the first specification as constraints on the formulae of the second one.
For instance, if A Z is the specification of Presburger arithmetic and A A is the specification of arrays, then: • 0 ≤ x ≤ n is a formula of A Z (x denotes a variable and n denotes a constant symbol of sort int).
• select(t, x) ≃ a is a formula of A A (stating that t is a constant array).
• 0 ≤ x ≤ n ⇒ select(t, x) ≃ a (stating that t is a constant on the interval [0, n]) is a formula obtained by combining A Z and A A hierarchically.
Such a combination cannot be viewed as a union of disjoint specifications, since the axioms contain function symbols from both specifications. In this example, A Z is a base specification and A A is a nesting specification.
More formally, we assume that the set of sorts S is divided into two disjoint sets S B and S N such that for every function f : s 1 × . . . × s n → s, if s ∈ S B , then s 1 , . . . , s n ∈ S B . A term is a base term if it is of a sort s ∈ S B and a nesting term if it is of a sort s ∈ S N and contains no non-variable base term. In the sequel we let X B def = s∈SB X s (resp. X N def = s∈SN X s ) be the set of base variables (resp. nesting variables) and let F B (resp. F N ) be the set of function symbols whose co-domain is in S B (resp. S N ). An S B -ground instance of an expression E is an expression of the form Eσ where σ is a ground substitution of domain Var(E) ∩ X B . Intuitively, an S B -ground instance of E is obtained from E by replacing every variable of a sort s ∈ S B (and only these variables) by a ground term of the same sort.
Definition 10. Ω B denotes the set of ω-clauses C such that every term occurring in C is a base term. Ω N denotes the set of ω-clauses C such that: 2. For every atom t ≃ s occurring in C, t and s are nesting terms.

♦
Notice that it follows from the definition that Ω B ∩ Ω N = ∅, since S B and S N are disjoint.

Every clause set in
If C is a clause in C, then C B is the base part of the clause and C N is its nesting part. If S is a set of clauses in C, then S B and S N respectively denote the sets {C B | C ∈ S} and {C N | C ∈ S}, and are respectively called the base part and nesting part of S.
The following proposition shows that the decomposition in Condition 2 is unique.
Proposition 13. For every clause C occurring in a clause set in C, there exist two unique clauses C B and C N such that C = C B ∨ C N .
Proof. The existence of two clauses C B , C N is a direct consequence of Condition 2 in Definition 12. Uniqueness follows straightforwardly from Definition 11.
Example 14. Consider the following clauses:

t is lower than the identity)
Clauses c 1 and c 2 occur in A A [A Z ], and for instance, because the atom select(t ′ , i + 1) of the nesting specification contains the non-variable term i + 1 of the base specification. However, c 3 can be equivalently written as follows: x) contains symbols from both A Z (namely ≤) and A A (select) which contradicts Condition 2 of Definition 12. However, c 4 can be handled in this setting by considering a copy A ′ Z of A Z (with disjoint sorts and function symbols). In this case, Of course A ′ Z can be replaced by any other specification containing an ordering predicate symbol. The same transformation cannot be used on the clause c 5 , since (because of the literal select(t, x) ≤ x) the sort of the indices cannot be separated from that of the elements. Again, this is not surprising because, as shown in [6], such axioms (in which index variables occur out of the scope of a select) easily make the theory undecidable.
Since S B and S N are disjoint, the boolean sort cannot occur both in S B and S N . However, this problem can easily be overcome by considering two copies of this sort (bool and bool ′ ).

Nested Combination of Instantiation Schemes
The goal of this section is to investigate how instantiation schemes for B and N can be combined in order to obtain an instantiation scheme for N [B]. For instance, given two instantiation schemes for integers and arrays respectively, we want to automatically derive an instantiation scheme handling mixed axioms such as those in Example 14. We begin by imposing conditions on the schemes under consideration.

Conditions on the Nesting Specification
First, we investigate what conditions can be imposed on the instantiation procedure for the nesting specification N . What is needed is not an instantiation procedure that is complete for N ; indeed, since by definition every term of a sort in S B occurring in C N is a variable, such an instantiation would normally replace every such variable by an arbitrary ground term (a constant, for example). This is not satisfactory because in the current setting, the value of these variables can be constrained by the base part of the clause. This is why we shall assume that the considered procedure is complete for every clause set that is obtained from clauses in C N by grounding the variables in X B , no matter the grounding instantiation.
Definition 15. An S B -mapping is a function α from T B to T B . Such a mapping is extended straightforwardly into a function from expressions to expressions: for every expression (term, atom, literal, clause or set of clauses) E, α(E) denotes the expression obtained from E by replacing every term t ∈ T B occurring in E by α(t).
An instantiation procedure Θ is S B -invariant iff for every S B -mapping α, and every clause C in a set S, C ∈ Θ(S) ⇒ α(C) ∈ Θ(α(S)). ♦ We may now define nesting-complete instantiation procedures. Intuitively, such a procedure must be complete on those sets in which the only terms of a sort in S B that occur are ground, the instances cannot depend on the names of the terms in T B and the addition of information cannot make the procedure less instantiate a clause set.
Definition 16. An instantiation procedure Θ is nesting-complete if the following conditions hold: 1. For all sets S ∈ C N and all sets S ′ such that every clause in S ′ is an S B -ground instance of a clause in S, S ′ and Θ(S ′ ) are A-equisatisfiable.

Conditions on the Base Specification
Second, we impose conditions on the instantiation procedure for the base specification B. We need the following definitions: Definition 17. Let S be a set of clauses and let G be a set of terms. We denote by S ↓G the set of clauses of the form Cσ, where C ∈ S and σ maps every variable in C to a term of the same sort in G. ♦ Proposition 18. Let S be a set of clauses and let G and G ′ be two sets of ground terms. If G ⊆ G ′ then S ↓G ⊆ S ↓G ′ .
Definition 19. If S is a set of clauses, we denote by S ⋆ ∨ the set of clauses of the form i=1,...,n C i σ i such that for every i ∈ [1, n], C i ∈ S and σ i is a pure substitution. ♦ Example 20. Let S = {p(x, y)}. Then S ⋆ ∨ contains among others the clauses Definition 21. An instantiation procedure Θ for B is base-complete iff the following conditions hold: 1. For every S ∈ C B there exists a finite set of terms G S such that Θ(S) = S ↓GS and Θ(S) and S are B-equisatisfiable.
Obviously these conditions are much stronger than those of Definition 16. Informally, Definition 21 states that: 1. All variables must be instantiated in a uniform 3 way by ground terms, and satisfiability must be preserved.
2. The instantiation procedure is monotonic.
3. The considered set of ground terms does not change when new clauses are added to S, provided that these clauses are obtained from clauses already occurring in S by disjunction and pure instantiation only.

Definition of the Combined Instantiation Scheme
We now define an instantiation procedure for N [B]. Intuitively this procedure is defined as follows.
1. First, the nesting part of each clause in S is extracted and all base variables are instantiated by arbitrary constant symbols • (one for each base sort).
2. The instantiation procedure for N is applied on the resulting clause set. This instantiates all nesting variables (but not the base variables, since they have already been instantiated at Step 1).
3. All the substitutions on nesting variables from Step 2 are applied to the initial set of clauses.

5.
We thus replace all base variables by every term in {a, b} yielding the set It is straightforward to check that this set of clauses is unsatisfiable. Any SMT-solver capable of handling arithmetic and propositional logic can be employed to test the satisfiability of this set.
The formal definition of the procedure is given below. Let γ • be a substitution mapping every variable of a sort s ∈ S B to an arbitrary constant symbol • s of sort s.
• θ ′ is obtained from θ by replacing every occurrence of a constant symbol • s in the co-domain of θ by a fresh variable of the same sort.
• σ maps every variable in Cθ ′ to a term of the same sort in G S B . ♦ The following proposition is straightforward to prove and states the soundness of this procedure:

Completeness
The remainder of this section is devoted to the proof of the main result of this paper, namely that the procedure Theorem 25. Let Θ B be a base-complete instantiation procedure (for B) and let Θ N be a nesting-complete instantiation procedure (for N ).
; furthermore, this procedure is monotonic and S B -invariant.
The rest of the section (up to Page 21) can be skipped entirely by readers not interested in the more theoretical aspects of the work. The proof of this theorem relies on a few intermediate results that are developed in what follows.

Substitution Decomposition
Definition 26. A substitution σ is a base substitution iff dom(σ) ⊆ X B . It is a nesting substitution iff dom(σ) ⊆ X N and for every x ∈ dom(σ), xσ contains no non-variable base term. ♦ We show that every ground substitution can be decomposed into two parts: a nesting substitution and a base substitution. We begin by an example: The following result generalizes this construction: Proposition 28. Every ground substitution σ can be decomposed into a product σ = (σ N σ B )| dom(σ) where σ N is a nesting substitution, σ B is a base substitution, and for all x ∈ dom(σ B ) \ dom(σ), Proof. Let E be the set of subterm-maximal base terms occurring in terms of the form xσ, with x ∈ dom(σ). Let ν be a (partial) function mapping every term t ∈ E ∩ cod(σ) to an arbitrarily chosen variable ν(t) such that ν(t)σ = t. This function ν is extended into a total function on E by mapping all terms t for which ν(t) is undefined to pairwise distinct new variables, not occurring in dom(σ). Note that ν is injective by construction. The substitutions σ B and σ N are defined as follows: • dom(σ N ) def = dom(σ)∩X N and xσ N is the term obtained by replacing every occurrence of a term t ∈ E in xσ by ν(t); By construction, σ N is a nesting substitution and σ B is a base substitution.
. By definition of σ B , x is of the form ν(t) for some t ∈ E, and there is no variable y ∈ dom(σ) such that yσ = t, since otherwise ν(t) would have been defined as y. Thus ∀y ∈ dom(σ B ) ∩ dom(σ), xσ B = yσ = yσ B . Now if y ∈ dom(σ B ) \ dom(σ) and xσ B = yσ B , then y is also of the form ν(s) for some s ∈ E and we have xσ B = t and yσ B = s, hence t = s and x = y.

Partial Evaluations
Given a set of clauses S in N [B] and an interpretation I of B, we consider a set of clauses S ′ of N by selecting those ground instances of clauses in S whose base part evaluates to false in I and adding their nesting part to S ′ . More formally: Definition 29. For every clause C ∈ C B and for every interpretation I ∈ I B , we denote by Φ I (C) the set of ground substitutions η of domain Var(C) such that I |= Cη. Then, for every S ∈ C we define: , where x, y, a are of sort int and z is a variable of a sort distinct from int. Let I be the interpretation of natural numbers such that a I = 1. Then The following lemma shows that S| I is N -unsatisfiable when S is N [B]unsatisfiable.
Lemma 31. For every N [B]-unsatisfiable set of clauses S ∈ C and for every I ∈ I B , S| I is N -unsatisfiable.
Proof. Let N [B] = (I, C). Assume that S| I is N -satisfiable, i.e. that there exists an interpretation J ∈ I N validating S| I . W.l.o.g. we assume that the domain of J is disjoint from that of I. We construct an interpretation K ∈ I satisfying S, which will yield a contradiction since S is N [B]-unsatisfiable by hypothesis.
For all sort symbols s ∈ S B and for all e ∈ s I , we denote by γ(e) an arbitrarily chosen ground term in T B such that [γ(e)] I = e 6 . If E is a ground expression, we denote by E↓ γ the expression obtained from E by replacing every term t by γ( We define the interpretation K by combining I and J as follows: • K coincides with I on S B and on every function symbol whose co-domain is in S B .
• K coincides with J on S N .
• For all function symbols f ∈ F N of arity n, f K (e 1 , . . . , e n ) def = f J (ψ(e 1 ), . . . , ψ(e n )). Note that f K is well-defined since by definition of ψ, if e ∈ s K then ψ(e) ∈ s J .
Let E be a ground expression (term, atom, literal, clause or ω-clause) such that E↓ γ = E. Assume that E is a ground instance of an expression occurring in a clause in Ω N . We prove by structural induction on E that [E] J = ψ([E] K ).
• If E is a term of a sort in S B then since I and K coincide on Thus, since the domains of I and J are disjoint, • If E is an atom of the form t 1 ≃ t 2 then t 1 , t 2 ∈ S B . Indeed E occurs in a ground instance of a clause C occurring in Ω N and by Definition 10, such clauses cannot contain equalities between base terms. Thus we have ψ([t i ] K ) = [t i ] K (for i = 1, 2) and the proof is straightforward.
• The proof is immediate if E is a literal or a (possibly infinite) disjunction of literals.
Since J |= S| I and all specifications are assumed to be ω-definable (see Definition 5), we deduce that K |= S| I ∪ Ax(I N ). Indeed, for the sake of contradiction, assume that there exists an ω-clause C ∈ S| I ∪ Ax(I N ) and a ground substitution θ of domain Var(C) such that K |= Cθ. Since K |= t ≃ t↓ γ for every term t, necessarily K |= Cθ ′ where xθ ′ def = xθ↓ γ . But then Cθ ′ ↓ γ = Cθ ′ and since [E] J = ψ([E] K ), we conclude that J |= Cθ ′ which is impossible since by hypothesis J is an N -model of S| I .
We now prove that K |= S. Let C ∈ S and η be a ground substitution of domain Var(C). W.l.o.g. we assume that ∀x ∈ Var(C), xη ↓ γ = xη. Let η B (resp. η N ) be the restriction of η to the variables of a sort in S B (resp. in S N ).
Finally, since K coincides with I on S B ∪ F B we have K |= Ax(I B ). This proves that K is an N [B]-model of S, which is impossible.

Abstraction of Base Terms
Lemma 31 relates the N [B]-unsatisfiability of a set of clauses S to the Nunsatisfiability of sets of the form S| I . By definition, S| I is of the form S ′ σ, for some clause set S ′ ∈ C N and for some ground base substitution σ. However, since neither Ax(I N ) nor C N contains symbols of a sort in S B , the interpretation of the ground base terms of S ′ in an interpretation of I N is arbitrary: changing the values of these terms does not affect the N -satisfiability of the formula. Thus the actual concrete values of the ground base terms does not matter: what is important is only how these terms compare to each other.
Therefore, if Sσ |= N Cσ for some base substitution σ then actually Sθ |= N Cθ, for every substitution θ such that xθ = yθ ⇔ xσ = yσ. This will be formalized in the following definitions and lemma. We first introduce an unusual notion of semantic entailment. The intuition is that variables in S B are considered as "rigid" variables that must be instantiated by arbitrary ground terms: where x, y, u are variables. Then S |= r q(x), but S |= r q(0). Note that x denotes the same variable in S and q(x) (the variables are not renamed).
Definition 35. For every substitution σ we denote by σ an arbitrarily chosen pure substitution such that xσ = yσ ⇒ x σ = y σ , for every x, y ∈ X . ♦ Note that such a substitution always exists. The next lemma can be viewed as a generalization lemma: it shows that the values of the ground base terms can be abstracted into variables.
Lemma 36. Let S ∈ C N and σ be a base substitution such that dom(σ) ⊆ X B . If Sσ |= N Cσ then S σ |= r C σ .
Proof. Let θ be a substitution of domain X B . We assume that there exists an I ∈ I N such that I |= S σ θ and I |= C σ θ, and we show that a contradiction can be derived.
For every ground term t, we denote by Γ(t) the ground term obtained from t by replacing every ground subterm of the form xσ by x σ θ. Γ is well-defined: indeed, if xσ = yσ, then by definition of σ , x σ = y σ thus x σ θ = y σ θ. Let J be the interpretation defined as follows 7 : • If s ∈ S B then s J def = T s .
• If f is a symbol of rank s 1 × . . . × s n → s where s 1 , . . . , s n , s ∈ S B then f J (t 1 , . . . , t n ) def = f (t 1 , . . . , t n ). 7 Intuitively, J interprets every base term as itself and coincides with I on nesting terms.
• If f is a symbol of rank . By construction, [s] J = s for every ground base term s; we prove that for every ground nesting term t, [t] J = [Γ(t)] I , by induction on t. If t = f (t 1 , . . . , t n ), Now let σ ′ be a ground substitution with a domain in X N , and let θ ′ def = Γ•σ ′ . We prove that for every expression E occurring in S ∪ {C} that is not a base term, [ We thus conclude that for every clause D ∈ S ∪ {C} ∪ Ax(I), J |= Dσσ ′ iff I |= D σ θθ ′ . Since I |= S σ θ ∪ Ax(I N ), we deduce that J |= Sσ ∪ Ax(I N ), which proves that J ∈ I N . Since I |= C σ θ we have J |= Cσ, which is impossible because J ∈ I N and Sσ |= N Cσ.

Completeness of Θ B for ω-Clauses
In this section, we prove that any procedure that is base-complete is also complete for some classes of sets of possibly infinite ω-clauses -this is of course not the case in general. We first notice that the notation S ⋆ ∨ of Definition 19 can be extended to ω-clauses, by allowing infinite disjunctions: Definition 37. Given a set of clauses, S, we denote by S ω ∨ the set of ω-clauses of the form {C i σ | i ∈ N, C i ∈ S, σ i is a pure substitution}. ♦ The notation S ↓G also extends to ω-clauses: S ↓G is the set of clauses Cσ such that C ∈ S and σ maps every variable in C to a term in G.
Proposition 38. Let S be a finite set of clauses and G be a finite set of terms. Then S ω ∨ ↓G is a finite set of clauses.
Proof. By definition, any literal occurring in S ω ∨ is of the form Lσ where L is a literal occurring in a clause C ∈ S and σ is a pure substitution. Thus any literal occurring in S ω ∨ ↓G is of the form Lσθ where L is literal occurring in a clause in S, σ is pure and θ maps every variable to a term in G. Obviously, since G and S are finite, there are finitely many literals of this form. Hence all the ω-clauses in S ω ∨ ↓G are actually finite, and there are only finitely many possible clauses.
Lemma 39. Let S be a set of clauses and S ′ a set of ω-clauses with S ′ ⊆ S ω ∨ . If G if a finite set of terms, then there exists a set of clauses S ′′ S ′ such that S ′′ ↓G = S ′ ↓G .
Proof. Let C be a clause in S ′ ↓G ; by Proposition 38, C is finite. By definition there exists an ω-clause C ′ ∈ S ′ such that C = C ′ θ, where θ is a substitution mapping all the variables in Var(C ′ ) to a term in G. Every literal in C ′ is of the form Lγ, where literal L occurs in S and γ is a pure substitution of Var(L). Since S and G are finite, there is a finite number of possible pairs (L, γθ). Thus there exists a finite subset D C ⊆ C ′ such that for every literal Lγ occurring in C ′ , there exists a literal Lγ ′ ∈ D C with γθ = γ ′ θ.
Every variable occurring in a literal Lγ of C ′ is of the form xγ, where x ∈ Var(L). Let η C be the substitution mapping every variable xγ ∈ Var(C ′ \ D C ) to xγ ′ . Then for every literal Lγ ∈ C ′ , we have Lγη C = Lγ ′ ∈ D C . Thus We define S ′′ = {D C | C ∈ S ′ ↓G }; obviously S ′′ S ′ and by definition S ′′ ↓G ⊇ S ′ ↓G . Conversely, let E be a clause in S ′′ ↓G , E is necessarily of the form D C θ where C ∈ S ′ ↓G and θ maps every variable to a term in G. But then E is of the form C ′ η C θ, where C ′ ∈ S ′ , and η C θ is a substitution mapping every variable in C ′ to a term in G; thus E must occur in S ′ ↓G . The next lemma proves the completeness result for ω-clauses: Lemma 40. Let Θ be a base-complete instantiation procedure and S be a set of clauses. If S ′ ⊆ S ω ∨ then S ′ and S ′ ↓GS are B-equisatisfiable.
Note that the clauses in S are finite, but those in S ′ may be infinite.
Proof. S ′ ↓GS is a logical consequence of S ′ , thus if S ′ is satisfiable then so is S ′ ↓GS ; we now prove the converse. Let I be an interpretation validating S ′ ↓GS . By Lemma 39, there exists a set of clauses S ′′ such that S ′′ S ′ and S ′ ↓GS = S ′′ ↓GS . Since I |= S ′ ↓GS , we deduce that S ′′ ↓GS is satisfiable, hence (since by Condition 1 in Definition 21, Θ is complete 8 ) so is S ′′ . But S ′′ S ′ therefore by Proposition 3, S ′ is satisfiable.

Main Proof
We are now in the position to give the proof of the main theorem. 8 Recall that S ′′ is a set of finite clauses.
Proof (of Theorem 25). Let Θ def = Θ N [Θ B ] and let S be an unsatisfiable clause set in C. We prove that Θ(S) is also unsatisfiable.
Let I ∈ I B , by Lemma 31, the set S| I = {C N η | C ∈ S, η ∈ Φ I (C)} is N -unsatisfiable, and by completeness of Θ N , so is Θ N (S| I ). We define This set may be infinite, since no assumption was made on the decidability of N . Every clause in A I is of the form Cηθ where I |= C B η, 9 and by Proposition 28, Cηθ = Cσσ ′ , where σ is a nesting substitution and σ ′ is a base substitution. In particular, since dom(σ) ⊆ X N , Since the C B cannot contain nesting variables, we have C B σσ ′ = C B σ ′ . Hence A I |= N Cσσ ′ ∈AI C B σ ′ . We let T = S B and define: Note that since A I may be infinite, E I is an ω-clause that belongs to T ω ∨ . Lemma 36 guarantees that B I |= r E I ; thus by definition, for all sets of ground base terms G, B I ↓G |= N E I ↓G . This is in particular the case for G = G T .
Let U = {E I | I ∈ I B }; by construction, for all I ∈ I B , I |= U ; hence U is Bunsatisfiable and since U ⊆ T ω ∨ , by Lemma 40, U ↓GT is also B-unsatisfiable. We have shown that B I ↓G |= N E I ↓G . This, together with the fact that There remains to prove that I∈IB B I ↓GT ⊆ Θ(S) to obtain the result. Consider the function α that maps every term of a sort s ∈ S B to • s ; it is clear that α(S| I ) ⊆ S N γ • . In particular, if C N σσ ′ ∈ Θ N (S| I ), then by the S B -invariance and monotonicity of Θ N , Therefore, (Cσ σ ′ ) ↓GT ⊆ Θ(S), hence the result.
The fact that Θ N [Θ B ] is S B -invariant and monotonic follows immediately from the definition and from the fact that Θ N is S B -invariant and that Θ B and Θ N are monotonic.

Applications
In this section, we show some examples of applications of Theorem 25 that are particularly relevant in the context of program verification.

Presburger Arithmetic
No base-complete instantiation procedure can be defined for the specification A Z as defined in Section 2.5, as evidenced by the following example.
Example 41. Assume that a base-complete procedure Θ exists, and consider the clause set S = {x ≃ y + 1, y ≃ 0}. Since Θ is base-complete by hypothesis, by Condition 1 of Definition 21, Θ(S) = S ↓GS for some finite set of ground terms G S , and by Condition 3, G S contains G S ⋆ ∨ . But S ⋆ ∨ contains in particular the clause: C n : It is however possible to define base-complete procedures for less general specifications, that are still of a practical value.
Definition 42. Let χ be a special constant symbol of sort int, let m be a natural number distinct from 0 and let T B be a set of ground terms of sort int not containing χ. We denote by B Z the specification (I ′ Z , C ′ Z ) defined as follows.
is defined in Example 7 (Section 2.5). C ′ Z contains every clause set S such that every non-ground literal occurring in a clause in S is of one of the following forms: • x ≤ t or t ≤ x for some variable x and for some ground term t ∈ T B ; • x ≤ y for some variables x, y; • x ≃ k t for some k ∈ N \ {0} that divides m, some ground term t ∈ T B and some variable x. ♦ Intuitively, the constant χ occurring in Ax(I ′ Z ) is meant to translate the fact that the terms appearing in S admit an upper bound (namely χ). It is clear that if S is an arbitrary set of arithmetic clauses (not containing the special constant χ), then the set T B and the integer m can be computed so that S indeed belongs to C ′ Z . Definition 43. For every set of clauses S ∈ C ′ Z , let B S be the set of ground terms t such that either t = χ or S contains an atom of the form x ≤ t. We define the instantiation procedure Θ Z by: The two following propositions are straightforward consequences of the definition: Proposition 45.
Proof. This is immediate because the set of ground terms occurring in S ⋆ ∨ is the same as that of S, since the atoms in S ⋆ ∨ are pure instances of atoms in S.
Proof. We adopt the following notations for the proof: given a set of terms W , we write x ≤ W for t∈W x ≤ t and x ≥ W for t∈W x ≥ t. Additionally, if K is a set of pairs (k, t) ∈ N × T int then we denote by ¬K(x) the disjunction Let S ∈ C ′ Z and assume that S is B Z -unsatisfiable, we prove that Θ Z (S) is also B Z -unsatisfiable. Let I ∈ I ′ Z , then in particular, I |= {χ > t + m | t is a ground term in S ′ }. Let C be a clause in S such that I |= C. By definition of C ′ Z , C can be written as where D is ground and where the x i 's (1 ≤ i ≤ n) denotes distinct variables 10 . Since I |= C, there exists a ground substitution θ such that I |= Cθ, i.e., for all i ∈ [1, n]: n]}, we deduce that I |= Cσ. Since Cσ ∈ S ↓G Z S , we conclude that S ↓G Z S is B Z -unsatisfiable, hence the result. By construction, G Z S is finite, hence Condition 1 of Definition 21 is satisfied. By Propositions 44 and 45, Conditions 2 and 3 are satisfied, respectively, which concludes the proof.

Term Algebra with Membership Constraints
We give a second example of a specification for which a base-complete instantiation procedure can be defined. We consider formulae built over a signature containing: • a set of free function symbols Σ; • a set of constant symbols interpreted as ground terms built on Σ; • a set of monadic predicate symbols P, each predicate p in P is interpreted as a (fixed) setp of ground terms built on Σ. We assume that the emptiness problem is decidable for any finite intersection of these sets (for instancê p can be the set of terms accepted by a regular tree automaton, see [9] for details).
From a more formal point of view: Definition 47. Let Σ ⊆ F B . We denote by T(Σ) s the set of ground terms of sort s built on Σ. Let P be a finite set of unary predicate symbols, together with a function p →p mapping every symbol p : s → bool ∈ P to a subset of T(Σ) s . We denote by A ∈ the specification (I ∈ , C ∈ ) where: • Ax(I ∈ ) contains the following axioms: • Every non-ground atom in C ∈ is of the form ¬p(x), or of the form x ≃ t for some ground term t. ♦ The axioms of Ax(I ∈ ) entail the following property which is proved by a straightforward induction on the depth of the terms: Proposition 48. For all interpretations I ∈ I ∈ and all terms t, t ′ occurring in a clause in C ∈ , if [t] I = [t ′ ] I then t = t ′ .
If the sets in {p | p ∈ P} are regular then A ∈ is well-known to be decidable, see, e.g., [10]. We define the following instantiation procedure for A ∈ : Definition 49. Let G ∈ S be a set of ground terms containing: • Every ground term t such that S contains an atom of the form x ≃ t.
• An arbitrarily chosen ground term s P ∈ p∈Pp , for each P ⊆ P such that p∈Pp = ∅ (recall that the emptiness problem is assumed to be decidable).
Proof. Let C be a clause in C ∈ , C is of the form are variables, t i is a ground term for i ∈ [1, n] and p j ∈ P for j ∈ [1, m]. Let X = {x 1 , . . . , x n } and Y = {y 1 , . . . , y m }; note that these sets are not necessarily disjoint. For every variable y ∈ Y we denote by P y the set of predicates p j (1 ≤ j ≤ m) such that y j = y and we let s y def = s Py . Consider the substitution σ of domain X ∪ Y such that: • if y ∈ Y \ X then yσ def = s y (notice that s y must be defined since y ∈ Y ) We prove that Cσ |= A∈ C.
Let I be an interpretation such that I |= Cσ and I |= C. Then there exists a substitution θ such that I |= Cθ, which implies that for all i ∈ [1, n], [x i θ] I = [t i ] I , and for all j ∈ [1, m], [y j θ] I ∈ [p j ] I . Proposition 48 entails that x i θ = t i for all i ∈ [1, n], and y j θ ∈p j for all j ∈ [1, m]. Thus, in particular, for all x ∈ X, xσ = xθ, and for all y ∈ Y \ X, p∈Pyp = ∅.
Since I |= Cσ and x i σ = t i for all i ∈ [1, n], there must exist a j ∈ [1, m] such that [y j σ] I ∈ [p j ] I ; and, again by Proposition 48, this is equivalent to y j σ / ∈p j . If y j ∈ X, then y j θ = y j σ / ∈p j and I |= Cθ, which is impossible. Thus y j ∈ Y \ X, and since p∈Py jp = ∅, by construction, y j σ = s yj ∈p j ; this contradicts the assumption that y j σ / ∈p j . Since Cσ |= A∈ C, we deduce that for every clause C ∈ S, there exists a D ∈ S ↓G ∈ S such that D |= A∈ C, and therefore, S ≡ A∈ S ↓G ∈ S . By construction, Hence all the conditions of Definition 21 are satisfied.

Combination of Specifications
Building on the results of the previous section, we now provide some concrete applications of Theorem 25.

Combining First-order Logic without Equality and Presburger Arithmetic
We begin with a simple example to illustrate how the method works. We show how to enrich the language of first-order predicate logic with some arithmetic constraints. We assume that F contains no function symbol of co-domain int other than the usual symbols 0, s, +, − introduced in Section 2.5. Let N fol be the restriction of the specification A fol defined in Example 6 to non-equational clause sets (i.e. to clause sets in which all atoms are of the form t ≃ true). We consider the combination N fol [B Z ] of the specification B Z introduced in Section 4.1.1 with N fol . According to Theorem 46, Θ Z is basecomplete for B Z ; thus, in order to apply Theorem 25, we only need to find a nesting-complete instantiation procedure for N fol . We will use an instantiation procedure based on hyper linking [22]. It is defined by the following inference rule: if σ is an mgu. of the (l i , m c i )'s. If S is a set of clauses, we denote by Θ ′ fol (S) the set of clauses that can be obtained from S by applying the rule above (in any number of steps) and by Θ fol (S) the set of clauses obtained from Θ fol (S) by replacing all remaining variables of sort s by a constant symbol ⊥ s of the same sort.
Proposition 51. Θ fol is nesting-complete for N fol .
Proof. In [22], it is proven that S and Θ fol (S) are equisatisfiable, thus Condition 1 of Definition 16 holds; furthermore, by definition, Θ fol is monotonic. To verify that Θ fol is S B -invariant, it suffices to remark that if a clause D is deducible from a set of clauses S by the instantiation rule above, then for every S B -mapping α, α(D) must be deducible from Θ fol (α(S)), since the unifiers are not affected by the replacement of ground terms: if an mgu maps a variable x to a term t in S, then the corresponding mgu will map x to α(t) in α(S).
Note that in general, Θ fol [Θ Z ] (and Θ fol ) are not terminating. However, Θ fol [Θ Z ] is terminating if the set of ground terms containing no subterm of sort int (and distinct from • int ) is finite (for instance if F contains no function symbol of arity greater than 0 and of a sort distinct from int).
Example 52. Consider the following set of clauses S, where i, j denote variables of sort int, x, y denote variables of sort s, and F contains the following symbols: a, b : int, c, d : s, p : int × s → bool and q : int × s × s → bool.
Clauses (2) and (3) are not in A. Indeed, the non-arithmetic atom p(a, c) contains a non-variable arithmetic subterm a and (3) contains a literal j < b that is not allowed in B Z (see Definition 42). Thus these clauses must be reformulated as follows: To apply the procedure Θ fol [Θ Z ], we compute the set S N and replace every arithmetic variable occurring in it by a special constant • of sort int: We apply the procedure Θ fol . The reader can verify that we obtain the following clause set: Next we consider the clauses in and compute the set G Z S B Z , according to Definition 43. The terms occurring as the right operands of a symbol ≤ are {a, b − 1}. The least common multiple of all the natural numbers k such that S B contains a comparison modulo k is 2.
To get the clause set Θ[Θ Z ](S), the substitutions generated by Θ are combined with all instantiations of integer variables by elements of G Z S B Z . This yields: The resulting set of clauses is N fol [B Z ]-unsatisfiable, hence, so is S.

Arrays with Integer Indices and Uninterpreted Elements
The specification of arrays with integer indices and uninterpreted elements can be defined as a hierarchic expansion of the base specification B Z defined in Section 4.1.1 with a simple specification N A = (I fol , C A ), where the clauses in C A are built on a set of variables of sort int, on a signature containing only constant symbols of sort array or elem and a function symbol select : array × int → elem. We have assumed that C A contains no occurrence of the function symbol store for convenience. There is no loss of generality: indeed, every definition of the form s = store(t, i, a) where s, t, i, a are ground terms can be written as the conjunction of the following clauses: It is simple to verify that these three clauses are in C A . Obviously, the last two clauses are equivalent to z ≃ i ∨ select(s, z) ≃ select(t, z).
There exists a straightforward nesting-complete instantiation procedure for N A : namely the identity function id(S) def = S. This is indeed an instantiation procedure since all the variables occurring in C A are of type int; these variables will already be instantiated by the instantiation procedure for B Z and the remaining clause set will be ground. The following result is a direct consequence of Theorem 25: We provide some examples of properties that have been considered in [6,21,20], and can be expressed in N A [B Z ] (t,t ′ denotes constant symbols of sort array).
--The values of t at even indices are disjoint from the ones at odd ones.
--For every even index, the value of t is equal to the value of t ′ or t ′′ .
Properties (1)(2)(3) can be expressed in the Array property fragment (see [6]), but not Property (4), because of condition i ≃ 2 0. Property (4) is expressible in the Logic for Integer Arrays (LIA) introduced in [21], but not Property (5), because there is a disjunction in the value formula.
On the other hand, Properties such as Injectivity cannot be expressed in our setting: Indeed, the literal i ≃ j is not allowed in C ′ Z .

Arrays with Integer Indices and Interpreted Elements
Instead of using the mere specification N A , one can combine the specification B Z with a richer specification, with function and predicate symbols operating on the elements of the arrays. For instance, consider the specification N R A = (I R , C R A ), where Ax(I R ) is some axiomatization of real closed fields over a signature F R and the clauses occurring in C R A are built on a set of variables of sort int and on a signature containing all function symbols in F R , constant symbols of sort array or real and a function symbol select : array × int → real. Then N R A [B Z ] is the specification of arrays with integer indices and real elements, and an immediate application of Theorem 25 yields: To model arrays with integer indices and integer elements, it is necessary to use a combination of the specification B Z with a specification containing the symbols in B Z : 0 : int, s : int → int, ≤: int × int → bool, etc. However, this is not permitted in our approach since the clause sets of the nesting specification would contain function symbols whose co-domain would be a sort of the base specification (namely int), thus contradicting the conditions on S B and S N (see Section 3.1). A solution is to use a copy of the sort int and of every symbol of co-domain int. We denote by N Z A the specification (I ′ Z , C Z ) where Ax(I ′ Z ) is the image of Ax(I Z ) by the previous transformation and where the clause sets in C Z A are built on a set of variables of sort int and on a signature containing all function symbols 0 ′ , s ′ , ≤ ′ ,. . . in Ax(I ′ Z ), constant symbols of sort array or int ′ and a function symbol select : ] is a specification of arrays with integer indices and integer elements, and by Theorem 25, id[Θ Z ] is complete for N Z A [B Z ]. Note however that, due to the fact that the sort symbols are renamed, equations between integer elements and integer indices are not permitted: indices cannot be stored into arrays and terms of the form select(t, select(t, i)) are forbidden. However, the sharing of a constant symbol c between the two sorts int and int ′ (as in the equation: select(t, c) ≃ c) is possible, by adding ground axioms of the form: k ≃ c ⇒ k ′ ≃ c ′ , where c ′ denotes the copy of c, k is any integer in int and k ′ denotes its copy in int ′ . Let A denote this set of axioms; it is obvious that A is countably infinite. It is clear that id[Θ Z ](S ∪ A) = id[Θ Z ](S) ∪ A, so that the instantiation procedure is not affected by this addition. Thus these axioms can be simply removed afterward by "merging" int and int ′ and by replacing c ′ by c (it is straightforward to verify that this transformation preserves satisfiability).
We provide some examples. ≤ ′ and + ′ are renaming of the symbols ≤ and + respectively. Notice that the indices of the arrays are of sort int, whereas the elements are of sort int ′ . The following properties can be expressed in N Z A [B Z ]: --For every even index lower than n, t is the sum of t ′ and t ′′ .
Here are some examples of properties that cannot be handled: The distance between the values at two consecutive index --is at most 2.
Property (4) is not in N Z A [B Z ] because there is an equation relating an element of sort int (i.e. an index) to an element of sort int ′ = int (an element). Property (5) could be expressed in our setting as ∀i, j, j ≃ i+1∨select(t, i)−select(t, j) ≤ 2 but the atom j ≃ i + 1 is not in B Z . Property (5) can be expressed in the logic LIA (see [21]). This shows that the expressive power of this logic is not comparable to ours.
These results extend straightforwardly to multidimensional arrays.

Arrays with Translations on Arrays Indices
In some cases, properties relating the value of an array at an index i to the value at index i + k for some natural number k can be expressed by reformulations.
Definition 55. Let S be a clause set, containing clauses that are pairwise variable-disjoint. Let λ be a function mapping every array constant to a ground term of sort int. S is shiftable relatively to λ iff the following conditions hold: 1. Every clause in S is of the form C ∨ D, where D is a clause in N Z A and every literal in C is of one of the following form: i ≤ j + s, i ≤ s, s ≤ i, i ≃ k s, where i, j are variables of sort int, s is a ground term of sort int and k is a natural number.
2. For every clause C ∈ S and for every literal i ≤ j + s occurring in C, where i, j are variables and s is a term of sort int, C contains two terms of the form select(t, i) and select(t ′ , j) where λ(t ′ ) − λ(t) is equivalent to s.
3. If C contains two terms of the form select(t, i) and select(t ′ , i) then λ(t) = λ(t ′ ).
4. If C contains a equation t ≃ t ′ between arrays then λ(t) = λ(t ′ ). ♦ The existence of such a function λ is easy to determine: conditions (2-4) above can immediately be translated into arithmetic constraints on the λ(t)'s, and the satisfiability of this set of constraints can be tested by using any decision procedure for Presburger arithmetic.
We define the following transformation of clause sets: Definition 56. Let t → t ′ be an arbitrarily chosen function mapping all the constants t of sort array to pairwise distinct fresh constants t ′ of sort array. We denote by shift(S) the clause set obtained from S by applying the following rules: • every clause C containing a term of the form select(t, i) (where i is a variable) is replaced by C{i → i − λ(t)}; • then, every term of the form select(t, s) is replaced by select(t ′ , s + λ(t)).♦ Lemma 57. Let S be a shiftable clause set. Then: • shift(S) and S are equisatisfiable.
Proof. It is clear that for every clause C in S, C ≡ C{i → i − k}: since i ranges over all integers, i and i − k range over the same set. The replacement of select(t, s) by select(t ′ , s+λ(t)) obviously preserves sat-equivalence: it suffices to interpret t ′ as the array defined by the relation: select(t ′ , i) def = select(t, i − λ(t)). Thus shift(S) and S are equisatisfiable.
We prove that shift(S) is in N Z A [B Z ]. By Condition 3 of Definition 55, if a clause C{i → i − λ(t)} contains a term of the form select(s, i − λ(t)) then we must have λ(s) = λ(t), thus this term is replaced by select(s ′ , i) when the second rule above is applied. Consequently, the non-arithmetic part of the resulting clause cannot contain any non-variable term of sort int. Now assume that C contains an arithmetic literal of the form i ≤ j + s. Then by condition 2, C also contains terms of the form select(t, i) and select(t ′ , j), where λ(t ′ ) − λ(t) is equivalent to s. Hence, the clause in shift(S) corresponding to C contains the literal i − λ(t) ≤ j − λ(t ′ ) + s ≡ i ≤ j − (λ(t ′ ) − λ(t)) + s ≡ i ≤ j.
We provide an example in which this result applies.
Example 58. Consider for instance the following clause set: (1) ∀i, j, a ≤ i ∨ i ≤ b ∨ j ≃ i − a ∨ select(s, i) ≃ select(t, j) --s is identical to t up to a shift of length a.
(2) ∀i, j, a ≤ i ∨ i ≤ b ∨ j ≃ i − a ∨ select(u, i) ≃ select(s, j) --u is identical to s up to a shift of length a.
(3) c ≥ a + a (4) c ≤ b (5) i ≃ c ∨ j ≃ c − a − a ∨ select(u, c) ≃ select(t, j) --u is not identical to t up to a shift of length a + a.
It is simple to check that S is shiftable relatively to the mapping: λ(u) = a + a, λ(s) = a and λ(t) = 0. According to Definition 57, S is reformulated as follows: shift(S) and S are equisatisfiable, and shift(S) belongs to N Z A [B Z ]. The unsatisfiability of shift(S) can be proven by applying the procedure id[Θ Z ].

Nested Arrays
An interesting feature of this approach is that it can be applied recursively, using as base and/or nesting specifications some nested combination of other specifications.
In A Z3 , the (integer) indices of an array t can themselves be stored into arrays of integers, but of a different type than t.
Example 60. The following clause set is A Z3 -unsatisfiable (for the sake of readability we use t ≃ s as a shorthand for t ≤ s ∨ t ≤ s): ∨select ′ (t ′ , x ′ ) > select(t ′ , y ′ ). --t ′ • t is not sorted.
We describe the way the procedure works on this very simple but illustrative example. According to the definition of id[Θ ′ Z ][Θ Z ], the variables i, j, x and y are replaced by a special symbol • and the instantiation procedure id[Θ ′ Z ] is applied. The variables i ′ , j ′ , x ′ , y ′ are replaced by a constant symbol • ′ and the procedure id is applied on the resulting clause set (in a trivial way, since this set is ground). Next, we apply the procedure Θ ′ Z . According to Definition 43, Θ ′ Z instantiates the variables i ′ , j ′ , x ′ , y ′ by select(t, •). This substitution is applied to the original clause set and the procedure Θ Z is invoked. The variables i, j, x and y, and the constant symbol • are replaced by {a, b}. After obvious simplifications, we obtain the following set of instances: select(t, a)) ≤ ′ select ′ (t ′ , select(t, a)) select(t, a) ≤ select(t, b) ∨ select ′ (t ′ , select(t, a)) ≤ ′ select ′ (t ′ , select(t, b)) select(t, b) ≤ select(t, b) ∨ select ′ (t ′ , select(t, b)) ≤ ′ select ′ (t ′ , select(t, b)) select(t, b) ≤ select(t, a) ∨ select ′ (t ′ , select(t, a)) ≤ ′ select ′ (t ′ , select(t, a)) a ≤ b select ′ (t ′ , select(t, a)) > select ′ (t ′ , select(t, b)) At this point, ≤ ′ may be simply replaced by ≤ (this operation obviously preserves equisatisfiability) and the resulting clause set can be refuted by any SMT-solver handling ground equality and integer arithmetic.
Such nested array reads are outside the scope of the Array property fragment of [6] and of the Logic LIA of [21]. They are not subsumed either by the extensions of the theory of arrays considered in [20]. Note that, due to the fact that we use distinct renamings of the specification of integers, equations such as select(t ′ , select(t, a)) ≃ select(t ′ , a) are forbidden (if arrays are viewed as heaps, this means that there can be no equation between pointers and referenced values).

Discussion
In this paper we have introduced a new combination method of instantiation schemes and presented sufficient conditions that guarantee the completeness of the resulting instantiation scheme. As evidenced by the examples provided in Section 4, this combination method permits to obtain instantiation procedures for several theories that are quite expressive, at almost no cost. One direct consequence of these results is that it should be possible for developers of SMT solvers to focus on the design of efficient decision procedures for a few basic theories, such as, e.g., the theory of equality with uninterpreted function symbols (EUF) or Presburger arithmetic, and obtain efficient SMT solvers for a large panel of theories.
This combination method may seem inefficient, since exponentially many ground clauses may be generated, except for the trivial cases. An interesting line of research is to investigate how incremental techniques can be implemented and the instantiations controlled so that the (un)satisfiability of the clause set under consideration can be detected before all clauses are instantiated in all possible ways. For instance, we believe it is possible -but this will probably depend on B and N -to devise more subtle strategies that begin by replacing base variables with the constants • s and applying the instantiation procedure for N , and deriving additional information from the resulting set of ground clauses to avoid having to instantiate all base variables in all possible ways. Further investigations into this line of work could lead to the design of more powerful instantiation procedures that could enlarge the scope of modern SMT solvers by making them able to handle efficiently more expressive classes of quantified formulae.