namespace cvc5 {
namespace theory {
-/** Attribute true for nodes that have been rewritten with proofs enabled */
-struct RewriteWithProofsAttributeId
-{
-};
-typedef expr::Attribute<RewriteWithProofsAttributeId, bool>
- RewriteWithProofsAttribute;
-
// Note that this function is a simplified version of Theory::theoryOf for
// (type-based) theoryOfMode. We expand and simplify it here for the sake of
// efficiency.
Node node,
TConvProofGenerator* tcpg)
{
- RewriteWithProofsAttribute rpfa;
#ifdef CVC5_ASSERTIONS
bool isEquality = node.getKind() == kind::EQUAL && (!node[0].getType().isBoolean());
// Check if it's been cached already
Node cached = getPostRewriteCache(theoryId, node);
- if (!cached.isNull() && (tcpg == nullptr || node.getAttribute(rpfa)))
+ if (!cached.isNull() && (tcpg == nullptr || hasRewrittenWithProofs(node)))
{
return cached;
}
cached = getPreRewriteCache(rewriteStackTop.getTheoryId(),
rewriteStackTop.d_node);
if (cached.isNull()
- || (tcpg != nullptr && !rewriteStackTop.d_node.getAttribute(rpfa)))
+ || (tcpg != nullptr
+ && !hasRewrittenWithProofs(rewriteStackTop.d_node)))
{
// Rewrite until fix-point is reached
for(;;) {
rewriteStackTop.d_node);
// If not, go through the children
if (cached.isNull()
- || (tcpg != nullptr && !rewriteStackTop.d_node.getAttribute(rpfa)))
+ || (tcpg != nullptr && !hasRewrittenWithProofs(rewriteStackTop.d_node)))
{
// The child we need to rewrite
unsigned child = rewriteStackTop.d_nextChild++;
if (tcpg != nullptr)
{
// if proofs are enabled, mark that we've rewritten with proofs
- rewriteStackTop.d_original.setAttribute(rpfa, true);
+ d_tpgNodes.insert(rewriteStackTop.d_original);
if (!cached.isNull())
{
// We may have gotten a different node, due to non-determinism in
clearCachesInternal();
}
+bool Rewriter::hasRewrittenWithProofs(TNode n) const
+{
+ return d_tpgNodes.find(n) != d_tpgNodes.end();
+}
+
} // namespace theory
} // namespace cvc5
void clearCachesInternal();
+ /**
+ * Has n been rewritten with proofs? This checks if n is in d_tpgNodes.
+ */
+ bool hasRewrittenWithProofs(TNode n) const;
+
/** The resource manager, for tracking resource usage */
ResourceManager* d_resourceManager;
/** The proof generator */
std::unique_ptr<TConvProofGenerator> d_tpg;
+ /**
+ * Nodes rewritten with proofs. Since d_tpg contains a reference to all
+ * nodes that have been rewritten with proofs, we can keep only a TNode
+ * here.
+ */
+ std::unordered_set<TNode> d_tpgNodes;
#ifdef CVC5_ASSERTIONS
std::unique_ptr<std::unordered_set<Node>> d_rewriteStack = nullptr;
#endif /* CVC5_ASSERTIONS */