<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">Early Validation of High-level System Requirements with Event Calculus and Answer Set Programming</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Ondřej</forename><surname>Vašíček</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">Brno University of Technology</orgName>
								<address>
									<settlement>Brno</settlement>
									<country>Czechia</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Joaquin</forename><surname>Arias</surname></persName>
							<email>joaquin.arias@urjc.es</email>
							<affiliation key="aff1">
								<orgName type="institution">Universidad Rey Juan Carlos</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Jan</forename><surname>Fiedor</surname></persName>
							<email>ifiedor@fit.vut.cz</email>
							<affiliation key="aff0">
								<orgName type="institution">Brno University of Technology</orgName>
								<address>
									<settlement>Brno</settlement>
									<country>Czechia</country>
								</address>
							</affiliation>
							<affiliation key="aff2">
								<orgName type="institution">Honeywell International s.r.o</orgName>
								<address>
									<settlement>Brno</settlement>
									<country>Czechia</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Gopal</forename><surname>Gupta</surname></persName>
							<email>gupta@utdallas.edu</email>
							<affiliation key="aff3">
								<orgName type="institution">The University of Texas at Dallas</orgName>
								<address>
									<region>Texas</region>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Brendan</forename><surname>Hall</surname></persName>
							<affiliation key="aff4">
								<orgName type="laboratory">Ardent Innovation Labs</orgName>
								<address>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Křena</forename><surname>Bohuslav</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">Brno University of Technology</orgName>
								<address>
									<settlement>Brno</settlement>
									<country>Czechia</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Brian</forename><surname>Larson</surname></persName>
							<affiliation key="aff5">
								<orgName type="institution">Multitude Corporation</orgName>
								<address>
									<settlement>St Paul</settlement>
									<region>Minnesota</region>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Sarat</forename><surname>Ch</surname></persName>
						</author>
						<author>
							<persName><surname>Varanasi</surname></persName>
							<affiliation key="aff6">
								<orgName type="institution">GE Aerospace Research</orgName>
								<address>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Tomáš</forename><surname>Vojnar</surname></persName>
							<email>vojnar@fi.muni.cz</email>
							<affiliation key="aff0">
								<orgName type="institution">Brno University of Technology</orgName>
								<address>
									<settlement>Brno</settlement>
									<country>Czechia</country>
								</address>
							</affiliation>
							<affiliation key="aff7">
								<orgName type="institution">Masaryk University</orgName>
								<address>
									<settlement>Brno</settlement>
									<country>Czechia</country>
								</address>
							</affiliation>
						</author>
						<title level="a" type="main">Early Validation of High-level System Requirements with Event Calculus and Answer Set Programming</title>
					</analytic>
					<monogr>
						<idno type="ISSN">1613-0073</idno>
					</monogr>
					<idno type="MD5">301B1A6CA6EB981C2D32B1CFEDE63729</idno>
					<note type="submission">which is a paper accepted at ICLP&apos;24.</note>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2025-04-23T19:51+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<textClass>
				<keywords>
					<term>Requirements Validation</term>
					<term>Event Calculus</term>
					<term>Answer Set Programming</term>
					<term>s(CASP)</term>
				</keywords>
			</textClass>
			<abstract>
