<!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>August</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Unmanned Aerial Vehicle compliance checking using Goal-Directed Answer Set Programming</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Sarat Chandra Varanasi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Baoluo Meng</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Christopher Alexander</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Szabolcs Borgyos</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Brendan Hall</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>General Electric Research</institution>
          ,
          <addr-line>Niskayuna, NY</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>The University of Texas at Dallas</institution>
          ,
          <addr-line>Richardson, TX</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2022</year>
      </pub-date>
      <volume>1</volume>
      <issue>2022</issue>
      <fpage>0000</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>We present a novel application of Goal-Directed Answer Set Programming that digitizes the model aircraft operator's compliance verification against the Academy of Model Aircrafts (AMA) safety code. The AMA safety code regulates how AMA flyers operate Unmanned Aerial Vehicles (UAVs) for limited recreational purposes. Flying drones and their operators are subject to various rules before and after the operation of the aircraft to ensure safe flights. In this paper, we leverage Goal-Directed Answer Set Programming to encode the AMA safety code and automate compliance checks. To check compliance, we use the s(CASP), a goal-directed ASP engine. By using s(CASP) the operators can easily check for violations and obtain a justification tree explaining the cause of the violations in human-readable natural language. We develop a front end questionnaire interface that accepts various conditions and uses s(CASP) as backend engine to evaluate whether the conditions adhere to the regulations. We also leverage s(CASP) implemented in SWI-Prolog, where SWI-Prolog exposes the reasoning capabilities of s(CASP) as a REST service. To the best of our knowledge, this is the first application of ASP in the AMA and Avionics Compliance and Certification space.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Goal-Directed Answer Set Programming</kwd>
        <kwd>Automated Flight Readiness Approval</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>certification. The s(CASP) system is capable of printing a justification tree for any identified
violations which is presented in plain English. This helps the user understand the cause of the
violation without having to understand ASP rules. To the best of our knowledge, this is the first
application of ASP in aviation rules compliance checking.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Background</title>
      <sec id="sec-2-1">
        <title>2.1. Goal-Directed Answer Set Programming</title>
        <p>
          Goal-directed approaches to Answer Set Solving do not perform grounding to find stable
