• Aucun résultat trouvé

Towards a Unified Framework for Declarative Structured Communications

N/A
N/A
Protected

Academic year: 2021

Partager "Towards a Unified Framework for Declarative Structured Communications"

Copied!
16
0
0

Texte intégral

(1)

HAL Id: inria-00426609

https://hal.inria.fr/inria-00426609v2

Submitted on 17 Nov 2009

HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Structured Communications

Hugo Lopez, Carlos Olarte, Jorge Perez

To cite this version:

Hugo Lopez, Carlos Olarte, Jorge Perez. Towards a Unified Framework for Declarative Structured Communications. 2nd PLACES 2009 - Second International Workshop on Programming Language Approaches to Concurrency and Communication-cEntric Software, Mar 2009, York, United Kingdom.

15p. �inria-00426609v2�

(2)

Communications

Hugo A. L´opez

IT University of Copenhagen lopez@itu.dk

Carlos Olarte

Ecole Polytechnique´ Universidad Javeriana Cali colarte@lix.polytechnique.fr

Jorge A. P´erez

University of Bologna perez@cs.unibo.it

We present a unified framework for the declarative analysis of structured communications. By relying on a (timed) concurrent constraint programming language, we show that in addition to the usual operational techniques from process calculi, the analysis of structured communications can elegantly exploit logic-based reasoning techniques. We introduce a declarative interpretation of the language for structured communications proposed by Honda, Vasconcelos, and Kubo. Distinguishing features of our approach are: the possibility of including partial information (constraints) in the session model;

the use of explicit time for reasoning about session duration and expiration; a tight correspondence with logic, which formally relates session execution and linear-time temporal logic formulas.

1 Introduction

Motivation. From the viewpoint of reasoning techniques, two main trends in modeling in Service Oriented Computing (SOC) can be singled out. On the one hand, anoperational approachfocuses on how process interactions can lead to correct configurations. Typical representatives of this approach are based on process calculi and Petri nets (see, e.g., [18, 3, 8, 9]), and count with behavioral equivalences and type disciplines as main analytic tools. On the other hand, in a declarative approach the focus is on the set of conditions components should fulfill in order to be considered correct, rather than on the complete specification of the control flows within process activities (see, e.g., [19, 14]). Even if these two trends address similar concerns, we find that they have evolved rather independently from each other.

The quest for a unified approach in which operational and declarative techniques can harmoniously converge is therefore a legitimate research direction. In this paper we shall argue that Concurrent Con- straint Programming (CCP) [17] can serve as a foundation for such an approach. Indeed, the unified framework for operational and logic techniques that CCP provides can be fruitfully exploited for anal- ysis in SOC, possibly in conjunction with other techniques such as type systems. Below we briefly introduce the CCP model and then elaborate on how it can shed light on a particular issue: the analysis of structured communications.

CCP [17] is a well-established model for concurrency where processes interact with each other by tellingandaskingfor pieces of information (constraints) in a shared medium, thestore. While the former operation simply adds a given constraint to the store (thus making it available for other processes), the latter allows for rich, parameterizable forms of process synchronization. Interaction is thus inherently asynchronous, and can be related to a broadcast-like communication discipline, as opposed to the point- to-point discipline enforced by formalisms such as the π-calculus [15]. In CCP, the information in the store grows monotonically, as constraints cannot be removed. This condition is relaxed in timed extensions of CCP (e.g., [16, 11]), where processes evolve along a series ofdiscrete time units. Although each unit contains its own store, information is not automatically transferred from one unit to another. In this paper we shall adopt a CCP process language that is timed in this sense.

(3)

In addition to the traditional operational view of process calculi, CCP enjoys adeclarative nature that distinguishes it from other models of concurrency: CCP programs can be seen, at the same time, as computing agents and as logic formulas [17, 11, 12], i.e., they can be read and understood as logical specifications. Hence, CCP-based languages are suitable forboth the specification and verification of programs. In the CCP language used in this paper, processes can be interpreted as linear-time temporal logic formulas; we shall exploit this correspondence to verify properties of our models.

This Work. We describe initial results on the definition of a formal framework for the declarative analysis of structured communications. We shall exploit utcc [13], a timed CCP process calculus, to give a declarative interpretation to the language defined by Honda, Vasconcelos, and Kubo in [7]

(henceforth referred to asHVK). This way, structured communications can be analyzed in a declarative framework where time is defined explicitly. We begin by proposing an encoding of theHVKlanguage intoutccand studying its correctness. We then move to the timed setting, and proposeHVKT, a timed extension of HVK. The extended language explicitly includes information on session duration, allows for declarative preconditions within session establishment constructs, and features a construct for session abortion. We then discuss how the encoding ofHVKintoutccstraightforwardly extends toHVKT. A Compelling Example. We now give intuitions on how a declarative approach could be useful in the analysis of structured communications. Consider the ATM example from [7, Sect. 4.1]. There, an ATM has established two sessions: the first one with a user, sharing sessionk over service a, and the second one with the bank, sharing session hover serviceb. The ATM offers deposit,balance, and withdrawoperations. When executing a withdraw, if there is not enough money in the account, then an overdraftmessage appears to the user. It is interesting to analyze what occurs when this scenario is extended to consider a card reader that acts as a malicious interface between the user and the ATM. The user communicates his personal data with the reader using the servicer, which will be kept by the reader after the first withdraw operation to continue withdrawing money without the authorization of the user.

