typerule FLOATINGPOINT_MAX ::CVC4::theory::fp::FloatingPointOperationTypeRule
-operator FLOATINGPOINT_LEQ 2 "floating-point less than or equal"
+operator FLOATINGPOINT_LEQ 2: "floating-point less than or equal"
typerule FLOATINGPOINT_LEQ ::CVC4::theory::fp::FloatingPointTestTypeRule
-operator FLOATINGPOINT_LT 2 "floating-point less than"
+operator FLOATINGPOINT_LT 2: "floating-point less than"
typerule FLOATINGPOINT_LT ::CVC4::theory::fp::FloatingPointTestTypeRule
-operator FLOATINGPOINT_GEQ 2 "floating-point greater than or equal"
+operator FLOATINGPOINT_GEQ 2: "floating-point greater than or equal"
typerule FLOATINGPOINT_GEQ ::CVC4::theory::fp::FloatingPointTestTypeRule
-operator FLOATINGPOINT_GT 2 "floating-point greater than"
+operator FLOATINGPOINT_GT 2: "floating-point greater than"
typerule FLOATINGPOINT_GT ::CVC4::theory::fp::FloatingPointTestTypeRule
namespace rewrite {
/** Rewrite rules **/
+ template <RewriteFunction first, RewriteFunction second>
+ RewriteResponse then (TNode node, bool isPreRewrite) {
+ RewriteResponse result(first(node, isPreRewrite));
+
+ if (result.status == REWRITE_DONE) {
+ return second(result.node, isPreRewrite);
+ } else {
+ return result;
+ }
+ }
RewriteResponse notFP (TNode node, bool) {
Unreachable("non floating-point kind (%d) in floating point rewrite?",node.getKind());
return RewriteResponse(REWRITE_DONE, addition);
}
+ RewriteResponse breakChain (TNode node, bool isPreRewrite) {
+ Assert(isPreRewrite); // Should be run first
+
+ Kind k = node.getKind();
+ Assert(k == kind::FLOATINGPOINT_EQ ||
+ k == kind::FLOATINGPOINT_GEQ ||
+ k == kind::FLOATINGPOINT_LEQ ||
+ k == kind::FLOATINGPOINT_GT ||
+ k == kind::FLOATINGPOINT_LT);
+
+
+ size_t children = node.getNumChildren();
+ if (children > 2) {
+
+ NodeBuilder<> conjunction(kind::AND);
+
+ for (size_t i = 0; i < children - 1; ++i) {
+ for (size_t j = i + 1; j < children; ++j) {
+ conjunction << NodeManager::currentNM()->mkNode(k, node[i], node[j]);
+ }
+ }
+ return RewriteResponse(REWRITE_AGAIN_FULL, conjunction);
+
+ } else {
+ return RewriteResponse(REWRITE_DONE, node);
+ }
+ }
+
/* Implies (fp.eq x x) --> (not (isNaN x))
*/
preRewriteTable[kind::FLOATINGPOINT_MAX] = rewrite::compactMinMax;
/******** Comparisons ********/
- preRewriteTable[kind::FLOATINGPOINT_EQ] = rewrite::ieeeEqToEq;
- preRewriteTable[kind::FLOATINGPOINT_LEQ] = rewrite::identity;
- preRewriteTable[kind::FLOATINGPOINT_LT] = rewrite::identity;
- preRewriteTable[kind::FLOATINGPOINT_GEQ] = rewrite::geqToleq;
- preRewriteTable[kind::FLOATINGPOINT_GT] = rewrite::gtTolt;
+ preRewriteTable[kind::FLOATINGPOINT_EQ] = rewrite::then<rewrite::breakChain,rewrite::ieeeEqToEq>;
+ preRewriteTable[kind::FLOATINGPOINT_LEQ] = rewrite::breakChain;
+ preRewriteTable[kind::FLOATINGPOINT_LT] = rewrite::breakChain;
+ preRewriteTable[kind::FLOATINGPOINT_GEQ] = rewrite::then<rewrite::breakChain,rewrite::geqToleq>;
+ preRewriteTable[kind::FLOATINGPOINT_GT] = rewrite::then<rewrite::breakChain,rewrite::gtTolt>;
/******** Classifications ********/
preRewriteTable[kind::FLOATINGPOINT_ISN] = rewrite::identity;