<!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>SMT-like Queries in Maple</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Maplesoft Europe Ltd.</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Cambridge</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>UK sforrest@maplesoft.com</string-name>
        </contrib>
      </contrib-group>
      <fpage>118</fpage>
      <lpage>121</lpage>
      <abstract>
        <p>The recognition that Symbolic Computation tools could bene t from techniques from the world of Satis ability Checking was a primary motive for the founding of the SC2 community. These bene ts would be further demonstrated by the existence of \SMT-like" queries in legacy computer algebra systems; that is, computations which seek to decide satis ability or identify a satisfying witness. The Maple CAS has been under continuous development since the 1980s and its core symbolic routines incorporate many heuristics. We describe ongoing work to compose an inventory of such \SMT-like\ queries extracted from the built-in Maple library, most of which were added long before the inclusion in Maple of explicit software links to SAT/SMT tools. Some of these queries are expressible in the SMT-LIB format using an existing logic, and it is hoped that those that are not could help inform future development of the SMT-LIB standard.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>1.1</p>
    </sec>
    <sec id="sec-2">
      <title>Introduction</title>
      <p>Maple</p>
    </sec>
    <sec id="sec-3">
      <title>The commands is and coulditbe</title>
      <p>
        Consistent with Maple's roots as a computer algebra system, its core symbolic
solvers (such as solve, dsolve, and int) generally aim to provide a general
solution to a posed problem which is both compact and useful. Further
transformation or simpli cation of such solutions using simpli ers based on heuristic
methods [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] is often necessary.
      </p>
      <p>
        Nevertheless the approach of posing queries as questions about satis ability
or requests for a satisfying witness is not unknown in Maple. The most obvious
example is in the commands is and coulditbe. These are the standard
generalpurpose commands in Maple for querying universal and existential properties,
respectively, about a given expression. [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] They are widely used by other symbolic
commands in Maple (e.g. solve, int).
      </p>
      <p>The is command accepts an expression p and asks if p evaluates to the value
true for every possible assignment of values to the symbols in p. The coulditbe
command operates similarly but asks if there is any assignment of values to the
symbols in p which could cause p to evaluate to true.</p>
      <p>Both is and coulditbe return results in ternary logic: true, false, or FAIL.
Both also make use of the \assume facility", which is a system for associating
Boolean properties with symbolic variables. This provides limits on the range of
possible assignments considered by is and coulditbe and is roughly analogous
to a type declaration. For example, the expression is(x^2&gt;=0) evaluates to
false because there are many possible values of x which do not evaluate to
nonnegative real numbers, in particular the imaginary unit p 1. By contrast,
the expression is(x^2&gt;=0) assuming x::real returns true because the range
of possible values of x has been constrained to real numbers.</p>
      <p>An illustrative example is found in the function product. In the evaluation of
the expression product(f(n),n=a..b), the system seeks to compute a symbolic
formula for the product Qbn=a f (n). As one can verify by inspecting the source
code with showstat(product), the implementation of product computes a set
of roots of f (n) and, if neither a nor b is in nite, checks whether there exists a
root r such that r is an integer and a r b. If so, it returns zero as the result
of the product. (Similar logic is applied if either of a or b is in nite.)</p>
      <p>
        As evidence of the ubiquity of such queries, Table 1 summarizes the distinct
invocations of is and coulditbe encountered during a complete run through
Maplesoft's internal test suite for the Maple library performed on 24 April 2018.
(An investigation into an earlier version of this dataset was published in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]). This
includes both instances in which the test case explicitly calls is/coulditbe and
instances in which is/coulditbe are invoked by other library functions such as
product, as shown previously.
      </p>
      <p>Note that in the above table, whenever logic L2 is an extension of logic L1,
the listed results for logic L2 refer only to those queries which are expressible
in L2 but not in L1. For example, the 2888 is queries expressible in QF LIA are
not included among the 1449 queries expressible in QF LIRA, even though all of
them are expressible in the more general logic.</p>
      <p>In total, 24006 distinct is and 5701 distinct coulditbe queries were issued
during the course of the test run. The inputs vary considerably in size and in the
complexity of the underlying theory, and for both is and coulditbe
approximately 11% of queries cannot be decided (i.e. return FAIL rather than true or
false). A complete list of queries encountered may be viewed at
https://doi.org/10.5281/zenodo.943349.</p>
      <p>Description is
