Service-Oriented Logic Programming

We develop formal foundations for notions and mechanisms needed to support service-oriented computing. Our work builds on recent theoretical advancements in the algebraic structures that capture the way services are orchestrated and in the processes that formalize the discovery and binding of services to given client applications by means of logical representations of required and provided services. We show how the denotational and the operational semantics specific to conventional logic programming can be generalized using the theory of institutions to address both static and dynamic aspects of service-oriented computing. Our results rely upon a strong analogy between the discovery of a service that can be bound to an application and the search for a clause that can be used for computing an answer to a query; they explore the manner in which requests for external services can be described as service queries, and explain how the computation of their answers can be performed through service-oriented derivatives of unification and resolution, which characterize the binding of services and the reconfiguration of applications.


Introduction
Service-Oriented Computing.Service-oriented computing is a modern computational paradigm that deals with the execution of programs over distributed information-processing infrastructures in which software applications can discover and bind dynamically, at run time, to services offered by providers.Whereas the paradigm has been effectively in use for a more than a decade in the form of Web services [ACKM04] or Grid computing [FK04], research into its formal foundations has lagged somewhat behind, partly because of our lack of understanding of (or agreement on) what is really new about the paradigm, especially in relation to distributed computing in general (see, for example, [Vog03]).
It is fair to say that significant advances have been made towards formalizing new forms of distributed computation that have arisen around the notion of service (e.g.choreography [SBFZ07]), notably through several variants of the π-calculus.However, service-oriented computing raises more profound challenges at the level of the structure of systems due to their ability to discover and bind dynamically, in a non-programmed manner, to other systems.The structure of the systems that we are now creating in the virtual space of computational networks is intrinsically dynamic, a phenomenon hitherto unknown.Formalisms such as the π-calculus do not address these structural properties of systems.This prevents us from fully controlling and developing trust in the systems that are now operating in cyberspace, and also from exploiting the power of the paradigm beyond the way it is currently deployed.
Towards that end, we have investigated algebraic structures that account for modularity (e.g.[FLB07,FS07]) -referring to the way services are orchestrated as composite structures of components and how binding is performed through interaction protocols -and the mechanisms through which discovery can be formalized in terms of logical specifications of required/provided services and constraint optimisation for service-level agreements (e.g.[FLB11,FL13b]).In the present paper, we take further this research to address the operational aspects behind dynamic discovery and binding, i.e. the mechanisms through which applications discover and bind, at run time, to services.Our aim is to develop an abstract, foundational setting -independent of the specific technologies that are currently deployed, such as soap for message-exchange protocols and uddi for description, discovery, and integration -that combines both the denotational and the operational semantics of services.The challenge here is to define an integrated algebraic framework that accounts for (a) logical specifications of services, (b) the way models of those specifications capture orchestrations of components that may depend on externally provided services to be discovered, and (c) the way the discovery of services and the binding of their orchestrations to client applications can be expressed in logical/algebraic terms.Logic Programming.The approach that we propose to develop to meet this challenge builds on the relational variant of (Horn-clause) logic programming -the paradigm that epitomizes the integration of declarative and operational aspects of logic.In conventional logic programming, clauses have a declarative semantics as universally quantified implications that express relationships over a domain (the Herbrand universe), and an operational semantics that derives from resolution and term unification: definite clauses (provided by a given logic program) are used to resolve logic-programming queries (expressed as existentially quantified conjunctions) by generating new queries and, through term unification, computing partial answers as substitutions for the variables of the original query.
In a nutshell, the analogy between service-oriented computing and conventional logic programming that we propose to systematically examine in this paper unfolds as follows: • The Herbrand universe consists of those service orchestrations that have no dependencies on external services -what we refer to as ground orchestrations.• Variables and terms correspond to dependencies on external services that need to be discovered and to the actual services that are made available by orchestrations.• Service clauses express conditional properties of services required or provided by orchestrations, thus capturing the notion of service module described in [FLB11].Their declarative semantics is that, when bound to the orchestrations of other service clauses that ensure the required properties, they deliver, through their orchestration, services that satisfy the specified properties.
• Service queries express properties of orchestrations of services that an application requires in order to fulfil its goal -what we describe in [FLB11] as activity modules.• Logic programs define service repositories as collections of service modules.
• Resolution and term unification account for service discovery by matching required properties with provided ones and the binding of required with provided services.
The structure of the paper.Our research into the logic-programming semantics of service-oriented computing is organized in two parts.In Section 2 we present a new categorical model of service orchestrations, called orchestration scheme, that enables us to treat orchestrations as fully abstract entities required to satisfy only a few elementary properties.This framework is flexible enough to accommodate, for example, orchestrations in the form of program expressions, as considered in [Fia12], or as asynchronous relational networks similar to those defined in [FL13a].In our study, such schemes play an essential role in managing the inherent complexity of orchestrations whilst making available, at the same time, the fundamental building blocks of service-oriented logic programming.In Section 3, we define a logical system of orchestration schemes over which we can express properties that can be further used to guide the interconnection of orchestrations.We recall from [T ¸F15] the algebraic structures that underlie institution-independent logic programming, in particular the substitution systems that are characteristic of relational logic programming, and prove that the resulting logic of orchestration schemes constitutes a generalized substitution system.This result is central to our work, not only because it provides the declarative semantics of our approach to service-oriented computing, but also because it gives a definite mathematical foundation to the analogy between service-oriented computing and conventional logic programming outlined above.Building on these results, we show how clauses, queries, unification and resolution can be defined over the generalized substitution system of orchestration schemes, providing in this way the corresponding operational semantics of service-oriented computing.
The work presented herein continues our investigation on logic-independent foundations of logic programming reported in [T ¸F15].As such, it is based on the theory of institutions of Goguen and Burstall [GB92]; although familiarity with the institution-independent presentation of logic programming is not essential, some knowledge of basic notions of institution theory such as institution, (co)morphism of institutions, and also of the description of institutions as functors into the category of rooms [Dia08,ST11] is presumed.

Orchestration Schemes
The first step in the development of the particular variant of logic programming that we consider in this paper consists in determining appropriate categorical abstractions of the structures that support service-oriented computing.These will ultimately allow us to describe the process of service discovery and binding in a way that is independent of any particular formalism (such as various forms of automata, transition systems or process algebras).
Our approach is grounded on two observations: first, that orchestrations can be organized as a category whose arrows, or more precisely, cospans of arrows, can be used to model the composition of service components (as defined, for example, in [FLB07,FLB11,FL13b]); second, that the discovery of a service to be bound to a given client application can be formalized in terms of logical specifications of required and provided properties, ensuring that the specification of the properties offered by the service provider refines the specification of the properties requested by the client application.To this end, we explore the model-theoretic notion of refinement advanced in [ST88], except that, in the present setting, the structures over which specifications are evaluated are morphisms into ground orchestrations, i.e. into orchestrations that have no dependencies on external services.The motivation for this choice is that, in general, the semantics of non-ground orchestrations is open: the (observable) behaviour exhibited by non-ground orchestrations varies according to the external services that they may procure at run time.With these remarks in mind, we arrive at the following concept of orchestration scheme.
Definition 2.1 (Orchestration scheme).An orchestration scheme is a quadruple Orc, Spec, Grc, Prop consisting of • a category Orc of orchestrations and orchestration morphisms, • a functor Spec : Orc → Set that defines a set Spec(o) of service specifications over o for every orchestration o, • a full subcategory Grc ⊆ Orc of ground orchestrations, and • a functor Prop : Grc → Set that defines a natural subset Prop(g) ⊆ Spec(g) 1 of properties of g (specifications that are guaranteed to hold when evaluated over g) for every ground orchestration g.
To illustrate our categorical approach to orchestrations, we consider two main running examples: program expressions as discussed in [Fia12] (see also [Mor94]), which provide a way of constructing structured (sequential) programs through design-time discovery and binding, and the theory of asynchronous relational networks put forward in [FL13a], which emphasizes the role of services as an interface mechanism for software components that can be composed through run-time discovery and binding.

