mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 09:34:08 +00:00
adding consequence examples
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
82d0310d94
commit
2263be1b4d
|
@ -1111,6 +1111,24 @@ void param_descrs_example() {
|
|||
}
|
||||
}
|
||||
|
||||
void consequence_example() {
|
||||
std::cout << "consequence example\n";
|
||||
context c;
|
||||
expr A = c.bool_const("a");
|
||||
expr B = c.bool_const("b");
|
||||
expr C = c.bool_const("c");
|
||||
solver s(c);
|
||||
s.add(implies(A, B));
|
||||
s.add(implies(B, C));
|
||||
expr_vector assumptions(c), vars(c), consequences(c);
|
||||
assumptions.push_back(!C);
|
||||
vars.push_back(A);
|
||||
vars.push_back(B);
|
||||
vars.push_back(C);
|
||||
std::cout << s.consequences(assumptions, vars, consequences) << "\n";
|
||||
std::cout << consequences << "\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
try {
|
||||
|
@ -1154,6 +1172,7 @@ int main() {
|
|||
extract_example(); std::cout << "\n";
|
||||
param_descrs_example(); std::cout << "\n";
|
||||
sudoku_example(); std::cout << "\n";
|
||||
consequence_example(); std::cout << "\n";
|
||||
std::cout << "done\n";
|
||||
}
|
||||
catch (exception & ex) {
|
||||
|
|
|
@ -1723,6 +1723,11 @@ namespace z3 {
|
|||
return to_check_result(r);
|
||||
}
|
||||
model get_model() const { Z3_model m = Z3_solver_get_model(ctx(), m_solver); check_error(); return model(ctx(), m); }
|
||||
check_result consequences(expr_vector& assumptions, expr_vector& vars, expr_vector& conseq) {
|
||||
Z3_lbool r = Z3_solver_get_consequences(ctx(), m_solver, assumptions, vars, conseq);
|
||||
check_error();
|
||||
return to_check_result(r);
|
||||
}
|
||||
std::string reason_unknown() const { Z3_string r = Z3_solver_get_reason_unknown(ctx(), m_solver); check_error(); return r; }
|
||||
stats statistics() const { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }
|
||||
expr_vector unsat_core() const { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace smt {
|
|||
expr_ref_vector premises(m_manager);
|
||||
uint_set::iterator it = vars.begin(), end = vars.end();
|
||||
for (; it != end; ++it) {
|
||||
premises.push_back(bool_var2expr(*it));
|
||||
expr* e = bool_var2expr(*it);
|
||||
premises.push_back(get_assignment(*it) != l_false ? e : m_manager.mk_not(e));
|
||||
}
|
||||
return mk_and(premises);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue