<!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>Algebraic Petri Nets with Active Tokens: Efective Implementation in Maude</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Lorenzo Capra</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michael Köhler-Bussmeier</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Implementing Algebraic Petri Nets</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dipartimento di Informatica, Università degli Studi di Milano -</institution>
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Hamburg University of Applied Sciences</institution>
          ,
          <addr-line>Berliner Tor 7, D-20099 Hamburg</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Coloured Petri nets (CPN) [1] are one of the major steps towards practical usage. In some sense, coloured nets are abstract in the sense that an external mechanism is assumed to generate bindings. A concrete formalism is obtained by importing a concrete annotation language and type system for arc expressions, like ML. Resig's Algebraic Petri nets [2] may represent one of the most robust and sophisticated high-level Petri net formalisms proposed to date, integrating clear mathematical semantics grounded in pure equational logic [3, 4] with intuitive operational semantics, high expressiveness, and analytical capabilities. However, it appears that there are few rigorous implementations derived from this model based on an algebraic framework: notable among these is the OBJSA formalism [5] and the associated tool (based on OBJ [6]), both unfortunately no longer supported. Other implementations of pseudo-algebraic nets have utilised various established programming languages such as Java or Python, partially compromising the original model's soundness. Translation of Algebraic Petri Nets into Conditional Rewrite Rules We present an efective implementation of algebraic Petri nets utilizing Maude [7], a purely declarative algebraic language characterized by sound rewriting logic semantics. Our definition follows the idea originally proposed in [8]. Despite Maude being proposed as a unifying framework for Petri Nets two decades ago and some recent works employing it to specify diferent classes of Petri Nets [ 9, 10, 11, 12, 13], we contend that our approach is the first systematic utilization of Maude as an efective rewriting engine for algebraic Petri Net models. Additonally, we explore the formalisation of algebraic net inscriptions as terms designed to conform to Maude's pattern-matching (modulo axioms) strategy, which ensures eficiency through the ground coherence property. Representation of Multisets In this contribution, we explore two potential approaches to cope with these modelling challenges arising from Maude's pattern-matching methodology employed in its operational semantics. The first approach is based on a classical representation of multisets as a free monoid on a set and the second one is based on a more compact representation as weighted sums. A small set of base functional modules delineate the signature of algebraic Petri nets (accessible at https://github.com/lgcapra/rewpt/blob/main/algPT/ALG-PN.maude). The resulting module hierarchy is succinct, modular, and easily extendable For both methods we define a translation procedure that generates conditional rewrite rules from the inscriptions of arcs and transitions.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Active Tokens We further demonstrate the advantage of using rewritable terms as active tokens
[14, 15, 16, 17, 18], a feature naturally supported by Maude. When places are linked to system modules,
tokens act as “dynamic entities” that can be rewritten. To demonstrate the advantages of this capability
– natural within the context of Maude and aligning perfectly with our definition of algebraic nets –
we will present an example of meta-modelling. Instead of utilizing the meta-model modules available
in the Maude system, which are cumbersome and reserved for expert users (and also impact rewrite
eficiency), we will showcase an application directly at the object-level. This approach is akin to the
nets-within-nets concept, but more generalized: We define an algebraic net where places contain nested
algebraic nets, using the same methodology described in the previous sections.</p>
    </sec>
    <sec id="sec-2">
      <title>Outlook</title>
      <p>We presented an efective methodology for the comprehensive implementation of the algebraic nets
schema in Maude, a purely declarative algebraic language characterized by sound rewriting logic
semantics. The fundamental Maude tools for model-checking and formal verification are readily
accessible; more sophisticated options (such as symbolic reachability and SMT) may be integrated at a
later stage.</p>
      <p>Our approach has the advantage that it allows rewritable terms for coloured tokens, i.e., we allow for
active tokens. A special case of active case are nets-within-nets, where the tokens are Petri nets again.
Our framework allows modifications to the structure and dynamic aspects can be straightforwardly
integrated, such as the removal or addition of net places, changes in types linked to places, arcs that
depend on parameters or markings, rewrite rules or transitions parametric in pre- and post-sets.</p>
    </sec>
    <sec id="sec-3">
      <title>Declaration on Generative AI</title>
      <p>The author(s) have not employed any Generative AI tools.
[11] M.-O. Stehr, J. Meseguer, P. C. Ölveczky, Rewriting logic as a unifying framework for Petri nets, in:
H. Ehrig, G. Juhas, J. Padberg, G. Rozenberg (Eds.), Unifying Petri Nets, Lecture Notes in Computer
Science (Advances in Petri Nets), Springer-Verlag, 2001.
[12] K. Hofmann, H. Ehrig, T. Mossakowski, High-level nets with nets and rules as tokens, in:
Application and Theory of Petri Nets and Other Models of Concurrency, volume 3536 of Lecture
Notes in Computer Science, Springer-Verlag, 2005, pp. 268 – 288.
[13] J. Padberg, L. Kahloul, Overview of reconfigurable Petri nets, in: R. Heckel, G. Taentzer (Eds.),</p>
      <p>Graph Transformation, Specifications, and Nets, volume 10800, Springer-Verlag, 2018, pp. 201–222.
[14] R. Valk, Object Petri nets: Using the nets-within-nets paradigm, in: J. Desel, W. Reisig, G. Rozenberg
(Eds.), Advanced Course on Petri Nets 2003, volume 3098 of Lecture Notes in Computer Science,
Springer-Verlag, 2003, pp. 819–848.
[15] K. Hofmann, T. Mossakowski, Algebraic higher-order nets: Graphs and petri nets as tokens, in:
Recent Trends in Algebraic Development Techniques, 16th International Workshop, WADT 2002,
volume 2755 of Lecture Notes in Computer Science, Springer-Verlag, 2003, pp. 253–267.
[16] M. Köhler-Bußmeier, A survey on decidability results for elementary object systems, Fundamenta</p>
      <p>Informaticae 130 (2014) 99–123. doi:10.5555/2608435.2608440.
[17] M. Köhler-Bußmeier, Hornets: Nets within nets combined with net algebra, in: K. Wolf, G.
Franceschinis (Eds.), Application and Theory of Petri Nets (ICATPN’2009), volume 5606 of Lecture Notes in
Computer Science, Springer-Verlag, 2009, pp. 243–262. doi:10.1007/978-3-642-02424-5_15.
[18] L. Capra, M. Köhler-Bußmeier, Modular rewritable Petri nets: an eficient model for dynamic
distributed systems, Theoretical Computer Science 990 (2024) 114397. doi:10.1016/j.tcs.2024.
114397.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>K.</given-names>
            <surname>Jensen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. M.</given-names>
            <surname>Kristensen</surname>
          </string-name>
          ,
          <source>Coloured Petri Nets: Modelling and Validation of Concurrent Systems</source>
          , Springer-Verlag,
          <year>2009</year>
          . doi:
          <volume>10</volume>
          .1007/b95112.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>W.</given-names>
            <surname>Reisig</surname>
          </string-name>
          ,
          <article-title>Petri nets and algebraic specifications</article-title>
          ,
          <source>Theoretical Computer Science</source>
          <volume>80</volume>
          (
          <year>1991</year>
          )
          <fpage>1</fpage>
          -
          <lpage>34</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>H.</given-names>
            <surname>Ehrig</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Mahr</surname>
          </string-name>
          , Fundamentals of algebraic Specification,
          <source>EATCS Monographs on TCS, SpringerVerlag</source>
          ,
          <year>1985</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bouhoula</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.-P.</given-names>
            <surname>Jouannaud</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Meseguer</surname>
          </string-name>
          ,
          <article-title>Specification and proof in membership equational logic</article-title>
          ,
          <source>Theoretical Computer Science</source>
          <volume>236</volume>
          (
          <year>2000</year>
          )
          <fpage>35</fpage>
          -
          <lpage>132</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>E.</given-names>
            <surname>Battiston</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>DeCindio</surname>
          </string-name>
          , G. Mauri,
          <article-title>OBJSA nets: a class of high-level nets having objects as domains</article-title>
          , Springer-Verlag, Berlin, Heidelberg,
          <year>1988</year>
          , p.
          <fpage>20</fpage>
          -
          <lpage>43</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>J.</given-names>
            <surname>Goguen</surname>
          </string-name>
          , G. Malcolm, Algebraic Semantics of Imperative Programs, MIT Press,
          <year>1996</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Clavel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Durán</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Eker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Lincoln</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Martí-Oliet</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Meseguer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. L.</given-names>
            Talcott (Eds.),
            <surname>All About Maude - A High-Performance Logical</surname>
          </string-name>
          <string-name>
            <surname>Framework</surname>
          </string-name>
          , How to Specify,
          <source>Program and Verify Systems in Rewriting Logic</source>
          , volume
          <volume>4350</volume>
          of Lecture Notes in Computer Science, Springer-Verlag,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>R.</given-names>
            <surname>Bruni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Meseguer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Montanari</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Sassone</surname>
          </string-name>
          ,
          <article-title>A comparison of Petri net semantics under the collective token philosophy</article-title>
          , in: J.
          <string-name>
            <surname>Hsiang</surname>
            ,
            <given-names>A</given-names>
          </string-name>
          . Ohori (Eds.),
          <source>Advances in Computing Science ASIAN 98</source>
          , Springer Berlin Heidelberg, Berlin, Heidelberg,
          <year>1998</year>
          , pp.
          <fpage>225</fpage>
          -
          <lpage>244</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Padberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Mahr</surname>
          </string-name>
          , L. Ribeiro,
          <article-title>Algebraic high-level net transformation systems</article-title>
          , Mathematical structures in computer science (
          <year>1995</year>
          )
          <fpage>217</fpage>
          -
          <lpage>256</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>O.</given-names>
            <surname>Biberstein</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Buchs</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Guelfi</surname>
          </string-name>
          ,
          <article-title>Object-oriented nets with algebraic specifications: The coopn/2 formalism</article-title>
          , in: G. A.
          <string-name>
            <surname>Agha</surname>
          </string-name>
          , F. De Cindio, G. Rozenberg (Eds.),
          <source>Concurrent Object-Oriented Programming and Petri Nets: Advances in Petri Nets</source>
          , Springer, Berlin, Heidelberg,
          <year>2001</year>
          , pp.
          <fpage>73</fpage>
          -
          <lpage>130</lpage>
          . URL: https://doi.org/10.1007/3-540-45397-
          <issue>0</issue>
          _3. doi:
          <volume>10</volume>
          .1007/3-540-45397-
          <issue>0</issue>
          _
          <fpage>3</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>