-
Notifications
You must be signed in to change notification settings - Fork 44
/
python_qf_ufbv.py
executable file
·37 lines (31 loc) · 1.08 KB
/
python_qf_ufbv.py
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
#!/usr/bin/env python3
import smt_switch as ss
from smt_switch.primops import Apply, Distinct, Equal, Extract, BVAnd, BVUge
if __name__ == "__main__":
s = ss.create_btor_solver(True)
s.set_logic('QF_UFBV')
s.set_opt('incremental', 'true')
s.set_opt('produce-models', 'true')
s.set_opt('produce-unsat-assumptions', 'true')
bvs = s.make_sort(ss.sortkinds.BV, 32)
funs = s.make_sort(ss.sortkinds.FUNCTION, [bvs, bvs])
x = s.make_symbol('x', bvs)
y = s.make_symbol('y', bvs)
f = s.make_symbol('f', funs)
ext = ss.Op(Extract, 15, 0)
x0 = s.make_term(ext, x)
y0 = s.make_term(ext, y)
fx = s.make_term(Apply, f, x)
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))
print(s.check_sat())
print(s.get_value(x))
s.pop(1)
xy = s.make_term(BVAnd, x, y)
a1 = s.make_term(BVUge, xy, x);
a2 = s.make_term(BVUge, xy, y);
a3 = s.make_term(BVUge, x0, y0);
print(s.check_sat_assuming([a1,a2,a3]))
print(s.get_unsat_assumptions())