This PR removes a bunch of the remaining places where options are accessed statically.
void UnsatCore::toStream(std::ostream& out) const {
options::ioutils::Scope scope(out);
options::ioutils::applyDagThresh(out, 0);
- Printer::getPrinter(options::outputLanguage())->toStream(out, *this);
+ auto language = options::ioutils::getOutputLang(out);
+ Printer::getPrinter(language)->toStream(out, *this);
}
std::ostream& operator<<(std::ostream& out, const UnsatCore& core) {
//=================================================================================================
// Constructor/Destructor:
-Solver::Solver(cvc5::prop::TheoryProxy* proxy,
+Solver::Solver(Env& env,
+ cvc5::prop::TheoryProxy* proxy,
cvc5::context::Context* context,
cvc5::context::UserContext* userContext,
ProofNodeManager* pnm,
bool enableIncremental)
- : d_proxy(proxy),
+ : EnvObj(env),
+ d_proxy(proxy),
d_context(context),
assertionLevel(0),
d_pfManager(nullptr),
// If a literal is false at 0 level (both sat and user level) we also
// ignore it, unless we are tracking the SAT solver's reasoning
if (value(ps[i]) == l_False) {
- if (!options::unsatCores() && !needProof() && level(var(ps[i])) == 0
+ if (!options().smt.unsatCores && !needProof() && level(var(ps[i])) == 0
&& user_level(var(ps[i])) == 0)
{
continue;
// If all false, we're in conflict
if (ps.size() == falseLiteralsCount) {
- if (options::unsatCores() || needProof())
+ if (options().smt.unsatCores || needProof())
{
// Take care of false units here; otherwise, we need to
// construct the clause below to give to the proof manager
clauses_persistent.push(cr);
attachClause(cr);
- if (options::unsatCores() || needProof())
+ if (options().smt.unsatCores || needProof())
{
if (ps.size() == falseLiteralsCount)
{
// If it's an empty lemma, we have a conflict at zero level
if (lemma.size() == 0) {
- Assert(!options::unsatCores() && !needProof());
+ Assert(!options().smt.unsatCores && !needProof());
conflict = CRef_Lazy;
backtrackLevel = 0;
Debug("minisat::lemmas") << "Solver::updateLemmas(): found empty clause" << std::endl;
bool Solver::needProof() const
{
return isProofEnabled()
- && options::unsatCoresMode() != options::UnsatCoresMode::ASSUMPTIONS
- && options::unsatCoresMode() != options::UnsatCoresMode::PP_ONLY;
+ && options().smt.unsatCoresMode != options::UnsatCoresMode::ASSUMPTIONS
+ && options().smt.unsatCoresMode != options::UnsatCoresMode::PP_ONLY;
}
} // namespace Minisat
#include "prop/minisat/mtl/Vec.h"
#include "prop/minisat/utils/Options.h"
#include "prop/sat_proof_manager.h"
+#include "smt/env_obj.h"
#include "theory/theory.h"
#include "util/resource_manager.h"
//=================================================================================================
// Solver -- the main class:
-class Solver {
+class Solver : protected EnvObj
+{
/** The only two cvc5 entry points to the private solver data */
friend class cvc5::prop::PropEngine;
friend class cvc5::prop::TheoryProxy;
// Constructor/Destructor:
//
- Solver(cvc5::prop::TheoryProxy* proxy,
+ Solver(Env& env,
+ cvc5::prop::TheoryProxy* proxy,
cvc5::context::Context* context,
cvc5::context::UserContext* userContext,
ProofNodeManager* pnm,
// Returns a random integer 0 <= x < size. Seed must never be 0.
static inline int irand(double& seed, int size) {
return (int)(drand(seed) * size); }
-
};
-
-
//=================================================================================================
// Implementation of inline methods:
// Create the solver
d_minisat =
- new Minisat::SimpSolver(theoryProxy,
+ new Minisat::SimpSolver(d_env,
+ theoryProxy,
d_context,
userContext,
pnm,
//=================================================================================================
// Constructor/Destructor:
-SimpSolver::SimpSolver(cvc5::prop::TheoryProxy* proxy,
+SimpSolver::SimpSolver(Env& env,
+ cvc5::prop::TheoryProxy* proxy,
cvc5::context::Context* context,
cvc5::context::UserContext* userContext,
ProofNodeManager* pnm,
bool enableIncremental)
- : Solver(proxy, context, userContext, pnm, enableIncremental),
+ : Solver(env, proxy, context, userContext, pnm, enableIncremental),
grow(opt_grow),
clause_lim(opt_clause_lim),
subsumption_lim(opt_subsumption_lim),
simp_garbage_frac(opt_simp_garbage_frac),
use_asymm(opt_use_asymm),
// make sure this is not enabled if unsat cores or proofs are on
- use_rcheck(opt_use_rcheck && !options::unsatCores() && !pnm),
- use_elim(options::minisatUseElim() && !enableIncremental),
+ use_rcheck(opt_use_rcheck && !options().smt.unsatCores && !pnm),
+ use_elim(options().prop.minisatUseElim && !enableIncremental),
merges(0),
asymm_lits(0),
eliminated_vars(0),
elimorder(1),
- use_simplification(!enableIncremental && !options::unsatCores()
+ use_simplification(!enableIncremental && !options().smt.unsatCores
&& !pnm) // TODO: turn off simplifications if
// proofs are on initially
,
bwdsub_assigns(0),
n_touched(0)
{
- if(options::minisatUseElim() &&
- Options::current().prop.minisatUseElimWasSetByUser &&
- enableIncremental) {
- WarningOnce() << "Incremental mode incompatible with --minisat-elim" << std::endl;
- }
+ if (options().prop.minisatUseElim && options().prop.minisatUseElimWasSetByUser
+ && enableIncremental)
+ {
+ WarningOnce() << "Incremental mode incompatible with --minisat-elim"
+ << std::endl;
+ }
vec<Lit> dummy(1,lit_Undef);
ca.extra_clause_field = true; // NOTE: must happen before allocating the dummy clause below.
lbool SimpSolver::solve_(bool do_simp, bool turn_off_simp)
{
- if (options::minisatDumpDimacs()) {
- toDimacs();
- return l_Undef;
- }
+ if (options().prop.minisatDumpDimacs)
+ {
+ toDimacs();
+ return l_Undef;
+ }
Assert(decisionLevel() == 0);
vec<Var> extra_frozen;
public:
// Constructor/Destructor:
//
- SimpSolver(cvc5::prop::TheoryProxy* proxy,
+ SimpSolver(Env& env,
+ cvc5::prop::TheoryProxy* proxy,
cvc5::context::Context* context,
cvc5::context::UserContext* userContext,
ProofNodeManager* pnm,
}
};
-PropEngine::PropEngine(TheoryEngine* te, Env& env)
- : d_inCheckSat(false),
+PropEngine::PropEngine(Env& env, TheoryEngine* te)
+ : EnvObj(env),
+ d_inCheckSat(false),
d_theoryEngine(te),
- d_env(env),
d_skdm(new SkolemDefManager(d_env.getContext(), d_env.getUserContext())),
d_theoryProxy(nullptr),
d_satSolver(nullptr),
ProofNodeManager* pnm = d_env.getProofNodeManager();
ResourceManager* rm = d_env.getResourceManager();
- options::DecisionMode dmode = options::decisionMode();
+ options::DecisionMode dmode = options().decision.decisionMode;
if (dmode == options::DecisionMode::JUSTIFICATION
|| dmode == options::DecisionMode::STOPONLY)
{
// CNF stream and theory proxy required pointers to each other, make the
// theory proxy first
d_theoryProxy = new TheoryProxy(
- this, d_theoryEngine, d_decisionEngine.get(), d_skdm.get(), d_env);
+ d_env, this, d_theoryEngine, d_decisionEngine.get(), d_skdm.get());
d_cnfStream = new CnfStream(d_satSolver,
d_theoryProxy,
userContext,
// do final checks on the lemmas we are about to send
if (isProofEnabled()
- && options::proofCheck() == options::ProofCheckMode::EAGER)
+ && options().proof.proofCheck == options::ProofCheckMode::EAGER)
{
Assert(tplemma.getGenerator() != nullptr);
// ensure closed, make the proof node eagerly here to debug
Node node = trn.getNode();
Debug("prop::lemmas") << "assertLemma(" << node << ")" << std::endl;
bool negated = trn.getKind() == TrustNodeKind::CONFLICT;
- Assert(
- !isProofEnabled() || trn.getGenerator() != nullptr
- || options::unsatCores()
- || (options::unsatCores()
- && options::unsatCoresMode() != options::UnsatCoresMode::FULL_PROOF));
+ Assert(!isProofEnabled() || trn.getGenerator() != nullptr
+ || options().smt.unsatCores);
assertInternal(trn.getNode(), negated, removable, false, trn.getGenerator());
}
TNode node, bool negated, bool removable, bool input, ProofGenerator* pg)
{
// Assert as (possibly) removable
- if (options::unsatCoresMode() == options::UnsatCoresMode::ASSUMPTIONS)
+ if (options().smt.unsatCoresMode == options::UnsatCoresMode::ASSUMPTIONS)
{
if (input)
{
// Note this currently ignores conflicts (a dangerous practice).
d_theoryProxy->presolve();
- if(options::preprocessOnly()) {
+ if (options().base.preprocessOnly)
+ {
return Result(Result::SAT_UNKNOWN, Result::REQUIRES_FULL_CHECK);
}
void PropEngine::getUnsatCore(std::vector<Node>& core)
{
- Assert(options::unsatCoresMode() == options::UnsatCoresMode::ASSUMPTIONS);
+ Assert(options().smt.unsatCoresMode == options::UnsatCoresMode::ASSUMPTIONS);
std::vector<SatLiteral> unsat_assumptions;
d_satSolver->getUnsatAssumptions(unsat_assumptions);
for (const SatLiteral& lit : unsat_assumptions)
std::shared_ptr<ProofNode> PropEngine::getRefutation()
{
- Assert(options::unsatCoresMode() == options::UnsatCoresMode::ASSUMPTIONS);
+ Assert(options().smt.unsatCoresMode == options::UnsatCoresMode::ASSUMPTIONS);
std::vector<Node> core;
getUnsatCore(core);
CDProof cdp(d_env.getProofNodeManager());
#include "expr/node.h"
#include "proof/trust_node.h"
#include "prop/skolem_def_manager.h"
+#include "smt/env_obj.h"
#include "theory/output_channel.h"
#include "theory/skolem_lemma.h"
#include "util/result.h"
* PropEngine is the abstraction of a Sat Solver, providing methods for
* solving the SAT problem and conversion to CNF (via the CnfStream).
*/
-class PropEngine
+class PropEngine : protected EnvObj
{
public:
/**
* Create a PropEngine with a particular decision and theory engine.
*/
- PropEngine(TheoryEngine* te, Env& env);
+ PropEngine(Env& env, TheoryEngine* te);
/**
* Destructor.
/** The theory engine we will be using */
TheoryEngine* d_theoryEngine;
- /** Reference to the environment */
- Env& d_env;
-
/** The decision engine we will be using */
std::unique_ptr<decision::DecisionEngine> d_decisionEngine;
namespace cvc5 {
namespace prop {
-TheoryProxy::TheoryProxy(PropEngine* propEngine,
+TheoryProxy::TheoryProxy(Env& env,
+ PropEngine* propEngine,
TheoryEngine* theoryEngine,
decision::DecisionEngine* decisionEngine,
- SkolemDefManager* skdm,
- Env& env)
- : d_propEngine(propEngine),
+ SkolemDefManager* skdm)
+ : EnvObj(env),
+ d_propEngine(propEngine),
d_cnfStream(nullptr),
d_decisionEngine(decisionEngine),
d_dmNeedsActiveDefs(d_decisionEngine->needsActiveSkolemDefs()),
d_theoryEngine(theoryEngine),
d_queue(env.getContext()),
d_tpp(env, *theoryEngine),
- d_skdm(skdm),
- d_env(env)
+ d_skdm(skdm)
{
}
Node theoryExplanation = tte.getNode();
if (d_env.isSatProofProducing())
{
- Assert(options::unsatCoresMode() != options::UnsatCoresMode::FULL_PROOF
+ Assert(options().smt.unsatCoresMode != options::UnsatCoresMode::FULL_PROOF
|| tte.getGenerator());
d_propEngine->getProofCnfStream()->convertPropagation(tte);
}
#include "proof/trust_node.h"
#include "prop/registrar.h"
#include "prop/sat_solver_types.h"
+#include "smt/env_obj.h"
#include "theory/theory.h"
#include "theory/theory_preprocessor.h"
#include "util/resource_manager.h"
/**
* The proxy class that allows the SatSolver to communicate with the theories
*/
-class TheoryProxy : public Registrar
+class TheoryProxy : protected EnvObj, public Registrar
{
public:
- TheoryProxy(PropEngine* propEngine,
+ TheoryProxy(Env& env,
+ PropEngine* propEngine,
TheoryEngine* theoryEngine,
decision::DecisionEngine* decisionEngine,
- SkolemDefManager* skdm,
- Env& env);
+ SkolemDefManager* skdm);
~TheoryProxy();
/** The skolem definition manager */
SkolemDefManager* d_skdm;
-
- /** Reference to the environment */
- Env& d_env;
}; /* class TheoryProxy */
} // namespace prop
std::ostream& operator<<(std::ostream& out, const Model& m) {
options::ioutils::Scope scope(out);
options::ioutils::applyDagThresh(out, 0);
- Printer::getPrinter(options::outputLanguage())->toStream(out, m);
+ auto language = options::ioutils::getOutputLang(out);
+ Printer::getPrinter(language)->toStream(out, m);
return out;
}
* are unregistered by the obsolete PropEngine object before registered
* again by the new PropEngine object */
d_propEngine.reset(nullptr);
- d_propEngine.reset(new prop::PropEngine(d_theoryEngine.get(), d_env));
+ d_propEngine.reset(new prop::PropEngine(d_env, d_theoryEngine.get()));
Trace("smt-debug") << "Setting up theory engine..." << std::endl;
d_theoryEngine->setPropEngine(getPropEngine());
* statistics are unregistered by the obsolete PropEngine object before
* registered again by the new PropEngine object */
d_propEngine.reset(nullptr);
- d_propEngine.reset(new prop::PropEngine(d_theoryEngine.get(), d_env));
+ d_propEngine.reset(new prop::PropEngine(d_env, d_theoryEngine.get()));
d_theoryEngine->setPropEngine(getPropEngine());
// Notice that we do not reset TheoryEngine, nor does it require calling
// finishInit again. In particular, TheoryEngine::finishInit does not
<< rm->getTimeUsage() << ", resources "
<< rm->getResourceUsage() << endl;
- if ((options::solveRealAsInt() || options::solveIntAsBV() > 0)
+ if ((d_env.getOptions().smt.solveRealAsInt
+ || d_env.getOptions().smt.solveIntAsBV > 0)
&& result.asSatisfiabilityResult().isSat() == Result::UNSAT)
{
result = Result(Result::SAT_UNKNOWN, Result::UNKNOWN_REASON);
{
Assert(d_mode == options::SolveBVAsIntMode::BITWISE);
// Enforce semantics over individual bits with iextract and ites
- uint64_t granularity = options::BVAndIntegerGranularity();
+ uint64_t granularity = options().smt.BVAndIntegerGranularity;
Node iAndOp = d_nm->mkConst(IntAnd(bvsize));
Node iAnd = d_nm->mkNode(kind::IAND, iAndOp, x, y);
}
if( c[index].getType().isSort() ){
//for star: check if all children are defined and have generalizations
- if( c[index]==st ){ ///options::fmfFmcCoverSimplify()
- //check if all children exist and are complete
+ if (c[index] == st)
+ { /// option fmfFmcCoverSimplify
+ // check if all children exist and are complete
unsigned num_child_def =
d_child.size() - (d_child.find(st) != d_child.end() ? 1 : 0);
if (num_child_def == m->getRepSet()->getNumRepresentatives(tn))
#include "theory/quantifiers/instantiation_list.h"
#include "options/base_options.h"
+#include "options/io_utils.h"
#include "printer/printer.h"
namespace cvc5 {
void InstantiationList::initialize(Node q) { d_quant = q; }
std::ostream& operator<<(std::ostream& out, const InstantiationList& ilist)
{
- Printer::getPrinter(options::outputLanguage())->toStream(out, ilist);
+ auto language = options::ioutils::getOutputLang(out);
+ Printer::getPrinter(language)->toStream(out, ilist);
return out;
}
std::ostream& operator<<(std::ostream& out, const SkolemList& skl)
{
- Printer::getPrinter(options::outputLanguage())->toStream(out, skl);
+ auto language = options::ioutils::getOutputLang(out);
+ Printer::getPrinter(language)->toStream(out, skl);
return out;
}
bool QuantConflictFind::needsCheck( Theory::Effort level ) {
bool performCheck = false;
- if( options::quantConflictFind() && !d_conflict ){
+ if (options().quantifiers.quantConflictFind && !d_conflict)
+ {
if( level==Theory::EFFORT_LAST_CALL ){
- performCheck = options::qcfWhenMode() == options::QcfWhenMode::LAST_CALL;
+ performCheck =
+ options().quantifiers.qcfWhenMode == options::QcfWhenMode::LAST_CALL;
}else if( level==Theory::EFFORT_FULL ){
- performCheck = options::qcfWhenMode() == options::QcfWhenMode::DEFAULT;
+ performCheck =
+ options().quantifiers.qcfWhenMode == options::QcfWhenMode::DEFAULT;
}else if( level==Theory::EFFORT_STANDARD ){
- performCheck = options::qcfWhenMode() == options::QcfWhenMode::STD;
+ performCheck =
+ options().quantifiers.qcfWhenMode == options::QcfWhenMode::STD;
}
}
return performCheck;
if (tdb->hasTermCurrent(r))
{
TypeNode rtn = r.getType();
- if (!options::cegqi() || !TermUtil::hasInstConstAttr(r))
+ if (!options().quantifiers.cegqi || !TermUtil::hasInstConstAttr(r))
{
d_eqcs[rtn].push_back(r);
}
Trace("sygus-process") << "Post-simplify conjecture : " << q << std::endl;
Assert(q.getKind() == FORALL);
- if (options::sygusArgRelevant())
+ if (options().quantifiers.sygusArgRelevant)
{
// initialize the information about each function to synthesize
for (unsigned i = 0, size = q[0].getNumChildren(); i < size; i++)
bool SynthConjectureProcess::isArgRelevant(Node f, unsigned i)
{
- if (!options::sygusArgRelevant())
+ if (!options().quantifiers.sygusArgRelevant)
{
return true;
}
Trace("cegqi-debug") << "...squery : " << squery << std::endl;
squery = rewrite(squery);
Trace("cegqi-debug") << "...rewrites to : " << squery << std::endl;
- Assert(options::sygusRecFun()
+ Assert(options().quantifiers.sygusRecFun
|| (squery.isConst() && squery.getConst<bool>()));
}
}
// We are processing without single invocation techniques, now check if
// we should fix an invariant template (post-condition strengthening or
// pre-condition weakening).
- options::SygusInvTemplMode tmode = options::sygusInvTemplMode();
+ options::SygusInvTemplMode tmode = options().quantifiers.sygusInvTemplMode;
if (tmode != options::SygusInvTemplMode::NONE)
{
// currently only works for single predicate synthesis
{
tmode = options::SygusInvTemplMode::NONE;
}
- else if (!options::sygusInvTemplWhenSyntax())
+ else if (!options().quantifiers.sygusInvTemplWhenSyntax)
{
// only use invariant templates if no syntactic restrictions
if (CegGrammarConstructor::hasSyntaxRestrictions(q))
// construct template
Node templ;
- if (options::sygusInvAutoUnfold())
+ if (options().quantifiers.sygusInvAutoUnfold)
{
if (d_ti.isComplete())
{
for( size_t i=0; i<n.getNumChildren(); i++ ){
bool processChild = true;
if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- processChild =
- options::userPatternsQuant() == options::UserPatMode::IGNORE
- ? i == 1
- : i >= 1;
+ processChild = options().quantifiers.userPatternsQuant
+ == options::UserPatMode::IGNORE
+ ? i == 1
+ : i >= 1;
}
if( processChild ){
children.push_back( n[i] );
for( size_t i=0; i<n.getNumChildren(); i++ ){
bool processChild = true;
if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- processChild =
- options::userPatternsQuant() == options::UserPatMode::IGNORE
- ? i == 1
- : i >= 1;
+ processChild = options().quantifiers.userPatternsQuant
+ == options::UserPatMode::IGNORE
+ ? i == 1
+ : i >= 1;
}
if( processChild ){
if (isHandledApplyUf(n.getKind()))
d_initialized(thss->userContext(), false),
d_c_dec_strat(nullptr)
{
-
- if (options::ufssMode() == options::UfssMode::FULL)
+ if (options().uf.ufssMode == options::UfssMode::FULL)
{
// Register the strategy with the decision manager of the theory.
// We are guaranteed that the decision manager is ready since we
void SortModel::check(Theory::Effort level)
{
- Assert(options::ufssMode() == options::UfssMode::FULL);
+ Assert(options().uf.ufssMode == options::UfssMode::FULL);
if (!d_hasCard && d_state.isInConflict())
{
// not necessary to check
}
}
// we assert it positively, if its beyond the bound, abort
- if (options::ufssAbortCardinality() >= 0
- && c >= static_cast<uint32_t>(options::ufssAbortCardinality()))
+ if (options().uf.ufssAbortCardinality >= 0
+ && c >= static_cast<uint32_t>(options().uf.ufssAbortCardinality))
{
std::stringstream ss;
- ss << "Maximum cardinality (" << options::ufssAbortCardinality()
+ ss << "Maximum cardinality (" << options().uf.ufssAbortCardinality
<< ") for finite model finding exceeded." << std::endl;
throw LogicException(ss.str());
}