11#include "dlinear/solver/ContextImpl.h"
12#include "dlinear/solver/ReluConstraint.h"
13#include "dlinear/util/exception.h"
14#include "dlinear/util/logging.h"
18Context::Context(Context &&context) noexcept : impl_{std::move(context.impl_)} {}
20Context::~Context() =
default;
27 impl_->AssertPiecewiseLinearFunction(var, cond, active, inactive);
32 impl_->DeclareVariable(v, is_model_variable);
35 const bool is_model_variable) {
36 impl_->DeclareVariable(v, is_model_variable);
37 impl_->SetDomain(v, lb, ub);
40 return impl_->AddGuidedConstraint(std::move(constraint));
47 DLINEAR_DEBUG_FMT(
"Context::Pop({})", n);
48 if (n <= 0) DLINEAR_RUNTIME_ERROR_FMT(
"Context::Pop(n) called with n = {} which is not positive.", n);
49 while (n-- > 0)
impl_->Pop();
52 DLINEAR_DEBUG_FMT(
"Context::Push({})", n);
53 if (n <= 0) DLINEAR_RUNTIME_ERROR_FMT(
"Context::Push(n) called with n = {} which is not positive.", n);
54 while (n-- > 0)
impl_->Push();
60 impl_->SetInterval(v, lb, ub);
69SmtSolverOutput *Context::m_solver_output() {
return impl_->m_solver_output(); }
Collection of variables with associated intervals.
Simple dataclass used to store the configuration of the program.
The context juggles between the SAT solver and the theory solver, in order to produce a model.
void Assert(const Formula &f)
Assert a formula f.
Context(Config &config, SmtSolverOutput *=nullptr)
Construct a context with config.
bool have_objective() const
Check whether or not there is an objective function (which may be zero) to optimize.
void Push(int n)
Push n stacks.
const Config & config() const
Get read-only access to the configuration of the context.
void SetInfo(const std::string &key, const std::string &val)
Set an info key with a value val.
std::string GetInfo(const std::string &key) const
Get the info key.
void Assert(const Formula &f)
Assert a formula f.
std::unique_ptr< Impl > impl_
Pointer to the implementation of the context.
void SetLogic(Logic logic)
Set the current logic to logic.
void Minimize(const Expression &f)
Assert a formula minimizing a cost function f.
std::string GetOption(const std::string &key) const
Get the option key.
bool is_max() const
Check whether or not the objective function (if present) is a maximization.
bool Verify(const Box &model) const
Check whether the model satisfies all the assertions loaded in the context.
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate_abstractor of the context.
void Maximize(const Expression &f)
Assert a formula maximizing a cost function f.
void DeclareVariable(const Variable &v, bool is_model_variable=true)
Declare a variable v.
void SetOption(const std::string &key, const std::string &val)
Set an option key with a value val.
const ScopedVector< Formula > & assertions() const
Get the the asserted formulas.
LpResult CheckOpt(mpq_class *obj_lo, mpq_class *obj_up)
Check the satisfiability of the asserted formulas, and (where possible) optimizes an objective functi...
void Pop(int n)
Pop n stacks.
void Exit()
Exit the context.
void AssertPiecewiseLinearFunction(const Variable &var, const Formula &cond, const Expression &active, const Expression &inactive)
Assert a piecewise linear function with two possible branches.
void SetInterval(const Variable &v, const mpq_class &lb, const mpq_class &ub)
Set the interval of v to in the current box (top one in boxes_).
SatResult CheckSat(mpq_class *actual_precision)
Check the satisfiability of the asserted formulas, and sets actual_precision to the actual max infeas...
const Box & model() const
Get a representation of a model computed by the solver in response to the last invocation of the chec...
const Box & box() const
Get the current active box from the top of the stack of boxes.
A piecewise linear constraint is a constraint that assumes different linear functions depending on th...
Predicate abstraction is a method to convert a first-order logic formula into a Boolean formula.
Represents a symbolic form of an expression.
Represents a symbolic variable.
Global namespace for the dlinear library.
SatResult
Result of running the theory solver over the literals decided by the SAT solver.
Logic
The SMT-LIB logic the SMT2 file is using.
LpResult
Result of running the LP solver over the input problem.
Data struct containing the output of the solver, such as the result of the computation as well as som...