A greedy card reader could even withdraw repeatedly until causing an overdraft, as expressed below:

Reader = acceptr(k0)ink0?(id)in

requesta(k)ink![id]; k0

withdraw:k0?(amt)in kwithdraw;k![amt];

k{dispense:k0dispense;k![amt];R(k,amt)koverdra f t:Q}

R(j,x) = defR0inkwithdraw;j![x];j{dispense:j?(amt)inR0koverdra f t:Q}

User = requestr(k0)ink0![myId];

k0withdraw;k0![58]; k0{dispense:k0?(amt)inPkoverdra f t:Q}

By creating sessions between them, the card readerReaderis able to receive the user’s information, and to use it later by attempting a session establishment with the bank. Following authentication steps (not modeled above), the card reader allows the user to obtain the requested amount. Additional with- drawing transactions between the reader and the bank are defined by the recursive process R. In the specification above, the processQcan be assumed to send a message (through a session with the bank) representing the fact that the account has run out of money:Q=kbank![0];inact.

Even in this simple scenario, the combination of operational and declarative reasoning techniques may come in handy to reason about the possible states of the system. Indeed, while an operational ap- proach can be used to describe an operational description of the compromised ATM above, the declarative approach can complement such a description by offering declarative insights regarding its evolution. For instance, assumingQas above, one could show that autccspecification of the ATM example satisfies

(4)

the linear temporal logic formula3out(kbank,0), which intuitively means that in presence of a malicious card reader the user’s bank account will eventually reach an overdraft status.

Related Work. One approach to combine the declarative flavor of constraints and process calculi tech- niques is represented by a number of works that have extended name-passing calculi with some form of partial information (see, e.g., [20, 6]). The crucial difference between such a strand of work and CCP-based calculi is that the latter offer a tight correspondence with logic, which greatly broadens the spectrum of reasoning techniques at one’s disposal. Recent works similar to ours include CC-Pi [4] and the calculus for structured communications in [5]. Such languages feature elements that resemble much ideas underlying CCP (especially [4]). The main difference between our approach and such works is that we adhere to the use of declarative reasoning techniques based on temporal logic as an effective way of complementing operational reasoning techniques. In [4], the reasoning techniques associated to CC-Pi are essentially operational, and used to reason about service-level agreement protocols. In [5], the key for analysis is represented by a type system which provides consistency for session execution, much as in the original approach in [7].

2 Preliminaries

2.1 A Language for Structured Communication

We begin by introducingHVK, a language for structured communication proposed in [7]. We assume the following conventions: namesare ranged over bya,b, . . .;channelsare ranged over byk,k0;variables are ranged over byx,y, . . .;constants(names, integers, booleans) are ranged over byc,c0, . . .;expressions (including constants) are ranged over bye,e0, . . .;labelsare ranged over byl,l0, . . .;process variablesare ranged over byX,Y, . . .. Finally,u,u0, . . .denote names and channels. We shall use~xto denote a sequence (tuple) of variablesx1...xnof lengthn=|~x|. Notation~xwill be similarly applied to other syntactic entities.

The sets of free names/channels/variables/process variables ofP, is defined in the standard way, and are respectively denoted byfn(·),fc(·), fv(·), andfpv(·). Processes without free variables or free channels are calledprograms.

Definition 1(TheHVKlanguage [7]). Processes inHVKare built from:

P,Q ::= requesta(k)in P Session Request | accepta(k)in P Session Acceptance

| k![~e];P Data Sending | k?(~x)in P Data Reception

| kl;P Label Selection | k{l1:P1k · · · kln:Pn} Label Branching

| throwk[k0];P Channel Sending | catchk(k0)in P Channel Reception

| ifethenPelseQ Conditional Statement | P|Q Parallel Composition

| inact Inaction | (νu)P Hiding

| defDinP Recursion | X[~e~k] Process Variables

D ::= X1(x1k1) =P1and· · ·andXn(xnkn) =Pn

Declaration for Recursion

Operational Semantics ofHVK. The operational semantics ofHVKis given by the reduction relation

−→h which is the smallest relation on processes generated by the rules in Figure 1. In Rule STR, the structural congruence≡his the smallest relation satisfying : 1)P≡hQif they differ only by a renaming of bound variables (alpha-conversion). 2)P|inact≡hP,P|Q≡hQ|P,(P|Q)|R≡hP|(Q|R). 3) (νu)inact≡hinact,(νuu0)P≡h(νu0u)P,(νu)(P|Q)≡h(νu)P|Qifx∈/fv(Q),(νu)(defDinP)≡h

(5)

(defDin((νu)P))ifu∈/ fv(D). 4) (defDinP) |Q≡hdefDin(P |Q) if fpv(D)∩fpv(Q) = /0. 5) defDin(defD0inP)≡hdefDandD0inPiffpv(D)∩fpv(D0) =/0.

LINK requesta(k)inQ|accepta(k)inP−→h(νk)(P|Q) COM (k![~e];P)|(k?(~x)inQ)−→hP|Q[~c/~x] ife~c

LABEL kli;P|k{l1:P1k · · · kln:Pn} −→hP|Pi(1in) PASS throwk[k0];P|catchk(k0)inQ−→hP|Q

IF1 ifethenPelseQ −→hP(etrue) IF2 ifethenPelseQ −→hQ(efalse)

