-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
52 lines (47 loc) · 1.29 KB
/
main.cc
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
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include "z3client.h"
using namespace z3;
void example_one(int iter){
context c;
model mdl(c);
expr x = c.int_const("x");
expr y = c.int_const("y");
solver s(c);
s.add(x >= 1);
s.add(y < x + 3);
int count = 1;
while (count <= iter){
/* We've received a serialized version of a Z3 model. Extract a
* model object from this. */
string res = write_problem_to_z3server(s.to_smt2());
std::cout << "Iteration #" << count << ":" << endl;
if (res.compare(0, 1, "(") == 0) {
solver s1(c);
s1.from_string(res.c_str());
auto is_sat = s1.check();
assert (is_sat == z3::sat);
mdl = s1.get_model();
/** Print model **/
for (unsigned i = 0; i < mdl.size(); i++) {
func_decl v = mdl[i];
std::cout << v.name() << " = " << mdl.get_const_interp(v) << "\n";
}
} else {
cout << "z3 solver client received unexpected output: '"
<< res << "'\n";
}
count++; // increase loop count
}
}
int main(int argc, char* argv[]) {
cout << "Sample use of z3Validation\n";
int iter = 10;
if (argc == 2)
{
iter = std::stoi(argv[1]);
}
example_one(iter);
}