delete d_satSolver;
}
-void PropEngine::processAssertionsStart() {
- d_theoryEngine->preprocessStart();
-}
-
void PropEngine::assertFormula(TNode node) {
Assert(!d_inCheckSat, "Sat solver in solve()!");
Debug("prop") << "assertFormula(" << node << ")" << endl;
// Assert as non-removable
- d_cnfStream->convertAndAssert(d_theoryEngine->preprocess(node), false, false);
+ d_cnfStream->convertAndAssert(node, false, false);
}
void PropEngine::assertLemma(TNode node, bool negated, bool removable) {
*/
void shutdown() { }
- /**
- * Signal that a new round of assertions is ready so we can notify the theory engine
- */
- void processAssertionsStart();
-
/**
* Converts the given formula to CNF and assert the CNF to the SAT solver.
* The formula is asserted permanently for the current context.
/** Assertions to push to sat */
vector<Node> d_assertionsToCheck;
+ /** Map from skolem variables to index in d_assertionsToCheck containing
+ * corresponding introduced Boolean ite */
+ IteSkolemMap d_iteSkolemMap;
+
/** The top level substitutions */
theory::SubstitutionMap d_topLevelSubstitutions;
void SmtEnginePrivate::removeITEs() {
Trace("simplify") << "SmtEnginePrivate::removeITEs()" << endl;
- // Remove all of the ITE occurances and normalize
- RemoveITE::run(d_assertionsToCheck);
+ // Remove all of the ITE occurrences and normalize
+ RemoveITE::run(d_assertionsToCheck, d_iteSkolemMap);
for (unsigned i = 0; i < d_assertionsToCheck.size(); ++ i) {
d_assertionsToCheck[i] = theory::Rewriter::rewrite(d_assertionsToCheck[i]);
}
}
}
- d_smt.d_propEngine->processAssertionsStart();
+ // Call the theory preprocessors
+ d_smt.d_theoryEngine->preprocessStart();
+ for (unsigned i = 0; i < d_assertionsToCheck.size(); ++ i) {
+ d_assertionsToCheck[i] = d_smt.d_theoryEngine->preprocess(d_assertionsToCheck[i]);
+ }
+
+ // TODO: send formulas and iteSkolemMap to decision engine
// Push the formula to SAT
for (unsigned i = 0; i < d_assertionsToCheck.size(); ++ i) {
d_smt.d_propEngine->assertFormula(d_assertionsToCheck[i]);
}
d_assertionsToCheck.clear();
+ d_iteSkolemMap.clear();
}
void SmtEnginePrivate::addFormula(TNode n)
d_possiblePropagations(),
d_hasPropagated(context),
d_inConflict(context, false),
- d_sharedTermsExist(context, false),
+ d_sharedTermsExist(logicInfo.isSharingEnabled()),
d_hasShutDown(false),
d_incomplete(context, false),
d_sharedLiteralsIn(context),
if (multipleTheories) {
// Collect the shared terms if there are multipe theories
NodeVisitor<SharedTermsVisitor>::run(d_sharedTermsVisitor, preprocessed);
- // Mark the multiple theories flag
- d_sharedTermsExist = true;
}
}
TNode atom = negated ? node[0] : node;
Theory* theory = theoryOf(atom);
- //TODO: there is probably a bug here if shared terms start to exist after some asseritons have been processed
if (d_sharedTermsExist) {
// If any shared terms, notify the theories
/**
* Does the context contain terms shared among multiple theories.
*/
- context::CDO<bool> d_sharedTermsExist;
+ bool d_sharedTermsExist;
/**
* Explain the equality literals and push all the explaining literals
// Remove the ITEs and assert to prop engine
std::vector<Node> additionalLemmas;
+ IteSkolemMap iteSkolemMap;
additionalLemmas.push_back(node);
- RemoveITE::run(additionalLemmas);
+ RemoveITE::run(additionalLemmas, iteSkolemMap);
additionalLemmas[0] = theory::Rewriter::rewrite(additionalLemmas[0]);
d_propEngine->assertLemma(additionalLemmas[0], negated, removable);
for (unsigned i = 1; i < additionalLemmas.size(); ++ i) {
struct IteRewriteAttrTag {};
typedef expr::Attribute<IteRewriteAttrTag, Node> IteRewriteAttr;
-void RemoveITE::run(std::vector<Node>& output) {
+void RemoveITE::run(std::vector<Node>& output, IteSkolemMap& iteSkolemMap)
+{
for (unsigned i = 0, i_end = output.size(); i < i_end; ++ i) {
- output[i] = run(output[i], output);
+ output[i] = run(output[i], output, iteSkolemMap);
}
}
-Node RemoveITE::run(TNode node, std::vector<Node>& output) {
+Node RemoveITE::run(TNode node, std::vector<Node>& output,
+ IteSkolemMap& iteSkolemMap) {
// Current node
Debug("ite") << "removeITEs(" << node << ")" << endl;
nodeManager->setAttribute(node, IteRewriteAttr(), skolem);
// Remove ITEs from the new assertion, rewrite it and push it to the output
- output.push_back(run(newAssertion, output));
+ newAssertion = run(newAssertion, output, iteSkolemMap);
+ iteSkolemMap[skolem] = output.size();
+ output.push_back(newAssertion);
// The representation is now the skolem
return skolem;
}
// Remove the ITEs from the children
for(TNode::const_iterator it = node.begin(), end = node.end(); it != end; ++it) {
- Node newChild = run(*it, output);
+ Node newChild = run(*it, output, iteSkolemMap);
somethingChanged |= (newChild != *it);
newChildren.push_back(newChild);
}
namespace CVC4 {
+typedef std::hash_map<Node, unsigned, NodeHashFunction> IteSkolemMap;
+
class RemoveITE {
public:
/**
* Removes the ITE nodes by introducing skolem variables. All additional assertions are pushed into assertions.
+ * iteSkolemMap contains a map from introduced skolem variables to the index in assertions containing the new
+ * Boolean ite created in conjunction with that skolem variable.
*/
- static void run(std::vector<Node>& assertions);
+ static void run(std::vector<Node>& assertions, IteSkolemMap& iteSkolemMap);
/**
* Removes the ITE from the node by introducing skolem variables. All additional assertions are pushed into assertions.
+ * iteSkolemMap contains a map from introduced skolem variables to the index in assertions containing the new
+ * Boolean ite created in conjunction with that skolem variable.
*/
- static Node run(TNode node, std::vector<Node>& additionalAssertions);
+ static Node run(TNode node, std::vector<Node>& additionalAssertions,
+ IteSkolemMap& iteSkolemMap);
};/* class RemoveTTE */