forked from stanford-centaur/smt-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbtor_qf_ufbv.cpp
54 lines (47 loc) · 1.4 KB
/
btor_qf_ufbv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include "smt-switch/boolector_factory.h"
#include "smt-switch/smt.h"
using namespace smt;
using namespace std;
int main()
{
// Boolector aliases booleans and bitvectors of size one
// and also performs on-the-fly rewriting
// if you'd like to maintain the term structure, you can
// enable logging by passing true
SmtSolver s = BoolectorSolverFactory::create(false);
s->set_logic("QF_UFBV");
s->set_opt("incremental", "true");
s->set_opt("produce-models", "true");
s->set_opt("produce-unsat-assumptions",
"true");
Sort bvs = s->make_sort(BV, 32);
Sort funs =
s->make_sort(FUNCTION, {bvs, bvs});
Term x = s->make_symbol("x", bvs);
Term y = s->make_symbol("y", bvs);
Term f = s->make_symbol("f", funs);
Op ext = Op(Extract, 15, 0);
Term x0 = s->make_term(ext, x);
Term y0 = s->make_term(ext, y);
Term fx = s->make_term(Apply, f, x);
Term fy = s->make_term(Apply, f, y);
s->assert_formula(
s->make_term(Distinct, fx, fy));
s->push(1);
s->assert_formula(
s->make_term(Equal, x0, y0));
cout << s->check_sat() << endl;
cout << s->get_value(x) << endl;
s->pop(1);
Term xy = s->make_term(BVAnd, x, y);
Term a1 = s->make_term(BVUge, x0, y0);
Term a2 = s->make_term(BVUge, xy, x);
Term a3 = s->make_term(BVUge, xy, y);
cout <<
s->check_sat_assuming({a1, a2, a3})
<< endl;
UnorderedTermSet ua;
s->get_unsat_assumptions(ua);
for (Term t : ua) { cout << t << endl; }
}