Program Expressions.
The view that program expressions can be seen as defining 'service orchestrations' through which structured programs can be built in a compositional way originates from [Fia12].Intuitively, we can see the rules of the Hoare calculus [Hoa69] as defining 'clauses' in the sense of logic programming, where unification is controlled through the refinement of pre/post-conditions as specifications of provided/required services, and resolution binds program statements (terms) to variables in program expressions.In Figure 1 we depict Hoare rules in a notation that is closer to that of service modules, which also brings out their clausal form: the specification (a pair of a pre-and a post-condition) on the lefthand side corresponds to the consequent of the clause (which relates to a 'provides-point' of the service), while those on the right-hand side correspond to the antecedent of the clause (i.e. to the 'requires-points' of the service) -the specifications of what remains to be discovered and bound to the program expression (the 'service orchestration' inside the box) to produce a program.In Figure 2, we retrace Hoare's original example of constructing a program that computes the quotient and the remainder resulting from the division of two natural numbers as an instance of the unification and resolution mechanisms particular to logic programming.We will further discuss these mechanisms in more detail in Subsection 3.3.
The formal description of program expressions that we consider here follows the presentation given in [GM96] of the algebraic semantics of programs except that, instead of the theory of many-sorted algebra, we rely on the theory of preordered algebra developed in [DF98], whose institution we denote by POA.In this context, signatures are ordinary 1 By describing the set Prop(g) as a natural subset of Spec(g) we mean that the family of inclusions (Prop(g) ⊆ Spec(g)) g∈|Grc| defines a natural transformation from Prop to (Grc ⊆ Orc) ; Spec.skip ρ, ρ (empty statement) x := e ρ(e), ρ(x) (assignment) Figure 1: Program modules algebraic signatures whose denotation is defined over the category of preorders rather than that of sets, with models interpreting the sorts as preordered sets and the operation symbols as monotonic functions.The sentences are built as in first-order logic based on two kinds of atoms: equational atoms l = r and preorder atoms l → r, where l and r are terms of the same sort; the latter are satisfied by a preordered algebra A if and only if the interpretations of l and r in A belong to the preorder relation of the carrier of their sort.
In order to fully define the orchestration scheme of program expressions we assume that the programming language we have chosen to analyse is specified through a many-sorted signature S, F equipped with • a distinguished set of sorts S pgm ⊂ S corresponding to the types of executable expressions supported by the language, and sorts State, Config ∈ S \ S pgm capturing the states of the programs and the various configurations that may arise upon their execution, respectively; SP 15 q := q + 1 SP 16 r := r − y Figure 2: The derivation of a program that computes the quotient q and the remainder r obtained from the division of x by y SP 1 : true, x = q * y + r ∧ r < y SP 12 : x = (q + 1) * y + (r − y) , x = q * y + r SP 5 : true, x = q * y + r SP 13 : x = (q + 1) * y + (r − y) , x = q * y + (r − y) SP 6 : true, x = q * y + x SP 14 : x = q * y + (r − y) , x = q * y + r SP 7 : x = q * y + x , x = q * y + r SP 15 : x = (q + 1) * y + (r − y) , x = q * y + (r − y) To simplify our presentation, we omit the details associated with the sorts Id of identifiers, AExp of arithmetic expressions and Cond of conditions; we also tacitly assume that the signature under consideration declares the usual operation symbols associated with the names of identifiers, the addition, subtraction and multiplication of arithmetic expressions, and with the atoms and Boolean connectives specific to conditions.Moreover, we assume the essential sorts State and Config to be defined, as well as the operation symbols and , .
Algebraic signatures having the aforementioned additional structure induce orchestration schemes in a canonical way, as follows.
Orchestrations.The orchestrations are program expressions, that is S, F ∪ Var -terms pgm : eXp, usually denoted simply by pgm if there is no danger of confusion, such that eXp is a sort in S pgm .The arrows through which they are linked generalize the subterm relations; in this sense, a morphism ψ, π between programs pgm 1 : eXp 1 and pgm 2 : eXp 2 consists of • a substitution ψ : var(pgm 1 ) → var(pgm 2 ), mapping the variables that occur in pgm 1 to program expressions defined over the variables of pgm 2 , together with • a position π in pgm 2 , i.e. a sequence of natural numbers that precisely identifies a particular occurrence of a subterm pgm 2 π of pgm 2 , such that ψ tm (pgm 1 ) = pgm 2 π . 3Their composition is defined componentwise, in a way that ensures the commutativity of the following diagram.
Specifications.For each program expression pgm : eXp, a (program) specification is a triple of the form ι : [ρ, ρ ], where ι is a position in pgm indicating the 'subprogram' of pgm whose behaviour is being analysed, 4 and ρ and ρ are pre-and post-conditions associated with pgm ι , formalized as (quantifier-free) POA-sentences over the signature S, F ∪ {st : State} .The intuitive interpretation is the usual one: Whenever the program pgm ι is executed in an initial state that satisfies the pre-condition ρ, and the execution terminates, the resulting final state satisfies the post-condition ρ .Note, however, that specifications cannot be evaluated over arbitrary program expressions because, due to the presence of program variables (from Var ), some of the programs may not support a well-defined notion of execution.We will address this aspect in Section 3 by taking into account translations of specifications along morphisms whose codomains are ground program expressions.For now, it suffices to mention that the translation of a program specification ι : [ρ, ρ ] of pgm 1 : eXp 1 along a morphism ψ, π : (pgm 1 : eXp 1 ) → (pgm 2 : eXp 2 ) is defined as the specification (π • ι) : [ψ(ρ), ψ(ρ )] of pgm 2 : eXp 2 .Ground orchestrations and properties.As expected, ground program expressions are just program expressions that do not contain variables: S, F -terms pgm : eXp whose sort eXp belongs to S pgm .Consequently, they have a well-defined operational semantics, which means that we can check whether or not they meet the requirements of a given specification.
A specification ι : [ρ, ρ ] is a property of a ground program expression pgm : eXp if and only if the following satisfaction condition holds for the preordered algebra A: To keep the notation simple and, at the same time, emphasize the roles of st and st , we used ρ(st) in the above POA-sentence as another name for ρ, while ρ (st ) is the sentence derived from ρ by replacing the variable st with st . 5The same notational convention is used in Figure 1 to represent the specification attached to the assignment expression.In that case, ρ is assumed to be a sentence defined not only over st : State, but also over a variable v : AExp; the sentences ρ(e) and ρ(x) are then derived from ρ by replacing v with e and x (regarded as an atomic arithmetic expression), respectively.Another notation used in Figure 1 (and also in Figure 2) is C , where C is a term of sort Cond; this follows Iverson's convention (see [Ive62], and also [GKP94]), and corresponds to an atomic POA-sentence that captures the semantics of the condition C.
We conclude the presentation of orchestrations as program expressions with Proposition 2.3 below, which guarantees that properties form natural subsets of the sets of specifications; in other words, the morphisms of ground programs preserve properties.
2.2.Asynchronous Relational Networks.Asynchronous relational networks as developed in [FL13a] uphold a significantly different perspective on services: the emphasis is put not on the role of services in addressing design-time organisational aspects of complex, interconnected systems, but rather on their role in managing the run-time interactions that are involved in such systems.In this paper, we consider a variant of the original theory of asynchronous relational networks that relies on hypergraphs instead of graphs, and uses ω-automata [Tho90] (see also [PP04]) instead of sets of traces as models of behaviour.
The notions discussed within this context depend upon elements of linear temporal logic, and are introduced through dedicated syntactic structures that correspond to specific temporal signatures and signature morphisms.However, the proposed theory is largely independent of any logical framework of choice -similarly to the way in which program expressions can be defined over a variety of algebraic signatures -and can be easily adapted to any institution for which 1. the category of signatures is (finitely) cocomplete; 2. there exist cofree models along every signature morphism, meaning that the reduct functors determined by signature morphisms admit right adjoints; 3. the category of models of every signature has (finite) products; 4. all model homomorphisms reflect the satisfaction of sentences.In addition to the above requirements, we implicitly assume, as is often done in institutions (see, for example, [Dia08] and [ST11] for more details), that the considered logical system is closed under isomorphisms, meaning that the satisfaction of sentences is invariant with respect to isomorphisms of models.This property holds in most institutions; in particular, it holds in the variant of temporal logic that we use here as a basis for the construction of the orchestration scheme of asynchronous relational networks.
Linear Temporal Logic.In order to capture a more operational notion of service orchestration, we work with an automata-based variant of the institution LTL of linear temporal logic [FC96].This logical system, denoted aLTL, has the same syntax as LTL, which means that signatures are arbitrary sets of actions, and that signature morphisms are just functions.With respect to sentences, for any signature A, the set of A-sentences is defined as the least set containing the actions in A that is closed under standard Boolean connectives6 and under the temporal operators next ( ) and until ( U ).As usual, the derived temporal sentences 3ρ and 2ρ stand for true U ρ and ¬(true U ¬ρ), respectively.
The semantics of aLTL is defined over (non-deterministic finite-state) Muller automata [Mul63] instead of the more conventional temporal models.This means that, in the present setting, the models of a signature A are Muller automata states, and a subset F ⊆ P(Q) of (non-empty) final-state sets.
The satisfaction relation is based on that of LTL: an automaton Λ satisfies a sentence ρ if and only if every trace accepted by Λ satisfies ρ in the sense of LTL.To be more precise, let us first recall that a trace over A is an (infinite) sequence λ ∈ P(A) ω , and that a run of an automaton Λ defined as above on a trace λ is a state sequence ∈ Q ω such that (0) ∈ I and ( (i), λ(i), (i + 1)) ∈ ∆ for every i ∈ ω.A run is said to be successful if its infinity set, i.e. the set of states that occur infinitely often in , denoted Inf( ), is a member of F. Then a trace λ is accepted by Λ if and only if there exists a successful run of Λ on λ.Finally, given a trace λ (that can be presumed to be accepted by Λ) and i ∈ ω, we use the notation λ(i..) to indicate the suffix of λ that starts at λ(i).The satisfaction of temporal sentences by traces can now be defined by structural induction, as follows: where a is an action in A, ρ, ρ 1 and ρ 2 are A-sentences, and E is a set of A-sentences.
One can easily see that the first of the hypotheses 1-4 that form the basis of the present study of asynchronous relational networks is satisfied by aLTL, as it corresponds to a wellknown result about the existence of small colimits in Set.In order to check that the remaining three properties hold as well, let us first recall that a homomorphism h : and h(F 1 ) ⊆ F 2 .We also note that for any map σ : A → A , i.e. for any signature morphism, and any Muller automaton Λ = Q , P(A ), ∆ , I , F , the reduct Λ σ is the automaton Q , P(A), ∆ σ , I , F with the same states, initial states and final-state sets as Λ , and with the transition relation given by ∆ σ = {(p , σ −1 (α ), q ) | (p , α , q ) ∈ ∆ }.
The following results enable us to use the institution aLTL as a foundation for the subsequent development of asynchronous relational networks.In particular, Proposition 2.4 ensures the existence of cofree Muller automata along signature morphisms; Proposition 2.5 allows us to form products of Muller automata based on a straightforward categorical interpretation of the fact that the sets of traces accepted by Muller automata, i.e. regular ω-languages, are closed under intersection; and finally, Proposition 2.6 guarantees that all model homomorphisms reflect the satisfaction of temporal sentences.
Proposition 2.4.For every morphism of aLTL-signatures σ : A → A , the reduct functor σ : Mod aLTL (A ) → Mod aLTL (A) admits a right adjoint, which we denote by ( ) σ .Proof.According to a general result about adjoints, it suffices to show that for any automaton Λ over the alphabet P(A) there exists a universal arrow from σ to Λ.
Proposition 2.5.For any set of actions A, the category Mod aLTL (A) of Muller automata defined over the alphabet P(A) admits (finite) products.
Proof.Let (Λ i ) i∈J be a (finite) family of Muller automata over the alphabet P(A), with Λ i given by Q i , P(A), ∆ i , I i , F i .We define the automaton Λ = Q, P(A), ∆, I, F by where the functions π i : Q → Q i are the corresponding projections of the Cartesian product i∈J Q i .By construction, it immediately follows that for every i ∈ J, the map π i defines a homomorphism of automata Λ → Λ i .Even more, one can easily see that for any other family of homomorphisms (h i : Λ → Λ i ) i∈J , with Λ = Q , P(A ), ∆ , I , F , the unique map h : Q → Q such that h ; π i = h i for all i ∈ J defines a homomorphism of automata as well.Therefore, the automaton Λ and the projections (π i ) i∈J form the product of (Λ i ) i∈J .
Proposition 2.6.Let h : Λ 1 → Λ 2 be a homomorphism between automata defined over an alphabet P(A).Every temporal sentence over A that is satisfied by Λ 2 is also satisfied by Λ 1 .Proof.Suppose that Λ i = Q i , P(A), ∆ i , I i , F i , for i ∈ {1, 2}.Since the map h : Q 1 → Q 2 defines a homomorphism of automata, for every successful run ∈ Q ω 1 of Λ 1 on a trace λ ∈ P(A) ω , the composition ; h yields a successful run of Λ 2 on λ.As a result, Λ 2 accepts all the traces accepted by Λ 1 , which further implies that Λ 1 satisfies all temporal sentences that are satisfied by Λ 2 .
Service Components.Following [FL13a], we regard service components as networks of processes that interact asynchronously by exchanging messages through communication channels.Messages are considered to be atomic units of communication.They can be grouped either into sets of messages that correspond to processes or channels, or into specific structures, called ports, through which processes and channels can be interconnected.
The ports can be viewed as sets of messages with attached polarities.As in [BZ83,BCT06] we distinguish between outgoing or published messages (labelled with a minus sign), and incoming or delivered messages (labelled with a plus sign).
Definition 2.7 (Port).A port M is a pair M − , M + of disjoint (finite) sets of published and delivered messages.The set of all messages of M is given by M − ∪ M + and is often denoted simply by M .Every port M defines the set of actions A Processes are defined by sets of interaction points labelled with ports and by automata that describe their behaviour in terms of observable publication and delivery actions.
Definition 2.8 (Process).A process is a triple X, (M x ) x∈X , Λ that consists of a (finite) set X of interaction points, each point x ∈ X being labelled with a port M x , and a Muller automaton Λ over the alphabet P(A M ), where M is the port given by Example 2.9.In Figure 3 we depict a process JP (for Journey Planner) that provides directions from a source to a target location.The process interacts with the environment by means of two ports, named JP 1 and JP 2 .The first port is used to communicate with potential client processes -the request for directions (including the source and the target locations) is encoded into the incoming message planJourney, while the response is represented by the outgoing message directions.The second port defines messages that JP exchanges with other processes in order to complete its task -the outgoing message getRoutes can be seen as a query for all possible routes between the specified source and target locations, while the incoming messages routes and timetables define the result of the query and the timetables of the available transport services for the selected routes.
The behaviour of JP is given by the Muller automaton depicted in Figure 4, whose final-state sets contain q 0 whenever they contain q 5 .We can describe it informally as follows: whenever the process JP receives a request planJourney it immediately initiates the search for the available routes by sending the message getRoutes; it then waits for the delivery of the routes and of the corresponding timetables, and, once it receives both, it compiles the directions and replies to the client.In the graphical representation, transitions are labelled with propositional sentences, as in [AS87]; this means that there exists a transition for any propositional model (i.e.set of actions) of the considered sentence.
Remark 2.10.To generalize Definition 2.8 to an arbitrary institution (subject to the four technical assumptions listed at the beginning of the subsection), we first observe that every polarity-preserving map θ between ports M and M defines a function A θ : A M → A M , i.e. a morphism of aLTL-signatures, usually denoted simply by θ, that maps every publication action m! to θ(m)! and every delivery action m¡ to θ(m)¡.Moreover, for any process X, (M x ) x∈X , Λ , the injections (x.: A Mx → A M ) x∈X define a coproduct in the category of aLTL-signatures.This allows us to introduce an abstract notion of process as a triple X, (ι x : Σ x → Σ) x∈X , Λ that consists of a set X of interaction points, each point x ∈ X being labelled with a port signature Σ x , a process signature Σ together with morphisms ι x : Σ x → Σ for x ∈ X (usually defining a coproduct), and a model Λ of Σ.
Processes communicate by transmitting messages through channels.As in [BZ83,FL13a], channels are bidirectional: they may transmit both incoming and outgoing messages.
Definition 2.11 (Channel).A channel is a pair M, Λ that consists of a (finite) set M of messages and a Muller automaton Λ over the alphabet P(A M ), where A M is given by the union Note that channels do not provide any information about the communicating entities.In order to enable given processes to exchange messages, channels need to be attached to their ports, thus forming connections.Definition 2.12 (Connection).A connection M, Λ, (µ x : M M x ) x∈X between the ports (M x ) x∈X consists of a channel M, Λ and a (finite) family of partial attachment injections (µ x : M M x ) x∈X such that M = x∈X dom(µ x ) and for any point x ∈ X, This notion of connection generalizes the one found in [FL13a] so that messages can be transmitted between more than two ports.The additional condition ensures in this case that messages are well paired: every published message of M x , for x ∈ X, is paired with a delivered message of M y , for y ∈ X \ {x}, and vice versa.One can also see that for any binary connection, the attachment injections have to be total functions; therefore, any binary connection is also a connection in the sense of [FL13a].
Example 2.13.In order to illustrate how the process JP can send or receive messages, we consider the connection C depicted in Figure 5 that moderates the flow of messages between the port named JP 2 and two other ports, named R 1 and R 2 .
The underlying channel of C is given by the set of messages M = {g, r, t} together with the automaton Λ C that specifies the delivery of all published messages without any delay; Λ C can be built as the product of the automata Λ m , for m ∈ M , whose transition map is depicted in Figure 6, and whose sets of states are all marked as final.The channel is attached to the ports JP 2 , R 1 and R 2 through the partial injections • µ JP 2 : M → M JP 2 given by g → getRoutes, r → routes and t → timetables, given by g → getRoutes and r → routes, and given by r → routes and t → timetables.These injections specify the actual senders and receivers of messages.For instance, the message g is delivered only to the port R 1 (because µ R 2 is not defined on g), whereas r is simultaneously delivered to both JP 2 and R 2 .
As already suggested in Examples 2.9 and 2.13, processes and connections have dual roles, and they interpret the polarities of messages accordingly.In this sense, processes are responsible for publishing messages (i.e. they regard delivered messages as inputs and published messages as outputs), while connections are responsible for delivering messages.This dual nature of connections can be made explicit by taking into account, for every connection M, Λ, (µ x : M M x ) x∈X , partial translations (A µx : A M A Mx ) x∈X of the actions defined by the channel into actions defined by the ports, as follows: x (M + x ).We usually designate the partial maps A µx simply by µ x if there is no danger of confusion.
Remark 2.14.Just as in the case of processes, we can define connections based on an arbitrary logical system, without relying on messages.To achieve this goal, note that, in aLTL, every connection M, Λ, (µ x : M M x ) x∈X determines a family of spans Then we can consider connections more generally as triples Σ, Λ, (ι x : Σ x → Σ, µ x : Σ x → Σ x ) x∈X in which the signature Σ and the model Λ of Σ abstract the channel component, and the spans of signature morphisms (ι x , µ x ) x∈X provide the means of attaching port signatures to the channel.
We can now define asynchronous networks of processes as hypergraphs having vertices labelled with ports and hyperedges labelled with processes or connections.Definition 2.15 (Hypergraph).A hypergraph X, E, γ consists of a set X of vertices or nodes, a set E of hyperedges, disjoint from X, and an incidence map γ : E → P(X), defining for every hyperedge e ∈ E a non-empty set γ e ⊆ X of vertices it is incident with.
A hypergraph X, E, γ is said to be edge-bipartite if it admits a distinguished partition of E into subsets F and G such that no adjacent hyperedges belong to the same part, i.e. for every e 1 , e 2 ∈ E such that γ e 1 ∩ γ e 2 = ∅, either e 1 ∈ F and e 2 ∈ G, or e 1 ∈ G and e 2 ∈ F .
Hypergraphs have been used extensively in the context of graph-rewriting-based approaches to concurrency, including service-oriented computing (e.g.[BGLL09, FHL + 05]).We use them instead of graphs [FL13a] because they offer a more flexible mathematical framework for handling the notions of variable and variable binding required in Section 3. Definition 2.16 (Asynchronous relational networkarn).An asynchronous relational network N = X, P, C, γ, M, µ, Λ consists of a (finite) edge-bipartite hypergraph X, P, C, γ of points x ∈ X, computation hyperedges p ∈ P and communication hyperedges c ∈ C, and of • a port M x for every point x ∈ X, • a process γ p , (M x ) x∈γp , Λ p for every hyperedge p ∈ P , and Example 2.17.By putting together the process and the connection presented in Examples 2.9 and 2.13, we obtain the arn JourneyPlanner depicted in Figure 7.Its underlying hypergraph consists of the points JP 1 , JP 2 , R 1 and R 2 , the computation hyperedge JP, the communication hyperedge C, and the incidence map γ given by γ JP = {JP 1 , JP 2 } and The Orchestration Scheme of Asynchronous Relational Networks.Let us now focus on the manner in which arns can be organized to form an orchestration scheme.We begin with a brief discussion on the types of points of arns, which will enable us to introduce notions of morphism of arns and ground arn.
An interaction point of an arn N is a point of N that is not bound to both computation and communication hyperedges.We distinguish between two types of interaction points, called requires-and provides-points, as follows.
Definition 2.18 (Requires-and provides-point).A requires-point of an arn N is a point of N that is incident only with a communication hyperedge.Similarly, a provides-point of N is a point incident only with a computation hyperedge.
For the arn JourneyPlanner depicted in Figure 7, the points R 1 and R 2 are requires-points (incident with the communication hyperedge C), whereas JP 1 is a provides-point (incident with the computation hyperedge JP).
Orchestrations.In order to describe arns as orchestrations we first need to equip them with appropriate notions of morphism and composition of morphisms.Morphisms of arns correspond to injective homomorphisms between their underlying hypergraphs, and are required to preserve all labels, except those associated with points that, like the requirespoints, are not incident with computation hyperedges.
Definition 2.19 (Homomorphism of hypergraphs).A homomorphism h between hypergraphs X 1 , E 1 , γ 1 and X 2 , E 2 , γ 2 consists of functions h : X 1 → X 2 and h : such that for any vertex x ∈ X 1 and hyperedge e ∈ E 1 , x ∈ γ 1 e if and only if h(x) ∈ γ 2 h(e) .Definition 2.20 (Morphism of arns).Given two arns between the underlying hypergraphs of N 1 and N 2 such that θ(P 1 ) ⊆ P 2 and θ(C 1 ) ⊆ C 2 , and • a family θ pt of polarity-preserving injections θ pt • for every point x ∈ X 1 incident with a computation hyperedge, , and and the following diagram commutes, for every point x ∈ γ 1 c .
It is straightforward to verify that the morphisms of arns can be composed in terms of their components.Their composition is associative and has left and right identities given by morphisms that consists solely of set-theoretic identities.We obtain in this way the first result supporting the construction of an orchestration scheme of arns.
Proposition 2.21.The morphisms of arns form a category, denoted ARN.Specifications.To define specifications over given arns, we label their points with linear temporal sentences, much in the way we used pre-and post-conditions as labels for positions in terms when defining specifications of program expressions.
Definition 2.22 (Specification over an arn).For any arn N, the set Spec(N) of N-specifications is the set of pairs x, ρ , usually denoted @ x ρ, where x is a point of N and ρ is an aLTL-sentence over A Mx , i.e. over the set of actions defined by the port that labels x.
The translation of specifications along morphisms of arns presents no difficulties: for every morphism θ : N → N , the map Spec(θ) : Spec(N) → Spec(N ) is given by Spec(θ)(@ x ρ) = @ θ(x) Sen aLTL (θ pt x )(ρ) for each point x of N and each aLTL-sentence ρ over the actions of x.Furthermore, it can be easily seen that it inherits the functoriality of the translation of sentences in aLTL, thus giving rise to the functor Spec : ARN → Set that we are looking for.
Ground orchestrations.Morphisms of arns can also be regarded as refinements, as they formalize the embedding of networks with an intuitively simpler behaviour into networks that are more complex.This is achieved essentially by mapping each of the requires-points of the source arn to a potentially non-requires-point of the target arn, a point which can be looked at as the 'root' of a particular subnetwork of the target arn.To explain this aspect in more detail we introduce the notions of dependency and arn defined by a point.
Definition 2.23 (Dependency).Let x and y be points of an arn N. The point x is said to be dependent on y if there exists a path from x to y that begins with a computation hyperedge, i.e. if there exists an alternating sequence x e 1 x 1 . . .e n y of (distinct) points and hyperedges of the underlying hypergraph X, P, C, γ of N such that x ∈ γ e 1 , y ∈ γ en , x i ∈ γ e i ∩ γ e i+1 for every 1 ≤ i < n, and e 1 ∈ P .Definition 2.24 (Network defined by a point).The arn defined by a point x of an arn N is the full sub-arn N x of N determined by x and the points on which x is dependent.
One can now see that any morphism of arns θ : N 1 → N 2 assigns to each requires-point x of the source network N 1 the sub-arn N 2,θ(x) of N 2 defined by θ(x).
Example 2.25.In Figure 8 we outline an extension of the arn JourneyPlanner discussed in Example 2.17 that is obtained by attaching the processes MS (for Map Services) and TS (for Transport System) to the requires-points R 1 and R 2 of JourneyPlanner.Formally, the link between JourneyPlanner and the resulting arn JourneyPlannerNet is given by a morphism θ : JourneyPlanner → JourneyPlannerNet that preserves all the labels, points and hyperedges of JourneyPlanner, with the exception of the requires-points R 1 and R 2 , which are mapped to MS 1 and TS 1 , respectively.
In this case, MS 1 only depends on itself, hence the sub-arn of JourneyPlannerNet defined by MS 1 , i.e. the arn assigned to the requires-point R 1 of JourneyPlanner, is given by the process MS and its port MS 1 .In contrast, the point JP 1 depends on all the other points of JourneyPlannerNet, and thus it defines the entire arn JourneyPlannerNet.In view of the above observation, we may consider the requires-points of networks as counterparts of the variables used in program expressions, and their morphisms as substitutions.This leads us to the following definition of ground arns.

