<!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>Extended Abstract: Early Validation of High-level System Requirements with Event Calculus and Answer Set Programming</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ondřej Vašíček</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Joaquin Arias</string-name>
          <email>joaquin.arias@urjc.es</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff8">8</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jan Fiedor</string-name>
          <email>ifiedor@fit.vut.cz</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
          <xref ref-type="aff" rid="aff4">4</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Gopal Gupta</string-name>
          <email>gupta@utdallas.edu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff7">7</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Brendan Hall</string-name>
          <email>bren@ardentinnovationlabs.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Křena Bohuslav</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Brian Larson</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff6">6</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Sarat Ch. Varanasi</string-name>
          <email>SaratChandra.Varanasi@ge.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Tomáš Vojnar</string-name>
          <email>vojnar@fi.muni.cz</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
          <xref ref-type="aff" rid="aff5">5</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Abstract This is an extended abstract of [1] O. Vašícek</institution>
          ,
          <addr-line>J. Arias, J. Fiedor, G. Gupta, B. Hall, B. Křena, B. Larson, S. C. Varanasi, T. Vojnar</addr-line>
          ,
          <institution>Early Validation of High-level System Requirements with Event Calculus and Answer Set Programming, which is a paper accepted at ICLP'24</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Ardent Innovation Labs</institution>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Brno University of Technology</institution>
          ,
          <addr-line>Brno, Czechia</addr-line>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>GE Aerospace Research</institution>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff4">
          <label>4</label>
          <institution>Honeywell International s.r.o.</institution>
          ,
          <addr-line>Brno, Czechia</addr-line>
        </aff>
        <aff id="aff5">
          <label>5</label>
          <institution>Masaryk University</institution>
          ,
          <addr-line>Brno, Czechia</addr-line>
        </aff>
        <aff id="aff6">
          <label>6</label>
          <institution>Multitude Corporation</institution>
          ,
          <addr-line>St Paul, Minnesota</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff7">
          <label>7</label>
          <institution>The University of Texas at Dallas</institution>
          ,
          <addr-line>Texas</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff8">
          <label>8</label>
          <institution>Universidad Rey Juan Carlos</institution>
          ,
          <addr-line>Madrid</addr-line>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Early validation of specifications describing requirements placed on cyber-physical systems (CPSs) under development is essential to avoid costly errors in later stages of the development, especially when the systems undergo certification. However, there is a lack of suitable automated tools and techniques for this purpose. A crucial need here is that of a small semantic gap between the requirements and the formalism used to model them for the purposes of validation. As described by [2], Event Calculus (EC) is a formalism suitable for commonsense reasoning. The semantic gap between a requirements specification and its EC encoding is near-zero because its semantics follows how a human would think of the requirements. Using Answer Set Programming (ASP) [3] and the s(CASP) [4] system for goal-directed reasoning in EC, the work [5] has demonstrated the versatility of EC for modelling and reasoning about CPSs. In this work, we develop a model of the core operation of the PCA pump [6]-a real safety-critical device that automatically delivers pain relief drugs into the blood stream of a patient-in order to assess, demonstrate, and improve the practical capabilities (and current limitations) of the EC+s(CASP) approach. The model operates in a way similar to an early prototype of the system and, thus, can be used to reason about its behaviour. However, due to the nature of EC, the behaviour of the model is very close to what the requirements themselves describe. Modelling the PCA Pump Requirements in EC under s(CASP) The transformation of the requirements specification of the PCA pump into an EC representation implemented in s(CASP) was done manually. The requirements specification and all the source codes of its s(CASP) representation can be found at https://github.com/ovasicek/pca-pump-ec-artifacts/. The below is a brief, illustrative overview of s(CASP) code for the delivery of a patient bolus (one of the features of the pump), which</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Requirements Validation</kwd>
        <kwd>Event Calculus</kwd>
        <kwd>Answer Set Programming</kwd>
        <kwd>s(CASP)</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>is an extra dose of drug delivered upon the patient’s request. We define events that start and end the
delivery of the bolus which is represented by a state fluent (lines 1-4). The total amount of drug delivered
to the patient and how the amount increases during the bolus is represented by a continuous fluent
and a trajectory (lines 6-10). And finally, the bolus stops automatically once the right amount of drug
(so called VTBI) is delivered which is represented by an event triggered based on the drug delivered
during the ongoing bolus (lines 12-15). A new continuous fluent and trajectory are used to represent
the volume of drug delivered by a bolus counting from zero instead of computing the diference of total
drug delivered at the start and at the end of a bolus (lines 17-20).</p>
      <p>
        Validating Consistency of Use/Exception Cases and the Requirements The first validation
