Skip to content

Commit 040d6d1

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

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 16 additions & 2 deletions
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 the actual 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(command);
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
@@ -214,8 +228,8 @@ static decision_proceduret::resultt lookup_decision_procedure_result(
214228
decision_proceduret::resultt smt2_incremental_decision_proceduret::dec_solve()
215229
{
216230
++number_of_solver_calls;
217-
solver_process->send(smt_check_sat_commandt{});
218-
const smt_responset result = solver_process->receive_response();
231+
const smt_responset result =
232+
get_response_to_command(*solver_process, smt_check_sat_commandt{});
219233
if(const auto check_sat_response = result.cast<smt_check_sat_responset>())
220234
{
221235
if(check_sat_response->kind().cast<smt_unknown_responset>())

unit/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

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

0 commit comments

Comments
 (0)