Soundness, Idempotence and Commutativity of Set-Sharing

PATRICIA M. HILL∗

School of Computer Studies, University of Leeds, Leeds, U.K.

                    (e-mail: hill@scs.leeds.ac.uk)

ROBERTO BAGNARA, ENEA ZAFFANELLA†

Department of Mathematics, University of Parma, Italy

              (e-mail: {bagnara,zaffanella}@cs.unipr.it)

Abstract

It is important that practical data-flow analyzers are backed by reliably proven theoretical results. Abstract interpretation provides a sound mathematical framework and necessary generic properties for an abstract domain to be well-defined and sound with respect to the concrete semantics. In logic programming, the abstract domain Sharing is a standard choice for sharing analysis for both practical work and further theoretical study. In spite of this, we found that there were no satisfactory proofs for the key properties of commutativity and idempotence that are essential for Sharing to be well-defined and that published statements of the soundness of Sharing assume the occur-check. This paper provides a generalization of the abstraction function for Sharing that can be applied to any language, with or without the occur-check. Results for soundness, idempotence and commutativity for abstract unification using this abstraction function are proven.

1 Introduction

In abstract interpretation, the concrete semantics of a program is approximated by an abstract semantics; that is, the concrete domain is replaced by an abstract domain and each elementary operation on the concrete domain is replaced by a corresponding abstract operation on the abstract domain. Assuming the global abstract procedure mimics the concrete execution procedure, each basic operation on the elements of the abstract domain must produce a safe approximation of the corresponding operation on corresponding elements of the concrete domain. For logic programming, the key elementary operation is unification that computes a solution to a set of equations. This solution can be represented by means of a mapping (called a substitution) from variables to first-order terms in the language. For global soundness of the abstract semantics, there needs to be, therefore, a corresponding abstract operation, aunify, that is sound with respect to unification.

∗ This work was partly supported by EPSRC under grant GR/M05645. † The work of the second and third authors has been partly supported by MURST project “Cer-

tificazione automatica di programmi mediante interpretazione astratta.”

For parallelization and several other program optimizations, it is important to know before execution which variables may be bound to terms that share a common variable. Jacobs and Langen developed the abstract domain Sharing (Jacobs & Langen, 1989; Jacobs & Langen, 1992) for representing and propagating the sharing behavior of variables and this is now a standard choice for sharing analysis. Subsequent research then concentrated mainly on extending the domain to incorporate additional properties such as linearity, freeness and depth-k abstractions (Langen, 1990; Bruynooghe & Codish, 1993; Codish et al., 1993; King, 1994; King & Soper, 1994; Muthukumar & Hermenegildo, 1992) or in reducing its complexity (Bagnara et al., 1997; Bagnara et al., 2000b). Key properties such as commutativity and soundness of this domain and its associated abstract operations such as abstract unification were normally assumed to hold. One reason for this was that (Jacobs & Langen, 1992) includes a proof of the soundness and refers to the Ph.D. thesis of Langen (Langen, 1990) for the proofs of commutativity and idempotence.^{1} We discuss below why these results are inadequate.

1.1 Soundness of aunify

An important step in standard unification algorithms based on that of Robinson (Robinson, 1965) (such as the Martelli-Montanari algorithm (Martelli & Montanari, 1982)) is the occur-check, which avoids the generation of infinite (or cyclic) data structures. With such algorithms, the resulting solution is both unique and idempotent. However, in computational terms, the occur-check is expensive and the vast majority of Prolog implementations omit this test, although some Prolog implementations do offer unification with the occur-check as a separate built-in predicate (in ISO Prolog (ISO/IEC, 1995) the predicate is unify with occurs check/2). In addition, if the unification algorithm is based on the Martelli-Montanari algorithm but without the occur-check step, then the resulting solution may be nonidempotent. Consider the following example.

Suppose we are given as input the equation p(z, f(x, y)) = p(f(z, y), z) with an initial substitution that is empty. We apply the steps in the Martelli-Montanari procedure but without the occur-check:

equations  substitution
1  p(z, f(x, y)) = p(f(z, y), z)  ∅
2  z = f(z, y), f(x, y) = z  ∅
3  f(x, y) = f(z, y)  {z ↦ f(z, y)}
4  x = z, y = y  {z ↦ f(z, y)}

1 Even though the thesis of Langen has been published as a technical report of the University of Southern California, an extensive survey of the literature on Sharing indicates that the thesis has not been widely circulated even among researchers in the field. For instance, Langen is rarely credited as being the first person to integrate Sharing with linearity information, despite the fact that this is described in the thesis.

5  y = y  {z ↦ f(z, y), x ↦ z}
6  ∅  {z ↦ f(z, y), x ↦ z}

Then σ = {z ↦ f(z, y), x ↦ z} is the computed substitution; it is not idempotent since, for example, xσ = z and xσσ = f(z, y).

Non-standard equality theories and unification procedures are also available and used in many logic programming systems. In particular, there are theoretically coherent languages, such as Prolog III (Colmerauer, 1982), that employ an equality theory and unification algorithm based on a theory of rational trees (possibly infinite trees with a finite number of subtrees). As remarked in (Colmerauer, 1982), complete (i.e., always terminating) unification with the omission of the occur-check solves equations over rational trees. Complete unification is made available by several Prolog implementations. The substitutions computed by such systems are in rational solved form and therefore not necessarily idempotent. As an example, the substitution {x ↦ f(x)}, which is clearly non-idempotent, is in rational solved form and could itself be computed by the above algorithms.

It is therefore important that theoretical work in data-flow analysis makes no assumption that the computed solutions are idempotent. In spite of this, most theoretical work on data-flow analysis of logic programming and of Prolog assume the occur-check is performed, thus allowing idempotent substitutions only. In particular, (Jacobs & Langen, 1992), (Langen, 1990), and, more recently, (Cortesi & Filé, 1999) make this assumption in their proofs of soundness. As a consequence, their results do not apply to the analysis of all Prolog programs. A recent exception to this is (King, 2000) where a soundness result is proved for a domain representing just the pair-sharing and linearity information. In this work it is assumed that a separate groundness analysis is performed and its results are used to recover from the precision losses incurred by the proposed domain. However, the problem of specifying a sound and precise groundness analysis when dealing with possibly non-idempotent substitutions is completely disregarded, so that the overall solution is incomplete. Moreover, the proposed abstraction function is based on a limit operation that, in the general case, is not finitely computable.

We have therefore addressed the problem of defining a sound and precise approximation of the sharing information contained in a substitution in rational solved form.

In particular, we observed that the Sharing domain is concerned with the set of variables occurring in a term, rather than with the term structure. We have therefore generalized the notion of idempotence to variable-idempotence. That is, if σ is a variable-idempotent substitution and t is any term, then any variable which is not in the domain of σ and occurs in tσ also occurs in tσσ. Clearly, as illustrated by the above example, substitutions generated by unification algorithms without the occur-check may not even be variable-idempotent. To resolve this, we have devised an algorithm that transforms any substitution in rational solved form to an equivalent (with respect to any equality theory) variable-idempotent substitution. For instance, in the example, it would transform σ to {z ↦ f(z, y), x ↦ f(z, y)}.

By suitably exploiting the properties enjoyed by variable-idempotent substitutions, we show that, for the domain Sharing, the abstract unification algorithm aunify is sound with respect to the actually implemented unification procedures for all logic programming languages. Moreover, we define a new abstraction function mapping any set of substitutions in rational solved form into the corresponding abstract descriptions so that there is no need for the analyser to compute the equivalent set of variable-idempotent substitutions. We note that this new abstraction function is carefully chosen so as to avoid any precision loss due to the possible non-idempotence of the substitution.

Note that both the notion of variable-idempotent substitution and the proven results relating it to arbitrary substitutions in rational solved form do not depend on the particular abstract domain considered. Indeed, we believe that this concept, perhaps with minor adjustments, can be usefully applied to other abstract domains when extending the soundness proofs devised for idempotent substitutions to the more general case of substitutions in rational solved form.

1.2 Commutativity and Idempotence of aunify

A substitution is defined as a set of bindings or equations between variables and other terms. Thus, for the concrete domain, the order and multiplicity of elements are irrelevant in both the computation and semantics of unification. It is therefore useful that the abstraction of the unification procedure should be unaffected by the order and multiplicity in which it abstracts the bindings that are present in the substitution. Furthermore, from a practical perspective, it is also useful if the global abstract procedure can proceed in a different order with respect to the concrete one without affecting the accuracy of the analysis results. On the other hand, as sharing is normally combined with linearity and freeness domains that are not idempotent or commutative (Langen, 1990; Bruynooghe & Codish, 1993; King, 1994), it may be asked why these properties are still important for sharing analysis. In answer to this, we observe that the order and multiplicity in which the bindings in a substitution are analyzed affects the accuracy of the linearity and freeness information. It is therefore a real advantage to be able to ignore these aspects as far as the sharing domain is concerned. Specifically, the order in which the bindings are analyzed can be chosen so as to improve the accuracy of linearity and freeness. We thus conclude that it is extremely desirable that aunify is also commutative and idempotent.

We found that there was no satisfactory proof of commutativity. In addition, for idempotence the only previous result was given in Theorem 32 of the thesis of Langen. However, his definition of abstract unification includes the renaming and projection operations and, in this case, only a weak form of idempotence holds. In fact, for the basic aunify operation as defined here and without projection and renaming, idempotence has never before been proven. We therefore provide here the first published proofs of these properties.

In summary, this paper, which is an extended and improved version of (Hill et al., 1998), provides a generalization of the abstraction function for Sharing that can be applied to any logic programming language dealing with syntactic term structures.

The results for soundness, idempotence and commutativity for abstract unification using this abstraction function are proved.

The paper is organised as follows. In the next section, the notation and definitions needed for equality and substitutions in the concrete domain are given. In Section 3, we recall the definition of the domain Sharing and of the classical abstraction function defined for idempotent substitutions. We also show why this abstraction function cannot be applied, as is, to non-idempotent substitutions. In Section 4, we introduce variable-idempotence and provide a transformation that may be used to map any substitution in rational solved form to an equivalent, variable-idempontent one. In Section 5, we define a new abstraction function relating the Sharing domain to the domain of arbitrary substitutions in rational solved form. In Section 6, we recall the definition of the abstract unification for Sharing and state our main results. Section 7 concludes. For the convenience of the reader, throughout the paper all the proofs (apart from the simpler ones) of the stated results are appended to the end of the corresponding section.

2 Equations and Substitutions

In this section we introduce the notation and some terminology concerning equality and substitutions that will be used in the rest of the paper.

2.1 Notation

For a set S, ℘(S) is the powerset of S, whereas ℘_{f}(S) is the set of all the finite subsets of S. The symbol Vars denotes a denumerable set of variables, whereas T_{Vars} denotes the set of first-order terms over Vars for some given set of function symbols. It is assumed that there are at least two distinct function symbols, one of which is a constant (i.e., of zero arity), in the given set. The set of variables occurring in a syntactic object o is denoted by vars(o). To simplify the expressions in the paper, any variable in a formula that is not in the scope of a quantifier is assumed to be universally quantified. To prove the results in the paper, it is useful to assume a total ordering, denoted with ‘≤’, on Vars.

2.2 Substitutions

If x ∈ Vars and s ∈ T_{Vars} \ {x}, then x ↦ s is called a binding. The set of all bindings is denoted by Bind. A substitution is a total function σ: Vars → T_{Vars} that is the identity almost everywhere; in other words, the domain of σ,

dom(σ) =^{def} { x ∈ Vars | σ(x) ≠ x },

is finite. We also define the set of parameter variables of a substitution σ as

param(σ) =^{def} vars(σ) \ dom(σ).

Given a substitution σ: Vars → T_{Vars} we overload the symbol ‘σ’ so as to denote also the function σ: T_{Vars} → T_{Vars} defined as follows, for each term t ∈ T_{Vars}:

σ(t) =^{def} \begin{cases}t, & if t is a constant symbol; \\ σ(t), & if t ∈ Vars; \\ f(σ(t_{1}), …, σ(t_{n})), & if t = f(t_{1}, …, t_{n}). \end{cases}

Substitutions are denoted by the set of their non-trivial bindings, thus a substitution σ is identified with the (finite) set

{ x ↦ σ(x) | x ∈ dom(σ) }.

If t ∈ T_{Vars}, we write tσ to denote σ(t) and t[x/s] to denote t{x ↦ s}. The composition of substitutions is defined in the usual way. Thus τ∘σ is the substitution such that, for all terms t ∈ T_{Vars},

(τ ∘ σ)(t) = τ(σ(t))

and has the formulation

τ ∘ σ = {x ↦ xστ | x ∈ dom(σ), x ≠ xστ} ∪ {x ↦ xτ | x ∈ dom(τ) \ dom(σ)}. (1)

As usual, σ^{0} denotes the identity function (i.e., the empty substitution) and, when i > 0, σ^{i} denotes the substitution (σ ∘ σ^{i−1}).

A substitution is said to be circular if, for n > 1, it has the form

{x_{1} ↦ x_{2}, …, x_{n−1} ↦ x_{n}, x_{n} ↦ x_{1}}.

A substitution is in rational solved form if it has no circular subset. The set of all substitutions in rational solved form is denoted by RSubst. A substitution σ is idempotent if, for all t ∈ T_{Vars}, we have tσσ = tσ. The set of all idempotent substitutions is denoted by ISubst and ISubst ⊂ RSubst.

Example 1 The following hold:

{x ↦ y, y ↦ a} ∈ RSubst \ ISubst,
{x ↦ a, y ↦ a} ∈ ISubst,
{x ↦ y, y ↦ g(y)} ∈ RSubst \ ISubst,
{x ↦ y, y ↦ g(x)} ∈ RSubst \ ISubst,
{x ↦ y, y ↦ x} ∉ RSubst,
{x ↦ y, y ↦ x, z ↦ a} ∉ RSubst.

We have assumed that there is a total ordering ‘≤’ for Vars. We say that σ ∈ RSubst is ordered (with respect to this ordering) if, for each binding (v ↦ w) ∈ σ such that w ∈ param(σ), we have w < v.

2.3 Equations

An equation is of the form s = t where s, t ∈ T_{Vars}. Eqs denotes the set of all equations. A substitution σ may be regarded as a finite set of equations, that is, as the set { x = t | x ↦ t ∈ σ }. We say that a set of equations e is in rational solved form if { r ↦ t | (r = t) ∈ e } ∈ RSubst. In the rest of the paper, we will often write a substitution σ ∈ RSubst to denote a set of equations in rational solved form (and vice versa).

We assume that any equality theory T over T_{Vars} includes the congruence axioms denoted by the following schemata:

s = s,  (2)
s = t ↔ t = s,  (3)
r = s ∧ s = t → r = t,  (4)
s_{1} = t_{1} ∧ ⋯ ∧ s_{n} = t_{n} → f(s_{1}, …, s_{n}) = f(t_{1}, …, t_{n}).  (5)

In logic programming and most implementations of Prolog it is usual to assume an equality theory based on syntactic identity. This consists of the congruence axioms together with the identity axioms denoted by the following schemata:

f(s_{1}, …, s_{n}) = f(t_{1}, …, t_{n}) → s_{1} = t_{1} ∧ ⋯ ∧ s_{n} = t_{n},  (6)
¬(f(s_{1}, …, s_{n}) = g(t_{1}, …, t_{m})).  (7)

The axioms characterized by schemata (6) and (7) ensure the equality theory depends only on the syntax. The equality theory for a non-syntactic domain replaces these axioms by ones that depend instead on the semantics of the domain and, in particular, on the interpretation given to functor symbols.

The equality theory of Clark (Clark, 1978) on which pure logic programming is based, usually called the Herbrand equality theory, is given by the congruence axioms, the identity axioms, and the axiom schema

∀z ∈ Vars : ∀t ∈ (T_{Vars} \ Vars) : z ∈ vars(t) → ¬(z = t).  (8)

Axioms characterized by the schema (8) are called the occur-check axioms and are an essential part of the standard unification procedure in SLD-resolution.

An alternative approach used in some implementations of Prolog, does not require the occur-check axioms. This approach is based on the theory of rational trees (Colmerauer, 1982; Colmerauer, 1984). It assumes the congruence axioms and the identity axioms together with a uniqueness axiom for each substitution in rational solved form. Informally speaking these state that, after assigning a ground rational tree to each parameter variable, the substitution uniquely defines a ground rational tree for each of its domain variables. Note that being in rational solved form is a very weak property. Indeed, unification algorithms returning a set of equations in rational solved form are allowed to be much more “lazy” than one would usually expect (e.g., see the first substitution in Example 1). We refer the interested reader to (Jaffar et al., 1987; Keisu, 1994; Maher, 1988) for details on the subject.

