tvt z3_propt::l_get(literalt a) const { tvt result=tvt(false); std::string literal; Z3_ast z3_literal; size_t found; if(a.is_true()) return tvt(true); else if(a.is_false()) return tvt(false); literal = "l"+i2string(a.var_no()); map_prop_varst::const_iterator cache_result=map_prop_vars.find(literal.c_str()); if(cache_result!=map_prop_vars.end()) { //std::cout << "Cache hit on " << cache_result->first << "\n"; z3_literal = cache_result->second; Z3_app app = Z3_to_app(z3_ctx, z3_literal); Z3_func_decl d = Z3_get_app_decl(z3_ctx, app); literal = Z3_func_decl_to_string(z3_ctx, d); found=literal.find("true"); if (found!=std::string::npos) result=tvt(true); else result=tvt(false); } if (a.sign()) result=!result; return result; }
void display_solver_term(SOLVER_CONTEXT ctx, FILE * out, SOLVER_TERM term){ Z3_context c = (Z3_context) ctx; Z3_ast v = (Z3_ast) term; switch (Z3_get_ast_kind(c, v)) { case Z3_NUMERAL_AST: { Z3_sort t; fprintf(out, "%s", Z3_get_numeral_string(c, v)); t = Z3_get_sort(c, v); fprintf(out, ":"); display_sort(c, out, t); break; } case Z3_APP_AST: { unsigned i; Z3_app app = Z3_to_app(c, v); unsigned num_fields = Z3_get_app_num_args(c, app); Z3_func_decl d = Z3_get_app_decl(c, app); fprintf(out, "%s", Z3_func_decl_to_string(c, d)); if (num_fields > 0) { fprintf(out, "["); for (i = 0; i < num_fields; i++) { if (i > 0) { fprintf(out, ", "); } display_solver_term((SOLVER_CONTEXT) c, out, (SOLVER_TERM) Z3_get_app_arg(c, app, i)); } fprintf(out, "]"); } break; } case Z3_QUANTIFIER_AST: { fprintf(out, "quantifier"); ; } default: fprintf(out, "#unknown"); } }