DEF defDin(X[~e~k]|Q)−→hdefDin(P[~c/~x]|Q) (e~c,X(~x~k) =PD) SCOP P−→hP0implies(νu)P−→h(νu)P0

PAR P−→hP0impliesP|Q−→hP0|Q

STR IfPhP0andP0−→hQ0andQ0hQthenP−→hQ

Figure 1: Reduction Relation forHVK(−→h)[7].

Let us give some intuitions about the language constructs and the rules in Figure 1. The central idea inHVKis the notion of asession, i.e., a series of reciprocal interactions between two parties, possibly with branching, delegation and recursion, which serves as an abstraction unit for describing structured communication. Each session has associated a specific port, or channel. Channels are generated at session initialization; communications inside the session take place on the same channel.

More precisely, sessions are initialized by a process of the formrequesta(k)inQ|accepta(k)inP.

In this case, there is a request, on name a, for the initiation of a session and the generation of a fresh channel. This request is matched by an accepting process on a, which generates a new channelk, thus allowing P and Q to communicate each other. This is the intuition behind rule LINK. Three kinds of atomic interactions are available in the language: sending (including name passing), branching, and channel passing (also referred to as delegation). Those actions are described by rules COM, LABEL, and PASS, respectively. In the case of COM, the expression~eis sent on the port (session channel)k. Process k?(~x)inQthen receives such a data and executesQ[~c/~x], where~cis the result of evaluating the expression

~e. The case of PASSis similar but considering that in the constructsthrowk[k0];Pandcatchk(k0)inQ, only session names can be transmitted. In the case of LABEL, the processkli;Pselects one label and then the corresponding processPi is executed. The other rules are self-explanatory.

For the sake of simplicity, and without loss of generality (due to rule 5 of≡h), in the sequel we shall assume programs of the formdefDinPwhere there are not procedure definitions inP.

2.2 Timed Concurrent Constraint Programming

Timed concurrent constraint programming (tcc) [16] extends CCP for modeling reactive systems. In tcc, time is conceptually divided into time units (ortime intervals). In a particular time unit, a tcc process P gets an input (i.e. a constraint) c from the environment, it executes with this input as the initialstore, and when it reaches its resting point, itoutputsthe resulting storedto the environment. The resting point determines also a residual processQwhich is then executed in the next time unit. It is worth noticing that the final store is not automatically transferred to the next time unit.

The utcc calculus [13] extendstccfor reactive systems featuring mobility. Heremobilityis un- derstood as the dynamic reconfiguration of system linkage through communication, much like in the π-calculus [15].utccgeneralizestccby considering aparametricask operator of the form(abs~x;c)P, with the following intuitive meaning: process P[~t/~x]is executed for every term~t such that the current

(6)

store entails an admissible substitutionc[~t/~x]. This process can be seen as anabstractionof the process Pon the variables~xunder the constraint (or with theguard)c.

utccprovides a number of reasoning techniques: First,utccprocesses can be represented as par- tial closure operators (i.e. idempotent and extensive functions). Also, for a significant fragment of the calculus, the input-output behavior of a process P can be retrieved from the set of fixed points of its associated closure operator [12]. Second,utccprocesses can be characterized as First-order Linear-time Temporal Logic (FLTL) formulas [10]. This declarative view of the processes allows for the use of the well-established verification techniques from FLTL to reason aboututccprocesses.