In the sequel we will use the expression “equality theory” to denote any consistent, decidable theory T satisfying the congruence axioms. We will also use the expression “syntactic equality theory” to denote any equality theory T also satisfying the identity axioms.^{2} When the equality theory T is clear from the context, it is convenient to adopt the notations σ ⟹ τ and σ ⟺ τ, where σ, τ are sets of equations, to denote T ⊢ ∀(σ → τ) and T ⊢ ∀(σ ↔ τ), respectively.

Given an equality theory T, and a set of equations in rational solved form σ, we say that σ is satisfiable in T if T ⊢ ∀Vars \dom(σ) : ∃ dom(σ) . σ. If T is a syntactic equality theory that also includes the occur-check axioms, and σ is satisfiable in T, then we say that σ is Herbrand.

Given a satisfiable set of equations e ∈ ℘_{f}(Eqs) in an equality theory T, then a substitution σ ∈ RSubst is called a solution for e in T if σ is satisfiable in T and T ⊢ ∀(σ → e). If vars(σ) ⊆ vars(e), then σ is said to be a relevant solution for e. In addition, σ is a most general solution for e in T if T ⊢ ∀(σ ↔ e). In this paper, a most general solution is always a relevant solution of e.

Observe that, given an equality theory T, a set of equations in rational solved form may not be satisfiable in T. For example, ∃x : {x = f(x)} is false in the Clark equality theory.

Lemma 1 Suppose T is an equality theory, σ ∈ RSubst is satisfiable in T, x ∈ Vars \ dom(σ), and a ∈ T_{∅}. Then, if σ′ =^{def} σ ∪ {x ↦ a} ∈ RSubst, σ′ is satisfiable in T.

Proof As x ∉ dom(σ) and σ ∈ RSubst, it follows that σ′ = σ ∪ {x ↦ a} ∈ RSubst.

Since σ is satisfiable in T,

T ⊢ ∀Vars \ dom(σ) : ∃ dom(σ) . σ.

Moreover, by the congruence axiom (2),

T ⊢ ∀Vars \ {x} : ∃x . {x = a}.

Hence,

T ⊢ ∀Vars \ (dom(σ) ∪ {x}) : ∃(dom(σ) ∪ {x}) . σ ∪ {x = a}.

Thus σ′ = σ ∪ {x ↦ a} is satisfiable in T.

Syntactically we have shown that any substitution in RSubst may be regarded as a set of equations in rational solved form and vice versa. The next lemma shows the semantic relationship between them.

Lemma 2 If T is an equality theory and σ ∈ RSubst, then, for each t ∈ T_{Vars},

T ⊢ ∀(σ → (t = tσ)).

2 Note that, as a consequence of axiom (7) and the assumption that there are at least two distinct function symbols in the language, one of which is a constant, there exist two terms a_{1}, a_{2} ∈ T_{∅} such that, for any syntactic equality theory T, we have T ⊢ a_{1} ≠ a_{2}.

Proof We assume the congruence axioms hold and prove that, for any t ∈ T_{Vars}, we have σ ⟹ {t = tσ}. The proof is by induction on the depth of t.

Suppose, first that the depth of t is one. If t is a variable not in dom(σ) or a constant, then tσ = t and the result follows from axiom (2). If t ∈ dom(σ), then, for some r ∈ T_{Vars}, (t ↦ r) ∈ σ. Thus σ ⟹ {t = tσ}.

If the depth of t is greater than one, then t has the form f(s_{1}, …, s_{n}) where s_{1}, …, s_{n} ∈ T_{Vars} have depth less than the depth of t. By the inductive hypothesis, for each i = 1, …, n, we have σ ⟹ {s_{i} = s_{i}σ}. Therefore, applying axiom (5), we have σ ⟹ {t = tσ}.

As is common in papers involving equality, we overload the symbol ‘=’ and use it to denote both equality and to represent syntactic identity. The context makes it clear what is intended.

3 The Set-Sharing Domain

In this section, we first recall the definition of the Sharing domain and present the (classical) abstraction function used for dealing with idempotent substitutions. We will then give evidence for the problems arising when applying this abstraction function to the more general case of substitutions in rational solved form.

3.1 The Sharing Domain

The Sharing domain is due to Jacobs and Langen (Jacobs & Langen, 1989). However, we use the definition as presented in (Bagnara et al., 1997) where the set of variables of interest is given explicitly.

Definition 1 (The set-sharing lattice.) Let

SG =^{def} ℘_{f}(Vars) \ {∅}

and let

SH =^{def} ℘(SG).

The set-sharing lattice is given by the set

SS =^{def} { (sh, U) | sh ∈ SH , U ∈ ℘_{f}(Vars), ∀S ∈ sh : S ⊆ U } ∪ {⊥, ⊤},

which is ordered by ‘⪯_{SS}’ defined as follows, for each d, (sh_{1}, U_{1}), (sh_{2}, U_{2}) ∈ SS:

⊥ ⪯_{SS} d,
d ⪯_{SS} ⊤,
(sh_{1}, U_{1}) ⪯_{SS} (sh_{2}, U_{2}) ⟺ (U_{1} = U_{2}) ∧ (sh_{1} ⊆ sh_{2}).

It is straightforward to see that every subset of SS has a least upper bound with respect to ⪯_{SS}. Hence SS is a complete lattice.^{3} The lub operator over SS will be denoted by ‘⊔’.

3.2 The Classical Abstraction Function for ISubst

An element sh of SH encodes the sharing information contained in an idempotent substitution σ. Namely, two variables x and y must be in the same set in sh if some variable occurs in both xσ and yσ.

Definition 2 (Classical sg and abstraction functions.) sg: ISubst ×Vars → ℘_{f}(Vars), called sharing group function, is defined, for each σ ∈ ISubst and each v ∈ Vars, by

sg(σ, v) =^{def} { y ∈ Vars | v ∈ vars(yσ) }.

The concrete domain ℘(ISubst) is related to SS by means of the abstraction function α_{I}: ℘(ISubst) × ℘_{f}(Vars) → SS. For each Σ ∈ ℘(ISubst) and each U ∈ ℘_{f}(Vars),

α_{I}(Σ, U) =^{def} ⨆_{σ∈Σ} α_{I}(σ, U),

where α_{I}: ISubst × ℘_{f}(Vars) → SS is defined, for each substitution σ ∈ ISubst and each U ∈ ℘_{f}(Vars), by

α_{I}(σ, U) =^{def} ({ sg(σ, v) ∩ U | v ∈ Vars } \ {∅}, U).

The sharing group function sg was first defined by Jacobs and Langen (Jacobs & Langen, 1989) and used in their definition of a concretisation function for SH . The function α_{I} corresponds closely to the abstract counterpart of this concretisation function, but explicitly includes the set of variables of interest as a separate argument. It is identical to the abstraction function for Sharing defined by Cortesi and Filé (Cortesi & Filé, 1999).

In order to provide an intuitive reading of the sharing information encoded into an abstract element, we should stress that the analysis aims at capturing possible sharing. The corresponding definite information (e.g., definite groundness or independence) can be extracted by observing which sharing groups are not in the abstract element. As an example, if we observe that there is no sharing group containing a particular variable of U, then we can safely conclude that this variable is definitely ground (namely, it is bound to a term containing no variables). Similarly, if we observe that two variables never occur together in the same sharing group, then we can safely conclude that they are independent (namely, they are bound to terms that do not share a common variable). For a more detailed description of the information contained in an element of SS, we refer the interested reader to (Bagnara et al., 1997; Bagnara et al., 2000b).

3 Notice that the only reason we have ⊤ ∈ SS is in order to turn SS into a lattice rather than a CPO.

Example 2 Assume U = {x_{1}, x_{2}, x_{3}, x_{4}} and let

σ = {x_{1} ↦ f(x_{2}, x_{3}), x_{4} ↦ a},

so that its abstraction is given by

α_{I}(σ, U) = ({{x_{1}, x_{2}}, {x_{1}, x_{3}}}, U).

From this abstraction we can safely conclude that variable x_{4} is ground and variables x_{2} and x_{3} are independent.

3.3 Towards an Abstraction Function for RSubst

To help motivate the approach we have taken in adapting the classical abstraction function to non-idempotent substitutions, we now explain some of the problems that arise if we apply α_{I}, as it is defined on ISubst, to the non-idempotent substitutions in RSubst. Note that these problems are only partially due to allowing for non-Herbrand substitutions (that is substitutions that are not satisfiable in a syntactic equality theory containing the occur-check axioms). They are also due to the presence of non-idempotent but Herbrand substitutions that may arise because of the potential “laziness” of unification procedures based on the rational solved form.

We use the following substitutions to illustrate the problems, where it is assumed that the set of variables of interest is U = {x_{1}, x_{2}, x_{3}, x_{4}}. Let

σ_{1} = {x_{1} ↦ f(x_{1})},
σ_{2} = {x_{3} ↦ x_{4}},
σ_{3} = {x_{1} ↦ x_{2}, x_{2} ↦ x_{3}, x_{3} ↦ x_{4}},
σ_{4} = {x_{1} ↦ x_{4}, x_{2} ↦ x_{4}, x_{3} ↦ x_{4}}

so that we have

α_{I}(∅, U) = α_{I}(σ_{1}, U) = ({{x_{1}}, {x_{2}}, {x_{3}}, {x_{4}}}, U),
α_{I}(σ_{2}, U) = α_{I}(σ_{3}, U) = ({{x_{1}}, {x_{2}}, {x_{3}, x_{4}}}, U),
α_{I}(σ_{4}, U) = ({{x_{1}, x_{2}, x_{3}, x_{4}}}, U).

The first problem is that the concrete equivalence classes induced by the classical abstraction function on RSubst are much coarser than one would expect and hence we have an unwanted loss of precision. For example, in all the sets of rational trees that are solutions for σ_{1}, the variable x_{1} is ground. However, the computed abstract element fails to distinguish this situation from that resulting from the empty substitution, where all the variables are free and un-aliased. Similarly, we have the same abstract element for both σ_{2} and σ_{3} although, x_{1}, x_{2} and x_{3} are independent in σ_{2} only.

The second problem is quite the opposite from the first in that the abstraction function distinguishes between substitutions that are equivalent (with respect to any equality theory). For example, σ_{3} and σ_{4} are equivalent although the abstract elements are distinct. Note that the two problems described here are completely orthogonal although they can interact and produce more complex situations.

4 Variable-Idempotence

In this section we define a new class of substitutions based on the concept of variable-idempotence. Variable-idempotent substitutions are then related to substitutions in rational solved form by means of an equivalence preserving rewriting relation.

4.1 Variable-Idempotent Substitutions

Recall that, for substitutions, the definition of idempotence requires that repeated applications of a substitution do not change the syntactic structure of a term. However, a sharing abstraction such as α_{I} is only interested in the variables and not in the structure that contains them. Thus, an obvious way to relax the definition of idempotence to allow for a non-Herbrand substitution is to ignore the structure and just require that its repeated application leaves the set of free variables in a term invariant.

Definition 3 (Variable-Idempotence.) A substitution σ is said to be variable-idempotent if σ ∈ RSubst and, for each t ∈ T_{Vars},

vars(tσσ) \ dom(σ) = vars(tσ) \ dom(σ).

The set of all variable-idempotent substitutions is denoted by VSubst.

Note that, as the condition vars(tσ) \ dom(σ) ⊆ vars(tσσ) is trivial and holds for all substitutions, we have σ ∈ VSubst if and only if σ ∈ RSubst and

vars(tσσ) \ dom(σ) ⊆ vars(tσ).  (9)

Also note that any idempotent substitution is also variable-idempotent, so that ISubst ⊂ VSubst ⊂ RSubst.

Example 3 Consider the following substitutions which are all in RSubst.

σ_{1} = {x ↦ f(x)}  ∈ VSubst \ ISubst,
σ_{2} = {x ↦ f(y), y ↦ z} ∉ VSubst,
σ_{3} = {x ↦ f(z), y ↦ z} ∈ ISubst,
σ_{4} = {x ↦ z, y ↦ f(x, y)} ∉ VSubst,
σ_{5} = {x ↦ z, y ↦ f(z, y)} ∈ VSubst \ ISubst.

Note that σ_{2} is equivalent (with respect to any equality theory) to the idempotent substitution σ_{3}; and σ_{4} is equivalent (with respect to any equality theory) to the substitution σ_{5} which is variable-idempotent but not idempotent.

The next result provides an alternative characterization of variable-idempotence.

Lemma 3 Suppose that σ ∈ RSubst. Then σ ∈ VSubst if and only if, for all (x ↦ r) ∈ σ,

vars(rσ) \ dom(σ) = vars(r) \ dom(σ).

Proof Suppose first that σ ∈ VSubst and that (x ↦ r) ∈ σ. Then

vars(xσσ) \ dom(σ) = vars(xσ) \ dom(σ)

and hence, vars(rσ) \ dom(σ) = vars(r) \ dom(σ).

Next, suppose that for all (x ↦ r) ∈ σ, vars(rσ) \ dom(σ) = vars(r) \ dom(σ). Let t ∈ T_{Vars}. We will show that vars(tσσ) \ dom(σ) = vars(tσ) \ dom(σ) by induction on the depth of t. If t is a constant or t ∈ Vars \ dom(σ), then the result follows from the fact that tσ = t. If t ∈ dom(σ), then the result follows from the hypothesis. Finally, if t = f(t_{1}, …, t_{n}), then, by the inductive hypothesis, vars(t_{i}σσ) \ dom(σ) = vars(t_{i}σ) \ dom(σ) for i = 1, …, n. Therefore we have vars(tσσ) \ dom(σ) = vars(tσ) \ dom(σ). Thus, by Definition (3), as σ ∈ RSubst, σ ∈ VSubst.

Note that, as a consequence of Lemma 3, any substitution consisting of a single binding is variable-idempotent. Note though that we cannot assume that every subset of a variable-idempotent substitution is variable-idempotent.

Example 4 Let

σ_{1} = {x_{1} ↦ x_{2}, x_{2} ↦ g(x_{3}), x_{3} ↦ f(x_{3})},
σ_{2} = {x_{3} ↦ f(x_{3})},
σ_{3} = σ_{1} \ σ_{2} = {x_{1} ↦ x_{2}, x_{2} ↦ g(x_{3})}.

It can be observed that σ_{1}, σ_{2} ∈ VSubst. Also note that σ_{3} ∉ VSubst, because we have x_{3} ∈ vars(x_{1}σ_{3}σ_{3}) \ dom(σ_{3}) but x_{3} ∉ vars(x_{1}σ_{3}) \ dom(σ_{3}).

On the other hand, a variable-idempotent substitution does enjoy the following useful property with respect to its subsets.

Lemma 4 If σ ∈ VSubst and t ∈ T_{Vars}, then, for all σ′ ⊆ σ,

vars(tσσ′) \ dom(σ) = vars(tσ) \ dom(σ).

Proof Observe that, since σ′ ⊆ σ, the relation vars(tσ) \ dom(σ) ⊆ vars(tσσ′) is trivial.

To prove the opposite relation, suppose that y ∈ vars(tσσ′)\dom(σ). Then there exists x ∈ vars(tσ) such that y ∈ vars(xσ′). Now, if x ∉ dom(σ′), then x = y and y ∈ vars(tσ). On the other hand, if x ∈ dom(σ′), then xσ′ = xσ so that y ∈ vars(tσσ) \ dom(σ) and hence, as σ ∈ VSubst, y ∈ vars(tσ).

We note that this result depends on the definition of variable-idempotence ignoring the domain elements of the substitution.

Example 5 Let

σ = {x ↦ f(x, y), y ↦ a}.

Then σ ∈ VSubst but

vars(xσ) = {x, y},
vars(xσσ) = {x, y},
vars(xσ{y ↦ a}) = {x}.

We now state three technical results that will be needed later in the paper. Note that, when proving these results at the end of this section, we require that the equality theory also satisfies the identity axioms. The first two results show that equivalent, ordered, variable-idempotent substitutions have the same domain and bind the domain variables to terms with the same set of parameter variables.

Lemma 5 Suppose that T is a syntactic equality theory, τ, σ ∈ VSubst are ordered and satisfiable in T and T ⊢ ∀(τ → σ). Then dom(σ) ⊆ dom(τ).

