A fine-grained Concurrent Completion Procedure

40

Transcript of A fine-grained Concurrent Completion Procedure

A �ne-grained Concurrent Completion ProcedureClaude Kirchner Christopher Lynch Christelle Schar�INRIA Lorraine & CRIN,615, rue du Jardin Botanique, BP 101,54602 Villers-l�es-Nancy Cedex, France.E-mail: fClaude.Kirchner, Christopher.Lynch, Christelle.Schar�[email protected]://www.loria.fr/equipe/protheo.htmlAbstractWe present a concurrent Completion procedure based on the use of a SOUR graph as data structure.The procedure has the following characteristics. It is asynchronous, there is no need for a global memoryor global control, equations are stored in a SOUR graph with maximal structure sharing, and eachvertex is a process, representing a term. Therefore, the parallelism is at the term level. Each edge is acommunication link, representing a (subterm, ordering, uni�cation or rewrite) relation between terms.Completion is performed on the graph as local graph transformations by cooperation between processes.We show that this concurrent Completion procedure is sound and complete with respect to the sequentialone, provided that the information is locally time stamped in order to detect out of date information.1 IntroductionParallelization is an attractive way for improving e�ciency of automated deduction, and the main approachesare surveyed in [BH94] and [SS93]. We present in this paper a new approach to term rewriting completionwhich is based on �ne grain concurrency, and which relies on a novel approach to completion.The resolution (and paramodulation) inference systems are theorem proving procedures for �rst-orderlogic (with equality) that can run exponentially long for subclasses which have polynomial time decisionprocedures, as in the case of the Knuth-Bendix ground completion procedure. D. Kozen [Koz77] developeda method based on congruence closure to solve word problem in ground equational theories. J. Gallier,P. Narandran, D. Plaisted, S. Raatz [GNP+93] extend Kozen's techniques to generate convergent equationalsystem equivalent to a ground set of equations. W. Snyder improves the running time of this algorithm tonlog(n) [Sny93]. D. Plaisted and A. Sattler-Klein [PSK96] show that, with a particular strategy and withstructure sharing, Knuth-Bendix completion runs in polynomial time for a ground set of equations. RecentlyC. Lynch has shown [Lyn95] that a special form of paramodulation which does not need to copy terms orliterals runs in polynomial time in ground cases that include ground completion. This can be implemented inan elegant way using the notion of SOUR graph [LS95]. These graphs represent in a very convenient way astate of the completion, where all the basic ingredients (i.e. orientation, uni�cation and rewriting) are madeexplicit at the object level. This makes explicit the fundamental operations of completion. A SOUR graphhas its edges labelled by S when representing a subterm relation, by O when representing an orientation,by U when representing a uni�cation problem and by R when representing a rewrite rule. The nodes of thegraph are labelled by function symbols, and edges are labelled by constraints and renamings.The properties of SOUR graphs are useful to study the parallelization and implementation of automateddeduction on parallel distributed memory machines. There is no duplication of work since there is nocopying. There is also no need of a consistency check. The explicit representation of basic operations allowsa direct implementation of the inference rules as transition rules and thus to get completion as the result ofindependent (and asynchronous) operations as well as an easier way to describe and prove soundness and1

completeness of the graph transformations. This property is always desirable, but the increased complexityof concurrent processes makes it even more important.Thus this paper presents a new �ne-grained concurrent completion procedure based on the notion ofdistributed SOUR graphs and it is proved to be sound and complete, for simplicity in the case of groundcompletion, although everything can be extended to non-ground completion.We consider each node of the SOUR graph as a process and the edges as communication links betweenprocesses. Each process is in charge of detecting particular con�gurations corresponding to critical pairs,uni�cation problems or ordering of terms. A node acts only in response to a message, independently of theother nodes. The processes are thus completely asynchronous. When a successful con�guration is found,the corresponding operation is performed, typically directing a subterm or a rewrite edge from one node toanother. In the �rst design of the approach we thought that this was enough to ensure correctness of theprocess. But after investigations, we discovered that since all these detections and actions are performedasynchronously, we need to keep account of only the newest information arriving from a given node, in orderto ensure the global consistency of the SOUR graph. This is performed via the use of local time stamps, sothat the system still works asynchronously, but old information is ignored.The paper describes the principles of this approach and its current implementation on a network ofprocessors. We show that this implements ground completion using �ne-grain concurrency. This relies inparticular on an original parallelization of the detection of the satis�ability of uni�cation and LPO orientationconstraints, detection that runs concurrently with the standard completion process. Because it is �ne-grainedand completely asynchronous, our approach is quite di�erent from the PaReDuX work [BGK95] and theclause di�usion method [BH95] but it also allows backward contraction. It is also quite di�erent from thediscount approach [ADF95] or the work on Partheo [LS90]. Let us �nally emphasise that we think ourapproach quite promising since as opposed to the unsuccessful attempts to parallelize prolog on �ne-grainedarchitectures, it is backed by a very simple concept, SOUR graphs, no synchronization is needed, and eachprocess gets enough work because of the internalization of uni�cation and ordering constraint satis�ability.The paper is structured as follows. Assuming the reader familiar with term rewriting (see [DJ90]), wesummarize in section 2 the notion of SOUR graph. In section 3, we present the principle of concurrentcompletion on SOUR graphs. We show how critical pairs are detected, how uni�cation and LPO orderingconstraints are checked satis�able, why time stamps are needed and how they are used. We also show howto detect the termination of the completion process and we prove that this model of completion is soundand complete.The short version of this paper appeared in the proceedings of RTA'96 (Rewriting Techniques and Ap-plication) [KLS96].2 PreliminariesTo simplify our presentation of inference rules, we will present them for ground terms. We refer the readerto [LS95] to see how the de�nitions and the inference rules are lifted to non-ground terms.The symbol � is a binary symbol, written in in�x notation, representing semantic equality. Let EQ be aset of equations. We de�ne a function Sub so that Sub(EQ) is the set of subterms of EQ. If t = f(t1; � � � ; tk)with k � 0, then Sub(t) = ftg [S1�i�k Sub(ti). We de�ne Sub(s � t) = Sub(s) [ Sub(t) and Sub(EQ) =Seq2EQ Sub(eq).In this paper � will refer to the lexicographic path ordering (� in its strict version)which is a reductionorder total on ground terms. It is de�ned based on a total ordering > on the function symbols. Lets = f(s1; � � � ; sn) and t = g(t1; � � � ; tm). Then s � t if (i) there exists an i such that si � t, (ii) f > gand s � tj for all tj , or (iii) f = g and either s = t or there exists a k such that sk � tk, si = ti for alli < k and s � tj for all j > k. If u[s] is a ground term, and EQ is a set of ground equations, we writeu[s]) u[t] and say that u[s] rewrites in one step to u[t] if there is an equation s � t 2 EQ such that s � t.We write u0 �) un and say that u0 rewrites to un if there is a a set of terms fu1; � � � ; un�1g such that for alli, 1 � i � n, ui�1 ) ui. A ground set of equations is convergent if it is terminating and con uent.A SOUR graph is a compact dag representation of a set of equations. Let EQ be a set of equations. TheSOUR graph of EQ is the graph which has one node associated with each element of t 2 Sub(EQ), labelledwith the root symbol of t. For each element f(t1 � � � ; tk) 2 Sub(EQ), with k > 0, for each i, 1 � i � k, there2

is a directed edge called a subterm edge in the SOUR Graph from the node associated with f(t1; � � � ; tk) tothe node associated with ti labelled with i, its index. For each equation s � t 2 EQ with s � t, there is adirected edge called a rewrite edge from the node associated with s to the node associated with t.We de�ne a semantic function Term from the nodes of the graph to the set of terms. If v is a node inthe graph labelled with f such that arity(f) = k, then there are k subterms edges from v labelled 1; � � � ; kto nodes v1 � � � ; vk respectively. Then Term(v) = f(Term(v1); � � � ; T erm(vk)). We de�ne a function Rulefrom the rewrite edges in the graph to the set of equations. If e is a rewrite edge from v1 to v2, then Rule(e)is Term(v1) � Term(v2). Graph G represents fRule(e) j e is a rewrite edge in Gg.We also add other kinds of edges to the SOUR graph. Some terms have an undirected edge called auni�cation edge between them, including between a node and itself. For now, we assume these edges areplaced between every pair of nodes v1 and v2 such that Term(v1) = Term(v2). There is a directed edgecalled an orientation edge between some pairs of nodes v1 and v2 such that Term(v1) � Term(v2). Theseedges are used to perform inferences. The graph is called a SOUR graph because of Subterm, Orientation,Uni�cation and Rewrite edges.The inference rule that we are coding with SOUR Graphs in the ground case is the critical pair inferencerule. Critical Pair s � t u[s] � vu[t] � v if s � t and u[s] � vWe simulate the completion inference rules by searching for patterns (or con�gurations) in the graph andperforming a transformation of the graph whenever we �nd one. A transformation consists of removing asubterm or rewrite edge and adding a new subterm or rewrite edge. Afterwards, uni�cation and orientationedges are re-calculated. There are three graph transformations.The �rst transformation is called an SUR transformation. It consists of �nding a set of edges v1, v2, v3and v4 such that there is a subterm edge eS from v1 to v2, a uni�cation edge eU between v2 and v3, anda rewrite edge vR from v3 to v4. Then eS is removed, and a new subterm edge e is added from v1 to v4,labelled with the same index as eS (see Figure 1). This simulates the critical pair rule, because it uni�es asubterm of a term with the larger side of an equation and replaces it with the smaller side of the equation.Figure 1 shows a critical pair between f(a) � c and a � b.=>

U

v1 v4

RS

v2 v3

R

v3

U

v2

v1

=>

f

a b

RU

S

f

a b

RU

v4 c cS R R

SFigure 1: SUR transformation and an exampleThe second transformation is called an RUR transformation. It consists of �nding a set of edges v1, v2,v3 and v4, such that there is a rewrite edge eR1 from v1 to v2, a uni�cation edge eU between v1 and v3, anda rewrite edge vR2 from v3 to v4. Also Term(v2) � Term(v4). Then eR1 is removed, and a new rewrite edgee is added from v2 to v4 (see Figure 2). This simulates the critical pair rule, because it uni�es the larger sideof two equations and adds a new equation between the two smaller sides.The third transformation is called an RUR � rhs transformation. It consists of �nding a set of edgesv1, v2, v3 and v4, such that there is a rewrite edge eR1 from v1 to v2, a uni�cation edge eU between v2 andv3, and a rewrite edge vR2 from v3 to v4. Then eR1 is removed, and a new rewrite edge e is added from v1to v4 (see Figure 2). This simulates a simpli�cation of the smaller side of an equation, because is uni�esthe smaller side with the larger side of another equation and replaces it with the smaller side of the otherequation.The completeness result from [LS95] says that if a SOUR graph is created from a set of equations EQand the above transformations are performed in any order, until no longer possible, then the resulting SOURgraph represents a convergent system, logically equivalent to EQ.We describe brie y how this is lifted to the non-ground case, and refer the reader to [LS95] for moredetails. For the non-ground case, the initial SOUR graph is constructed in exactly the same way. However,3

v3

v4

R

Rv1

v2

U

=>

v3

v4

R

U

R =>

v2

v1

U

v3

v4

R

R

v1

v2

U

v3

v4

R

v1

v2

RFigure 2: RUR and RUR-rhs transformationthe transformations are handled di�erently. We simulate Basic Completion. Therefore, each inference isperformed by renaming the variables in one of the premises, and by applying a constraint to the conclusionof the inference, representing the uni�cation problem. In the SOUR graph, the new edge that is added to thegraph in a transformation is labelled with the constraint and renaming associated with the inference, whichis a combination of the constraints and renamings labelling the edges which caused the transformation to beperformed. Initial edges can be considered to have constraints and renamings which are trivial. As opposedto the ground case, each inference does not represent a simpli�cation. It is only possible to delete an edgewhen the inference represents a simpli�cation.Since edges are not deleted when new ones are added, a node represents a set of terms, instead of asingle term. The semantics of SOUR graphs must also be modi�ed to accommodate the constraints andrenamings on the edges. Each dag of subterm edges still represents a term. But the constraints on thedag must be conjoined with each other, and the renamings on the edges must be applied to everythingthat appears underneath it in the term. Also, instead of performing transformations among edges with auni�cation constraint of true, we now perform transformations where the uni�cations constraints must besatis�able, and the constraint representing the orientation is satis�able. These constraints are passed alongto to the new edge in a transformation, along with the constraints on the old edges.In summary, the algorithm for completion of SOUR graphs is the same in the non-ground case as in theground case, except for the fact that an old edge might not be deleted in a transformation, and the new edgeis labelled by a renaming inherited from the old edges, and a constraint inherited from the old edges andthe uni�cation constraint determined by the uni�cation problem. For simplicity, we present the completionprocedure in the ground case, but the algorithm for the non-ground case is the same, except that messageswill contain constraints and nodes will try to satisfy these constraints.3 Concurrent Completion using SOUR GraphsWe now present our concurrent method for performing completion using SOUR graphs. The set of equationsis represented as a SOUR graph. The number of vertices of the initial SOUR graph gives the number ofindependent children processes which will perform completion. A root process launches all these childrenprocesses. Completion is performed using edges as communication links. At the beginning of the concurrentcompletion process, the root process has knowledge of the whole SOUR graph. For each node, it launches aprocess. To each process is associated its identi�cation number called its tid. The preliminary informationthat is initially loaded by each process, is the symbol of the node and a dictionary containing for eachsymbol its arity and its place in the precedence. Then, for each node, uni�cation edges, subterm edges, andrewrite edges are sent in this order to the associated process using messages called INITU, INITS and INITRrespectively. These messages contain characteristics of an edge. The root process creates a uni�cation edgebetween every pair of nodes with the same symbol, with an initial value of false. One node adjacent toeach uni�cation edge is designated as being the node in charge of calculating the uni�cation constraint. AnINITU message is sent to the nodes on both ends of each uni�cation edge. The INITU message containsthe tid of the process at the other end of the edge, the initial false uni�cation constraint, a noti�cationwhether that node is in charge of calculating the uni�cation problem and an another noti�cation whetherthat node needs to calculate the uni�cation problem. INITS is sent to each node adjacent to a subtermedge. It contains the tid and the symbol of the process at the other end of the edge, a boolean indicating ifthe edge is incoming or outgoing, and the index of the subterm edge. INITR is sent to each node adjacentto a rewrite edge. It contains the tid, the symbol of the process at the other end of the edge and a boolean4

