<!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>October</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Integrating SMT solvers into Goal-Directed Answer Set Programming, Challenges and Directions</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>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Baoluo Meng</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>GE Aerospace Research</institution>
          ,
          <addr-line>1 Research Circle, Niskayuna, NY</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>12</volume>
      <issue>2024</issue>
      <fpage>0000</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Goal-Directed Answer Programming is a powerful paradigm to evaluate Answer Set Programs with several applications in Natural Language Understanding based question-answering, legal reasoning, development of LLM-assisted chatbots and reasoning about cyber-physical systems represented in the event-calculus formalism. Particularly, goal-directed ASP has been extended to support constraintsolving over reals CLP(R) to facilitate the capture of event calculus axioms. This enhancement involved integrating the CLP(R) constraint-solving system with the operational semantics of the goal-directed s(CASP) system. We position that more expressive and eficient theory-solving ofered by modern SMT solvers can be integrated into s(CASP) to naturally evolve and increase the modeling capabilities of s(CASP). We show some potential applications of using a few SMT-based theories and also discuss some challenges involved in integrating SMT-solvers with s(CASP).</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Goal-Directed Answer Set Programming</kwd>
        <kwd>SMT solving</kwd>
        <kwd>Theory solving</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        resulted in the s(CASP) system [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. s(CASP) ability to support CLP(R) has enabled the capture
of axioms of Event calculus [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and unlocked several applications in validation of systems
requirements in diferent domains from Avionics [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] to Healthcare applications [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Research in
formal methods using SAT-solving evolved into support for multiple expressive theories that
has resulted in numerous applications in fields of Program Verification [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], Security Analyses
[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], SMT-based model checking to mention a few [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. Several industrial scale SMT solvers
such as Z3 and CVC5 are continually extended to support more expressive theories with novel
applications. For example, SMT solving over a restricted theory of strings has been applied
to formally verify access policies in Amazon Web Services [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. We position that integrating
expressive theory solvers powered by advances in industrial scale SMT solver engines with
s(CASP) will vastly improve in the accessibility of Formal Methods along and also drive s(CASP)
towards the direction of being adopted as an SMT-enabled theorem-prover. The rest of the paper
is organized as follows: We provide a background of SMT theories integrated into Declarative
ASP followed by how CLP(R) was integrated into the operational semantics of goal-directed ASP.
We then motivate the integration of SMT-solvers into goal-directed ASP with an example. Then,
we present the challenges of integrating solvers into s(CASP) with potential future directions.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Background</title>
      <sec id="sec-2-1">
        <title>2.1. Declarative ASP with constraint-solving</title>
        <p>
          Integrating constraint-solving into declarative Answer Set Programming has been continually
evolving from its introduction [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ] to direct integration of SMT-solving capabilities in the
Clingcon system [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]. The work of Lierler broadly categorizes declarative constraint-based
ASP into two categories: Integrational where ASP solving is combined algorithmically with
theory-solving and Translational where ASP programs are translated into SMT-LIB format [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ].
The reader is referred to their work for a comprehensive survey of declarative constraint answer
set programming (CASP) systems [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ]. Our focus for this paper is solely on an integrational
approach for SMT into s(CASP). For the integrational approaches the main challenge involves
correctly and eficiently grounding the input ASP programming while also dispatching
theoryatoms to the respective constraint solver such as an SMT-solver. Despite these challenges, such
approaches have resulted in numerous applications and various implementations of CASP [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ].
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Integration of CLP(R) into s(ASP)</title>
        <p>The operational semantics of first predicate ASP system s(ASP) introduced unique techniques
to be consistent with ASP semantics:
1. Disunification operator between terms which maintains prohibtied list of ground terms
for each variable while performing top-down execution of a query
2. Dual rules to provide operational semantics for negation-as-failure (NAF) predicates
present in the original ASP program
3. Forall algorithm to evaluate the success of a goal for all possible values of its variables,
resulting from dual rules generated for original ASP program rules with existentially
quantified variables in the body.</p>
        <p>
          More details about s(ASP) can be found elsewhere [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. In order to modularly introduce CLP(R)
into s(ASP), the disunification operator was extended to also represent CLP(R) constraints for
relevant terms and the forall was extended to check for a CLP(R) constrained variable for goal
validity for its complete range. More details about the resulting s(CASP) system can be found
elsewhere [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ].
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Example of potential SMT theory integrated into s(CASP)</title>
      <p>
        s(CASP) currently supports linear arithmetic over reals. While this has proved to be useful,
there are aerospace applications such as that require solving non-linear constraints such as
aircraft collision detection [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]. Consider an object A’s trajectory confined to the 2-D unit circle
whereas another object B’s trajectory confined to the 2-D half-plane where its x-coordinate is
greater than 1. Clearly, we know that the object A’s space does not intersect with that of object
B, but we cannot simplify it currently in s(CASP).
      </p>
      <p>intersect :- areaA(X, Y), areaB(X). % intersect cannot be safistife
areaA(X,Y) :- X*X + Y*Y #&lt; 1. % non-linear arithmetic constraint
areaB(X) :- X #&gt; 1.</p>
      <p>There are two aspects of integrating SMT-solver into s(CASP) beyond the obvious aspect of
increased expressivity of theories.</p>
      <p>1. Removing SMT-LIB encoding encoding overhead: Variables and terms naturally express
theory constraints in Logic Programming and appropriately implementing the SMT-LIB
encoding, solver dispatch and integration of c-forall for the respective theory readily adds
theory-solving into s(CASP).
2. Such an integration drives the use of s(CASP) as a front-end to decision procedures.</p>
      <p>Although, removing SMT-LIB encoding overhead implies having developed a front-end,
modular integration of theory-solving into s(CASP) goes a step beyond dispatching SMT
queries. Proof obligations pertaining to an application domain can be structured into
SMT-LIB solver dispatches to establish formal proofs of correctness or produce
counterexamples for system functions.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Challenges and Directions</title>
      <p>Although the above example motivated the need for more decision procedures powered by SMT
technology to be integrated into s(CASP), there are a few challenges:
1. Before a query is issued to s(CASP), static analysis can help infer the right SMT theory
that needs to be used before dispatching SMT-encoding and solving. This challenge can
be circumvented by modularizing rules according to the SMT theory solving they would
require.
2. Non-termination issues: s(CASP) sufers from non-termination when fresh variables are
added to its co-inductive hypothesis set that builds an infinite (descending) ascending
chain of variable inequalities. We term this the “Zeno" problem. This problem is still open
for s(CASP).</p>
      <p>In addition to the challenges, other directions for s(CASP)-SMT integration would be to develop
dynamic consistency checking methods [16] while accounting for SMT-LIB theories. Another
direction is to integrate proof visualizers developed for SMT solvers such as CVC5 [17] for SMT
unsatisfiable queries with the justification tree that is already produced by s(CASP).
[16] J. Arias, M. Carro, G. Gupta, Towards dynamic consistency checking in goal-directed
predicate answer set programming, in: International Symposium on Practical Aspects of
Declarative Languages, Springer, 2022, pp. 117–134.
[17] H. Barbosa, C. Barrett, M. Brain, G. Kremer, H. Lachnitt, M. Mann, A. Mohamed, M.
Mohamed, A. Niemetz, A. Nötzli, et al., cvc5: A versatile and industrial-strength smt solver,
in: International Conference on Tools and Algorithms for the Construction and Analysis
of Systems, Springer, 2022, pp. 415–442.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>K.</given-names>
            <surname>Marple</surname>
          </string-name>
          , E. Salazar, G. Gupta,
          <article-title>Computing stable models of normal logic programs without grounding</article-title>
          ,
          <source>preprint arXiv:1709.00501</source>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>M.</given-names>
            <surname>Gebser</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Kaminski</surname>
          </string-name>
          , B. Kaufmann, P. Lühne, s. Obermeier,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ostrowski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Romero</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Schaub</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Schellhorn</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Wanko</surname>
          </string-name>
          ,
          <article-title>The potsdam answer set solving collection 5.0</article-title>
          ,
          <string-name>
            <surname>KIKünstliche</surname>
            <given-names>Intelligenz</given-names>
          </string-name>
          32 (
          <year>2018</year>
          )
          <fpage>181</fpage>
          -
          <lpage>182</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>K.</given-names>
            <surname>Marple</surname>
          </string-name>
          , G. Gupta,
          <article-title>Galliwasp: A goal-directed answer set solver</article-title>
          ,
          <source>in: International Symposium on Logic-Based Program Synthesis and Transformation</source>
          , Springer,
          <year>2012</year>
          , pp.
          <fpage>122</fpage>
          -
          <lpage>136</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>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="ref5">
        <mixed-citation>
          [5]
          <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>Z.</given-names>
            <surname>Chen</surname>
          </string-name>
          , G. Gupta,
          <article-title>Modeling and reasoning in event calculus using goaldirected constraint answer set programming</article-title>
          ,
          <source>Theory and Practice of Logic Programming</source>
          <volume>22</volume>
          (
          <year>2022</year>
          )
          <fpage>51</fpage>
          -
          <lpage>80</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>B.</given-names>
            <surname>Hall</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. C.</given-names>
            <surname>Varanasi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Fiedor</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Basu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Bhatt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Driscoll</surname>
          </string-name>
          , E. Salazar, G. Gupta,
          <article-title>Knowledge-assisted reasoning of model-augmented system requirements with event calculus and goal-directed answer set programming</article-title>
          ,
          <source>arXiv preprint arXiv:2109.04634</source>
          (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>O.</given-names>
            <surname>Vašíček</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>arXiv preprint arXiv:2408.09909</source>
          (
          <year>2024</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>N.</given-names>
            <surname>Bjørner</surname>
          </string-name>
          , L. de Moura,
          <article-title>Applications of smt solvers to program verification, Notes for the Summer School on Formal Techniques (</article-title>
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>P. B.</given-names>
            <surname>Jackson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. J.</given-names>
            <surname>Ellis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Sharp</surname>
          </string-name>
          ,
          <article-title>Using smt solvers to verify high-integrity programs</article-title>
          ,
          <source>in: Proceedings of the second workshop on Automated formal methods</source>
          ,
          <year>2007</year>
          , pp.
          <fpage>60</fpage>
          -
          <lpage>68</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>C.</given-names>
            <surname>Tinelli</surname>
          </string-name>
          ,
          <article-title>Smt-based model checking</article-title>
          .,
          <source>in: NASA Formal Methods</source>
          ,
          <year>2012</year>
          , p.
          <fpage>1</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>J.</given-names>
            <surname>Backes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Bolignano</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Cook</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Dodge</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gacek</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Luckow</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Rungta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Tkachuk</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Varming</surname>
          </string-name>
          ,
          <article-title>Semantic-based automated reasoning for aws access policies using smt, in: 2018 Formal Methods in Computer Aided Design (FMCAD)</article-title>
          , IEEE,
          <year>2018</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>9</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>V. S.</given-names>
            <surname>Mellarkod</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gelfond</surname>
          </string-name>
          ,
          <string-name>
            <surname>Y. Zhang,</surname>
          </string-name>
          <article-title>Integrating answer set programming and constraint logic programming</article-title>
          ,
          <source>Annals of Mathematics and Artificial Intelligence</source>
          <volume>53</volume>
          (
          <year>2008</year>
          )
          <fpage>251</fpage>
          -
          <lpage>287</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>M.</given-names>
            <surname>Banbara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Kaufmann</surname>
          </string-name>
          , M. Ostrowski, T. Schaub,
          <article-title>Clingcon: The next generation</article-title>
          ,
          <source>Theory and Practice of Logic Programming</source>
          <volume>17</volume>
          (
          <year>2017</year>
          )
          <fpage>408</fpage>
          -
          <lpage>461</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Lierler</surname>
          </string-name>
          ,
          <article-title>Constraint answer set programming: Integrational and translational (or smtbased) approaches</article-title>
          ,
          <source>Theory and Practice of Logic Programming</source>
          <volume>23</volume>
          (
          <year>2023</year>
          )
          <fpage>195</fpage>
          -
          <lpage>225</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>S.</given-names>
            <surname>Paul</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Meng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Alexander</surname>
          </string-name>
          ,
          <article-title>Smt-based aircraft conflict detection and resolution</article-title>
          ,
          <source>in: NASA Formal Methods Symposium</source>
          , Springer,
          <year>2024</year>
          , pp.
          <fpage>186</fpage>
          -
          <lpage>203</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>