Lemma 6 Suppose that T is a syntactic equality theory, τ, σ ∈ VSubst are satisfiable in T and T ⊢ ∀(τ → σ). In addition, suppose s, t ∈ T_{Vars} are such that T ⊢ ∀(τ → (s = t)). Then, if v ∈ vars(s) \ dom(τ), there exists a variable z ∈ vars(tσ) \ dom(σ) such that v ∈ vars(zτ).

Lemma 7 Let τ, σ ∈ VSubst, where dom(σ) ∩ vars(τ) = ∅. Then τ ∘ σ has the following properties.

1. T ⊢ ∀((τ ∘ σ) ↔ (τ ∪ σ)), for some syntactic equality theory T;

2. dom(τ ∘ σ) = dom(τ ∪ σ);

3. τ ∘ σ ∈ VSubst.

4.2 S-transformations

A useful property of variable-idempotent substitutions is that any substitution can be transformed to an equivalent (with respect to any equality theory) variableidempotent one.

Definition 4 (S-transformation.) The relation ⟼^{S} ⊆ RSubst×RSubst, called S-step, is defined by

\frac{(x ↦ t) ∈ σ  (y ↦ s) ∈ σ  x ≠ y}{σ ⟼^{S} (σ \ \{y ↦ s\}) ∪ \{y ↦ s[x/t]\}} .

If we have a finite sequence of S-steps σ_{1} ⟼^{S} ⋯ ⟼^{S} σ_{n} mapping σ_{1} to σ_{n}, then we write σ_{1} ⟼^{∗}^{S} σ_{n} and say that σ_{1} can be rewritten, by S-transformation, to σ_{n}.

Example 6 Let

σ_{0} = \{\underline{x_{1} ↦ f(x_{2})}, x_{2} ↦ g(x_{3}, x_{4}), x_{3} ↦ x_{1}\}
σ_{1} = \{x_{1} ↦ f(x_{2}), \underline{x_{2} ↦ g(x_{3}, x_{4})}, x_{3} ↦ f(x_{2})\},
σ_{2} = \{x_{1} ↦ f(g(x_{3}, x_{4})), x_{2} ↦ g(x_{3}, x_{4}), \underline{x_{3} ↦ f(g(x_{3}, x_{4}))}\},
σ_{3} = {x_{1} ↦ f(g(f(g(x_{3}, x_{4})), x_{4})),
x_{2} ↦ g(f(g(x_{3}, x_{4})), x_{4}), x_{3} ↦ f(g(x_{3}, x_{4}))}.

Then

σ_{0} ⟼^{S} σ_{1} ⟼^{S} σ_{2} ⟼^{S} σ_{3}.

Observe that σ_{0} is not variable-idempotent since vars(x_{1}σ_{0}) \ {x_{1}, x_{2}, x_{3}} = ∅ but vars(x_{1}σ_{0}σ_{0}) \ {x_{1}, x_{2}, x_{3}} = {x_{4}}. Notice, however, that σ_{3} is variable-idempotent and that T ⊢ ∀(σ_{0} ↔ σ_{3}).

The next two theorems, which are proved at the end of this section, show that we need only consider variable-idempotent substitutions.

Theorem 1 Suppose σ ∈ RSubst and σ ⟼^{∗}^{S} σ′. Then σ′ ∈ RSubst, dom(σ) = dom(σ′), vars(σ) = vars(σ′) and, if T is any equality theory, then T ⊢ ∀(σ ↔ σ′).

Theorem 2 Suppose σ ∈ RSubst. Then there exists σ′ ∈ VSubst such that σ ⟼^{∗}^{S} σ′ and, for all τ ⊆ σ′, τ ∈ VSubst.

Note that as a consequence of this theorem, we can transform any substitution in rational solved form to a substitution for which it and all its subsets are variableidempotent. In particular, by this transformation we can avoid having to consider a substitution such as that illustrated in Example 4.

4.3 The Abstraction Function for VSubst

With these results, it can be seen that we need to consider variable-idempotent substitutions only. Moreover, in this case, one of the causes of the problems outlined in Section 3.3, due to the possible “laziness” of the unification algorithm, is no longer present. As a consequence, it is now sufficient to address the potential loss in precision due to the non-Herbrand substitutions. The simple solution is to define a new abstraction function for VSubst which is the same as that in Definition 2 but where any sharing group generated by a variable in the domain of the substitution is disregarded. This new abstraction function works for variable-idempotent substitutions and no longer suffers the drawbacks outlined in Section 3.3.

Therefore, at least from a theoretical point of view, the problem of defining a sound and precise abstraction function for arbitrary substitutions in rational solved form would have been solved. Given a substitution in RSubst, we would proceed in two steps: we first transform it to an equivalent substitution in VSubst and then compute the corresponding description by using the modified abstraction function. However, from a practical point of view, we need to define an abstraction function that directly computes the description of a substitution in RSubst in a single step, thus avoiding the expensive computation of the intermediate variable-idempotent substitution. We present such an abstraction function in Section 5.

4.4 Proofs of Lemmas 5, 6 and 7 and Theorems 1 and 2

To prove Lemmas 5 and 6, it is useful to first establish the following two properties of variable-idempotent substitutions.

Lemma 8 Suppose that σ ∈ VSubst, r ∈ T_{Vars} and, for all i ≥ 0, rσ^{i} ∈ Vars. Then we have rσ ∈ Vars \ dom(σ).

Proof As σ has no circular subset and dom(σ) is finite, there exists a j ≥ 1 such that rσ^{j} = rσ^{j+1} and hence, rσ^{j} ∈ Vars \ dom(σ). As σ is variable-idempotent, we have

{rσ^{j}} = vars(rσ^{j}) \ dom(σ)
= vars(rσ) \ dom(σ)
= {rσ} \ dom(σ).

Hence rσ ∈ Vars \ dom(σ).

Lemma 9 Suppose that σ ∈ VSubst and v, r ∈ T_{Vars} so that v ∈ Vars \ dom(σ) and, for any syntactic equality theory T, T ⊢ ∀(σ → {v = r}). Then v = rσ.

Proof We assume that the congruence and identity axioms hold. Let a_{1}, a_{2} ∈ T_{∅} have distinct outer-most symbols so that, by the identity axioms, T ⊢ a_{1} ≠ a_{2}. By Lemma 8, either rσ ∈ Vars \ dom(σ) or, for some j ≥ 0, rσ^{j} ∉ Vars. We consider each case separately.

If, for some j ≥ 0, rσ^{j} ∉ Vars, then, as a_{1} and a_{2} have distinct outer-most symbols, there exists an i ∈ {1, 2} such that a_{i} and rσ^{j} have distinct outer-most symbols. Thus, by the identity axioms, a_{i} ≠ rσ^{j}. Let σ′ = σ ∪ {v = a_{i}}. It follows from Lemma 1 that, as v ∉ dom(σ) and σ is satisfiable, σ′ ∈ RSubst and is satisfiable. By Lemma 2 and the congruence axioms, σ ⟹ {v = rσ^{j}}. However, σ′ ⟹ σ, so that σ′ ⟹ {v = rσ^{j}, v = a_{i}}. Thus, by the congruence axioms, we have σ′ ⟹ {a_{i} = rσ^{j}}, which is a contradiction.

Suppose then that rσ ∈ Vars \ dom(σ). If v ≠ rσ, then it follows from Lemma 1 that σ′ = σ ∪ {v = a_{1}, rσ = a_{2}} ∈ RSubst and, as σ is satisfiable, σ′ is satisfiable. By Lemma 2 and the congruence axioms, σ ⟹ {v = rσ}. However, σ′ ⟹ σ, so that σ′ ⟹ {v = rσ, v = a_{1}, rσ = a_{2}}. Thus, by the congruence axioms, we have σ′ ⟹ {a_{1} = a_{2}}, which is a contradiction. Hence v = rσ as required.

Proof of Lemma 5. We assume that the congruence and identity axioms hold. To prove the result, we suppose that there exists v ∈ dom(σ) \ dom(τ) and derive a contradiction.

By hypothesis, τ ⟹ σ. Thus, using Lemma 2 and the congruence axioms, we have, for any i ≥ 0, τ ⟹ {v = vσ^{i}}. By Lemma 9, for all i ≥ 0, v = vσ^{i}τ so that vσ^{i} ∈ Vars. By Lemma 8, vσ ∉ dom(σ), so that, as σ is ordered and v ∈ dom(σ), vσ < v. In particular, vσ ≠ v, so that as vστ = v and τ is ordered, we would have v < vσ, which is a contradiction.

Proof of Lemma 6. We assume that the congruence and identity axioms hold. Note that, by the hypothesis, τ ⟹ σ and τ ⟹ {s = t} so that, using Lemma 2 and the congruence axioms, we have τ ⟹ {s = tσ^{j}} and τ ⟹ {tστ^{k} = s}, for all j, k ≥ 0.

Let v ∈ vars(s) \ dom(τ). We prove, by induction on the depth d of s, that there exists z ∈ vars(tσ) \ dom(σ) such that v ∈ vars(zτ). The base case is when d = 1 so that s = v. Now, for each j ≥ 0, τ ⟹ {v = tσ^{j}} and hence, by Lemma 9 (as v ∉ dom(τ)), v = tσ^{j}τ. As a consequence, tσ^{j} ∈ Vars for all j ≥ 0 and v = tστ. By Lemma 8, tσ ∈ Vars \ dom(σ). Thus, we define z = tσ.

For the inductive step, we assume that d > 1 so that, for some n ≥ 1, we have s = f(s_{1}, …, s_{n}) and, for some i ∈ {1, …, n}, v ∈ vars(s_{i}) and s_{i} has depth d − 1. By Lemma 8, either tσ ∈ Vars \ dom(σ) or there exists a j ≥ 0 such that tσ^{j} ∉ Vars.

First, suppose that tσ ∈ Vars \ dom(σ). Now, τ ⟹ {tστ = s} so that, as sτ ∉ Vars, by Lemma 9, we have tστ ∉ Vars \ dom(τ). Thus, by Lemma 8, there exists k > 1 such that tστ^{k} ∉ Vars. Then, using the identity axioms, we have tστ^{k} = f(r_{1}, …, r_{n}) and τ ⟹ {s_{i} = r_{i}}. By the inductive hypothesis (letting σ be the empty substitution), we have v ∈ vars(r_{i}τ). However, vars(r_{i}) ⊆ vars(tστ^{k}) so that v ∈ vars(tστ^{k+1}). As τ ∈ VSubst and v ∉ dom(τ), v ∈ vars(tστ). Thus, in this case, let z = tσ.

Secondly, suppose that there exists a j ≥ 0 such that tσ^{j} ∉ Vars. Then, as τ ⟹ {s = tσ^{j}}, it follows from the identity axioms that tσ^{j} = f(t_{1}, …, t_{n}) and τ ⟹ {s_{i} = t_{i}}. By the inductive hypothesis, there exists z ∈ vars(t_{i}σ) \ dom(σ) such that v ∈ vars(zτ). However, vars(t_{i}σ) ⊆ vars(tσ^{j+1}) so that we must have z ∈ vars(tσ^{j+1}) \ dom(σ). As σ ∈ VSubst, z ∈ vars(tσ) \ dom(σ) as required.

Proof of Lemma 7. As consequences of the hypothesis, we have that dom(σ) ∩ dom(τ) = ∅ and that (τ ∪ σ) ∈ RSubst. It follows from Eq. (1) that τ ∘ σ can be obtained from (τ ∪ σ) by a sequence of S-steps so that, by Theorem 1, we have Properties 1 and 2.

To prove Property 3, we suppose that, for some v ∈ dom(τ ∘ σ), there exist w ∈ vars(vσ), x ∈ vars(wτ) and y ∈ vars(xσ) such that z ∈ vars(yτ) \ dom(τ ∘ σ). We need to prove that z ∈ vars(vστ).

It follows from Property 2, that z ∉ dom(σ) and z ∉ dom(τ). Suppose first that x ∉ dom(σ). Then y = x and hence z ∈ vars(vσττ). Therefore, as τ ∈ VSubst and z ∉ dom(τ), we can conclude z ∈ vars(vστ). Thus, we now assume that x ∈ dom(σ). As dom(σ) ∩ vars(τ) = ∅, we have x ∉ vars(τ), so that x = w and hence, y ∈ vars(vσσ). If y ∉ dom(τ) we have y = z, so that y ∉ dom(σ). On the other hand, if y ∈ dom(τ) then, by the hypothesis, y ∉ dom(σ). Thus, in both cases, as σ ∈ VSubst, we obtain y ∈ vars(vσ) and hence z ∈ vars(vστ). It follows, using Eq. (9), that Property 3 holds.

To prove Theorem 1, we need to show that the result holds for a single S-step.

Lemma 10 Let T be an equality theory and suppose that σ ∈ RSubst and σ ⟼^{S} σ′. Then σ′ ∈ RSubst, dom(σ) = dom(σ′), vars(σ) = vars(σ′), and T ⊢ ∀(σ ↔ σ′).

Proof Since σ ⟼^{S} σ′, there exists x, y ∈ dom(σ) with x ≠ y such that (x ↦ t), (y ↦ s) ∈ σ and σ′ = (σ \ {y ↦ s}) ∪ {y ↦ s[x/t]}. If x ∉ vars(s), σ = σ′ and the result is trivial. Suppose now that x ∈ vars(s). We define

σ_{0} =^{def} σ \ {x = t, y = s}.

Hence, as it is assumed that x ≠ y,

σ = σ_{0} ∪ {x ↦ t, y ↦ s},  (10)
σ′ = σ_{0} ∪ {x ↦ t, y ↦ s[x/t]}.  (11)

We first show that σ′ ∈ RSubst and dom(σ) = dom(σ′). If s ∉ Vars, then s[x/t] ∉ Vars so that dom(σ) = dom(σ′). Also, as σ has no circular subset, σ′ has no circular subset and σ′ ∈ RSubst. If s ∈ Vars, then s = x and s[x/t] = t. Thus, as σ = σ_{0} ∪ {x ↦ t, y ↦ x} has no circular subset, t ≠ y so that dom(σ) = dom(σ′). Moreover, neither σ_{0} ∪ {x ↦ t} nor σ_{0} ∪ {y ↦ t} have circular subsets. Hence σ′ has no circular subset. Thus σ′ ∈ RSubst.

Now, since

(vars(s) ∪ vars(t)) \ dom(σ) = vars(s[x/t] ∪ vars(t)) \ dom(σ),

it follows that vars(σ) = vars(σ′).

Therefore, it remains to show that, for any equality theory T, T ⊢ ∀(σ ↔ σ′). To do this, we assume that the congruence axioms hold, and show that σ ⟺ σ′. By Lemma 2, we have

{x = t} ⟹ {s = s[x/t]}.

Thus, using the congruence axiom (4), we have

{x = t, y = s} ⟹ {x = t, y = s, s = s[x/t]}
⟹ {x = t, y = s[x/t]}.

Similarly, using congruence axioms (3) and (4), we have

{x = t, y = s[x/t]} ⟹ {x = t, y = s[x/t], s = s[x/t]}
⟹ {x = t, y = s}.

Thus

{x = t, y = s} ⟺ {x = t, y = s[x/t]}.

It therefore follows from (10) and (11) that σ ⟺ σ′.

The condition x ≠ y in the proof of Lemma 10 is necessary. For example, suppose σ = {x ↦ f(x)} and σ′ = {x ↦ f(f(x))}. Then we do not have σ′ ⟹ σ. Note however that this implication will hold as soon as we enrich the equality theory T with either the occur-check axioms or the uniqueness axioms of the rational trees’ theory.

Proof of Theorem 1. The proof is by induction on the length of the sequence of S-steps transforming σ to σ′. The base case is the empty sequence. For the inductive step, the sequence has length n > 0 and there exists σ_{1} such that σ ⟼^{S} σ_{1} ⟼^{∗}^{S} σ′ and σ_{1} ⟼^{∗}^{S} σ′ has length n − 1. By Lemma 10, σ_{1} ∈ RSubst, dom(σ) = dom(σ_{1}), vars(σ) = vars(σ_{1}) and T ⊢ ∀(σ ↔ σ_{1}). By the inductive hypothesis, σ′ ∈ RSubst, dom(σ_{1}) = dom(σ′), vars(σ_{1}) = vars(σ′) and T ⊢ ∀(σ_{1} ↔ σ′). Hence we have dom(σ) = dom(σ′), vars(σ) = vars(σ′), and T ⊢ ∀(σ ↔ σ′).

Proof of Theorem 2. To prove the theorem, we construct an S-transformation and show that the resulting substitution has the required properties.

Suppose that {x_{1}, …, x_{n}} = dom(σ), σ_{0} = σ and, for each j = 0, …, n,

