-
Notifications
You must be signed in to change notification settings - Fork 3
/
Utils.cpp
48 lines (40 loc) · 1.02 KB
/
Utils.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
//
// Created by xie on 18-5-23.
//
#include <stdfix.h>
#include <vector>
#include "Utils.h"
z3::context z3context;
std::string intTostring(int num) {
std::stringstream ss;
ss << num;
std::string str = ss.str();
return str;
}
bool isSat(z3::expr exp) {
z3::solver sol(z3context);
sol.add(exp);
if (sol.check() == z3::sat)
return true;
else
return false;
}
bool isSat(std::vector<z3::expr> exp) {
z3::solver sol(z3context);
for(auto it = exp.begin(), ed = exp.end(); it != ed; it++)
sol.add(*it);
if (sol.check() == z3::sat)
return true;
else
return false;
}
z3::expr substitute(z3::expr e, expr_map<z3::expr> &emap) {
z3::expr_vector ev(z3context), ev_prime(z3context);
for (auto it = emap.begin(), end = emap.end(); it != end; it++) {
assert(it->first.get_sort()=it->second.get_sort());
ev.push_back(it->first);
ev_prime.push_back(it->second);
}
z3::expr re= e.substitute(ev, ev_prime);
return re;
}