method that we propose is a way to check the consistency between the behaviour defined by the
requirements specification and the use cases (UC) and exception cases (ExC) based on which the
requirements were created (or, in general, checking consistency of the behaviour against any scenarios
defined at a diferent level of the specification) by, essentially, simulating the UC/ExC. This is done
by transforming the UC/ExC into an EC narrative and forming a query based on the UC/ExC and its
post-conditions. If running the query on the narrative using s(CASP) fails, then we have found an
inconsistency. Using this technique we were able to identify a number of such inconsistencies in the
PCA pump specification. A simplified example of such a narrative and query for UC2: Patient-Requested
Bolus is shown below. The use case specifies the delivery of a patient requested bolus which is requested
during basal delivery (the baseline delivery mode), is not denied by the pump, and the pump goes back
to basal delivery after the bolus finishes. Lines 1-2 specify the input events which occur in the narrative,
and lines 3-9 define the query to be checked. Full implementation of UC2 can be found in uc2.pl.
1 happens(start_button_pressed, 60).
2 happens(patient_bolus_requested, 120).
3 ?- holdsIn(basal_delivery_enabled,
4 happens(patient_bolus_delivery_started,
5 not_happens(patient_bolus_denied,
6 initiallyP(vtbi(VTBI)), happens(patient_bolus_completed,
7 holdsAt(patient_bolus_drug_delivered(VTBI),
8 happens(basal_delivery_started,
9 holdsAfter(basal_delivery_enabled,
60, 120),
120),
120),
T2),
T2),
T2),
T2).
Validating the Requirements wrt. General Properties The second validation method that we
propose is a way to check whether the requirements specification satisfies general properties, such as
that the system should not allow an overdose of the patient or that the system should respond to an
event within a given time limit. This is done by representing a general property as an s(CASP) query
and checking that query on suitable narratives. In this way, we were able to detect that the patient
can be overdosed by the PCA pump in certain specific narratives, which is a safety property violation
caused by a missing requirement. We were further able to leverage the abductive reasoning capabilities
of s(CASP) in order to generalize the narrative on which the property is being checked. In our case
of checking the possibility of an overdose, we were able to abduce the parameters of an overdose
(what volume of drug is allowed over what time period) and, subsequently, detect the possibility of an
overdose in the “sunny day” narrative of UC2 in which the overdose does not directly occur otherwise.
Results of Experimental Evaluation We have simulated all relevant UCs and ExCs from the PCA
pump specification and checked the possibility of an overdoes of the patient. Some of the cases appear
in multiple variants of the narrative and we aggregate the measurements of variants of the same case
that led to the same result to save space. Implementations of all experiments can be found in the
narratives_and_queries folder. Table 1 shows selected representative results of simulating UCs and
ExCs. All UCs were simulated successfully, but quite a few ExCs failed. This has led to the discovery of
a number of issues in the specification, such as inconsistencies in alarm responses or defined constants.
Table 2 shows results and execution times of querying overdose on variants of ExC13 (implemented in
overdose-ec13b.pl and similar) and of using abduction on UC2. Execution of the overdose queries takes
much longer than the simulation queries from Table 1 due to the higher complexity of the overdose
query. However, the abductive queries are the slowest ones due to the higher complexity of abduction
in general but also due to the limitations of its current implementation in s(CASP).
Techniques Used to Empower s(CASP) Reasoning We further present a number of challenges
encountered during the translation of the requirements to EC encoded in s(CASP) and during the
subsequent evaluation, based on deductive as well as abductive reasoning, which was often too costly
or non-terminating. We have applied and, in multiple cases, also newly developed various techniques
that helped us resolve many of these challenges. These include extensions of the axiomatization of
the EC (in a similar way as [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]) and special ways of translating certain parts of the specifications
in order to avoid non-termination, in particular when dealing with certain trajectories. Further, we
present an original approach to abductive reasoning in s(CASP) with incrementally refined abduced
values in order to assure consistency of the abduced values whenever abduction on the same value is
used multiple times in the reasoning tree. Next, we proposed a mechanism for caching evaluations
(failure-tabling and tabling of ground sub-goal success) of selected predicates (in a similar way as
mode-directed tabling [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ]) that was added into s(CASP) as a prototype leading to a significant increase
in performance. We also describe a way of separating the reasoning about the trigger and the efect of
certain complexity-inducing triggered events into multiple reasoning runs where each run produces
new facts to be used in the subsequent ones, which reduces their performance impact.
Conclusion Our work demonstrated that EC can be used to model the requirements specification
of a non-trivial, real-life cyber-physical system in s(CASP) and the reasoning involved can lead to
discovering issues in the requirements while producing valuable evidence towards their validation.
Indeed, the work resulted in the discovery of a number of issues in the PCA pump specification, which
we have discussed and confirmed with the authors of the specification.
      </p>
      <p>
        Our future work involves improving s(CASP) in order to make it more eficient and to reduce the
