A Process Algebra for Synchronous Concurrent Constraint Programming

Concurrent constraint programming is classically based on asynchronous communication via a shared store. This paper presents new version of the ask and tell primitives which features synchronicity. Our approach is based on the idea of telling new information just in the case that a concurrently running process is asking for it. An operational and an algebraic semantics are de(cid:12)ned. The algebraic semantics is proved to be sound and complete with respect to a compositional operational semantics which is also presented in the paper


Introduction
As a consequence of being a generalisation of previous proposals for concurrent logic programming languages (Concurrent Prolog, Parlog, GHC, etc.), concurrent constraint programming has naturally inherited one of their main features: the asynchronous character of the communication.This is obtained by ask primitives blocking when the information on the store is not complete enough to entail the asked constraints.Following these lines, a natural way of obtaining synchronous communication in concurrent constraint programming is to force the reduction of ask and tell primitives to synchronise.Speci cally, our approach considers tell primitives as lazy producers of information and views ask primitives as consumers of this information.From this point of view, a tell operation is reduced when an ask operation requires the told information.Moreover, the reduction of the two primitives is performed simultaneously.However, there is no reason to block ask and tell primitives on information which is already present.Consequently, stress is put on the novelty of the information and hence any tell(c) and ask(c) operations whose Example 1 (Di erentiating ccp and CCS (from 6])) Let A 1 = (a; b)+(a; c)+ (a; d) and A 2 = (a; b) + (a; (c + d)): In any compositional semantics for CCS these two processes must be distinguished.Indeed, they behave di erently under the context A = a; (b + c): The process A 1 can deadlock, by choosing the third alternative of the choice, while A 2 cannot.However, in cc, both A 1 and A 2 have the same behaviour.The process A 2 can deadlock by choosing the second alternative, because A can independently decide to produce y = b (after x = a).
Example 2 (Di erentiating ccp and Scc) Using the processes A, A 1 , A 2 of the above example, the processes A 1 and A 2 are also distinguished by A in Scc for the same reason as in CCS.
This example illustrates the di erence between Scc and cc.Stated in other terms, in the ccp paradigm, since the tell operation is asynchronous, the choice guarded by tell(a) is a local choice whereas, since the tell operation is synchronous in Scc, this choice is global in Scc.
Nevertheless, synchronisation is only forced in Scc in the case that a process tries to tell information which is not already entailed by the store.Otherwise, it can proceed asynchronously.This fact is used subsequently to di erentiate CCS and The distinction between Scc and CCS thus appear to be more subtle than the distinction between ccp and CCS.The choice guarded by tell is actually a \mixture" of global and local choice.The choice depends upon actions performed and upon the results of the past behaviour of the system, i.e. upon the constraint contained in the store.
The rest of the paper is organised as follows.Section 2 describes informally Scc and section 3 presents the basic operational semantics O. Section 4 studies the algebraic semantics.To prove its soundness and completeness, we introduce a compositional model M in the section 5 and relate it with the algebraic semantics.
Finally, section 6 draws our conclusions.

