bool scratch_programt::check_sat() { fix_types(); add_instruction(END_FUNCTION); #ifdef DEBUG cout << "Checking following program for satness:" << endl; output(ns, "scratch", cout); #endif symex.constant_propagation = constant_propagation; goto_symex_statet::propagationt::valuest constants; symex(symex_state, functions, *this); slice(equation); equation.convert(checker); return (checker.dec_solve() == decision_proceduret::D_SATISFIABLE); }
bool scratch_programt::check_sat(bool do_slice) { fix_types(); add_instruction(END_FUNCTION); remove_skip(*this); update(); #ifdef DEBUG std::cout << "Checking following program for satness:\n"; output(ns, "scratch", std::cout); #endif symex.constant_propagation=constant_propagation; goto_symex_statet::propagationt::valuest constants; symex(symex_state, functions, *this); if(do_slice) { slice(equation); } if(equation.count_assertions()==0) { // Symex sliced away all our assertions. #ifdef DEBUG std::cout << "Trivially unsat\n"; #endif return false; } equation.convert(*checker); #ifdef DEBUG std::cout << "Finished symex, invoking decision procedure.\n"; #endif return (checker->dec_solve()==decision_proceduret::D_SATISFIABLE); }
bool termination_baset::bmc( concrete_modelt &model, fine_timet &modelchecker_time, fine_timet &unsafe_time, fine_timet &safe_time) { bool res=false; #if 0 std::ofstream out("model"); model.goto_functions.output(ns, out); out.close(); #endif fine_timet before=current_time(); symex_target_equationt equation(ns); custom_symext symex(ns, shadow_context, equation); satcheckt satcheck; bv_pointerst bv_pointers(ns, satcheck); symex.options.set_option("assertions", true); satcheck.set_verbosity(2); satcheck.set_message_handler(get_message_handler()); bv_pointers.set_verbosity(2); bv_pointers.set_message_handler(get_message_handler()); try { symex(model.goto_functions); bv_pointerst::resultt satres; if(!symex.has_remaining_claims()) satres=bv_pointerst::D_UNSATISFIABLE; else { equation.convert(bv_pointers); satres=bv_pointers.dec_solve(); } modelchecker_time+=current_time()-before; switch(satres) { case bv_pointerst::D_TAUTOLOGY: case bv_pointerst::D_SATISFIABLE: unsafe_time+=current_time()-before; res=false; break; case bv_pointerst::D_UNSATISFIABLE: safe_time+=current_time()-before; res=true; break; default: throw("SAT Solver error."); break; } } catch (const std::bad_alloc &s) { status(std::string("BMC Exception: Memory exhausted")); } catch (const std::string &s) { status(std::string("BMC Exception: ") + s); } catch (const char *s) { status(std::string("BMC Exception: ") + s); } catch (unsigned u) { status(std::string("BMC Exception: ") + i2string(u)); } return res; }