Syntax. Processes in utcc are parametric in a constraint system[17] which specifies the basic con- straints that agents can tell or ask during execution. It also defines anentailmentrelation “`” specifying interdependencies among constraints. Intuitively,c`d means that the information ind can be deduced from that inc(as in, e.g.,x>42`x>0).

The notion of constraint system can be set up by using first-order logic (see e.g., [11]). We assume a first-order signatureΣand a (possibly empty) first-order theory∆, i.e., a set of sentences overΣhaving at least one model. Constraints are then first-order formulas overΣ. Consequently, the entailment relation is defined as follows: c`dif the implicationc⇒dis valid in∆.

The syntax of the language is as follows:

P,Q:= skip

|

tell(c)

|

(abs~x;c)P

|

PkQ

|

(local~x;c)P

|

nextP

|

unlesscnextP

|

!P with the variables in~xbeing pairwise distinct.

A processskip does nothing; a processtell(c) adds c to the store in the current time interval. A process Q= (abs~x;c)P binds the variables~x inP andc. It executes P[~t/~x]for every term~t s.t. the current store entails an admissible substitution overc[~t/~x]. The substitution[~t/~x]is admissible if|~x|=|~t|

and noxi in~xoccurs in~t. Furthermore,Qevolves intoskipat the end of the time unit, i.e., abstractions are not persistent when passing from one time unit to the next one. P k QdenotesPandQrunning in parallel during the current time unit. A process(local~x;c)P bindsthe variables~xinPby declaring them private toPunder a constraintc. Ifc=true, we write(local~x)Pinstead of(local~x;true)P. Theunit delaynextPexecutesPin the next time unit. Thetime-outunlesscnextPis also a unit delay, butPis executed in the next time unit iffcis not entailed by the final store at the current time unit. Finally, the replication !PmeansPknextPknext2Pk. . ., i.e., an unbounded number of copies ofPbut one at a time. We shall use ![n]Pto denotebounded replication, i.e.,PknextPk...knextn−1P.

From a programming language perspective, variables~x in (abs~x;c)P can be seen as the formal parameters ofP. This way,recursive definitionsof the formX(~x)def= Pcan be encoded inutccas

R[[X(~x)def= P]] =!(abs~x;callx(~x))Pb (1) where callx is an uninterpreted predicate (a constraint) of arity|~x|. Process Pbis obtained fromP by replacing recursive calls of the formX(~t) withtell(callx(~t)). Similarly, calls of the formX(~t)in other processes are replaced withtell(callx(~t)).

Operational Semantics. The operational semantics considerstransitionsbetween process-storecon- figurationshP,ciwith stores represented as constraints and processes quotiented by the structural con- gruence≡udefined below. We shall useγ,γ0, . . .to range over configurations.

The semantics is given in terms of aninternaland anobservabletransition relation; both are given in Figure 2. Theinternal transition hP,di −→ hP0,d0iinformally means “Pwith storedreduces, in one

(7)

RT

htell(c),di −→ hskip,dci RP

hP,ci −→ hP0,di

hPkQ,ci −→ hP0kQ,di RU d`c

hunlesscnextP,di −→ hskip,di

RL

hP,c∧(∃~xd)i −→ hP0,c0∧(∃~xd)i

h(local~x;c)P,di −→ h(local~x;c0)P0,d∧ ∃~xc0i RA

d`c[~t/~x] [~t/~x]is admissible h(abs~x;c)P,di −→

P[~t/~x]k(abs~x;c∧~x6=~. t)P,d

RS

γ1−→γ2

γ10−→γ20

ifγ1uγ10andγ2uγ20 RR

h!P,di −→ hPknext!P,di

RO

hP,ci −→hQ,di 6−→

P ===(c,d)F(Q)

where F(P) =

skip ifP=skiporP= (abs~x;c)Q F(P1)kF(P2) ifP=P1kP2

(local~x)F(Q) ifP= (local~x;c)Q

Q ifP=nextQorP=unlesscnextQ

Figure 2: Operational Semantics for utcc. In RA,~x6=~. t (~x syntactically different from~t) denotes W

1≤i≤|~x|xi6.

=ti. If|~x|=0,~x6.

=~tis defined asfalse.

internal step, toP0 with stored0”. We sometimes abuse of notation by writingP−→P0 whend,d0 are unimportant. Theobservable transition P ===(c,d)⇒Rmeans “Pon inputc, reducesin one time unittoR and outputsd”. The latter is obtained from a finite sequence of internal transitions.

In ruleRS, the structural congruence≡uis the smallest congruence satisfying: 1)P≡uQif they differ only by a renaming of bound variables. 2)Pkskip≡uP. 3)PkQ≡uQkP,Pk(QkR)≡u(PkQ)kR.

4)Pk(local~x;c)Q≡u(local~x;c) (PkQ)if~x6∈fv(P). 5)(local~x;c) (local~y;d)P≡u(local~x;~y;c∧d)P if~x∩~y=/0 and~y∈/fv(c). Extend≡uby decreeing thathP,ci ≡uhQ,ciiffP≡uQ.

Definition 2 (Output Behavior). Let s=c1.c2....cn be a sequence of constraints. If P=P1 (true,c===⇒1) P2 (true,c===⇒2). . .Pn

(true,cn)

===⇒ Pn+1uQ we shall write P ===sQ. If s=c1.c2.c3...is an infinite sequence, we omit Q in P ===sQ. Theoutput behaviorof P is defined as o(P) ={s|P ===s}. If o(P) =o(Q) we shall write P∼oQ. Furthermore, if P ===s⇒Q and s is unimportant we simply write P ===⇒Q.

Logic Correspondence. Remarkably, in addition to this operational view, utcc processes admit a declarative interpretation based on Pnueli’s first-order linear-time temporal logic (FLTL) [10]. This is formalized by the encoding below, which mapsutccprocesses into FLTL formulas.

Definition 3. LetTL[[·]]a map fromutccprocesses to FLTL formulas given by:

TL[[skip]] = true TL[[tell(c)]] = c

TL[[PkQ]] = TL[[P]]TL[[Q]] TL[[(abs~y;c)P]] = ∀~y(cTL[[P]]) TL[[(local~x;c)P]] = ∃~x(cTL[[P]]) TL[[nextP]] = ◦TL[[P]]

TL[[unlesscnextP]] = c∨ ◦TL[[P]] TL[[!P]] = 2TL[[P]]

Modalities◦F andF represent thatF holds next andalways, respectively. We use theeventual modality3Fas an abbreviation of¬¬F.

The following theorem relates the operational view of processes with their logic interpretation.

Theorem 1 (Logic correspondence [13]). LetTL[[·]] be as in Definition 3, P autccprocess and s= c1.c2.c3... an infinite sequence of constraints s.t. P ===s. For every constraint d, it holds that:

TL[[P]]`3d iff there exists i≥1s.t. ci`d .

(8)

Recall that an observable transitionP (c,c

0)

===⇒Qis obtained from a finite sequence of internal transi- tions (rule RO). We notice that there exist processes that may produce infinitely many internal transitions and as such, they cannot exhibit an observable transition; an example is(absx;c(x))tell(c(x+1)). The utccprocesses considered in this paper arewell-terminated, i.e., they never produce an infinite number of internal transitions during a time unit. Notice also that in the Theorem 1 the processPis assumed to be able to output a constraintcifor all time-uniti≥1. Therefore,Pmust be a well-terminated process.