JP
Definition 2.26 (Ground arn).An arn is said to be ground if it has no requires-points.
Properties.The evaluation of specifications with respect to ground arns relies on the concepts of diagram of a network and automaton (i.e.aLTL-model) defined by a point, whose purpose is to describe the observable behaviour of a ground arn through one of its points.We start by extending Remarks 2.10 and 2.14 to arns.
Fact 2.27 (Diagram of an arn).Every arn N = X, P, C, γ, M, µ, Λ defines a diagram D N : J N → Sig aLTL as follows: • J N is the free preordered category given by the set of objects and the arrows -{x → p | p ∈ P, x ∈ γ p } for computation hyperedges, and is the functor that provides the sets of actions of ports, processes and channels, together with the appropriate mappings between them.For example, given a communication hyperedge c ∈ C and a point x .We define the signature of an arn by taking the colimit of its diagram, which is guaranteed to exist because the category Sig aLTL , i.e.Set, is finitely cocomplete.
Definition 2.28 (Signature of an arn).The signature of an arn N is the colimiting cocone ξ : The most important construction that allows us to define properties of ground arns is the one that defines the observed behaviour of a (ground) network at one of its points.
Definition 2.29 (Automaton defined by a point).Let x be a point of a ground arn G.The observed automaton Λ x at x is given by the reduct Λ Gx ξx , where • G x = X, P, C, γ, M, µ, Λ is the sub-arn of G defined by x, • Λ Gx is the product automaton e∈P ∪C Λ Gx e , and • Λ Gx e is the cofree expansion of Λ e along ξ e , for any hyperedge e ∈ P ∪ C. Example 2.30.Consider once again the (ground) arn represented in Figure 8.The automaton defined by the point MS 1 is just Λ MS A MS 1 ; this follows from the observation that the arn defined by MS 1 consists exclusively of the process MS and the port MS 1 .On the other hand, in order to obtain the automaton defined by the provides-point JP 1 one needs to compute the product of the cofree expansions of all four automata Λ JP , Λ C , Λ MS and Λ TS .Based on Propositions 2.4 and 2.5, the resulting automaton has to accept precisely the projections to A M JP 1 of those traces accepted by Λ JP that are compatible with traces accepted by Λ C , Λ MS and Λ TS , in the sense that together they give rise, by amalgamation, to traces over the alphabet of the network.
We now have all the necessary concepts for defining properties of ground arns.
Definition 2.31 (Property of an arn).Let @ x ρ be a specification over a ground arn G. Then @ x ρ is a property of G if and only if the automaton Λ x observed at the point x in G satisfies (according to the definition of satisfaction in aLTL) the temporal sentence ρ.

