Introduces a TermContext class that can be used to skip rewrites below theory leafs. Fixes issues related to bit-vector leafs begin incorrectly rewritten.
#include "expr/term_context.h"
+#include "theory/theory.h"
+
namespace cvc5 {
uint32_t TermContext::computeValueOp(TNode t, uint32_t tval) const
pol = val == 2;
}
+uint32_t TheoryLeafTermContext::initialValue() const { return 0; }
+
+uint32_t TheoryLeafTermContext::computeValue(TNode t,
+ uint32_t tval,
+ size_t index) const
+{
+ return theory::Theory::isLeafOf(t, d_theoryId) ? 1 : tval;
+}
+
} // namespace cvc5
#define CVC5__EXPR__TERM_CONTEXT_H
#include "expr/node.h"
+#include "theory/theory_id.h"
namespace cvc5 {
static void getFlags(uint32_t val, bool& hasPol, bool& pol);
};
+/**
+ * Similar to InQuantTermContext, but computes whether we are below a theory
+ * leaf of given theory id.
+ */
+class TheoryLeafTermContext : public TermContext
+{
+ public:
+ TheoryLeafTermContext(theory::TheoryId id) : d_theoryId(id) {}
+ /** The initial value: not beneath a theory leaf. */
+ uint32_t initialValue() const override;
+ /** Compute the value of the index^th child of t whose hash is tval */
+ uint32_t computeValue(TNode t, uint32_t tval, size_t index) const override;
+
+ private:
+ theory::TheoryId d_theoryId;
+};
+
} // namespace cvc5
#endif /* CVC5__EXPR__TERM_CONVERSION_PROOF_GENERATOR_H */
BBProof::BBProof(TheoryState* state, ProofNodeManager* pnm, bool fineGrained)
: d_bb(new BBSimple(state)),
d_pnm(pnm),
+ d_tcontext(new TheoryLeafTermContext(theory::THEORY_BV)),
d_tcpg(pnm ? new TConvProofGenerator(
pnm,
nullptr,
/* STATIC to get the same ProofNode for a shared subterm. */
TConvCachePolicy::STATIC,
"BBProof::TConvProofGenerator",
- nullptr,
+ d_tcontext.get(),
false)
: nullptr),
d_recordFineGrainedProofs(fineGrained)
#ifndef CVC5__THEORY__BV__BITBLAST__PROOF_BITBLASTER_H
#define CVC5__THEORY__BV__BITBLAST__PROOF_BITBLASTER_H
+#include "expr/term_context.h"
#include "theory/bv/bitblast/simple_bitblaster.h"
namespace cvc5 {
std::unique_ptr<BBSimple> d_bb;
/** The associated proof node manager. */
ProofNodeManager* d_pnm;
+ /** Term context for d_tcpg to not rewrite below BV leafs. */
+ std::unique_ptr<TermContext> d_tcontext;
/** The associated term conversion proof generator. */
std::unique_ptr<TConvProofGenerator> d_tcpg;
/** Map bit-vector nodes to bit-blasted nodes. */