/** Gets the next decision based on strategies that are enabled */
SatLiteral getNext(bool &stopSearch) {
- NodeManager::currentResourceManager()->spendResource();
+ NodeManager::currentResourceManager()->spendResource(options::decisionStep());
Assert(d_cnfStream != NULL,
"Forgot to set cnfStream for decision engine?");
Assert(d_satSolver != NULL,
#include "util/output.h"
#include "util/resource_manager.h"
#include "options/options.h"
+#include "smt/options.h"
using namespace std;
using namespace CVC4::kind;
dynamic_cast<QuitCommand*>(cmd) == NULL) {
// don't count set-option commands as to not get stuck in an infinite
// loop of resourcing out
- d_resourceManager->spendResource();
+ d_resourceManager->spendResource(d_exprManager->getOptions()[options::parseStep]);
}
return cmd;
}
Expr Parser::nextExpression() throw(ParserException, UnsafeInterruptException) {
Debug("parser") << "nextExpression()" << std::endl;
- d_resourceManager->spendResource();
+ d_resourceManager->spendResource(d_exprManager->getOptions()[options::parseStep]);
Expr result;
if(!done()) {
try {
d_notify->notify(satClause);
}
- void spendResource() {
- d_notify->spendResource();
+ void spendResource(uint64_t ammount) {
+ d_notify->spendResource(ammount);
}
- void safePoint() {
- d_notify->safePoint();
+ void safePoint(uint64_t ammount) {
+ d_notify->safePoint(ammount);
}
};
#include "util/utility.h"
#include "util/exception.h"
#include "theory/bv/options.h"
+#include "smt/options.h"
#include "theory/interrupted.h"
using namespace BVMinisat;
// NO CONFLICT
bool isWithinBudget;
try {
- isWithinBudget = withinBudget();
+ isWithinBudget = withinBudget(CVC4::options::bvSatConflictStep());
}
catch (const CVC4::theory::Interrupted& e) {
// do some clean-up and rethrow
while (status == l_Undef){
double rest_base = luby_restart ? luby(restart_inc, curr_restarts) : pow(restart_inc, curr_restarts);
status = search(rest_base * restart_first);
- if (!withinBudget()) break;
+ if (!withinBudget(CVC4::options::bvSatConflictStep())) break;
curr_restarts++;
}
*/
virtual void notify(vec<Lit>& learnt) = 0;
- virtual void spendResource() = 0;
- virtual void safePoint() = 0;
+ virtual void spendResource(uint64_t ammount) = 0;
+ virtual void safePoint(uint64_t ammount) = 0;
};
//=================================================================================================
CRef reason (Var x) const;
int level (Var x) const;
double progressEstimate () const; // DELETE THIS ?? IT'S NOT VERY USEFUL ...
- bool withinBudget () const;
+ bool withinBudget (uint64_t ammount) const;
// Static helpers:
//
inline void Solver::interrupt(){ asynch_interrupt = true; }
inline void Solver::clearInterrupt(){ asynch_interrupt = false; }
inline void Solver::budgetOff(){ conflict_budget = propagation_budget = -1; }
-inline bool Solver::withinBudget() const {
+inline bool Solver::withinBudget(uint64_t ammount) const {
Assert (notify);
- notify->spendResource();
- notify->safePoint();
+ notify->spendResource(ammount);
+ notify->safePoint(0);
return !asynch_interrupt &&
(conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
Debug("cnf") << "convertAndAssert(" << node << ", negated = " << (negated ? "true" : "false") << ")" << endl;
if (d_convertAndAssertCounter % ResourceManager::getFrequencyCount() == 0) {
- NodeManager::currentResourceManager()->spendResource();
+ NodeManager::currentResourceManager()->spendResource(options::cnfStep());
d_convertAndAssertCounter = 0;
}
++d_convertAndAssertCounter;
check_type = CHECK_WITH_THEORY;
}
- if (nof_conflicts >= 0 && conflictC >= nof_conflicts || !withinBudget()) {
+ if (nof_conflicts >= 0 && conflictC >= nof_conflicts ||
+ !withinBudget(options::satConflictStep())) {
// Reached bound on number of conflicts:
progress_estimate = progressEstimate();
cancelUntil(0);
while (status == l_Undef){
double rest_base = luby_restart ? luby(restart_inc, curr_restarts) : pow(restart_inc, curr_restarts);
status = search(rest_base * restart_first);
- if (!withinBudget()) break;
+ if (!withinBudget(options::satConflictStep())) break; // FIXME add restart option?
curr_restarts++;
}
- if(!withinBudget())
+ if(!withinBudget(options::satConflictStep()))
status = l_Undef;
if (verbosity >= 1)
Debug("minisat::lemmas") << "Solver::updateLemmas() begin" << std::endl;
// Avoid adding lemmas indefinitely without resource-out
- proxy->spendResource();
+ proxy->spendResource(options::lemmaStep());
CRef conflict = CRef_Undef;
return conflict;
}
-inline bool Solver::withinBudget() const {
+inline bool Solver::withinBudget(uint64_t ammount) const {
Assert (proxy);
// spendResource sets async_interrupt or throws UnsafeInterruptException
// depending on whether hard-limit is enabled
- proxy->spendResource();
+ proxy->spendResource(ammount);
bool within_budget = !asynch_interrupt &&
(conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
int trail_index (Var x) const; // Index in the trail
double progressEstimate () const; // DELETE THIS ?? IT'S NOT VERY USEFUL ...
public:
- bool withinBudget () const;
+ bool withinBudget (uint64_t amount) const;
protected:
// Static helpers:
Debug("prop") << "interrupt()" << endl;
}
-void PropEngine::spendResource() throw (UnsafeInterruptException) {
- d_resourceManager->spendResource();
+void PropEngine::spendResource(uint64_t ammount) throw (UnsafeInterruptException) {
+ d_resourceManager->spendResource(ammount);
}
bool PropEngine::properExplanation(TNode node, TNode expl) const {
* Informs the ResourceManager that a resource has been spent. If out of
* resources, can throw an UnsafeInterruptException exception.
*/
- void spendResource() throw (UnsafeInterruptException);
+ void spendResource(uint64_t ammount) throw (UnsafeInterruptException);
/**
* For debugging. Return true if "expl" is a well-formed
* Notify about a learnt clause.
*/
virtual void notify(SatClause& clause) = 0;
- virtual void spendResource() = 0;
- virtual void safePoint() = 0;
+ virtual void spendResource(uint64_t ammount) = 0;
+ virtual void safePoint(uint64_t ammount) = 0;
};/* class BVSatSolverInterface::Notify */
}
void TheoryProxy::notifyRestart() {
- d_propEngine->spendResource();
+ d_propEngine->spendResource(options::restartStep());
d_theoryEngine->notifyRestart();
static uint32_t lemmaCount = 0;
#endif /* CVC4_REPLAY */
}
-void TheoryProxy::spendResource() {
- d_theoryEngine->spendResource();
+void TheoryProxy::spendResource(uint64_t ammount) {
+ d_theoryEngine->spendResource(ammount);
}
bool TheoryProxy::isDecisionRelevant(SatVariable var) {
void logDecision(SatLiteral lit);
- void spendResource();
+ void spendResource(uint64_t ammount);
bool isDecisionEngineDone();
common-option cpuTime cpu-time --cpu-time bool :default false
measures CPU time if set to true and wall time if false (default false)
+# Resource spending options for SPARK
+expert-option rewriteStep rewrite-step --rewrite-step uint64_t :default 1
+ ammount of resources spent for each rewrite step
+
+expert-option theoryCheckStep theory-check-step --theory-check-step uint64_t :default 1
+ ammount of resources spent for each theory check call
+
+expert-option decisionStep decision-step --decision-step uint64_t :default 1
+ ammount of getNext decision calls in the decision engine
+
+expert-option bitblastStep bitblast-step --bitblast-step uint64_t :default 1
+ ammount of resources spent for each bitblast step
+
+expert-option parseStep parse-step --parse-step uint64_t :default 1
+ ammount of resources spent for each command/expression parsing
+
+expert-option lemmaStep lemma-step --lemma-step uint64_t :default 1
+ ammount of resources spent when adding lemmas
+
+expert-option restartStep restart-step --restart-step uint64_t :default 1
+ ammount of resources spent for each theory restart
+
+expert-option cnfStep cnf-step --cnf-step uint64_t :default 1
+ ammount of resources spent for each call to cnf conversion
+
+expert-option preprocessStep preprocess-step --preprocess-step uint64_t :default 1
+ ammount of resources spent for each preprocessing step in SmtEngine
+
+expert-option quantifierStep quantifier-step --quantifier-step uint64_t :default 1
+ ammount of resources spent for quantifier instantiations
+
+expert-option satConflictStep sat-conflict-step --sat-conflict-step uint64_t :default 1
+ ammount of resources spent for each sat conflict (main sat solver)
+
+expert-option bvSatConflictStep bv-sat-conflict-step --bv-sat-conflict-step uint64_t :default 1
+ ammount of resources spent for each sat conflict (bitvectors)
+
+
expert-option rewriteApplyToConst rewrite-apply-to-const --rewrite-apply-to-const bool :default false
eliminate function applications, rewriting e.g. f(5) to a new symbol f_5
}
ResourceManager* getResourceManager() { return d_resourceManager; }
- void spendResource() throw(UnsafeInterruptException) {
- d_resourceManager->spendResource();
+ void spendResource(uint64_t ammount) throw(UnsafeInterruptException) {
+ d_resourceManager->spendResource(ammount);
}
void nmNotifyNewSort(TypeNode tn, uint32_t flags) {
// or upward pass).
do {
- spendResource();
+ spendResource(options::preprocessStep());
n = worklist.top().first; // n is the input / original
Node node = worklist.top().second; // node is the output / result
bool childrenPushed = worklist.top().third;
void SmtEnginePrivate::removeITEs() {
d_smt.finalOptionsAreSet();
- spendResource();
+ spendResource(options::preprocessStep());
Trace("simplify") << "SmtEnginePrivate::removeITEs()" << endl;
// Remove all of the ITE occurrences and normalize
void SmtEnginePrivate::staticLearning() {
d_smt.finalOptionsAreSet();
- spendResource();
+ spendResource(options::preprocessStep());
TimerStat::CodeTimer staticLearningTimer(d_smt.d_stats->d_staticLearningTime);
// returns false if it learns a conflict
bool SmtEnginePrivate::nonClausalSimplify() {
- spendResource();
+ spendResource(options::preprocessStep());
d_smt.finalOptionsAreSet();
if(options::unsatCores()) {
void SmtEnginePrivate::bvToBool() {
Trace("bv-to-bool") << "SmtEnginePrivate::bvToBool()" << endl;
- spendResource();
+ spendResource(options::preprocessStep());
std::vector<Node> new_assertions;
d_smt.d_theoryEngine->ppBvToBool(d_assertions.ref(), new_assertions);
for (unsigned i = 0; i < d_assertions.size(); ++ i) {
bool SmtEnginePrivate::simpITE() {
TimerStat::CodeTimer simpITETimer(d_smt.d_stats->d_simpITETime);
- spendResource();
+ spendResource(options::preprocessStep());
Trace("simplify") << "SmtEnginePrivate::simpITE()" << endl;
unsigned numAssertionOnEntry = d_assertions.size();
for (unsigned i = 0; i < d_assertions.size(); ++i) {
- spendResource();
+ spendResource(options::preprocessStep());
Node result = d_smt.d_theoryEngine->ppSimpITE(d_assertions[i]);
d_assertions.replace(i, result);
if(result.isConst() && !result.getConst<bool>()){
void SmtEnginePrivate::unconstrainedSimp() {
TimerStat::CodeTimer unconstrainedSimpTimer(d_smt.d_stats->d_unconstrainedSimpTime);
- spendResource();
+ spendResource(options::preprocessStep());
Trace("simplify") << "SmtEnginePrivate::unconstrainedSimp()" << endl;
d_smt.d_theoryEngine->ppUnconstrainedSimp(d_assertions.ref());
}
// returns false if simplification led to "false"
bool SmtEnginePrivate::simplifyAssertions()
throw(TypeCheckingException, LogicException, UnsafeInterruptException) {
- spendResource();
+ spendResource(options::preprocessStep());
Assert(d_smt.d_pendingPops == 0);
try {
ScopeCounter depth(d_simplifyAssertionsDepth);
Node SmtEnginePrivate::rewriteBooleanTerms(TNode n) {
TimerStat::CodeTimer codeTimer(d_smt.d_stats->d_rewriteBooleanTermsTime);
- spendResource();
+ spendResource(options::preprocessStep());
if(d_booleanTermConverter == NULL) {
// This needs to be initialized _after_ the whole SMT framework is in place, subscribed
void SmtEnginePrivate::processAssertions() {
TimerStat::CodeTimer paTimer(d_smt.d_stats->d_processAssertionsTime);
- spendResource();
+ spendResource(options::preprocessStep());
Assert(d_smt.d_fullyInited);
Assert(d_smt.d_pendingPops == 0);
<< "applying substitutions" << endl;
for (unsigned i = 0; i < d_assertions.size(); ++ i) {
Trace("simplify") << "applying to " << d_assertions[i] << endl;
- spendResource();
+ spendResource(options::preprocessStep());
d_assertions.replace(i, Rewriter::rewrite(d_topLevelSubstitutions.apply(d_assertions[i])));
Trace("simplify") << " got " << d_assertions[i] << endl;
}
}
Expr SmtEngine::expandDefinitions(const Expr& ex) throw(TypeCheckingException, LogicException, UnsafeInterruptException) {
- d_private->spendResource();
+ d_private->spendResource(options::preprocessStep());
Assert(ex.getExprManager() == d_exprManager);
SmtScope smts(this);
#include "theory/arith/theory_arith.h"
#include "theory/arith/theory_arith_private.h"
#include "theory/arith/infer_bounds.h"
+#include "smt/options.h"
using namespace std;
using namespace CVC4::kind;
}
void TheoryArith::check(Effort effortLevel){
+ getOutputChannel().spendResource(options::theoryCheckStep());
d_internal->check(effortLevel);
}
#include "expr/command.h"
#include "theory/theory_model.h"
#include "theory/arrays/options.h"
+#include "smt/options.h"
#include "smt/logic_exception.h"
if (done() && !fullEffort(e)) {
return;
}
+
+ getOutputChannel().spendResource(options::theoryCheckStep());
+
TimerStat::CodeTimer checkTimer(d_checkTime);
while (!done() && !d_conflict)
int numrestarts = 0;
while (true || numrestarts < 1 || fullEffort(e) || combination(e)) {
++numrestarts;
- d_out->safePoint();
+ d_out->safePoint(1);
int level = getSatContext()->getLevel();
d_getModelValCache.clear();
for (constraintIdx = 0; constraintIdx < d_modelConstraints.size(); ++constraintIdx) {
{}
bool notify(prop::SatLiteral lit);
void notify(prop::SatClause& clause);
- void spendResource();
- void safePoint();
+ void spendResource(uint64_t ammount);
+ void safePoint(uint64_t ammount);
};
TheoryBV *d_bv;
MinisatEmptyNotify() {}
bool notify(prop::SatLiteral lit) { return true; }
void notify(prop::SatClause& clause) { }
- void spendResource() {
- NodeManager::currentResourceManager()->spendResource();
+ void spendResource(uint64_t ammount) {
+ NodeManager::currentResourceManager()->spendResource(ammount);
}
- void safePoint() {}
+ void safePoint(uint64_t ammount) {}
};
}
void EagerBitblastSolver::assertFormula(TNode formula) {
- d_bv->spendResource();
+ d_bv->spendResource(1);
Assert (isInitialized());
Debug("bitvector-eager") << "EagerBitblastSolver::assertFormula "<< formula <<"\n";
d_assertionSet.insert(formula);
// We need to ensure we are fully propagated, so propagate now
if (d_useSatPropagation) {
- d_bv->spendResource();
+ d_bv->spendResource(1);
bool ok = d_bitblaster->propagate();
if (!ok) {
std::vector<TNode> conflictAtoms;
#include "theory/bv/slicer.h"
#include "theory/theory_model.h"
#include "theory/bv/options.h"
+#include "smt/options.h"
using namespace std;
using namespace CVC4;
bool CoreSolver::check(Theory::Effort e) {
Trace("bitvector::core") << "CoreSolver::check \n";
- d_bv->spendResource();
+ d_bv->spendResource(options::theoryCheckStep());
d_checkCalled = true;
Assert (!d_bv->inConflict());
#include "theory/bv/theory_bv.h"
#include "theory/bv/theory_bv_utils.h"
#include "theory/theory_model.h"
+#include "smt/options.h"
using namespace std;
using namespace CVC4;
bool InequalitySolver::check(Theory::Effort e) {
Debug("bv-subtheory-inequality") << "InequalitySolveR::check("<< e <<")\n";
++(d_statistics.d_numCallstoCheck);
- d_bv->spendResource();
+ d_bv->spendResource(options::theoryCheckStep());
bool ok = true;
while (!done() && ok) {
return;
}
- d_bv->spendResource();
+ d_bv->spendResource(options::bitblastStep());
Debug("bitvector-bitblast") << "Bitblasting node " << node <<"\n";
d_termBBStrategies[node.getKind()] (node, bits, this);
return;
}
- d_bv->spendResource();
+ d_bv->spendResource(options::bitblastStep());
Debug("bitvector-bitblast") << "Bitblasting node " << node <<"\n";
++d_statistics.d_numTerms;
}
}
-void TLazyBitblaster::MinisatNotify::spendResource() {
- d_bv->spendResource();
+void TLazyBitblaster::MinisatNotify::spendResource(uint64_t ammount) {
+ d_bv->spendResource(ammount);
}
-void TLazyBitblaster::MinisatNotify::safePoint() {
- d_bv->d_out->safePoint();
+void TLazyBitblaster::MinisatNotify::safePoint(uint64_t ammount) {
+ d_bv->d_out->safePoint(ammount);
}
}
}
-void TheoryBV::spendResource() throw(UnsafeInterruptException) {
- getOutputChannel().spendResource();
+void TheoryBV::spendResource(uint64_t ammount) throw(UnsafeInterruptException) {
+ getOutputChannel().spendResource(ammount);
}
TheoryBV::Statistics::Statistics():
Statistics d_statistics;
- void spendResource() throw(UnsafeInterruptException);
+ void spendResource(uint64_t ammount) throw(UnsafeInterruptException);
/**
* Return the uninterpreted function symbol corresponding to division-by-zero
* With safePoint(), the theory signals that it is at a safe point
* and can be interrupted.
*/
- virtual void safePoint() throw(Interrupted, UnsafeInterruptException, AssertionException) {
+ virtual void safePoint(uint64_t ammount) throw(Interrupted, UnsafeInterruptException, AssertionException) {
}
/**
* long-running operations, they cannot rely on resource() to break
* out of infinite or intractable computations.
*/
- virtual void spendResource() throw(UnsafeInterruptException) {}
+ virtual void spendResource(uint64_t ammount) throw(UnsafeInterruptException) {}
/**
* Handle user attribute.
bool QuantifiersEngine::addInstantiation( Node f, std::vector< Node >& terms, bool mkRep, bool modEq, bool modInst ) {
// For resource-limiting (also does a time check).
- getOutputChannel().safePoint();
+ getOutputChannel().safePoint(options::quantifierStep());
Assert( terms.size()==f[0].getNumChildren() );
Trace("inst-add-debug") << "Add instantiation: ";
if (hasSmtEngine &&
d_iterationCount % ResourceManager::getFrequencyCount() == 0) {
- rm->spendResource();
+ rm->spendResource(options::rewriteStep());
d_iterationCount = 0;
}
return th->entailmentCheck(lit, params, seffects);
}
-void TheoryEngine::spendResource() {
- d_resourceManager->spendResource();
+void TheoryEngine::spendResource(uint64_t ammount) {
+ d_resourceManager->spendResource(ammount);
}
{
}
- void safePoint() throw(theory::Interrupted, UnsafeInterruptException, AssertionException) {
- spendResource();
+ void safePoint(uint64_t ammount) throw(theory::Interrupted, UnsafeInterruptException, AssertionException) {
+ spendResource(ammount);
if (d_engine->d_interrupted) {
throw theory::Interrupted();
}
d_engine->setIncomplete(d_theory);
}
- void spendResource() throw(UnsafeInterruptException) {
- d_engine->spendResource();
+ void spendResource(uint64_t ammount) throw(UnsafeInterruptException) {
+ d_engine->spendResource(ammount);
}
void handleUserAttribute( const char* attr, theory::Theory* t ){
/**
* "Spend" a resource during a search or preprocessing.
*/
- void spendResource();
+ void spendResource(uint64_t ammount);
/**
* Adds a theory. Only one theory per TheoryId can be present, so if
~TestOutputChannel() {}
- void safePoint() throw(Interrupted, AssertionException) {}
+ void safePoint(uint64_t ammount) throw(Interrupted, AssertionException) {}
void conflict(TNode n)
throw(AssertionException, UnsafeInterruptException) {
#include "theory/uf/theory_uf.h"
#include "theory/uf/options.h"
+#include "smt/options.h"
#include "theory/quantifiers/options.h"
#include "theory/uf/theory_uf_strong_solver.h"
#include "theory/theory_model.h"
if (done() && !fullEffort(level)) {
return;
}
-
+ getOutputChannel().spendResource(options::theoryCheckStep());
TimerStat::CodeTimer checkTimer(d_checkTime);
while (!done() && !d_conflict)
return d_thisCallTimeBudget - time_passed;
}
-void ResourceManager::spendResource() throw (UnsafeInterruptException) {
+void ResourceManager::spendResource(uint64_t ammount) throw (UnsafeInterruptException) {
++d_spendResourceCalls;
- ++d_cumulativeResourceUsed;
+ d_cumulativeResourceUsed += ammount;
if (!d_on) return;
Debug("limit") << "ResourceManager::spendResource()" << std::endl;
- ++d_thisCallResourceUsed;
+ d_thisCallResourceUsed += ammount;
if(out()) {
Trace("limit") << "ResourceManager::spendResource: interrupt!" << std::endl;
Trace("limit") << " on call " << d_spendResourceCalls << std::endl;
return d_thisCallResourceBudget;
}
- void spendResource() throw(UnsafeInterruptException);
+ void spendResource(uint64_t ammount) throw(UnsafeInterruptException);
void setHardLimit(bool value);
void setResourceLimit(uint64_t units, bool cumulative = false);