Λ x aLTL ρ
Remark 2.32.It is important to notice that not only the signature of an arn, but also the various cofree expansions and products considered in Definition 2.29 are unique only up to an isomorphism.Consequently, the automaton defined by a point of a ground arn is also unique only up to an isomorphism, which means that the closure of aLTL under isomorphisms plays a crucial role in ensuring that the evaluation of specifications with respect to ground arns is well defined.
All we need now in order to complete the construction of the orchestration scheme of arns is to show that the morphisms of ground arns preserve properties.This result depends upon the last of the four hypotheses we introduced at the beginning of the subsection: the reflection of the satisfaction of sentences by the model homomorphisms of the institution used as foundation for the construction of arns.
Proof.Let G x 1 and G x 2 be the sub-arns of G 1 and G 2 determined by x and θ(x) respectively, and let us also assume that i , for i ∈ {1, 2}.Since @ x ρ is a property of G 1 , we know that the automaton Λ 1 x observed at the point x in G 1 satisfies ρ.We also know that θ : . By Proposition 2.6, aLTL-model homomorphisms reflect the satisfaction of sentences; therefore, in order to prove that Λ 2 θ(x) satisfies ρ -and in this way, that Spec(θ)(@ x ρ) is a property of G 2 -it suffices to determine the existence of a homomorphism Λ 2 θ(x) → Λ 1 x .Recall that Λ 1 x and Λ 2 θ(x) are the reducts Λ G x , where, for i ∈ {1, 2}, , and • Λ G x i e , for e ∈ P i ∪ C i , is the cofree expansion of Λ i e along ξ i e , for which we denote the universal morphism from ξ i e to Λ i e by ε i e : Λ According to the description of the arns defined by given points, we can restrict θ to a morphism of arns from G x 1 to G x 2 .Since G x 1 is ground, we further obtain, based on this restriction, a functor F : This allows us to define the derived cocone , whose components are given, for example, by (F • ξ 2 ) x = ξ 2 θ(x) .Since ξ 1 is the colimit of D G x 1 it follows that there exists a (unique) morphism of cocones σ : ξ 1 → F • ξ 2 , i.e. an aLTL-signature morphism σ : A G x 1 → A G x 2 that satisfies, in particular, ξ 1 e ; σ = ξ 2 θ(e) for every hyperedge e ∈ P 1 ∪ C 1 .
We obtain in this way, for every hyperedge e ∈ P 1 ∪ C 1 , the composite morphism Λ is the cofree expansion of Λ 1 e along ξ 1 e , we deduce that there exists a (unique) morphism e such that the above diagram is commutative.This implies, by the universal property of the product Λ G x 1 , the existence of a (unique) morphism x .Then, to complete the proof, we only need to notice that Λ G

