<!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>Bolzano, Italy
" nicoletta.fornara@usi.ch (N. Fornara)
~ https://people.lu.usi.ch/fornaran/ (N. Fornara)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>An Architecture for Monitoring Norms that combines OWL Reasoning and Forward Chaining over Rules</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Nicoletta Fornara</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marco Sterpetti</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Politecnico di Milano</institution>
          ,
          <addr-line>piazza Leonardo Da Vinci 32, Milano</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Università della Svizzera italiana</institution>
          ,
          <addr-line>via G. Bufi 13, 6900 Lugano</addr-line>
          ,
          <country country="CH">Switzerland</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0003</lpage>
      <abstract>
        <p>In this paper we presents the architecture of a system able to monitor the fulfillment or violation of a set of norms (formalized with the T-NORM model) that regulates the performance of a class of actions that should or should not be performed in a temporal interval by autonomous agents. The proposed architecture is innovative because it combines an OWL reasoner with a forward chaining interpreter and its implementation requires to solve various problems of interoperability among them.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Norm</kwd>
        <kwd>Policy</kwd>
        <kwd>Ontology</kwd>
        <kwd>OWL</kwd>
        <kwd>Production Rule</kwd>
        <kwd>Time</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        In NormMAS literature [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] it is widely accepted that norms (or policies1) models are characterized
by: an activation condition, which specifies when norms become active, and by a regulated action
(or target condition), which describes what is prohibited or obliged by the norms [
        <xref ref-type="bibr" rid="ref2 ref3 ref4 ref5">2, 3, 4, 5</xref>
        ]. Out
