Includes proper set up of the proof equality engine it uses (which may be shared over multiple theories). Also makes its assertEquality method robust to non-equality atoms.
*/
virtual TrustNode explain(TNode literal, TheoryId id) = 0;
/**
- * Assert equality to the shared terms database.
+ * Assert n to the shared terms database.
*
* This method is called by TheoryEngine when a fact has been marked to
* send to THEORY_BUILTIN, meaning that shared terms database should
- * maintain this fact. This is the case when either an equality is
- * asserted from the SAT solver or a theory propagates an equality between
- * shared terms.
+ * maintain this fact. In the distributed equality engine architecture,
+ * this is the case when either an equality is asserted from the SAT solver
+ * or a theory propagates an equality between shared terms.
*/
- virtual void assertSharedEquality(TNode equality,
- bool polarity,
- TNode reason) = 0;
+ virtual void assertShared(TNode n, bool polarity, TNode reason) = 0;
/** Is term t a shared term? */
virtual bool isShared(TNode t) const;
return texp;
}
-void SharedSolverDistributed::assertSharedEquality(TNode equality,
- bool polarity,
- TNode reason)
+void SharedSolverDistributed::assertShared(TNode n, bool polarity, TNode reason)
{
- d_sharedTerms.assertEquality(equality, polarity, reason);
+ d_sharedTerms.assertShared(n, polarity, reason);
}
} // namespace theory
/** Set equality engine in the shared terms database */
void setEqualityEngine(eq::EqualityEngine* ee) override;
//------------------------------------- end initialization
- /** Assert equality to the shared terms database. */
- void assertSharedEquality(TNode equality,
- bool polarity,
- TNode reason) override;
+ /** Assert n to the shared terms database. */
+ void assertShared(TNode n, bool polarity, TNode reason) override;
/**
* Get equality status based on the equality engine of shared terms database
*/
{
Assert(ee != nullptr);
d_equalityEngine = ee;
- // if proofs are enabled, make the proof equality engine
+ // if proofs are enabled, make the proof equality engine if necessary
if (d_pnm != nullptr)
{
- d_pfee.reset(
- new eq::ProofEqEngine(d_satContext, d_userContext, *ee, d_pnm));
+ d_pfee = d_equalityEngine->getProofEqualityEngine();
+ if (d_pfee == nullptr)
+ {
+ d_pfeeAlloc.reset(
+ new eq::ProofEqEngine(d_satContext, d_userContext, *ee, d_pnm));
+ d_pfee = d_pfeeAlloc.get();
+ d_equalityEngine->setProofEqualityEngine(d_pfee);
+ }
}
}
bool SharedTermsDatabase::needsEqualityEngine(EeSetupInfo& esi)
{
esi.d_notify = &d_EENotify;
- esi.d_name = "SharedTermsDatabase";
+ esi.d_name = "shared::ee";
return true;
}
return d_equalityEngine;
}
-void SharedTermsDatabase::assertEquality(TNode equality, bool polarity, TNode reason)
+void SharedTermsDatabase::assertShared(TNode n, bool polarity, TNode reason)
{
Assert(d_equalityEngine != nullptr);
- Debug("shared-terms-database::assert") << "SharedTermsDatabase::assertEquality(" << equality << ", " << (polarity ? "true" : "false") << ", " << reason << ")" << endl;
+ Debug("shared-terms-database::assert")
+ << "SharedTermsDatabase::assertShared(" << n << ", "
+ << (polarity ? "true" : "false") << ", " << reason << ")" << endl;
// Add it to the equality engine
- d_equalityEngine->assertEquality(equality, polarity, reason);
+ if (n.getKind() == kind::EQUAL)
+ {
+ d_equalityEngine->assertEquality(n, polarity, reason);
+ }
+ else
+ {
+ d_equalityEngine->assertPredicate(n, polarity, reason);
+ }
// Check for conflict
checkForConflict();
}
//-------------------------------------------- end initialization
/**
- * Asserts the equality to the shared terms database,
+ * Asserts n to the shared terms database with given polarity and reason
*/
- void assertEquality(TNode equality, bool polarity, TNode reason);
+ void assertShared(TNode n, bool polarity, TNode reason);
/**
* Return whether the equality is alreday known to the engine
context::UserContext* d_userContext;
/** Equality engine */
theory::eq::EqualityEngine* d_equalityEngine;
- /** Proof equality engine */
- std::unique_ptr<theory::eq::ProofEqEngine> d_pfee;
+ /** Proof equality engine, if we allocated one */
+ std::unique_ptr<theory::eq::ProofEqEngine> d_pfeeAlloc;
+ /** The proof equality engine we are using */
+ theory::eq::ProofEqEngine* d_pfee;
/** The proof node manager */
ProofNodeManager* d_pnm;
};
// assert to the shared solver
bool polarity = assertion.getKind() != kind::NOT;
TNode atom = polarity ? assertion : assertion[0];
- d_sharedSolver->assertSharedEquality(atom, polarity, assertion);
+ d_sharedSolver->assertShared(atom, polarity, assertion);
}
return;
}