A Logical View on Service Discovery and Binding
Building on the results of Section 2, let us now investigate how the semantics of the service overlay can be characterized using fundamental computational aspects of the logicprogramming paradigm such as unification and resolution.Our approach is founded upon a simple and intuitive analogy between concepts of service-oriented computing like service module and client application [FLB11], and concepts such as clause and query that are specific to (the relational variant of) logic programming [Llo87].In order to clarify this analogy we rely on the institutional framework that we put forward in [T ¸F15] to address the model-theoretic foundations of logic programming.We begin by briefly recalling the most basic structure that underlies both the denotational and the operational semantics of relational logic programming: the substitution system of (sets of) variables and substitutions over a given (single-sorted) first-order signature.Its definition relies technically on the category Room of institution rooms and corridors (see e.g.Definition 3.1 (Substitution system).A substitution system is a triple Subst, G, S , often denoted simply by S, that consists of • a category Subst of signatures of variables and substitutions, • a room G of ground sentences and models, and • a functor S : Subst → G / Room, defining for every signature of variables X the corridor S(X) : G → G(X) from G to the room G(X) of X-sentences and X-models.
Example 3.2.In the case of conventional logic programming, every single-sorted first-order signature F, P determines a substitution system AFOL 1 = F,P : Subst F,P → AFOL 1 = (F, P ) / Room 9 in which Subst F,P is simply the category whose objects are sets of variables (defined over the signature F, P ), and whose arrows are first-order substitutions.The room AFOL 1 = (F, P ) accounts for the (ground) atomic sentences given by F, P , the models of F, P , as well as the standard satisfaction relation between them.And finally, the functor AFOL 1 = F,P maps every signature (i.e.set) of variables X to the corridor α F,P ,X , β F,P ,X , Sen(F, P ), α F,P ,X Mod(F, P ), F,P Sen(F ∪ X, P ), Mod(F ∪ X, P ), where α F,P ,X and β F,P ,X are the translation of sentences and the reduction of models that correspond to the inclusion of signatures F, P ⊆ F ∪ X, P .
Substitution systems are particularly useful when reasoning about the semantics of clauses and queries.For instance, the above substitution system can be used to define (definite) clauses over F, P as syntactic structures ∀X • C ← H, also written C ← − − X H such that X is a signature of variables, C is sentence over F ∪ X, P , and H is a (finite) set of sentences over F ∪ X, P . 10The semantics of such a construction is given by the class of models of F, P , i.e. of ground models of the substitution system, whose expansions to F ∪ X, P satisfy C whenever they satisfy all sentences in H -this reflects the usual interpretation of logic-programming clauses as universally quantified sentences Similarly to institutions, the axiomatic approach to logic programming on which we rely in this paper is parameterized by the signature used.In categorical terms, this means that the morphisms of signatures induce appropriate morphisms between their corresponding substitution systems, and moreover, that this mapping is functorial.As regards our inquiry on the semantics of the service overlay, it suffices to recall that the category SubstSys of substitution systems results from the Grothendieck construction [TBG91] for the functor [ → / Room] : (Cat × Room) op → Cat that maps • every category Subst and room G to the category of functors [Subst → G / Room], • every functor Ψ : Subst → Subst and corridor κ : 9 Through AFOL 1 = we refer to the institution that corresponds to the atomic fragment of the single-sorted variant of first-order logic without equality.
10 Note that, in relational logic programming, the variables are often distinguished from other symbols through notational conventions; for this reason, the set X of variables is at times omitted.
This allows us to introduce the next notion of generalized substitution system.
Definition 3.3 (Generalized substitution system).A generalized substitution system is a pair Sig, GS given by a category Sig of signatures, and a functor GS : Sig → SubstSys.
In order to provide a better understanding of the complex structure of generalized substitution systems, we consider the following notational conventions and terminology: For every signature Σ of a generalized substitution system GS, we denote the (local) substitution system GS(Σ) by GS Σ : Subst Σ → G Σ / Room, and we refer to the objects and morphisms of Subst Σ as signatures of Σ-variables and Σ-substitutions.The room G Σ is assumed to comprise the set Sen(Σ) of ground Σ-sentences, the category Mod(Σ) of Σ-models, and the Σ-satisfaction relation Σ ⊆ |Mod(Σ)| × Sen(Σ).On objects, GS Σ maps every signature of Σ-variables X to the corridor On arrows, GS Σ maps every Σ-substitution ψ : Sen Σ (X) With respect to signature morphisms, every ϕ : Σ → Σ determines a morphism of substitution systems GS ϕ : GS Σ → GS Σ in the form of a triple Ψ ϕ , κ ϕ , τ ϕ , where Ψ ϕ is a functor Subst Σ → Subst Σ , κ ϕ is a corridor Sen(ϕ), Mod(ϕ) : G Σ → G Σ , and for every signature of Σ-variables X, τ ϕ,X is a (natural) corridor α ϕ,X , β ϕ,X : Sen(Σ) In addition, we adopt notational conventions that are similar to those used for institutions.
For example, we may use superscripts as in Subst GS Σ is order to avoid potential ambiguities; or we may drop the subscripts of Σ,X when there is no danger of confusion.Also, we will often denote the functions Sen(ϕ), α Σ,X and Sen Σ (ψ) by ϕ( ), X( ) and ψ( ), respectively, and the functors Mod(ϕ), β Σ,X and Mod Σ (ψ) by ϕ , Σ and ψ .
Example 3.4.Relational logic programming is based upon the generalized substitution system AFOL 1 = of the atomic fragment of single-sorted first-order logic without equality.
In this case, the category Sig AFOL 1 = is just the category of single-sorted first-order signatures.Every signature F, P is mapped to a substitution system AFOL 1 = F,P as described in Example 3.2, while every signature morphism ϕ : F, P → F , P resolves to a morphism of substitution systems for which Ψ ϕ is the obvious translation of F, P -substitutions along ϕ, and κ ϕ is the corridor AFOL 1 = (ϕ).A more detailed presentation of first-order generalized substitution systems can be found in [T ¸F15].

3.1.
A Generalized Substitution System of Orchestration Schemes.What is essential about orchestration schemes with respect to the development of the service-oriented variant of logic programming is that they can be organized as a category OS from which there exists a functor OrcScheme into SubstSys that allows us to capture some of the most basic aspects of service-oriented computing by means of logic-programming constructs.More precisely, orchestration schemes form the signatures of a generalized substitution system OrcScheme : OS → SubstSys through which the notions of service module, application, discovery and binding emerge as particular instances of the abstract notions of clause, query, unification and resolution.In this sense, OrcScheme and AFOL 1 = can be regarded as structures having the same role in the description of service-oriented and relational logic programming, respectively.
Morphisms of orchestration schemes are, intuitively, a way of encoding orchestrations.In order to understand how they arise in practice, let us consider a morphism ϕ between two algebraic signatures Σ and Σ used in defining program expressions.For instance, we may assume Σ to be the signature of structured programs discussed in Example 2.2, and ϕ : Σ → Σ its extension with a new operation symbol repeat until : Pgm Cond → Pgm.Then, it is easy to notice that the translation of Σ-terms (over a given set of program variables) along ϕ generalizes to a functor F between the categories of program expressions defined over Σ and Σ .Moreover, the choice of ϕ enables us to define a second functor U , from program expressions over Σ to program expression over Σ, based on the derived signature morphism (see e.g.[ST11]) Σ → Σ that encodes the repeat until operation as the term 1 ; while not 2 do 1 done. 11The functor U is clearly a right inverse of F with respect to ground program expressions, whereas in general, for every program expression pgm over Σ we actually obtain a morphism η pgm : pgm → U (F (pgm)) as a result of the potential renaming of program variables; thus, the morphism η pgm accounts for translation of the program variables of pgm along F ; U .Furthermore, for every program expression pgm over Σ , the translation of Σ-sentences determined by ϕ extends to a map between the specifications over U (pgm ) and the specifications over pgm , which, as we will see, can be used to define a translation of the specifications over a program expression pgm (given by Σ) to specifications over F (pgm).With respect to the semantics, it is natural to expect that every program expression pgm over Σ has the same behaviour as F (pgm) and, even more, that every program expression pgm over Σ (that may be built using repeat until ), behaves in the same way as U (pgm ).These observations lead us to the following formalization of the notion of morphism of orchestration schemes.Definition 3.5 (Morphism of orchestration schemes).A morphism between orchestration schemes Orc, Spec, Grc, Prop and Orc , Spec , Grc , Prop is a tuple F, U, η, σ , where • F and U are functors as depicted above such that F (Grc) ⊆ Grc and U (Grc ) ⊆ Grc, • η is a natural transformation 1 Orc ⇒ F ; U such that η g = 1 g for every g ∈ |Grc|, and • σ is a natural transformation U ; Spec ⇒ Spec such that for every ground orchestration g ∈ |Grc | and specification ρ ∈ Spec(U (g )), Example 3.6.Let I = Sig, Sen, Mod, and I = Sig , Sen , Mod , be two institutions suitable for defining orchestration schemes of arns (according to the hypotheses introduced in Subsection 2.2), and let Υ, α, β be a morphism of institutions I → I such that Υ : Sig → Sig is cocontinuous and β : Mod ⇒ Υ op ; Mod preserves cofree expansions and products.If Υ and β admit sections, that is if there exist a functor Φ : Sig → Sig such that Φ ; Υ = 1 Sig and a natural transformation τ : Mod ⇒ Φ op ; Mod such that τ ; (Φ op • β) = 1 Mod , then Υ, α, β gives rise to a morphism F, U, η, σ between the orchestration schemes of arns defined over I and I .In particular, the functor F maps the diagram and the models that label an arn defined over I to their images under Φ and τ ; similarly, U maps arns defined over I according to Υ and β; the natural transformation η is just an identity, and σ extends the α-translation of sentences to specifications.The additional properties of Υ and β are essential for ensuring that the observable behaviour of ground networks is preserved.
One may consider, for instance, the extension of aLTL (in the role of I) with new temporal modalities such as previous and since, as in [KMWZ10]; this naturally leads to a morphism of orchestration schemes for which both Υ and β would be identities.Alternatively, one may explore the correspondence between deterministic weak ω-automata -which form a subclass of Muller automata -and sets of traces that are both Büchi and co-Büchi deterministically recognizable -for which a minimal automaton can be shown to exist (see e.g.[MS97,Löd01]).In this case, in the roles of I and I we could consider variants of aLTL with models given by sets of traces and deterministic weak automata, respectively;12 Υ and α would be identities, β would define the language recognized by a given automaton, and τ would capture the construction of minimal automata.
It it easy to see that the morphisms of orchestration schemes compose in a natural way in terms of their components, thus giving rise to a category of orchestration schemes.
Proposition 3.7.The morphisms of orchestration schemes can be composed as follows: Under this composition, orchestration schemes and their morphisms form a category OS.
The definition of the functor OrcScheme is grounded on two simple ideas: 1. Orchestrations can be regarded as signatures of variables; they provide sentences in the form of specifications, and models as morphisms into ground orchestrationswhich can also be seen, in the case of arns, for example, as collections of ground networks assigned to the 'variables' of the considered orchestration.In addition, we can define a satisfaction relation between the models and the sentences of an orchestration based of the evaluation of specifications with respect to ground orchestrations.In this way, every orchestration scheme yields an institution whose composition resembles that of the so-called institutions of extended models [SML04].
2. There is a one-to-one correspondence between institutions and substitution systems defined over the initial room ∅, 1, ∅ -the room given by the empty set of sentences, the terminal category 1, and the empty satisfaction relation.The effect of this is that a clause can be described as 'correct' whenever it is satisfied by the sole model of ∅, 1, ∅ ; therefore, we obtain precisely the notion of correctness of a service module [FLB11]: all models of the underlying signature of variables, i.e. of the orchestration, that satisfy the antecedent of the clause satisfy its consequent as well.Formally, OrcScheme results from the composition of two functors, Ins : OS → coIns and SS : coIns → SubstSys, that implement the general constructions outlined above.
The functor Ins carries most of the complexity of OrcScheme, and is discussed in detail in Theorem 3.8.Concerning SS, we recall from [T ¸F15] that the category coIns of institution comorphisms can also be described as the category [ → Room] of functors into Room, and that any functor G : K → K can be extended to a functor [ → K] → [ → K ] that is given essentially by the right-composition with G.In particular, the isomorphism Room → ∅, 1, ∅ / Room that maps every room S, M, to the unique corridor ∅, 1, ∅ → S, M, generates an isomorphism of categories between [ → Room] , i.e. coIns, and [ → ∅, 1, ∅ / Room] .The latter is further embedded into SubstSys, defining in this way, by composition, the required functor SS.To sum up, SS maps every institution I : Sig → Room to the substitution system S : Sig → ∅, 1, ∅ / Room for which S(Σ), for every signature Σ ∈ |Sig|, is the unique corridor between ∅, 1, ∅ and I(Σ).
Theorem 3.8.The map Ins : OS → coIns is a functor, where • for any orchestration scheme O = Orc, Spec, Grc, Prop , Ins(O) is the institution Orc, Spec, / Grc, whose family of satisfaction relations is given by for every orchestration o, every o-model δ, i.e. every morphism of orchestrations δ : o → g such that g is ground, and every specification SP over o;13 • for any morphism of orchestrations F, U, η, σ : O → O , with O as above, and O given by Orc , Spec , Grc , Prop , Ins(F, U, η, σ) is the comorphism of institutions F, α, β : Ins(O) → Ins(O ) defined by Finally, it is easy to see that Ins preserves identities.To prove that it also preserves composition, let F, U, η, σ and F , U , η , σ be morphisms of orchestration schemes as below, and suppose that Ins(F, U, η, σ) = F, α, β and Ins(F , U , η , σ ) = F , α , β .
Orc, Spec, Grc, Prop In addition, let υ : ( / Grc ) ⇒ U op ; ( / Grc) and υ : ( / Grc ) ⇒ U op ; ( / Grc ) be the natural transformations involved in the definitions of β and β , respectively.Based on the composition of morphisms of orchestration schemes and on the definition of Ins, it follows that Ins( F, U, η, σ ; F , U , η , σ ) is a comorphism of institutions of the form F ; F , α , β , where α and β are given by In order to complete the proof we need to show that α = α ; (F • α ) and β = (F • β ) ; β.Each of these equalities follows from a sequence of straightforward calculations that relies on the naturality of σ (in the case of α ), or on the naturality of υ (in the case of β ).
We recall from [T ¸F15] that, in order to be used as semantic frameworks for logic programming, generalized substitution systems need to ensure a weak model-amalgamation property between the models that are ground and those that are defined by signatures of variables.This property entails that the satisfaction of quantified sentences (and in particular, of clauses and queries) is invariant under change of notation.In the case of OrcScheme, this means, for example, that the correctness property of service modules does not depend on the actual orchestration scheme over which the modules are defined.Definition 3.10 (Model amalgamation).A generalized substitution system GS : Sig → SubstSys has weak model amalgamation when for every signature morphism ϕ : Σ → Σ and every signature of Σ-variables X, the diagram depicted below is a weak pullback.Remark 3.12.In addition to model amalgamation, it is important to notice that, similarly to AFOL 1 = , in OrcScheme the satisfaction of sentences is preserved by model homomorphisms.This is an immediate consequence of the fact that, in every orchestration scheme, the morphisms of ground orchestrations preserve properties: given an orchestration o, a specification SP over o, and a homomorphism ζ between o-models δ 1 and δ 2 as depicted below, if Spec(δ 1 )(SP ) is a property of g 1 then Spec(δ 2 )(SP ) = Spec(ζ)(Spec(δ 1 )(SP )) is a property of g 2 ; therefore, δ 1 OrcScheme SP implies δ 2 OrcScheme SP .
2. The Clausal Structure of Services.Given the above constructions, we can now consider a service-oriented notion of clause, defined over the generalized substitution system OrcScheme rather than AFOL 1 = .Intuitively, this means that we replace first-order signatures with orchestration schemes, sets of variables with orchestrations, and first-order sentences (over given sets of variables) with specifications.Furthermore, certain orchestration schemes allow us to identify structures that correspond to finer-grained notions like variable and term: in the case of program expressions, variables and terms have their usual meaning (although we only take into account executable expressions), whereas in the case of arns, variables and terms materialize as requires-points and sub-arns defined by provides-points.
The following notion of service clause corresponds to the concept of service module presented in [FLB11], and also to the concept of orchestrated interface discussed in [FL13a].Definition 3.13 (Service clause).A (definite) service-oriented clause over a given orchestration scheme O = Orc, Spec, Grc, Prop is a structure ∀o • P ← R, also denoted where o is an orchestration of O, P is a specification over o -called the provides-interface of the clause -and R is a finite set of specifications over o -the requires-interface of the clause.
The semantics of service-oriented clauses is defined just as the semantics of first-order clauses, except that they are evaluated within the generalized substitution system OrcScheme instead of AFOL 1 = .As mentioned before, this means that we can only distinguish whether or not a clause is correct.Definition 3.14 (Correct clause).A service-oriented clause ∀o • P ← R is correct if for every morphism δ : o → g such that g is a ground orchestration and Spec(δ)(R) consists only of properties of g, the specification Spec(δ)(P ) is also a property of g.
In other words, a service clause is correct if the specification given by its provides-interface is ensured by its orchestration and the specifications of its requires-interface.
Example 3.15.We have already encountered several instances of service clauses in the form of the program modules depicted in Figure 1.Their provides-and requires-interfaces are placed on the left-and right-hand side of their orchestrations, and are represented using symbolic forms that are traditionally associated with services.
To illustrate how service modules can be defined as clauses over arns, notice that the network JourneyPlanner introduced in Example 2.17 can orchestrate a module named Journey Planner that consistently delivers the requested directions, provided that the routes and the timetables can be obtained whenever they are needed.This can be described in logical terms through the following (correct) service-oriented clause: where ρ JP , ρ JP 1 and ρ JP 2 correspond to the aLTL-sentences 2(planJourney¡ ⇒ 3directions!), 2(getRoutes¡ ⇒ 3routes!) and 2(routes¡ ⇒ 3timetables!), respectively.
Client applications are captured in the present setting by service-oriented queries.The way they are defined is similar to that of service clauses, but their semantics is based on an existential quantification, not on a universal one.Definition 3.16 (Service query).A service-oriented query over an orchestration scheme and Q is a finite set of specifications over o that defines the requires-interface of the query.Definition 3.17 (Satisfiable query).A service-oriented query ∃o • Q is said to be satisfiable if there exists a morphism of orchestrations δ : o → g such that g is ground and all specifications in Spec(δ)(Q) are properties of g. given by the aLTL-sentence 2(getRoute¡ ⇒ 3route!).Let us now turn our attention to the dynamic aspects of service-oriented computing that result from the process of service discovery and binding [FLB11].Service discovery represents, as in conventional logic programming, the search for a module (service clause) that can be bound to a given application (service query) in order to take it one step closer to a possible solution, i.e. to a 'complete' application capable of fulfilling its goal.From a technical point of view, both discovery and binding are subject to matching the requires-interface of the application, or more precisely, one of its specifications, with the provides-interface of the module under consideration.This is usually achieved through a suitable notion of refinement of specifications.For instance, in the case of program expressions, given specifications ι 1 : [ρ 1 , ρ 1 ] and ι 2 : [ρ 2 , ρ 2 ] over programs pgm 1 : eXp 1 and pgm 2 : eXp 2 , respectively, if by translation we obtain specifications that refer to the same position of pgm : eXp, i.e. π 1 • ι 1 = π 2 • ι 2 , such that the pre-condition ψ 2 (ρ 2 ) is weaker that ψ 1 (ρ 1 ), and the post-condition ψ 2 (ρ 2 ) is stronger than ψ 1 (ρ 1 ), meaning that This notion of refinement reflects the rules of consequence introduced in [Hoa69] (see also [Mor94], whence we also adopt the notation ι 2).In a similar manner, in the case of arns, a specification @ x 1 ρ 1 over a network N 1 is refined by another specification @ x 2 ρ 2 over a network N 2 up to a cospan of morphisms of arns θ 1 : N 1 → N, θ 2 : N 2 → N when θ 1 (x 1 ) = θ 2 (x 2 ) and θ pt 2,x 2 (ρ 2 ) aLTL θ pt 1,x 1 (ρ 1 ) [T ¸F13].Both of these notions of refinement generalize to the following concept of unification.Definition 3.19 (Unification).Let SP 1 and SP 2 be specifications defined over orchestrations o 1 and o 2 , respectively, of an arbitrary but fixed orchestration scheme.We say that the ordered pair SP 1 , SP 2 is unifiable if there exists a cospan of morphisms of orchestrations called the unifier of SP 1 and SP 2 , such that θ 2 (SP 2 ) OrcScheme θ 1 (SP 1 ).
Therefore, θ 1 , θ 2 is a unifier of SP 1 and SP 2 if and only if, for every morphism of orchestrations δ : o → g such that g is a ground orchestration, if Spec(θ 2 ; δ)(SP 2 ) is a property of g then so is Spec(θ 1 ; δ)(SP 1 ).
In conventional logic programming, the resolution inference rule simplifies the current goal and at the same time, through unification, yields computed substitutions that could eventually deliver a solution to the initial query.This process is accurately reflected in the case of service-oriented computing by service binding.However, unlike relational logic programming, in the case of services the emphasis is put not on the computed morphisms of orchestrations (i.e. on substitutions), but on the dynamic reconfiguration of the orchestrations (i.e. of the signatures of variables) that underlie the considered applications.Definition 3.20 (Resolution).Let ∃o 1 • Q 1 be a query and ∀o 2 • P 2 ← R 2 a clause defined over an arbitrary but fixed orchestration scheme.A query ∃o • Q is said to be derived by resolution from ∃o 1 • Q 1 and ∀o 2 • P 2 ← R 2 using the computed morphism θ • θ 1 can be extended to a unifier θ 1 , θ 2 of a specification SP 1 ∈ Q 1 and P 2 , and • Q is the set of specifications given by the translation along θ 1 and θ 2 of the specifications in Q 1 \ {SP 1 } and R 2 .
Example 3.21.Consider the service query and the clause detailed in Examples 3.18 and 3.15.One can easily see that the single specification @ R 1 ρ T 1 of the requires-interface of the application Traveller and the provides-interface @ JP 1 ρ JP of the module Journey Planner form a unifiable pair: they admit, for instance, the unifier θ 1 , θ 2 given by • the arn JourneyPlannerApp depicted in Figure 10, • the morphism θ 1 that maps the point R 1 to JP 1 , the communication hyperedge C to CJP and the messages getRoute and route of M R 1 to planJourney and directions, respectively, while preserving all the remaining elements of Traveller, and • the inclusion θ 2 of JourneyPanner into JourneyPlannerApp.
The logic-programming framework of services.The crucial property of the above notions of service clause, query, and resolution is that, together with the generalized substitution system OrcScheme used to define them, they give rise to a logic-programming framework [T ¸F15].The construction is to a great extent self-evident, and it requires little additional consideration apart from the fact that, from a technical point of view, in order to define clauses and queries as quantified sentences, we need to extend OrcScheme by closing the sets of sentences that it defines under propositional connectives such as implication and conjunction.It should be noted, however, that the properties that guarantee the welldefinedness of the resulting logic-programming framework such as the fact that its underlying generalized substitution system has weak model amalgamation (ensured by Proposition 3.11), and also the fact that the satisfaction of specifications is preserved by model homomorphisms (detailed in Remark 3.12), are far from trivial, especially when taking into account particular orchestration schemes (see e.g.Proposition 2.33).
By describing service discovery and binding as instances of unification and resolution (specific to the logic-programming framework of services) we obtain not only a rigorously defined analogy between service-oriented computing and relational logic programming, but also a way to apply the general theory of logic programming to the particular case of services.For example, we gain a concept of solution to a service query that reflects the rather intuitive service-oriented notion of solution and, moreover, through Herbrand's theorem, a characterization of satisfiable queries as queries that admit solutions.Definition 3.22 (Solution).A solution, or correct answer, to a service-oriented query ∃o • Q consists of a morphism of orchestrations ψ : o → o such that o has models, and every one of them satisfies the ψ-translations of the specifications in Q.
Proposition 3.23.A service query is satisfiable if and only if it admits a solution.
Even more significant is the fact that logic programming provides us with a general search procedure that can be used to compute solutions to queries.The search is triggered by a query ∃o • Q and consists in the iterated application of resolution, that is of service discovery and binding, until the requires-interface of the derived service query consists solely of trivial specifications (tautologies); these are specifications whose translation along morphisms into ground orchestrations always gives rise to properties.Thus, whenever the search procedure successfully terminates we obtain a computed answer to the original query by sequentially composing the resulting computed morphisms.This is the process that led, for example, to the derivation of the program that calculates the quotient and the remainder obtained on dividing two natural numbers illustrated in Figure 2. The computed answer is given in this case by the sequence of substitutions pgm → pgm 1 ; pgm 2 → (pgm 3 ; pgm 4 ) ; pgm 2 → • • • → (q := 0 ; r := x) ; while y ≤ r do q := q + 1 ; r := r − y done.In a similar manner, we can continue Example 3.21 towards the derivation of an answer to the Traveller application.To this purpose, we assume that Map Services and Transport System are two additional service modules that correspond to the processes MS and TS used in Example 2.25, and whose provides-interfaces meet the requires-specifications of the module Journey Planner.We obtain in this way the construction outlined in Figure 11.
The soundness of resolution, detailed in Proposition 3.24 below, entails that the search for solutions is sound as well, in the sense that every computed answer to ∃o • Q is also a solution to ∃o • Q.This fundamental result, originally discussed in [T ¸F15] in the context of abstract logic programming, ensures, in combination with Proposition 3.23, that the operational semantics of the service overlay given by discovery and binding is sound with respect to the notion of satisfiability of a service query.Proposition 3.24.Let ∃o • Q be a service query derived by resolution from ∃o 1 • Q 1 and ∀o 2 • P 2 ← R 2 using the computed morphism θ 1 : o 1 → o.If ∀o 2 • P 2 ← R 2 is correct then, for any solution ψ to ∃o • Q, the composed morphism θ 1 ; ψ is a solution to ∃o 1 • Q 1 .

Conclusions
We have shown how the integration of the declarative and the operational semantics of conventional logic programming can be generalized to service-oriented computing, thus offering a unified semantics for the static and the dynamic aspects of this paradigm.That is, we have provided, for the first time, an algebraic framework that accounts for the mechanisms through which service interfaces can be orchestrated, as well as for those mechanisms that allow applications to discover and bind to services.
The analogy that we have established is summarized in Table 1.Our approach to the logic-programming semantics of services is based on the identification of the binding of terms to variables in logic programming with the binding of orchestrations of services to those of software applications in service-oriented computing; the answer to a service query -the request for external services -is obtained through resolution using service clausesorchestrated service interfaces -that are available from a repository.This departs from other works on the logic-programming semantics of service-oriented computing such as [KBG07] that actually considered implementations of the service discovery and binding mechanisms based on constraint logic programming.
The theory of services that we have developed here is grounded on a declarative semantics of service clauses defined over a novel logical system of orchestration schemes.The structure of the sentences and of the models of this logical system varies according to the orchestration scheme under consideration.For example, when orchestrations are defined as asynchronous relational networks over the institution aLTL, we obtain sentences as linear-temporal-logic sentences expressing properties observed at given interaction points of a network, and models in the form of ground orchestrations of Muller automata.Other logics (with corresponding model theory) could have been used instead of the automata-based variant of linear temporal logic, more specifically any institution such that (a) the category of signatures is (finitely) cocomplete; (b) there exist cofree models along every signature morphism; (c) the category of models of every signature has (finite) products; and (d ) model homomorphisms reflect the satisfaction of sentences.Moreover, the formalism used in defining orchestrations can change by means of morphisms of orchestration schemes.We could consider, for instance, an encoding of the hypergraphs of processes and connections discussed in this paper into graphbased structures similar to those of [FL13b]; or we could change their underlying institution by adding new temporal modalities (along the lines of Example 3.6) or by considering other classes of automata, like the closed reduced Büchi automata used in [AS87,FL13a].This encourages us to further investigate aspects related to the heterogeneous foundations of service-oriented computing based on the proposed logical system of orchestration schemes.

Figure 8 :
Figure 8: The arn JourneyPlannerNet [Mos02]).The objects of Room are triples S, M, consisting of a set S of sentences, a category M of models, and a satisfaction relation ⊆ |M| × S. They are related through corridors α, β : S, M, → S , M , that abstract the change of notation within or between logics by defining a sentence-translation function α : S → S and a model-reduction functor β : M → M such that the following condition holds for all M ∈ |M | and ρ ∈ S: M α(ρ) if and only if β(M ) ρ.