of these models, the last three describe the activation condition and the obliged or forbidden
action using semantic web technologies. In particular, the OWL-POLAR model [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and the
T-NORM [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] model (which is the model of norm adopted for this demonstration paper) formalize
the conceptual model for describing actions, events, and state of afairs, used in the specification
of activation conditions and regulated actions, using conjunction of atomic assertions expressed
using the classes, properties, and individuals defined in OWL ontologies.
      </p>
      <p>
        The semantics of the notion of activation condition is as follows: when the condition is
satisfied by the world state, the norm becomes active or in force. This relevant change in
the state of the norm is represented in diferent ways in the diferent models: the norm is
instantiated in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] by creating norm instances; the policy is activated for a specific agent in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]
but its activation is not explicitly represented in the data; the norm changes its deontic state
from conditional to active or inForce in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]; and a new specific or general deontic relation is
created in the T-NORM model [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>
        The meaning correlated to the description of the action regulated by a norm is as follows:
when an action that matches with the described one is performed the norm becomes fulfilled (if
it is an obligation) or violated (if it is a prohibition). In the models described in [
        <xref ref-type="bibr" rid="ref4 ref5">4, 5</xref>
        ], it is also
possible to specify what happens if an action that matches with the regulated one cannot be
performed anymore (for example when the deadline for performing the action is elapsed). In
this case the norm becomes violated (if it is an obligation) or fulfilled (if it is a prohibition).
      </p>
      <p>
        Another well known language for expressing policies by taking advantage of semantic web
technologies is the Open Digital Rights Language (ODRL 2.2)2. ODRL is a policy expression
language, it is a W3C Recommendation since 15 February 2018. In ODRL the Information Model
is formalized as an OWL ontology3. The ODRL OWL ontology is used as a metamodel for the
specification of the policies, it is not used for reasoning on policies components nor it is used for
reasoning on the fulfillment or violation of policies. Diferently from the approaches discussed
before, in the ODRL model there is not a clear distinction between an activation condition and
the regulated action. By using the ODRL language it is possible to express constraints on the
performance of the actions regulated by a policy (for example it is obligatory to pay before the
turn of the New Year in 2019), but it is impossible to specify the efects that the satisfaction
of certain constraints have on the policy. Moreover, in ODRL the regulated actions are not
described using the classes, properties and individuals defined in an ontology of actions, but they
are specified using individuals belonging to the ODRL:Action class and constraints on those
individuals. This is due to the fact that in ODRL a policy is an instance of the ODRL:Policy class
or of one of its subclasses. In [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] a proposal to extend ODRL 2.2 with an activation condition is
proposed. In such a paper the activation conditions and the regulated actions are anonymous
individuals belonging to a subclass of the ODRL:Action class and monitoring is realized by
matching such an individual in the policy with a real action happening in the world state. In
[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] a profile of the ODRL 2.2 language is presented and the semantics of ODRL policies is given
by translating them into Answer Set Programming.
      </p>
      <p>
        In the T-NORM model of norms [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and in OWL-POLAR [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], one specific norm is not an
instance of an OWL class, but it is a complex object made by diferent components. In particular,
in OWL-POLAR the diferent components of a norm may be represented in a table and the
activation of policies and their violation is computed with an ad-hoc software and by executing
SPARQL-DL queries. In the T-NORM model the norm designer may specify norms by using basic
building blocks that consist of rules of the form IF...THEN...ELSE as presented in Section
3. From the operational prospective, an interesting proposal for computing the activation and
fulfillment or violation of norms consists in translating every norm into a set of production
rules and then, by using a forward engine, computing their execution. This approach has the
advantage that the norm designer will never need to change the software that manages the
efect of events on norms’ state, but they can simply change the declarative form of norms. The
architecture of a system, able to monitor (or to simulate) the evolution over time of the state of
a set of norms expressed using the T-NORM model, needs to combine an OWL reasoner and
a forward chaining reasoner or interpreter [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. The combination of those two diferent types
of reasoners is innovative and presents some interesting problems that we solved for testing
      </p>
      <sec id="sec-1-1">
        <title>2https://www.w3.org/TR/odrl-model/</title>
        <p>3https://www.w3.org/ns/odrl/2/
our proposal and that we will discuss in this paper by using as running example a norm in the
Covid-19 domain.</p>
        <p>This paper is organized as follows. In Section 2 the OWL ontologies required for formalizing
and monitoring norms are presented. In Section 3 the T-NORM model and one example of norm
is introduced. In Section 4 the architecture of the system for norms monitoring is described and
its implementation is discussed.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>2. OWL Ontologies for Modelling and Monitoring Norms</title>
      <p>The goal of the proposed architecture is to realize norms monitoring. For doing that it is
crucial to represent: (i) the world state; (ii) the activation condition and the actions regulated
by the norms; (iii) a mechanism for matching the real actions performed by agents with the
one regulated by norms. It is feasible to realize this matching when the model for representing
the wold state and the one used for specifying the relevant actions and events described in the
norms are the same or are at least compatible.</p>
      <p>The world state consists of state of afairs, events, and actions, that are events performed
by an actor. We propose to model the world state by using the Event Ontology in OWL. The
advantages of using an OWL ontology are: first of all the possibility to use OWL reasoning for
deducing new knowledge; secondly OWL reasoning has an efect on the normative position
of the regulated actions. In fact, if the performance of an action  implies another one ′ (for
example when I sell a product I am also transferring the property of the product) we have that: (i)
if action ′ is obliged (transferring the property), the performance of action  (selling) will fulfill
the obligation; (ii) if action ′ is prohibited (transferring the property), the performance of action
 (selling) will violate the prohibition. In order to make it easy to realize a matching between
real actions and the regulated ones we propose to use the Event Ontology also for modelling
events and actions descried in the norms. The Event Ontology imports the W3C Candidate
Recommendation Time Ontology in OWL for connecting events to instants or intervals of time.
To be used in the formalization of concrete examples, the Event Ontology needs to be extended
with a domain-specific Action Ontology that defines a hierarchy of classes and a set of properties
for modelling various types of actions like for instance paying, selling, testing, and so on.</p>
      <p>The second ontology introduced in our system is the T-NORM Ontology, it is required for
managing and representing the efects of the activation of norms and of their fulfillment or
violation. The T-NORM Ontology imports the Event Ontology for representing events that are
relevant for norms, for example the deadlines for obligations that are represented as individuals
of the TimeEvent class. It is used for representing the activation of norms by creating specific
or general deontic relations and for representing the fulfillment and violation of those deontic
relations. The T-NORM Ontology is depicted in Figure 1 together with the Event Ontology and
the Time Ontology4.</p>
      <p>4The T-NORM ontology is available at https://raw.githubusercontent.com/fornaran/T-Norm-Model/main/
tnorm.owl</p>
    </sec>
    <sec id="sec-3">
      <title>3. The T-NORM Model and a Running Example</title>
      <p>
        The T-NORM model is presented in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. By using this model the norm designer may specify
norms by using basic building blocks that consist of rules of the form IF...THEN...ELSE.
There is not a pre-defined type of norm, like obligation or prohibition, but it is the norm designer
that has the instrument to specify that when an activation event happens and some contextual
conditions are satisfied, some parameters must be computed (for example the deadline for
obligations) and then the monitoring of the performance of an action belonging to a class of
regulated actions has to start. The result of the monitoring process is the fulfillment or violation
of a set of norms. In particular, if a specific action that belongs to the class of the regulated one
is performed there is a fulfillment, when the action is obligated, or a violation, when the action
is prohibited; otherwise, if a specific action cannot be performed anymore (for example because
it must be performed before the deadline and the deadline has elapsed) there is a violation (this
is the case of obligations) or a fulfillment (when the norm represents a prohibition). The abstract
form of a norm is:
NORM Norm_n
[ON ?event1 WHERE conditions on ?event1
THEN
      </p>
      <p>COMPUTE]
CREATE DeonticRelation(?dr);
ASSERT isGenerated(?dr,Norm_n); [activated(?dr,?event1);]
ON ?event2 [BEFORE ?event3 WHERE conditions on ?event3]</p>
      <p>WHERE actor(?event2,?agent) AND conditions on ?event2
THEN ASSERT fulfills(?agent,?dr); fullfilled(?dr,?event2) |</p>
      <p>violates(?agent,?dr); violated(?dr,?event2)
[ELSE ASSERT violates(?agent,?dr); violated(?dr,?event3) |</p>
      <p>fulfills(?agent,?dr); fulfilled(?dr,?event3)]</p>
      <p>Where conditions are a conjunctions of atomic assertions over the Event Ontology with
the use of variables5. In the ASSERT parts only the variables introduced in the previous parts
can be used. One useful example of prohibition that can be represented with the T-NORM model
is: “a person who has a positive swab to Covid-19 cannot leave the house for the next 15 days”. It
is formalized in the following way:
NORM Norm01
ON ?e1 WHERE PositiveTest(?e1) AND affectedPerson(?e1,?agent) AND</p>
      <p>atTime(?e1,?inst1) AND inXSDDateTimeStamp(?inst1,?t1)
THEN</p>
      <p>COMPUTE ?tend=?t1.days+15
CREATE DeonticRelation(?dr); TimeEvent(?tev_end); Instant(?inst_end);
ASSERT isGenerated(?dr,Norm01); activated(?dr,?e1); atTime(?tev_end,?inst_end);
inXSDDateTimeStamp(?inst_end,?tend); end(?dr,?tev_end); debtor(?dr,?agent);
ON ?e2 BEFORE ?tev_end</p>
      <p>WHERE LeaveHouse(?e2) AND actor(?e2,?agent) AND from(?e2,?house) AND home(?agent,?house)
THEN ASSERT violates(?agent,?dr); violated(?dr,?e2)
ELSE ASSERT fulfills(?agent,?dr); fulfilled(?dr,?tev_end)</p>
      <p>The operational semantics of the T-NORM model is specified by providing an unambiguous
procedure for translating every norm into a set of production rules, i.e. a formalism that already
has an operational semantics6. The translation of the IF...THEN part is straightforward,
because the form of a production rule is: IF conditions THEN actions. Diferently, the translation
of the ELSE part requires to capture its meaning. That is, the ELSE branch is followed whenever
an event that matches the description of event2 cannot happen anymore. For example in
Norm01 the ELSE branch is followed when the deadline is elapsed7.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Architecture for Norms Monitoring and its Implementation</title>
      <p>The architecture of the system designed to monitor norms formalized with the T-NORM model
is depicted in Figure 2. It combines an OWL reasoner with a forward chaining engine. The
depicted process consists in the following steps: (1) the norms, in force at a given instant of
time, are translated into productions rules8; (2) the state of the world is loaded into the working
memory of the production system and the value of the now variable is set to the current time;
(3) an OWL reasoner is executed on the working memory; (4) a forward chaining engine is
executed on the result of the OWL reasoner by using as input the production rules resulting
from step 1; (5) the efects of the production rules are stored in the working memory. Whenever
the working memory is updated with an event (including a Time Event) the process restarts
from point 2.</p>
      <p>5The syntax of conditionsis equal to the Human Readable Syntax of the antecedent of SWRL rules
https://www.w3.org/Submission/SWRL/#2.2</p>
      <p>6The operational semantics of a production rule system is given in the W3C Recommendation of the RIF
Production Rule Dialect10 w3.org/TR/rif-prd/#Operational_semantics_of_rules_and_rule_sets
7Assuming that there is complete knowledge of all the actions or events happened in a given instant of time
8The translation of Norm01 into the corresponding production rules is available at https://raw.
githubusercontent.com/fornaran/T-Norm-Model/main/Rules-Covid19</p>
      <p>
        An interesting research question would be whether it is possible to avoid combining two
diferent types of reasoning. In [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] we studied the approach of using only an OWL reasoner
for computing the activation and the fulfillment or violation of norms. Due to the open-world
assumption of OWL reasoning, we faced the problem of deducing that when an action is not
performed before a given deadline the related norm becomes violated. This problem was solved
by computing the closure of certain OWL classes using a Java program.
4.1. Implementation and Testing
We tested the proposed architecture by using Pellet9, as OWL 2 reasoner, and the JENA general
purpose rule engine10 as forward chaining engine. We decided to use JENA, instead of another
production system, like Drools (which is used in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]), because its rule engine natively supports
rule-based computations over an OWL ontology serialized as an RDF graph. The main problem
with Drools is due to the need of translating the OWL ontologies into Java classes for being able
to execute the production rules on the state of the world. Another advantage of choosing the
JENA forward engine is that it allows to combine RDFS/OWL reasoning with custom rules11
by cascading reasoners. The main problem we had in the implementation and testing of this
part is the lack of a clear documentation on how to realize this combination in Java. A very
useful source of information is represented by the slides about the integration of Pellet and
JENA presented in the ISWC2009 tutorial “Building Ontology-based Applications using Pellet”.
The most critical part of the Java code required for combining Pellet with Jena is the following:
//Create an ontology model (OntModel) by reading the world state ontology
OntModel rawModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
rawModel.read("file:" + modelSourceFile);
      </p>
      <sec id="sec-4-1">
        <title>9http://pellet.owldl.com/ 10https://jena.apache.org/documentation/inference/#rules 11https://jena.apache.org/documentation/inference/#RDFSPlusRules</title>
        <p>//Create another ontology model using Pellet reasoner and the rawModel above
OntModel model=ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC,rawModel);
//Create a generic inferencing model (InfModel) using the ontology model above
//and the rules that represent the norms
GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
InfModel infModel = ModelFactory.createInfModel(reasoner, model);</p>
        <p>Whenever the rawModel is updated or queried the Pellet reasoner is executed, this may
introduce some overhead due to the queries to the OWL reasoner. One possible weakness of
this approach is that it is “layered”, i.e. the outer InfModel can work on the results of the inner
model but not viceversa. For our architecture this is not a problem because we do not need to
perform OWL reasoning on the efects of production rules.</p>
        <p>Given that the JENA forward chaining engine does not support the specification of a priority
among rules, and we need it for the management of exceptions (for example for expressing
permissions), we introduced into the rules the evaluation of the value of a variable called
salience.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>S.</given-names>
            <surname>Villata</surname>
          </string-name>
          (Ed.), Special Issue:
          <article-title>Normative Multi-Agent Systems</article-title>
          , volume
          <volume>5</volume>
          of Journal of Applied Logics - IfCoLog
          <string-name>
            <surname>Journal</surname>
          </string-name>
          , College Publications,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S.</given-names>
            <surname>Álvarez-Napagao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Aldewereld</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Vázquez-Salceda</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Dignum</surname>
          </string-name>
          ,
          <article-title>Normative monitoring: Semantics and implementation</article-title>
          , in: M. D.
          <string-name>
            <surname>Vos</surname>
          </string-name>
          , et al. (Eds.),
          <source>COIN@AAMAS</source>
          <year>2010</year>
          ,
          <article-title>COIN@MALLOW 2010, Revised Selected Papers</article-title>
          , volume
          <volume>6541</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2010</year>
          , pp.
          <fpage>321</fpage>
          -
          <lpage>336</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Sensoy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T. J.</given-names>
            <surname>Norman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W. W.</given-names>
            <surname>Vasconcelos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. P.</given-names>
            <surname>Sycara</surname>
          </string-name>
          ,
          <article-title>OWL-POLAR: A framework for semantic policy representation and reasoning</article-title>
          ,
          <source>J. Web Sem</source>
          .
          <volume>12</volume>
          (
          <year>2012</year>
          )
          <fpage>148</fpage>
          -
          <lpage>160</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>N.</given-names>
            <surname>Fornara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Colombetti</surname>
          </string-name>
          ,
          <article-title>Using semantic web technologies and production rules for reasoning on obligations, permissions, and prohibitions</article-title>
          ,
          <source>AI Commun</source>
          .
          <volume>32</volume>
          (
          <year>2019</year>
          )
          <fpage>319</fpage>
          -
          <lpage>334</lpage>
          . URL: https://doi.org/10.3233/AIC-190617. doi:
          <volume>10</volume>
          .3233/AIC-190617.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>N.</given-names>
            <surname>Fornara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Roshankish</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Colombetti</surname>
          </string-name>
          ,
          <article-title>A framework for automatic monitoring of norms that regulate time constrained actions</article-title>
          ,
          <source>in: Proc. of the COINE 2021 co-located with AAMAS</source>
          <year>2021</year>
          , 3rd May
          <year>2021</year>
          , London, UK.,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>M. De Vos</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Kirrane</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Padget</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Satoh</surname>
          </string-name>
          ,
          <article-title>Odrl policy modelling and compliance checking</article-title>
          , in: P. Fodor,
          <string-name>
            <given-names>M.</given-names>
            <surname>Montali</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          , D. Roman (Eds.),
          <source>Rules and Reasoning</source>
          , Springer International Publishing, Cham,
          <year>2019</year>
          , pp.
          <fpage>36</fpage>
          -
          <lpage>51</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>R.</given-names>
            <surname>Brachman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Levesque</surname>
          </string-name>
          ,
          <source>Knowledge Representation and Reasoning</source>
          , Morgan Kaufmann Publishers Inc., San Francisco, CA, USA,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>N.</given-names>
            <surname>Fornara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Colombetti</surname>
          </string-name>
          ,
          <article-title>Representation and monitoring of commitments and norms using OWL</article-title>
          ,
          <source>AI Commun</source>
          .
          <volume>23</volume>
          (
          <year>2010</year>
          )
          <fpage>341</fpage>
          -
          <lpage>356</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>