σ_{j} = {x_{1} ↦ t_{1,j}, …, x_{n} ↦ t_{n,j}},

where, if j > 0, t_{j,j} = t_{j,j−1} and, for each i = 1, …, n with i ≠ j, we have t_{i,j} = t_{i,j−1}[x_{j}/t_{j,j}].

It follows from the definition of σ_{j} that, for j = 1, …, n , σ_{j} can be obtained from σ_{j−1} by two sequences of S-steps of lengths j − 1 and n − j + 1:

σ_{j−1} = σ_{j−1}^{0} ⟼^{S} ⋯ ⟼^{S} σ_{j−1}^{j−1} = σ_{j−1}^{j} ⟼^{S} ⋯ ⟼^{S} σ_{j−1}^{n} = σ_{j},

where, for i = 1, …, n with i ≠ j,

σ_{j−1}^{i} = (σ_{j−1}^{i−1} \ {x_{i} ↦ t_{i,j−1}}) ∪ {x_{i} ↦ t_{i,j−1}[x_{j}/t_{j,j}]}
= {x_{1} ↦ t_{1,j}, …, x_{i} ↦ t_{i,j}, x_{i+1} ↦ t_{i+1,j−1}, …, x_{n} ↦ t_{n,j−1}}.

Hence, by Theorem 1, σ_{1}, …, σ_{n} ∈ RSubst.

We next show, by induction on j, with 0 ≤ j ≤ n, that, for each i = 1, …, n and each h = 1, …, j, we have vars(t_{i,j}) = vars(t_{i,j}[x_{h}/t_{h,j}]).

For the base case when j = 0 there is nothing to prove. Suppose, therefore, that 1 ≤ j ≤ n and that, for each i = 1, …, n and h = 1, …, j − 1,

vars(t_{i,j−1}) = vars(t_{i,j−1}[x_{h}/t_{h,j−1}]).

Now by the definition of t_{k,j} where 1 ≤ k ≤ n, k ≠ j, we have

vars(t_{k,j}) = vars(t_{k,j−1}[x_{j}/t_{j,j}]).  (12)

Also, since a substitution consisting of a single binding is variable-idempotent,

vars(t_{j,j}) = vars(t_{j,j}[x_{j}/t_{j,j}])

so that, as t_{j,j} = t_{j,j−1},

vars(t_{j,j}) = vars(t_{j,j−1}[x_{j}/t_{j,j}]).  (13)

Thus, by (12) and (13), for all k such that 1 ≤ k ≤ n, we have

vars(t_{k,j}) = vars(t_{k,j−1}[x_{j}/t_{j,j}]).  (14)

Therefore, for each i = 1, …, n and h = 1, …, j, using (14) and the inductive hypothesis, we have

vars(t_{i,j}[x_{h}/t_{h,j}]) = vars(t_{i,j−1}[x_{j}/t_{j,j}][x_{h}/t_{h,j−1}[x_{j}/t_{j,j}]])
= vars(t_{i,j−1}[x_{h}/t_{h,j−1}][x_{j}/t_{j,j}])
= vars(t_{i,j−1}[x_{j}/t_{j,j}])
= vars(t_{i,j}).

Letting j = n we obtain, for each i, h = 1, …, n,

vars(t_{i,n}[x_{h}/t_{h,n}]) = vars(t_{i,n}).

Therefore, for all τ ⊆ σ_{n} and each i = 1, …, n,

vars(t_{i,n}τ) = vars(t_{i,n}).

Thus, by Lemma 3, for all τ ⊆ σ_{n}, τ ∈ VSubst. The result follows by taking σ′ = σ_{n}.

5 The Abstraction Function for RSubst

In this section we define a new abstraction function mapping arbitrary substitutions in rational solved form into their abstract descriptions. This abstraction function is based on a new definition for the notion of occurrence. The new occurrence operator occ is defined on RSubst so that it does not require the explicit computation of intermediate variable-idempotent substitutions. To this end, it is given as the fixed point of a sequence of occurrence functions. The occ operator generalises the sg operator, defined for ISubst, coinciding with it when applied to idempotent substitutions.

Definition 5 (Occurrence functions.) For each n ∈ ℕ, occ_{n}: RSubst × Vars → ℘_{f}(Vars), called occurrence function, is defined, for each σ ∈ RSubst and each v ∈ Vars, by

occ_{0}(σ, v) =^{def} {v} \ dom(σ)

and, for n > 0, by

occ_{n}(σ, v) =^{def} { y ∈ Vars | vars(yσ) ∩ occ_{n−1}(σ, v) ≠ ∅ }.

The following monotonicity property for occ_{n} is proved at the end of this section.

Lemma 11 If n > 0, then, for each σ ∈ RSubst and each v ∈ Vars,

occ_{n−1}(σ, v) ⊆ occ_{n}(σ, v).

Note that, by considering the substitution {u ↦ v, v ↦ w}, it can be seen that, if we had not excluded the domain variables in the definition of occ_{0}, then this monotonicity property would not have held.

For any n, the set occ_{n}(σ, v) is restricted to the set {v}∪vars(σ). Thus, it follows from Lemma 11, that there is an ℓ = ℓ(σ, v) ∈ ℕ such that occ_{ℓ}(σ, v) = occ_{n}(σ, v) for all n ≥ ℓ.

Definition 6 (Occurrence operator.) For each σ ∈ RSubst and v ∈ Vars, the occurrence operator occ: RSubst × Vars → ℘_{f}(Vars) is given by

occ(σ, v) =^{def} occ_{ℓ}(σ, v)

where ℓ ∈ ℕ is such that occ_{ℓ}(σ, v) = occ_{n}(σ, v) for all n ≥ ℓ.

Note that, by combining Definitions 5 and 6, we obtain

occ(σ, v) = { y ∈ Vars | vars(yσ) ∩ occ(σ, v) ≠ ∅ }.  (15)

The following simpler characterisations for occ can be used when the variable is in the domain of the substitution, the substitution is variable-idempotent or the substitution is idempotent.

Lemma 12 If σ ∈ RSubst and v ∈ dom(σ), then occ(σ, v) = ∅.

Lemma 13 If σ ∈ VSubst then, for each v ∈ Vars,

occ(σ, v) = occ_{1}(σ, v)
= { y ∈ Vars | v ∈ vars(yσ) \ dom(σ) }.

Lemma 14 If σ ∈ ISubst and v ∈ Vars then occ(σ, v) = sg(σ, v).

These results are proved at the end of this section.

Example 7 Consider again Example 6. Then, for all i ≥ 0, dom(σ_{i}) = {x_{1}, x_{2}, x_{3}} so that

occ(σ_{i}, x_{1}) = occ(σ_{i}, x_{2}) = occ(σ_{i}, x_{3}) = ∅.

However,

occ_{0}(σ_{0}, x_{4}) = {x_{4}},
occ_{1}(σ_{0}, x_{4}) = {x_{2}, x_{4}},
occ_{2}(σ_{0}, x_{4}) = {x_{1}, x_{2}, x_{4}},
occ_{3}(σ_{0}, x_{4}) = {x_{1}, x_{2}, x_{3}, x_{4}} = occ(σ_{0}, x_{4}).

Also, note that

occ_{1}(σ_{3}, x_{4}) = {x_{1}, x_{2}, x_{3}, x_{4}} = occ(σ_{3}, x_{4}).

The definition of abstraction is based on the occurrence operator, occ.

Definition 7 (Abstraction.) The concrete domain ℘(RSubst) is related to SS by means of the abstraction function α: ℘(RSubst) × ℘_{f}(Vars) → SS. For each Σ ∈ ℘(RSubst) and each U ∈ ℘_{f}(Vars),

α(Σ, U) =^{def} ⨆_{σ∈Σ} α(σ, U)

where α: RSubst ×℘_{f}(Vars) → SS is defined, for each substitution σ ∈ RSubst and each U ∈ ℘_{f}(Vars), by

α(σ, U) =^{def} ({ occ(σ, v) ∩ U | v ∈ Vars } \ {∅}, U).

Example 8 Let us consider Examples 6 and 7 once more. Then, assuming U = {x_{1}, x_{2}, x_{3}, x_{4}},

α(σ_{0}, U) = ({occ(σ_{0}, x_{4})}, U) = ({{x_{1}, x_{2}, x_{3}, x_{4}}}, U).

As a second example, consider the substitution

σ = {x_{1} ↦ f(x_{1}), x_{2} ↦ x_{1}, x_{3} ↦ x_{1}, x_{4} ↦ x_{2}}.

Then

occ(σ, x_{1}) = occ(σ, x_{2}) = occ(σ, x_{3}) = occ(σ, x_{4}) = ∅

so that, if we again assume U = {x_{1}, x_{2}, x_{3}, x_{4}},

α(σ, U) = (∅, U).

Any substitution in rational solved form is equivalent, with respect to any equality theory, to a variable-idempotent substitution having the same abstraction.

Theorem 3 If T is an equality theory and σ ∈ RSubst is satisfiable in T, then there exists a substitution σ′ ∈ VSubst such that τ ∈ VSubst, for all τ ⊆ σ′, T ⊢ ∀(σ ↔ σ′), vars(σ) = vars(σ′) and α(σ, U) = α(σ′, U), for any U ∈ ℘_{f}(Vars).

Equivalent substitutions in rational solved form have the same abstraction. We note that this property is essential for the implementation of the SS domain.

Theorem 4 If T is a syntactic equality theory and σ, σ′ ∈ RSubst are satisfiable in T and such that T ⊢ ∀(σ ↔ σ′), then α(σ, U) = α(σ′, U), for any U ∈ ℘_{f}(Vars).

5.1 Proofs of Lemmas 11, 12, 13 and 14 and Theorems 3 and 4

Proof of Lemma 11. The proof is by induction on n. For the base case (when n = 1), if occ_{0}(σ, v) ≠ ∅, then v ∉ dom(σ) and occ_{0}(σ, v) = {v}. Thus, v = vσ so that, by Definition 5, v ∈ occ_{1}(σ, v). Suppose n > 1. Then, if y ∈ occ_{n−1}(σ, v), we have, by Definition 5, vars(yσ) ∩ occ_{n−2}(σ, v) ≠ ∅. By the induction hypothesis,

occ_{n−2}(σ, v) ⊆ occ_{n−1}(σ, v)

so that vars(yσ) ∩ occ_{n−1}(σ, v) ≠ ∅ and thus y ∈ occ_{n}(σ, v).

Proof of Lemma 12. By Definition 5, occ_{0}(σ, v) = ∅ and, for all n > 0, we have occ_{n}(σ, v) = ∅ if occ_{n−1}(σ, v) = ∅. Thus, occ_{n}(σ, v) = ∅, for all n ≥ 0, so that, by Definition 6, occ(σ, v) = ∅.

Proof of Lemma 13. Suppose first that v ∈ dom(σ). Then

{ y ∈ Vars | v ∈ vars(yσ) \ dom(σ) } = ∅.

Also, by Lemma 12, occ_{1}(σ, v) = occ(σ, v) = ∅.

Suppose next that v ∉ dom(σ). It follows from Definition 5, that

occ_{0}(σ, v) = {v},
occ_{1}(σ, v) = { y ∈ Vars | vars(yσ) ∩ {v} ≠ ∅ }
= { y ∈ Vars | v ∈ vars(yσ) },

and

occ_{2}(σ, v) = { y ∈ Vars | vars(yσ) ∩ { y_{1} ∈ Vars | v ∈ vars(y_{1}σ) } ≠ ∅ }
= { y ∈ Vars | v ∈ vars(yσ^{2}) }.

However, as σ ∈ VSubst, we have vars(yσ) \ dom(σ) = vars(yσ^{2}) \ dom(σ). Thus, as v ∉ dom(σ), occ_{1}(σ, v) = occ_{2}(σ, v) and hence, by Definition 5, we have also occ_{n}(σ, v) = occ_{1}(σ, v), for all n ≥ 1. Therefore, by Definition 6,

occ(σ, v) = occ_{1}(σ, v) = { y ∈ Vars | v ∈ vars(yσ) }.

Proof of Lemma 14. As σ ∈ ISubst we have, for all y ∈ Vars, vars(yσ) \ dom(σ) = vars(yσ). Also, as σ ∈ VSubst, we can apply Lemma 13 so that

occ(σ, v) = { y ∈ Vars | v ∈ vars(yσ) \ dom(σ) }
= { y ∈ Vars | v ∈ vars(yσ) }
= sg(σ, v).

To prove Theorem 3, we need to show that the abstraction function α is invariant with respect to S-transformation.

Lemma 15 Let σ, σ′ ∈ RSubst where σ ⟼^{∗}^{S} σ′ and U ∈ ℘_{f}(Vars). Then α(σ, U) = α(σ′, U).

Proof Suppose first that σ ⟼^{S} σ′. Thus we assume that (x ↦ t), (y ↦ s) ∈ σ , where x ≠ y, and that

σ′ = (σ \ {y ↦ s}) ∪ {y ↦ s[x/t]}.  (16)

Suppose v ∈ Vars. Then we show that occ(σ, v) = occ(σ′, v).

If x ∉ vars(s), then σ′ = σ and there is nothing to prove. Also, if v ∈ dom(σ) then, by Theorem 1, v ∈ dom(σ′) so that by Lemma 12, occ(σ, v) = occ(σ′, v) = ∅.

We now assume that x ∈ vars(s) and v = vσ = vσ′. We first prove that, for each m ≥ 0,

occ_{m}(σ, v) ⊆ occ(σ′, v).  (17)

The proof is by induction on m. By Definition 5, we have that

occ_{0}(σ, v) = occ_{0}(σ′, v) = {v},

so that (17) holds for m = 0. Suppose then that m > 0 and that v_{m} ∈ occ_{m}(σ, v). Then, to prove (17), we must show that v_{m} ∈ occ(σ′, v). By Definition 5, there exists

v_{m−1} ∈ vars(v_{m}σ) ∩ occ_{m−1}(σ, v).  (18)

Hence, by the inductive hypothesis, v_{m−1} ∈ occ(σ′, v). If v_{m−1} ∈ vars(v_{m}σ′), then, by Eq. (15), v_{m} ∈ occ(σ′, v). Suppose now that v_{m−1} ∉ vars(v_{m}σ′). Since, by (18), we have that v_{m−1} ∈ vars(v_{m}σ), it follows, using (16), that v_{m} = y and v_{m−1} = x. However, by assumption, v ∈ dom(σ), so that x ≠ v and m > 1. Thus, by Definition 5, there exists

v_{m−2} ∈ vars(xσ) ∩ occ_{m−2}(σ, v).  (19)

However, xσ = t and x ∈ vars(s) so that, by (19), we have v_{m−2} ∈ vars(s[x/t]). Since, by Eq. (16), (y ↦ s[x/t]) ∈ σ′, we have also v_{m−2} ∈ vars(yσ′). Moreover, by (19), v_{m−2} ∈ occ_{m−2}(σ, v) so that, by the inductive hypothesis, we have that v_{m−2} ∈ occ(σ′, v). Thus, by Eq. (15), as v_{m} = y, v_{m} ∈ occ(σ′, v).

Conversely, we now prove that, for all m ≥ 0,

occ_{m}(σ′, v) ⊆ occ(σ, v).  (20)

The proof is again by induction on m. As before, occ_{0}(σ′, v) = occ_{0}(σ, v) = {v} so that (20) holds for m = 0. Suppose then that m > 0 and v_{m} ∈ occ_{m}(σ′, v). Then, to prove (20), we must show that v_{m} ∈ occ(σ, v). By Definition 5, there exists

v_{m−1} ∈ vars(v_{m}σ′) ∩ occ_{m−1}(σ′, v).  (21)

Hence, by the inductive hypothesis, v_{m−1} ∈ occ(σ, v). If v_{m−1} ∈ vars(v_{m}σ) then, by Eq. (15), we have v_{m} ∈ occ(σ, v). Suppose now that v_{m−1} ∉ vars(v_{m}σ). Since, by (21), we have v_{m−1} ∈ vars(v_{m}σ′), it follows, using Eq. (16), that v_{m} = y and v_{m−1} ∈ vars(t) = vars(xσ). Hence, since v_{m−1} ∈ occ(σ, v), by Eq. (15), we have also x ∈ occ(σ, v). Furthermore, x ∈ vars(yσ) so again, by Eq. (15), as v_{m} = y, v_{m} ∈ occ(σ, v).

Combining (17) and (20) we obtain the result that, if σ′ is obtained from σ by a single S-step, then occ(σ, v) = occ(σ′, v). Thus, as v ∈ Vars was arbitrary, α(σ, U) = α(σ′, U).

