Skip to content

Commit d3d483f

Browse files
committed
Implement handling of success messages from SMT solver
1 parent 194bf8a commit d3d483f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818

1919
#include <stack>
2020

21+
/// Issues a command to the solving process which is expected to optionally
22+
/// return a success status followed by response of interest.
23+
static smt_responset get_response_to_command(
24+
smt_base_solver_processt &solver_process,
25+
const smt_commandt &command)
26+
{
27+
solver_process.send(smt_check_sat_commandt{});
28+
auto response = solver_process.receive_response();
29+
if(response.cast<smt_success_responset>())
30+
return solver_process.receive_response();
31+
else
32+
return response;
33+
}
34+
2135
/// \brief Find all sub expressions of the given \p expr which need to be
2236
/// expressed as separate smt commands.
2337
/// \return A collection of sub expressions, which need to be expressed as
@@ -215,7 +229,8 @@ decision_proceduret::resultt smt2_incremental_decision_proceduret::dec_solve()
215229
{
216230
++number_of_solver_calls;
217231
solver_process->send(smt_check_sat_commandt{});
218-
const smt_responset result = solver_process->receive_response();
232+
const smt_responset result =
233+
get_response_to_command(*solver_process, smt_check_sat_commandt{});
219234
if(const auto check_sat_response = result.cast<smt_check_sat_responset>())
220235
{
221236
if(check_sat_response->kind().cast<smt_unknown_responset>())

unit/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,11 @@ TEST_CASE(
286286
CHECK(test.procedure() == decision_proceduret::resultt::D_ERROR);
287287
}
288288
}
289+
290+
TEST_CASE("smt2_incremental_decision_proceduret receives success and check-sat response.",
291+
"[core][smt2_incremental]")
292+
{
293+
decision_procedure_test_environmentt test{};
294+
test.mock_responses = {smt_success_responset{}, smt_check_sat_responset{smt_sat_responset{}}};
295+
REQUIRE_NOTHROW(test.procedure());
296+
}

0 commit comments

Comments
 (0)