The Language Scc
This section presents the syntax and the informal semantics of the language underlying the Scc paradigm, also called Scc by abuse of language.For reasons of simplicity we consider a simpli ed version of Scc which does not contain recursion.Recursion can however be treated in the standard way described in 2].As in 14], the constraint system underlying Scc consists of any system of partial information that supports the entailment relation.We assume a given cylindric constraint system hC; `i over a set of variables Svar, de ned as usual from a simple constraint system hD; `i.Furthermore, for the purposes of axiomatisation we will suppose that the cylindric constraint system is embedded into a complemented and distributive one denoted by dc(D).For detailed de nitions we refer to 14, 7, 4].
The language description is parametric with respect to hC; `i; and so are the semantic constructions presented.
In the following, we use G; H; : : : possibly subscripted to range over the set Sgoal of processes c; d; : : : to range over basic constraints (i.e.constraints which are equivalent to a nite set of primitive constraints), and X; Y; : : : to range over the subsets of Svar.
Processes G 2 Sgoal are de ned by the following grammar G ::= 4 j j ask(c) j tell(c) j G; G j G + G j G k G j 9 X G The constant 4 denotes a process which is only capable of terminating successfully.The constant is used to denote deadlocking processes.
The atomic constructs ask(c) and tell(c) act on a given store in the following way: as usual, given a constraint c, the process ask(c) succeeds if c is entailed by the store, otherwise it is suspended until it can succeed.However, the process tell(c), of a more lazy nature than the classical one, succeeds only if c is (already) entailed by the store and in this case it does not modify the store, and suspends otherwise.It is resumed by a concurrently suspended ask(d) operation provided that the conjunction of c and of the store entails d.In that case, both the tell and the ask are resumed synchronously and at the same time the store is atomically augmented with the constraint c.
The sequential composition G 1 ; G 2 is executed by rst performing G 1 and, if G 1 terminates successfully, by performing G 2 .
The nondeterministic choice G 1 + G 2 selects between the execution of G 1 or G 2 respectively provided that the selected component can perform at least one step of a computation (i.e. it is not immediately suspended).It is a global nondeterministic choice since the selection of a component can be in uenced by the (global) store and by the environment of the process as well.
The parallel composition G 1 k G 2 represents both the interleaving (merge) of the computation steps of the components involved (provided they can do these steps independently of each other) and also synchronisation: this is the case of the tell and ask described above.Note that in the general case there can be a parallel composition of a nite sets of tell's and a nite set of ask's such that the current store and a conjunction of some of the tell constraints entail the conjunction of the ask constraints and the other tell's.In this case all the components are reduced simultaneously.This is sometimes referred to in the literature as multiparty synchronous communication.
The block construct 9 X G behaves like a process G with the variables in X considered as local.It hides the information about variables from X within the process G. Let us recall that full version of Scc contains recursive procedures too (see an example below), but for ease of reasoning they are not studied here.
To ilustrate some features of Scc (synchronous multi-party communication) we present the dining philosophers example.We have chosen to represent both philosophers and forks as processes; in addition communication is achieved via shared stream variables as in classical concurrent logic programming.
The inital description of the system is and the processes are described as follows: fork(R,L):-ask(L= takenjL 0 ]); ask(L 0 = freejL 00 ]); fork(R,L 00 ) + ask(R= takenjR 0 ]); ask(R 0 = freejR 00 ]); fork(R 00 ,L) phil(L,R):-tell(L= takenjL 0 ] , R= takenjR 0 ]); tell(L 0 = freejL 00 ] , R 0 = freejR 00 ]); phil(L 00 ,R 00 ) Finally, it is worth observing that it is quite easy to recover the traditional cc paradigm from our framework by the introduction of an asynchronous tell by providing, for each constraint to be told, a concurrent corresponding ask operation.3 The operational semantics O It turns out that it is possible to treat the sequential and parallel composition operators in a very similar way by introducing the auxiliary notion of context.Basically, a context consists of a partially ordered structure where place holders (subsequently referred to by 2) have been inserted at a top-level place i.e. a place not constrained by the previous execution of other atoms.Viewing goals as partially ordered structures too, the ask and tell primitives to be reduced are those which can be substituted by a place holder 2 in a context.Furthermore, the goals resulting from the reductions are essentially obtained by substituting the place holder by the corresponding syntax structure or the 4, depending upon whether an atom or a ask/tell primitive is considered.
The formal de nition of the contexts is a very standard one and can be found e.g. in 4].Moreover, we further state that the structure (Sgoal; ; ; k; 4) is a bimonoid, that is, \ ;" and \ k" are associative binary operations and have 4 as neutral element.In the following, we will also simplify the goals resulting from the application of contexts accordingly.The operational semantics of Scc is de ned in Plotkin's style 11] by means of a transition system, where Sstore denotes the set of stores.
De nition 1 De ne the transition relation ! as the smallest relation of (Sgoal Sstore) (Sgoal Sstore) satisfying the rules of Figure 1.
Rules (H) and (C) express the classical treatment of hiding and of choice, respectively.Classical rules for the sequential and parallel composition operators are tackled by means of the notion of context.Rule (T) de nes the reduction of tell and ask primitives.The primitives to be reduced, there referred to as sp 1 , . . ., sp m , are partitioned in three categories: i) the ask primitives (the multi-set fask(a 1 ); ; ask(a p )g); ii) the tell primitives split into those which add information to the store (the multi-set ftell(rt 1 ); ; tell(rt r )g) and those which do not (the multi-set ftell(at 1 ); ; tell(at q )g); All these primitives are then simultaneously reduced to the empty goal 4 when the information on the current store ( ) together with the new information told (rt 1 ; : : :; rt r ) entails the information of the other primitives.The new store consists in this case of the old store enriched by the new information told.Note that this rule re ects the laziness feature of our tell primitives.
In the case a constraint c is entailed by the current store an ask(c) primitive can be reduced alone following rule (T) by taking the unary context 2, m = 1, p = 1, q = 0, r = 0 and tell(c) can be reduced alone following rule (T) by taking the unary context 2, m = 1, p = 0, q = 1, r = 0. Other tell's and ask's need each other for reduction and reduce simultaneously.A minimality condition is required to forbid outsider tell's to be reduced by taking advantage of a concurrent reduction.
It also indicates those stores associated with deadlock situations, namely situations corresponding either to the absence of suitable data on the store or to the absence of concurrent process(es) that would allow tell and ask primitives to proceed, i.e. to resume suspended tell's and ask's.Note that the two situations may be distinguished by a simple criterion: the existence of a store richer than the current one that would enable the computation to proceed.Note also that real failure, corresponding to the absence of suitable procedure declaration, does not occur since recursion is not treated here.
The following de nition follows directly from this intuition.The symbols + and s are used to indicate the computations ending by a success and a suspension, respectively.
Other axioms are speci c to our work (see 4] for comparisson of our axioms with the axioms for asynchronous ccp given by deBoer and Palmidessi 7]).

Axioms from general process algebra
The rst group (A) consists of axioms in Figure 2.They deal with the general requirements found in any process algebra of communicating systems.As usual, we use two auxiliary operators to axiomatise the parallel composition operator k.They are k for left merge and j for communication merge.In the following ; ; (c) and (c) represent asks or tells on constraints, the constraint c when an axiom is parametric with respect to it.The system A axiomatises a notion of equivalence which is known as bisimulation (see e.g.2]).The next group of axioms (T) in Figure 3 permits the abstraction from silent steps .In the context of concurrent constraint programming corresponds to a tell(c) or ask(c) action where c is entailed by the current store, e.g.tell(true) or ask(true).Failure is axiomatised by axioms (F) given in Figure 3 (cf.2], p.215).
The axiom (L7) permits the restricted composition of tell actions and re ects our minimality condition (see rule (T) in Figure 1).The axiom (L8) permits the composition of ask actions.
The axiom (L9) is informally justi ed as follows.Suppose that the current store implies the constraint d.In this case the process represented by the right-hand side of the axiom can select the branch, execute the action and proceed with A. But this behaviour can be mimicked by the other branch, the order of the actions being unobservable.In the case the current store does not imply d, the only choice left is to execute the branch.

Soundness and Completeness
This section discusses the soundness and completeness properties of our axiomatisation.Classically, algebraic theories identify computations which only exhibit the same nal results but also behave identically when they are placed in any context.We are thus lead to relate our algebraic semantics with a compositional semantics.
However, the semantics O is not compositional, as shown by considering the goals tell(c), ask(c), tell(c) k tell(c), and tell(c) k ask(c): for any store such that 6 `c, the rst three suspend whereas the last succeeds.Consequently, we rst de ne a compositional operational semantics, prove that it is correct with respect to the semantics O and then relate it to the algebraic semantics just developed.