FF
;F ,U ;U,η;(F •η •U ),(U •σ);σ y y Orc , Spec , Grc , Prop F ,U ,η ,σ G G Orc , Spec , Grc , Prop This means that for every model Σ -model M and every X-model N such that M ϕ = N Σ there exists a Ψ ϕ (X)-model N that satisfies N Σ = M and β ϕ,X (N ) = N .Proposition 3.11.The generalized substitution system OrcScheme : OS → SubstSys has weak model amalgamation.Proof.Let ϕ be a morphism F, U, η, σ between orchestration schemes O and O as in Definition 3.5, and let o be an orchestration of O. Since orchestrations define substitution systems over the initial room ∅, 1, ∅ , we can redraw the diagram of interest as follows: It is easy to see that the above diagram depicts a weak pullback if and only if β ϕ,o is surjective on objects.By Theorem 3.8, we know that β ϕ,o (δ ) = η o ; U (δ ) for every object δ : F (o) → g in |F (o) / Grc |.Therefore, for every δ : o → g in |o / Grc| we obtain β ϕ,o (F (δ)) = η o ; U (F (δ))= δ ; η g by the naturality of η = δ because, by definition, η g is an identity.
Example 3.18.Figure 9 outlines the arn of a possible client application for the service module Journey Planner discussed in Example 3.15.We specify the actual application, called Traveller, through the service query − −−−−− − Traveller @ R 1 ρ T 1