Derived Constructs. Let outbe an uninterpreted predicate. One could attempt at representing the actions of sending and receiving as in a name-passing calculus (say,k![~e]andk?(~x)inP, resp.) with the utccprocessestell(out(k,~e))and(abs~x;out(k,~x))P, respectively. Nevertheless, since these processes are not automatically transferred from one time unit to the next one, they will disappear right after the current time unit, even if they do not interact. To cope with this kind of behavior, we shall define versions of(abs~x;c)Pandtell(c)processes that arepersistent in time. More precisely, we shall use the process (wait~x;c) do P, which transfers itself from one time unit to the next one until, for some~t, c[~t/~x] is entailed by the current store. Intuitively, the process behaves like an input that is active until interacting with an output. When this occurs, the process outputs the constraintc[~t/~x], as a way of acknowledging the successful read of c. When|~x|=0, we shall write wheneverc do P instead of(wait~x;c) do P.

Similarly, we definetell(c)for the persistent output ofcuntil some process “reads”c. These processes can be expressed in the basicutccsyntax as follows (in all cases, we assumestop,go∈/fv(c)):

tell(c) def= (localgo,stop) ( tell(out0(go))k!whenout0(go)do tell(c)k

!unlessout0(stop)next tell(out0(go))k

!whencdo!tell(out0(stop)))