number of non-termination issues, and making our approach more general and practically usable, in
particular targeting the transformation phase by introducing a more structured specification language
such as [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>O.</given-names>
            <surname>Vašícek</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Fiedor</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Gupta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Hall</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Křena</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Larson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. C.</given-names>
            <surname>Varanasi</surname>
          </string-name>
          , T. Vojnar,
          <article-title>Early Validation of High-level System Requirements with Event Calculus and Answer Set Programming</article-title>
          ,
          <source>in: proc. of ICLP</source>
          ,
          <year>2024</year>
          . doi:
          <volume>10</volume>
          .48550/arXiv.2408.09909.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>E. T.</given-names>
            <surname>Mueller</surname>
          </string-name>
          ,
          <source>Commonsense Reasoning: An Event Calculus Based Approach</source>
          , Morgan Kaufmann,
          <year>2014</year>
          . doi:
          <volume>10</volume>
          .1016/B978-0
          <source>-12-801416-5</source>
          .
          <fpage>00002</fpage>
          -
          <lpage>4</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>V.</given-names>
            <surname>Lifschitz</surname>
          </string-name>
          , Answer Set Programming, Springer,
          <year>2019</year>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>030</fpage>
          -24658-7.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Carro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Salazar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Marple</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Gupta, Constraint Answer Set Programming without Grounding</article-title>
          , TPLP
          <volume>18</volume>
          (
          <year>2018</year>
          )
          <fpage>337</fpage>
          -
          <lpage>354</lpage>
          . doi:
          <volume>10</volume>
          .1017/S1471068418000285.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>S. C.</given-names>
            <surname>Varanasi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Salazar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Basu</surname>
          </string-name>
          , G. Gupta,
          <article-title>Modeling and Verification of Real-Time Systems with the Event Calculus and s(CASP)</article-title>
          ,
          <source>in: proc. of PADL'22</source>
          , volume
          <volume>13165</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2022</year>
          , pp.
          <fpage>181</fpage>
          -
          <lpage>190</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>J.</given-names>
            <surname>Hatclif</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Larson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Carpenter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Jones</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , J. Jorgens,
          <article-title>The Open PCA Pump Project: An Exemplar Open Source Medical Device as a Community Resource</article-title>
          ,
          <source>SIGBED Rev</source>
          .
          <volume>16</volume>
          (
          <year>2019</year>
          )
          <fpage>8</fpage>
          -
          <lpage>13</lpage>
          . doi:
          <volume>10</volume>
          .1145/3357495.3357496.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Shanahan</surname>
          </string-name>
          , An Abductive Event Calculus Planner,
          <source>The Journal of Logic Programming</source>
          <volume>44</volume>
          (
          <year>2000</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>H.-F.</given-names>
            <surname>Guo</surname>
          </string-name>
          , G. Gupta,
          <article-title>Simplifying Dynamic Programming via Mode-directed Tabling</article-title>
          ,
          <source>Software: Practice and Experience</source>
          <volume>38</volume>
          (
          <year>2008</year>
          )
          <fpage>75</fpage>
          -
          <lpage>94</lpage>
          . doi:
          <volume>10</volume>
          .1002/spe.824.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Carro, Incremental Evaluation of Lattice-Based Aggregates in Logic Programming Using Modular TCLP</article-title>
          ,
          <source>in: proc. of PADL'19</source>
          , volume
          <volume>11372</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2019</year>
          , pp.
          <fpage>98</fpage>
          -
          <lpage>114</lpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>030</fpage>
          -05998-
          <issue>9</issue>
          _
          <fpage>7</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>B.</given-names>
            <surname>Hall</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Fiedor</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Jeppu</surname>
          </string-name>
          ,
          <article-title>Model Integrated Decomposition and Assisted Specification (MIDAS)</article-title>
          ,
          <source>INCOSE International Symposium</source>
          <volume>30</volume>
          (
          <year>2020</year>
          ). doi:
          <volume>10</volume>
          .1002/j.2334-
          <fpage>5837</fpage>
          .
          <year>2020</year>
          .
          <volume>00757</volume>
          .x.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>