A Compositional Operational Semantics
Two problems need to be tackled in order to transform O into a compositional semantics.Firstly, the semantics should be modi ed in order to allow suspended goals to resume thanks to the store as computed by concurrent goals.This is subsequently achieved by reporting in the semantics not just the nal results coupled to a status mark but sequences corresponding to the computation steps.Progress made by the concurrent goals is then indicated by steps of the form ; e indicating the update of the store in the store .Secondly, tell and ask primitives of goals should also be able to synchronise with primitives provided by concurrent processes.This is subsequently achieved by introducing in semantic sequences the steps of the form ; 0 (A;At;Rt) , where the (A; At; Rt) triple denotes the actors of the synchronisation, according to the three categories detailed in section 3.In fact each of these multi-sets is a pair composed of (the store argument of) the primitives of the considered goal and of (the store argument of) the primitives provided by its concurrent processes.
It is possible to extend the transition system of Figure 1 so as to re ect these extensions.The slight modi cations to rules (T), (H), and (C) are given in Figure 6.They consist of adding labels describing the pair of initial and nal values of the store for the steps under consideration.Note that rule (R) introduced in section 4 can likewise be modi ed straightforwardly.
Rules (Sn) and (Ss) deal with suspension and success.The last one re ects the intuition already embodied in de nition 2.
The treatment of suspension requires some care.Our solution, illustrated in rule (Sn), is to report, in a single mark, for each suspended con guration, the set of stores and the set of concurrent tell and ask primitives (split as before) that would allow a transition to take place.Suspension marks disappear when combining components in the case where the tell and ask primitives required by the components are mutually provided.
The intuition has now been provided for the following de nitions.
2) The set Smark of marks is de ned as the set feg Sspair.Marks are typically denoted by the letter M, possibly subscripted.
3) The set Sstep of steps is de ned as the set (Sstore Sstore) (Sstore Sstore Smark).Steps are typically denoted in an exponential fashion as ; M] ; the notation M] indicating a possibly absent mark.
4) The set Sterm of terminators is de ned as the set Sstore (f + g f s( ;S) : Sstore; S Sspairg).In the following, terminators are typically denoted as ; z , Terminators not involving + are typically denoted as ; S , when there is no need to specify further the mark S.
The operational semantics M basically collects the labels appearing in the nitely ended computations.To obtain compositionality, those computations are allowed to start in any store.
De nition 5 De ne the operational semantics M : Sgoal !P(Shist) as the following function: for any goal G, M(G) = f l 1 l m : <G; > l 1 !lm !C; 2 Sstore; C 2 (fSucc; Suspg) Sstore g The semantics M can be proved compositional.It is also correct with respect to the semantics O in the following sense.A few de nitions are rst in order.De nition 6 Let h = 1 ; 1 M 1 ] : : : n ; n Mn] : n+1 ; z be a history,n 0. 1) h is continuous i there is no gap of stores between the steps ie i i+1 = i for i = 1; : : : ; n. 2) h starts in i 1 = .
3) h is non-hypothetical i it contains no step of Sstore Sstore Smark.

