class TheoryBuiltinRewriter : public TheoryRewriter
{
static Node blastDistinct(TNode node);
- static Node blastChain(TNode node);
-public:
+ public:
+ /**
+ * Takes a chained application of a binary operator and returns a conjunction
+ * of binary applications of that operator.
+ *
+ * For example:
+ *
+ * (= x y z) ---> (and (= x y) (= y z))
+ *
+ * @param node A node that is a chained application of a binary operator
+ * @return A conjunction of binary applications of the chained operator
+ */
+ static Node blastChain(TNode node);
- static inline RewriteResponse doRewrite(TNode node) {
- switch(node.getKind()) {
- case kind::DISTINCT:
- return RewriteResponse(REWRITE_DONE, blastDistinct(node));
- case kind::CHAIN:
- return RewriteResponse(REWRITE_DONE, blastChain(node));
- default:
- return RewriteResponse(REWRITE_DONE, node);
+ static inline RewriteResponse doRewrite(TNode node)
+ {
+ switch (node.getKind())
+ {
+ case kind::DISTINCT:
+ return RewriteResponse(REWRITE_DONE, blastDistinct(node));
+ case kind::CHAIN: return RewriteResponse(REWRITE_DONE, blastChain(node));
+ default: return RewriteResponse(REWRITE_DONE, node);
}
}
TypeNode tn;
try {
- // Actually do the expansion to do the typechecking.
- // Shouldn't be extra work to do this, since the rewriter
- // keeps a cache.
- tn = nodeManager->getType(Rewriter::rewrite(n), check);
+ tn = nodeManager->getType(TheoryBuiltinRewriter::blastChain(n), check);
} catch(TypeCheckingExceptionPrivate& e) {
std::stringstream ss;
ss << "Cannot typecheck the expansion of chained operator `" << n.getOperator() << "':"
Trace("fp-registerTerm") << "TheoryFp::registerTerm(): " << node << std::endl;
if (!isRegistered(node)) {
+ Kind k = node.getKind();
+ Assert(k != kind::FLOATINGPOINT_TO_FP_GENERIC
+ && k != kind::FLOATINGPOINT_SUB && k != kind::FLOATINGPOINT_EQ
+ && k != kind::FLOATINGPOINT_GEQ && k != kind::FLOATINGPOINT_GT);
+
bool success = d_registeredTerms.insert(node);
(void)success; // Only used for assertion
Assert(success);
// Add to the equality engine
- if (node.getKind() == kind::EQUAL) {
+ if (k == kind::EQUAL)
+ {
d_equalityEngine.addTriggerEquality(node);
- } else {
+ }
+ else
+ {
d_equalityEngine.addTerm(node);
}
// Give the expansion of classifications in terms of equalities
// This should make equality reasoning slightly more powerful.
- if ((node.getKind() == kind::FLOATINGPOINT_ISNAN)
- || (node.getKind() == kind::FLOATINGPOINT_ISZ)
- || (node.getKind() == kind::FLOATINGPOINT_ISINF))
+ if ((k == kind::FLOATINGPOINT_ISNAN) || (k == kind::FLOATINGPOINT_ISZ)
+ || (k == kind::FLOATINGPOINT_ISINF))
{
NodeManager *nm = NodeManager::currentNM();
FloatingPointSize s = node[0].getType().getConst<FloatingPointSize>();
Node equalityAlias = Node::null();
- if (node.getKind() == kind::FLOATINGPOINT_ISNAN)
+ if (k == kind::FLOATINGPOINT_ISNAN)
{
equalityAlias = nm->mkNode(
kind::EQUAL, node[0], nm->mkConst(FloatingPoint::makeNaN(s)));
}
- else if (node.getKind() == kind::FLOATINGPOINT_ISZ)
+ else if (k == kind::FLOATINGPOINT_ISZ)
{
equalityAlias = nm->mkNode(
kind::OR,
node[0],
nm->mkConst(FloatingPoint::makeZero(s, false))));
}
- else if (node.getKind() == kind::FLOATINGPOINT_ISINF)
+ else if (k == kind::FLOATINGPOINT_ISINF)
{
equalityAlias = nm->mkNode(
kind::OR,
rewrite::identity;
d_preRewriteTable[kind::FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR] =
rewrite::identity;
- d_preRewriteTable[kind::FLOATINGPOINT_TO_FP_GENERIC] = rewrite::removed;
+ d_preRewriteTable[kind::FLOATINGPOINT_TO_FP_GENERIC] = rewrite::identity;
d_preRewriteTable[kind::FLOATINGPOINT_TO_UBV] = rewrite::identity;
d_preRewriteTable[kind::FLOATINGPOINT_TO_SBV] = rewrite::identity;
d_preRewriteTable[kind::FLOATINGPOINT_TO_REAL] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_NEG] = rewrite::removeDoubleNegation;
d_postRewriteTable[kind::FLOATINGPOINT_PLUS] =
rewrite::reorderBinaryOperation;
- d_postRewriteTable[kind::FLOATINGPOINT_SUB] = rewrite::removed;
+ d_postRewriteTable[kind::FLOATINGPOINT_SUB] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_MULT] =
rewrite::reorderBinaryOperation;
d_postRewriteTable[kind::FLOATINGPOINT_DIV] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_MAX_TOTAL] = rewrite::compactMinMax;
/******** Comparisons ********/
- d_postRewriteTable[kind::FLOATINGPOINT_EQ] = rewrite::removed;
+ d_postRewriteTable[kind::FLOATINGPOINT_EQ] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_LEQ] = rewrite::leqId;
d_postRewriteTable[kind::FLOATINGPOINT_LT] = rewrite::ltId;
- d_postRewriteTable[kind::FLOATINGPOINT_GEQ] = rewrite::removed;
- d_postRewriteTable[kind::FLOATINGPOINT_GT] = rewrite::removed;
+ d_postRewriteTable[kind::FLOATINGPOINT_GEQ] = rewrite::identity;
+ d_postRewriteTable[kind::FLOATINGPOINT_GT] = rewrite::identity;
/******** Classifications ********/
d_postRewriteTable[kind::FLOATINGPOINT_ISN] = rewrite::removeSignOperations;
rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR] =
rewrite::identity;
- d_postRewriteTable[kind::FLOATINGPOINT_TO_FP_GENERIC] = rewrite::removed;
+ d_postRewriteTable[kind::FLOATINGPOINT_TO_FP_GENERIC] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_TO_UBV] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_TO_SBV] = rewrite::identity;
d_postRewriteTable[kind::FLOATINGPOINT_TO_REAL] = rewrite::identity;
d_constantFoldTable[kind::FLOATINGPOINT_ABS] = constantFold::abs;
d_constantFoldTable[kind::FLOATINGPOINT_NEG] = constantFold::neg;
d_constantFoldTable[kind::FLOATINGPOINT_PLUS] = constantFold::plus;
- d_constantFoldTable[kind::FLOATINGPOINT_SUB] = rewrite::removed;
d_constantFoldTable[kind::FLOATINGPOINT_MULT] = constantFold::mult;
d_constantFoldTable[kind::FLOATINGPOINT_DIV] = constantFold::div;
d_constantFoldTable[kind::FLOATINGPOINT_FMA] = constantFold::fma;
d_constantFoldTable[kind::FLOATINGPOINT_MAX_TOTAL] = constantFold::maxTotal;
/******** Comparisons ********/
- d_constantFoldTable[kind::FLOATINGPOINT_EQ] = rewrite::removed;
d_constantFoldTable[kind::FLOATINGPOINT_LEQ] = constantFold::leq;
d_constantFoldTable[kind::FLOATINGPOINT_LT] = constantFold::lt;
- d_constantFoldTable[kind::FLOATINGPOINT_GEQ] = rewrite::removed;
- d_constantFoldTable[kind::FLOATINGPOINT_GT] = rewrite::removed;
/******** Classifications ********/
d_constantFoldTable[kind::FLOATINGPOINT_ISN] = constantFold::isNormal;
constantFold::convertFromSBV;
d_constantFoldTable[kind::FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR] =
constantFold::convertFromUBV;
- d_constantFoldTable[kind::FLOATINGPOINT_TO_FP_GENERIC] = rewrite::removed;
d_constantFoldTable[kind::FLOATINGPOINT_TO_UBV] = constantFold::convertToUBV;
d_constantFoldTable[kind::FLOATINGPOINT_TO_SBV] = constantFold::convertToSBV;
d_constantFoldTable[kind::FLOATINGPOINT_TO_REAL] =
}
}; /* struct RewriteResponse */
+/**
+ * The interface that a theory rewriter has to implement.
+ *
+ * Note: A theory rewriter is expected to handle all kinds of a theory, even
+ * the ones that are removed by `Theory::expandDefinition()` since it may be
+ * called on terms before the definitions have been expanded.
+ */
class TheoryRewriter
{
public:
regress0/fp/abs-unsound2.smt2
regress0/fp/down-cast-RNA.smt2
regress0/fp/ext-rew-test.smt2
+ regress0/fp/issue3536.smt2
regress0/fp/rti_3_5_bug.smt2
regress0/fp/rti_3_5_bug_report.smt2
regress0/fp/simple.smt2
--- /dev/null
+; REQUIRES: symfpu
+(set-logic QF_FP)
+(declare-const x (_ FloatingPoint 11 53))
+(assert (= true (fp.eq x ((_ to_fp 11 53) (_ bv13831004815617530266 64))) true))
+(set-info :status sat)
+(check-sat)