mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
Move tbv to util
This commit is contained in:
parent
a89be68050
commit
79ee543d25
|
@ -25,7 +25,7 @@ Revision History:
|
||||||
#include "muz/base/dl_context.h"
|
#include "muz/base/dl_context.h"
|
||||||
#include "ast/scoped_proof.h"
|
#include "ast/scoped_proof.h"
|
||||||
#include "ast/bv_decl_plugin.h"
|
#include "ast/bv_decl_plugin.h"
|
||||||
#include "muz/rel/tbv.h"
|
#include "util/tbv.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace datalog {
|
namespace datalog {
|
||||||
|
|
|
@ -23,7 +23,6 @@ z3_add_component(rel
|
||||||
doc.cpp
|
doc.cpp
|
||||||
karr_relation.cpp
|
karr_relation.cpp
|
||||||
rel_context.cpp
|
rel_context.cpp
|
||||||
tbv.cpp
|
|
||||||
udoc_relation.cpp
|
udoc_relation.cpp
|
||||||
COMPONENT_DEPENDENCIES
|
COMPONENT_DEPENDENCIES
|
||||||
muz
|
muz
|
||||||
|
|
|
@ -695,12 +695,36 @@ void doc_manager::check_equiv(ast_manager& m, expr* fml1, expr* fml2) {
|
||||||
SASSERT(res == l_false);
|
SASSERT(res == l_false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
expr_ref doc_manager::to_formula(ast_manager & m, tbv const& src) {
|
||||||
|
expr_ref result(m);
|
||||||
|
expr_ref_vector conj(m);
|
||||||
|
for (unsigned i = 0; i < num_tbits(); ++i) {
|
||||||
|
switch (src[i]) {
|
||||||
|
case BIT_0:
|
||||||
|
conj.push_back(m.mk_not(m.mk_const(symbol(i), m.mk_bool_sort())));
|
||||||
|
break;
|
||||||
|
case BIT_1:
|
||||||
|
conj.push_back(m.mk_const(symbol(i), m.mk_bool_sort()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = mk_and(m, conj.size(), conj.data());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
expr_ref doc_manager::mk_var(ast_manager & m, unsigned i) {
|
||||||
|
return expr_ref(m.mk_const(symbol(i), m.mk_bool_sort()), m);
|
||||||
|
}
|
||||||
|
|
||||||
expr_ref doc_manager::to_formula(ast_manager& m, doc const& src) {
|
expr_ref doc_manager::to_formula(ast_manager& m, doc const& src) {
|
||||||
expr_ref result(m);
|
expr_ref result(m);
|
||||||
expr_ref_vector conj(m);
|
expr_ref_vector conj(m);
|
||||||
conj.push_back(tbvm().to_formula(m, src.pos()));
|
conj.push_back(to_formula(m, src.pos()));
|
||||||
for (unsigned i = 0; i < src.neg().size(); ++i) {
|
for (unsigned i = 0; i < src.neg().size(); ++i) {
|
||||||
conj.push_back(m.mk_not(tbvm().to_formula(m, src.neg()[i])));
|
conj.push_back(m.mk_not(to_formula(m, src.neg()[i])));
|
||||||
}
|
}
|
||||||
result = mk_and(m, conj.size(), conj.data());
|
result = mk_and(m, conj.size(), conj.data());
|
||||||
return result;
|
return result;
|
||||||
|
@ -712,9 +736,9 @@ void doc_manager::project_expand(expr_ref& fml, bit_vector const& to_delete) {
|
||||||
for (unsigned i = 0; i < num_tbits(); ++i) {
|
for (unsigned i = 0; i < num_tbits(); ++i) {
|
||||||
if (to_delete.get(i)) {
|
if (to_delete.get(i)) {
|
||||||
expr_safe_replace rep1(m), rep2(m);
|
expr_safe_replace rep1(m), rep2(m);
|
||||||
rep1.insert(tbvm().mk_var(m, i), m.mk_true());
|
rep1.insert(mk_var(m, i), m.mk_true());
|
||||||
rep1(fml, tmp1);
|
rep1(fml, tmp1);
|
||||||
rep2.insert(tbvm().mk_var(m, i), m.mk_false());
|
rep2.insert(mk_var(m, i), m.mk_false());
|
||||||
rep2(fml, tmp2);
|
rep2(fml, tmp2);
|
||||||
if (tmp1 == tmp2) {
|
if (tmp1 == tmp2) {
|
||||||
fml = tmp1;
|
fml = tmp1;
|
||||||
|
@ -731,7 +755,7 @@ void doc_manager::project_rename(expr_ref& fml, bit_vector const& to_delete) {
|
||||||
expr_safe_replace rep(m);
|
expr_safe_replace rep(m);
|
||||||
for (unsigned i = 0, j = 0; i < num_tbits(); ++i) {
|
for (unsigned i = 0, j = 0; i < num_tbits(); ++i) {
|
||||||
if (!to_delete.get(i)) {
|
if (!to_delete.get(i)) {
|
||||||
rep.insert(tbvm().mk_var(m, j), tbvm().mk_var(m, i));
|
rep.insert(mk_var(m, j), mk_var(m, i));
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ Revision History:
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "muz/rel/tbv.h"
|
#include "util/tbv.h"
|
||||||
#include "util/union_find.h"
|
#include "util/union_find.h"
|
||||||
#include "util/buffer.h"
|
#include "util/buffer.h"
|
||||||
|
#include "ast/ast.h"
|
||||||
|
|
||||||
class doc;
|
class doc;
|
||||||
template<typename M, typename T> class union_bvec;
|
template<typename M, typename T> class union_bvec;
|
||||||
|
@ -101,6 +101,8 @@ private:
|
||||||
void project_rename(expr_ref& fml, bit_vector const& to_delete);
|
void project_rename(expr_ref& fml, bit_vector const& to_delete);
|
||||||
void project_expand(expr_ref& fml, bit_vector const& to_delete);
|
void project_expand(expr_ref& fml, bit_vector const& to_delete);
|
||||||
expr_ref to_formula(ast_manager& m, doc const& src);
|
expr_ref to_formula(ast_manager& m, doc const& src);
|
||||||
|
expr_ref to_formula(ast_manager& m, tbv const& src);
|
||||||
|
expr_ref mk_var(ast_manager& m, unsigned i);
|
||||||
void check_equiv(ast_manager& m, expr* fml1, expr* fml2);
|
void check_equiv(ast_manager& m, expr* fml1, expr* fml2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Copyright (c) 2015 Microsoft Corporation
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
#include "muz/ddnf/ddnf.h"
|
#include "muz/ddnf/ddnf.h"
|
||||||
#include "muz/rel/tbv.h"
|
#include "util/tbv.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
|
@ -4,7 +4,7 @@ Copyright (c) 2015 Microsoft Corporation
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
#include "muz/rel/tbv.h"
|
#include "util/tbv.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
static void tst1(unsigned num_bits) {
|
static void tst1(unsigned num_bits) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ z3_add_component(util
|
||||||
state_graph.cpp
|
state_graph.cpp
|
||||||
statistics.cpp
|
statistics.cpp
|
||||||
symbol.cpp
|
symbol.cpp
|
||||||
|
tbv.cpp
|
||||||
timeit.cpp
|
timeit.cpp
|
||||||
timeout.cpp
|
timeout.cpp
|
||||||
trace.cpp
|
trace.cpp
|
||||||
|
|
|
@ -18,9 +18,8 @@ Revision History:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
#include "muz/rel/tbv.h"
|
#include "util/tbv.h"
|
||||||
#include "util/hashtable.h"
|
#include "util/hashtable.h"
|
||||||
#include "ast/ast_util.h"
|
|
||||||
|
|
||||||
|
|
||||||
static bool s_debug_alloc = false;
|
static bool s_debug_alloc = false;
|
||||||
|
@ -301,26 +300,3 @@ std::ostream& tbv_manager::display(std::ostream& out, tbv const& b) const {
|
||||||
if (num_tbits() == 0) return out << "[]";
|
if (num_tbits() == 0) return out << "[]";
|
||||||
return display(out, b, num_tbits()-1, 0);
|
return display(out, b, num_tbits()-1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_ref tbv_manager::to_formula(ast_manager& m, tbv const& src) {
|
|
||||||
expr_ref result(m);
|
|
||||||
expr_ref_vector conj(m);
|
|
||||||
for (unsigned i = 0; i < num_tbits(); ++i) {
|
|
||||||
switch (src[i]) {
|
|
||||||
case BIT_0:
|
|
||||||
conj.push_back(m.mk_not(m.mk_const(symbol(i), m.mk_bool_sort())));
|
|
||||||
break;
|
|
||||||
case BIT_1:
|
|
||||||
conj.push_back(m.mk_const(symbol(i), m.mk_bool_sort()));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = mk_and(m, conj.size(), conj.data());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
expr_ref tbv_manager::mk_var(ast_manager& m, unsigned i) {
|
|
||||||
return expr_ref(m.mk_const(symbol(i), m.mk_bool_sort()), m);
|
|
||||||
}
|
|
|
@ -21,8 +21,8 @@ Revision History:
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "util/fixed_bit_vector.h"
|
#include "util/fixed_bit_vector.h"
|
||||||
|
#include "util/bit_vector.h"
|
||||||
#include "util/rational.h"
|
#include "util/rational.h"
|
||||||
#include "ast/ast.h"
|
|
||||||
|
|
||||||
class tbv;
|
class tbv;
|
||||||
|
|
||||||
|
@ -84,10 +84,7 @@ public:
|
||||||
void set(tbv& dst, tbv const& other, unsigned hi, unsigned lo);
|
void set(tbv& dst, tbv const& other, unsigned hi, unsigned lo);
|
||||||
void set(tbv& dst, unsigned index, tbit value);
|
void set(tbv& dst, unsigned index, tbit value);
|
||||||
|
|
||||||
|
|
||||||
static void debug_alloc();
|
static void debug_alloc();
|
||||||
expr_ref to_formula(ast_manager& m, tbv const& src);
|
|
||||||
expr_ref mk_var(ast_manager& m, unsigned i);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class tbv: private fixed_bit_vector {
|
class tbv: private fixed_bit_vector {
|
Loading…
Reference in a new issue