4)
n+1 ; z is called the nal step of h and h is said to end by this step.
For any goal G, the semantics O(G) can be obtained from M(G) in the following way: (i)by retaining the histories of the latter which are continuous, nonhypothetical, and which start in true; (ii) by taking their nal steps; (iii) by changing all the symbols S by the symbol s .Proposition 7 De ne the function : Sstore !P(Shist) !P(Sstore f + ; s g) as follows: for any store 2 Sstore, any subset S Shist, ( )(S) = f ; + : h 2 S; h continuous, non-hypothetical h starts in ; h ends by ; + g f ; s : h 2 S; h continuous, non-hypothetical h starts in ; h ends in ; S g: Then, for any program P and any goal G, O(G) = (true)(M(G)):

Soundness and completeness
We nally relate the algebraic semantics with the semantics M.This is achieved following the classical lines, illustrated among others in 2].
The proof of soundness of our axiomatisation consists of a simple veri cation establishing M(G) = M(H), for any axiom G = H.As far as completeness is concerned, every process is rst proved equal to a basic process, namely a process built up from the ask, tell and (tell j ask) constructs, and ; constants using sequencing and choice only.Completeness is then established for basic processes by inductively reasoning on their structure.Summing up, the following theorem can be established.

Conclusions
This paper has presented an algebraic semantics for a synchronous version of concurrent constraint programming.This version is based on new variants of the tell and ask primitives where the former behave as lazy producers of new pieces of information which are consumed by the latter at the same time they are produced.Stress on the novelty of the information permits tell and ask to proceed asynchronously in the case their corresponding constraint argument is entailed by the current contents of the store.This framework, called Scc, has been argued to be (in some aspects) different from traditional algebraic languages, exempli ed by CCS, and from classical concurrent constraint programming, exempli ed by the cc family of languages.These di erences call for semantic treatments, which have been proposed and compared with existing ones.Soundness and completeness of the proposed axiomatic system have been established by relating it to a compositional operational semantics, which has also been presented.

Scc. Example 3 (
Di erentiating CCS and Scc) Using again the above processes A, A 1 , A 2 , let B 1 = b; A 1 and B 2 = b; A 2 : In CCS, these two processes can be distinguished by the process B = b; A for the reasons exposed in Example 1.However, in Scc, both processes have the same behaviour.The process B 2 can now deadlock by choosing the second alternative because A can now independently proceed by the rst alternative as y = b is already entailed by the store.

Figure 7 :
Figure 7: Rules induced by the compositionality requirement

Theorem 8
For any processes G and H `G = H i M(G) = M(H) An interesting relationship between the algebraic semantics and the semantics O can be derived therefrom and from proposition 7. Proposition 9 For any processes G and H, if `G = H then O(G) = O(H).