This PR refactors the nonlinear extension(s) to access options only via the environment class.
TrustNode lem = TrustNode::null();
NodeManager* nm = NodeManager::currentNM();
Integer floor = value.floor();
- if (options::brabTest())
+ if (d_astate.options().arith.brabTest)
{
Trace("integers") << "branch-round-and-bound enabled" << std::endl;
Integer ceil = value.ceiling();
ProofNodeManager* pnm)
: InferenceManagerBuffered(ta, astate, pnm, "theory::arith::"),
// currently must track propagated literals if using the equality solver
- d_trackPropLits(options::arithEqSolver()),
+ d_trackPropLits(astate.options().arith.arithEqSolver),
d_propLits(astate.getSatContext())
{
}
bool InferenceManager::isEntailedFalse(const SimpleTheoryLemma& lem)
{
- if (options::nlExtEntailConflicts())
+ if (d_theoryState.options().arith.nlExtEntailConflicts)
{
Node ch_lemma = lem.d_node.negate();
ch_lemma = Rewriter::rewrite(ch_lemma);
namespace nl {
namespace cad {
-CDCAC::CDCAC(context::Context* ctx,
- ProofNodeManager* pnm,
- const std::vector<poly::Variable>& ordering)
- : d_variableOrdering(ordering)
+CDCAC::CDCAC(Env& env, const std::vector<poly::Variable>& ordering)
+ : d_env(env), d_variableOrdering(ordering)
{
- if (pnm != nullptr)
+ if (d_env.isTheoryProofProducing())
{
- d_proof.reset(new CADProofGenerator(ctx, pnm));
+ d_proof.reset(
+ new CADProofGenerator(d_env.getContext(), d_env.getProofNodeManager()));
}
}
void CDCAC::retrieveInitialAssignment(NlModel& model, const Node& ran_variable)
{
- if (!options::nlCadUseInitial()) return;
+ if (!d_env.getOptions().arith.nlCadUseInitial) return;
d_initialAssignment.clear();
Trace("cdcac") << "Retrieving initial assignment:" << std::endl;
for (const auto& var : d_variableOrdering)
{
std::vector<CACInterval> res;
LazardEvaluation le;
- if (options::nlCadLifting() == options::NlCadLiftingMode::LAZARD)
+ if (d_env.getOptions().arith.nlCadLifting
+ == options::NlCadLiftingMode::LAZARD)
{
for (size_t vid = 0; vid < cur_variable; ++vid)
{
Trace("cdcac") << "Infeasible intervals for " << p << " " << sc
<< " 0 over " << d_assignment << std::endl;
std::vector<poly::Interval> intervals;
- if (options::nlCadLifting() == options::NlCadLiftingMode::LAZARD)
+ if (d_env.getOptions().arith.nlCadLifting
+ == options::NlCadLiftingMode::LAZARD)
{
intervals = le.infeasibleRegions(p, sc);
if (Trace.isOn("cdcac"))
poly::Value& sample,
std::size_t cur_variable)
{
- if (options::nlCadUseInitial() && cur_variable < d_initialAssignment.size())
+ if (d_env.getOptions().arith.nlCadUseInitial
+ && cur_variable < d_initialAssignment.size())
{
const poly::Value& suggested = d_initialAssignment[cur_variable];
for (const auto& i : infeasible)
<< requiredCoefficientsOriginal(p, d_assignment)
<< std::endl;
}
- switch (options::nlCadProjection())
+ switch (d_env.getOptions().arith.nlCadProjection)
{
case options::NlCadProjectionMode::MCCALLUM:
return requiredCoefficientsOriginal(p, d_assignment);
#include <vector>
+#include "smt/env.h"
#include "theory/arith/nl/cad/cdcac_utils.h"
#include "theory/arith/nl/cad/constraints.h"
#include "theory/arith/nl/cad/proof_generator.h"
{
public:
/** Initialize this method with the given variable ordering. */
- CDCAC(context::Context* ctx,
- ProofNodeManager* pnm,
- const std::vector<poly::Variable>& ordering = {});
+ CDCAC(Env& env, const std::vector<poly::Variable>& ordering = {});
/** Reset this instance. */
void reset();
*/
void pruneRedundantIntervals(std::vector<CACInterval>& intervals);
+ /** A reference to the environment */
+ Env& d_env;
+
/**
* The current assignment. When the method terminates with SAT, it contains a
* model for the input constraints.
namespace arith {
namespace nl {
-CadSolver::CadSolver(InferenceManager& im,
- NlModel& model,
- context::Context* ctx,
- ProofNodeManager* pnm)
+CadSolver::CadSolver(Env& env, InferenceManager& im, NlModel& model)
:
#ifdef CVC5_POLY_IMP
- d_CAC(ctx, pnm),
+ d_CAC(env),
#endif
d_foundSatisfiability(false),
d_im(im),
d_ranVariable = sm->mkDummySkolem(
"__z", nm->realType(), "", NodeManager::SKOLEM_EXACT_NAME);
#ifdef CVC5_POLY_IMP
- ProofChecker* pc = pnm != nullptr ? pnm->getChecker() : nullptr;
- if (pc != nullptr)
+ if (env.isTheoryProofProducing())
{
+ ProofChecker* pc = env.getProofNodeManager()->getChecker();
// add checkers
d_proofChecker.registerTo(pc);
}
class CadSolver
{
public:
- CadSolver(InferenceManager& im,
- NlModel& model,
- context::Context* ctx,
- ProofNodeManager* pnm);
+ CadSolver(Env& env, InferenceManager& im, NlModel& model);
~CadSolver();
/**
IAndSolver::IAndSolver(InferenceManager& im, ArithState& state, NlModel& model)
: d_im(im),
d_model(model),
+ d_astate(state),
d_initRefine(state.getUserContext())
{
NodeManager* nm = NodeManager::currentNM();
}
// ************* additional lemma schemas go here
- if (options::iandMode() == options::IandMode::SUM)
+ if (d_astate.options().smt.iandMode == options::IandMode::SUM)
{
Node lem = sumBasedLemma(i); // add lemmas based on sum mode
Trace("iand-lemma")
d_im.addPendingLemma(
lem, InferenceId::ARITH_NL_IAND_SUM_REFINE, nullptr, true);
}
- else if (options::iandMode() == options::IandMode::BITWISE)
+ else if (d_astate.options().smt.iandMode == options::IandMode::BITWISE)
{
Node lem = bitwiseLemma(i); // check for violated bitwise axioms
Trace("iand-lemma")
Node x = i[0];
Node y = i[1];
size_t bvsize = i.getOperator().getConst<IntAnd>().d_size;
- uint64_t granularity = options::BVAndIntegerGranularity();
+ uint64_t granularity = d_astate.options().smt.BVAndIntegerGranularity;
NodeManager* nm = NodeManager::currentNM();
Node lem = nm->mkNode(
EQUAL, i, d_iandUtils.createSumNode(x, y, bvsize, granularity));
Node y = i[1];
unsigned bvsize = i.getOperator().getConst<IntAnd>().d_size;
- uint64_t granularity = options::BVAndIntegerGranularity();
+ uint64_t granularity = d_astate.options().smt.BVAndIntegerGranularity;
Rational absI = d_model.computeAbstractModelValue(i).getConst<Rational>();
Rational concI = d_model.computeConcreteModelValue(i).getConst<Rational>();
InferenceManager& d_im;
/** Reference to the non-linear model object */
NlModel& d_model;
+ /** Reference to the arithmetic state */
+ ArithState& d_astate;
/** commonly used terms */
Node d_false;
Node d_true;
namespace arith {
namespace nl {
-NlModel::NlModel(context::Context* c) : d_used_approx(false)
+NlModel::NlModel() : d_used_approx(false)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
void NlModel::getModelValueRepair(
std::map<Node, Node>& arithModel,
std::map<Node, std::pair<Node, Node>>& approximations,
- std::map<Node, Node>& witnesses)
+ std::map<Node, Node>& witnesses,
+ bool witnessToValue)
{
Trace("nl-model") << "NlModel::getModelValueRepair:" << std::endl;
// If we extended the model with entries x -> 0 for unconstrained values,
pred = nm->mkNode(AND, nm->mkNode(GEQ, v, l), nm->mkNode(GEQ, u, v));
Trace("nl-model") << v << " approximated as " << pred << std::endl;
Node witness;
- if (options::modelWitnessValue())
+ if (witnessToValue)
{
// witness is the midpoint
witness = nm->mkNode(
friend class NonlinearExtension;
public:
- NlModel(context::Context* c);
+ NlModel();
~NlModel();
/**
* This method is called once at the beginning of a last call effort check,
void getModelValueRepair(
std::map<Node, Node>& arithModel,
std::map<Node, std::pair<Node, Node>>& approximations,
- std::map<Node, Node>& witnesses);
+ std::map<Node, Node>& witnesses,
+ bool witnessToValue);
private:
/** The current model */
#include "theory/arith/nl/nonlinear_extension.h"
#include "options/arith_options.h"
+#include "options/smt_options.h"
#include "theory/arith/arith_state.h"
#include "theory/arith/bound_inference.h"
#include "theory/arith/inference_manager.h"
containing.getSatContext(),
containing.getUserContext(),
d_im),
- d_model(containing.getSatContext()),
+ d_model(),
d_trSlv(d_im, d_model, d_astate.getEnv()),
d_extState(d_im, d_model, d_astate.getEnv()),
d_factoringSlv(&d_extState),
d_monomialSlv(&d_extState),
d_splitZeroSlv(&d_extState),
d_tangentPlaneSlv(&d_extState),
- d_cadSlv(d_im,
- d_model,
- state.getUserContext(),
- d_astate.getEnv().getProofNodeManager()),
+ d_cadSlv(d_astate.getEnv(), d_im, d_model),
d_icpSlv(d_im),
d_iandSlv(d_im, state, d_model),
d_pow2Slv(d_im, state, d_model)
{
Trace("nl-ext-assert-debug") << "Getting assertions..." << std::endl;
bool useRelevance = false;
- if (options::nlRlvMode() == options::NlRlvMode::INTERLEAVE)
+ if (options().arith.nlRlvMode == options::NlRlvMode::INTERLEAVE)
{
useRelevance = (d_checkCounter % 2);
}
- else if (options::nlRlvMode() == options::NlRlvMode::ALWAYS)
+ else if (options().arith.nlRlvMode == options::NlRlvMode::ALWAYS)
{
useRelevance = true;
}
// relevance here, since we may have discarded literals that are relevant
// that are entailed based on the techniques in getAssertions.
std::vector<Node> passertions = assertions;
- if (options::nlExt() == options::NlExtMode::FULL)
+ if (options().arith.nlExt == options::NlExtMode::FULL)
{
// preprocess the assertions with the trancendental solver
if (!d_trSlv.preprocessAssertionsCheckModel(passertions))
return false;
}
}
- if (options::nlCad())
+ if (options().arith.nlCad)
{
d_cadSlv.constructModelIfAvailable(passertions);
}
if (e == Theory::EFFORT_FULL)
{
d_needsLastCall = true;
- if (options::nlExtRewrites())
+ if (options().arith.nlExtRewrites)
{
std::vector<Node> nred;
if (!d_extTheory.doInferences(0, nred))
}
// we are incomplete
- if (options::nlExt() == options::NlExtMode::FULL
- && options::nlExtIncPrecision() && d_model.usedApproximate())
+ if (options().arith.nlExt == options::NlExtMode::FULL
+ && options().arith.nlExtIncPrecision && d_model.usedApproximate())
{
d_trSlv.incrementTaylorDegree();
needsRecheck = true;
d_approximations.clear();
d_witnesses.clear();
// modify the model values
- d_model.getModelValueRepair(arithModel, d_approximations, d_witnesses);
+ d_model.getModelValueRepair(arithModel,
+ d_approximations,
+ d_witnesses,
+ options().smt.modelWitnessValue);
}
}
}
if (!d_strategy.isStrategyInit())
{
- d_strategy.initializeStrategy();
+ d_strategy.initializeStrategy(options());
}
auto steps = d_strategy.getStrategy();
InferStep StepGenerator::next() { return d_steps[d_next++]; }
bool Strategy::isStrategyInit() const { return !d_interleaving.empty(); }
-void Strategy::initializeStrategy()
+void Strategy::initializeStrategy(const Options& options)
{
StepSequence one;
- if (options::nlICP())
+ if (options.arith.nlICP)
{
one << InferStep::ICP << InferStep::BREAK;
}
- if (options::nlExt() == options::NlExtMode::FULL
- || options::nlExt() == options::NlExtMode::LIGHT)
+ if (options.arith.nlExt == options::NlExtMode::FULL
+ || options.arith.nlExt == options::NlExtMode::LIGHT)
{
one << InferStep::NL_INIT << InferStep::BREAK;
}
- if (options::nlExt() == options::NlExtMode::FULL)
+ if (options.arith.nlExt == options::NlExtMode::FULL)
{
one << InferStep::TRANS_INIT << InferStep::BREAK;
- if (options::nlExtSplitZero())
+ if (options.arith.nlExtSplitZero)
{
one << InferStep::NL_SPLIT_ZERO << InferStep::BREAK;
}
one << InferStep::IAND_INITIAL << InferStep::BREAK;
one << InferStep::POW2_INIT;
one << InferStep::POW2_INITIAL << InferStep::BREAK;
- if (options::nlExt() == options::NlExtMode::FULL
- || options::nlExt() == options::NlExtMode::LIGHT)
+ if (options.arith.nlExt == options::NlExtMode::FULL
+ || options.arith.nlExt == options::NlExtMode::LIGHT)
{
one << InferStep::NL_MONOMIAL_SIGN << InferStep::BREAK;
one << InferStep::NL_MONOMIAL_MAGNITUDE0 << InferStep::BREAK;
}
- if (options::nlExt() == options::NlExtMode::FULL)
+ if (options.arith.nlExt == options::NlExtMode::FULL)
{
one << InferStep::TRANS_MONOTONIC << InferStep::BREAK;
one << InferStep::NL_MONOMIAL_MAGNITUDE1 << InferStep::BREAK;
one << InferStep::NL_MONOMIAL_MAGNITUDE2 << InferStep::BREAK;
one << InferStep::NL_MONOMIAL_INFER_BOUNDS;
- if (options::nlExtTangentPlanes()
- && options::nlExtTangentPlanesInterleave())
+ if (options.arith.nlExtTangentPlanes
+ && options.arith.nlExtTangentPlanesInterleave)
{
one << InferStep::NL_TANGENT_PLANES;
}
one << InferStep::BREAK;
one << InferStep::FLUSH_WAITING_LEMMAS << InferStep::BREAK;
- if (options::nlExtFactor())
+ if (options.arith.nlExtFactor)
{
one << InferStep::NL_FACTORING << InferStep::BREAK;
}
- if (options::nlExtResBound())
+ if (options.arith.nlExtResBound)
{
one << InferStep::NL_MONOMIAL_INFER_BOUNDS << InferStep::BREAK;
}
- if (options::nlExtTangentPlanes()
- && !options::nlExtTangentPlanesInterleave())
+ if (options.arith.nlExtTangentPlanes
+ && !options.arith.nlExtTangentPlanesInterleave)
{
one << InferStep::NL_TANGENT_PLANES_WAITING;
}
- if (options::nlExtTfTangentPlanes())
+ if (options.arith.nlExtTfTangentPlanes)
{
one << InferStep::TRANS_TANGENT_PLANES;
}
}
one << InferStep::IAND_FULL << InferStep::BREAK;
one << InferStep::POW2_FULL << InferStep::BREAK;
- if (options::nlCad())
+ if (options.arith.nlCad)
{
one << InferStep::CAD_INIT;
}
- if (options::nlCad())
+ if (options.arith.nlCad)
{
one << InferStep::CAD_FULL << InferStep::BREAK;
}
#include <iosfwd>
#include <vector>
+#include "options/options.h"
+
namespace cvc5 {
namespace theory {
namespace arith {
/** Is this strategy initialized? */
bool isStrategyInit() const;
/** Initialize this strategy */
- void initializeStrategy();
+ void initializeStrategy(const Options& options);
/** Retrieve the strategy for the given effort e */
StepGenerator getStrategy();
d_theoryState = &d_astate;
d_inferManager = &d_im;
- if (options::arithEqSolver())
+ if (options().arith.arithEqSolver)
{
d_eqSolver.reset(new EqualitySolver(d_astate, d_im));
}
TEST_F(TestTheoryWhiteArithCAD, test_cdcac_1)
{
- cad::CDCAC cac(nullptr, nullptr, {});
+ Options opts;
+ Env env(NodeManager::currentNM(), &opts);
+ cad::CDCAC cac(env, {});
poly::Variable x = cac.getConstraints().varMapper()(make_real_variable("x"));
poly::Variable y = cac.getConstraints().varMapper()(make_real_variable("y"));
TEST_F(TestTheoryWhiteArithCAD, test_cdcac_2)
{
- cad::CDCAC cac(nullptr, nullptr, {});
+ Options opts;
+ Env env(NodeManager::currentNM(), &opts);
+ cad::CDCAC cac(env, {});
poly::Variable x = cac.getConstraints().varMapper()(make_real_variable("x"));
poly::Variable y = cac.getConstraints().varMapper()(make_real_variable("y"));
TEST_F(TestTheoryWhiteArithCAD, test_cdcac_3)
{
- cad::CDCAC cac(nullptr, nullptr, {});
+ Options opts;
+ Env env(NodeManager::currentNM(), &opts);
+ cad::CDCAC cac(env, {});
poly::Variable x = cac.getConstraints().varMapper()(make_real_variable("x"));
poly::Variable y = cac.getConstraints().varMapper()(make_real_variable("y"));
poly::Variable z = cac.getConstraints().varMapper()(make_real_variable("z"));
TEST_F(TestTheoryWhiteArithCAD, test_cdcac_4)
{
- cad::CDCAC cac(nullptr, nullptr, {});
+ Options opts;
+ Env env(NodeManager::currentNM(), &opts);
+ cad::CDCAC cac(env, {});
poly::Variable x = cac.getConstraints().varMapper()(make_real_variable("x"));
poly::Variable y = cac.getConstraints().varMapper()(make_real_variable("y"));
poly::Variable z = cac.getConstraints().varMapper()(make_real_variable("z"));
void test_delta(const std::vector<Node>& a)
{
- cad::CDCAC cac(nullptr, nullptr, {});
+ Options opts;
+ Env env(NodeManager::currentNM(), &opts);
+ cad::CDCAC cac(env, {});
cac.reset();
for (const Node& n : a)
{