Theory Reference: Transcendentals ¶
cvc5 supports transcendental functions that naturally extend the nonlinear real arithmetic theories
NRA
and
NIRA
.
The theory consists of the constant
\(\pi\)
and function symbols for most common transcendental functions like, e.g.,
sin
,
cos
and
tan
.
Logic ¶
To enable cvc5’s decision procedure for transcendentals, append
T
to the arithmetic logic that is being used:
(set-logic QF_NRAT)
Alternatively, use the
ALL
logic:
(set-logic ALL)
Syntax ¶
cvc5 internally defines a constant
real.pi
of sort
Real
and the following unary function symbols from
Real
to
Real
:
-
the square root function
sqrt
-
the exponential function
exp
-
the sine function
sin
-
the cosine function
cos
-
the tangent function
tan
-
the cosecant function
csc
-
the secant function
sec
-
the cotangent function
cot
-
the arcsine function
arcsin
-
the arccosine function
arccos
-
the arctangent function
arctan
-
the arccosecant function
arccsc
-
the arcsecant function
arcsec
-
the arccotangent function
arccot
Semantics ¶
Both the constant
real.pi
and all function symbols are defined on real numbers and are thus not subject to limited precision. That being said, cvc5 internally uses inexact techniques based on incremental linearization.
While
real.pi
is specified using a rational enclosing interval that is automatically refined on demand, the function symbols are approximated using tangent planes and secant lines using the techniques described in
[
CGI+18
]
.
Examples ¶
examples/api/cpp/transcendentals.cpp
1 /******************************************************************************
2 * Top contributors (to current version):
3 * Gereon Kremer, Mathias Preiner
4 *
5 * This file is part of the cvc5 project.
6 *
7 * Copyright (c) 2009-2022 by the authors listed in the file AUTHORS
8 * in the top-level source directory and their institutional affiliations.
9 * All rights reserved. See the file COPYING in the top-level source
10 * directory for licensing information.
11 * ****************************************************************************
12 *
13 * A simple demonstration of the transcendental extension.
14 */
15
16 #include <iostream>
17
18 #include <cvc5/cvc5.h>
19
20 using namespace std;
21 using namespace cvc5;
22
23 int main()
24 {
25 Solver slv;
26 slv.setLogic("QF_NRAT");
27
28 Sort real = slv.getRealSort();
29
30 // Variables
31 Term x = slv.mkConst(real, "x");
32 Term y = slv.mkConst(real, "y");
33
34 // Helper terms
35 Term two = slv.mkReal(2);
36 Term pi = slv.mkPi();
37 Term twopi = slv.mkTerm(MULT, {two, pi});
38 Term ysq = slv.mkTerm(MULT, {y, y});
39 Term sinx = slv.mkTerm(SINE, {x});
40
41 // Formulas
42 Term x_gt_pi = slv.mkTerm(GT, {x, pi});
43 Term x_lt_tpi = slv.mkTerm(LT, {x, twopi});
44 Term ysq_lt_sinx = slv.mkTerm(LT, {ysq, sinx});
45
46 slv.assertFormula(x_gt_pi);
47 slv.assertFormula(x_lt_tpi);
48 slv.assertFormula(ysq_lt_sinx);
49
50 cout << "cvc5 should report UNSAT." << endl;
51 cout << "Result from cvc5 is: " << slv.checkSat() << endl;
52
53 return 0;
54 }
examples/api/java/Transcendentals.java
1 /******************************************************************************
2 * Top contributors (to current version):
3 * Mudathir Mohamed, Andres Noetzli
4 *
5 * This file is part of the cvc5 project.
6 *
7 * Copyright (c) 2009-2022 by the authors listed in the file AUTHORS
8 * in the top-level source directory and their institutional affiliations.
9 * All rights reserved. See the file COPYING in the top-level source
10 * directory for licensing information.
11 * ****************************************************************************
12 *
13 * A simple demonstration of the transcendental extension.
14 */
15
16 import static io.github.cvc5.Kind.*;
17
18 import io.github.cvc5.*;
19
20 public class Transcendentals
21 {
22 public static void main(String args[]) throws CVC5ApiException
23 {
24 try (Solver slv = new Solver())
25 {
26 slv.setLogic("QF_NRAT");
27
28 Sort real = slv.getRealSort();
29
30 // Variables
31 Term x = slv.mkConst(real, "x");
32 Term y = slv.mkConst(real, "y");
33
34 // Helper terms
35 Term two = slv.mkReal(2);
36 Term pi = slv.mkPi();
37 Term twopi = slv.mkTerm(MULT, two, pi);
38 Term ysq = slv.mkTerm(MULT, y, y);
39 Term sinx = slv.mkTerm(SINE, x);
40
41 // Formulas
42 Term x_gt_pi = slv.mkTerm(GT, x, pi);
43 Term x_lt_tpi = slv.mkTerm(LT, x, twopi);
44 Term ysq_lt_sinx = slv.mkTerm(LT, ysq, sinx);
45
46 slv.assertFormula(x_gt_pi);
47 slv.assertFormula(x_lt_tpi);
48 slv.assertFormula(ysq_lt_sinx);
49
50 System.out.println("cvc5 should report UNSAT.");
51 System.out.println("Result from cvc5 is: " + slv.checkSat());
52 }
53 }
54 }
examples/api/python/transcendentals.py
1 #!/usr/bin/env python
2 ###############################################################################
3 # Top contributors (to current version):
4 # Gereon Kremer, Aina Niemetz, Alex Ozdemir
5 #
6 # This file is part of the cvc5 project.
7 #
8 # Copyright (c) 2009-2022 by the authors listed in the file AUTHORS
9 # in the top-level source directory and their institutional affiliations.
10 # All rights reserved. See the file COPYING in the top-level source
11 # directory for licensing information.
12 # #############################################################################
13 #
14 # A simple demonstration of the transcendental extension.
15 ##
16
17 import cvc5
18 from cvc5 import Kind
19
20 if __name__ == "__main__":
21 slv = cvc5.Solver()
22 slv.setLogic("QF_NRAT")
23
24 real = slv.getRealSort()
25
26 # Variables
27 x = slv.mkConst(real, "x")
28 y = slv.mkConst(real, "y")
29
30 # Helper terms
31 two = slv.mkReal(2)
32 pi = slv.mkPi()
33 twopi = slv.mkTerm(Kind.MULT, two, pi)
34 ysq = slv.mkTerm(Kind.MULT, y, y)
35 sinx = slv.mkTerm(Kind.SINE, x)
36
37 # Formulas
38 x_gt_pi = slv.mkTerm(Kind.GT, x, pi)
39 x_lt_tpi = slv.mkTerm(Kind.LT, x, twopi)
40 ysq_lt_sinx = slv.mkTerm(Kind.LT, ysq, sinx)
41
42 slv.assertFormula(x_gt_pi)
43 slv.assertFormula(x_lt_tpi)
44 slv.assertFormula(ysq_lt_sinx)
45
46 print("cvc5 should report UNSAT")
47 print("Result from cvc5 is:", slv.checkSat())
examples/api/smtlib/transcendentals.smt2
1 (set-logic QF_NRAT)
2 (declare-fun x () Real)
3 (declare-fun y () Real)
4
5 (assert (> x real.pi))
6 (assert (< x (* 2 real.pi)))
7 (assert (< (* y y) (sin x)))
8 (check-sat)