<div xmlns="http://www.tei-c.org/ns/1.0"><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 <ref type="bibr" target="#b1">[2]</ref>, 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.</p><p>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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Modelling the PCA Pump Requirements in EC under s(CASP)</head><p>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 4th Workshop on Goal-directed Execution of Answer Set Programs (GDE'24), October 12, 2024   </p></div>
			</abstract>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><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 difference of total drug delivered at the start and at the end of a bolus (lines 17-20).</p><p>1 fluent(patient_bolus_delivery_enabled). 2 event(patient_bolus_delivery_started). event(patient_bolus_delivery_stopped).</p><p>3 initiates(patient_bolus_delivery_started, patient_bolus_delivery_enabled, T). 4 terminates(patient_bolus_delivery_stopped, patient_bolus_delivery_enabled, T). </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Validating Consistency of Use/Exception Cases and the Requirements</head><p>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 different 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.</p><p>1 happens(start_button_pressed, 60).</p><p>2 happens(patient_bolus_requested, 120).  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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Results of Experimental Evaluation</head><p>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 <ref type="table" target="#tab_1">1</ref> 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 <ref type="table" target="#tab_2">2</ref> 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 <ref type="table" target="#tab_1">1</ref> 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).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Techniques Used to Empower s(CASP) Reasoning</head><p>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 <ref type="bibr" target="#b6">[7]</ref>) 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 <ref type="bibr" target="#b7">[8,</ref><ref type="bibr" target="#b8">9]</ref>) 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 effect 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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Conclusion</head><p>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. Our future work involves improving s(CASP) in order to make it more efficient 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 <ref type="bibr" target="#b9">[10]</ref>.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head></head><label></label><figDesc>(VTBI)), happens(patient_bolus_completed, T2), 7 holdsAt(patient_bolus_drug_delivered(VTBI), T2), 8 happens(basal_delivery_started, T2), 9 holdsAfter(basal_delivery_enabled, T2).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_1"><head>Table 1</head><label>1</label><figDesc>Results of validating consistency of use/exception cases and the requirements</figDesc><table><row><cell></cell><cell>Use Case Name</cell><cell>Variant</cell><cell>Result</cell><cell>Time (s)</cell></row><row><cell>UC2</cell><cell>Patient-Requested Bolus</cell><cell>no variants</cell><cell>OK</cell><cell>3.17</cell></row><row><cell>UC3a</cell><cell cols="2">Clinician-Requested Bolus not suspended</cell><cell>OK</cell><cell>2.84</cell></row><row><cell>UC3b</cell><cell cols="2">Clinician-Requested Bolus suspended and resumed</cell><cell>OK</cell><cell>37.13</cell></row><row><cell>ExC7a-f</cell><cell>Over-Flow Rate Alarm</cell><cell>defined in ExC step 1</cell><cell>FAIL</cell><cell>1.53-4.62</cell></row><row><cell>ExC13a</cell><cell>Maximum Safe Dose</cell><cell>during basal delivery</cell><cell>FAIL</cell><cell>25.62</cell></row><row><cell cols="2">ExC13b-c Maximum Safe Dose</cell><cell>during each bolus</cell><cell>OK</cell><cell>31.61-53.45</cell></row><row><cell>ExC21</cell><cell>Reservoir Empty</cell><cell>no variants</cell><cell>OK</cell><cell>40.99</cell></row></table></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_2"><head>Table 2</head><label>2</label><figDesc>Results of validating the requirements wrt. the possibility of an overdose</figDesc><table><row><cell></cell><cell>Use Case Name</cell><cell>Variant</cell><cell>Model</cell><cell>Result</cell><cell>Time (m)</cell></row><row><cell cols="2">ExC13b Maximum Safe Dose</cell><cell>patient bolus</cell><cell>original</cell><cell>OK</cell><cell>14.11</cell></row><row><cell cols="2">ExC13c Maximum Safe Dose</cell><cell cols="2">clinician bolus original</cell><cell>OK</cell><cell>20.85</cell></row><row><cell cols="2">ExC13a Maximum Safe Dose</cell><cell>during basal</cell><cell cols="2">original overdose fixed OK</cell><cell>15.29 3.34</cell></row><row><cell>UC2</cell><cell cols="2">Patient-Requested Bolus abduction</cell><cell cols="2">original overdose fixed OK</cell><cell>38.01 48.11</cell></row></table></figure>
		</body>
		<back>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<analytic>
		<title level="a" type="main">Early Validation of High-level System Requirements with Event Calculus and Answer Set Programming</title>
		<author>
			<persName><forename type="first">O</forename><surname>Vašícek</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Arias</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Fiedor</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<author>
			<persName><forename type="first">B</forename><surname>Hall</surname></persName>
		</author>
		<author>
			<persName><forename type="first">B</forename><surname>Křena</surname></persName>
		</author>
		<author>
			<persName><forename type="first">B</forename><surname>Larson</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><forename type="middle">C</forename><surname>Varanasi</surname></persName>
		</author>
		<author>
			<persName><forename type="first">T</forename><surname>Vojnar</surname></persName>
		</author>
		<idno type="DOI">10.48550/arXiv.2408.09909</idno>
	</analytic>
	<monogr>
		<title level="m">proc. of ICLP</title>
				<meeting>of ICLP</meeting>
		<imprint>
			<date type="published" when="2024">2024</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b1">
	<monogr>
		<title level="m" type="main">Commonsense Reasoning: An Event Calculus Based Approach</title>
		<author>
			<persName><forename type="first">E</forename><forename type="middle">T</forename><surname>Mueller</surname></persName>
		</author>
		<idno type="DOI">10.1016/B978-0-12-801416-5.00002-4</idno>
		<imprint>
			<date type="published" when="2014">2014</date>
			<publisher>Morgan Kaufmann</publisher>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b2">
	<monogr>
		<title level="m" type="main">Answer Set Programming</title>
		<author>
			<persName><forename type="first">V</forename><surname>Lifschitz</surname></persName>
		</author>
		<idno type="DOI">10.1007/978-3-030-24658-7</idno>
		<imprint>
			<date type="published" when="2019">2019</date>
			<publisher>Springer</publisher>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b3">
	<analytic>
		<title level="a" type="main">Constraint Answer Set Programming without Grounding</title>
		<author>
			<persName><forename type="first">J</forename><surname>Arias</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Carro</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Salazar</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Marple</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<idno type="DOI">10.1017/S1471068418000285</idno>
	</analytic>
	<monogr>
		<title level="j">TPLP</title>
		<imprint>
			<biblScope unit="volume">18</biblScope>
			<biblScope unit="page" from="337" to="354" />
			<date type="published" when="2018">2018</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b4">
	<analytic>
		<title level="a" type="main">Modeling and Verification of Real-Time Systems with the Event Calculus and s(CASP)</title>
		<author>
			<persName><forename type="first">S</forename><forename type="middle">C</forename><surname>Varanasi</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Arias</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Salazar</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><surname>Li</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Basu</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">proc. of PADL&apos;22</title>
				<meeting>of PADL&apos;22</meeting>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2022">2022</date>
			<biblScope unit="volume">13165</biblScope>
			<biblScope unit="page" from="181" to="190" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b5">
	<analytic>
		<title level="a" type="main">The Open PCA Pump Project: An Exemplar Open Source Medical Device as a Community Resource</title>
		<author>
			<persName><forename type="first">J</forename><surname>Hatcliff</surname></persName>
		</author>
		<author>
			<persName><forename type="first">B</forename><surname>Larson</surname></persName>
		</author>
		<author>
			<persName><forename type="first">T</forename><surname>Carpenter</surname></persName>
		</author>
		<author>
			<persName><forename type="first">P</forename><surname>Jones</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>Zhang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Jorgens</surname></persName>
		</author>
		<idno type="DOI">10.1145/3357495.3357496</idno>
	</analytic>
	<monogr>
		<title level="j">SIGBED Rev</title>
		<imprint>
			<biblScope unit="volume">16</biblScope>
			<biblScope unit="page" from="8" to="13" />
			<date type="published" when="2019">2019</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b6">
	<analytic>
		<title level="a" type="main">An Abductive Event Calculus Planner</title>
		<author>
			<persName><forename type="first">M</forename><surname>Shanahan</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">The Journal of Logic Programming</title>
		<imprint>
			<biblScope unit="volume">44</biblScope>
			<date type="published" when="2000">2000</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b7">
	<analytic>
		<title level="a" type="main">Simplifying Dynamic Programming via Mode-directed Tabling</title>
		<author>
			<persName><forename type="first">H.-F</forename><surname>Guo</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<idno type="DOI">10.1002/spe.824</idno>
	</analytic>
	<monogr>
		<title level="j">Software: Practice and Experience</title>
		<imprint>
			<biblScope unit="volume">38</biblScope>
			<biblScope unit="page" from="75" to="94" />
			<date type="published" when="2008">2008</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b8">
	<analytic>
		<title level="a" type="main">Incremental Evaluation of Lattice-Based Aggregates in Logic Programming Using Modular TCLP</title>
		<author>
			<persName><forename type="first">J</forename><surname>Arias</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Carro</surname></persName>
		</author>
		<idno type="DOI">10.1007/978-3-030-05998-9_7</idno>
	</analytic>
	<monogr>
		<title level="m">proc. of PADL&apos;19</title>
				<meeting>of PADL&apos;19</meeting>
		<imprint>
			<publisher>Springer</publisher>
			<date type="published" when="2019">2019</date>
			<biblScope unit="volume">11372</biblScope>
			<biblScope unit="page" from="98" to="114" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b9">
	<analytic>
		<title level="a" type="main">Model Integrated Decomposition and Assisted Specification (MIDAS)</title>
		<author>
			<persName><forename type="first">B</forename><surname>Hall</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Fiedor</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>Jeppu</surname></persName>
		</author>
		<idno type="DOI">10.1002/j.2334-5837.2020.00757.x</idno>
	</analytic>
	<monogr>
		<title level="j">INCOSE International Symposium</title>
		<imprint>
			<biblScope unit="volume">30</biblScope>
			<date type="published" when="2020">2020</date>
		</imprint>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