Total expressible in SMT-LIB 15572</p>
      <p>Expressible with QF LIA 2888
Expressible with QF NIA 2129
Expressible with QF LRA 1542
Expressible with QF NRA 284
Expressible with AUFLIRA 1449</p>
      <p>Expressible with AUFNIRA 7230</p>
      <p>Total not expressible in SMT-LIB 8434</p>
      <p>Expressible with complex arithmetic 4134</p>
      <p>Linear arithmetic with Gaussian integers (\QF LICA") 258
Nonlinear arithmetic with Gaussian integers (\QF NICA") 259</p>
      <p>Linear arithmetic with complex numbers (\AUFLIRCA") 165
Nonlinear arithmetic with complex numbers (\AURNIRCA") 2728</p>
      <p>All \special" functions 3248
Exponential functions and logarithms 461</p>
      <p>RootOf expressions 232
RootOf with exponential and trigometric functions 231</p>
      <p>Remaining queries with Boolean structure 599</p>
      <p>Total distinct queries 24006
coulditbe
4690
1686
744
505
41
687
1027
1011
565
171
88
32
207
441
76
40
24
5
5701</p>
      <p>Of the total, 15572 of the is queries and 4690 of the coulditbe queries can be
assigned to one of the SMT-LIB2 prede ned logics. Of the queries which cannot
be so assigned, the reasons include the use of special functions unsupported by
SMT-LIB, as well as complex arithmetic.
3</p>
    </sec>
    <sec id="sec-4">
      <title>Future Work</title>
      <p>
        Recent versions of Maple have seen the addition of explicit links to SAT and
SMT solvers: Maple 2018 is distributed with both the SAT solver MapleSAT [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]
and the SMT solver Z3 [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. In future, we aim to examine the e ectiveness of
using these packaged solvers on SMT instances which arise during evaluation of
symbolic expressions.
      </p>
      <p>An important factor in this assessment will be whether this implementation
o ers better performance and meaningful answers (not FAIL) for a larger class
of such queries than existing tools in Maple.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Hui</given-names>
            <surname>Liang</surname>
          </string-name>
          , Vijay Ganesh.
          <article-title>MapleSAT development site</article-title>
          . https://sites.google.com/a/gsd.uwaterloo.ca/maplesat/
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Clark</surname>
            <given-names>Barrett</given-names>
          </string-name>
          , Pascal Fontaine, and
          <string-name>
            <given-names>Cesare</given-names>
            <surname>Tinelli</surname>
          </string-name>
          .
          <article-title>The Satis ability Modulo Theories Library (SMT-LIB)</article-title>
          , http://www.smt-lib.org,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>Jacques</given-names>
            <surname>Carette</surname>
          </string-name>
          .
          <year>2004</year>
          .
          <article-title>Understanding Expression Simpli cation</article-title>
          .
          <source>In Proceedings of the 2004 International Symposium on Symbolic and Algebraic Computation</source>
          , Santander,
          <source>Spain (ISSAC</source>
          <year>2004</year>
          ), ACM, New York, NY, USA,
          <fpage>72</fpage>
          -
          <lpage>79</lpage>
          . doi:
          <volume>10</volume>
          .1145/1005285.1005298.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Stephen</surname>
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Forrest</surname>
          </string-name>
          .
          <year>2017</year>
          .
          <article-title>Integration of SMT-LIB Support into Maple</article-title>
          .
          <source>Second Annual SC2 Workshop</source>
          , ISSAC 2017, Kaiserslautern, Germany. http://www.scsquare.org/CSA/workshop2-papers/EA5-FinalVersion.pdf
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>5. The Assume Facility in Maple, Maple Online Help : The Assume Facility</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>6. Logics in SMT-LIB, http://smtlib.org/logics.shtml.</mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. de Moura,
          <string-name>
            <surname>L. M.</surname>
          </string-name>
          , and Bj rner,
          <string-name>
            <surname>N.</surname>
          </string-name>
          <article-title>Z3: an e cient SMT solver</article-title>
          .
          <source>In TACAS</source>
          (
          <year>2008</year>
          ), vol.
          <volume>4963</volume>
          of Lecture Notes in Computer Science, Springer, pp.
          <fpage>337340</fpage>
          . https://github.com/Z3Prover/z3.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>