diff --git a/src/solvers/smt2/smt2_conv.cpp b/src/solvers/smt2/smt2_conv.cpp index 5b7ab53c4ea5..a925580e80e5 100644 --- a/src/solvers/smt2/smt2_conv.cpp +++ b/src/solvers/smt2/smt2_conv.cpp @@ -214,7 +214,7 @@ void smt2_convt::write_footer() { out << "(check-sat-assuming ("; for(const auto &assumption : assumptions) - convert_literal(to_literal_expr(assumption).get_literal()); + convert_literal(assumption); out << "))\n"; } else @@ -227,7 +227,7 @@ void smt2_convt::write_footer() for(const auto &assumption : assumptions) { out << "(assert "; - convert_literal(to_literal_expr(assumption).get_literal()); + convert_literal(assumption); out << ")" << "\n"; } @@ -323,7 +323,7 @@ decision_proceduret::resultt smt2_convt::dec_solve(const exprt &assumption) write_footer(); else { - assumptions.push_back(literal_exprt(convert(assumption))); + assumptions.push_back(convert(assumption)); write_footer(); assumptions.pop_back(); } @@ -987,7 +987,9 @@ void smt2_convt::push(const std::vector &_assumptions) { INVARIANT(assumptions.empty(), "nested contexts are not supported"); - assumptions = _assumptions; + assumptions.reserve(_assumptions.size()); + for(auto &assumption : _assumptions) + assumptions.push_back(convert(assumption)); } void smt2_convt::pop() diff --git a/src/solvers/smt2/smt2_conv.h b/src/solvers/smt2/smt2_conv.h index 9f83687f8be9..8d1353262743 100644 --- a/src/solvers/smt2/smt2_conv.h +++ b/src/solvers/smt2/smt2_conv.h @@ -101,7 +101,7 @@ class smt2_convt : public stack_decision_proceduret unordered_map, irep_id_hash>; converterst converters; - std::vector assumptions; + std::vector assumptions; boolbv_widtht boolbv_width; std::size_t number_of_solver_calls = 0; diff --git a/src/solvers/smt2/smt2_dec.cpp b/src/solvers/smt2/smt2_dec.cpp index 55528f80ce77..89532a41e877 100644 --- a/src/solvers/smt2/smt2_dec.cpp +++ b/src/solvers/smt2/smt2_dec.cpp @@ -13,6 +13,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include + #include "smt2irep.h" std::string smt2_dect::decision_procedure_text() const @@ -44,10 +46,20 @@ decision_proceduret::resultt smt2_dect::dec_solve(const exprt &assumption) const auto write_problem_to_file = [&](std::ofstream problem_out) { cached_output << stringstream.str(); stringstream.str(std::string{}); - write_footer(); + + if(assumption.is_nil()) + write_footer(); + else + { + assumptions.push_back(convert(assumption)); + write_footer(); + assumptions.pop_back(); + } + problem_out << cached_output.str() << stringstream.str(); stringstream.str(std::string{}); }; + write_problem_to_file(std::ofstream( temp_file_problem(), std::ios_base::out | std::ios_base::trunc));