<!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>
      <journal-title-group>
        <journal-title>Tunisian-Algerian Joint Conference on Applied Computing, November</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Runtime verification of distributed algorithms using high-level Petri nets</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Fateh Latreche</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Hichem Talbi</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>LIRE Laboratory, Abdelhamid Mehri Constantine 2 University</institution>
          ,
          <country country="DZ">Algeria</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>MISC Laboratory, Abdelhamid Mehri Constantine 2 University</institution>
          ,
          <country country="DZ">Algeria</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>0</volume>
      <fpage>6</fpage>
      <lpage>08</lpage>
      <abstract>
        <p>Distributed algorithms play an important role for current IT applications and systems. The formal verification of the correctness of distributed algorithms is a challenging task. Distributed algorithms are frequently deployed on dynamic and scalable distributed systems. Therefore, these algorithms will generate a huge space-state and require an long checking time. The aim of this work is explore the use of high-level algebraic Petri nets, Recursive ECATNets, for the specification and formal verification of distributed algorithms. The proposed modelling formalism supports the inherent multi-threading aspect of distributed algorithms. Furthermore, it allows specifying compactly distributed algorithms with complex synchronisation constraints and advanced data structures. In order to show the efectiveness of our approach, the proposed model is applied on the Zusuki and Kasami mutual exclusion algorithm. Recursive ECATNets' models of distributed algorithms are implemented in this work using the Maude system. In order to alleviate the state explosion problem, the runtime dynamic verification approach is used to check whether a distributed algorithm respect the recursive ECTANet model.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Distributed algorithms verification</kwd>
        <kwd>Recursive ECATNets</kwd>
        <kwd>Runtime verification</kwd>
        <kwd>Maude system</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Thanks to the technological advances in the fields of computers and communication networks,
distributed systems have become feasible. Distributed systems can be found at several facets
of our daily life. This is due to the widespread use of wireless networks, mobile devices and
Internet of Things. Distributed systems are now more and more able to meet the growing and
renewable needs of users in terms of computing power and storage space.</p>
      <p>
        Several definitions of the concept "distributed systems" exist. In [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], a distributed system is
defined as a collection of interacting autonomous computing elements. The collection appears
to their users as a single coherent system. This first definition reveals that each component of a
distributed system may behave independently of other components. Despite this, the clients
of the distributed system believe that they are dealing with a single coherent system, i.e. the
existence of stand-alone components is hidden from users.
      </p>
      <p>
        Leslie Lamport [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], defines a distributed system by : “A distributed system is one in which the
failure of a computer you didn’t even know existed can render your own computer unusable”.
This definition suggests that a user is aware of the use of a distributed system, if the failure of
another computer of the system prevents him/her from completing his/her work. The definition
refers to the fault tolerance challenge. Due to the heterogeneity and the physical distribution
of its components, parts of a distributed system may fail. In this case, the distributed system
should automatically recover from failures without afecting the overall performance.
      </p>
      <p>
        Distributed systems provide several advantages. The well-known advantage of a distributed
