Update ownership policy for dynamic quantifiers splitting (#3493)
[cvc5.git] / examples / api / extract-new.cpp
1 /********************* */
2 /*! \file extract-new.cpp
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Aina Niemetz, Makai Mann
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 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.\endverbatim
11 **
12 ** \brief A simple demonstration of the solving capabilities of the CVC4
13 ** bit-vector solver.
14 **
15 **/
16
17 #include <iostream>
18
19 #include <cvc4/api/cvc4cpp.h>
20
21 using namespace std;
22 using namespace CVC4::api;
23
24 int main()
25 {
26 Solver slv;
27 slv.setLogic("QF_BV"); // Set the logic
28
29 Sort bitvector32 = slv.mkBitVectorSort(32);
30
31 Term x = slv.mkConst(bitvector32, "a");
32
33 OpTerm ext_31_1 = slv.mkOpTerm(BITVECTOR_EXTRACT_OP, 31, 1);
34 Term x_31_1 = slv.mkTerm(BITVECTOR_EXTRACT, ext_31_1, x);
35
36 OpTerm ext_30_0 = slv.mkOpTerm(BITVECTOR_EXTRACT_OP, 30, 0);
37 Term x_30_0 = slv.mkTerm(BITVECTOR_EXTRACT, ext_30_0, x);
38
39 OpTerm ext_31_31 = slv.mkOpTerm(BITVECTOR_EXTRACT_OP, 31, 31);
40 Term x_31_31 = slv.mkTerm(BITVECTOR_EXTRACT, ext_31_31, x);
41
42 OpTerm ext_0_0 = slv.mkOpTerm(BITVECTOR_EXTRACT_OP, 0, 0);
43 Term x_0_0 = slv.mkTerm(BITVECTOR_EXTRACT, ext_0_0, x);
44
45 Term eq = slv.mkTerm(EQUAL, x_31_1, x_30_0);
46 cout << " Asserting: " << eq << endl;
47 slv.assertFormula(eq);
48
49 Term eq2 = slv.mkTerm(EQUAL, x_31_31, x_0_0);
50 cout << " Check validity assuming: " << eq2 << endl;
51 cout << " Expect valid. " << endl;
52 cout << " CVC4: " << slv.checkValidAssuming(eq2) << endl;
53
54 return 0;
55 }