Suppose now that σ = σ_{1} ⟼^{S} ⋯ ⟼^{S} σ_{n} = σ′. If n = 1, then σ = σ′. If n > 1, we have by the first part of the proof that, for each i = 2, …, n, α(σ_{i−1}, U) = α(σ_{i}, U), and hence the required result.

Proof of Theorem 3. By Theorem 2, there exists σ′ ∈ VSubst such that σ ⟼^{∗}^{S} σ′ and, for any τ ⊆ σ′, τ ∈ VSubst. Moreover, by Theorem 1, vars(σ) = vars(σ′) and T ⊢ ∀(σ ↔ σ′). Thus, by Lemma 15, α(σ, U) = α(σ′, U).

To prove Theorem 4, we need to show that the abstraction function α is invariant when we exchange equivalent variables to obtain an ordered substitution.

Lemma 16 Suppose σ ∈ VSubst, v, w ∈ Vars and (v ↦ w) ∈ σ. Let ρ = {v ↦ w, w ↦ v} be a (circular) substitution and define σ′ = ρ ∘ σ = {xρ ↦ tρ | x ↦ t ∈ σ}. Then

1. σ′ ∈ VSubst,

2. vars(σ) = vars(σ′),

3. α(σ, U) = α(σ′, U), for all U ∈ ℘_{f}(Vars), and

4. T ⊢ ∀(σ ↔ σ′), for any equality theory T.

Proof Since σ′ is obtained from σ by renaming variables and σ ∈ VSubst, we have also that σ′ ∈ VSubst. In addition, vars(σ) \ {v, w} = vars(σ′) \ {v, w} so that, since (v ↦ w) ∈ vars(σ) and (w ↦ v) ∈ vars(σ′), we have vars(σ) = vars(σ′).

To prove 16.3, we have to show that, if

α(σ, U) =^{def} (sh, U) and α(σ′, U) =^{def} (sh′, U),

then sh = sh′. By the hypothesis, for all y ∈ Vars we have x ∈ vars(yσ) if and only if xρ ∈ vars(yσ′). As σ, σ′ ∈ VSubst, we can use the alternative characterisation of occ given by Lemma 13 and conclude that, for each x ∈ Vars, occ(σ, x) = occ(σ′, xρ). Therefore sh ⊆ sh′. The reverse inclusion follows by symmetry so that sh = sh′.

To prove 16.4, we first show by induction on the depth of r ∈ T_{Vars} that

T ⊢ ∀((v = w) → (r = rρ)).  (22)

For the base case, r has depth 1. If r is a constant or a variable other than v or w, then r = rρ. If r = v, then rρ = w and T ⊢ ∀((v = w) → (v = w)). Finally, if r = w, then rρ = v and we have, using the congruence axioms, that T ⊢ ∀((v = w) → (w = v)). For the inductive step, let r = f(r_{1}, …, r_{n}). Then rρ = f(r_{1}ρ, …, r_{n}ρ). Thus, using the inductive hypothesis, for each i = 1, …, n, T ⊢ ∀((v = w) → (r_{i} = r_{i}ρ)). Hence, by the congruence axioms, (22) holds.

Note that (v ↦ w) ∈ σ. Thus, it follows from (22) that, for each (x ↦ t) ∈ σ, T ⊢ ∀(σ → {x = t, x = xρ, t = tρ}) and hence, using the congruence axioms, T ⊢ ∀(σ → {xρ = tρ}). Thus, T ⊢ ∀(σ → σ′). Since (w ↦ v) ∈ σ′, the reverse implication follows by symmetry so that T ⊢ ∀(σ′ ↔ σ).

Lemma 17 Suppose σ ∈ VSubst. Then there exists σ′ ∈ V Subst that is ordered such that vars(σ) = vars(σ′), α(σ, U) = α(σ′, U), for all U ∈ ℘_{f}(Vars), and T ⊢ ∀(σ ↔ σ′), for any equality theory T.

Proof The proof is by induction on the number b ≥ 0 of the bindings (v ↦ w) ∈ σ such that w ∈ param(σ) and w > v (the number of unordered bindings). For the base case, when b = 0, σ is ordered and the result holds by taking σ′ = σ.

For the inductive case, when b > 0, let (v ↦ w) ∈ σ be an unordered binding and define ρ = {v ↦ w, w ↦ v}. Then, by Lemma 16, we have ρ ∘ σ ∈ VSubst, vars(σ) = vars(ρ ∘ σ), α(σ, U) = α(ρ ∘ σ, U), for all U ∈ ℘_{f}(Vars), and, finally, T ⊢ ∀(σ ↔ ρ ∘ σ), for any equality theory T. In order to apply the inductive hypothesis to ρ ∘ σ, we must show that the number of unordered bindings in ρ ∘ σ is less than b. To this end, roughly speaking, we start showing that any ordered binding in σ is mapped by ρ into another ordered binding in ρ∘σ, therefore proving that the number of unordered bindings is not increasing. There are three cases. First, any ordered binding (y ↦ t) ∈ σ such that t ∉ Vars is mapped by ρ into the binding (yρ ↦ tρ) ∈ (ρ ∘ σ) which is clearly ordered, since tρ ∉ Vars. Second, consider any ordered binding (y ↦ z) ∈ σ such that z ∈ dom(σ). Since w ∈ param(σ), we have z ≠ w. If also z ≠ v then we have zρ = z and z ∈ dom(ρ ∘ σ); otherwise z = v so that zρ = w and, as (w ↦ v) ∈ (ρ ∘ σ), zρ ∈ dom(ρ ∘ σ). Thus, in either case, such a binding is mapped by ρ into the binding (yρ ↦ zρ) ∈ (ρ ∘ σ) which is ordered since zρ ∈ dom(ρ ∘ σ). Third, consider any ordered binding (y ↦ z) ∈ σ such that z ∈ param(σ) and z < y. The ordering relation implies y ≠ v and we also have y ≠ w, since w ∈ param(σ). Hence, we obtain yρ = y. Now, as z ∈ param(σ), z ≠ v. If z ≠ w, then zρ = z. On the other hand, if z = w, then zρ = v so that zρ < z. Thus, in both cases, as z < y, zρ < y. and hence, (yρ ↦ zρ) ∈ (ρ ∘ σ) is ordered. Finally, to show that the number of unordered bindings is strictly decreasing, we note that the unordered binding (v ↦ w) ∈ σ is mapped by ρ into the binding (w ↦ v) ∈ (ρ ∘ σ), which is ordered.

Therefore, by applying the inductive hypothesis, there exists a substitution σ′ such that σ′ ∈ VSubst is ordered, vars(ρ ∘ σ) = vars(σ′), α(ρ ∘ σ, U) = α(σ′, U), for all U ∈ ℘_{f}(Vars), and T ⊢ ∀(ρ ∘ σ ↔ σ′), for any equality theory T. Then the required result follows by transitivity.

Proof of Theorem 4. By Theorem 3, we can assume that σ, σ′ ∈ VSubst, T ⊢ ∀(σ ↔ σ′) and, for any U ∈ ℘_{f}(Vars), α(σ, U) = α(σ′, U). By Lemma 17, we can assume that σ, σ′ are also ordered substitutions so that, by Lemma 5, dom(σ′) = dom(σ).

To prove the result we need to show that, for all v ∈ Vars, we have both occ(σ, v) ⊆ occ(σ′, v) and occ(σ′, v) ⊆ occ(σ, v). We just prove the first of these as the other case is symmetric.

Suppose that w ∈ Vars and that v ∈ vars(wσ) \ dom(σ). Then, using the alternative characterisation of occ for variable-idempotent substitutions given by Lemma 13, we just have to show that v ∈ vars(wσ′) \ dom(σ′).

By Lemma 6 (replacing τ by σ, σ by σ′ and s = t by w = w), we have that there exists z ∈ vars(wσ′) \ dom(σ′) such that v ∈ vars(zσ). Thus as dom(σ′) = dom(σ), z ∉ dom(σ), and hence, v = z so that v ∈ vars(wσ′) \ dom(σ′), as required.

6 Abstract Unification

The operations of abstract unification together with statements of the main results are presented here in three stages. In the first two stages, we consider substitutions containing just a single binding. For the first, it is assumed that the set of variables of interest is fixed so that the definition is based on the SH domain. Then, in the second, using the SS domain, the definition is extended to allow for the introduction of new variables in the binding. The final stage extends this definition further to deal with arbitrary substitutions.

6.1 Abstract Operations for Sharing Sets

The abstract unifier amgu abstracts the effect of a single binding on an element of the SH domain. For this we need some ancillary definitions.

Definition 8 (Auxiliary functions.) The closure under union function (also called star-union), (·)^{⋆}: SH → SH , is given, for each sh ∈ SH , by

sh^{⋆} =^{def} { S ∈ SG | ∃n ≥ 1 . ∃S_{1}, …, S_{n} ∈ sh . S = S_{1} ∪ ⋯ ∪ S_{n} }.

For each sh ∈ SH and each V ∈ ℘_{f}(Vars), the extraction of the relevant component of sh with respect to V is encoded by rel: ℘_{f}(Vars) × SH → SH defined as

rel(V, sh) =^{def} { S ∈ sh | S ∩ V ≠ ∅ }.

For each sh_{1}, sh_{2} ∈ SH , the binary union function bin: SH × SH → SH is given by

bin(sh_{1}, sh_{2}) =^{def} { S_{1} ∪ S_{2} | S_{1} ∈ sh_{1}, S_{2} ∈ sh_{2} }.

Definition 9 (amgu.) The function amgu: SH × Bind → SH captures the effects of a binding on an SH element. Suppose x ∈ Vars, r ∈ T_{Vars}, and sh ∈ SH . Let

A =^{def} rel({x}, sh),
B =^{def} rel(vars(r), sh).

Then

amgu(sh, x ↦ r) =^{def} (sh \ (A ∪ B)) ∪ bin(A^{⋆}, B^{⋆}).

The following soundness result for amgu is proved in Section 6.4.

Theorem 5 Let T be a syntactic equality theory, (sh, U) ∈ SS an abstract description and {x ↦ r}, σ ∈ RSubst such that vars(x ↦ r) ∪ vars(σ) ⊆ U. Suppose that there exists a most general solution μ for ({x = r} ∪ σ) in T. Then

α(σ, U) ⪯_{SS} (sh, U) ⟹ α(μ, U) ⪯_{SS} (amgu(sh, x ↦ r), U).

The following theorems, proved in Section 6.4, show that amgu is idempotent and commutative.

Theorem 6 Let sh ∈ SH and (x ↦ r) ∈ Bind. Then

amgu(sh, x ↦ r) = amgu(amgu(sh, x ↦ r), x ↦ r).

Theorem 7 Let sh ∈ SH and (x ↦ r), (y ↦ t) ∈ Bind. Then

amgu(amgu(sh, x ↦ r), y ↦ t) = amgu(amgu(sh, y ↦ t), x ↦ r).

6.2 Abstract Operations for Sharing Domains

The definitions and results of Section 6.1 can be lifted to apply to the proper setsharing domain.

Definition 10 (Amgu.) The operation Amgu: SS × Bind → SS extends the SS description it takes as an argument to the set of variables occurring in the binding it is given as the second argument. Then it applies amgu. Formally:

U′ =^{def} vars(x ↦ r) \ U,
Amgu((sh, U), x ↦ r) =^{def} (amgu(sh ∪ { {u} | u ∈ U′ }, x ↦ r), U ∪ U′).

The results for amgu can easily be extended to apply to Amgu giving us the following corollaries.

Corollary 1 Let T be a syntactic equality theory, (sh, U) ∈ SS and {x ↦ r}, σ ∈ RSubst such that vars(σ) ⊆ U. Suppose there exists a most general solution μ for ({x = r} ∪ σ) in T. Then

α(σ, U) ⪯_{SS} (sh, U) ⟹ α(μ, U ∪ vars(x ↦ r)) ⪯_{SS} Amgu((sh, U), x ↦ r).

Corollary 2 Let sh ∈ SH and (x ↦ r) ∈ Bind. Then

Amgu((sh, U), x ↦ r) = Amgu(Amgu((sh, U), x ↦ r), x ↦ r).

Corollary 3 Let sh ∈ SH and (x ↦ r), (y ↦ t) ∈ Bind. Then

Amgu(Amgu((sh, U), x ↦ r), y ↦ t)

= Amgu(Amgu((sh, U), y ↦ t), x ↦ r).

6.3 Abstract Unifiers for Sharing

We now extend the above definitions and results for a single binding to any substitution.

Definition 11 (aunify.) The function aunify: SS × RSubst → SS generalizes Amgu to any substitution μ ∈ RSubst in the context of some syntactic equality theory T: If we have (sh, U) ∈ SS, then

aunify((sh, U), ∅) =^{def} (sh, U);

if μ holds in T and (x ↦ r) ∈ μ,

aunify((sh, U), μ) =^{def} aunify((Amgu(sh, U), x ↦ r), μ \ {x ↦ r});

and, if μ does not hold in T,

aunify((sh, U), μ) =^{def} ⊥.

For the distinguished elements ⊥ and ⊤ of SS,

aunify(⊥, μ) =^{def} ⊥,
aunify(⊤, μ) =^{def} ⊤.

As a result of Corollary 3, Amgu and aunify commute.

Lemma 18 Let (sh, U) ∈ SS, ν ∈ RSubst and (y ↦ t) ∈ Bind. Then

aunify(Amgu((sh, U), y ↦ t), ν) = Amgu(aunify((sh, U), ν), y ↦ t).

As a consequence of this and Corollaries 1, 2 and 3, we have the following soundness, idempotence and commutativity results required for aunify to be sound and welldefined.

Theorem 8 Let T be a syntactic equality theory, (sh, U) ∈ SS and σ, ν ∈ RSubst such that vars(σ) ⊆ U. Suppose also that there exists a most general solution μ for (ν ∪ σ) in T. Then

α(σ, U) ⪯_{SS} (sh, U) ⟹ α(μ, U ∪ vars(ν)) ⪯_{SS} aunify((sh, U), μ).

This theorem shows also that it is safe for the analyzer to perform part or all of the concrete unification algorithm before computing aunify.

Theorem 9 Let (sh, U) ∈ SS and ν ∈ RSubst. Then

aunify((sh, U), ν) = aunify(aunify((sh, U), ν), ν).

Theorem 10 Let (sh, U) ∈ SS and ν_{1}, ν_{2} ∈ RSubst. Then

aunify(aunify((sh, U), ν_{1}), ν_{2}) = aunify(aunify((sh, U), ν_{2}), ν_{1}).

The proofs of all these results are in Section 6.5.

6.4 Proofs of Results for Sharing-Sets

In the proofs we use the fact that (·)^{⋆} and rel are monotonic so that

sh_{1} ⊆ sh_{2} ⟹ sh_{1}^{⋆} ⊆ sh_{2}^{⋆},  (23)
sh_{1} ⊆ sh_{2} ⟹ rel(sh_{1}, U) ⊆ rel(sh_{2}, U).  (24)

We will also use the fact that (·)^{⋆} is idempotent.

Let t_{1}, …, t_{n} be terms. For the sake of brevity we will use the notation v_{t_{1}···t_{n}} to denote ⋃_{i=1}^{n} vars(t_{i}). In particular, if x and y are variables, and r and t are terms, we will use the following definitions:

v_{x} =^{def} {x},  v_{y} =^{def} {y},
v_{r} =^{def} vars(r),  v_{t} =^{def} vars(t),
v_{xr} =^{def} v_{x} ∪ v_{r},  v_{yt} =^{def} v_{y} ∪ v_{t}.

Definition 12 (\overline{rel}.) Suppose V ∈ ℘_{f}(Vars) and sh ∈ SH . Then

\overline{rel}(V, sh) =^{def} sh \ rel(V, sh).

Notice that if S ∈ \overline{rel}(V, sh) then S ∩V = ∅. Conversely, if S ∈ sh and S ∩V = ∅ then S ∈ \overline{rel}(V, sh). The following definition of amgu is clearly equivalent to the one given in Definition 9: for each variable x, each term r, and each sh ∈ SH ,

amgu(sh, x ↦ r) =^{def} \overline{rel}(v_{xr}, sh) ∪ bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆}).  (25)

Proof of Theorem 5. We first prove the result under the assumption that α(σ, U) = (sh, U). We do this in two parts. In the first, we partition σ into two substitutions one of which, called σ^{−}, is the same as σ when σ and μ are idempotent. We construct a new substitution ν which, in the case that σ and μ are idempotent, is a most general solution for xσ = rσ. Finally we compose ν with σ^{−} to define a substitution that has the same abstraction as μ but with a number of useful properties including that of variableidempotence. In the second part, we use this composed substitution in place of μ to prove the result.

