<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Reversible Semantics in Session-based Concurrency?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Claudio Antares Mezzina</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jorge A. Pérez</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>IMT School for Advanced Studies Lucca</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Groningen</institution>
          ,
          <country country="NL">The Netherlands</country>
        </aff>
      </contrib-group>
      <fpage>221</fpage>
      <lpage>226</lpage>
      <abstract>
        <p>Much research has studied foundations for correct and reliable communication-centric systems. A salient approach to correctness uses session types to enforce structured communications; a recent approach to reliability uses reversible actions as a way of reacting to unanticipated events or failures. This note describes recent work that develops a simple observation: the machinery required to define monitored semantics can also support reversible protocols. We illustrate a process framework of session communication in which monitors support reversibility. A key novelty in our approach are session types with present and past, which allow us to streamline the semantics of reversible actions.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        The purpose of this short paper is to motivate and describe our ongoing work in
reversible models of structured communications [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Framed within concurrency
theory and process calculi approaches, we are interested in developing rich models
of concurrent computation in which communicating processes follow structured
interaction protocols (as described by session types [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]), and whose underlying
operational semantics admits the possibility of reversing their actions. This
integration of structured communication and reversibility should inform the design of
sound programming abstractions for resilient communicating programs governed
by casual consistent semantics.
      </p>
      <p>
        Models of reversible computation and structured communications have
received much attention (cf. [
        <xref ref-type="bibr" rid="ref1 ref3">1,3</xref>
        ]). Reversing computational steps is an appealing
feature in different scenarios; for instance, in the case of a failure in a (concurrent)
program or transaction, we might like to undo all steps leading to the failure, so
as to return to last known stable state of the system. Indeed, good examples of
how reversibility can be used to model transactional models are [
        <xref ref-type="bibr" rid="ref2 ref6">2,6</xref>
        ]. The design
of reversible semantics for models of concurrency is a delicate issue, for we would
like to undo computational steps in a causally consistent fashion: a step should
be undone only if all its causes (if any) have been already undone. In this way,
reversibility in a causal consistent model leads to a system state that could have
been reached by performing forward steps only.
      </p>
      <p>The key observation that underlies our work is that the design of casually
consistent operational semantics for concurrent processes can take advantage of
the structured protocols that typically govern their behavior. As session types
abstract sequences of communication actions (protocols), they appear as a natural
choice for recording the forward and backward actions of interacting processes.</p>
      <p>
        In recent work, we have started to formalize the integration of reversibility
and session-based concurrency [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. In this note, we illustrate the model in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] by
means of a simple example that contains the main ingredients of our approach,
namely an operational semantics for untyped processes which is instrumented by
monitors that contain protocols specified as session types. In order to support
both forward and backward steps, we consider session types that describe both
past and present protocol states.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Reversible Sessions, By Example</title>
      <p>Our proposal builds upon the approach of models of concurrency such as the
πcalculus. As such, main ingredients in our approach are configurations, processes,
and (protocol) types, whose syntax is given in Figure 1. We assume a language
of the expressions e, e0, . . . that includes basic values, variables, and functions on
them. The syntax of configurations includes the empty configuration 0, name
restriction νn.M , parallel composition M k N , but also running processes and
monitors:
– eAndrupnoni nintsg porcocucersrsingPi n· σP·. ueTesheisluoncaivlosctaolrlye iσdeinstiafieldistbyofs,ptahiersliostf otfhesesfosiromn
e
{x, ve} (i.e., a set of mappings from variables to values); the list u collects the
subjects of actions already performed by P . e
– Given a session name s, a monitor sbH · eec contains a protocol (session) type
H that describes the structured behavior associated to s (see below) and a
list e containing all the expressions (including variables) used by the process.</p>
      <p>e
Intuitively, the list u in the running process and the list e in the monitor will be
e e
used to record previously performed actions and reconstruct the process structure
accordingly.</p>
      <p>
        The design of the operational semantics for our model is inspired by the
approach of [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], in which session types are used as monitors that enable
communication actions: a synchronization can only occur if the process actions correspond
to the intended protocols given by the monitor types. After synchronization,
portions of both processes and monitor types are consumed. Our approach consists
      </p>
      <p>M, N ::=
(processes)
(actions)
0 |</p>
      <p>P · σ · ue es | sbH · eec | νn.M | M k N
P, Q ::=</p>
      <p>u(x : S).P | uhx : Si.P | khei.P | k(x).P | νa.P | 0
α, β ::= !U | ?U
(protocol types)</p>
      <p>S, T ::=
end | α.S
(history types)</p>
      <p>H, K ::=</p>
      <p>^ S | S ^ | α1. · · · .αn. ^ S
in keeping, rather than consuming, these monitor types. For this to work, we need
to distinguish the part of the protocol that has been already executed (its past),
from the protocol that still needs to execute (its present). We thus introduce
session types with present and past (H in the syntax): the type α1. · · · .αn. ^ S
says that actions α1, · · · , αn are past protocol actions, whereas actions in
protocol S are yet to be executed. That is, the cursor ^ in history types helps us to
distinguish the past from the present. Each action αi corresponds to the input
or output of a value; we use U to range over the types of these values (e.g., int,
str, etc.).</p>
      <p>
        We illustrate our approach by means of a simple business protocol example [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]:
a slightly modified version of the two buyers protocol. It involves three participants:
a Buyer, a Seller, and a Buyer’s Friend. Buyer is willing to buy a book, and sends
to Seller the title of the book he is interested in. Seller replies with the price
of the book, and awaits for final information (e.g., shipping address and order
confirmation) from Buyer, before providing a delivery date. Once Buyer receives
the price, he realizes that he needs a loan from Friend in order to finalize the
purchase. To this aim, Buyer contacts Friend and then the transaction is finalized.
The set of interactions of Buyer with Seller and Friend are prescribed by the
following session types:
      </p>
      <p>Sa : ?str.!int.?str.?int.!cal.end
Ta : !str.?int.!str.!int.?cal.end
Sb : ?int.!int.end
Tb : !int.?int.end
Above, Sa describes the interaction between Buyer and Seller from Seller’s
perspective; type Ta is its dual and describes the protocol from Buyer’s perspective.
In session types, duality is essential to (statically) ensure action compatibility
between partners (and therefore, to guarantee absence of communication errors).
Types Tb and Sb describe the interaction between Buyer and Friend, from each
perspective.</p>
      <p>Having defined the interaction protocols using types, we proceed to examine
some possible process implementations for Buyer, Seller, and Friend. The behavior
of Buyer may be specified by the following process:</p>
      <sec id="sec-2-1">
        <title>B u y e r , ahz : Tai.zh“dune”i.z(prc). bhw : Tbi.whloan(prc)i.w(cash).zhaddri.zhcashi.z(date).0</title>
        <p>The implementation for Buyer involves the creation of two interleaved sessions:
the first one is established with the prefix ahz : Tai, which explicitly mentions
the session protocol to be executed with the implementation of Seller; the
second session is established with the implementation of Friend through the prefix
bhw : Tbi. Process implementations for Seller and Friend can be specified by the
following processes:
S e l l e r , a(z : Sa).z(title).zhquote(title)i.z(addr).z(paymnt).zhdate(addr)i.0</p>
      </sec>
      <sec id="sec-2-2">
        <title>F r i e n d , b(w : Sb).w(amount).whloani.0</title>
        <p>Note that functions loan(), quote() and date() are used to calculate the amount
of money to be borrowed, the book price and the delivery date, respectively.
The overall system specification is then given by the parallel composition of
configurations containing the three processes (in what follows, denotes the
empty list):</p>
        <p>S y s t e m ,</p>
        <p>B u y e r · ·
k S e l l e r · ·
k F r i e n d · ·
In the following, we will indicate with B u y e ri (resp. S e l l e ri and F r i e n di)
the process B u y e r after performing its i-th action. We will do the same with
types.</p>
        <p>
          The operational semantics that we have defined in [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] is based on a reduction
relation with both forward and backward steps, denoted and , respectively.
The first forward reduction of S y s t e m is establishing a session between Buyer
and Seller, using the fact that Ta and Sa are dual types. We have:
S y s t e m
(νs, s).
        </p>
        <p>B u y e r1 · {z, s} · a s k sb ^ Ta · zc k
S e l l e r1 · {z, s} · a s k sb ^ Sa · zc k F r i e n d · ·
(1)
As we can see, once a session is established two monitors are created, one per
endpoint; their task is to discipline the behavior of the process holding the
endpoint. For example, the behavior of Buyer in session s has to obey type Sa.
Buyer then sends (according to Sa) to Seller the request for the book, and the
entire system evolves as:</p>
        <p>B u y e r2 · ({z, s}) · a, z s k sb!str ^ Ta1 · z, “dune”c k</p>
        <p>S e l l e r2 · ({z, s}, {title, “dune”}) · a, z s k
sb?str ^ Sa1 · z, titlec k F r i e n d · ·
We can easily check that the configurations in (3) and (1) are equivalent. From M
in (2) the interaction between Buyer and Seller goes on, and the system arrives
to a point in which Buyer establishes a new session with Friend:
M
∗(νs, s, r, r).</p>
        <p>B u y e r4 · ({z, s}, {w, r}) · ue1, b s,r k
rb ^ Tb · bc k sbTa0 ^ Ta3 · z, “dune”, prc, wc k</p>
        <p>S e l l e r3 · ({z, s}, {title, “dune”}) · a, z, z s k
sbSa0 ^ Sa3 · z, title, quote(title)c k</p>
        <p>F r i e n d1 · {w, r} · b r k rb ^ Sb · wc
As effect of the communication, both types register the action and move forward.
Another effect is that the information needed to restore back the consumed
prefixes is stored into the running configurations and the related monitors.
Communication in (2) can be reverted by moving backward the monitor types, by
restoring the prefixes and deleting the read value from the receiver store, that is:
M</p>
        <p>zh“dune”i.B u y e r2 · ({z, s} · a s k sb ^ !str.Ta1 · zc k
z(title).S e l l e r2 · {z, s} · a s k sb ^ ?str.Sa1 · zc k
F r i e n d · ·
As (4) shows, the running process for Buyer is present in two sessions: one with
Seller and another one with Friend, and has two associated monitors, identified
by endpoints s, r. The list of subjects stored into the running process allows us to
reverse communications (possibly in different sessions) and session establishments
in the order in which they were performed, thus respecting causality of actions.
In this way, Buyer cannot undo a communication with Seller while the session
with Friend is still established.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Future Work</title>
      <p>
        We have described recent work on the integration of reversible semantics and
session-based concurrency [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. It represents a fresh approach with respect to
previous approaches [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. Several directions deserve further investigation:
– Richer (typed) languages. The process model in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] is admittedly simple; to
model and reason about interesting examples we need support for constructs
such as labeled choices. Also, process specifications do not specify reversible
actions; this is the role of monitors, history types, and other mechanisms.
Since reversibility is independent from specifications, rich types are needed
to support controlled forms of reversibility. In recent work we propose
alternatives to these challenges [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
(3)
(4)
– Multiparty session communications. The model in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] concerns binary session
types, which codify interaction between exactly two partners. Generalizing
our approach to multiparty session types [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] should require a finer, coordinated
representation of reversible actions, as protocol exchanges may involve more
than two participants.
– Dedicated reasoning techniques. Session types induce a “simpler” model of
concurrency in which reversibility is a better behaved phenomenon. It
remains to be seen to what extent such a setting enables the development of
tractable reasoning techniques (e.g., axiomatizations, behavioral equivalences,
and proof systems).
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Danos</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Krivine</surname>
          </string-name>
          , J.:
          <article-title>Reversible communicating systems</article-title>
          .
          <source>In: Proc. of CONCUR 2004</source>
          . pp.
          <fpage>292</fpage>
          -
          <lpage>307</lpage>
          . LNCS, Springer (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Danos</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Krivine</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>Transactions in RCCS</article-title>
          .
          <source>In: CONCUR 2005. LNCS</source>
          , vol.
          <volume>3653</volume>
          , pp.
          <fpage>398</fpage>
          -
          <lpage>412</lpage>
          (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Honda</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vasconcelos</surname>
            ,
            <given-names>V.T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kubo</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Language primitives and type discipline for structured communication-based programming</article-title>
          .
          <source>In: ESOP'98. LNCS</source>
          , vol.
          <volume>1381</volume>
          , pp.
          <fpage>122</fpage>
          -
          <lpage>138</lpage>
          . Springer (
          <year>1998</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Honda</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yoshida</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Carbone</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Multiparty asynchronous session types</article-title>
          .
          <source>In: POPL 2008</source>
          . pp.
          <fpage>273</fpage>
          -
          <lpage>284</lpage>
          . ACM (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Kouzapas</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yoshida</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Honda</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>On asynchronous session semantics</article-title>
          .
          <source>In: Proc. of FMOODS 2011</source>
          and
          <article-title>FORTE 2011</article-title>
          .
          <article-title>LNCS</article-title>
          , vol.
          <volume>6722</volume>
          , pp.
          <fpage>228</fpage>
          -
          <lpage>243</lpage>
          . Springer (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Lanese</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lienhardt</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mezzina</surname>
            ,
            <given-names>C.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schmitt</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stefani</surname>
            ,
            <given-names>J.B.</given-names>
          </string-name>
          :
          <article-title>Concurrent flexible reversibility</article-title>
          .
          <source>In: ESOP 2013. LNCS</source>
          , vol.
          <volume>7792</volume>
          , pp.
          <fpage>370</fpage>
          -
          <lpage>390</lpage>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Mezzina</surname>
            ,
            <given-names>C.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pérez</surname>
            ,
            <given-names>J.A.</given-names>
          </string-name>
          :
          <article-title>Reversibility in session-based concurrency: A fresh look (</article-title>
          <year>2016</year>
          ), draft available in http://www.jperez.nl
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Mezzina</surname>
            ,
            <given-names>C.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pérez</surname>
            ,
            <given-names>J.A.</given-names>
          </string-name>
          :
          <article-title>Reversible sessions using monitors</article-title>
          .
          <source>In: Proc. of PLACES 2016. EPTCS</source>
          , vol.
          <volume>211</volume>
          , pp.
          <fpage>56</fpage>
          -
          <lpage>64</lpage>
          (
          <year>2016</year>
          ), http://dx.doi.org/10.4204/EPTCS.211. 6
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Tiezzi</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yoshida</surname>
          </string-name>
          , N.:
          <article-title>Reversible session-based pi-calculus</article-title>
          .
          <source>J. Log. Algebr. Meth. Program</source>
          .
          <volume>84</volume>
          (
          <issue>5</issue>
          ),
          <fpage>684</fpage>
          -
          <lpage>707</lpage>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>