theory/bv/bitblast_mode.h \
theory/bv/bitblast_mode.cpp \
theory/bv/bitblast_utils.h \
+ theory/bv/bvintropow2.h \
+ theory/bv/bvintropow2.cpp \
theory/idl/idl_model.h \
theory/idl/idl_model.cpp \
theory/idl/idl_assertion.h \
#include "printer/options.h"
#include "theory/arith/pseudoboolean_proc.h"
+#include "theory/bv/bvintropow2.h"
using namespace std;
using namespace CVC4;
dumpAssertions("post-unconstrained-simp", d_assertionsToPreprocess);
}
+ if(options::bvIntroducePow2()){
+ theory::bv::BVIntroducePow2::pow2Rewrite(d_assertionsToPreprocess);
+ }
+
dumpAssertions("pre-substitution", d_assertionsToPreprocess);
// Apply the substitutions we already have, and normalize
--- /dev/null
+#include "theory/bv/bvintropow2.h"
+#include "theory/rewriter.h"
+#include "theory/bv/theory_bv_rewrite_rules_simplification.h"
+
+
+namespace CVC4 {
+namespace theory {
+namespace bv {
+
+void BVIntroducePow2::pow2Rewrite(std::vector<Node>& assertionsToPreprocess){
+ NodeMap cache;
+ for(size_t i = 0, N= assertionsToPreprocess.size(); i < N; ++i){
+ Node curr = assertionsToPreprocess[i];
+ Node next = pow2Rewrite(curr, cache);
+ assertionsToPreprocess[i] = next;
+ }
+}
+
+Node BVIntroducePow2::pow2Rewrite(Node node, NodeMap& cache){
+ NodeMap::const_iterator ci = cache.find(node);
+ if(ci != cache.end()){
+ Node incache = (*ci).second;
+
+ return incache.isNull() ? node : incache;
+ }
+
+ Node res = Node::null();
+ switch(node.getKind()){
+ case kind::AND:
+ {
+ bool changed = false;
+ std::vector<Node> children;
+ for(unsigned i = 0, N = node.getNumChildren(); i < N; ++i){
+ Node child = node[i];
+ Node found = pow2Rewrite(child, cache);
+ changed = changed || (child != found);
+ children.push_back(found);
+ }
+ if(changed){
+ res = NodeManager::currentNM()->mkNode(kind::AND, children);
+ }
+ }
+ break;
+
+ case kind::EQUAL:
+ if(node[0].getType().isBitVector()){
+ if (RewriteRule<IsPowerOfTwo>::applies(node)) {
+ res = RewriteRule<IsPowerOfTwo>::run<false>(node);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ cache.insert(std::make_pair(node, res));
+ return res.isNull() ? node : res;
+}
+
+
+}/* CVC4::theory::bv namespace */
+}/* CVC4::theory namespace */
+
+}/* CVC4 namespace */
--- /dev/null
+
+
+#include "cvc4_private.h"
+#include "expr/node.h"
+
+#include <vector>
+#include <ext/hash_map>
+
+#ifndef __CVC4__THEORY__BV__BV_INTRO_POW_H
+#define __CVC4__THEORY__BV__BV_INTRO_POW_H
+
+namespace CVC4 {
+namespace theory {
+namespace bv {
+
+
+class BVIntroducePow2 {
+public:
+ static void pow2Rewrite(std::vector<Node>& assertionsToPreprocess);
+
+private:
+ typedef __gnu_cxx::hash_map<Node, Node, NodeHashFunction> NodeMap;
+ static Node pow2Rewrite(Node assertionsToPreprocess, NodeMap& cache);
+};
+
+
+
+}/* CVC4::theory::bv namespace */
+}/* CVC4::theory namespace */
+
+}/* CVC4 namespace */
+
+
+#endif /* __CVC4__THEORY__BV__BV_INTRO_POW_H */
expert-option bitvectorQuickXplain --bv-quick-xplain bool :default false
minimize bv conflicts using the QuickXplain algorithm
+expert-option bvIntroducePow2 --bv-intro-pow2 bool :default false
+ introduce bitvector powers of two as a preprocessing pass
endmodule
d_subtheories(),
d_subtheoryMap(),
d_statistics(),
+ d_staticLearnCache(),
d_lemmasAdded(c, false),
d_conflict(c, false),
d_literalsToPropagate(c),
void TheoryBV::ppStaticLearn(TNode in, NodeBuilder<>& learned) {
+ if(d_staticLearnCache.find(in) != d_staticLearnCache.end()){
+ return;
+ }
+ d_staticLearnCache.insert(in);
+
if (in.getKind() == kind::EQUAL) {
if(in[0].getKind() == kind::BITVECTOR_PLUS && in[1].getKind() == kind::BITVECTOR_SHL ||
in[1].getKind() == kind::BITVECTOR_PLUS && in[0].getKind() == kind::BITVECTOR_SHL){
}
}
}
- }
+ }else if(in.getKind() == kind::AND){
+ for(size_t i = 0, N = in.getNumChildren(); i < N; ++i){
+ ppStaticLearn(in[i], learned);
+ }
+ }
}
bool TheoryBV::applyAbstraction(const std::vector<Node>& assertions, std::vector<Node>& new_assertions) {
typedef __gnu_cxx::hash_set<TNode, TNodeHashFunction> TNodeSet;
void collectNumerators(TNode term, TNodeSet& seen);
+ typedef __gnu_cxx::hash_set<Node, NodeHashFunction> NodeSet;
+ NodeSet d_staticLearnCache;
+
/**
* Maps from bit-vector width to divison-by-zero uninterpreted
* function symbols.