Part 1. By Theorem 3, we can assume that

σ ∈ VSubst  (26)

and that all subsets of σ are in VSubst. Let σ^{∘}, σ^{−} ∈ RSubst be defined such that

σ^{−} ∪ σ^{∘} = σ,  (27)
dom(σ^{∘}) = dom(σ) ∩ ⋃_{i≥1} vars(xσ^{i} = rσ^{i}),  (28)
dom(σ^{−}) ∩ dom(σ^{∘}) = ∅.  (29)

Then, it follows from the above assumption on subsets of σ that

σ^{−} ∈ VSubst, σ^{∘} ∈ VSubst.  (30)

Now, suppose z ∈ vars(σ^{∘}) \ dom(σ^{∘}). Then z ∈ vars(yσ^{∘}) for some y ∈ dom(σ^{∘}). Thus, by (28), for some j ≥ 2, z ∈ vars(xσ^{j} = rσ^{j}) \ dom(σ^{∘}) and, again by (28), z ∉ dom(σ) so that, by (26), z ∈ vars(xσ = rσ). Therefore, as z was an arbitrary variable in vars(σ^{∘}) \ dom(σ^{∘}),

vars(σ^{∘}) ⊆ (vars(xσ = rσ) ∪ dom(σ^{∘})).  (31)

It follows from (28) that dom(σ) ∩ vars(xσ = rσ) ⊆ dom(σ^{∘}) so that, by (29)

dom(σ^{−}) ∩ vars(xσ = rσ) = ∅.  (32)

Hence, by (29) and (31), we have

dom(σ^{−}) ∩ vars(σ^{∘}) = ∅.  (33)

Let ν ∈ RSubst be a most general solution for {xσ = rσ} ∪ σ^{∘} in T so that

T ⊢ ∀(ν ↔ {xσ = rσ} ∪ σ^{∘}),  (34)
vars(ν) ⊆ (vars(xσ = rσ) ∪ vars(σ^{∘})).  (35)

By Theorem 3, we can assume that

ν ∈ VSubst.  (36)

By (32), (33), and (35), we have

dom(σ^{−}) ∩ vars(ν) = ∅.  (37)

Therefore, as σ^{−}, ν ∈ VSubst (by (30) and (36)), we can use Lemma 7 to obtain the following properties for ν ∘ σ^{−}.

T ⊢ ∀((ν ∘ σ^{−}) ↔ (ν ∪ σ^{−})),  (38)
dom(ν ∘ σ^{−}) = dom(ν ∪ σ^{−}),  (39)
ν ∘ σ^{−} ∈ VSubst.  (40)

Now we have

T ⊢ ∀(μ ↔ {x = r} ∪ σ)

[by hypothesis]

T ⊢ ∀(μ ↔ {xσ = rσ} ∪ σ)

[by Lemma 2 and the congruence axioms]

T ⊢ ∀(μ ↔ ν ∪ σ^{−})

[by (27) and (34)]

T ⊢ ∀(μ ↔ ν ∘ σ^{−})  (41)

[by (38)].

Therefore, by Theorem 4,

α(μ, U) = α(ν ∘ σ^{−}, U).  (42)

Part 2. To prove the result under the assumption that α(σ, U) = (sh, U), we define sh′ ∈ SH so that

α(μ, U) = (sh′, U).  (43)

Then, by (42), α(ν ∘ σ^{−}, U) = (sh′, U). We show that sh′ ⊆ amgu(sh, x ↦ r). If sh′ = ∅, there is nothing to prove. Therefore, we assume that there exists S ∈ sh′ so that S ≠ ∅ and, for some v ∈ Vars,

v ∉ dom(ν ∘ σ^{−}),  (44)
S =^{def} occ(ν ∘ σ^{−}, v).  (45)

Note that (39) and (44) imply that

v ∉ dom(ν),  v ∉ dom(σ^{−}).  (46)

Let

S′ =^{def} ⋃{ occ(σ, y) | y ∈ occ(ν, v) }.  (47)

We show that

S = S′.  (48)

By (26), (36) and (40), σ, ν, ν ∘σ^{−} ∈ VSubst and, by (44) and (46), v ∉ dom(ν ∘σ^{−}) and v ∉ dom(ν). Thus, it follows from Lemma 13 with (45) and (47), that it suffices to show that, for each w ∈ Vars, v ∈ vars(wσ^{−}ν) if and only if there exists z ∈ vars(wσ) \ dom(σ) such that v ∈ vars(zν).

First, we suppose that v ∈ vars(wσ^{−}ν). Thus, there exists y ∈ vars(wσ^{−}) such that v ∈ vars(yν). Since σ^{∘}, ν ∈ VSubst (by (30) and (36)), T ⊢ ∀(ν → σ^{∘}) (by (34)), v ∉ dom(ν) (by (46)) and T ⊢ ∀(ν → (yν = y)) (using Lemma 2), we can apply Lemma 6 (replacing τ by ν, σ by σ^{∘} and s = t by yν = y) so that there exists z ∈ vars(yσ^{∘}) \ dom(σ^{∘}) such that v ∈ vars(zν). We want to show that z ∈ vars(wσ) \ dom(σ). Now either z ∈ dom(ν) or z = v so that, by (37) (if z ∈ dom(ν)) or (46) (if z = v), z ∉ dom(σ^{−}). However, z ∉ dom(σ^{∘}), so that, by (27), z ∉ dom(σ). Thus, it remains to prove that z ∈ vars(wσ). Now, as y ∈ vars(wσ^{−}) and z ∈ vars(yσ^{∘}), we have z ∈ vars(wσ^{−}σ^{∘}). So we must show that vars(wσ^{−}σ^{∘}) \ dom(σ) ⊆ vars(wσ). To see this note that, if w ∉ dom(σ^{−}), then wσ^{−} = w and, by (27), wσ^{∘} = wσ so that wσ^{−}σ^{∘} = wσ. On the other hand, if w ∈ dom(σ^{−}), then, by (27), wσ^{−} = wσ so that wσ^{−}σ^{∘} = wσσ^{∘} Now, as σ ∈ VSubst and σ^{∘} ⊆ σ (by (26) and (27)), we can apply Lemma 4 so that vars(wσσ^{∘}) \ dom(σ) ⊆ vars(wσ). Hence, vars(wσ^{−}σ^{∘}) \ dom(σ) ⊆ vars(wσ).

Secondly, suppose there exists z ∈ vars(wσ) \ dom(σ) such that v ∈ vars(zν). Then v ∈ vars(wσν). We need to show that v ∈ vars(wσ^{−}ν). By Eq. (27), if w ∈ dom(σ^{−}), then wσ^{−}ν = wσν so that v ∈ vars(wσ^{−}ν). On the other hand, if w ∉ dom(σ^{−}), then again, by (27), v ∈ vars(wσ^{∘}ν). Moreover, w = wσ^{−} so that, by (34) and Lemma 2 with the congruence axioms, T ⊢ ∀(ν → (wσ^{∘}ν = wσ^{−})). Hence, since ν ∈ VSubst (by (36)) and v ∉ dom(ν) (by (46)), we can apply Lemma 6 (replacing τ by ν, σ by the empty substitution and s = t by wσ^{∘}ν = wσ^{−}) and obtain v ∈ vars(wσ^{−}ν).

Therefore, as a consequence of the previous two paragraphs, for each w ∈ Vars, we have v ∈ vars(wσ^{−}ν) if and only if there exists z ∈ vars(wσ)\dom(σ) such that v ∈ vars(zν). It therefore follows that Eq. (48) holds.

Let

S_{x} =^{def} ⋃({ occ(σ, y) | y ∈ occ(ν, v) } ∩ rel(v_{x}, sh)),  (49)
S_{r} =^{def} ⋃({ occ(σ, y) | y ∈ occ(ν, v) } ∩ rel(v_{r}, sh)),  (50)
S_{0} =^{def} ⋃(\{ occ(σ, y) | y ∈ occ(ν, v) \} ∩ \overline{rel}(v_{xr}, sh)).  (51)

Note that by (47), (48) and the fact that

\overline{rel}(v_{xr}, sh) = sh \ (rel(v_{x}, sh) ∪ rel(v_{r}, sh)),

we have

S_{0} = S \ (S_{x} ∪ S_{r}).  (52)

We now consider the two cases S_{0} ≠ ∅ and S_{0} = ∅ separately.

Consider first the case when S_{0} ≠ ∅. Then, by (51), for some y ∈ Vars,

y ∈ occ(ν, v),  (53)

occ(σ, y) ∈ \overline{rel}(v_{xr}, sh).  (54)

Thus, by Lemma 12, y ∉ dom(σ) and hence, by (27), y ∉ dom(σ^{∘}). Also, by (54), occ(σ, y) ∩ v_{xr} = ∅. Thus as σ ∈ VSubst (by (26)) we can use Lemma 13 to see that, for each w ∈ v_{xr}, y ∉ vars(wσ) and hence, y ∉ vars(xσ = rσ). Therefore, by (31) and (35), y ∉ vars(ν). As ν ∈ VSubst (by (36)), we can apply Lemma 13 to both occ(ν, y) and occ(ν, v). Thus, as y ∉ vars(ν), occ(ν, y) = {y} and also (using (53)) v = y so that occ(ν, v) = {v}. It therefore follows from (47) and (48) that S = occ(σ, v) and hence from (54), that

S ∈ \overline{rel}(v_{xr}, sh).  (55)

Now consider the case when S_{0} = ∅. By (52), and the assumption that S ≠ ∅,

S = S_{x} ∪ S_{r} ≠ ∅.  (56)

As a consequence of (49) and (50),

S_{x} ∈ rel(v_{x}, sh)^{⋆} ∪ ∅,  (57)
S_{r} ∈ rel(v_{r}, sh)^{⋆} ∪ ∅.  (58)

Now, by (56) either S_{x} ≠ ∅ or S_{r} ≠ ∅. We will show that both S_{x} ≠ ∅ and S_{r} ≠ ∅. Suppose first that S_{x} ≠ ∅. Then, by (57), x ∈ S_{x}. Hence, by (56), x ∈ S. By (45), x ∈ occ(ν∘σ^{−}, v). However, ν∘σ^{−} ∈ VSubst (by (40)) so that we can apply Lemma 13 to occ(ν ∘ σ^{−}, v) and obtain that v ∈ vars(xσ^{−}ν). By the definition of μ in the hypothesis and (41), T ⊢ ∀(ν ∘ σ^{−} → (x = r)) and hence, by Lemma 2 with the congruence axioms, T ⊢ ∀(ν ∘ σ^{−} → (xσ^{−}ν = r)). Thus, as ν ∘ σ^{−} ∈ VSubst (by (40)) and v ∉ dom(ν ∘ σ^{−}) (by (44)), we have, by Lemma 6 (replacing τ by ν ∘ σ^{−}, σ by the empty substitution and s = t by xσ^{−}ν = r), v ∈ vars(rσ^{−}ν). By re-applying Lemma 13 to occ(ν∘σ^{−}, v), it can be seen that, as v ∉ dom(ν) (by (44)), v_{r} ∩ occ(ν ∘ σ^{−}, v) ≠ ∅. Hence, by (45), S ∩ v_{r} ≠ ∅. Thus, by (47) and (48), there exists a y ∈ occ(ν, v) such that occ(σ, y) ∩ v_{r} ≠ ∅. Therefore, by (50), S_{r} ∩ v_{r} ≠ ∅ and so S_{r} ≠ ∅. Secondly, by a similar argument, if S_{r} ≠ ∅ then we have S_{x} ≠ ∅. Hence S_{x} ≠ ∅ and S_{r} ≠ ∅. So that, by (57) and (58), S_{x} ∈ rel(v_{x}, sh)^{⋆} and S_{r} ∈ rel(v_{r}, sh)^{⋆}. Therefore, we have, by (56),

S ∈ bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆}).  (59)

Combining (55) when S_{0} ≠ ∅ and (59) when S_{0} = ∅ we obtain

S ∈ \overline{rel}(v_{xr}, sh) ∪ bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆})

and therefore, by (25),

S ∈ amgu(sh, x ↦ r).

As a consequence, since S was any set in sh′, we have sh′ ⊆ amgu(sh, x ↦ r) and hence, by (43),

α(μ, U) ⪯_{SS} (amgu(sh, x ↦ r), U).  (60)

We now drop the assumption that α(σ, U) = (sh, U) and just assume the hypothesis of the theorem that α(σ, U) ⪯_{SS} (sh, U). Suppose α(σ, U) = (sh_{1}, U). Then sh_{1} ⊆ sh. It follows from Definition 9 that amgu is monotonic on its first argument so that

amgu(sh_{1}, x ↦ r) ⊆ amgu(sh, x ↦ r).

Thus, by (60) (replacing sh by sh_{1}), we obtain the required result

α(μ, U) ⪯_{SS} (amgu(sh, x ↦ r), U).

Proof of Theorem 6. Let

sh_{−} =^{def} \overline{rel}(v_{xr}, sh),
sh_{xr} =^{def} bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆}).

Then,

sh_{xr}^{⋆} = sh_{xr},  bin(sh_{xr}, sh_{xr}) = sh_{xr}.

Moreover,

rel(v_{x}, sh_{xr}) = sh_{xr},  rel(v_{x}, sh_{−}) = ∅,
rel(v_{r}, sh_{xr}) = sh_{xr},  rel(v_{r}, sh_{−}) = ∅,
\overline{rel}(v_{xr}, sh_{xr}) = ∅,  \overline{rel}(v_{xr}, sh_{−}) = sh_{−}.

Hence, we have

rel(v_{x}, sh_{−} ∪ sh_{xr}) = sh_{xr},
rel(v_{r}, sh_{−} ∪ sh_{xr}) = sh_{xr},
\overline{rel}(v_{xr}, sh_{−} ∪ sh_{xr}) = sh_{−}.

Now, by (25),

amgu(amgu(sh, x ↦ r), x ↦ r)

= \overline{rel}(v_{xr}, sh_{−} ∪ sh_{xr}) ∪ bin(rel(v_{x}, sh_{−} ∪ sh_{xr})^{⋆}, rel(v_{r}, sh_{−} ∪ sh_{xr})^{⋆})

= sh_{−} ∪ sh_{xr}
= amgu(sh, x ↦ r).

For the proof of commutativity, we require the following auxiliary results.

Lemma 19 For each V ∈ ℘_{f}(Vars) and sh ∈ SH we have

\overline{rel}(V, sh^{⋆}) = \overline{rel}(V, sh)^{⋆}.

Proof Let S ∈ SG. Then S ∈ \overline{rel}(V, sh^{⋆}) means S ∈ sh^{⋆} and S ∩ V = ∅. In other words, there exist S_{1}, …, S_{n} ∈ sh such that S = ⋃_{i=1}^{n} S_{i} and, for each i = 1, …, n, we have S_{i} ∩ V = ∅. This amounts to saying that there exist S_{1}, …, S_{n} ∈ \overline{rel}(V, sh) such that S = ⋃_{i=1}^{n} S_{i}, which is equivalent to S ∈ \overline{rel}(V, sh)^{⋆}.

The auxiliary function rel possesses a weaker property.

Lemma 20 For each V ∈ ℘_{f}(Vars) and sh ∈ SH we have

rel(V, sh^{⋆}) ⊇ rel(V, sh)^{⋆}.

Proof Let S ∈ SG. Then S ∈ rel(V, sh)^{⋆} means that there exist S_{1}, …, S_{n} ∈ sh such that S_{i} ∩ V ≠ ∅, for each i = 1, …, n, and S = ⋃_{i=1}^{n} S_{i}. Thus S ∩ V ≠ ∅ and S ∈ rel(V, sh^{⋆}). Hence, rel(V, sh^{⋆}) ⊇ rel(V, sh)^{⋆}.

Lemma 21 For each V ∈ ℘_{f}(Vars), sh_{1}, sh_{2} ∈ SH , and S ∈ ℘_{f}(Vars) we have

S ∈ rel(V, sh_{1} ∪ sh_{2})^{⋆} ∪ {∅} ⟺ ∃S_{1} ∈ rel(V, sh_{1})^{⋆} ∪ {∅} . ∃S_{2} ∈ rel(V, sh_{2})^{⋆} ∪ {∅} . S = S_{1} ∪ S_{2}.

Proof If S = ∅ the statement is trivial.