system is that it enables resource sharing among users. This will facilitate collaboration and
reduce costs. In addition, distributed systems improve calculation speed and eficiency thanks
to the parallel execution of requests over multiple components [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>Distributed computing has grown rapidly in recent years and has become able to tackle
advanced topics. However, distributed applications can be safety-critical for users since an
unwanted behaviour can lead to serious risks. Thus, the designers of distributed applications
should ensure the accuracy of used algorithms before deploying them for real exploitation.</p>
      <p>Checking the correctness of distributed algorithms was the aim of several studies.
Formalbased methods are good candidates for specifying and checking distributed algorithms. They
provide notation with well-defined semantics and are amenable to sound analyses.</p>
      <p>
        The formal checking of distributed algorithms is challenging. This is due to multiple factors,
such as the potential interleaving of events, the asynchronous communication and the possible
failures [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Checking the correctness of distributed algorithms can be approached using model
checking techniques and theorem proving. However, these techniques sufer from the state
space explosion problem and the need for user intervention.
      </p>
      <p>Some research works have proposed to combine model checking and theorem proving to
model and check correctness of distributed algorithms. However, they have used restrictive
specification notations. In addition, these works still need intervention from users with an
appropriate level of experience.</p>
      <p>
        In this paper, we propose to formally specify distributed algorithms using recursive ECATNets
[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] and then check their correctness using a runtime verification approach. Recursive ECATNets
have a graphical notation that facilitates design of distributed algorithms models. They also
allow modelling the multithreading aspect inherent to distributed algorithms. The runtime
checking approach is formal and provides a lightweight yet rigorous method for analysing the
runtime behaviour of systems [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>The paper is organised as follows: Section 2 presents some important related works. The
third section gives some preliminary concepts. In section 4, we describe the proposed approach
for modelling and checking at runtime distributed algorithms. Finally, section 5 gives some
ifnal remarks and future extensions.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Literature review</title>
      <p>
        Ensuring the correctness of distributed algorithms was the aim of several research works
[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. These research eforts have focused on proposing models that are suitable for distributed
algorithms and/or proposing verification techniques that mitigate the state space explosion
problem.
      </p>
      <p>In [7], the author has proposed a hybrid approach that combines deductive reasoning and
bounded model-checking to formally verify distributed algorithms. At first, the distributed
mutual exclusion algorithm of Ricart and Agrawala [8] is checked using the calculus of inductive
constructions of Coq proof assistant using assertional reasoning. Then, a fault tolerant extension
of the same algorithm is implemented using TLA (Temporal Logic of Actions) [9] and checked
on a bounded model.</p>
      <p>Combining proof and model-checking to validate distributed algorithms is an interesting
technique. However, the proposed model deals with a simplified distributed system having few
processes with few critical section access requests. Furthermore, the approach still needs expert
intervention when proving properties. In addition, the author has not mentioned how to scale
up the checking and modelling approaches to deal with complex distributed systems.</p>
      <p>In [10], the author proposed the use of a refinement-based construction of distributed
algorithms. At first, a starting abstract formal model of a distributed algorithm is built. Then,
the model is refined iteratively by adding required behaviours. A verification by construction
approach is followed to ensure correctness of distributed algorithms. The work uses Event-B
modelling language [11] that allows the gradual development of systems through refinement.</p>
      <p>In [12], authors have tackled the challenge of checking correctness of distributed algorithms
running on dynamic environments. Their approach proposes a set of reusable patterns that
facilitate the specification and verification eforts of distributed algorithms. More precisely, a
basic pattern that deals with topological events is first defined. Then, the pattern is extended
using the refinement technique to specify particular distributed systems topologies. A leader
election distributed algorithm is used to show the eficiency of the approach and a set of proofs
associated with the development of the algorithm are presented. The pattern-based approach is
implemented using Event-B and the correctness of resulting specification is ensured by a set of
automatic and interactive proof obligations (POs).</p>
      <p>Despite the importance of gradual verification of distributed algorithms, both [ 10, 12] works
need expert skills in discharging interactive POs. In addition, the authors have not shown how
to generalize their approaches to be applied to other distributed algorithms.</p>
      <p>
        In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], authors have proposed a reusable formal framework for model checking round-based
distributed algorithms. To mitigate the space-explosion problem, two reduction techniques
were proposed: partition symerty reduction and message order reduction. The partition symmetry
technique exploits the symmetry that arises when processes choose non-deterministic initial
value, that is, rather than exploring all possible combinations of processes’ initial states, only a
subset of initial states are visited. The message order reduction technique is applied when the
order in which messages are sent or received is irrelevant for the final result of the algorithm.
The proposed reduction techniques have been implemented using Promela language for the
spin model checker. Reducing the space state will make it possible to automatically check
distributed algorithms. However, the proposed framework suggests reduction techniques that
are closely related to only round-based distributed algorithms. Furthermore, to reuse the
provided verification template written for the spin model checker, users must master promela
language.
      </p>
      <p>In [13], authors have proposed a framework for programming and checking distributed
algorithms. Authors have used DistAlgo language for writing distributed algorithms and for
expressing safety and liveness properties. The DistAlgo language is an object oriented
programming language that has a formal semantics and an open source implementation. Authors have
proposed the use of runtime verification technique for fighting the state space explosion when
checking distributed algorithms’ properties. An external checker observes messages exchanged
between nodes. Then, it verifies safety and liveness properties of the considered algorithms.</p>
      <p>The main drawback of the work is its use of a restrictive specification language for expressing
checked properties. These properties can only be related to bounded reachability. In addition,
DistAlgo language has no graphical notations facilitating the reuse of the proposed framework.</p>
      <p>In this work, a formal approach for checking distributed algorithms is proposed. In order to
tackle the problem of state space explosion, the approach makes use of runtime verification . The
expected behaviours of the considered distributed algorithms are specified using a high-level
Petri net model: Recursive ECATNets. The Verification process consists in examining compliance
of extracted execution traces with the recursive ECATNet model of the distributed algorithm.
The proposed specification formalism (Recursive ECATNets) is expressive; it allows expressing
data flow, control flow as well as advanced synchronisation constraints. Recursive ECATNets are
also equipped with graphical notation that facilitates the specification of distributed algorithms.</p>
      <p>The recursive ECATNet model and the monitor that checks conformance are implemented
using the Maude system. Maude [14] is one of the most eficient implementations of rewriting
logic. In fact, we have benefited from the reflective properties of rewriting logic. The Maude
built-in descent functions have been used to check whether tackled actions are possible over
the recursive ECATNet model.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Preliminaries</title>
      <p>Recursive ECATNets extend ECATNets with useful modelling features, such as creation of
multiple sub-processes and exception handling. Recursive ECATNets can be naturally expressed
using the Maude system.</p>
      <p>The aim of this section is to present basic concepts on Maude, ECATNets and recursive
ECATNets. These concepts will allow a good comprehension of the proposed modelling and
checking methods.</p>
      <sec id="sec-3-1">
        <title>3.1. The Maude system</title>
        <p>Rewriting logic is a logic of concurrent change that can deal naturally with highly
nondeterministic and concurrent computation [15]. Rewriting logic contains an equational subtheory for
representing the systems’ distributed states. It includes also a rewrite theory for implementing
systems’ concurrent transitions [16].</p>
        <p>Maude is a high-level language for specification and programming in rewriting logic [ 14].
Maude supports equational programming using its functional modules. Maude’s system modules
implement concurrent and dynamic systems’ evolution. They implement rewriting logic rewrite
theory. Maude supports reflection and metaprogramming. This can be achieved using decent
functions provided by the module META-LEVEL. The Reflection mechanism of Maude provides
powerful capabilities. Particularly, it allows to guide and adapt the process of applying rewriting
rules at an object level.</p>
        <p>ECATNets can be naturally implemented in Maude. In this case, the algebraic equational
specification depicts the abstract data type underlining the ECATNet, and the set of rewriting
rules implements the dynamic evolution between markings of the ECATNet.</p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. ECATNets</title>
        <p>ECATNets (Extended Concurrent Algebraic Term Nets) are a kind of high-level and algebraic
Petri nets, proposed by [17]. ECATNets combine expressiveness and strength of both Petri
nets with abstract data types. ECATNets are endowed with a natural implementation in terms
of rewri6ting logic, which has allowed to expand their area of use. ECATNets have bxexexnx used
to model and analyse diferent kinds of systems. Furthermore, ECATNets allow to describe
complex sy•ncPhronisat∪ioSnTc,onwsittrhaints and advanced abstractOduattpauttyppelasc[e4s].having a
well= IO IO is a set of Input and
In an ECAdTeNfiente,dpslaocrtesa,ntdransitions and arcs are labelled with elements of a multi-set of</p>
        <p>ST is a set of state places;
algebraic te•rmTsi.sFtihreinsgetruofletsraonfsEitCioAnTs,Nweittsh’ Ptra∩nTsit=ion∅s; establish a clear distinction between
enabling marking and consumed tokens. When firing an ECATNet transition, adding and
removing to•kseonrstt:aPke→place on a multi-set of ground algebraic terms.</p>
        <p>S is a function that associates to each place an algebraic sort s
belonging to Σ;</p>
        <p>Figure 1 depicts a simple ECATNet having one transition and two places. An ECATNet E is
defined by th•e ItuCpl(eInEpu=t C(ondit,ion,):,P×T, →,MTΣ,/EUA,(X))),, wis haerfuenction that specifies
partial conditions on input place markings;
•  = (Σ , ) is the underlining equational algebraic specification of .
•• is t•ihseaDassTfseuotncoi(cafDttipeoeslsnattcrtooehyseaeaatdcnahdsTsinoopckiiuesantttseha)ser:ctsoPe(pte×ao×cfThtt)rp→aonlfasMcaietitToorΣnaf/nsE,siUwtaAiiots(nhoXrt)t,.)a,∩InmiFsui=lgtaui-∅rsee.fut1n,ocftiaaolnngdebtrh′aaaictre the
terms to be consumed from input place;
sorts of places  and ′.
• (•, C)Tis (aCfruenatcetdionTotkheantsd):efinPes×aT p→artMiaTlΣc/oEnUdAit(iXon) oanssoincpiauttespltaoceesacfhorofiruitnpgutthe
transitipolna ce. of P , a multiset of algebraic terms which may be added when a transition
•  (, is) fiisreadf;unction that determines the deleted tokens from input places when firing
the tr•anTsCitio(Tnra.nsition Condition) is an additional condition, its default value is the
•  (′,te)r mis tar ufue;nction specifying the set of tokens to be created in the output places
when•firiMn gi athned tMrafnsairtieornespe.ctively the initial and the final markings.
•  () is a function that expresses further conditions for firing the transition .</p>
        <p>In order to illustrate Open-ECATNets notations, Figure 2 shows a simple hotel
booking service modelled as an Open-ECATNet. For this service, the process is
3.3. Restcaurtresdivbey receiviNngeatshotel request (transition t1 ) for a given date and location</p>
      </sec>
      <sec id="sec-3-3">
        <title>ECAT</title>
        <p>through the interface place pi1, then, either a hotel offer or a not available message
Recursivise EseCnAtT(Ntreatnss(iatbiobnrevt2ia)t.edTRhEuCs,AiTnNtehtsis) [O18p]enex-EteCnAdToNrdeitnaerxyaEmCpAleT:NIeOts=w{iptih1t,hpei2c}o,ncept
of recurSsiTo=n.{Rp1E,Cp2A,TpN3}e,tsMaire=w{e(l1l,-s0u,0it)e}dafnodr mMofde=lli{n(g0,c0o, n1)c}u.rrent systems characterized by
dynamic crTeahteioOnpaennd-EdCelAeTtiNonetofbtehhraevaiodusranisddseufibn-epdrobcyesrseews.riting logic based concurrent
computations. Each transition is materialized by a local rewriting rule of a given
In a RrEewCrAitTeNtehteotwryo; ittypdeesfinoefstrtahnesditiisotrnisbuctaend strduicsttuinrgeuoifshsteadte:s. A nice consequence of
be
the proposed model is that analysis of specified open systems is directly achieved
using the existing formal tools around the Maude system.
Mop-ECATNets (Latreche and Belala, 2014) are a combination of Meta Petri nets
and Open ECATNets, introduced to make possible formal modelling of dynamic
Web service processes.</p>
        <p>Meta Petri nets (Savolainen and Terziyan, 1999) are a multilevel Petri net model
that makes easy flexible modelling and control of dynamic processes. By using
• Elementary transitions that describe ordinary actions, and allow the termination of running
sub-processes. Elementary transitions are graphically depicted by simple rectangles, and
• Abstract transitions that are able to dynamically create new child processes that start their
execution with a specific initial marking. Abstract transitions are graphically represented
by double border rectangles. Their starting marking is mentioned in a rectangle beside
the transition.</p>
        <p>The space state generated by a RECATNet is a tree of processes (an extended marking). Each
sub-process has a set of termination markings that indicate the states in which the sub-process
terminates. When a process ends, it terminates all of its child processes and creates in the father
process the output tokens of the abstract transition which has created them.</p>
        <p>Elementary transitions of RECATNets are fired in the same way as for ECATNets. However,
the outgoing arcs of an abstract transition are labelled with an integer index associated with a
termination marking. When a sub-process reaches a termination marking, it generates tokens
only in the output place linked by an edge having the same index as the index of the termination
marking.</p>
        <p>The events that can take place in a RECATNet are:
• Firing an abstract transition, and creating at the same time a sub-process,
• Firing an elementary transition that can end a running sub-process (executing a cut step),
• Reaching a termination marking and producing tokens in output places of the creating
abstract transition.</p>
        <p>A RECATNet is defined by the tuple  = (, , Υ ,  ), where
•  = (, , , , , , ,  ), is the underlying ECATNet, with  =  ∪
 is the set of abstract and elementary transitions,
•  is a finite set of termination indexes,
• Υ is a family indexed by  of final markings,
•  :  ×  ×  → Σ() is a function specifying the tokens created in output
places of abstract transitions.</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Runtime verification of distributed algorithms using recursive</title>
    </sec>
    <sec id="sec-5">
      <title>ECATNets</title>
      <p>Unlike centralized systems, distributed systems have no common physical clock and
memory. This will complicate the processes synchronisation task. Furthermore, partial failure,
unpredictable communication delays and diference in node processing speed make distributed
algorithms managing and control more dificult and challenging.</p>
      <p>The aim of this section is to detail the proposed runtime verification of distributed algorithms.
The process is organized in two steps: specifying the desired behaviour of the distributed
algorithm as a RECATNet model, and then generating the monitor that extracts the necessary
information for monitoring and checks whether the the runtime behaviour of the distributed
algorithm conforms to the RECANet model.</p>
      <p>This section starts by describing the adopted system model and the chosen case study. Then,
the proposed RECATNet model is depicted. Lastly, we show how to check at runtime the
distributed algorithm regarding the RECATNet model.</p>
      <sec id="sec-5-1">
        <title>4.1. The system model and case study</title>
        <p>The addressed problem in this work is a synchronization problem: the mutual exclusion. The
issue is to ensure that, at any moment, at most one process is authorized to use a resource.</p>
        <p>Two kinds of distributed algorithms were proposed to ensure the exclusive access to a shared
resource: token-based algorithms and non-token-based (permission-based) algorithms [19]. In
permission-based algorithms, a node that needs to use the critical resource must at first receive
permission from other nodes. Contrariwise, when using token-based algorithms, the right to
access a critical resource is conditioned by obtaining the token.</p>
        <p>The case study algorithm of this work is the well-known token-based mutual exclusion
algorithm of Suzuki and Kasami [20]. In this algorithm, a unique token (a special message ) is
shared among all the nodes of the distributed system. A node is allowed to access the critical
section only if it possesses the token. When a site wants to use the critical resource and it has
not the token, it broadcasts request messages to all other sites. A site releases the token only
if it has completed its use of the critical resource. When a site terminates its execution of the
critical section, it sends the token to another requesting site.</p>
        <p>The algorithm of Suzuki and kasami provides several advantages: it has a low message
overhead, it ofers a clear and intuitive approach for achieving mutual exclusion, and it demonstrates
robustness against failure events within a distributed system.</p>
        <p>Through this paper, the following conventions are adopted:
• The system is composed of  nodes (sites).
• It is assumed that only one process runs on each site. Thus, the terms site, node and
process are used interchangeably.
• The nodes are linked by reliable communication channels.
• The processes do not share the memory or the physical clock. So, they only communicate
by exchanging messages.
• The communication delays are finite.
• The distributed system is conceptually fully connected; every site in the system can send
messages to any other site of the system.</p>
        <p>• Nodes use the critical resource for fixed durations.</p>
      </sec>
      <sec id="sec-5-2">
        <title>4.2. RECATNet model of Suzuki and kasami algorithm</title>
        <p>The expected behaviour of the distributed algorithm is expressed using a RECATNet. The
adopted modelling approach makes use of several threads. In this case, a thread may send
requests to access the critical section, while another thread responds to messages received from
other sites. The RECATNet model associated to a distributed system executing Suzuki and
Kasami distributed algorithm is shown in Figure 2.</p>
        <p>Let us first mention that initially, the place p1 contains n tokens, each token is associated
to a site. Tokens of the place p1 have a well defined structure: any token has a component
of the sort natural numbers (Nat) that represents the site identifier, the second and the third
components mention the state of the site and whether the site has the right to use the critical
resource.</p>
        <p>Informally the model of Figure 2 can be explained as follows. At first, the transition
initialize is fired, it consumes all the tokens from the place p1 and produces copies of
these tokens in the output places p2 and p3. This will allow for each site to respond to messages
received from other sites, and to send requests for acquiring the critical resource.</p>
        <p>When the place p2 becomes marked, a site can receive requests from other sites by executing
the transition t4. Then, the site can either emit the token (by firing the transition t5) or going
back (executing the transition t3) if it has not the token or if it is needing the resource. In
addition, when the place p2 is marked, a site can receive the token from other sites by firing
the transition t2.</p>
        <p>Moreover, the place p3 allows nodes to become requesters. If the site is already requester and
has the token, then it directly uses the resource (it fires the transition t6). Otherwise, the site
executes a call to acquire the resource through launching the abstract transition Request-CS.</p>
        <p>The execution of the abstract transition Rquest-CS dynamically creates a new sub-process
that starts its execution with n-1 tokens in place p6. This process is responsible for sending
requests to the remaining sites to obtain the token.</p>
        <p>The execution of the sub-process launched by the transition Rquest-CS is interrupted
automatically when the elementary transition t2 (receipt of the token) is fired with the index
&lt;0&gt;. The execution of this cut step also produces a token in place p3. This will subsequently
allow the access to the critical resource.</p>
        <p>The place p5 contains the token associated to the site using the critical resource. When the
abstract transition Realeas-CS is fired, a sub-process for releasing the resource is launched.
This process starts with a token at the place p8. At first, the process leaving the critical section
goes to the outside state (firing of the transition t9). Then, if there is a pending request from
another site, the token will be passed to it (firing the transition t11). Otherwise, the token will
be maintained (execution of the transition t10).</p>
        <p>The end of a call to release the resource is mentioned by the presence of a token in place
p10 (see termination state Υ 1). During this termination, a token is produced in place p3. This
allows a site to become requester of the critical resource.</p>
        <p>The RECATNet model of the Figure 2 is implemented using Maude. Places identifiers are
specified by algebraic ground terms of the sort PlaceId.</p>
        <p>ops localVar p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 : -&gt; PlaceId .</p>
        <p>Additionally, the states through which sites pass, as well as the number of sites are specified
by algebraic constructor terms:</p>
        <p>ops InCs Reqstr outside : -&gt; State [ctor] . op nbS : -&gt; Nat [ctor] .
Then, one equation is needed to define overall Maude RECATNet model. In fact, the equation
defines the marking of the RECATNet, it associates each place identifier with a set of tokens.
eq inits = (p1,’tk 0 ’tk 1 ’tk 2...) (p2,noneTk) (p3,noneTk) (p4,
noneTk) (p5, noneTk) (p6, noneTk) (localVar, outside TkAv 0 outside
tkNav 1 outside tkNav 2 ... ) &lt; "" &gt; .</p>
        <p>The last implementation step of Zusuki and Kasami algorithm RECATNet is to associate to
each transition a Maude rewriting rule. The left-hand side of each rule is a term that represents
conditions on input places to fire the transition. If conditions of the left-hand side are matched
by the RECATNet marking, then the marking will be updated according the right-hand side
term of the rule. The condition part of each rewrite rule implements further constraints on
input marking to fire the RECATNet transitions.</p>
        <p>The following code shows the rewriting rules associated with the transition that receives a
request and the transition for requesting the critical resource.</p>
        <p>crl [Receive-request]:{M(p2,’tk i tks)(p4,tks’)&lt;M’,(p7,’tk j s)(p8,’tk
j),M’’&gt;} =&gt; {M(p2, tks)(p4,’tk i tks’)&lt;M’,(p7,’tk j i.s)(p8, ’tk j),
M’’&gt;} if in(i,s)==false/\(i =/= j).
rl [Reques-Cs] :{ M (localVar, Reqstr tkNav i tks)(p3,’tk itks’)&lt;M’&gt;}=&gt;
{M (localVar,Reqstr tkNav itks)(p3,tks’)&lt;M’,(p7,’tk i e-l)(p8,’tk i
(INF))&gt;} .</p>
      </sec>
      <sec id="sec-5-3">
        <title>4.3. Runtime monitoring of Zusuki and Kasami algorithm against the</title>
      </sec>
      <sec id="sec-5-4">
        <title>RECATNet model</title>
        <p>The algorithm under scrutiny is implemented using MPI (Message Passing Interface) for
Python which is a standardized communication protocol widely used for implementing
distributed applications. Each node of the distributed system encapsulates an events catching
mechanism that records important events as an execution trace. In fact, we have adopted an
asynchronous online monitoring. That is, while the distributed algorithm is checked during its
execution, the monitor receives the system’s trace of events asynchronously without suspending
any node of the system. Then, the monitor analyses traces at its own pace. This checking
strategy allows to significantly reduce overhead.</p>
        <p>The Maude monitor module benefits from the metaprogramming capabilities of Maude. The
monitor module uses the decent function metaXapply to check whether the transitions of
the RECATNet model (implemented as rewriting rule) corresponding to the traces’ events are
ifreable. In this case, the monitor passes to the following events and update the RECATNet
model according to the fired transition. If no event is possible in the RECATNet model, then
the monitor concludes that the events traces violate the correctness of the analysed distributed
algorithm.</p>
        <p>The following listing includes a slightly modified version of the MONITOR Maude module. The
module declares the operation Verify that accepts as a first parameter the meta representation
of a term denoting the marking of the Suzuki and kasami algorithm’s RECATNet model. The
second parameter of the operation Verify is a term that gathers all traces. The module MONITOR
uses two rewriting rules to check the conformance of the finite execution traces against the
RECATNet model. The first rule checks execution of events having one parameter, whereas the
second checks execution of events having two parameters.</p>
        <p>The following Maude code shows how to use the operation Verify to check at runtime
the correctness of Suzuki and kasami algorithm. In fact, we have checked an execution of the
algorithm that involves three nodes having three traces. In order to check conformance, users
need only to execute the Maude search command that checks whether it is possible to reach a
state in which all traces events where applied on the RECATNet model, i.e. reaching the term
: (’End-trace 0) x (’End-trace 1) x (’End-trace 2) as traces, which is the case
for the following code.
=================
Maude&gt; search in MONITOR : Verify(upTerm(inits),Traces) =&gt;* Verify(T,Tr)
such that Tr == (’End-trace 0) x (’End-trace 1) x (’End-trace 2) .
=================
Solution 1 (state 46)
states: 47 rewrites: 515 in 5811094365ms cpu (1194ms real) (0 rewrites/
second)
T --&gt; ’‘{_‘}[’_&lt;_&gt;[’__[’‘(_‘,_‘)[’localVar.PlaceId,’__[’___[’InCs.State, ’
TkAv.Availabilaty,’0.Zero],’___[’outside.State,’tkNav.Availabilaty ... Tr
--&gt; (’End-trace 0) x (’End-trace 1) x (’End-trace 2)
No more solutions.
=================</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>5. Conclusion</title>
      <p>The motivation of the proposed specification and modelling approach presented in this paper
comes from the need to cope with the state space explosion problem when formally checking
distributed algorithms. Hence a runtime verification approach is used in this work to verify the
distributed algorithms correctness.</p>
      <p>The desired behaviour of a distributed algorithm is expressed using RECATNets. This has
enabled a natural modelling of multithreaded and interruptible computation. The proposed
modelling and checking approach was implemented using Maude language, especially by
leveraging its metalevel capabilities. The modelling and checking approach presented in this
section can be easily reused to check the correctness of other distributed algorithms.</p>
      <p>As a future extension of the work, we plan to extend the proposed model to take in
consideration timed and fault-tolerant behaviour of distributed algorithms. We intend also to
explore how to achieve a choreographed runtime checking where monitors are deployed across
more than one node. This is more in harmony with distributed algorithms principles. Besides,
implementing a graphical editor for creating distributed algorithms RECATNets models and
then translating them into Maude programs will be very useful.</p>
    </sec>
    <sec id="sec-7">
      <title>Acknowledgment</title>
      <p>This work was partially supported by the LABEX-TA project MeFoGL: "Méthode Formelles
pour le Génie Logiciel"
D. B. Popovic, S. N. Vukosavic, C. Toro, Y. Hicks (Eds.), Knowledge-Based and Intelligent
Information &amp; Engineering Systems: Proceedings of the 22nd International Conference
KES-2018, Belgrade, Serbia, 3-5 September 2018, volume 126 of Procedia Computer Science,
Elsevier, 2018, pp. 1551–1560. doi:10.1016/j.procs.2018.08.128.
[7] E. Shishkin, Construction and formal verification of a fault-tolerant distributed mutual
exclusion algorithm, in: N. Chechina, S. L. Fritchie (Eds.), Proceedings of the 16th ACM
SIGPLAN International Workshop on Erlang, Oxford, United Kingdom, September 3-9,
2017, ACM, 2017, pp. 1–12. doi:10.1145/3123569.3123571.
[8] G. Ricart, A. K. Agrawala, An optimal algorithm for mutual exclusion in computer networks,</p>
      <p>Communications of the ACM 24 (1981) 9–17.
[9] L. Lamport, Specifying Systems, The TLA+ Language and Tools for Hardware and Software</p>
      <p>Engineers, Addison-Wesley, 2002.
[10] D. Méry, Refinement-based construction of correct distributed algorithms, in: 2021 Second
International Conference on Information Systems and Software Technologies (ICI2ST),
IEEE, 2021, pp. 46–53.
[11] J.-R. Abrial, Modeling in Event-B: system and software engineering, Cambridge University</p>
      <p>Press, 2010.
[12] F. Fakhfakh, M. Tounsi, M. Mosbah, Modeling and proving distributed algorithms for
dynamic graphs, Future Gener. Comput. Syst. 108 (2020) 751–761. doi:10.1016/j.future.
2020.03.003.
[13] Y. A. Liu, S. D. Stoller, Assurance of distributed algorithms and systems: Runtime checking
of safety and liveness, in: J. Deshmukh, D. Nickovic (Eds.), Runtime Verification - 20th
International Conference, RV 2020, Los Angeles, CA, USA, October 6-9, 2020, Proceedings,
volume 12399 of Lecture Notes in Computer Science, Springer, 2020, pp. 47–66. doi:10.
1007/978-3-030-60508-7_3.
[14] M. Clavel, F. Durán, S. Eker, S. Escobar, P. Lincoln, N. Martı-Oliet, J. Meseguer, R. Rubio,
C. Talcott, Maude manual (version 3.1), SRI International University of Illinois at
UrbanaChampaign http://maude. lcc. uma. es/maude31-manual-html/maude-manual. html (2020).
[15] M. Clavel, F. Durán, S. Eker, P. Lincoln, N. Martı-Oliet, J. Meseguer, J. F. Quesada, Maude:
Specification and programming in rewriting logic, Theoretical Computer Science 285
(2002) 187–243.
[16] J. Meseguer, Twenty years of rewriting logic, The Journal of Logic and Algebraic
Programming 81 (2012) 721–781.
[17] M. Bettaz, M. Maouche, How to specify non determinism and true concurrency with
algebraic term nets, in: Recent Trends in Data Type Specification, Springer, 1991, pp.
164–180.
[18] K. Barkaoui, A. Hicheur, Towards analysis of flexible and collaborative workflow using
recursive ecatnets, in: Business Process Management Workshops: BPM 2007
International Workshops, BPI, BPD, CBP, ProHealth, RefMod, semantics4ws, Brisbane, Australia,
September 24, 2007, Revised Selected Papers 5, Springer, 2008, pp. 232–244.
[19] M. Raynal, Distributed Algorithms for Message-Passing Systems, Springer, 2013. doi:10.</p>
      <p>1007/978-3-642-38123-2.
[20] I. Suzuki, T. Kasami, A distributed mutual exclusion algorithm, ACM Trans. Comput. Syst.
3 (1985) 344–349. doi:10.1145/6110.214406.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Van Steen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. S.</given-names>
            <surname>Tanenbaum</surname>
          </string-name>
          ,
          <article-title>A brief introduction to distributed systems</article-title>
          ,
          <source>Computing</source>
          <volume>98</volume>
          (
          <year>2016</year>
          )
          <fpage>967</fpage>
          -
          <lpage>1009</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Lamport</surname>
          </string-name>
          ,
          <article-title>A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable</article-title>
          .
          <source>" á cacm</source>
          ,
          <year>1992</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>R.</given-names>
            <surname>Barbosa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Fonseca</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Araujo</surname>
          </string-name>
          ,
          <article-title>Reductions and abstractions for formal verification of distributed round-based algorithms</article-title>
          ,
          <source>Software Quality Journal</source>
          <volume>29</volume>
          (
          <year>2021</year>
          )
          <fpage>705</fpage>
          -
          <lpage>731</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>A.</given-names>
            <surname>Hicheur</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Barkaoui</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Boudiaf</surname>
          </string-name>
          ,
          <article-title>Modeling workflows with recursive ecatnets</article-title>
          , in: 2006
          <source>Eighth International Symposium on Symbolic and Numeric Algorithms for Scientific Computing</source>
          ,
          <year>2006</year>
          , pp.
          <fpage>389</fpage>
          -
          <lpage>398</lpage>
          . doi:
          <volume>10</volume>
          .1109/SYNASC.
          <year>2006</year>
          .
          <volume>52</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A.</given-names>
            <surname>Francalanza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. A.</given-names>
            <surname>Pérez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Sánchez</surname>
          </string-name>
          ,
          <article-title>Runtime verification for decentralised and distributed systems</article-title>
          , Lectures on Runtime Verification: Introductory and
          <string-name>
            <given-names>Advanced</given-names>
            <surname>Topics</surname>
          </string-name>
          (
          <year>2018</year>
          )
          <fpage>176</fpage>
          -
          <lpage>210</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>F.</given-names>
            <surname>Fakhfakh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Tounsi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Mosbah</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. H.</given-names>
            <surname>Kacem</surname>
          </string-name>
          ,
          <article-title>Formal verification approaches for distributed algorithms: A systematic literature review</article-title>
          , in: R. J.
          <string-name>
            <surname>Howlett</surname>
            ,
            <given-names>L. C.</given-names>
          </string-name>
          <string-name>
            <surname>Jain</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          <string-name>
            <surname>Popovic</surname>
          </string-name>
          ,
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>