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 * This file is part of the cvc5 project.
3 *
4 * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
5 * in the top-level source directory and their institutional affiliations.
6 * All rights reserved. See the file COPYING in the top-level source
7 * directory for licensing information.
8 * ****************************************************************************
9 *
10 * A simple demonstration of the transcendental extension.
11 */
12
13#include <cvc5/cvc5.h>
14
15#include <iostream>
16
17using namespace std;
18using namespace cvc5;
19
20int main()
21{
22 TermManager tm;
23 Solver slv(tm);
24 slv.setLogic("QF_NRAT");
25
26 Sort real = tm.getRealSort();
27
28 // Variables
29 Term x = tm.mkConst(real, "x");
30 Term y = tm.mkConst(real, "y");
31
32 // Helper terms
33 Term two = tm.mkReal(2);
34 Term pi = tm.mkPi();
35 Term twopi = tm.mkTerm(Kind::MULT, {two, pi});
36 Term ysq = tm.mkTerm(Kind::MULT, {y, y});
37 Term sinx = tm.mkTerm(Kind::SINE, {x});
38
39 // Formulas
40 Term x_gt_pi = tm.mkTerm(Kind::GT, {x, pi});
41 Term x_lt_pi = tm.mkTerm(Kind::LT, {x, twopi});
42 Term ysq_lt_sinx = tm.mkTerm(Kind::LT, {ysq, sinx});
43
44 slv.assertFormula(x_gt_pi);
45 slv.assertFormula(x_lt_pi);
46 slv.assertFormula(ysq_lt_sinx);
47
48 cout << "cvc5 should report UNSAT." << endl;
49 cout << "Result from cvc5 is: " << slv.checkSat() << endl;
50
51 return 0;
52}
examples/api/c/transcendentals.c
1/******************************************************************************
2 * This file is part of the cvc5 project.
3 *
4 * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
5 * in the top-level source directory and their institutional affiliations.
6 * All rights reserved. See the file COPYING in the top-level source
7 * directory for licensing information.
8 * ****************************************************************************
9 *
10 * A simple demonstration of the transcendental extension.
11 */
12
13#include <cvc5/c/cvc5.h>
14#include <stdio.h>
15
16int main()
17{
18 Cvc5TermManager* tm = cvc5_term_manager_new();
19 Cvc5* slv = cvc5_new(tm);
20 cvc5_set_logic(slv, "QF_NRAT");
21
22 Cvc5Sort real_sort = cvc5_get_real_sort(tm);
23
24 // Variables
25 Cvc5Term x = cvc5_mk_const(tm, real_sort, "x");
26 Cvc5Term y = cvc5_mk_const(tm, real_sort, "y");
27
28 // Helper terms
29 Cvc5Term two = cvc5_mk_real_int64(tm, 2);
30 Cvc5Term pi = cvc5_mk_pi(tm);
31 Cvc5Term args2[2] = {two, pi};
32 Cvc5Term twopi = cvc5_mk_term(tm, CVC5_KIND_MULT, 2, args2);
33 args2[0] = y;
34 args2[1] = y;
35 Cvc5Term ysq = cvc5_mk_term(tm, CVC5_KIND_MULT, 2, args2);
36 Cvc5Term args1[1] = {x};
37 Cvc5Term sinx = cvc5_mk_term(tm, CVC5_KIND_SINE, 1, args1);
38
39 // Formulas
40 args2[0] = x;
41 args2[1] = pi;
42 Cvc5Term x_gt_pi = cvc5_mk_term(tm, CVC5_KIND_GT, 2, args2);
43 args2[0] = x;
44 args2[1] = twopi;
45 Cvc5Term x_lt_pi = cvc5_mk_term(tm, CVC5_KIND_LT, 2, args2);
46 args2[0] = ysq;
47 args2[1] = sinx;
48 Cvc5Term ysq_lt_sinx = cvc5_mk_term(tm, CVC5_KIND_LT, 2, args2);
49
50 cvc5_assert_formula(slv, x_gt_pi);
51 cvc5_assert_formula(slv, x_lt_pi);
52 cvc5_assert_formula(slv, ysq_lt_sinx);
53
54 printf("cvc5 should report UNSAT.\n");
55 printf("Result from cvc5 is: %s\n",
56 cvc5_result_to_string(cvc5_check_sat(slv)));
57
58 cvc5_delete(slv);
59 cvc5_term_manager_delete(tm);
60 return 0;
61}
examples/api/java/Transcendentals.java
1/******************************************************************************
2 * This file is part of the cvc5 project.
3 *
4 * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
5 * in the top-level source directory and their institutional affiliations.
6 * All rights reserved. See the file COPYING in the top-level source
7 * directory for licensing information.
8 * ****************************************************************************
9 *
10 * A simple demonstration of the transcendental extension.
11 */
12
13import static io.github.cvc5.Kind.*;
14
15import io.github.cvc5.*;
16
17public class Transcendentals
18{
19 public static void main(String args[]) throws CVC5ApiException
20 {
21 TermManager tm = new TermManager();
22 Solver slv = new Solver(tm);
23 {
24 slv.setLogic("QF_NRAT");
25
26 Sort real = tm.getRealSort();
27
28 // Variables
29 Term x = tm.mkConst(real, "x");
30 Term y = tm.mkConst(real, "y");
31
32 // Helper terms
33 Term two = tm.mkReal(2);
34 Term pi = tm.mkPi();
35 Term twopi = tm.mkTerm(MULT, two, pi);
36 Term ysq = tm.mkTerm(MULT, y, y);
37 Term sinx = tm.mkTerm(SINE, x);
38
39 // Formulas
40 Term x_gt_pi = tm.mkTerm(GT, x, pi);
41 Term x_lt_tpi = tm.mkTerm(LT, x, twopi);
42 Term ysq_lt_sinx = tm.mkTerm(LT, ysq, sinx);
43
44 slv.assertFormula(x_gt_pi);
45 slv.assertFormula(x_lt_tpi);
46 slv.assertFormula(ysq_lt_sinx);
47
48 System.out.println("cvc5 should report UNSAT.");
49 System.out.println("Result from cvc5 is: " + slv.checkSat());
50 }
51 Context.deletePointers();
52 }
53}
examples/api/python/transcendentals.py
1#!/usr/bin/env python
2###############################################################################
3# This file is part of the cvc5 project.
4#
5# Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
6# in the top-level source directory and their institutional affiliations.
7# All rights reserved. See the file COPYING in the top-level source
8# directory for licensing information.
9# #############################################################################
10#
11# A simple demonstration of the transcendental extension.
12##
13
14import cvc5
15from cvc5 import Kind
16
17if __name__ == "__main__":
18 tm = cvc5.TermManager()
19 slv = cvc5.Solver(tm)
20 slv.setLogic("QF_NRAT")
21
22 real = tm.getRealSort()
23
24 # Variables
25 x = tm.mkConst(real, "x")
26 y = tm.mkConst(real, "y")
27
28 # Helper terms
29 two = tm.mkReal(2)
30 pi = tm.mkPi()
31 twopi = tm.mkTerm(Kind.MULT, two, pi)
32 ysq = tm.mkTerm(Kind.MULT, y, y)
33 sinx = tm.mkTerm(Kind.SINE, x)
34
35 # Formulas
36 x_gt_pi = tm.mkTerm(Kind.GT, x, pi)
37 x_lt_tpi = tm.mkTerm(Kind.LT, x, twopi)
38 ysq_lt_sinx = tm.mkTerm(Kind.LT, ysq, sinx)
39
40 slv.assertFormula(x_gt_pi)
41 slv.assertFormula(x_lt_tpi)
42 slv.assertFormula(ysq_lt_sinx)
43
44 print("cvc5 should report UNSAT")
45 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)