Suppose S ∈ rel(V, sh_{1} ∪ sh_{2})^{⋆}. Then, for some n ∈ ℕ, there exists n sets R_{1}, …, R_{n} ∈ (sh_{1} ∪ sh_{2}) such that R_{i} ∩ V ≠ ∅ for each i = 1, …, n, and S = ⋃_{i=1}^{n} R_{i}. Suppose S_{j} = ⋃{ R_{i} ∈ sh_{j} | 1 ≤ i ≤ n } for j = 1, 2. Thus we have S_{1} ∈ rel(V, sh_{1})^{⋆} ∪ {∅}, S_{2} ∈ rel(V, sh_{2})^{⋆} ∪ {∅}, and S = S_{1} ∪ S_{2}.

Suppose

∃S_{1} ∈ rel(V, sh_{1})^{⋆} ∪ {∅} . ∃S_{2} ∈ rel(V, sh_{2})^{⋆} ∪ {∅} . S = S_{1} ∪ S_{2},

with S_{1} and S_{2} not both empty. Then, for some m ≥ 0 and n ≥ 0, there exist R_{1}, …, R_{m} ∈ rel(V, sh_{1}) and T_{1}, …, T_{n} ∈ rel(V, sh_{2}) such that S_{1} = ⋃_{i=1}^{m} R_{i} and S_{2} = ⋃_{i=1}^{n} T_{i}. Then R_{1}, …, R_{m}, T_{1}, …, T_{n} ∈ rel(V, sh_{1} ∪ sh_{2}) and

S = (⋃_{i=1}^{m} R_{i}) ∪ (⋃_{i=1}^{n} T_{i}).

Thus S ∈ rel(V, sh_{1} ∪ sh_{2})^{⋆}.

Lemma 22 For each V_{1}, V_{2} ∈ ℘_{f}(Vars) and sh ∈ SH we have

rel(V_{1}, \overline{rel}(V_{2}, sh)) = \overline{rel}(V_{2}, rel(V_{1}, sh)).

Proof Suppose S ∈ SG. Then S ∈ rel(V_{1}, \overline{rel}(V_{2}, sh)) means S ∩ V_{1} ≠ ∅ and S ∩ V_{2} = ∅. Similarly, S ∈ \overline{rel}(V_{2}, rel(V_{1}, sh)) means that S ∩ V_{2} = ∅ and S ∩ V_{1} ≠ ∅.

Lemma 23 For each sh_{1}, sh_{2} ∈ SH , we have

bin(sh_{1}, sh_{2})^{⋆} = bin(sh_{1}^{⋆}, sh_{2}^{⋆}).

Proof Suppose S ∈ SG. Then S ∈ bin(sh_{1}, sh_{2})^{⋆} means that, for some n ∈ ℕ, there exist sets R_{1}, …, R_{n} ∈ sh_{1} and T_{1}, …, T_{n} ∈ sh_{2} such that S = (R_{1}∪T_{1})∪⋯∪(R_{n}∪T_{n}). Thus S = (R_{1} ∪ ⋯ ∪ R_{n}) ∪ (T_{1} ∪ ⋯ ∪ T_{n}). However R_{1} ∪ ⋯ ∪ R_{n} ∈ sh_{1}^{⋆} and T_{1} ∪ ⋯ ∪ T_{n} ∈ sh_{2}^{⋆}. Thus S ∈ bin(sh_{1}^{⋆}, sh_{2}^{⋆}).

On the other hand, S ∈ bin(sh_{1}^{⋆}, sh_{2}^{⋆}) means that S = R ∪ T where, for some k, l ∈ ℕ, R_{1}, …, R_{k} ∈ sh_{1}, and T_{1}, …, T_{l} ∈ sh_{2}, we have R = R_{1} ∪ ⋯ ∪ R_{k} and T = T_{1} ∪⋯∪T_{l}. Let n be the maximum of {k, l} and suppose that, for each i, j ∈ ℕ where k + 1 ≤ i ≤ n and l + 1 ≤ j ≤ n, we define R_{i} =^{def} R_{k} and T_{j} =^{def} T_{l}. Then, S = (R_{1} ∪ T_{1}) ∪ ⋯ ∪ (R_{n} ∪ T_{n}). However, for 1 ≤ i ≤ n, R_{i} ∪ T_{i} ∈ bin(sh_{1}, sh_{2}). Thus S ∈ bin(sh_{1}, sh_{2})^{⋆}.

Proof of Theorem 7. We let R, S, T, and U (possibly subscripted) denote elements of sh^{⋆}. The subscripts reflect certain properties of the sets. In particular, subscripts x, r, xr, y, t, yt indicate sets of variables that definitely have a variable in common with the subscripted set. For example, R_{x} is a set in sh^{⋆} that has a common element with v_{x} and T_{xt} is a set in sh^{⋆} that has common elements with v_{x} and v_{t}. In contrast, the subscript ‘−’ indicates that the subscripted set does not share with one of the sets v_{xr} or v_{yt}. Of course, in the proof, each set is formally defined as needed.

Suppose that

S ∈ amgu(amgu(sh, x ↦ r), y ↦ t).

We will show that

S ∈ amgu(amgu(sh, y ↦ t), x ↦ r).

The converse then holds by simply exchanging x and y, and r and t.

There are two cases due to the two components of the definition of amgu in Eq. (25).

Case 1. Assume

S ∈ \overline{rel}(v_{yt}, amgu(sh, x ↦ r)).

Then S ∈ amgu(sh, x ↦ r) and S ∩ v_{yt} = ∅. Again there are two possibilities.

Subcase 1a. Suppose first that

S ∈ \overline{rel}(v_{xr}, sh).

Thus S ∈ sh, and, since in this case we have S ∩ v_{yt} = ∅,

S ∈ \overline{rel}(v_{yt}, sh).

The alternative definition of amgu, (25), implies \overline{rel}(v_{yt}, sh) ⊆ amgu(sh, y ↦ t) and thus we have also

S ∈ amgu(sh, y ↦ t).

38 P. M. Hill, R. Bagnara and E. Zaffanella Now, since the hypothesis of this subcase implies S ∩ v_{xr} = ∅, we obtain

S ∈ \overline{rel}(v_{xr}, amgu(sh, y ↦ t)).

Hence, again by (25), we can conclude that

S ∈ amgu(amgu(sh, y ↦ t), x ↦ r).

Subcase 1b. Suppose now that

S ∈ bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆}).

Then, there exist S_{x}, S_{r} ∈ SG such that S = S_{x} ∪ S_{r}, where

S_{x} ∈ rel(v_{x}, sh)^{⋆},  S_{r} ∈ rel(v_{r}, sh)^{⋆}.

By the hypothesis for this case we have S ∩ v_{yt} = ∅ and thus S_{x} ∩ v_{yt} = ∅ and S_{r} ∩ v_{yt} = ∅. This allows to state that

S_{x} ∈ \overline{rel}(v_{yt}, rel(v_{x}, sh)^{⋆}),  S_{r} ∈ \overline{rel}(v_{yt}, rel(v_{r}, sh)^{⋆}),

and hence, by Lemma 19,

S_{x} ∈ \overline{rel}(v_{yt}, rel(v_{x}, sh))^{⋆},  S_{r} ∈ \overline{rel}(v_{yt}, rel(v_{r}, sh))^{⋆},

Thus, by Lemma 22,

S_{x} ∈ rel(v_{x}, \overline{rel}(v_{yt}, sh))^{⋆},  S_{r} ∈ rel(v_{r}, \overline{rel}(v_{yt}, sh))^{⋆},

so that, by (23), (24), and (25),

S_{x} ∈ rel(v_{x}, amgu(sh, y ↦ t))^{⋆},  S_{r} ∈ rel(v_{r}, amgu(sh, y ↦ t))^{⋆}.

Therefore,

S_{x} ∪ S_{r} ∈ bin(rel(v_{x}, amgu(sh, y ↦ t))^{⋆}, rel(v_{r}, amgu(sh, y ↦ t))^{⋆})

so that, as S_{x} ∪ S_{r} = S, it follows from (25) that

S ∈ amgu(amgu(sh, y ↦ t), x ↦ r).

Case 2. Assume

S ∈ bin(rel(v_{y}, amgu(sh, x ↦ r))^{⋆}, rel(v_{t}, amgu(sh, x ↦ r))^{⋆}).

Then there exist S_{y}, S_{t} ∈ SG such that

S = S_{y} ∪ S_{t}  (61)

where

S_{y} ∈ rel(v_{y}, amgu(sh, x ↦ r))^{⋆},
S_{t} ∈ rel(v_{t}, amgu(sh, x ↦ r))^{⋆}.

(62)

Soundness, Idempotence and Commutativity of Set-Sharing 39

Then, by Lemma 20,

S_{y} ∩ v_{y} ≠ ∅, S_{t} ∩ v_{t} ≠ ∅. (63)

By (25) and Lemma 21, there exist R_{−}, R_{xr}, T_{−}, and T_{xr} such that

S_{y} = R_{−} ∪ R_{xr}, S_{t} = T_{−} ∪ T_{xr} (64)

where

R_{−} ∈ rel(v_{y}, \overline{rel}(v_{xr}, sh))^{⋆} ∪ \{∅\},
R_{xr} ∈ rel(v_{y}, bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆}))^{⋆} ∪ {∅},
T_{−} ∈ rel(v_{t}, \overline{rel}(v_{xr}, sh))^{⋆} ∪ \{∅\},
T_{xr} ∈ rel(v_{t}, bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆}))^{⋆} ∪ {∅}.

(65)

Then, by Lemmas 22 and 19,

R_{−} ∈ \overline{rel}(v_{xr}, rel(v_{y}, sh)^{⋆}) ∪ \{∅\},
T_{−} ∈ \overline{rel}(v_{xr}, rel(v_{t}, sh)^{⋆}) ∪ \{∅\}. (66)

Also, using Lemmas 20, 23, and then the idempotence of (·)^{⋆},

R_{xr} ∈ rel(v_{y}, bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆})) ∪ {∅},
T_{xr} ∈ rel(v_{t}, bin(rel(v_{x}, sh)^{⋆}, rel(v_{r}, sh)^{⋆})) ∪ {∅}.

(67)

Subcase 2a. Suppose R_{xr} = T_{xr} = ∅. Then, by (64),

S_{y} = R_{−}, S_{t} = T_{−}.  (68)

By (63), R_{−}, T_{−} ≠ ∅ and hence, using (66),

R_{−} ∪ T_{−} ∈ bin(rel(v_{y}, sh)^{⋆}, rel(v_{t}, sh)^{⋆}),

so that, by (25),

R_{−} ∪ T_{−} ∈ amgu(sh, y ↦ t).

Also, it follows from (66) that R_{−} ∩ v_{xr} = ∅ and T_{−} ∩ v_{xr} = ∅, so that

R_{−} ∪ T_{−} ∈ \overline{rel}(v_{xr}, amgu(sh, y ↦ t)).

However, by (61) and (68), S = R_{−} ∪ T_{−} so that, by (25),

S ∈ amgu(amgu(sh, y ↦ t), x ↦ r).

Subcase 2b. Suppose R_{xr} ∪ T_{xr} ≠ ∅. Then, by (67),

(R_{xr} ∪ T_{xr}) ∩ v_{yt} ≠ ∅.  (69)

The proof of this subcase is in two parts. In the first part we divide R_{xr} and T_{xr} into a number of subsets. In the second part, these subsets will be reassembled so as to prove the required result.

First, by (67), there exist R_{x}, R_{r}, T_{x}, T_{r} ∈ ℘_{f}(Vars) such that

R_{xr} = R_{x} ∪ R_{r},  T_{xr} = T_{x} ∪ T_{r},  (70)

where either R_{x} = R_{r} = ∅ or

R_{x} ∈ rel(v_{x}, sh)^{⋆},  R_{r} ∈ rel(v_{r}, sh)^{⋆},

and either T_{x} = T_{r} = ∅ or

T_{x} ∈ rel(v_{x}, sh)^{⋆},  T_{r} ∈ rel(v_{r}, sh)^{⋆}.

Thus, if either R_{x} ∪ T_{x} = ∅ or R_{r} ∪ T_{r} = ∅, it follows that

R_{xr} ∪ T_{xr} = (R_{x} ∪ R_{r}) ∪ (T_{x} ∪ T_{r}) = ∅.

However, by (69), R_{xr} ∪ T_{xr} ≠ ∅, so that we have

R_{x} ∪ T_{x} ≠ ∅,  R_{r} ∪ T_{r} ≠ ∅.  (71)

We now subdivide the sets R_{x}, T_{x}, R_{r}, and T_{r} further. First note that

sh = \overline{rel}(v_{yt}, sh) ∪ rel(v_{y}, sh) ∪ \overline{rel}(v_{y}, rel(v_{t}, sh)),
sh = \overline{rel}(v_{yt}, sh) ∪ \overline{rel}(v_{t}, rel(v_{y}, sh)) ∪ rel(v_{t}, sh).

Hence, by Lemma 21, sets R_{x−}, R_{xy}, R_{xt}, R_{r−}, R_{ry}, R_{rt}, T_{x−}, T_{xy}, T_{xt}, T_{r−}, T_{ry}, T_{rt} ∈ ℘_{f}(Vars) exist such that

\begin{aligned}R_{x} & = R_{x−} ∪ R_{xy} ∪ R_{xt}, \\ R_{r} & = R_{r−} ∪ R_{ry} ∪ R_{rt}, \end{aligned}  \begin{aligned}T_{x} & = T_{x−} ∪ T_{xy} ∪ T_{xt}, \\ T_{r} & = T_{r−} ∪ T_{ry} ∪ T_{rt}, \end{aligned}  (72)

where

R_{x−}, T_{x−} ∈ rel(v_{x}, \overline{rel}(v_{yt}, sh))^{⋆} ∪ \{∅\},
R_{r−}, T_{r−} ∈ rel(v_{r}, \overline{rel}(v_{yt}, sh))^{⋆} ∪ \{∅\},

(73)

and

R_{xy}, T_{xy} ∈ rel(v_{x}, rel(v_{y}, sh))^{⋆} ∪ {∅},
R_{ry}, T_{ry} ∈ rel(v_{r}, rel(v_{y}, sh))^{⋆} ∪ {∅},
R_{xt}, T_{xt} ∈ rel(v_{x}, rel(v_{t}, sh))^{⋆} ∪ {∅},
R_{rt}, T_{rt} ∈ rel(v_{r}, rel(v_{t}, sh))^{⋆} ∪ {∅},

(74)

and also

\begin{aligned}(R_{x} \ R_{xy}) ∩ v_{y} & = ∅, \\ (R_{r} \ R_{ry}) ∩ v_{y} & = ∅, \end{aligned}  \begin{aligned}(T_{x} \ T_{xt}) ∩ v_{t} & = ∅, \\ (T_{r} \ T_{rt}) ∩ v_{t} & = ∅. \end{aligned}  (75)

We note a few simple but useful consequences of these definitions. First, it follows from (73) using (23), (24), and (25), that

R_{x−}, T_{x−} ∈ rel(v_{x}, amgu(sh, y ↦ t))^{⋆} ∪ {∅},
R_{r−}, T_{r−} ∈ rel(v_{r}, amgu(sh, y ↦ t))^{⋆} ∪ {∅}.

(76)

Secondly, using (73) with Lemma 20, we have

R_{x−}, T_{x−}, R_{r−}, T_{r−} ∈ \overline{rel}(v_{yt}, sh)^{⋆} ∪ \{∅\},  (77)

and then, using this with (69), (70), and (72), it follows that

R_{xy} ∪ T_{xy} ∪ R_{ry} ∪ T_{ry} ∪ R_{xt} ∪ T_{xt} ∪ R_{rt} ∪ T_{rt} ≠ ∅.  (78)

In the second part of the proof for this subcase, the component subsets of S are reassembled in an order that proves the required result. First, let

\begin{matrix}U_{y} & =^{def} R_{−} ∪ R_{xy} ∪ R_{ry} ∪ T_{xy} ∪ T_{ry}, \\ U_{t} & =^{def} T_{−} ∪ R_{xt} ∪ R_{rt} ∪ T_{xt} ∪ T_{rt}, \end{matrix}  (79)

and

U =^{def} U_{y} ∪ U_{t}.  (80)

By relations (65) and (74) (with Lemma 20), each component set in the definition of U_{y} is in rel(v_{y}, sh)^{⋆} ∪ {∅} and each component set in the definition of U_{t} is in rel(v_{t}, sh)^{⋆} ∪ {∅}. Thus, by the definition of (·)^{⋆},

U_{y} ∈ rel(v_{y}, sh)^{⋆} ∪ {∅},
U_{t} ∈ rel(v_{t}, sh)^{⋆} ∪ {∅}.  (81)