Figure 10 :
Figure 10: The arn JourneyPlannerAppIt follows that we can derive by resolution a new service query defined by the network JourneyPlannerApp and the requires-specifications @ R 1 ρ JP 1 and @ R 2 ρ JP 2 .

Figure 11 :
Figure 11: The derivation of an answer to the Traveller application Config for sorts eXp ∈ S pgm , which we regard as constructor operators for the sort Config; • a (sortwise infinite) S pgm -indexed set Var of program variables, and state variables st, st : State, used to refer to the states that precede or result from executions; and • a preordered S, F -algebra A that describes the semantics of the programming language through the preorder relation associated with the sort Config. 2mple 2.2.The premises that we consider within this subsection are weak enough to allow the proposed algebraic framework to accommodate a wide variety of programming languages.For instance, the program expressions underlying the modules depicted in Figure1are simply terms of sort Pgm that can be formed based on the following five operation symbols • operation symbols : State → Config and , : eXp State → and only if a ∈ λ(0), λ ¬ρ if and only if λ ρ, λE if and only if λ ρ for some ρ ∈ E, λ ρ if and only if λ(1..) ρ, and λ ρ 1 U ρ 2 if and only if λ(i..) ρ 2 for some i ∈ ω, and λ(j..) ρ 1 for all j < i,

Table 1 :
Correspondence between concepts of relational and service-oriented logic programming