Skip to content

Implement sending commands to solver in incremental SMT2 backend #6357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/goto-checker/solver_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ solver_factoryt::get_incremental_smt2(std::string solver_command)

return util_make_unique<solvert>(
util_make_unique<smt2_incremental_decision_proceduret>(
std::move(solver_command)));
std::move(solver_command), message_handler));
}

std::unique_ptr<solver_factoryt::solvert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include <util/string_utils.h>

smt2_incremental_decision_proceduret::smt2_incremental_decision_proceduret(
std::string _solver_command)
: solver_command{std::move(_solver_command)},
std::string _solver_command,
message_handlert &message_handler)
: solver_command(std::move(_solver_command)),
number_of_solver_calls{0},
solver_process{split_string(solver_command, ' ', false, true)}
solver_process{split_string(solver_command, ' ', false, true)},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The split_string looks brittle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments are provided to cbmc in space separated form. Therefore they currently need to be split in order separate them. Any suggestions for making this less brittle?

log{message_handler}
{
send_to_solver(smt_set_option_commandt{smt_option_produce_modelst{true}});
send_to_solver(smt_set_logic_commandt{
Expand Down Expand Up @@ -83,5 +85,8 @@ decision_proceduret::resultt smt2_incremental_decision_proceduret::dec_solve()
void smt2_incremental_decision_proceduret::send_to_solver(
const smt_commandt &command)
{
solver_process.send(smt_to_smt2_string(command) + "\n");
const std::string command_string = smt_to_smt2_string(command);
log.debug() << "Sending command to SMT2 solver - " << command_string
<< messaget::eom;
solver_process.send(command_string + "\n");
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@
#define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT2_INCREMENTAL_DECISION_PROCEDURE_H

#include <solvers/stack_decision_procedure.h>
#include <util/message.h>
#include <util/piped_process.h>

class smt_commandt;
class message_handlert;

class smt2_incremental_decision_proceduret final
: public stack_decision_proceduret
{
public:
/// \param solver_command: The command and arguments for invoking the smt2
/// solver.
explicit smt2_incremental_decision_proceduret(std::string solver_command);
/// \param solver_command:
/// The command and arguments for invoking the smt2 solver.
/// \param message_handler:
/// The messaging system to be used for logging purposes.
explicit smt2_incremental_decision_proceduret(
std::string solver_command,
message_handlert &message_handler);

// Implementation of public decision_proceduret member functions.
exprt handle(const exprt &expr) override;
Expand All @@ -44,6 +50,7 @@ class smt2_incremental_decision_proceduret final
size_t number_of_solver_calls;

piped_processt solver_process;
messaget log;
};

#endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT2_INCREMENTAL_DECISION_PROCEDURE_H