By (70) and (75) we have

(R_{xr} \ (R_{xy} ∪ R_{ry})) ∩ v_{y} = ∅

and hence, by (64), we have also that

(S_{y} \ (R_{xy} ∪ R_{ry} ∪ R_{−})) ∩ v_{y} = ∅.

By (63), S_{y} ∩ v_{y} ≠ ∅. Thus, R_{xy} ∪ R_{ry} ∪ R_{−} ≠ ∅ and, as a consequence of (79), U_{y} ≠ ∅. For similar reasons, U_{t} ≠ ∅. Hence, by (80),

U ∈ bin(rel(v_{y}, sh)^{⋆}, rel(v_{t}, sh)^{⋆}),

and therefore, using (25), it follows that

U ∈ amgu(sh, y ↦ t).  (82)

Now, by (78), at least one of the following two inequalities holds:

\begin{matrix}R_{xy} ∪ T_{xy} ∪ R_{xt} ∪ T_{xt} & ≠ ∅, \\ R_{ry} ∪ T_{ry} ∪ R_{rt} ∪ T_{rt} & ≠ ∅. \end{matrix}  (83)

R_{xy} ∪ T_{xy} ∪ R_{xt} ∪ T_{xt} = ∅ and R_{ry} ∪ T_{ry} ∪ R_{rt} ∪ T_{rt} ≠ ∅. Then, using (71) and (72) with the first of these,

R_{x−} ∪ T_{x−} ≠ ∅.

Also, using (74) with the second, we have (R_{ry} ∪ R_{rt} ∪ T_{ry} ∪ T_{rt}) ∩ v_{r} ≠ ∅ and therefore it follows from (79) and (80), that

U ∩ v_{r} ≠ ∅.

Hence, by (76) and (82),

R_{x−} ∪ T_{x−} ∈ rel(v_{x}, amgu(sh, y ↦ t))^{⋆},
U ∪ R_{r−} ∪ T_{r−} ∈ rel(v_{r}, amgu(sh, y ↦ t))^{⋆}.

(84)

Similarly, assuming R_{xy} ∪ T_{xy} ∪ R_{xt} ∪ T_{xt} ≠ ∅ and R_{ry} ∪ T_{ry} ∪ R_{rt} ∪ T_{rt} = ∅ it follows that

R_{r−} ∪ T_{r−} ∈ rel(v_{r}, amgu(sh, y ↦ t))^{⋆},
R_{x−} ∪ T_{x−} ∪ U ∈ rel(v_{x}, amgu(sh, y ↦ t))^{⋆}.

(85)

Finally, assuming R_{xy} ∪T_{xy} ∪R_{xt} ∪T_{xt} ≠ ∅ and R_{ry} ∪T_{ry} ∪R_{rt} ∪T_{rt} ≠ ∅ it follows from (74) that U ∩ v_{x} ≠ ∅ and U ∩ v_{r} ≠ ∅, and hence

R_{x−} ∪ T_{x−} ∪ U ∈ rel(v_{x}, amgu(sh, y ↦ t))^{⋆},
U ∪ R_{r−} ∪ T_{r−} ∈ rel(v_{r}, amgu(sh, y ↦ t))^{⋆}.

(86)

Thus, as one of the inequalities in (83) holds, one of (84), (85) or (86) holds so that

R_{x−} ∪ T_{x−} ∪ U ∪ R_{r−} ∪ T_{r−}

∈ bin(rel(v_{x}, amgu(sh, y ↦ t))^{⋆}, rel(v_{r}, amgu(sh, y ↦ t))^{⋆}).

However, since

S = R_{x−} ∪ T_{x−} ∪ U ∪ R_{r−} ∪ T_{r−},

we have

S ∈ bin(rel(v_{x}, amgu(sh, y ↦ t))^{⋆}, rel(v_{r}, amgu(sh, y ↦ t))^{⋆}).

Hence, by (25),

S ∈ amgu(amgu(sh, y ↦ t), x ↦ r).

6.5 Proofs of Results for Sharing Domains

We prove all the results in this section by induction on the cardinality of a substitution ν. For each result, the proof is obvious if ν is empty or does not unify. Thus, in the following proofs, we assume that ν unifies and is non-empty. We suppose that (x ↦ r) ∈ ν and let ν′ =^{def} ν \ {x ↦ r}.

Proof of Lemma 18. We have

aunify(Amgu((sh, U), y ↦ t), ν)
= aunify(Amgu(Amgu((sh, U), y ↦ t), x ↦ r), ν′) [Def. 11]
= aunify(Amgu(Amgu((sh, U), x ↦ r), y ↦ t), ν′) [Cor. 3]
= Amgu(aunify(Amgu((sh, U), x ↦ r), ν′), y ↦ t) [induction]
= Amgu(aunify((sh, U), ν), y ↦ t)  [Def. 11].

Proof of Theorem 8. Let μ′ be a most general solution for (ν′ ∪ σ). Then

α(σ, U) ⪯_{SS} (sh, U)
⟹ α(μ′, U ∪ vars(ν′))
⪯_{SS} aunify((sh, U), ν′)  [induction]
⟹ α(μ, U ∪ vars(ν))
⪯_{SS} Amgu(aunify((sh, U), ν′), x ↦ r) [Cor. 1]
⟹ α(μ, U ∪ vars(ν))
⪯_{SS} aunify(Amgu((sh, U), x ↦ r), ν′) [Lem. 18]
⟹ α(μ, U ∪ vars(ν))
⪯_{SS} aunify((sh, U), ν)  [Def. 11].

Proof of Theorem 9. We have

aunify(aunify((sh, U), ν), ν)

= aunify(Amgu(aunify(Amgu((sh, U), x ↦ r), ν′), x ↦ r), ν′) [Def. 11]
= aunify(aunify(Amgu(Amgu((sh, U), x ↦ r), x ↦ r), ν′), ν′) [Lem. 18]
= aunify(Amgu(Amgu((sh, U), x ↦ r), x ↦ r), ν′)  [induction]
= aunify(Amgu((sh, U), x ↦ r), ν′)  [Cor. 2]
= aunify((sh, U), ν)  [Def. 11].

Proof of Theorem 10. In this theorem the induction is on the set of equations ν_{1}. The comments at the start of this section apply therefore to ν_{1} instead of ν and thus we let ν′_{1} =^{def} ν_{1}\{x ↦ r} so that we have

aunify(aunify((sh, U), ν_{1}), ν_{2})
= aunify(aunify(Amgu((sh, U), x ↦ r), ν′_{1}), ν_{2})  [Def. 11]
= aunify(aunify(Amgu((sh, U), x ↦ r), ν_{2}), ν′_{1})  [induction]
= aunify(Amgu(aunify((sh, U), ν_{2}), x ↦ r), ν′_{1})  [Lem. 18]
= aunify(aunify((sh, U), ν_{2}), ν_{1})  [Def. 11].

7 Conclusion

The Sharing domain, which was defined in (Jacobs & Langen, 1989; Langen, 1990), is considered to be the principle abstract domain for sharing analysis of logic programs in both practical work and theoretical study. For many years, this domain was accepted and implemented as it was. However, in (Bagnara et al., 1997), we proved that Sharing is, in fact, redundant for pair-sharing and we identified the weakest abstraction of Sharing that can capture pair-sharing with the same degree of precision. One notable advantage of this abstraction is that the costly star-union operator is no longer necessary. The question of whether the abstract operations for Sharing were complete or optimal was studied by Cortesi and Filé (Cortesi & Filé, 1999). Here it is proved that although the ‘⊔’ and projection operations are complete (and hence, optimal), aunify is optimal but not complete. The problem of scalability of Sharing, still retaining as much precision as possible, was tackled in (Zaffanella et al., 1999b), where a family of widenings is presented that allow the desired goal to be achieved. In (Zaffanella et al., 1999a), the decomposition of Sharing and its non-redundant counterpart via complementation is studied. This shows the close relationship between these domains and PS (the usual domain for pair-sharing) and Def (the domain of definite Boolean functions). Many sharing analysis techniques and/or enhancements have been advocated to have potential for improving the precision of the sharing information over and above that obtainable using the classical combination of Sharing with the usual domains for linearity and freeness. Moreover, these enhancements had been circulating for years without an adequate supporting experimental evaluation. Thus we investigated these techniques to see if and by how much they could improve precision. Using the China analyzer (Bagnara, 1997) for the experimental part of the work, we discovered that, apart from the enhancement that upgrades Sharing with structural information, these techniques had little impact on precision (Bagnara et al., 2000a).

In this paper, we have defined a new abstraction function mapping a set of substitutions in rational solved form into their corresponding sharing abstraction. The new function is a generalisation of the classical abstraction function of (Jacobs & Langen, 1989), which was defined for idempotent substitutions only. Using our new abstraction function, we have proved the soundness of the classical abstract unification operator aunify. Other contributions of our work are the formal proofs of the commutativity and idempotence of the aunify operator on the Sharing domain. Even if commutativity was a known property, the corresponding proof in (Langen, 1990) was not satisfactory. As far as idempotence is concerned, our result differs from that given in (Langen, 1990), which was based on a composite abstract unification operator performing also the renaming of variables. It is our opinion that our main result, the soundness of the aunify operator, is really valuable as it allows for the safe application of sharing analysis based on Sharing to any constraint logic language supporting syntactic term structures, based on either finite trees or rational trees. This happens because our result does not rely on the presence (or even the absence) of the occur-check in the concrete unification procedure implemented by the analysed language. Furthermore, as the groundness domain Def is included in Sharing, our main soundness result also shows that Def is sound for non-idempotent substitutions.

From a technical point of view, we have introduced a new class of concrete substitutions based on the notion of variable-idempotence, generalizing the classical concept of idempotence. We have shown that any substitution is equivalent to a variable-idempotent one, providing a finite sequence of transformations for its construction. This result assumes an arbitrary equality theory and is therefore applicable to the study of any abstract property which is preserved by logical equivalence. Our application of this idea to the study of the soundness of abstract unification for Sharing has shown that it is particularly suitable for data-flow analyzers where the corresponding abstraction function only depends on the set of variables occurring in a term. However, we believe that this concept can be usefully exploited in a more general context. Possible applications include the proofs of optimality and completeness of abstract operators with respect to the corresponding concrete operators defined on a domain of substitutions in rational solved form.

References

Bagnara, R. 1997 (Mar.). Data-flow analysis for constraint logic-based languages. Ph.D. thesis, Dipartimento di Informatica, Università di Pisa, Corso Italia 40, I-56125 Pisa, Italy. Printed as Report TD-1/97.

Bagnara, R., Hill, P. M., & Zaffanella, E. (1997). Set-sharing is redundant for pairsharing. Pages 53–67 of: Van Hentenryck, P. (ed), Static analysis: Proceedings of the 4th international symposium. Lecture Notes in Computer Science, vol. 1302. Paris, France: Springer-Verlag, Berlin.

Bagnara, R., Zaffanella, E., & Hill, P. M. (2000a). Enhanced sharing analysis techniques: A comprehensive evaluation. Gabbrielli, M., & Pfenning, F. (eds), Proceedings of the acm sigplan 2nd international conference on principles and practice of declarative programming. Lecture Notes in Computer Science. Montreal, Canada: Springer-Verlag, Berlin. To appear.

Bagnara, R., Hill, P. M., & Zaffanella, E. (2000b). Set-sharing is redundant for pair-

sharing. Theoretical computer science. To appear. Bruynooghe, M., & Codish, M. (1993). Freeness, sharing, linearity and correctness —

All at once. Pages 153–164 of: Cousot, P., Falaschi, M., Filé, G., & Rauzy, A. (eds), Static analysis, proceedings of the third international workshop. Lecture Notes in Com-

46 P. M. Hill, R. Bagnara and E. Zaffanella

puter Science, vol. 724. Padova, Italy: Springer-Verlag, Berlin. An extended version is available as Technical Report CW 179, Department of Computer Science, K.U. Leuven, September 1993.

Clark, K. L. (1978). Negation as failure. Pages 293–322 of: Gallaire, H., & Minker, J.

(eds), Logic and databases. Toulouse, France: Plenum Press. Codish, M., Dams, D., Filé, G., & Bruynooghe, M. (1993). Freeness analysis for logic pro-

grams — and correctness? Pages 116–131 of: Warren, D. S. (ed), Logic programming: Proceedings of the tenth international conference on logic programming. MIT Press Series in Logic Programming. Budapest, Hungary: The MIT Press. An extended version is available as Technical Report CW 161, Department of Computer Science, K.U. Leuven, December 1992.

Colmerauer, A. (1982). Prolog and infinite trees. Pages 231–251 of: Clark, K. L., & Tärnlund, S. Å. (eds), Logic programming, apic studies in data processing, vol. 16. Academic Press, New York.

Colmerauer, A. (1984). Equations and inequations on finite and infinite trees. Pages 85– 99 of: Proceedings of the international conference on fifth generation computer systems (fgcs’84). Tokyo, Japan: ICOT.

Cortesi, A., & Filé, G. (1999). Sharing is optimal. Journal of logic programming, 38(3),

371–386. Hill, P. M., Bagnara, R., & Zaffanella, E. (1998). The correctness of set-sharing. Pages 99–

114 of: Levi, G. (ed), Static analysis: Proceedings of the 5th international symposium. Lecture Notes in Computer Science, vol. 1503. Pisa, Italy: Springer-Verlag, Berlin.

ISO/IEC. (1995). ISO/IEC 13211-1: 1995 Information technology — Programming lan-

guages — Prolog — Part 1: General core. International Standard Organization. Jacobs, D., & Langen, A. (1989). Accurate and efficient approximation of variable aliasing

in logic programs. Pages 154–165 of: Lusk, E. L., & Overbeek, R. A. (eds), Logic programming: Proceedings of the north american conference. MIT Press Series in Logic Programming. Cleveland, Ohio, USA: The MIT Press.

Jacobs, D., & Langen, A. (1992). Static analysis of logic programs for independent AND

parallelism. Journal of logic programming, 13(2&3), 291–314. Jaffar, J., Lassez, J-L., & Maher, M. J. (1987). Prolog-II as an instance of the logic

programming scheme. Pages 275–299 of: Wirsing, M. (ed), Formal descriptions of programming concepts III. North-Holland.

Keisu, T. 1994 (May). Tree constraints. Ph.D. thesis, The Royal Institute of Technology,

Stockholm, Sweden. Also available in the SICS Dissertation Series: SICS/D–16–SE. King, A. (1994). A synergistic analysis for sharing and groundness which traces linearity.

Pages 363–378 of: Sannella, D. (ed), Proceedings of the fifth european symposium on programming. Lecture Notes in Computer Science, vol. 788. Edinburgh, UK: Springer-Verlag, Berlin.

King, A. (2000). Pair-sharing over rational trees. Journal of logic programming. King, A., & Soper, P. (1994). Depth-k sharing and freeness. Pages 553–568 of: Van Henten-

ryck, P. (ed), Logic programming: Proceedings of the eleventh international conference on logic programming. MIT Press Series in Logic Programming. Santa Margherita Ligure, Italy: The MIT Press.

Langen, A. (1990). Advanced techniques for approximating variable aliasing in logic programs. Ph.D. thesis, Computer Science Department, University of Southern California. Printed as Report TR 91-05.

Maher, M. J. (1988). Complete axiomatizations of the algebras of finite, rational and infinite trees. Pages 348–357 of: Proceedings, third annual symposium on logic in computer science. IEEE Computer Society, Edinburgh, Scotland.

Soundness, Idempotence and Commutativity of Set-Sharing 47

Martelli, A., & Montanari, U. (1982). An efficient unification algorithm. Acm transactions

on programming languages and systems, 4(2), 258–282. Muthukumar, K., & Hermenegildo, M. (1992). Compile-time derivation of variable depen-

dency using abstract interpretation. Journal of logic programming, 13(2&3), 315–347. Robinson, J. A. (1965). A machine-oriented logic based on the resolution principle. Journal

of the acm, 12(1), 23–41. Zaffanella, E., Hill, P. M., & Bagnara, R. (1999a). Decomposing non-redundant sharing

by complementation. Pages 69–84 of: Cortesi, A., & Filé, G. (eds), Static analysis: Proceedings of the 6th international symposium. Lecture Notes in Computer Science, vol. 1694. Venice, Italy: Springer-Verlag, Berlin.

Zaffanella, E., Bagnara, R., & Hill, P. M. (1999b). Widening Sharing. Pages 414–431 of: Nadathur, G. (ed), Principles and practice of declarative programming. Lecture Notes in Computer Science, vol. 1702. Paris, France: Springer-Verlag, Berlin.