indicating if the rewrite edge is incoming or outgoing. We call this phase the Initialization phase.The set of information stored in a node is called its state. It is composed of its symbol symb, its dictionarydico order arity and its uni�cation edges, its outgoing and incoming subterm edges and its outgoing and in-coming rewrite edges, which are saved in data structures. Uni�cation edges are saved in a list of uni�cationedges U list. Initially, the U list of a process contains the unary cycle between the node and itself, whichforms a uni�cation edge with a true uni�cation constraint. Incoming subterm edges are saved in a list ofsubterm edges S in list, outgoing subterm edges are saved in a list of subterm edges called S out list. In thesame manner, rewrite edges are saved in R in list and R out list. So for now, the state of a child process isa record whose �elds are its identi�cation number tid, its symbol symb, its dictionary dico order arity, itslist of edges U list, S in list, S out list, R in list, R out list. This record will be extended with �elds con-cerning semi-con�gurations semiconfig list and �elds concerning Uni�cation: list infou, list requestu andlist answeru and �elds concerning Orientation: O out list, O in list, O eq list, calculo list, requesto1 list,requesto2 list, answero1 list and answero2 list, that we will describe later.Completion, including the following di�erent phases: con�guration creation, con�guration processing andUni�cation and Orientation computation, concerns all but the root process. A process works only by reactionto messages, which allows the whole process to be fully asynchronous.Actions of a process implied by a received message are formalized using the transition rules.De�nition 1� An �-transition is the transformation of a state of a process to another state, when it receives amessage. It is denoted by: (fMesgg, State) ��! (Mesgset, State0), where � is a phase of completionlike the creation of con�gurations, the processing of con�gurations, calculation of Uni�cation and cal-culation of Orientation, Mesg is the received message, State is the state of the process before receivingthe message Mesg, Mesgset is the set of all messages that are consequences of message Mesg, whichmust be sent and State0 is the state of the same process with the consequences of receiving Mesg. Inthe set Mesgset, each message mesg is characterized by its destination dest, and denoted mesg[dest].� A C-transition is an �-transition for the creation of con�gurations.A P-transition is an �-transition for the processing of con�gurations.A U-transition is an �-transition for Uni�cation calculation.An O-transition is an �-transition for Orientation calculation.� The binary + operator has got two arguments: a list and an element to add to this list. It is de�ned by:L+ x = L if x belongs to the list L else + pushes x at the end of L. The + operator can be overloadedsuch that its two arguments are lists. In this case for L + L0, + appends elements of the list L0 to thelist L without repetition.The binary � operator has got two arguments: a list and an element to delete from this list. It isde�ned by: L � x = L if x does not belong to the list L else � deletes x from L. The � operator canbe overloaded such that its two arguments are lists. In this case for L � L0, � deletes all elements ofL0 from L.The binary operator combines elementary computations on a node : Starting from a state, it addsthe new information while updating the old. It is de�ned by: if (fMesgg, State) ��! (Mesgset1, State1)and (fMesgg, State) ��! (Mesgset2, State2) then (fMesgg, State) ���! (Mesgset1 [ Mesgset2, State3)where State3 is de�ned by:{ State3:tid = State:tid{ State3:symb = State:symb{ State3:dico order arity = State:dico order arity5

{ State3:X = State:X + (State1:X � State:X) � (State:X � State1:X)+ (State2:X � State:X) �(State:X � State2:X)forX 2 fU list; R in list; R out list; S in list; S out list; semiconfig list; infou list; requestu list;answeru list; O in list; O out list; O eq list; calculo list; requesto1 list; requesto2 list;answero1 list; answero2 listg.The operator is commutative and associative.An A-transition is an �-transition (fMesgg; State) A�! (Mesgset; State0), which processes allD, P, U and O-transitions that can be applied to the state State. A = �1 �2 : : : �n where �i 2fD;U; P;Og.3.1 Implementation of Inference Rules for CompletionCompletion, i.e. local graph transformation, is performed by cooperation between processes by messagepassing, because each process has a local view of the graph. In this section, we present the implementationof the inference rules of Completion, as the creation and processing of con�gurations.3.1.1 Creation of con�gurationsFor the creation of a con�guration, we use the fact that a process can detect a sequence of two adjacentedges forming a con�guration: SUR (see Figure 1), RUR-rhs, RUR (see Figure 2) with a uni�cation edgebetween a node and itself, or two adjacent edges forming a semi-con�guration UR, (a uni�cation edge and anoutgoing rewrite edge). A semi-con�guration or a con�guration is de�ned by edges, therefore by the tids ofprocesses at the ends of these edges. These patterns of two adjacent edges are detected when a new subtermor a new rewrite edge is added or when the uni�cation constraint of a uni�cation edge becomes true.When a semi-con�guration UR is detected, a message called SEMICONF is sent to the process at theother end of the uni�cation edge. When a con�guration of type SUR, RUR-rhs or RUR is detected, amessage called CONFIG containing this con�guration is sent to only one process, since we want to avoidredundant work. SUR and RUR-rhs con�gurations are sent to the process at the top left with respect to�gures 1 and 2. An RUR con�guration is sent to the process of the outgoing end of the rewrite edge withthe maximal tid.When a semi-con�guration UR is detected, a message called SEMICONF is sent. All received messagesSEMICONF are stored in a list called semicon�g list.Consider the creation of an SUR con�guration and look at the example of �gure 1. The process repre-senting term a detects an SUR con�guration containing the rewrite edge from itself to process with term band the uni�cation edge between itself and process with term f . This con�guration is sent to process withterm f to be processed.Creation of con�gurations can be de�ned in terms of C-transitions. We only mention here data structuresand messages, which are useful for the creation of semi-con�gurations and con�gurations. Also, states arerepresented as sets.Notation : We de�ne a function Constraint such that for a uni�cation edge eu, Constraint(eu) = Trueif the uni�cation constraint of eu is true, otherwise Constraint(eu) = False (for the ground case). Fora message Mesg of type CONFIG, we write CONFIG(T, S) to show that the con�guration contained inMesg is of type T and contains the elements of S. T can be SUR, RUR-rhs, or RUR, and S contains theenumeration of the edges or the edge and the semi-con�guration forming the con�guration contained in themessage. We generalize this notation such that for a messageMesg,Mesg(S) means that the messageMesgcontains the elements of S. This notation can also be extended for describing the contents of a �eld, of anedge or of a semi-con�guration. We denote subterm edges by es, e0s and e00s , rewrite edges by er , e0r and e00r ,uni�cation edges by eu and semi-con�gurations contained in a SEMICONF message by semiconf .Let St be the state of the process which receives the message. The creation of con�gurations can beexpressed by the following C-transitions. 6

The �rst seven C-transitions show how an INITR message, indicating the addition of a new rewrite edge,causes the creation of semi-con�gurations and SUR, RUR and RUR-rhs con�gurations.(1) (fINITR(er)g; fSt:R out list; St:U list(eu(tid))g)C�!(fSEMICONF (er; eu)[tid]g; fSt:R out list + er; St:U list(eu)g)if Constraint(eu) = True:(2) (fINITR(er)g; fSt:R out list; St:R in list(e0r (tid))g)C�!(fCONFIG(RUR-rhs; er ; e0r)[tid]g; fSt:R out list + er ; St:R in list(e0r)g)(3) (fINITR(er(tid1))g; fSt:R out list; St:R out list(e0r (tid2))g)C�!(fCONFIG(RUR; er; e0r)[tidmax]g; fSt:R out list + er ; St:R out list(e0r )g)To prevent two messages CONFIG containing the same con�guration from being sent, CONFIGmessage is sent to the process with the tid tidmax such that tidmax = max(tid1; tid2).(4) (fINITR(er)g; fSt:R out list; St:S in list(es(tid; index))g)C�!(fCONFIG(SUR; es; er)[tid]g; fSt:R out list + er; St:S in list(es)g)(5) (fINITR(er(tid))g; fSt:R in list; St:R out list(e0r )g)C�!(fCONFIG(RUR-rhs; er ; e0r)[tid]g; fSt:R in list + er; St:R out list(e0r))g)(6) (fINITR(er(tid1))g; fSt:R out list; St:semiconfig list(semiconf(e0r (tid2); u(tid3)))g)C�!(fCONFIG(RUR; er; semiconf)[tidmax]g; fSt:R out list + er ; St:semiconfig list(semiconf)g)To prevent two messages CONFIG containing the same con�guration from being sent, if the tid ofthe process receiving INITR is larger than tid3 then the message CONFIG is sent to the processwith tid tid1, otherwise to the process with tid tid2.(7) (fINITR(er(tid))g; fSt:R in list; St:semiconfig list(semiconf )g)C�!(fCONFIG(RUR-rhs; er ; semiconf)[tid]g; fSt:R in list + er ; St:semiconfig list(semiconf )g)The following C-transition indicates that a semi-con�guration can be formed when there exists an out-going rewrite edge and when the uni�cation constraint of a uni�cation edge becomes True, after a INITUmessage has been received.(8) (fINITU (eu(tid))g; fSt:U list; St:R out list(er)g)C�!(fSEMICONF (eu; er)[tid]g; fSt:U list + eu; St:R out list(er)g)if Constraint(eu) = TrueThe following two C-transitions express the creation of SUR con�gurations due to the addition of anincoming subterm edge. 7

(9) (fINITS(es(tid; index))g; fSt:S in list; St:semiconfig list(semiconf )g)C�!(fCONFIG(SUR; es; semiconf)[tid]g; fSt:S in list + es; St:semiconfig list(semiconf)g)(10) (fINITS(es(tid; index))g; fSt:S in list; St:R out list(er ))g)C�!(fCONFIG(SUR; es; er)[tid]g; fSt:S in list + es; St:R out list(er )g)The following three C-transitions show how a received SEMICONF message is used to form SUR, RUR-rhs and RUR con�gurations respectively.(11) (fSEMICONF (semiconf)g; fSt:S in list(es(tid; index)); St:semiconfig listg)C�!(fCONFIG(SUR; es; semiconf)[tid]g; fSt:S in list(es); St:semiconfig list + semiconfg)(12) (fSEMICONF (semiconf)g; fR in list(er(tid)); semiconfig listg)C�!(fCONFIG(RUR-rhs; er; semiconf)[tid]g; fSt:R in list(er (tid)); St:semiconfig list + semiconfg)(13) (fSEMICONF (semiconf(eu (tid1); er(tid1; tid2)))g; fSt:R out list(e0r (tid3)); St:semiconfig listg)C�!(fCONFIG(RUR; e0r ; semiconf)[tid]g; fSt:R out list(e0r ); St:semiconfig list + semiconfg)In the same manner as before, the con�guration contained in message CONFIG is only sent onceto process with tid tid3 if the tid of the process receiving the message SEMICONF is larger thantid1, otherwise the message CONFIG is sent to the process with tid tid2, the process at theoutgoing extremity of the rewrite edge of semiconf . So tid is equal to tid2 or to tid3.3.1.2 Processing of con�gurationsThe processing of con�gurations is set o� when a CONFIG message is received by a process. The messagethen releases a sequence of actions depending on the type of the received con�guration. The process receivingthe message processes the con�guration i.e. performs the associated transformation, and sends messageswhich will be used to update information of other processes. The two main steps of the processing of acon�guration are the addition and the deletion of an edge. The completion rules of �gures 1 and 2 showthese two steps and can be implemented using P-transitions and O-transitions (see section 3.3).Messages used for the processing of con�gurations are INITS and INITR to announce that a new edgeis added and UPDATES, UPDATER and UPDATESEMICONF to delete respectively a subterm edge, arewrite edge and a semi-con�guration from the state of a process. An INITR or INITS message can beignored, because the rewrite edge or the subterm edge contained in the message already exists in the stateof the process receiving this message. Consequences of this messages are already done. This remark is validfor D, P, U and O-transitions.Let St be the state of the process receiving a message. The processing of con�gurations can be expressedby the following P-transitions.The following two P-transitions show the processing of an SUR con�guration i.e. the addition and thedeletion of a subterm edge. 8

(14) (fCONFIG(SUR; es(tid1; index); er(tid2))g; fSt:S out list(es(tid1; index))g)P�!(fINITS(e0s(tid2; index))[tid2]; UPDATES(es)[tid1]g; fSt:S out list + e0s � esg)where e0s is the new outgoing subterm edge and tid2 is the tid of the process at the outgoingextremity of er.(15) (fUPDATES(es(tid; index))g; fSt:S in list(es(tid; index))g)P�!(fg; fSt:S in list � esg)The following four P-transitions implement the post-processing of RUR and RUR-rhs con�gurations i.e.the deletion of a rewrite edge. The �rst part of this processing i.e. the addition of a rewrite edge is linkedto the Orientation calculation and so is postponed to section 3.3.(16) (fUPDATER(er)g; fSt:R out list(er )g)P�!(fg; fSt:R out list � erg)(17) (fUPDATER(er)g; St:R out list(er ); St:U list(eu(tid))g)P�!(fUPDATESEMICONF (er; u(tid))[tid]g; fSt:R out list � er ; St:U list(eu)g)if Constraint(eu) = True.(18) (fUPDATER(er)g; fSt:R in list(er)g)P�!(fg; fSt:R in list � erg)(19) (fUPDATESEMICONF (semiconf)g; fSt:semiconfig list(semiconf )g)P�!(fg; fSt:semiconfig list � semiconfg)3.2 Concurrent Uni�cationAlthough concurrency cannot improve the worst-case behavior of uni�cation [DKM84], we give an algorithmthat reduces the amount of processing by a single node. Uni�cation is evaluated by a request-answer method.In a previous implementation, we used only a bottom-up method for computing Uni�cation, but a lots ofcalculated constraints were never used. So we decided to mix a bottom-up and a top-down method. Aprocess sends a request to each child to ask if there is a uni�cation edge with a True constraint betweenitself and a given process. The child responds only if the constraint is True.A Uni�cation problem, in the ground case, is to determine if two terms are equal i.e. if the uni�cationconstraint of the uni�cation edge between the two processes representing the two terms is True. Considerthe problem represented by �gure 3. U0 is the uni�cation edge between the process representing termf(s1; : : : ; sn) and the process representing term f(t1; : : : ; tn). Computation of the uni�cation constraint c0of uni�cation edge U0 depends on the calculation of uni�cation constraints c1,: : :,cn of uni�cation edgesU1,: : :,Un. We have c0 = c1 ^ : : :^ cn. Each constraint ci represents the uni�cation problem si ?= ti.9

f

... ...

t

fprocess p process p’

1

U0

s s t1 n n

U1

UnFigure 3: Calculation of the uni�cation constraint c0 of the uni�cation edge U0Uni�cation must be re-calculated when subterm edges are added or deleted.Using �gure 3, we will explain the principles of the calculation of the uni�cation constraint c0 concurrently:� Initially, all uni�cation constraints are false except uni�cation constraints of unary cycle uni�cationedges.� Suppose process p represents f(s1; : : : ; sn) and p0 represents f(t1; : : : ; tn), such that p0 is in charge ofcomputing c0. Process p sends to p0 the tids of processes representing terms s1; : : : ; sn, so that p0 knowson which children's uni�cation constraints c0 depends.This is done with INFOU messages. An INFOU message contains the uni�cation edge to calculate,the tid of the process at the extremity of the outgoing subterm edge, and the index of this subtermedge. INFOU received messages are saved in infou list.� When p0 receives this information, it asks the processes representing terms t1, : : :, tn, if their uni�cationconstraints c1, : : :, cn respectively are True. This calculation is top-down. A request is sent with aREQUESTU message. REQUESTU received messages are saved in requestu list.� If a uni�cation constraint ci (i > 0) becomes True and has a saved request concerning the computationof c0, then the process representing term ti informs process p0 that ci became True. This calculationis bottom-up.An answer is announced with an ANSWERU message. ANSWERU received messages are saved inansweru list.� If a process detects that a uni�cation constraint becomes True i.e. for the corresponding edge, thenumber of ANSWERU messages is equal to the arity of the symbol of the process, then it must informthe other extremity of the uni�cation edge.Two observations permit us to optimize this request-answer method for the calculation of uni�cation.Indeed, it is useless to send the same request several times (REQUESTU messages) and the same information(INFOU messages) and it is useless to calculate all uni�cation constraints of all uni�cation edges. A requestcan be sent only once, because requests are saved by processes receiving them and when an answer toa request is available, the answer will be sent. The uni�cation constraint of a uni�cation edge must becalculated, only if the uni�cation edge forms a semi-con�guration with an adjacent outgoing rewrite edge.This observation is implemented by the following principals. The Initialization Phase can be consideredas a pre-processing phase. If there exist an outgoing rewrite edge and a uni�cation edge for one node ofthe initial graph, then both processes at the extremity of this uni�cation edge must be informed that theyneed to calculate the uni�cation constraint, but only one process will calculate it. In this case, the processnot in charge of computing the uni�cation constraint of this uni�cation edge is allowed to send INFOUinformation messages to the process at the other end of the edge to permit it to calculate the constraint.The optimization resides in the fact that uni�cation is calculated only if it is needed. During the Completionprocess, if an outgoing rewrite edge is added to the state of a process and if this process has got a uni�cationedge, the uni�cation constraint of this uni�cation edge must be calculated and the other extremity of theuni�cation edge is noti�ed of this fact using either a message INFOU if the process is in charge of computingthe uni�cation edge or a message NEEDU otherwise.10

Notations We de�ne a function Needu such that for a uni�cation edge eu, Needu(eu) returns True ifthe uni�cation constraint of eu must be calculated (as described before), otherwise it returns False. Wedenote the information contained in INFOU messages by infou and infou0, the information contained inREQUESTU messages by requestu and requestu0, and the the information contained in a ANSWERUmessage by answeru and answeru0.Let St be the state of the process which receives the message. The preceding algorithm can be expressedusing the following U-transitions.The following four U-transitions explain how the data structures U list, infou list, requestu list and an-sweru list are updated.(20) (fINITU (eu(tid))g; fSt:U list(eu)g)U�!(fg; fSt:U list(eu) � e0u(tid) + eu(tid)g)if e0u is the uni�cation edge eu with a False uni�cation constraint and if Constraint(eu) = True inthe INITU message.(21) (fINFOU (infou(es(tid; index)); eu(tid))g; fSt:infou list; St:U list(eu)g)U�!(fg; fSt:infou list � infou0(index; eu)+infou(e0s; eu); St:U list(eu)g)where tid is the outgoing extremity of the subterm edge e0s and infou0 is the old uni�cationinformation concerning the calculation of the uni�cation of eu using the index index.If initially, Needu(eu) = False, this value is changed to True.(22) (fREQUESTU (requestu(eu(tid); e0u(tid2; tid1); e0s(tid1; tid; index)))g; fSt:U list(eu);S in list(e0s(tid2; index)); St:requestu listg)U�!(fg; fSt:U list(eu); St:S in list(e0s); St:requestu list + requestu � requestu0(e0u; es)g)where requestu0 is due to the old REQUESTU message concerning eu and the index index.(23) (fANSWERU (e0u(tid1; tid2); eu(St:tid; tid); index)g; fSt:U list(eu(tid)); St:S out list(e0s(tid1; index))g)U�!(fg; fSt:U list(eu); St:S out list(e0s); St:answeru list � answeru0 + answerug)where answeru0 is the old received ANSWERU message concerning eu and index.The following four U-transitions shows how an explicit addition of an outgoing subterm edge (INITRmessage) or an implicit addition of an outgoing subterm edge (processing of an SUR con�guration) causesmessages for the calculation of Uni�cation to be sent. These messages are either information (INFOUmessages) or requests.(24) (fINITS(es)g; fSt:S out list; St:U list(eu(tid))g)U�!(fINFOU (es; eu)[tid]g; fSt:S out list + es; St:U list(eu)g)if Constraint(eu) = False, Needu(eu) = True and the process that receives INITS is not in chargeof calculating the uni�cation constraint of eu.11

(25) (fINITS(es(tid; index))g; fSt:S out list; St:U list(eu); St:infou list(infou(eu ; index))g)U�!(fREQUESTU (infou; es)[tid]g; fSt:S out list + es; St:U list(eu); St:infou list(infou)g)if Constraint(eu) = False and the process that receives INITS is in charge of calculating theuni�cation constraint of eu.(26) (fCONFIG(SUR; es(index); er(tid0))g; fSt:S out list(es(index)); St:U list(eu(tid)g)U�!(fINFOU (e0s(tid0; index); eu)[tid]g; fSt:S out list � es + e0s; St:U list(eu)g)if Constraint(eu) = False, Needu(eu) = True and the process that receives CONFIG is not in chargeof calculating the uni�cation constraint of eu.Also tid0 is the tid of the process at the outgoing extremity of er . e0s is the new outgoing subterm edge.(27) (fCONFIG(SUR; es(index); er(tid0))g; fSt:S out list(es(index)); St:U list(eu(tid));St:infou list(infou(index; eu(tid)))g)U�!(fREQUESTU (e0s(index; tid0); infou)[tid0]g; fSt:S out list � es + e0s; St:U list(eu); St:infou list(infou)g)if Constraint(eu) = False and the process that receives CONFIG is in charge of the calculation of theuni�cation constraint of eu.Also tid0 is the tid of the process at the outgoing extremity of er . e0s is the new outgoing subterm edge.The following four U-transitions show the up-propagation of uni�cation information, in particular AN-SWERU messages.(28) (fINITS(es(tid; index))g; fSt:S in list; St:U list(eu); St:requestu list(requestu(eu ; index))g)U�!(fANSWERU (eu; es)[tid]g; fSt:S in list + es; St:U list(eu); St:requestu list(requestu)g)if Constraint(eu) = True:(29) (fINITU (eu(tid))g; fSt:U list(eu(tid)); St:S in list(es(tid0; index)); St:requestu list(requestu(eu ; es)g)U�!(fANSWERU (eu; es)[tid0]g; fSt:U list(eu); St:S in list(es); St:requestu list(requestu)g)if Constraint(eu) = False initially and Constraint(eu) = True in the INITU message.(30) (fREQUESTU (requestu(eu; es(tid; index)))g; fSt:U list(eu); S in list(es(tid; index)); St:requestu listg)U�!(fANSWERU (eu; es)[tid]g; fSt:U list(eu); St:S in list(es); St:requestu list(requestu)g)if Constraint(eu) = True.(31) (fANSWERU (eu(tid))g; fSt:U list(eu(tid)); St:requestu list(e0u(tid1); eu(tid); es(index; tid1));St:S in list(es))g)U�!(fANSWERU (e0u; es))[tid1]g; fSt:U list(eu); St:requestu list(e0u; eu; es); St:S in list(es))g)the number of ANSWERU received messages for calculating the uni�cation constraint of eu, initiallyFalse is equal to the arity of the symbol of the process which receives ANSWERU, the uni�cationconstraint of eu is then changed to True. 12

The following U-transition indicates that if uni�cation information is received by a process, this processis able to send requests asking if there exists a particular uni�cation constraint True between two processes.(32) (fINFOU (infou(e0s(tids; index)); eu)g; fSt:S out list(es(tid; index)); St:infou list; St:U list(eu)g)U�!(fREQUESTU (infou; es)[tid]g; fSt:S out list(es); St:infou list(infou); St:U list(eu)g)where tids is the outgoing extremity of the subterm edge e0s and infou is the old uni�cationinformation concerning the calculation of the uni�cation of eu using the index index.If initially, Needu(eu) = False, this value is changed to True.The following two U-transitions mean that, if a received request has no answer available, requests andinformation must be sent to make this answer available later.(33) (fREQUESTU (requestu(eu; es)g; fSt:U list(eu); St:S in list(es); S out list(e0s(tid));St:infou list(infou(eu ; e00s ))g)U�!(fREQUESTU (eu; e0s; e00s )[tid]g; fSt:U list(eu); St:S in list(es); St:S out list(e0s); St:infou list(infou)g)if Constraint(eu) = False and if the process which receives REQUESTU is in charge of the calculationof the uni�cation constraint of eu.(34) (fREQUESTU (requestu(eu(tid); es)g; fSt:U list(eu(tid)); St:S in list(es); S out list(e0s)g)U�!(fINFOU (eu; e0s)[tid]g; fSt:U list(eu); St:S out list(e0s); St:S in list(es)g)Constraint(u) = False and if the process which receives REQUESTU is not in charge of thecalculation of the uni�cation constraint of eu.requestu0 is due to the old REQUESTU message concerning eu and the index index.This following U-transition is used to decide when a uni�cation constraint becomes True.(35) (fANSWERU (eu(tid))g; fSt:U list(eu(tid))g)U�!(fINITU (eu)[tid]g; fSt:U list(eu)g)the number of ANSWERU received messages for calculating the uni�cation constraint of eu, initiallyFalse is equal to the arity of the symbol of the process which receives ANSWERU, the uni�cationconstraint of eu is then changed to True.The following U-transitions optimize of the Uni�cation calculation. This optimization, as explainedabove, is based on the criterion that Uni�cation needs to be calculated only when a process has got auni�cation edge adjacent to an outgoing rewrite edge. So when an outgoing rewrite edge is added explicitlyusing a INITR message or implicitly when a con�guration is processed, Uni�cation must be calculated. Forthis last case, we use O-transitions, that will be expressed later in section 3.3.(36) (fINITR(er )g; fSt:R out list; St:U list(eu(tid)); St:S out list(es(tid1))g)U�!(fINFOU (eu; es)[tid]g; fSt:R out list + er ; St:U list(eu); St:S out list(es)g)if Constraint(eu) = False and the process receiving INITR is not in charge of the calculation of theconstraint of eu and Needu(eu) = False in the initial state of the process receiving INITR. Afterthe processing of the message INITR, the value of Needu(eu) is changed to True.13

(37) (fINITR(er )g; fSt:tid; St:R out list; St:U list(eu(tid)); St:S out list(es(tid1))g)U�!(fNEEDU (St:tid)[tid]g; fSt:tid; St:R out list + er ; St:U list(eu); St:S out list(es)g)if Constraint(eu) = False and the process receiving INITR is in charge of the calculation of theconstraint of eu and Needu(eu) = False in the initial state of the process receiving INITR. Afterthe processing of the message INITR, the value of Needu(eu) is changed to True.(38) (fNEEDU (eu)g; fSt:S out list(s(tid; index)); St:U list(eu(tid1))g)U�!(fINFOU (eu; es)[tid1]g; fSt:S out list(s); St:U list(eu)g)if the process receiving the message NEEDU is not in charge of the calculation of theuni�cation constraint of eu. After processing of the message, Needu(eu) = True.The soundness and completeness results of this set of rules for this concurrent Uni�cation algorithm aregiven in section 3.6.3.3 Concurrent OrientationAn Orientation problem is to determine if a term s is bigger than a term t with respect to LPO. If it is, wecreate an outgoing orientation edge from the process representing term s to the process representing term t.We use a request-answer method as we did for Uni�cation.Each process saves its orientation edges in three lists: O in list, O out list and O eq list depending onwhether the orientation edge is incoming, outgoing or `equal'. This last case means that there exists auni�cation edge with a true uni�cation constraint between these two processes. So, an orientation edge ischaracterized by the tid and the symbol of the process at the other extremity of the orientation edge.3.3.1 Graphic Implementation of LPOThe concurrent calculation of Orientation is based on the simpli�cation ordering LPO (see de�nition insection 2). We will now see how to pass from a textual de�nition of LPO to a graphic de�nition adapted toour concurrent calculation of Orientation.Let p1 be the process representing the term s = f(s1; : : : ; sn) and p2 the process representing the termt = g(t1; : : : ; tm). We want to know if s �lpo t i.e. if we can add an orientation edge Oo going from theprocess of term s to the process of term t. The three conditions of the de�nition of LPO can be expressedby the following schemas respectively.1. There is an outgoing orientation edge O0 from p1 to p2, if the symbol of process p1 is bigger than thesymbol of process p2 and if process p1 is linked to each child process of p2 by an outgoing orientationedge (see �gure 4)....

... ...

f gO0

Om

s s t t1 n 1 m

O1

subterm edgeFigure 4: Implementation of LPO - Case 12. There is an outgoing orientation edge O0 from p1 to p2, if there is an outgoing or `equal' orientationedge from one child process of p1 to p2 (see �gure 5).14

n 1 m

...

Of g

O

0

i

t t1 i

subterm edge

s s sFigure 5: Implementation of LPO - Case 23. There is an outgoing orientation edge O0 from p1 to p2, if the symbol of process p1 is equal to thesymbol of process p2 and if process p1 is linked to each child process of p2 by an outgoing orientationedge, and there exists a child process of p1 (linked with p1 with a subterm edge of index i) whichhas got an outgoing orientation edge to a child process of p2 (linked with p2 with a subterm edge ofindex i), and all orientation edges from p1 (linked with p1 with a subterm edge of index j < i) to achild process of p2 (linked with p2 with a subterm edge of index j) have as direction `equal'. Figure6 presents the case where the nth child of p1 is linked to the nth child process of p2 with an outgoingorientation edge and On+1,: : :,O2n�1 have as direction `equal'....

... ...

n+1

f f0

O

ss t t

OO

O

n1n1

1

n

2n

subterm edge

OFigure 6: Implementation of LPO - Case 33.3.2 Principles of the concurrent calculation of OrientationOrientation is evaluated by a request-answer method. The request consists of a process asking each of itschildren if there is an incoming orientation edge between itself and another process. The child processanswers if such an edge exists.The algorithm of concurrent calculation of Orientation works according to the following principles:� The concurrent calculation of Orientation is based on the knowledge of the symbols of the two processesat the extremities of the orientation edge to orient.� The Orientation calculation takes place when:{ an RUR-rhs or an RUR con�guration is received, to orient the new rewrite edge to add. If thereis no orientation information available, requests are made to ask how to orient this edge and theprocess records that this information of orientation will serve to orient the corresponding rewriteedge. We will not insist on this in what is following for reasons of readability.{ an SUR con�guration is received. In this case, the direction of outgoing orientation edges are nolonger sure, new orientation request messages are sent.� 1. Assume that a process p1 needs to calculate the orientation edge o between itself and the processp2, such that the symbol of p1 is symb1 and the symbol of p2 is symb2 and symb1 > symb2 withrespect to the precedence. Then we proceed as follows:{ If symb2 is a constant, an outgoing orientation edge can be added from p1 to p2 in p1'sO out list and in p2's O in list. 15

{ Otherwise, process p1 sends a message to process p2 to tell it that it must calculate theorientation edge o. This message contains characteristics of child processes of p1 and is calledCALCULO.{ When process p2 receives this message, it saves it in the data structure called calculo list andsends to each of its children a request, to ask them if there is an orientation edge from p1 tothem. Messages used for doing that are REQUESTO1 messages. For optimization, a requestis not re-sent, if the same request has already been sent.{ When p3, child process of p2, receives this request, it does not automatically process it. Theconsequences of a request are processed only if there still exists an outgoing subterm edgefrom p2 to p3.If there still exists an outgoing subterm edge from p2 to p3, when p3 receives this request, itsaves it in requesto1 list and the following tests are made.{ If p3's O in list contains an orientation edge from p1 to p3, p3 sends to p2 an answer sayingthat there is an orientation edge from p1 to p3. This answer is sent using an ANSWERO1message. This message will be saved in p2's answero1 list.{ If p3's O out list contains an outgoing orientation edge from p3 to p1, process p3 sends amessage to process p2 to tell it that the orientation edge o is going from p2 to p1 using amessage OUTO containing a ag equal to 2. When process p2 receives this message, if therestill exists an outgoing subterm edge from p2 to p3, p2 will tell process p1 that the orientationedge o is going from p2 to p1 using a message INO.{ If there is no orientation edge between p3 and p1, then either an orientation edge can be easilyadded, because p1 or p3 is a constant, or requests must be sent considering the symbols of p1and p3.{ If process p2 has received n answers messagesANSWERO1, one from each of its n child processpk saying that there is an outgoing edge from p1 to pk, p2 can decide that the orientation edgeo is going from p1 to p2 and tells p1 using a message OUTO , and adds the new orientationedge o to its O in list. If o exists in p1's O in list, this information is updated, because thestate of a process can not contain contradictory information. If this orientation informationserves to add a rewrite edge, the corresponding rewrite edge is added. We will not insist onthis in what is following for reasons of readability.2. Assume that process p1 needs to calculate the orientation edge o between itself and process p2,such that symbols symb1 and symb2 of p1 and p2 are the same and are function symbols.{ Processes p1 and p2 must calculate the direction of the orientation edge o. Process p1 sends amessage to process p2 to tell it that it must calculate the orientation edge o, with a CALCULOmessage.{ When process p2 receives this message, it saves it and sends to each of its children a messagecalledREQUESTO1 and a message called REQUESTO2, to ask them if there is an orientationedge from p1 to them and if there is an `equal' or incoming orientation edge from childprocesses of p1 to children processes of p2 with the same index.Furthermore, process p2 sends a message called CALCULO1 to process p1 to tell it thatit must calculate the orientation edge o too. This message CALCULO1 is a consequenceof message CALCULO and contains the tids and the indexes of children processes of p2.Consequences of message CALCULO1 are the same as consequences of message CALCULO(except that a message CALCULO is no longer sent). Received messages CALCULO1 aresaved in calculo list.{ When p3, child process of p2, receives a message REQUESTO1, it saves this message in itsrequesto1 list and makes the following test.If p3's O in list or O out list contains an orientation edge between p1 and p3, p3 has the samebehavior as in the previous point.If there is no orientation edge between p3 and p1, then either an orientation edge can be easilyadded, because p1 or p3 is a constant, or requests must be sent considering the symbols of p1and p3. 16

{ When p3, ith child process of p2, receives a message REQUESTO2, it saves this message inits requesto2 list and makes the following test.If p3's O in list (respectively O eq list) contains an orientation edge from (respectively be-tween) a child process p4 of p1 with index i to p3 (child process of p2) sends to process p2 amessage called ANSWERO2 containing the ag > (respectively the ag =).If there is no orientation edge between p4 and p3, then either an orientation edge can be easilyadded, because p4 or p3 is a constant, or requests must be sent considering the symbols of p4and p3.{ If process p2 has received n messages ANSWERO1 one from each of its n children processesand if process p2 has received k messages ANSWERO2, containing `equal' orientation edge( ag =), from its k �rst children processes and a message ANSWERO2, containing an incom-ing edge ( ag >), from its k + 1st child process such that k 2 f0; : : : ; n� 1g and if all thesemessages concern the calculation of the orientation edge o, process p2 can decide that theorientation edge o is going from p1 to p2. Process p2 sends to process p1 a message OUTO ,to tell it the direction of o and add the new orientation edge o to its O in list. We will notinsist on this in what is following for reasons of readability.Process p1 makes the same test and can decide that the orientation edge o is going from p2to p1.Notation : We denote orientation edges by eo, e0o and e00o , the information contained in a RE-QUESTO1 message by requesto1 and requesto10, the information contained in a REQUESTO2 mes-sage by requesto2 and requesto20, the information contained in a ANSWERO1 message by answero1and answero10, the information contained in a ANSWERO2 message by answero2 and answero20, theinformation contained in a CALCULO or CALCULO1 message by calculo and calculo0.Let St be the state of the process which receives the message. The preceding algorithm can be expressedmore speci�cally using the following O-transitions.The following �ve O-transitions explain how the data structures calculo list, requesto1 list, requesto2 listanswero1 list and answero2 list are updated.(39) (fCALCULO(calculo(eo(tid1; symb1); es(tid1; tid2; index))g; fSt:calculo listg))O�!(fg; fSt:calculo list � calculo0(eo; e0s(tid1; index)) + calculog)where calculo0 is due to an old saved CALCULO message concerning eo and index.(40) (fREQUESTO1(requesto1(eo(tid1; tid2); e0o(St:tid; tid1); index))g; fSt:tid; St:S in list(es(tid2; index));St:requesto1 listg)O�!(fg; fSt:tid; St:S in list(es); St:requesto1 list + requesto1g)(41) (fREQUESTO2(requesto2(eo(tid1; tid2); e0o(St:tid; tid3); index))g; fSt:tid; St:S in list(es(tid2; index));St:requesto2 listg)O�!(fg; fSt:tid; St:S in list(es); St:requesto2 list � requesto20(eo; index) + requesto2g)where requesto20 is due to an old saved REQUESTO2 message concerning eo and index and tid3 is thetid of indexth child process of process with tid tid1.17

(42) (fANSWERO1(answero1(eo(tid1; St:tid); e0o(tid2; tid1); index))g; fSt:tid; St:S out list(es(tid2; index);answero1 list)g)O�!(fg; fSt:tid; St:S out list(es); St:answero1 list + answero1g)(43) (fANSWERO2(answero2(eo(tid2; tid1); e0o(St:tid; tid3); index))g; fSt:tid; St:S out list(es(tid2; index));St:answero2 listg)O�!(fg; fSt:tid; St:S out list(es); St:answero2 list � answero20(eo; index) + answero2g)where answero20 is due to an old received ANSWERO2 message concerning eo and index and tid3 is thetid of indexth child process of process with tid tid1.The following �veO-transitions show the processing of an RUR con�guration, in particular when anoutgoing rewrite edge can be added, because an outgoing orientation edge is present or can be easily added.(44) (fCONFIG(RUR; er(tid1); e00r (tid2))g; fSt:R in list(er(tid1)); St:O out list(eo(tid2));St:R out listg)O�!(fINITR(St:tid)[tid2]g; fSt:R in list � er ; St:O out list(eo); St:R out list + e0r(tid2)g)where tid2 is the tid of the process at the outgoing extremity of the rewrite edge e00r . e0r is the newrewrite edge.(45) (fCONFIG(RUR; er(tid1); e00r (tid2)g; fSt:O out list(eo(tid2)); St:R in list(er (tid1))g)O�!(fUPDATER(er)[tid1]g; fSt:O out list(eo); St:R in list � erg)The same assertions as in (44).(46) (fCONFIG(RUR; er(tid1); e00r (tid2; symb2))g; fSt:symb; St:tid; St:O out list; St:R in list(er (tid1))St:R out listg)O�!(fINO(St:tid)[tid2]; INITR(St:tid)[tid2]g; fSt:symb; St:tid; St:O out list + eo(tid2; symb2);St:R in list � er ; St:R out list + e0r(tid2; symb2)g)if symb2 is a constant, St:symb is either a constant or a function symbol, St:symb > symb2 and thereis no orientation edge between the process with tid St:tid and the process with tid tid2 (the tid of theprocess at the outgoing extremity of e00r ). eo is a new orientation edge. e0r is the new rewrite edge.(47) (fCONFIG(RUR; er(tid1); e00r (tid2; symb2))g; fSt:symb; St:tid; St:R in list(er (tid1))g)O�!(fUPDATER(St:tid)[tid2]g; fSt:symb; St:tid; St:R in list � erg)The same assertions as in (46).(48) (fCONFIG(RUR; er(tid1); e00r (tid2; symb2))g; fSt:symb; St:tid; St:S in list(es(tid; index));St:R in list(er)g)O�!(fOUTO(eo(tid; tid2); St:tid; index; 2)[tid]g; fSt:symb; St:tid; St:S in list(ss); St:R in list � erg)The same assertions as in (46). 18

The following four O-transitions show the processing of an RUR con�guration, in particular when anincoming orientation edge used to orient the corresponding rewrite edge is present or can be easily added.(49) (fCONFIG(RUR; er(tid1); e00r (tid2; tid3); eu(tid1; tid2))g; fSt:O in list(eo(tid3)); St:R in list(er (tid1))g)O�!(fINITR(St:tid)[tid3]g; fSt:O in list(eo); St:R in list + e0r(tid3)g)where tid3 is the tid of the process at the outgoing extremity of e00r . e0r is the new rewrite edge.(50) (fCONFIG(RUR; er(tid1); e00r (tid2; tid3); eu(tid1; tid2)g; fSt:O in list(eo(tid3)); St:R in list(er(tid1))g)O�!(fUPDATER(e00r (tid3))[tid2]; UPDATER(e00r(tid2))[tid3]g; fSt:O in list(eo); St:R in list + e0r(tid3)g)where e0r is the new rewrite edge and tid3 is the tid of the process at the outgoing extremityof e00r and both messages UPDATER contain the rewrite edge e00r as outgoing and therewrite edge e00r as incoming, respectively.(51) (fCONFIG(RUR; er(tid1); e00r (tid2; tid3; symb3); eu(tid1; tid2))g; fSt:symb; St:tid; St:O in list;St:R in list(er)g)O�!(fOUTO(eo(St:tid); 1)[tid3]; INITR(St:tid)[tid3]g; fSt:symb; St:tid; St:O in list + eo(tid3); St:R in list+e0r(tid3)g)if St:symb is a constant, symb3 is either a constant or a function symbol, symb3 > St:symb and thereis no orientation edge between the process with tid St:tid and process with tid tid3 (the tid of the processat the outgoing extremity of e00r ). eo is a new orientation edge. e0r is a new rewrite edge.(52) (fCONFIG(RUR; er(tid1); e00r (tid2; tid3; symb3); eu(tid1; tid2))g; fSt:symb; St:tid; R in list(er (tid1))g)O�!(fUPDATER(e00r (tid3))[tid2]; UPDATER(e00r(tid2))[tid3]g; fSt:symb; St:tid; St:R in list + e0r(tid3)g)The same assertions as in (51).The following two O-transitions show the processing of an RUR con�guration, in particular when arewrite edge can not be added, because orientation information is not available. In this case, requests aresent to ask for orientation information.(53) (fCONFIG(RUR; er(tid1); e00r (tid2; symb2))g; fSt:symb; St:tid; St:R in list(er )g)O�!(fCALCULO(eo(St:tid; St:symb); list sons)[tid2]g; fSt:symb; St:tid; St:R in list(er )g)if St:symb and symb2 are function symbols, St:symb � symb2 and there is no orientationedge between the process with tid St:tid and the process with tid tid2 (the tid of the process at theoutgoing extremity of e00r ). list sons is the list of the children of the process with tid St:tid.(54) (fCONFIG(RUR; er(tid1); e00r (tid2; tid3; symb3); eu(tid1; tid2))g; fSt:symb; St:tid;St:S out list(es(tid; index)); St:R in list(er)g)O�!(fREQUESTO1(eo(St:tid; tid3); e0o(tid3; tid); index)[tid]g; fSt:symb; St:tid; St:S out list(es));St:R in list(er)g)if St:symb and symb3 are function symbols, St:symb < symb3 and there is no orientation edge betweenthe process with tid St:tid and the process with tid tid3, tid of the process at the outgoing extremity of e00r .The following four O-transitions described one part of the Uni�cation calculation. The case, where anoutgoing rewrite edge is added because of the processing of an RUR con�gurations and Uni�cation needs tobe calculated, can not be described using U-transitions.19

(55) (fCONFIG(RUR; er(tid1); e00r (tid2))g; fSt:R in list(er(tid1)); St:U list(eu(tid3))g)O�!(fNEEDU [tid3]g; fSt:R in list � er ; St:U list(eu)g)if Constraint(eu) = False and the process receiving CONFIG is in charge of the calculation of theconstraint of eu and if Needu(eu) = False in the initial state of the process receiving CONFIG. After theprocessing of the message CONFIG, the value of Needu(eu) is changed to True.(56) (fCONFIG(RUR; er(tid1); e00r (tid2))g; fSt:R in list(er(tid1)); St:U list(eu(tid)); St:S out list(es)g)O�!(fINFOU (eu; es)[tid]g; fSt:R in list � er ; St:U list(eu); St:S out list(es)g)if Constraint(eu) = False and the process receiving CONFIG is not in charge of the calculation of theconstraint of eu and Needu(eu) = False in the initial state of the process receiving CONFIG. After theprocessing of the message CONFIG, the value of Needu(eu) is changed to True.(57) (fCONFIG(RUR; er(tid1); e00r (tid2; symb2))g; fSt:symb; St:O out list; St:R in list(er ); St:U list(eu(tid))g)O�!(fNEEDU [tid]g; fSt:symb; St:O out list + eo(tid2; symb2); St:R in list � er ; St:U list(eu)g)if the following Uni�cation conditions are true: Constraint(eu) = False, the process receiving CONFIG isin charge of the calculation of the constraint of eu and Needu(eu) = False in the initial state of the process.The following Orientation conditions must be true too: symb2 is a constant, St:symb > symb2 and thereis no orientation edge between the process with tid St:tid and the process with tid tid2 (the tid of theprocess at the outgoing extremity of e00r ). eo is a new orientation edge.After the processing of the message CONFIG, the value of Needu(eu) is changed to True.(58) (fCONFIG(RUR; er(tid1); e00r (tid2; symb2))g; fSt:symb; St:O out list; St:R in list(er ); St:U list(eu(tid));St:S out list(es)g)O�!(fINFOU (es; eu)[tid]g; fSt:symb; St:O out list + eo(tid2); St:R in list � er ; St:U list(eu); St:S out list(es)g)if the following Uni�cation conditions are true: Constraint(eu) = False, the process receiving CONFIG is notin charge of the calculation of the constraint of eu and Needu(eu) = False in the initial state of the process.The following Orientation conditions must be true: symb2 is a constant, St:symb > symb2 and thereis no orientation edge between the process with tid St:tid and the process with tid tid2, the tid of theprocess at the outgoing extremity of e00r . eo is a new orientation edge.O-transitions are similar for the processing of RUR-rhs con�gurations, and we do not express them.The following two O-transitions illustrate the orientation part of the SUR con�guration processing.Orientation requests are made via the new added subterm edge.(59) (fCONFIG(SUR; es(tid; index); er(tid1; symb1))g; fSt:symb; St:tid; St:S out list(es(index; tid));St:calculo list(eo(tid2; symb2))g)O�!(fREQUESTO1(eo(St:tid; St:symb; tid2; symb2); e0o(tid1; tid2); index)[tid]g; fSt:symb; St:tid; St:S out list�es + e0s(tid1; symb1); St:calculo list(eo)g)if St:symb = symb2 or St:symb < symb2. e0s is the new subterm edge and o is an edge to calculate.20

(60) (fCONFIG(SUR; es(index; tid); er(tid1; symb1))g; fSt:symb; St:tid; St:S out list(es(index; tid));St:calculo list(eo(tid2; symb2); index; tidsontid2; symbsontid2)g)O�!(fREQUESTO2(eo(St:tid; St:symb; tid2; symb2); e0o(tid1; tidsontid2; symbsontid2); index)[tid]g;St:symb; St:tid; St:S out list � es + e0s(tid1); St:calculo list(eo ; index; tidsontid2; symbsontid2)g)if St:symb = symb2. e0s is the new subterm edge and eo is an edge to calculate. tidsontid2 andsymbsontid2 are the tid and the symbol of a child of process with tid tid2.The following two O-transitions indicate how the addition of an outgoing subterm edge causes orientationrequests to be sent via this edge with respect to all orientation edges to calculate saved in calculo list.(61) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:calculo list(calculo(eo(St:tid; St:symb; tid1; symb1)));St:S out listg)O�!(fREQUESTO1(eo(St:tid; St:symb; tid1; symb1); e0o(tid; tidsontid1; symbsontid1); index)[tid]g; fSt:symb;St:tid; St:calculo list(calculo); St:S out list + esg)where eo is an orientation edge between the process with tid St.tid and the process with tid tid1.(62) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:calculo list(calculo(eo(St:tid; St:symb; tid1; symb1); index;tidsontid1; symbsontid1)); St:S out listg)O�!(fREQUESTO2(eo(St:tid; St:symb; tid1; symb1); e0o(tid; tidsontid1; symbsontid1); index)[tid]g; fSt:symb;St:tid; St:calculo list(calculo); St:S out list + esg)where eo is an orientation edge between the process with tid St.tid and the process with tid tid1.tidsontid1 is the tid of the indexth child process of tid1 with symbol symbsontid1.The following �ve O-transitions indicate how the addition of an incoming subterm edge causes up-propagation of orientation answers for all the saved requests having an answer.(63) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:requesto1 list(requesto1(eo (St:tid; tid1); e0o(tid; tid1);index)); St:O in list(eo); St:S in listg)O�!(fANSWERO1(eo; e0o; index)[tid]g; fSt:symb; St:tid; St:requesto1 list(requesto1);St:O in list(eo); St:S in list + esg)(64) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:requesto1 list(requesto1(eo (St:tid; tid1; symb1);e0o(tid; tid1); index)); St:O in list(eo); St:S in listg)O�!(fANSWERO1(eo; e0o; index)[tid]g; fSt:symb; St:tid; St:requesto1 list(requesto1);St:O in list(eo); St:S in list + esg)if symb1 � St:symb and St:symb is a constant symbol.(65) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:requesto2 list(requesto2(eo (St:tid; tidsontid1); e0o(tid; tid1);index); St:O in list(eo); St:S in listg)O�!(fANSWERO2(eo; e0o; index;>)[tid]g; fSt:symb; St:tid; St:O in list(eo);St:requesto2 list(requesto2); St:S out list + sg)where tidsontid1 is the tid of the indexth child process of tid121

(66) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:requesto2 list(requesto2(eo (St:tid; tidsontid1; symbsontid1);e0o(tid; symb; tid1); index); St:O in list(eo); St:S in listg)O�!(fANSWERO2(eo; e0o; index;>)[tid]g; fSt:symb; St:tid; St:O in list(eo); St:requesto2 list(requesto2);St:S out list + sg)where tidsontid1 is the tid of the indexth child process of tid1 withsymbol symbsontid1 and symbsontid1 > St:symb and St:symb is a constant symbol and symb = symb1.(67) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:requesto2 list(requesto2(eo (St:tid; tidsontid1; symbsontid1);e0o(tid; symb; tid1); index); St:O eq list(eo); St:S in listg)O�!(fANSWERO2(eo; e0o; index;=)[tid]g; fSt:symb; St:tid; St:O eq list(eo); St:requesto2 list(requesto2);St:S out list + sg)where tidsontid1 is the tid of the indexth child process of tid1with symbol symbsontid1 and symbsontid1 > St:symb and St:symb is a constant symbol and symb = symb1.(68) (fINITS(es(tid; index))g; fSt:symb; St:tid; St:O out list(eo(St:tid; tid))O�!(fOUTO(eo; e0o(tid1; tid); index)[tid]g; fSt:symb; St:tid; St:O out list(eo)g)The following three O-transitions show the processing of an INITU. These INITU messages implies theupdating of O eq list and the up-propagation of Orientation answers.(69) (fINITU (eu(tid))g; fSt:O eq listg)O�!(fg; fSt:O eq list + eo(tid)g)if Constraint(eu) = True(70) (fINITU (eu(tid))g; fSt:S in list(es(tid1; index))g)O�!(fOUTO(eo(tid1; tid); St:tid; index; 2)[tid]g; fSt:S in list(es)g)if Constraint(eu) = True(71) (fINITU (eu(tid))g; fSt:tid; St:S in list(es(tid2; index));St:requesto1 list(requesto1(tid1; tid2; symb1; symb2; tid; index))g)O�!(fANSWERO2(eo(St:tid; tidsontid1; >); e0o(tid2; tid1); index;=)[tid2]g; fSt:tid; St:S in list(es);St:requesto1 list(requesto1)g)where the process with tid tidsontid1 is the indexth child of the process with tid tid1.The following �ve O-transitions show the processing of a CALCULO or CALCULO1 message. Thismessages causes requests to be sent.(72) (fCALCULO(calculo(eo(tid1; symb1)))g; fSt:symb; St:tid; St:S out list(es(tid; index))g)O�!(fREQUESTO1(eo(St:tid; tid1); e0o(tid; tid1); index)[tid]g; fSt:symb; St:tid; St:S out list(es)g)22

(73) (fCALCULO(calculo(eo(tid1; symb1)))g; fSt:symb; St:tidg)O�!(fCALCULO1(calculo1(eo(St:tid; St; symb)))[tid1]g; fSt:symb; St:tidg)if St:symb = symb1(74) (fCALCULO(calculo(eo(St:tid; tid1; symb1); es(tid1; tidsontid1; symbsontid1)))g; fSt:symb; St:tid;St:S out list(es(tid; index))g)O�!(fREQUESTO2(eo; e0o(tid; tidsontid1); index)[tid]g; fSt:symb; St:tid; St:S out list(es)g)where tidsontid1 is the tid of the indexth child of the process with tid tid1 and symbsontid1 is its symbol.(75) (fCALCULO1(calculo(eo(tid1; symb1)))g; fSt:symb; St:tid; St:S out list(es(tid; index))g)O�!(fREQUESTO1(eo(St:tid; tid1); e0o(tid; tid1); index)[tid]g; fSt:symb; St:tid; St:S out list(es)g)(76) (fCALCULO(calculo(eo(St:tid; tid1; symb1); es(tid1; tidsontid1; symbsontid1)))g; fSt:symb; St:tid;St:S out list(es(tid; index))g)O�!(fREQUESTO2(eo; e0o(tid; tidsontid1); index)[tid]g; fSt:symb; St:tid; St:S out list(es)g)where tidsontid1 is the tid of the indexth child of the process with tid tid1 and symbsontid1 is its symbol.The following �ve O-transitions describe the processing of an OUTO message depending on the agcontained in the message. In particular, we can see which test is made for each ag and the up-propagationof information if an outgoing orientation edge is added.(77) (fOUTO(eo(tid; symb); listsons; 3)g; fSt:symb; St:O out list; St:S in list(es(tid1; index))g)O�!(fOUTO(e0o(tid1; tid); St:tid; index; 2)g; fSt:symb; St:O out list + eo; St:S in list(es)g)if there exist an outgoing subterm edge from the process receiving the OUTO message to allthe processes of list sons and if the number of elements of list sons is equal to the arity of St:symb.(78) (fOUTO(eo(St:tid; tid); tid1; index; 2))g; fSt:S out list(es(tid1; index)); St:O out list;St:S in list(e0s(tid2; index2))g)O�!(fINO(St:tid)[tid]; OUTO(eo(tid2; tid); St:tid; index; 2)[tid2]g;fSt:S out list(es); St:O out list;St:S in list(e0s)g)(79) (fOUTO(eo(tid); 1)g; fSt:O out list; St:S in list(es(tid1; index))g)O�!(fOUTO(e0o(tid1; tid); St:tid; index; 2)g; fSt:O out list + eo; St:S in list(es)g)The following three O-transitions describe the processing of an INO message. In particular, we can seethe up-propagation of answers when an incoming orientation edge is added.23

(80) (fINO(eo(tid1))g; fSt:O in listg)O�!(fg; fSt:O in list + eo(tid1))g)(81) (fINO(eo(tid1))g; fSt:tid; St:requesto1 list(requesto1(eo(tid1; tid2; symb1; symb2); o0(St:tid; tid1; St:symb;St:tid); index)); St:S in list(es(tid2; index))g)O�!(fANSWERO1(eo; e0o); index)[tid2]g; fSt:tid;St:requesto1 list(requesto1); St:S in list(es)g)where the orientation edge e0o is used to calculate the orientation edge between the process with tid tid1and the process with tid tid2.(82) (fINO(eo(tid1))g; fSt:tid; St:requesto2 list(requesto2(eo(tid1; tid2; symb1; symb2)); e0o(St:tid; tidsontid1;St:symb; symbsontid1); index); St:S in list(es(tid2; index))g)O�!(fANSWERO2(eo; e0o; index;>)[tid2]g; fSt:tid;St:requesto2 list(requesto2); St:S in list(es)g)where the orientation edge e0o is used to calculate the orientation edge between the process with tid tid1and the process with tid tid2.The following four O-transitions describe the processing of a REQUESTO1 message. If the processreceiving the message can answer i.e. there exists an orientation edge or this orientation edge can be easilyadded, answers are propagated up.(83) (fREQUESTO1(requesto1(eo(tid1; tid2; symb1; symb2); e0o(St:tid; tid1; St:symb; symb1); index))g;fSt:tid; St:symb; St:O out list(e0o); St:S in list(es(tid2; index))g)O�!(fOUTO(eo; St:tid; index; 2)[tid2]g; fSt:tid; St:symb; St:O out list(e0o); St:S in list(es)g)(84) (fREQUESTO1(requesto1(eo(tid1; tid2; symb1; symb2); e0o(St:tid; tid1; St:symb; symb1); index))g; fSt:tid;St:symb; St:O in list(e0o); St:S in list(es(tid2; index))g)O�!(fANSWERO1(answero1(eo ; e0o; index))[tid2]g; fSt:tid; St:symb; St:O in list(e0o);St:S in list(es)g)(85) (fREQUESTO1(requesto1(eo(tid1; tid2; symb1; symb2); e0o(St:tid; tid1; St:symb; symb1); index))g; fSt:tid;St:symb; St:O in list; St:S in list(es(tid2; index))g)O�!(fANSWERO1(answero1(eo ; e0o; index))[tid2]g; fSt:tid; St:O in list + e0o;St:S in list(es)g)if there is no orientation edge between the process with tid tid1 and the process with tid St:tidand St:symb is a constant and symb1 is a function symbol or a constant and symb1 > St:symb.24

(86) (fREQUESTO1(requesto1(eo(tid1; tid2; symb1; symb2); e0o(St:tid; tid1; St:symb; symb1); index))g; fSt:tid;St:symb; St:O out list; St:S in list(es(tid2; index)); g)O�!(fOUTO(eo; St:tid; index; 2)[tid2]g; fSt:tid; St:symb; St:O out list + e0o;St:S in list(es)g)if there is no orientation edge between the process with tid St:tid and the process with tid tid1 andsymb1 is a constant and St:symb is a function symbol or a constant and St:symb � symb1.The following two O-transitions express the case where, the process receiving the message can not answer.New orientations requests are then sent to make the information available.(87) (fREQUESTO1(requesto1(eo(tid1; tid2; symb1; symb2); e0o(St:tid; tid1; St:symb; symb1); index))g; fSt:tid;St:symb; St:S in list(e0s(tid2; index)); St:S out list(es(tid3; index3))g)O�!(fREQUESTO1(e0o; e00o (tid1; tid3; symb1; symb3); index3)[tid3]g; fSt:tid;St:symb; St:S in list(e0s); St:S out list(es)g)if there is no orientation edge between the process with tid tid1 and the process with tid St:tid andSt:symb and symb1 are function symbols and St:symb < symb1.(88) (fREQUESTO1(requesto1(eo(tid1; tid2; symb1; symb2); e0o(St:tid; tid1; St:symb; symb1); index))g; fSt:tid;St:symb; St:S in list(e0s(tid2; index)); St:S out list(es(tid3; index3))g)O�!(fCALCULO(calculo(e0o; es)[tid1]g; fSt:tid; St:symb; St:S in list(e0s); St:S out list(es)g)if there is no orientation edge between the process with tid tid1 and the process with tid St:tid andSt:symb and symb1 are function symbols and St:symb � symb1.O-transitions are similar for a REQUESTO2 messages and we do not express them.The following three O-transitions shows the processing of an ANSWERO1 message. In particular, thisANSWERO1 message permits the process receiving it to orient an orientation edge between two processeshaving di�erent symbols such that its direction is incoming.(89) (fANSWERO1(answero1(eo(tid1; St:tid; symb1; St:symb); e0o(tid2; tid1; symb1; symb2); index))g; fSt:tid;St:symb; St:S out list(es(tid2; index)); St:O in list)g)O�!(fOUTO(eo(St:tid); 1)[tid]g; fSt:tid; St:symb; St:S out list(es); St:O in list + eog)if there is no orientation edge between the process with tid tid1 and the process with tid St:tid and theif orientation edge e0o to calculate is between the process with tid1 and the process with St:tid and thenumber of messages ANSWERO1 received for calculating the orientation of eo is equal to the arity ofthe symbol St:symb.(90) (fANSWERO1(answero1(eo(tid1; St:tid; symb1; St:symb); e0o(tid2; tid1; symb1; symb2); index)); fSt:tid;fSt:symb; St:S out list(es(tid2; index)); St:S in list(e0s(tid3; index3)); St:requesto1 list(requesto1(eo ;e00o (tid1; tid3; symb1; symb3); index3))g)O�!(fANSWERO1(eo; e00o ; index3)[tid3]g; fSt:S out list(es); S in list(e0s); St:requesto1 list(requesto1)g)The same conditions as in (89). 25

(91) (fANSWERO1(answero1(eo(tid1; St:tid; symb1; St:symb); e0o(tid2; tid1; symb1; symb2); index)); fSt:tid;fSt:symb; St:S out list(es(tid2; index)); St:S in list(es(tid3; index3)); St:requesto2 list(requesto2(eo ;e00o (tid4; tid3; symb4; symb3); index3))g)O�!(fANSWERO2(eo; e00o ; index3; >)[tid20]g; fSt:S out list(es); S in list(e0s); St:requesto2 list(requesto2)g)The same conditions as in (89). In addition, the process with tid tid1 is the index3th child of the processwith tid tid4.The following six O-transitions deal with the processing of an ANSWERO1 or ANSWERO2 message, inparticular, when these messages permit the process receiving them to orient an orientation edge betweentwo processes having the same symbol such that its direction is incoming.(92) (fANSWERO2(answero2(eo(St:tid; tid1); e0o(tid2; tidsontid1); index;>))g; fSt:tid; St:symb;St:S out list(es(tid2; index)); St:O in listg)O�!(fOUTO(eo(St:tid); 1)[tid1]g; fSt:tid; St:symb; St:S out list(es); St:O in list + eog)if symb1 = St:symb and there is no orientation edge eo between the process with tid tid1 p1 and the processwith tid St:tid and the number of ANSWERO1 received messages is equal to the arity of the symbol St:symband if the ANSWERO2 received messages from the �rst k children of process with tid St:tid contain = andthe ANSWERO2 received messages from its k + 1th children contain +, where k 2 f0::n� 1g. The processwith tid tidsontid1 is the indexth child of the process with tid tid1.(93) (fANSWERO2(answero2(eo(St:tid; tid1); e0o(tid2; tidsontid1); index;>))g; fSt:tid; St:symb;St:S out list(es(tid2; index)); St:S in list(e0s(tid3; index3)); St:requesto1 list(requesto1(eo ; e00o (tid3; tid1);index3))g)O�!(fANSWERO1(eo; e00o ; index3)[tid3]g; fSt:tid; St:symb; St:S out list(es); St:S in list(e0s);St:requesto1 list(requesto1); St:S in list(es)g)The same conditions as in (92).(94) (fANSWERO2(answero2(eo(St:tid; tid1); e0o(tid2; tidsontid1); index;>))g; fSt:tid; St:symb;St:S out list(es(tid2; index)); St:S in list(e0s(tid3; index3)); St:requesto2 list(requesto2(eo ; e00o (tid3; tid5);index3))g)O�!(fANSWERO2(eo; e00o ; index3; >)[tid3]g; fSt:tid; St:symb; St:S out list(es); St:S in list(e0s);St:requesto2 list(requesto2); St:S out list(es)g)The same conditions as in (92). In addition, the process with tid tid1 is the index3th child of the processwith tid tid5.(95) (fANSWERO1(answero1(eo(St:tid; tid1; symb1); e0o(tid1; tid2; symb2); index))g; fSt:tid; St:symb;St:S out list(es(tid2; index)); St:O in listg)O�!(fOUTO(eo(St:tid); 1)[tid1]g; fSt:tid; St:symb; St:S out list(es); St:O in list + eog)The same conditions as in (92). 26

(96) (fANSWERO1(answero1(eo(St:tid; tid1; symb1); e0o(tid1; tid2; symb2); index))g;fSt:tid; St:S out list(es(tid2; index)); St:S in list(e0s(tid3; index3));St:requesto1 list(requesto1(e0o ; e00o (tid1; tid3))); St:S out list(es(tid2; index))g)O�!(fANSWERO1(e0o; e00o (tid3; tid1); index3)[tid3]g; fSt:requesto1 list(requesto1); St:S out list(es);S in list(e0s)g)The same conditions as in (92).(97) (fANSWERO1(answero1(eo(St:tid; tid1; symb1); e0o(tid1; tid2; symb2); index))g;fSt:tid; St:S out list(es(tid2; index)); St:S in list(e0s(tid3; index3));St:requesto2 list(requesto2(e0o ; e00o (tid3; tid4))); St:S out list(es(tid2; index))g)O�!(fANSWERO2(e0o; e00o (tid3; tid4); index3; >)[tid3]g;fSt:requesto2 list(requesto2); St:S out list(es);S in list(e0s)g)The same conditions as in (92). In addition, the process with tid tid1 is the index3th child process of tid4.The two last O-transitions concern the processing of an ANSWERO1 or ANSWERO2 message. Inparticular, these messages tell the process receiving them to orient an orientation edge between two processeshaving the same symbol such that its direction is "equal".(98) (fANSWERO2(answero2(eo(tid2; tid3); e0o(St:tid; tid1; St:symb; symb1); index;=))g; fSt:tid;St:S out list(es(tid2; index)); St:O eq listg)O�!(fg; fSt:tid; St:S out list(es); St:O eq list + e0og)if symb1 = St:symb and the process with tid St:tid has received n messages ANSWERO2containing = from its n children and n is the arity of St:symb.(99) (fANSWERO2(answero2(eo(tid2; tid3); e0o(St:tid; tid1; St:symb; symb1); index;=))g; fSt:tid;St:S out list(es(tid2; index)); St:S in list(e0s(index0; tid0))g)O�!(fOUTO(e0o(St:tid; tid1); St:tid; index; 2)[tid0]g; fSt:tid; St:S out list(es); St:S in list(e0s)g)The same conditions as in (98).The completeness results of this set of rules for our concurrent Orientation calculation are given insection 3.6.3.4 Detection of the termination of the programIt is di�cult to detect termination of an asynchronous concurrent program, because a process cannot detectthat it will not receive any more messages. We give a termination detection algorithm di�erent from theclassical one [DFvG83]. Indeed, we do not need any broadcast and the termination is evaluated by a mailboxreceiving messages.The general de�nition of the termination of a concurrent program is given in de�nition 2.De�nition 2 The program terminates when all processes are idle and all sent messages have been received.Our termination detection algorithm uses a mailbox, which can be handled by the root process. It isbased on the following principles. 27

Sent and received messages are noti�ed to the mailbox using a message called NOTIFY. In practice, amessage can be speci�ed in the mailbox as received and not yet as sent. The mailbox contains envelopes ofsent or received messages. An envelope is composed of a ag SENT or RECEIVED for a sent or receivedmessage mesg, the source process of mesg, the destination process of mesg and an identi�cation number,permitting us to distinguish two messages having the same origin, the same destination and the same contents.So, an envelope is one of the following forms: (pi; pj; NB; SENT ) for message NB sent by process pi topj, and (pj; pi; NB;RECEIV ED) for message NB received by process pi from pj. A mailbox consists oftwo lists: list sent, which contains envelopes of messages speci�ed as sent but not received and list received,which contains envelopes of messages speci�ed as received but not sent. So we can consider the state of themailbox or of the root process as the record of these two lists.Processes cycle from idle to busy to idle. The busy state is entered when a message is received. Othermessages are sent as a result of this message. In the busy state, other messages may be received and messagesare sent as a result of them. When the process re-enters the idle state, it sends the mailbox one NOTIFYmessage for each message received in that cycle. The NOTIFYmessage contains one envelope for the receivedmessage, and an envelope for each message sent as a result of this received message. We call this statementstatement 1. This fact is crucial for the soundness of our termination detection algorithm.The main question is now to detect termination. The condition of termination is that list sent andlist received are empty.When the mailbox receives a message NOTIFY containing an envelope (pi; pj; NB; SENT ), the mate ofthis envelope (pj; pi; NB;RECEIV ED) is searched for in the list list received. If the envelope (pj; pi; NB;RECEIV ED) does not belong to this list, (pi; pj; NB; SENT ) is added to the list list sent, otherwise(pj ; pi; NB;RECEIV ED) is deleted from list received.When the mailbox receives a message NOTIFY containing an envelope (pi; pj; NB;RECEIV ED), itsmate envelope (pj ; pi; NB; SENT ) is removed from list sent, if it belongs to this list otherwise (pi; pj; NB;RECEIV ED) is added to the list list received.Initially, list sent contains all the envelopes of SENT messages of the Initialization phase. This ensuresthe soundness of the algorithm.De�nition 3 A t-transition is an �-transition for the calculation of termination concerning the mailbox.The termination algorithm can be expressed using the following t-transition.(100) (fNOTIFY ((pi; p;NB;RECEIVED); (p; pj; NB0; SENT ); (p; pk; NB00; SENT ); : : :)g;fSt:list received((p; pj ; NB0; RECEIV ED)); St:list sent((pi; p;NB; SENT ))g)t�!(fg; fSt:list received � (p; pj; NB0; RECEIV ED); St:list sent + (p; pk; NB00; SENT )�(p; pj; NB0; SENT )� : : :g)where St is the state of the mailbox p which receives the message NOTIFY and pi, pj and pk areprocesses.We introduce lemma 1 that will permit us to prove the soundness of the termination.Message passing between processes can be viewed as a tree such that each node is a son process and eachedge represents the passing of a message between two processes. Edges are labelled with the message. Theroot of the constructed tree is a particular process: the main process, and it appears only once in the tree.If the program terminates, this tree is �nite else it is in�nite. On this tree, we de�ne the measure �. For amessage mesg of the tree, �(mesg) is the depth of the node, which represents the process P , which receivesmesg. For example, for an initialization message mesginit, �(mesginit) = 1.Lemma 1 For all n, if list sent and list received contain only messages mesg such that �(mesg) � n, thenall messages mesg such that �(mesg) < n have already been processed by the mailbox.Proof:To prove this lemma, we proceed by induction on n.n = 2 : 28

If list sent and list received contain only messages mesg such that �(mesg) � 2, then list sent andlist received have already contained all messages of initialization mesginit such that �(mesginit) = 1,because initially, list sent and list received contains all the envelopes of sent messages of the Initializa-tion phase. So, all messages of initialization have been speci�ed as sent and received in the mailbox.Also, because of statement 1, all messages mesg such that �(mesg) = 2 have been noti�ed to themailbox as sent. So, messages with �-measure less than 2 have already been processed by the mailbox.n > 2 :The induction hypothesis is that: if list sent and list received contain only messages mesg such that�(mesg) � n, then all messages mesg such that �(mesg) < n have already been processed by themailbox.We assume that if list sent and list received contain only messages mesg such that �(mesg) � n+ 1,and we will prove that all messages mesg such that �(mesg) < n + 1 have already been processed bythe mailbox.If list sent and list received contain only messages mesg such that �(mesg) � n + 1, then by theinduction hypothesis, all messages mesg such that �(mesg) < n have already been processed by themailbox. network.Furthermore, if list sent and list received contain only messages mesg such that �(mesg) � n+1, thenlist sent and list received have already processed all messages mesg such that �(mesg) = n. So allmessages mesg sent such that �(mesg) = n were in the mailbox as sent and received and because ofstatement 1, all sent messages with a �-measure equal to n + 1 have appeared in the mailbox. Now,all messages mesg such that �(mesg) < n + 1 have already been processed by the mailbox. 2Theorem 1 The program is terminated i� list sent and list received are empty.Proof:) It is trivial that if the program is terminated, then list sent and list received are empty, becauseall messages which have been sent, have been received.( The reverse is not trivial.We proceed by contradiction. Suppose that list sent and list received are empty but program does notterminate. Then, we consider two cases:� There is a message mesg in the network such that �(mesg) = n. By considering lemma 1, allmessages such that �(mesg) = n have already been processed. We meet then a contradiction.� There is a busy process. At the end of the busy state of the process, the process sent a NOTIFYmessage to the mailbox. Suppose that this noti�cation message contains a message mesg suchthat �(mesg) = n. By considering lemma 1, all messages such that �(mesg) = n have alreadybeen processed. We meet then a contradiction.Contradictions prove that if list sent and list received are empty, the program terminates.23.5 Time Stamps3.5.1 Why are time stamps needed?In our approach, when an inference is performed, it is not necessary that other processes know about thisinference immediately. We are allowed to use old information. That is why a concurrent algorithm is possible.However, we use time stamps to insure that an inference with a term is not performed using new informationfollowed by another inference using an old version of that term. Time stamps prevent this from happening.Since operations like Uni�cation and Orientation are distributed among subterms, we need the time stampsto compare when operations are performed.Consider the following example. 29

Example 1 Let E = fg(f(a)) � b; f(a) � f(b); a � cg. be the set of equations to complete. Consider theprecedence g � f � c � b � a. The set of equations E can be represented by the SOUR graph of �gure 7.S S

f

b

g

f

a

S

SS

R

R

f

b

g

f

a c

R

R

p2

c

p6p5p4

R

p1

R

p3

U U

UFigure 7: The SOUR Graph representing E and the result of the execution planConsider the following execution plan:� Process p3 detects an SUR con�guration conf1 and sends it to process p1.� Process p5 detects an SUR con�guration conf2 and sends it to process p3.� Process p3 receives the SUR con�guration conf2 and processes it.� Process p3 changes the direction of its rewrite edge because f(b) � f(c), after a sequence of messages.� Process p1 receives a message from p3 to tell it to change the direction of its rewrite edge becauseb � g(f(c)).� Process p4 has got an outgoing rewrite edge and detects an SUR con�guration conf3 that it sends top2.� Process p1 receives and processes the SUR con�guration conf1 so adds a subterm edge from processp1 to process p2.� Process p2 receives and processes the SUR con�guration conf3 so adds a subterm edge from p2 toprocess p1.� On the graph, we notice a cycle of subterm edges.To prevent this critical case, we use Time Stamps.3.5.2 Time stamps de�nition and usageDe�nition 4 The time stamp of a process is a counter initialized to 0. We denote the current time stampof a process p by TSp.Each process p contains a time stamp TSp and a table of time stamps that we denote TS Tablep. Thetable has n entries, where n is the arity of the symbol of p. For process p0, TS Tablep[p0] is the last timestamp TSp0 of process p0 known by p, initially 0. When p sends a message to one of its parent processes, itsends its current time stamp TSp in the message.Uni�cation and orientation edges now contain a new kind of information.A uni�cation edge betweenprocesses p and p0 has two time stamps associated with it: the time stamps of the processes at the ends ofthe edge. These time stamps are stored in p and p0. The same thing is done for orientation edges.30

Use of time stamps for the creation of con�gurations: Consider a semi-con�guration containing arewrite edge r from process p3 to process p4 and a uni�cation edge between processes p2 and p3.� This semi con�guration is sent to p2 only if the calculation of the direction of the rewrite edge r givesthat r is from p3 to p4 and the calculation of Uni�cation for the uni�cation edge u between p2 andp3 gives a true uni�cation constraint and the time stamp of p3 used for calculating Uni�cation is thesame as the time stamp of p3 used for calculating Orientation. The message SEMICONF is sent to p2containing the time stamp of p2 used to calculate Uni�cation. Let t be this time stamp.� When p2 receives the message SEMICONF, it sends to process p1 a message CONFIG only if TSp2 = t.� If process p1 receives a message CONFIG containing an SUR con�guration, it processes it only ifthe subterm edge in the message still exists and TS Tablep1 [p2] = t or TS Tablep1 [p2] < t. Then, ifTS Tablep1 [p2] < t, TSp1 is incremented and TS Tablep1 is updated so that TS Tablep1 [p2] = t.� When process p1 receives a message CONFIG containing an RUR or an RUR-rhs con�guration, itprocesses it only if the incoming or the outgoing rewrite edge respectively still exists.Use of time stamps for Uni�cation : Suppose that we want to calculate the Uni�cation constraint ofuni�cation edge u between process p0 and process p1, such that p1 decides the calculation.Suppose that process p2 (kth child process of p1) receives a request REQUESTU asking if there isa uni�cation edge with constraint true between processes p2 and p3 (kth child process of p0). AnswersANSWERU will be sent to p1 (for conditions of this sending see section 3.2). Answer messages contain t2and t3 the last time stamps of p2 and p3 used in the calculation of the uni�cation constraint between p2 andp3. � When p1 receives an answer ANSWERU from p2 containing time stamps t2 and t3, the answer messageis processed only if the following conditions are respected:| There is a subterm edge going from p1 to p2 with index k.| TS Tablep1 [p2] = t2 or TS Tablep1 [p2] < t2. For this second case, TS Tablep1 is updated, suchthat TS Tablep1 [p2] = t2 and the current time stamp of p1 is incremented.� If an answer message permits us to determine that the uni�cation constraint of the uni�cation edge ubetween p0 and p1 is true i.e. n answer messages have been received by p1 where n is the arity of thesymbol of p1, then the message INITU corresponding to the fact that the uni�cation constraint of u istrue, is sent to p0 containing t3.� When p0 receives from p1 a message INITU containing the time stamp t3, this message is processedonly if the following conditions are respected:| There is a subterm edge going from p0 to p3 with index k.| TS Tablep0 [p3] = t3 or TS Tablep0 [p3] < t3. For this second case, TS Tablep0 is updated, suchthat TS Tablep0 [p3] = t3 and the current time stamp of p0 is incremented.Use of time stamps for Orientation: Use of time stamps for Orientation is similar to the use of timestamps for Uni�cation.Example 2Consider the preceding example and the preceding execution plan. We now use time stamps and we obtainthe following results.� Process p3 detects an SUR con�guration conf1 and sends it to process p1. The corresponding messageCONFIG contains the time stamp TSp3 (= 0). Let t3 = TSp3 .� Process p5 detects an SUR con�guration conf2 and sends it to process p3. The corresponding messageCONFIG contains the time stamp TSp5 (= 0). Let t5 = TSp5 .31

� Process p3 receives the SUR con�guration conf2 and processes it, because TS Tablep3 [p5] = t5(= 0)(Process p5 will never change its time stamp). A con�guration is processed, so p3 increments its timestamp, TSp3 = TSp3 + 1(= 1).� Process p3 changes the direction of its rewrite edge because f(b) � f(c), using a message INO of p1with a time stamp equal to 0.� Process p1 receives a message from p3 to tell it to change the direction of its rewrite edge because b �g(f(c)). This message contains the last time stamp of p3 equal to 1. We have TS Tablep1 [p3](= 0) < 1,so the message is processed, TS Tablep1 [p3] = 1, TSp1 is incremented by one.� Process p4 has got an outgoing rewrite edge and detects an SUR con�guration conf3 that it sends top2. This con�guration is sent with time stamp TSp4(= 0).� Process p1 receives the SUR con�guration conf1 containing the time stamp t3(= 0). This con�gurationis forgotten because it is an old information TS Tablep1 [p3](= 1) > t3(= 0).� Process p2 receives and processes the SUR con�guration conf3 so adds a subterm edge from p2 toprocess p1. There is no more cycle of subterm edges.3.5.3 Semantics of a time stamped ground SOUR GraphDe�nition 5 We de�ne the semantics of the term representing process p by T (p; TSp), where TSp is thecurrent time stamp of process p. We have: T (p; TSp) = f(T (p1; t1); : : : ; T (pn; tn)) where:� f is the symbol of process p.� pi are processes such that there exists a subterm edge going from p to pi, when the time stamp of p isTSp with index i.� ti = TS Tablep[pi], the last time stamp of pi known by p, 8i 2 f1; : : : ; ng.Remark 1 If at a given time, process p has got an outgoing subterm edge to pi such that the time stampof p is TSp and TS Tablep[pi] = ti and the time stamp of pi is TSpi , then ti � TSpi , because ti is the lasttime stamp of pi known by p.Using time stamps, we have the following results.Lemma 2 For all time stamps t and t0 such that t0 < t, and for all processes p, we have: T (p; t0) � T (p; t).Proof:To prove this lemma, we proceed by induction on the depth of the processed con�guration in the term.Initial case:Consider a process p. Let t be TSp. The semantics of the term of p is: T (p; t) = f(T (p1; t1)); : : : ; T (pi; ti);: : : ; T (pn; tn)), where f is the symbol of p and 8k 2 f1; : : : ; ng; TS Tablep[pk] = tk.Suppose that p receives an SUR con�guration in a message CONFIG and processes it. This con�g-uration is described by: There is an outgoing subterm edge from process p to process pi, there is anoutgoing rewrite edge from process pi to process pj . We consider here an SUR con�guration withoutuni�cation edge, but it is similar with an SUR con�guration with a uni�cation edge.The time stamp of p changes to TSp = t+ 1.The semantics of the new term of p is: T (p; TSp) = f(T (p1; t1); : : : ; T (pj; tj); : : : ;T (pn; tn)), where tj = TS Table[pj].The con�guration was processed, so the time stamp contained in the message CONFIG is equal to orlarger than TS Table[pi], furthermore T (p; t) � T (pi; ti), using the subterm property and T (pi; ti) �T (pj; tj), because of the rewrite edge. 32

T (pi; ti) � T (pj ; tj) implies that T (p; TSp) � T (p; t). As t < TSp and T (p; TSp) � T (p; t), the lemmais proved for the initial case.General case:Suppose that the time stamp of p changes now, because its TS Table changes.The reason of this change is that the semantics of a subterm of p changed due to the processing of anSUR con�guration.The induction hypothesis is that for all processes p0 such that there exists a chain of subterm edgesgoing from p to p0 the lemma is veri�ed.Let p1 be the subterm changing the semantic of p. We can apply the induction hypothesis to p1 i.e.the term of process p1 is replaced by a smaller term. So the term of p is getting smaller and this provesthe lemma.2De�nition 6 The term of a process is persisting, if the time stamp of the process is persisting.Corollary 1 For each process, its term becomes persisting.Proof: Using lemma 2 for a process p, in particular, T (p; TSp) � T (p; TSp + 1). As LPO is well-founded,the term of p is getting smaller and becomes persisting so the node becomes persisting. 2Theorem 2 Our concurrent completion using ground SOUR graphs terminates.Proof: This theorem is a consequence of the precedent corollary. 23.6 Soundness and Completeness ResultsIn this section, we give results for the soundness and completeness of our concurrent calculation of Uni�cationand Orientation. Also, we give results for the soundness and the completeness for our concurrent Completionusing SOUR graphs.Let E be the equational theory the graph represents.3.6.1 Soundness ResultsThis section contains the de�nitions and the proofs of the soundness of the concurrent uni�cation and of ourconcurrent completion using SOUR graphs.De�nition 7 A concurrent SOUR graph is a set of processes and their states.De�nition 8 A coucurrent sound SOUR graph is such that if there exists a uni�cation edge with a Trueuni�cation constraint or a rewrite edge between two terms s and t then s =E t and no subterm is added suchthat a cycle of subterm edges is created.De�nition 9 G0, : : : Gn is a SOUR Graph derivation, where G0 is the initial SOUR graph and each Giis a concurrent SOUR graph forall i 2 f0; : : : ; ng and Gi+1 is obtained from Gi by the processing of acon�guration of Gi forall i 2 f1; : : : ; n� 1g.De�nition 10 Concurrent uni�cation is sound if for all derivations G0,: : :,Gn, forall i 2 f0; : : : ; ng andfor all uni�cation edges of Gi between a process with term s and a process with term t with True uni�cationconstraint, we have s =E t.De�nition 11 Our concurrent completion using SOUR graphs is sound if for all derivations G0,: : :,Gn,forall i 2 f0; : : : ; ng, Gi is sound.Lemma 3 If G is a sound SOUR graph, if one process of G processes a con�guration, the obtained SOURgraph is sound. 33

Proof: To prove the lemma, we prove each statements separately.1. We �rst prove that, if a rewrite edge is added between process p with term s and the process withterm t on the sound SOUR graph G, then s =E t.A rewrite edge is added, when an RUR con�guration or an RUR-rhs con�guration is processed.If a con�guration RUR-rhs is processed i.e. at a certain time, the schema of Figure 8 takes place,a rewrite edge is added between the process with term s and the process with term t. We mustprove that s =E t. As G is sound, we have s =E v, v0 =E t and v =E v0. By transitivity, weobtain s =E t.U

RR

u = T

s t

v v’Figure 8: Processing of a con�guration RUR-rhsIf a con�guration RUR is processed i.e. at a certain time, the schema of �gure 9 takes place, arewrite edge is added between the process with term s and the process with term t (The orientationof this edge depends on whether s �lpo t or t �lpo s). We must prove that s =E t. As G is sound, we have s =E v, v0 =E t and v =E v0. By transitivity, we obtain s =E t.U

RR

v’v

s tFigure 9: Processing of a con�guration RUR2. We now prove that if a subterm edge is added to p on the sound SOUR graph G and p's newterm is s0 and if there is a rewrite edge between p and the process with term t then s0 =E t.If a con�guration SUR is processed i.e. at a certain time, the schema of Figure 10 takes place,a subterm edge is added between the process with term w0 and the process with term w. Wemust prove that s[w0[w]] =E t. As G is sound, we have v0 =E w, s[w0[v]] =E t and v =E v0. Bytransitivity, we obtain s[w0[w]] =E t.U

R

u = T

Sindex

S

S

s t

v v’

ww’Figure 10: Processing of a con�guration SUR3. If a subterm edge is added between the process p with term s and the process p0 on the soundSOUR graph G and if there is a uni�cation edge between process p with its new term s0 andprocess with term t, then s0 =E t. This statement is proved in the same way as the previousstatement. 34

4. We now prove that if a uni�cation edge with a True uni�cation is added between two processeswith terms s and t on the sound SOUR graph G, then s =E t.Suppose there is a uni�cation edge with a uni�cation constraint True between two processesrepresenting terms f(s1; : : : ; sn) and f(t1; : : : ; tn). So one of these processes has got informationthat there are uni�cation edges with constraints True between si and ti for i 2 f1; : : : ; ng (see rules(28) to (31)). By soundness of G, si =E ti for i 2 f1; : : : ; ng, so f(s1; : : : ; sn) =E f(t1; : : : ; tn) bythe congruence property of =E .5. We now prove that no subterm is added on a sound SOUR graph G such that a cycle of subtermedges is created using Figure 11. Indeed, the processing of an SUR con�guration is the only wayto create a cycle of subterms edges. Here we consider the case where the SUR con�guration doesnot contain any uni�cation edge ,but the proof is similar when the SUR con�guration contains auni�cation edge. Using this �gure, we will prove that it is impossible to add a subterm edge fromp2 to pn.In �gure 11, TSpn , TSpn�1 , : : :, TSp2 and TSp1 are the current time stamps of processes pn, pn�1,: : :, p2 and p1 in a concurrent SOUR graph G.Let t1 = TS Tablep2 [p1], : : :, tn2 = TS Tablepn�1 [pn�2], tn�1 = TS Tablepn [pn�1].S

S

S

pn-1

p n

p1

p2

...

RFigure 11:In Figure 11, we have: T (pn; tn) �lpo T (pn�1; tn�1) �lpo : : : �lpo T (p2; tp2) �lpo T (p1; t1) (1).We prove that 8i 2 f1; : : : ; n� 1g; T (pi+1; TSpi+1 ) �lpo T (pi; TSpi).We have T (pi+1; TSpi+1 ) �lpo T (pi; ti) by the subterm property. Furthermore, using lemma 2, asTSpi � ti, T (pi; ti) �lpo T (pi; TSpi) and by transitivity, T (pi+1; TSpi+1) �lpo T (pi; TSpi)An SUR con�guration, containing a subterm edge from p2 to p1 and a rewrite edge from p1 topn, is detected by process p1 and sent to process p2. When process p2 receives this con�guration,and if it processes it, by the subterm property, T (p2; TSp2) �lpo T (p1; t1). In addition, becauseof the rewrite edge and if we freeze the system, we have: 9t; T (p2; TSp2) �lpo T (pn; t) such thatt = TS Tablep1 [pn] when the time stamp of p1 is TS Tablep2 [p1] and the time stamp of p2 isTSp2 . If TSpn is the current time stamp of pn when the SUR con�guration is received, TSpn � tand using lemma 2, we can deduce that: T (pn; t) �lpo T (pn; TSpn ).As T (p2; TSp2) �lpo T (pn; t) and T (pn; t) �lpo T (pn; TSpn), we have by transitivity : T (p2; TSp2 ) �lpoT (pn; TSpn) (2), which is in contradiction with (1). So it is impossible to have a schema like in�gure 11, so to create a cycle of subterm edges. This proves the lemma.2Theorem 3 Our concurrent completion using SOUR Graphs is sound.Proof: By induction, the base case is trivial, and the induction step follows immediately from lemma 3. 2Corollary 2 Concurrent Uni�cation is sound.Proof: By induction, the base case is trivial, and the induction step follows immediately from lemma 3. 235

3.6.2 Completeness ResultsThis section contains the de�nitions and the proofs of the completeness of the concurrent uni�cation, of theconcurrent orientation and of our concurrent completion using SOUR Graphs.De�nition 12 Concurrent uni�cation is complete if whenever s and t are persisting terms and s and t areuni�able, then at some time the uni�cation edge between the processes representing terms s and t will havea True uni�cation constraint.De�nition 13 The concurrent computation of orientation is complete if whenever s and t are persistingterms and s �lpo t then, at some time, the orientation edge between processes representing terms s and tgoes from s to t and does not change.De�nition 14 Our concurrent completion using SOUR Graphs is complete, if there are no con�gurationbetween persisting nodes.Theorem 4 Concurrent uni�cation is complete.Proof: To prove completeness, we proceed by structural induction on the pairs of terms of the SOUR graph.Base case:If we consider terms s and t as constants, the result is trivial.Induction step:Suppose terms s = f(s1; : : : ; sn) and t = f(t1; : : : ; tn) are persisting forms and are uni�able, so si andti are persisting forms and are uni�able for i 2 f1; : : : ; ng. The induction hypothesis is that for allterms structurally less complex than f(s1; : : : ; sn) and f(t1; : : : ; tn), the statement for completenessbecomes True. By the induction hypothesis, there are uni�cation edges with uni�cation constraintsTrue between si and ti for i 2 f1; : : : ; ng. By passing up information (see rules (28) to (31)), theconstraint of the uni�cation edge between s and t becomes True. It is clear, that information fromchildren processes will not be ignored, because time stamps of children are persisting. this is becausethe TS tables information of processes receiving information from their children is not in contradictionwith the time stamps contained in messages passing up. 2Theorem 5 The concurrent computation of orientation is complete.Proof: To prove completeness, we proceed by structural induction on the pairs of terms in the SOUR graph.Base case:If we consider terms s and t as constants, the result is trivial (see rules (64) and (85) for instance).Induction step:The induction hypothesis is that for all terms structurally less complex than s = f(s1; : : : ; sn) andt = g(t1; : : : ; tm), the statement for completeness is True.� Suppose that terms s = f(s1; : : : ; sn) and t = g(t1; : : : ; tm) are persisting forms and s �lpo t suchthat f > g and 8j 2 f1; : : : ;mg; s �lpo tj. Each tj is a persisting form for j 2 f1; : : : ;mg. By theinduction hypothesis, at some time and for j 2 f1; : : : ;mg, the orientation edge between processesrepresenting terms s and tj goes from s to tj. By passing up information (see rules (64) and (85)for instance), the process representing term t will know all this information, and using rule (89), itwill add a new orientation edge from the process representing terms s to the process representingterm t.� Suppose that terms s = f(s1; : : : ; sn) and t = g(t1; : : : ; tm) are persisting forms and s �lpo t suchthat 9i 2 f1; : : : ; ng; si �lpo t. Each si is a persisting form. By the induction hypothesis, at sometime, the orientation edge between the processes representing terms si and t goes from si to t.By passing up information (see rules (63) and (78) for instance), the process representing term swill add a new orientation edge from the process representing term s to the process representingterm t. 36

� Suppose that terms s = f(s1; : : : ; sn) and t = g(t1; : : : ; tm) are persisting forms and s �lpo tsuch that f = g, n = m, 8i 2 f1; : : : ; ng; s �lpo ti, and (s1; : : : ; sn) �lex (t1; : : : ; tn) such thatsj �lpo tj and 8k < j; sk = tk. So si and ti are persisting forms for i 2 f1; : : : ; ng. By theinduction hypothesis, at some time, for k 2 f1; : : : ; ng, the orientation edges between processesrepresenting terms s and tk go from s to tk, the orientation edge between processes representingterms sj and tj goes from sj to tj, and the orientation edge between the processes representingterms si and ti for i 2 f1; : : : ; j � 1g is an "equal" orientation edge. By passing up information(see rules (64), (66) and (67) for instance), the process representing term s will know all thisinformation and using rules (92) and (99), it will add a new orientation edge from the processrepresenting term s to the process representing term t.It is clear, that information from child processes will not be ignored, because time stamps of childrenare persisting. Indeed, the TS tables information of processes receiving information from their childrenis not in contradiction with the time stamps containing in messages passing up.2Theorem 6 Our concurrent completion using SOUR Graphs is complete.Proof: To prove completeness, we proceed by contradiction. Assume that node n1 and n2 are persisting,and that node n1 has an SUR con�guration to process. So node n1 is not persisting. This prove thecompleteness.24 Implementation and Experimental ResultsWe call CWD the concurrent implementation of completion using SOUR Graphs and all the concurrentoperations that we describe. It implements the D,P,U and O transitions rules mentioned in this paper.CWD is currently implemented in C++ (about 15000 lines of commented C++) using LEDA (Libraryof E�cient Data types) and PVM (Parallel Virtual Machine). It is tested on a network of Unix and SolarisSun4Stations (Sparc5, Sparc10, Sparc20), and Sgi Indy Workstations (processor R4400, 200 MHz, 64 Mb)and on a Power Challenge Array (PCA) (8 R8000 processors at 90 MHz and 160 Mb).We try to make some optimizations on the implementation, we have expressed them in the paper and wesummarize them in the following points.� The number of messages has been limited. Indeed, communications take most of the running time ofa distributed program.Identical requests messages (REQUESTU, REQUESTO1, and REQUESTO2 messages), con�gurations(CONFIG messages) and INFOU messages are sent only once.� Uni�cation and Orientation are evaluated by a request-answer method.� Uni�cation is evaluated only when it is needed i.e. there exists a uni�cation edge adjacent to anoutgoing rewrite edge.� Out-of-date messages are not processed.� A message is redundant if its contents is already present in the sate of the process receiving it.For example, if a INITS message containing an incoming rewrite edge is received and if the processreceiving this message has this rewrite edge in its state, there is no need to process the message.Consequences of this messages have already been done.Experimental Results : Measurements have been made with many benchmark examples. Table 1 showsa selection of results of measurements obtained on di�erent platforms for four particular problems. Table 1summarizes, for each problem, the platform we use, the total number of messages sent between processes,the total number of NOTIFY messages (used for detecting termination), and the real time of execution givenin seconds. 37

Example1 [GNP+93]: Counter5Precedence : f � g � c.Set of equations : E = ff(c) = g(c) ; f(g(c)) = g(f(c)); f(g(g(c)) = g(f(f(c))); f(g(g(g(c))) =g(f(f(f(c)))); f(g(g(g(g(c))))) = g(f(f(f(f (c)))))gNumber of child processes (the number of vertices of the initial graph representing the set of equations tocomplete) : 17The reason that the counter example is interesting is that for some strategies of completion it runsexponentially, even if structure sharing is used.Example2: expf6Precedence : aa � ab � ac � ad � ae � af � ag � f � b.Set of equations : E = faa = f(ab; ab; ab; ab; ab; ab); ab = f(ac; ac; ac; ac; ac; ac);ac = f(ad; ad; ad; ad; ad; ad); ad = f(ae; ae; ae; ae; ae; ae); ae = f(af; af; af; af; af; af);af = f(ag; ag; ag; ag; ag; ag); f(aa; aa; aa; aa; aa; aa) = bg.Number of child processes: 15This example is interesting, because terms resulting rules are exponential. Because of structure sharing, wedo not have this problem. On this example, OTTER-3.0 runs out of memory after 20 minutes on a Digitalserver with 2 CPUs and 256 Mb of Main Memory. PaReDux also gives no result for this example, becauseof the number of reclaimed cells.Example3:Precedence : a > b > c > d > e > f > g > h > j > k > l Set of equations :E = fa = b; a = c; f(a) = d; g(a; a) = h(b; c); k(a; c; d) = k(f(a); d; g(a; a)); j(f(b)) = j(g(a; b)); f(c) =g(f(a); g(b; c)); l(a; b) = e; l(g(f(a); f(b)); a) = eg.Number of child processes: 20Problem Platform Completion Messages Termination Messages Real timeCounter5 1 Sun4 582 627 13.00 sCounter5 5 Sun4 470 514 4.00 sCounter5 10 Sun4 648 696 3.62 sCounter5 15 Sun4 616 663 3.23 sCounter5 5 Sgi 500 545 4.77 sCounter5 PCA 594 639 1.88 sExpf6 1 Sun4 724 822 11.00 sExpf6 5 Sun4 737 835 5.52 sExpf6 10 Sun4 734 832 3.00 sExpf6 15 Sun4 729 827 3.00 sExpf6 5 Sgi 715 813 4.56 sExpf6 PCA 722 820 2.32 sData 1 Sun4 1023 1099 10sData 5 Sun4 850 925 5sData 10 Sun4 937 1012 4sData 15 Sun4 893 968 3sData 5 Sgi 889 964 7sData PCA 975 1051 7sTable 1Using Table 1, we can see that results are the best when we run our program on the PCA. This is be-cause the PCA architecture is a distributed architecture with a shared memory component. Message passingis implemented through the shared memory. When we run our program on a network of SUN4 and SGI38

workstations, there are speeds up between 3 and 4. In fact, speeds up depend on the examples, on theirsequentiality and on communication overhead. We consider these �rstobtained results to be promising. Sinceour method is concurrent from its design, we think that the implementation can be improved. In particu-lar, the number of termination messages can be reduced and processes can avoid idle time by performingbackground work.5 ConclusionWe have presented a concurrent algorithm for completion using SOUR graphs. The initial set of equationsis divided up into small pieces, stored in a graph. Initially each vertex represents one of the subtermsin the initial set of equations. Edges represent relations between those pieces. Inferences are local graphtransformations, which remove existing edges and create new edges constrained by constraints and renamings.In the concurrent implementation, vertices represent processes and edges represent communication linksbetween processes.For simplicity, the algorithm we have given in this paper is for ground completion. However, we havesummarized in the preliminaries how the theory of SOUR graphs is lifted to the non-ground case. The mod-i�cation of our algorithm to the non-ground case is simple. Uni�cation messages now contain a satis�ableequational constraint instead of just an assertion that a uni�cation problem is true. Orientation messagescontain a satis�able ordering constraint. Con�guration messages pass around these constraints, plus renam-ings. And new edges that are added are labelled with a constraint and renaming, which is a combination ofexisting constraints and renamings plus new ones given by a uni�cation message. This gives the processesmore work to do. Whenever a node receives constraints, it must combine them, determine the satis�abilityof the combination, and pass along the solved form.Our presentation and algorithm has several desirable properties. As far as we know, it is the �rst �ne-grained completion or theorem proving procedure, in the sense that each process represents a subterm of theequational system.Another feature of most concurrent completion and theorem proving techniques is that they either requirea global memory which all processes need to read from and write to, or else a master process which controlsall the other processes. In contrast, our algorithm works in a completely local fashion. All processes operateindependently, because the algorithm is based on local transformations of the SOUR graph algorithm. Thework of a process is based on receiving a message from another process. However, a process does not needto wait, because there are lots of di�erent things that are done by one process, and the message passing isasynchronous. Our algorithm has no need for any consistency checks, and two processes never do the samething.We feel that the property of having no global memory or global control is important. As mentionedin [BH94], contraction-based strategies are the most e�cient strategies, but they are the most di�cult toparallelize. Their parallelization almost always requires a global control or global memory, because anythingcan be a simpli�er, and it is not known which simpli�ers will simplify which equations. Our approach allowsa contraction based strategy with all local operations.AcknowledgementsThis work is partially supported by the Esprit Basic Research working group 6028, CCL and by the "Cen-tre Charles Hermite". We would like to thank Polina Strogova, Ilies Alouini, Dominique Fortin and theanonymous referees of the RTA commitee for their comments.References[ADF95] J. Avenhaus, J. Denzinger, and M. Fuchs. DISCOUNT: A system for distributed equational deduction.In Hsiang [Hsi95], pages 397{402.[BGK95] R. B�undgen, M. G�obel, and W. K�uchlin. Parallel ReDuX! PaReDuX. In Hsiang [Hsi95], pages 408{413.[BH94] M. P. Bonacina and J. Hsiang. Parallelization of deduction strategies: an analytical study. Journal ofAutomated Reasoning, 13:1{33, 1994. 39

[BH95] M. P. Bonacina and J. Hsiang. Distributed deduction by clause-di�usion: Distributed contraction andthe aquarius prover. Journal of Symbolic Computation, 19:245{267, March 1995.[DFvG83] E. Dijkstra, W. Feijen, and A. van Gasteren. Derivation of a termination detection algorithm for dis-tributed computation. Information Processing Letters, 16:217{219, 1983.[DJ90] N. Dershowitz and J.-P. Jouannaud. Handbook of Theoretical Computer Science, volume B, chapter 6:Rewrite Systems, pages 244{320. Elsevier Science Publishers B. V. (North-Holland), 1990. Also as:Research report 478, LRI.[DKM84] C. Dwork, P. Kanellakis, and J. C. Mitchell. On the sequential nature of uni�cation. Journal of LogicProgramming, 1(1):35{50, 1984.[GNP+93] J. Gallier, P. Narandran, D. Plaisted, S. Raatz, and W. Snyder. Finding canonical rewriting systemsequivalent to a �nite set of ground equations in polynomial time. Journal of Association for ComputingMachinery, 40(1):1{16, 1993.[Hsi95] J. Hsiang, editor. Rewriting Techniques and Applications, 6th International Conference, RTA-95, LNCS914, Kaiserslautern, Germany, April 5{7, 1995. Springer-Verlag.[KLS96] C. Kirchner, C. Lynch, and C. Schar�. A �ne-grained concurrent completion procedure. In H. Ganzinger,editor, Proceedings of RTA'96, volume 1103 of Lecture Notes in Computer Science, pages 3{17. Springer-Verlag, July 1996.[Koz77] D. Kozen. Complexity of Finitely Presented Algebras. PhD thesis, Cornell University, 1977.[LS90] R. Letz and J. Schumann. Partheo: A high-performance parallel theorem prover. In Proceedings 10thInternational Conference on Automated Deduction, Kaiserslautern (Germany), volume 446 of LectureNotes in Arti�cial Intelligence, pages 40{56. Springer-Verlag, 1990.[LS95] C. Lynch and P. Strogova. Sour graphs for e�cient completion. Technical Report 95-R-343, CRIN, 1995.[Lyn95] C. Lynch. Paramodulation without duplication. In D. Kozen, editor, Proceedings 10th IEEE Symposiumon Logic in Computer Science, San Diego (Ca., USA), pages 167{177, San Diego, June 1995. IEEE.[PSK96] D. A. Plaisted and A. Sattler-Klein. Proof lengths for equational completion. Information and Computa-tion, 125(2):154{170, 15 March 1996.[Sny93] W. Snyder. A fast algorithm for generating reduced ground rewriting systems from a set of groundequations. Journal of Symbolic Computation, 15:415{450, 1993.[SS93] C. Suttner and J. Schumann. Parallel automated theorem proving. Parallel Processing for Arti�cialIntelligence, 1993.40