models. One such approach is Goal-Directed ASP[
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. Goal-directed ASP assumes that a query
?− (1, 2, ..., ) is provided to the ASP solver. The goal-directed search finds the predicates
that support the submitted query and finds bindings for 1, 2, .., . At an interactive level,
this looks similar to Logic Programming, however, the underlying search uses the co-SLDNF
resolution algorithm to find stable models[
          <xref ref-type="bibr" rid="ref2 ref3">2, 3</xref>
          ]. A salient feature of goal-directed ASP is that,
the co-SLDNF algorithm only searches for rules that are relevant to finding the support for the
given query. The state-of-the-art implementation of goal-directed ASP is s(CASP). When given
a query, s(CASP) returns a partial stable model of the query for the given ASP program. Along
with the partial stable model, s(CASP) also prints a justification tree to the user conveying
how the proof for the given query was performed. The justifications of ASP queries have
been used widely in several application areas such as Explainable AI, Legal Reasoning and
Natural Language Understanding [
          <xref ref-type="bibr" rid="ref4 ref5 ref6 ref7">4, 5, 6, 7</xref>
          ]. Further, the justifications can also be rendered in
human understandable natural language [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. For example, consider the below ASP program
with the predicates mapped to their English equivalents. An example justification tree (s(CASP)
justification tree) and partial stable model (s(CASP) model) for the program below is shown in
Figure 1.
flies(X) :- bird(X), not penguin(X).
bird(tweety).
#pred flies(X)::'@(X) flies'.
#pred bird(X)::'@(X) is a bird'.
#pred penguin(X): '@(X) is a penguin'.
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Modern SWISH Interface and REST API for s(CASP)</title>
        <p>
          The s(CASP) system is available on the modern SWISH Interface for SWI-Prolog [
          <xref ref-type="bibr" rid="ref10 ref9">9, 10</xref>
          ]. SWISH
allows a user to create interactive Logic Program Notebooks for s(CASP) answer set programs.
The s(CASP) module can be enabled by using the :- use_module(library(scasp)). Along
with the online interface, SWISH also provides REST APIs for external clients to run ASP
programs. The AMA Safety Code application in this paper uses the SWISH API for s(CASP).
        </p>
        <p>We next explain the Flight Compliance and Certification process used to ensure compliance
by recreational UAV operators with AMA rules, followed by their translation in ASP. We also
show snippets of the user interface involved in the certification process.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. The AMA Safety Code for Aircraft Operators</title>
      <p>
        The Academy of Model Aeronautics (AMA) defines a set of rules and regulations to be followed
by the operator(s) of model aircraft during their flight. We have adopted the rules defined in the
AMA Safety code[
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. The AMA Safety Code has conditions pertaining to general operation of
aircrafts along with regulations pertaining to radio control and free flight. The rules are written
in plain English. Each rule either prescribes a certain set of conditions desirable for flight safety
or proscribes a set of conditions that violate safety requirements. We encode each rule as a
violation rule. A few AMA safety code rules are shown in Figure 2.
      </p>
      <p>For example, the AMA rule 3 states that I will not operate my model aircraft while
under the influence of alcohol or while using any drug which could adversely afect my
ability to safely control the model. This potential violation is capture by a rule in ASP as:
violation_3 :- under_alcohol_or_drug_influence.</p>
      <p>Many of the rules are written in terms of defaults and exceptions. In such case, the rules will
be of the form, some_violation :- default, not exception.</p>
      <p>
        For instance, first clause of rule 7 (not shown in Figure 2, but found here[
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]) states that:
I will only fly models weighing more than 55 pounds, including fuel, if certified through AMA’s
Large Model Airplane Program. The sub-clause before if represents a default and the sub-clause
after if represents the exception to the default. This violation is encoded as:
violation_7 :- aircraft_above_55, not ama_large_program_certified.
      </p>
      <p>The AMA flight compliance rules are therefore translated into ASP.</p>
      <p>
        The architecture of the web application and its backend interface to SWISH is shown in
Figure 5. The app’s source itself is accessible from github [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
      <p>
        On the front-end of the compliance application, the questionnaire elicits answers from the
user by asking the following sequence of questions. Each of the questions maps to the literals in
the body of a potential violation rule. Shown in figure 3. The proof tree returned by s(CASP) is
rendered graphically on the front-end 4. From the viewpoint of the end-user, the ASP translation
and proof tree are completely transparent. Showing the proof graphically helps the operator
easily understand the violations and also to figure out how to achieve compliance. The app’s
source itself is accessible from github [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          , et al. (Eds.),
          <source>Proceedings of the International Conference on Logic Programming</source>
          <year>2021</year>
          <article-title>Workshops co-located with the 37th International Conference on Logic Programming (ICLP</article-title>
          <year>2021</year>
          ), Porto, Portugal (virtual),
          <source>September 20th-21st</source>
          ,
          <year>2021</year>
          , volume
          <volume>2970</volume>
          <source>of CEUR Workshop Proceedings, CEUR-WS.org</source>
          ,
          <year>2021</year>
          . URL: http://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>2970</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>R. K.</given-names>
            <surname>Min</surname>
          </string-name>
          ,
          <article-title>Predicate answer set programming with coinduction</article-title>
          , The University of Texas at Dallas,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <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>
          , G. Gupta,
          <article-title>Constraint answer set programming without grounding</article-title>
          ,
          <source>Theory and Practice of Logic Programming</source>
          <volume>18</volume>
          (
          <year>2018</year>
          )
          <fpage>337</fpage>
          -
          <lpage>354</lpage>
          .
        </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>Moreno-Rebato</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. A.</given-names>
            <surname>Rodriguez-García</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ossowski</surname>
          </string-name>
          ,
          <article-title>Modeling administrative discretion using goal-directed answer set programming</article-title>
          ,
          <source>in: Conference of the Spanish Association for Artificial Intelligence</source>
          , Springer,
          <year>2021</year>
          , pp.
          <fpage>258</fpage>
          -
          <lpage>267</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>K.</given-names>
            <surname>Basu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Shakerin</surname>
          </string-name>
          , G. Gupta, Aqua:
          <article-title>Asp-based visual question answering</article-title>
          ,
          <source>in: International Symposium on Practical Aspects of Declarative Languages</source>
          , Springer,
          <year>2020</year>
          , pp.
          <fpage>57</fpage>
          -
          <lpage>72</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>K.</given-names>
            <surname>Basu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. C.</given-names>
            <surname>Varanasi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Shakerin</surname>
          </string-name>
          , G. Gupta, Square:
          <article-title>Semantics-based question answering and reasoning engine</article-title>
          , arXiv preprint arXiv:
          <year>2009</year>
          .
          <volume>10239</volume>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>K.</given-names>
            <surname>Basu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Varanasi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Shakerin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          , G. Gupta,
          <article-title>Knowledge-driven natural language understanding of english text and its applications</article-title>
          ,
          <source>in: Proceedings of the AAAI Conference on Artificial Intelligence</source>
          , volume
          <volume>35</volume>
          ,
          <year>2021</year>
          , pp.
          <fpage>12554</fpage>
          -
          <lpage>12563</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          , et al.,
          <article-title>Justifications for goal-directed constraint answer set programming</article-title>
          ,
          <source>in: Proceedings 36th International Conference on Logic Programming (Technical Communications)</source>
          ,
          <source>ICLP Technical Communications</source>
          <year>2020</year>
          ,
          <article-title>(Technical Communications) UNICAL, Rende (CS), Italy</article-title>
          ,
          <fpage>18</fpage>
          -24th
          <source>September</source>
          <year>2020</year>
          , volume
          <volume>325</volume>
          <source>of EPTCS</source>
          ,
          <year>2020</year>
          , pp.
          <fpage>59</fpage>
          -
          <lpage>72</lpage>
          . URL: https://doi.org/10.4204/EPTCS.325.12. doi:
          <volume>10</volume>
          .4204/EPTCS.325.12.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Wielemaker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Riguzzi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. A.</given-names>
            <surname>Kowalski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Lager</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Sadri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Calejo</surname>
          </string-name>
          ,
          <article-title>Using swish to realize interactive web-based tutorials for logic-based languages</article-title>
          ,
          <source>Theory and Practice of Logic Programming</source>
          <volume>19</volume>
          (
          <year>2019</year>
          )
          <fpage>229</fpage>
          -
          <lpage>261</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>J.</given-names>
            <surname>Wielemaker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Gupta, s(casp) for swi-prolog</article-title>
          , in: J.
          <string-name>
            <surname>Arias</surname>
          </string-name>
          , et al. (Eds.),
          <source>Proceedings of the International Conference on Logic Programming</source>
          <year>2021</year>
          <article-title>Workshops co-located with the 37th International Conference on Logic Programming (ICLP</article-title>
          <year>2021</year>
          ), Porto, Portugal (virtual),
          <source>September 20th-21st</source>
          ,
          <year>2021</year>
          , volume
          <volume>2970</volume>
          <source>of CEUR Workshop Proceedings</source>
          , CEURWS.org,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>AMA</surname>
          </string-name>
          , Ama safety code, https://www.modelaircraft.org/sites/default/files/documents/100. pdf,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>S. C.</given-names>
            <surname>Varanasi</surname>
          </string-name>
          , Flight readiness asp, https://github.com
          <article-title>/ge-high-assurance/ lfight-readiness-</article-title>
          <string-name>
            <surname>asp</surname>
          </string-name>
          ,
          <year>2022</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>