(wait~x;c)doP def= (localstop,go) ( tell(out0(go))k!unlessout0(stop)next tell(out0(go)) k!(abs~x;cout0(go)) (Pk!tell(out0(stop))) (wait~x;c)doP def= (wait~x;c)do(Pktell(c))

Notice that once a pair of processestellandwaitinteract, their continuation in the next time unit is a process able to output only a constraint of the form∃xout0(x)(e.g.,∃stop(out0(stop))). We define the following equivalence relation that allows us to abstract from these processes.

Definition 4(Observables). Let∼obe the output equivalent relation in Definition 2. We say that P and Q are observable equivalent, notation P∼obsQ, if Pk!tell(∃xout0(x))∼oQk!tell(∃xout0(x)).

Using the previous equivalence relation, we can show the following.

Proposition 1. Assume that c(~x)is a predicate symbol of arity|~x|.

1. If d6`c[~t/~x]for any~t then(wait~x;c)doP ===(d,d)⇒(wait~x;c)doP.

2. If P≡utell(c(~t))k(wait~x;c(~x))do nextQ then P ===⇒∼obsQ[~t/~x].

3 A Declarative Interpretation for Structured Communications

The encoding[[·]]fromHVKintoutccis defined in Table 3. Two noteworthy aspects when considering such a translation aredeterminacyandtimed behavior. Concerning determinacy, it is of uttermost impor- tance to recall that whileutccis a deterministic language,HVKprocesses may exhibit non-deterministic behavior. Moreover, whileHVKis a synchronous language, whereasutccis asynchronous. Consider, for instance, theHVKprocess:

P=k![~e];Q1|k![~e0];Q2|k?(~x)inQ3

(9)

[[requesta(k)inP]] = (localk) (tell(req(a,k))kwheneveracc(a,k)do next[[P]]) [[accepta(k)inP]] = (waitk;req(a,k))do(tell(acc(a,k))knext[[P]])

[[k![~e];P]] = tell(out(k,~e))kwheneverout(k,~e)do next[[P]]

[[k?(~x)inP]] = (wait~x;out(k,~x))do next[[P]]

[[kl;P]] = tell(sel(k,l))kwheneversel(k,l)do next[[P]]

[[k{l1:P1k. . .kln:Pn}]] = (waitl;sel(k,l))do

1≤i≤n

whenl=lido next[[Pi]]

[[throwk[k0];P]] = tell(outk(k,k0))kwheneveroutk(k,k0)do next[[P]]

[[catchk(k0)inP]] = wheneveroutk(k,k0)do next[[P]]

[[ifethenPelseQ]] = whenetruedo next[[P]]kwhenefalsedo next[[Q]]

[[P|Q]] = [[P]]k[[Q]]

[[inact]] = skip [[(νu)P]] = (localu) [[P]]

[[defDinP]] =

Xi(xiki)∈D

R[[Xi(xiki)]]Pb

Table 3: An Encoding fromHVKintoutcc. R[[·]]andPbare defined in Equation 1.

ProcessPcan have two possible transitions, and evolve intok![~e0];Q2| Q3[~e/~x]or intok![~e];Q1| Q3[~e0/~x].

In both cases, there is an output that cannot interact with the inputk?(~x)inQ3. Inutcc, inputs are repre- sented by abstractions which are persistent during a time unit. As a result, in the encoding ofPwe shall observe thatbothoutputs react with the same input, i.e. that[[P]] ===⇒[[Q3[~e/~x]]]k[[Q3[~e0/~x]]].

As for timed behavior, it is crucial to observe that whileHVKis an untimed calculus,utccprovides constructs for explicit time. In the encoding we shall advocate a timed interpretation of HVKin which all available synchronizations between processes occur at a given time unit, and the continuations of synchronized processes will be executed in the next time unit. This will prove convenient when showing the operational correspondence between both calculi, as we can relate the observable behavior inutcc and the reduction semantics inHVK.

Let us briefly provide some intuitions on[[·]]. ConsiderHVKprocessesP=requesta(k)inP0 and Q=accepta(x)inQ0. The encoding ofPdeclares a new variable sessionk and sends it through the channela by posting the constraintreq(a,k). Upon reception of the session key (local variable) gen- erated by[[P]], process[[Q]] adds the constraintacc(a,k) to notify the acceptance ofk. They can then synchronize on this constraint, and execute their continuations in the next time unit. The encoding of label selection and branching is similar, and uses constraint sel(k,l) for synchronization. We use the parallel composition ∏

1≤i≤n

whenl=lido next[[Pi]]to execute the selected choice. Notice that we do not require a non-deterministic choice since the constraintsl=li are mutually exclusive. As in [7], in the encoding ofifethenPelseQ we assume an evaluation function on expressions. Onceeis evaluated,↓e is aconstantboolean value. The encoding ofdefDinPexploits the scheme described in Equation 1.

Operational Correspondence. Here we study an operational correspondence property for our encod- ing. The differences with respect to (a)synchrony and determinacy discussed above will have a direct influence on the correspondence. Intuitively, the encoding falls short forHVKprograms featuring the kind of non-determinism that results from “uneven pairings” between session requesters/providers, label selection/branching, and inputs/outputs as in the example above.

(10)

We thus find it convenient to appeal to the type system ofHVKto obtain some basic determinacy of the source terms. Roughly speaking, the type discipline in [7] ensures a correct pairing between actions and co-actions once a session is established. Although the type system guarantees a correct match between (the types of) session requesters and providers, it does not rule out the kind of non- determinism induced by different orders in the pairing of requesters and providers. We shall then require session providers to be always willing to engage into a session. This is, given a channel a, we require that there is at most oneacceptprocess (possibly replicated) onathat is able to synchronize with every process requesting a session on a. Notice that this requirement is in line with a meaningful class of programs, namely those described by the type discipline developed in [2, 1].

Before presenting the operational correspondence, we introduce some auxiliary notions.

Definition 5 (Processes in normal form). We say that a HVKprocess P is innormal form if takes the forminactordefDinν~u(Q1| · · · |Qn)where neither the operators “ν” and “|” nor process variables occur in the top level of Q1, . . . ,Qn.

The following proposition states that given a processPwe can find a processP0in normal form, such that: eitherP0 is structurally congruent toP, or it results from replacing the process variables at the top level ofPwith their corresponding definition (using rule DEF).

Proposition 2. For all HVKprocess P there exists P0 in normal form s.t. P−→hhP0 only using the rulesDEFandSTRin Figure 1.

Proof. LetP be a process of the form defDinQ where there are no procedure definitions inQ. By repeated applications of the rule DEF, we can show thatP−→hP0 whereP0does not have occurrences of processes variables in the top level. Then, we use the rules of the structural congruence to move the local variables to the outermost position and findP00hP0in the desired normal form.

Notice that the rules of the operational semantics ofHVKare given for pairs of processes that can interact with each other. We shall refer to each of those pairs as aredex.

Definition 6(Redex). Aredexis a pair of complementary processes composed in parallel as in:

(1)requesta(k)inP|accepta(k)inQ (3)throwk[k0];P|catchk(k0)inQ.

(2)k![~e];P|k?(~x)inQ (4)kl;P|k{l1:P1k · · · kln:Pn}

Notice that a redex inHVKsynchronizes and reduces in a single transition as in(k![~e];P)|(k?(~x)inQ)

−→hP|Q[~e/~x]. Nevertheless, in utcc, the encoding of the processes above requires several internal transitions for adding the constraintout(k,~e)to the current store, and for “reading” that constraint by means of(wait~x;out(k,~x))do next[[Q]]to later executenext[[Q[~e/~x]]]. We shall then establish the op- erational correspondence between an observable transition of utcc (obtained from a finite number of internal transitions) and the following subset of reduction relations overHVKprocesses:

Definition 7(Outermost Reductions). Let P≡hdefDinν~x(Q1| · · · |Qn)be anHVKprogram in normal form. We define the outermost reduction relationP ===⇒hP0 as the maximal sequence of reductions P−→hP0hdefDinν~x0(Q01| · · · |Q0n)such that for every i∈ {1, ..n}, either

1. Qi=ifethenR1elseR2 −→hR1/2=Q0i;

2. for some j∈ {1, ..n}, Qi|Qj is a redex such that Qi|Qj−→hν~y(Q0i|Q0j), with~y⊆~x0; 3. there is no k∈ {1, ..n}such that Qi|Qkis a redex and QihQ0i.

(11)

One may argue that the above-presented definition may rule out some possible reductions inHVK.

Returning to the concerns about determinacy, an outermost reduction filters out cases where there are more than one possible reduction for a set of parallel processes (i.e.: the parallel composition of two outputs and one input with the same session key). The use of outermost reductions gives us a subset of possible reductions in HVKthat keeps synchronous processes and discard processes that are not going to interact in any way (recall that in the typing discipline of HVKthe composition of an input and an output with the same session key will consume the channel used; hence, every other process sending information over the same session will not have any complementary process to synchronize with).

In the sequel we shall thus consider only HVKprocesses P where for n≥1, ifP≡h P1 ===⇒h P2 ===⇒h· · · ===⇒hPnandP≡hP10 ===⇒hP20 ===⇒h· · · ===⇒hPn0thenPihPi0for alli∈ {1, ..,n}, i.e.,Pis adeterministicprocess.

Theorem 2(Operational Correspondence). Let P,Q be deterministicHVKprocesses in normal form and R,S beutccprocesses. It holds:

1)Soundness: If P ===⇒hQ then, for some R,[[P]] ===⇒R∼obs[[Q]];

2)Completeness: If[[P]] ===⇒S then, for some Q, P ===⇒hQ and[[Q]]∼obsS.

Proof. Assume thatP≡hdefDinν~x(Q1| · · · |Qn)andQ≡hdefDinν~x0(Q01| · · · |Q0n).

1. Soundness. SinceP ===⇒hQthere must exist a sequence of derivations of the formP≡hP1−→h P2−→h...−→hPnhQ. The proof proceeds by induction on the length of this derivation, with a case analysis on the last applied rule. We then have the following cases:

(a) Using the rule IF1. It must be the case that there existsQihifethenR1elseR2 andQi−→h R1hQ0i ande↓true. One can easily show thatwhene↓truedo next [[Q0i]] ===⇒[[Q0i]].

(b) Using the rule IF2Similarly as for IF1.

(c) Using the rule LINK. It must be the case that there existi,jsuch thatQihrequesta(k)inQ0i andQjhaccepta(x)inQ0jand thenQi|Qj−→h(νk)(Q0i|Q0j). We then have a derivation

[[Qi]]k[[Qk]] −→ (localk;c) (R0ikwheneveracc(a,k)do next[[Q0i]]k

(waitk0;req(a,k0))do(tell(acc(a,k0))knext([[Q0j]]))

−→ (localk;c0) (R0ikwheneveracc(a,k)do next[[Q0i]]k R0jktell(acc(a,k))knext([[Q0j[k/k0]]])

−→ (localk;c00) (R0ikR0jknext[[Q0i]]knext([[Q0j[k/k0]]])6−→

wherec=req(a,k),c0=c∧req(a,k),c00=c0acc(a,k)∧acc(a,k)andR0i,R0jare the pro- cesses resulting after the interaction of the processes in the parallel compositiontell(req(a,k))k (waitk0;req(a,k0))do · · ·, i.e.:

R0i u (localgo,stop;out0(go)out0(stop)c(~t))

next!unlessout0(stop)next tell(out0(go))knext!tell(out0(stop)) R0j u (localstop0,go0;out0(go0)c(~t)out0(stop0))next!tell(out0(stop0))

knext!unlessout0(stop0)next tell(out0(go0)) k(abs~x;c∧out0(go0)∧~x6.

=~t) (Qktell(c(~t))k!tell(out0(stop0)) knext!(abs~x;cout0(go0)) (Qktell(c(~t))k!tell(out0(stop0))

We notice thatR0ikR0j6−→and it is a process that can only output the constraintout0(x)where x is a local variable. By appealing to Proposition 1 we conclude [[Qi]]k[[Qj]] ===⇒∼obs (localk) ([[Q0i]]k[[Q0j]]).

(d) The cases using the rules LABELand PASScan be proven similarly as the case forLINK.

(12)

2. Completeness. Given the encoding and the structure ofP, we have autccprocessR= [[P]]s.t.

R≡u(local~x) ([[Q1]]k...k[[Qn]]).

LetRi= [[Qi]]for 1≤i≤n. By an analysis on the structure ofR, ifRi−→R0ithen it must be the case that either (a)Ri=whenedo next[[Q0i]]andR0i=next[[Q0i]]or (b)hRi,ci −→ hR0i,c∧diwhere d is a constraint of the formreq(·),sel(·),out(·), or outk(·). In both cases we shall show that there exists aR00i such thatRi−→R00i 6−→such thatQi−→hQ0iandR00i =next[[Q0i]].

(a) Assume thatRi=whene↓true do next[[Q0i]]for someQ0i. Then it must be the case that Qi=ifethenQ0ielseQ00i . Ife↓truewe then haveR00i =next[[Q0i]]. The case whene↓false is similar by consideringRi=whene↓falsedoQ0i.

(b) Assume now that hRi,ci −→ hR0i,c∧di where d is of the form req(·), sel(·), out(·) or outk(·). We proceed by case analysis of the constraintd. Let us consider only the cased=

k(req(a,k)); the cases in whichdtakes the formsel(·),out(·), oroutk(·)are handled sim- ilarly. Ifd=∃k(req(a,k))for somea, then we must have thatQihrequesta(k)inQ0i for somei. If there exists jsuch thatQjhaccepta(x)inQ0j, one can show a derivation similar to the case of the rule LINKin soundness to prove thatRikRj−→o(localk) (next[[Q0i]]k next[[Q0j]]). If there is noQjsuch thatQi |Qjforms a redex, then one can show by using (1) in Proposition 1 thatRi ===⇒∼obsRi.

4 A Timed Extension of HVK

We now propose an extension toHVKin which a bundled treatment of time is explicit and session closure is considered. More precisely, theHVKTlanguage arises as the extension ofHVKprocesses (Def. 1) with refined constructs for session request and acceptance, as well as with a construct for session abortion:

Definition 8(A timed language for sessions). HVKTprocesses are given by the following syntax:

P ::= requesta(k)duringmin P Timed Session Request

| accepta(k)givencin P Declarative Session Acceptance

| · · · { the other constructs, as in Def. 1 }

| killck Session Abortion

The intuition behind these three operators is the following: requesta(k)duringminPwill request a sessionk over the service nameaduringmtime units. Its dual construct isaccepta(k)givencinP:

it will grant the session key k when requested over the service name a provided by a session and a successful check over the constraintc. Notice thatc stands for a precondition for agreement between session request and acceptance. Inc, the durationmof the corresponding session keykcan be referenced by means of the variabledurk. In the encoding we syntactically replace it by the variable corresponding tom. Finally,killck will removeck from the valid set of sessions.

Adapting the encoding in Table 3 to considerHVKTprocesses is remarkably simple (see Table 4).

Indeed, modifications to the encoding of session request and acceptance are straightforward. The most evident change is the addition of the parametermwithin the constraintreq(a,k,m). The duration of the requested session is suitably represented as a bounded replication of the process defining the activation of the sessionkrepresented as the constraintact(k). The execution of the continuation[[P]]is guarded by the constraintact(k)(i.e.Pcan be executed only when the sessionkis valid). Thus, in the encoding we use the functionGd(P) to denote the process behaving asPwhen the constraintd can be entailed from the current store, doing nothing otherwise. More precisely:

(13)

[[requesta(k)duringminP]] = (localk)tell(req(a,k,m))k

wheneveracc(a,k)do next(tell(act(k))kGact(k)([[P]])k

![m]unlesskill(k)next tell(act(k))) [[accepta(k)givencinP]] = (waitk;req(a,k,m)c[m/durk])do(tell(acc(a,k))knextGact(k)([[P]]))

[[killk]] = !tell(kill(k))

Table 4: The Extended Encoding.Gd(P)is in Definition 9.

Definition 9. LetG :C →Procs→Procs be defined as

Gd(skip) =skip Gd(P1kP2) =Gd(P1)kGd(P2)

Gd(tell(c)) =whenddo tell(c) Gd(!Q) =!Gd(Q)

Gd(nextQ) =whenddo nextGd(Q) Gd((abs~x;c)Q) =(abs~x;c)Gd(Q) if~x/fv(d) Gd(unlesscnextQ) =whenddo unlesscnextGd(Q) Gd((local~x;c)Q) =(local~x;c)Gd(Q) if~x/fv(d)

On the side of session acceptance, the main novelty is the introduction ofc[m/durk]. As explained before, we syntactically replace the variabledurk by the corresponding duration of the sessionm. This is a generic way to represent the agreement that should exist between a service provider and a client; for instance, it could be the case that the client is requesting a session longer than what the service provider can or want to grant.

4.1 Case Study: Electronic booking

Here we present an example that makes use of the constructs introduced inHVKT.

Let us consider an electronic booking scenario. On one side, consider a company AC which offers flights directly from its website. On the other side, there is a customer looking for the best offers. In this scenario, the customer establishes a timed session with AC and asks for a flight proposal given a set of constraints (dates allowed, destination, etc.). After receiving an offer from AC, the customer can refine the selection further (e.g. by checking that the prices are below a given threshold) and loops until finding a suitable option, that he will accept by starting the booking phase. One possibleHVKTspecification of this scenario is described in Table 5.

Customer = requestob(k)duringmin(k![bookingdata];Select(k))

Select(k) = k?(o f f er)in(if(o f f er.price1500)thenkContract;elseSelect(k) ) AC = acceptob(k)givendurkMAX T IMEin(k?(bookingData)in

(νu)k![u];k

Contract:AcceptkRe ject:killk )

Table 5: Online booking example with two agents.

In a second stage, the customer uses an online broker to mediate between him and a set of airlines acting as service providers. Letnbe the number of service providers, and consider two vectors of fixed length: Offers, which contains the list[Offers0, . . . ,Offersi, . . . ,Offersn]of offers received by a customer, and SP, which contains the list of trusted services. First, the customer establishes a session with the broker for a given periodm; later on, he/she starts requesting for a flight by providing the details of his/her trip to the broker. On the other side, the broker will look into his pool of trusted service providers for the ones that can supply flights that suit the customer’s requirements. All possible offers are transferred back to the customer, who will invoke a local procedureSel (not specified here) that selects one of the offers

Références

Documents relatifs

The first cycle of this action research method was reported in (Mazo and Jaramillo 2019) and the resulting template was used as input for the second cycle, which was

We illustrate how it is possible to reuse abstract domains previously defined for logic programming, e.g., to perform a groundness analysis for tcc programs.. We show the

Abstract diagnosis [8] is a declarative debugging framework which extends the methodology in [10,19], based on using the immediate consequence operator to identify bugs in

We represent these equations by a timed concurrent constraint (ntcc) language, which can deal with partial information and the time for a reaction to occur.. We describe a

Thus, the calculus integrates two dimensions of computation: a horizontal dimension dealing with partial information (e.g., note > 60) and a vertical one in which

The new calculus called Universal Timed Concurrent Constraint (utcc) increases the expressiveness of tcc languages allowing infinite behaviour and mo- bility.. the later can be

A Declarative Framework for Security: Secure Concurrent Constraint Programming..

In order to attain a semantical meaning of these epistemic behaviors we use declarative models, specifically con- straint systems ; algebraic structures that operate on elements