mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Merge branch 'unstable' into contrib
This commit is contained in:
commit
d2a2dbb4b6
230 changed files with 9263 additions and 13830 deletions
|
@ -906,6 +906,72 @@ void enum_sort_example() {
|
|||
std::cout << "2: " << result_goal.as_expr() << std::endl;
|
||||
}
|
||||
|
||||
void expr_vector_example() {
|
||||
std::cout << "expr_vector example\n";
|
||||
context c;
|
||||
const unsigned N = 10;
|
||||
|
||||
expr_vector x(c);
|
||||
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
std::stringstream x_name;
|
||||
x_name << "x_" << i;
|
||||
x.push_back(c.int_const(x_name.str().c_str()));
|
||||
}
|
||||
|
||||
solver s(c);
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
s.add(x[i] >= 1);
|
||||
}
|
||||
|
||||
std::cout << s << "\n" << "solving...\n" << s.check() << "\n";
|
||||
model m = s.get_model();
|
||||
std::cout << "solution\n" << m;
|
||||
}
|
||||
|
||||
void exists_expr_vector_example() {
|
||||
std::cout << "exists expr_vector example\n";
|
||||
context c;
|
||||
const unsigned N = 10;
|
||||
|
||||
expr_vector xs(c);
|
||||
expr x(c);
|
||||
expr b(c);
|
||||
b = c.bool_val(true);
|
||||
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
std::stringstream x_name;
|
||||
x_name << "x_" << i;
|
||||
x = c.int_const(x_name.str().c_str());
|
||||
xs.push_back(x);
|
||||
b = b && x >= 0;
|
||||
}
|
||||
|
||||
expr ex(c);
|
||||
ex = exists(xs, b);
|
||||
std::cout << ex << std::endl;
|
||||
}
|
||||
|
||||
void substitute_example() {
|
||||
std::cout << "substitute example\n";
|
||||
context c;
|
||||
expr x(c);
|
||||
x = c.int_const("x");
|
||||
expr f(c);
|
||||
f = (x == 2) || (x == 1);
|
||||
std::cout << f << std::endl;
|
||||
|
||||
expr two(c), three(c);
|
||||
two = c.int_val(2);
|
||||
three = c.int_val(3);
|
||||
Z3_ast from[] = { two };
|
||||
Z3_ast to[] = { three };
|
||||
expr new_f(c);
|
||||
new_f = to_expr(c, Z3_substitute(c, f, 1, from, to));
|
||||
|
||||
std::cout << new_f << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
demorgan(); std::cout << "\n";
|
||||
|
@ -937,10 +1003,13 @@ int main() {
|
|||
tactic_example9(); std::cout << "\n";
|
||||
tactic_qe(); std::cout << "\n";
|
||||
tst_visit(); std::cout << "\n";
|
||||
incremental_example1(); std::cout << "\n";
|
||||
incremental_example2(); std::cout << "\n";
|
||||
incremental_example3(); std::cout << "\n";
|
||||
incremental_example1(); std::cout << "\n";
|
||||
incremental_example2(); std::cout << "\n";
|
||||
incremental_example3(); std::cout << "\n";
|
||||
enum_sort_example(); std::cout << "\n";
|
||||
expr_vector_example(); std::cout << "\n";
|
||||
exists_expr_vector_example(); std::cout << "\n";
|
||||
substitute_example(); std::cout << "\n";
|
||||
std::cout << "done\n";
|
||||
}
|
||||
catch (exception & ex) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue