//Assert(d_inCheckSat, "Sat solver should be in solve()!");
Debug("prop::lemmas") << "assertLemma(" << node << ")" << endl;
- if(Dump.isOn("lemmas")) {
- Dump("lemmas") << AssertCommand(node.toExpr());
- }
-
// Assert as removable
d_cnfStream->convertAndAssert(node, removable, negated);
}
}
Node TheoryArith::ppRewrite(TNode atom) {
- CodeTimer timer(d_ppRewriteTimer);
+ CodeTimer timer(d_ppRewriteTimer, /* allow_reentrant = */ true);
return d_internal->ppRewrite(atom);
}
*
* @param n - a theory lemma valid at decision level 0
* @param removable - whether the lemma can be removed at any point
+ * @param preprocess - whether to apply more aggressive preprocessing
* @return the "status" of the lemma, including user level at which
* the lemma resides; the lemma will be removed when this user level pops
*/
- virtual LemmaStatus lemma(TNode n, bool removable = false)
+ virtual LemmaStatus lemma(TNode n, bool removable = false,
+ bool preprocess = false)
throw(TypeCheckingExceptionPrivate, AssertionException) = 0;
/**
nn = nn.substitute( vars.begin(), vars.end(), subs.begin(), subs.end() );
Node lem = NodeManager::currentNM()->mkNode( LEQ, nn, d_range[f][v] );
Trace("bound-int-lemma") << "*** Add lemma to minimize instantiated non-ground term " << lem << std::endl;
- d_quantEngine->getOutputChannel().lemma(lem);
+ d_quantEngine->getOutputChannel().lemma(lem, false, true);
l = Node::null();
u = Node::null();
return;
nb << f << ceLit;
Node lem = nb;
Trace("cbqi") << "Counterexample lemma : " << lem << std::endl;
- d_quantEngine->getOutputChannel().lemma( lem );
+ d_quantEngine->getOutputChannel().lemma( lem, false, true );
addedLemma = true;
}
}
option internalReps /--disable-quant-internal-reps bool :default true
disables instantiating with representatives chosen by quantifiers engine
-option finiteModelFind --finite-model-find bool :default false :read-write
+option finiteModelFind finite-model-find --finite-model-find bool :default false :read-write
use finite model finding heuristic for quantifier instantiation
option mbqiMode --mbqi=MODE CVC4::theory::quantifiers::MbqiMode :read-write :default CVC4::theory::quantifiers::MBQI_DEFAULT :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToMbqiMode :handler-include "theory/quantifiers/options_handlers.h" :predicate CVC4::theory::quantifiers::checkMbqiMode :predicate-include "theory/quantifiers/options_handlers.h"
//flush pending lemmas
if( !d_pending_lemmas.empty() ){
for( unsigned i=0; i<d_pending_lemmas.size(); i++ ){
- getStrongSolver()->getOutputChannel().lemma( d_pending_lemmas[i] );
+ getStrongSolver()->getOutputChannel().lemma( d_pending_lemmas[i], false, true );
++( getStrongSolver()->d_statistics.d_sym_break_lemmas );
}
d_pending_lemmas.clear();
nb << n[0] << body.notNode();
Node lem = nb;
Trace("quantifiers-sk") << "Skolemize lemma : " << lem << std::endl;
- d_out->lemma( lem );
+ d_out->lemma( lem, false, true );
d_skolemized[n] = true;
}
}
bool flipDecision();
void setUserAttribute( const std::string& attr, Node n );
eq::EqualityEngine* getMasterEqualityEngine() { return d_masterEqualityEngine; }
+ bool ppDontRewriteSubterm(TNode atom) { return atom.getKind() == kind::FORALL || atom.getKind() == kind::EXISTS; }
private:
void assertUniversal( Node n );
void assertExistential( Node n );
Debug("inst-engine-debug") << "Adding lemma : " << lem << std::endl;
lem = Rewriter::rewrite(lem);
if( d_lemmas_produced_c.find( lem )==d_lemmas_produced_c.end() ){
- //d_curr_out->lemma( lem );
+ //d_curr_out->lemma( lem, false, true );
d_lemmas_produced_c[ lem ] = true;
d_lemmas_waiting.push_back( lem );
Debug("inst-engine-debug") << "Added lemma : " << lem << std::endl;
//take default output channel if none is provided
d_hasAddedLemma = true;
for( int i=0; i<(int)d_lemmas_waiting.size(); i++ ){
- out->lemma( d_lemmas_waiting[i] );
+ out->lemma( d_lemmas_waiting[i], false, true );
}
d_lemmas_waiting.clear();
}
Theory::PPAssertStatus ppAssert(TNode in, SubstitutionMap& outSubstitutions);
- bool ppDontRewriteSubterm(TNode atom){ return true; }
+ bool ppDontRewriteSubterm(TNode atom) { return true; }
private:
// We need to split on it
Debug("sharing") << "TheoryEngine::combineTheories(): requesting a split " << endl;
- lemma(equality.orNode(equality.notNode()), false, false, carePair.theory);
+ lemma(equality.orNode(equality.notNode()), false, false, false, carePair.theory);
}
}
Node newTerm;
if (theoryOf(term)->ppDontRewriteSubterm(term)) {
- newTerm = term;
+ newTerm = Rewriter::rewrite(term);
} else {
NodeBuilder<> newNode(term.getKind());
if (term.getMetaKind() == kind::metakind::PARAMETERIZED) {
}
}
-theory::LemmaStatus TheoryEngine::lemma(TNode node, bool negated, bool removable, theory::TheoryId atomsTo) {
+theory::LemmaStatus TheoryEngine::lemma(TNode node, bool negated, bool removable, bool preprocess, theory::TheoryId atomsTo) {
// Do we need to check atoms
if (atomsTo != theory::THEORY_LAST) {
options::lemmaOutputChannel()->notifyNewLemma(node.toExpr());
}
+ // Run theory preprocessing, maybe
+ Node ppNode = preprocess ? this->preprocess(node) : Node(node);
+
// Remove the ITEs
std::vector<Node> additionalLemmas;
IteSkolemMap iteSkolemMap;
- additionalLemmas.push_back(node);
+ additionalLemmas.push_back(ppNode);
d_iteRemover.run(additionalLemmas, iteSkolemMap);
additionalLemmas[0] = theory::Rewriter::rewrite(additionalLemmas[0]);
if(Debug.isOn("lemma-ites")) {
- Debug("lemma-ites") << "removed ITEs from lemma: " << node << endl;
+ Debug("lemma-ites") << "removed ITEs from lemma: " << ppNode << endl;
Debug("lemma-ites") << " + now have the following "
<< additionalLemmas.size() << " lemma(s):" << endl;
for(std::vector<Node>::const_iterator i = additionalLemmas.begin();
Node fullConflict = mkExplanation(explanationVector);
Debug("theory::conflict") << "TheoryEngine::conflict(" << conflict << ", " << theoryId << "): full = " << fullConflict << endl;
Assert(properConflict(fullConflict));
- lemma(fullConflict, true, true, THEORY_LAST);
+ lemma(fullConflict, true, true, false, THEORY_LAST);
} else {
// When only one theory, the conflict should need no processing
Assert(properConflict(conflict));
- lemma(conflict, true, true, THEORY_LAST);
+ lemma(conflict, true, true, false, THEORY_LAST);
}
}
return d_engine->propagate(literal, d_theory);
}
- theory::LemmaStatus lemma(TNode lemma, bool removable = false) throw(TypeCheckingExceptionPrivate, AssertionException) {
+ theory::LemmaStatus lemma(TNode lemma, bool removable = false, bool preprocess = false) throw(TypeCheckingExceptionPrivate, AssertionException) {
Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma(" << lemma << ")" << std::endl;
++ d_statistics.lemmas;
d_engine->d_outputChannelUsed = true;
- return d_engine->lemma(lemma, false, removable, theory::THEORY_LAST);
+ return d_engine->lemma(lemma, false, removable, preprocess, theory::THEORY_LAST);
}
theory::LemmaStatus splitLemma(TNode lemma, bool removable = false) throw(TypeCheckingExceptionPrivate, AssertionException) {
Trace("theory::lemma") << "EngineOutputChannel<" << d_theory << ">::lemma(" << lemma << ")" << std::endl;
++ d_statistics.lemmas;
d_engine->d_outputChannelUsed = true;
- return d_engine->lemma(lemma, false, removable, d_theory);
+ return d_engine->lemma(lemma, false, removable, false, d_theory);
}
void demandRestart() throw(TypeCheckingExceptionPrivate, AssertionException) {
* @param removable can the lemma be remove (restrictions apply)
* @param needAtoms if not THEORY_LAST, then
*/
- theory::LemmaStatus lemma(TNode node, bool negated, bool removable, theory::TheoryId atomsTo);
+ theory::LemmaStatus lemma(TNode node, bool negated, bool removable, bool preprocess, theory::TheoryId atomsTo);
/** Enusre that the given atoms are send to the given theory */
void ensureLemmaAtoms(const std::vector<TNode>& atoms, theory::TheoryId theory);
push(PROPAGATE_AS_DECISION, n);
}
- LemmaStatus lemma(TNode n, bool removable) throw(AssertionException) {
+ LemmaStatus lemma(TNode n, bool removable, bool preprocess) throw(AssertionException) {
push(LEMMA, n);
return LemmaStatus(Node::null(), 0);
}
*/
class CodeTimer {
TimerStat& d_timer;
+ bool d_reentrant;
/** Private copy constructor undefined (no copy permitted). */
CodeTimer(const CodeTimer& timer) CVC4_UNDEFINED;
CodeTimer& operator=(const CodeTimer& timer) CVC4_UNDEFINED;
public:
- CodeTimer(TimerStat& timer) : d_timer(timer) {
- d_timer.start();
+ CodeTimer(TimerStat& timer, bool allow_reentrant = false) : d_timer(timer), d_reentrant(false) {
+ if(!allow_reentrant || !(d_reentrant = d_timer.running())) {
+ d_timer.start();
+ }
}
~CodeTimer() {
- d_timer.stop();
+ if(!d_reentrant) {
+ d_timer.stop();
+ }
}
};/* class CodeTimer */
void propagateAsDecision(TNode n) throw(AssertionException) {
Unimplemented();
}
- LemmaStatus lemma(TNode n, bool removable) throw(AssertionException) {
+ LemmaStatus lemma(TNode n, bool removable, bool preprocess) throw(AssertionException) {
Unimplemented();
}
void requirePhase(TNode, bool) throw(AssertionException) {
// ignore
}
- LemmaStatus lemma(TNode n, bool removable)
+ LemmaStatus lemma(TNode n, bool removable = false, bool preprocess = false)
throw(AssertionException) {
push(LEMMA, n);
return LemmaStatus(Node::null(), 0);
void testOutputChannel() {
Node n = atom0.orNode(atom1);
- d_outputChannel.lemma(n, false);
+ d_outputChannel.lemma(n);
d_outputChannel.split(atom0);
Node s = atom0.orNode(atom0.notNode());
TS_ASSERT_EQUALS(d_outputChannel.d_callHistory.size(), 2u);