#include "context/context.h"
#include "util/stats.h"
#include "theory/bv/theory_bv_utils.h"
+#include "expr/command.h"
#include <sstream>
namespace CVC4 {
Assert(checkApplies || applies(node));
//++ s_statistics->d_ruleApplications;
Node result = apply(node);
+ if (result != node) {
+ if(Dump.isOn("bv-rewrites")) {
+ std::ostringstream os;
+ os << "RewriteRule <"<<rule<<">; expect unsat";
+
+ Node condition;
+ if (result.getType().isBoolean()) {
+ condition = node.iffNode(result).notNode();
+ } else {
+ condition = node.eqNode(result).notNode();
+ }
+
+ Dump("bv-rewrites")
+ << CommentCommand(os.str())
+ << CheckSatCommand(condition.toExpr());
+ }
+ }
BVDebug("theory::bv::rewrite") << "RewriteRule<" << rule << ">(" << node << ") => " << result << std::endl;
return result;
} else {
BVDebug("bv-rewrite") << "RewriteRule<ExtractBitwise>(" << node << ")" << std::endl;
unsigned high = utils::getExtractHigh(node);
unsigned low = utils::getExtractLow(node);
- Node a = utils::mkExtract(node[0][0], high, low);
- Node b = utils::mkExtract(node[0][1], high, low);
+ std::vector<Node> children;
+ for (unsigned i = 0; i < node[0].getNumChildren(); ++i) {
+ children.push_back(utils::mkExtract(node[0][i], high, low));
+ }
Kind kind = node[0].getKind();
- return utils::mkNode(kind, a, b);
+ return utils::mkSortedNode(kind, children);
}
/**
unsigned low = utils::getExtractLow(node);
Assert (low == 0);
unsigned high = utils::getExtractHigh(node);
- Node a = utils::mkExtract(node[0][0], high, low);
- Node b = utils::mkExtract(node[0][1], high, low);
-
+ std::vector<Node> children;
+ for (unsigned i = 0; i < node[0].getNumChildren(); ++i) {
+ children.push_back(utils::mkExtract(node[0][i], high, low));
+ }
Kind kind = node[0].getKind();
- return utils::mkNode(kind, a, b);
+ return utils::mkNode(kind, children);
}
BVDebug("bv-rewrite") << "RewriteRule<ExtractArith2>(" << node << ")" << std::endl;
unsigned low = utils::getExtractLow(node);
unsigned high = utils::getExtractHigh(node);
- Node a = utils::mkExtract(node[0][0], high, 0);
- Node b = utils::mkExtract(node[0][1], high, 0);
-
+ std::vector<Node> children;
+ for (unsigned i = 0; i < node[0].getNumChildren(); ++i) {
+ children.push_back(utils::mkExtract(node[0][i], high, 0));
+ }
Kind kind = node[0].getKind();
- Node a_op_b = utils::mkNode(kind, a, b);
+ Node op_children = utils::mkSortedNode(kind, children);
- return utils::mkExtract(a_op_b, high, low);
+ return utils::mkExtract(op_children, high, low);
}
template<> inline
} else if(!strcmp(optarg, "clauses")) {
} else if(!strcmp(optarg, "t-conflicts") ||
!strcmp(optarg, "t-lemmas") ||
- !strcmp(optarg, "t-explanations")) {
+ !strcmp(optarg, "t-explanations") ||
+ !strcmp(optarg, "bv-rewrites")) {
// These are "non-state-dumping" modes. If state (SAT decisions,
// propagations, etc.) is dumped, it will interfere with the validity
// of these generated queries.