3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-04-30 09:30:43 -07:00
commit f525f43e43
155 changed files with 3188 additions and 1043 deletions

View file

@ -45,7 +45,7 @@ namespace datalog {
protected:
sort_ref m_sort;
bool m_limited_size;
uint64 m_size;
uint64_t m_size;
sort_domain(sort_kind k, context & ctx, sort * s)
: m_kind(k), m_sort(s, ctx.get_manager()) {
@ -103,15 +103,15 @@ namespace datalog {
};
class context::uint64_sort_domain : public sort_domain {
typedef map<uint64, finite_element, uint64_hash, default_eq<uint64> > el2num;
typedef svector<uint64> num2el;
typedef map<uint64_t, finite_element, uint64_hash, default_eq<uint64_t> > el2num;
typedef svector<uint64_t> num2el;
el2num m_el_numbers;
num2el m_el_names;
public:
uint64_sort_domain(context & ctx, sort * s) : sort_domain(SK_UINT64, ctx, s) {}
finite_element get_number(uint64 el) {
finite_element get_number(uint64_t el) {
//we number symbols starting from zero, so table->size() is equal to the
//index of the symbol to be added next
@ -368,14 +368,14 @@ namespace datalog {
return dom.get_number(sym);
}
context::finite_element context::get_constant_number(relation_sort srt, uint64 el) {
context::finite_element context::get_constant_number(relation_sort srt, uint64_t el) {
sort_domain & dom0 = get_sort_domain(srt);
SASSERT(dom0.get_kind()==SK_UINT64);
uint64_sort_domain & dom = static_cast<uint64_sort_domain &>(dom0);
return dom.get_number(el);
}
void context::print_constant_name(relation_sort srt, uint64 num, std::ostream & out)
void context::print_constant_name(relation_sort srt, uint64_t num, std::ostream & out)
{
if (has_sort_domain(srt)) {
SASSERT(num<=UINT_MAX);
@ -386,7 +386,7 @@ namespace datalog {
}
}
bool context::try_get_sort_constant_count(relation_sort srt, uint64 & constant_count) {
bool context::try_get_sort_constant_count(relation_sort srt, uint64_t & constant_count) {
if (!has_sort_domain(srt)) {
return false;
}
@ -394,18 +394,18 @@ namespace datalog {
return true;
}
uint64 context::get_sort_size_estimate(relation_sort srt) {
uint64_t context::get_sort_size_estimate(relation_sort srt) {
if (get_decl_util().is_rule_sort(srt)) {
return 1;
}
uint64 res;
uint64_t res;
if (!try_get_sort_constant_count(srt, res)) {
const sort_size & sz = srt->get_num_elements();
if (sz.is_finite()) {
res = sz.size();
}
else {
res = std::numeric_limits<uint64>::max();
res = std::numeric_limits<uint64_t>::max();
}
}
return res;

View file

@ -61,7 +61,7 @@ namespace datalog {
class relation_manager;
typedef sort * relation_sort;
typedef uint64 table_element;
typedef uint64_t table_element;
typedef svector<table_element> table_fact;
typedef app * relation_element;
@ -351,16 +351,16 @@ namespace datalog {
/**
\brief Return number of a symbol in a DK_UINT64 kind sort (\see register_sort() )
*/
finite_element get_constant_number(relation_sort srt, uint64 el);
finite_element get_constant_number(relation_sort srt, uint64_t el);
/**
\brief Output name of constant with number \c num in sort \c sort.
*/
void print_constant_name(relation_sort sort, uint64 num, std::ostream & out);
void print_constant_name(relation_sort sort, uint64_t num, std::ostream & out);
bool try_get_sort_constant_count(relation_sort srt, uint64 & constant_count);
bool try_get_sort_constant_count(relation_sort srt, uint64_t & constant_count);
uint64 get_sort_size_estimate(relation_sort srt);
uint64_t get_sort_size_estimate(relation_sort srt);
/**
\brief Assign names of variables used in the declaration of a predicate.

View file

@ -141,7 +141,7 @@ namespace datalog {
}
void cost_recorder::start(accounted_object * obj) {
uint64 curr_time = static_cast<uint64>(m_stopwatch->get_current_seconds()*1000);
uint64_t curr_time = static_cast<uint64_t>(m_stopwatch->get_current_seconds()*1000);
if(m_obj) {
costs::time_type time_delta = static_cast<costs::time_type>(curr_time-m_last_time);
costs & c = m_obj->get_current_costs();

View file

@ -95,7 +95,7 @@ namespace datalog {
stopwatch * m_stopwatch;
bool m_running;
uint64 m_last_time;
uint64_t m_last_time;
public:
cost_recorder();
~cost_recorder();

View file

@ -31,6 +31,10 @@ Revision History:
#include "muz/base/dl_rule.h"
#include "muz/base/dl_util.h"
#include "util/stopwatch.h"
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
namespace datalog {
@ -165,7 +169,7 @@ namespace datalog {
}
expr * arg = f->get_arg(i);
uint64 sym_num;
uint64_t sym_num;
SASSERT(is_app(arg));
VERIFY( ctx.get_decl_util().is_numeral_ext(to_app(arg), sym_num) );
relation_sort sort = pred_decl->get_domain(i);
@ -626,11 +630,11 @@ namespace datalog {
return name.substr(ofs, count);
}
bool string_to_uint64(const char * s, uint64 & res) {
bool string_to_uint64(const char * s, uint64_t & res) {
#if _WINDOWS
int converted = sscanf_s(s, "%I64u", &res);
int converted = sscanf_s(s, "%" SCNu64, &res);
#else
int converted = sscanf(s, "%llu", &res);
int converted = sscanf(s, "%" SCNu64, &res);
#endif
if(converted==0) {
return false;
@ -639,9 +643,9 @@ namespace datalog {
return true;
}
bool read_uint64(const char * & s, uint64 & res) {
static const uint64 max_but_one_digit = ULLONG_MAX/10;
static const uint64 max_but_one_digit_safe = (ULLONG_MAX-9)/10;
bool read_uint64(const char * & s, uint64_t & res) {
static const uint64_t max_but_one_digit = ULLONG_MAX/10;
static const uint64_t max_but_one_digit_safe = (ULLONG_MAX-9)/10;
if(*s<'0' || *s>'9') {
return false;
@ -669,7 +673,7 @@ namespace datalog {
return true;
}
std::string to_string(uint64 num) {
std::string to_string(uint64_t num) {
std::stringstream stm;
stm<<num;
return stm.str();

View file

@ -602,8 +602,8 @@ namespace datalog {
\brief If it is possible to convert the beginning of \c s to uint64,
store the result of conversion and return true; otherwise return false.
*/
bool string_to_uint64(const char * s, uint64 & res);
std::string to_string(uint64 num);
bool string_to_uint64(const char * s, uint64_t & res);
std::string to_string(uint64_t num);
/**
\brief Read the sequence of decimal digits starting at \c s and interpret it as
uint64. If successful, \c res will contain the read number and \c s will point
@ -612,7 +612,7 @@ namespace datalog {
overflows, \c points to the character which caused the overflow and false is
returned.
*/
bool read_uint64(const char * & s, uint64 & res);
bool read_uint64(const char * & s, uint64_t & res);
};
#endif /* DL_UTIL_H_ */

View file

@ -206,7 +206,7 @@ namespace datalog {
return find(t);
}
tbv* allocate(uint64 v, unsigned hi, unsigned lo) {
tbv* allocate(uint64_t v, unsigned hi, unsigned lo) {
return m_tbv.allocate(v, hi, lo);
}
@ -437,7 +437,7 @@ namespace datalog {
}
}
tbv* allocate(unsigned num_bits, uint64 v, unsigned hi, unsigned lo) {
tbv* allocate(unsigned num_bits, uint64_t v, unsigned hi, unsigned lo) {
return get(num_bits).allocate(v, hi, lo);
}
void insert(unsigned num_bits, tbv const& t) {

View file

@ -979,7 +979,7 @@ protected:
if(!num.is_uint64()) {
return unexpected(tok, "integer expected");
}
uint64 int_num = num.get_uint64();
uint64_t int_num = num.get_uint64();
app * numeral = mk_symbol_const(int_num, s);
args.push_back(numeral);
@ -1072,7 +1072,7 @@ protected:
}
}
sort * register_finite_sort(symbol name, uint64 domain_size, context::sort_kind k) {
sort * register_finite_sort(symbol name, uint64_t domain_size, context::sort_kind k) {
if(m_sort_dict.contains(name.bare_str())) {
throw default_exception(default_exception::fmt(), "sort %s already declared", name.bare_str());
}
@ -1102,7 +1102,7 @@ protected:
app* mk_const(symbol const& name, sort* s) {
app * res;
if(m_arith.is_int(s)) {
uint64 val;
uint64_t val;
if(!string_to_uint64(name.bare_str(), val)) {
throw default_exception(default_exception::fmt(), "Invalid integer: \"%s\"", name.bare_str());
}
@ -1117,7 +1117,7 @@ protected:
/**
\brief Make a constant for DK_SYMBOL sort out of an integer
*/
app* mk_symbol_const(uint64 el, sort* s) {
app* mk_symbol_const(uint64_t el, sort* s) {
app * res;
if(m_arith.is_int(s)) {
res = m_arith.mk_numeral(rational(el, rational::ui64()), s);
@ -1128,7 +1128,7 @@ protected:
}
return res;
}
app* mk_const(uint64 el, sort* s) {
app* mk_const(uint64_t el, sort* s) {
unsigned idx = m_context.get_constant_number(s, el);
app * res = m_decl_util.mk_numeral(idx, s);
return res;
@ -1137,7 +1137,7 @@ protected:
table_element mk_table_const(symbol const& name, sort* s) {
return m_context.get_constant_number(s, name);
}
table_element mk_table_const(uint64 el, sort* s) {
table_element mk_table_const(uint64_t el, sort* s) {
return m_context.get_constant_number(s, el);
}
};
@ -1169,9 +1169,9 @@ protected:
// -----------------------------------
class wpa_parser_impl : public wpa_parser, dparser {
typedef svector<uint64> uint64_vector;
typedef hashtable<uint64, uint64_hash, default_eq<uint64> > uint64_set;
typedef map<uint64, symbol, uint64_hash, default_eq<uint64> > num2sym;
typedef svector<uint64_t> uint64_vector;
typedef hashtable<uint64_t, uint64_hash, default_eq<uint64_t> > uint64_set;
typedef map<uint64_t, symbol, uint64_hash, default_eq<uint64_t> > num2sym;
typedef map<symbol, uint64_set*, symbol_hash_proc, symbol_eq_proc> sym2nums;
num2sym m_number_names;
@ -1261,7 +1261,7 @@ private:
return true;
}
bool inp_num_to_element(sort * s, uint64 num, table_element & res) {
bool inp_num_to_element(sort * s, uint64_t num, table_element & res) {
if(s==m_bool_sort.get() || s==m_short_sort.get()) {
res = mk_table_const(num, s);
return true;
@ -1332,7 +1332,7 @@ private:
if(*ptr==0) {
break;
}
uint64 num;
uint64_t num;
if(!read_uint64(ptr, num)) {
throw default_exception(default_exception::fmt(), "number expected on line %d in file %s",
m_current_line, m_current_file.c_str());
@ -1389,7 +1389,7 @@ private:
bool fact_fail = false;
fact.reset();
for(unsigned i=0;i<pred_arity; i++) {
uint64 const_num = args[i];
uint64_t const_num = args[i];
table_element c;
if(!inp_num_to_element(arg_sorts[i], const_num, c)) {
fact_fail = true;
@ -1415,7 +1415,7 @@ private:
symbol sort_name = sit->m_key;
uint64_set & sort_content = *sit->m_value;
//the +1 is for a zero element which happens to appear in the problem files
uint64 domain_size = sort_content.size()+1;
uint64_t domain_size = sort_content.size()+1;
// sort * s;
if(!m_use_map_names) {
/* s = */ register_finite_sort(sort_name, domain_size, context::SK_UINT64);
@ -1428,7 +1428,7 @@ private:
uint64_set::iterator cit = sort_content.begin();
uint64_set::iterator cend = sort_content.end();
for(; cit!=cend; ++cit) {
uint64 const_num = *cit;
uint64_t const_num = *cit;
inp_num_to_element(s, const_num);
}
*/
@ -1443,7 +1443,7 @@ private:
*ptr=0;
}
bool parse_map_line(char * full_line, uint64 & num, symbol & name) {
bool parse_map_line(char * full_line, uint64_t & num, symbol & name) {
cut_off_comment(full_line);
if(full_line[0]==0) {
return false;
@ -1515,7 +1515,7 @@ private:
m_current_line++;
char * full_line = rdr.get_line();
uint64 num;
uint64_t num;
symbol el_name;
if(!parse_map_line(full_line, num, el_name)) {

View file

@ -384,7 +384,7 @@ namespace datalog {
VERIFY(sig.first_functional() == 1);
uint64 upper_bound = get_signature()[0];
uint64_t upper_bound = get_signature()[0];
bool empty_table = empty();
if (upper_bound > (1 << 18)) {

View file

@ -832,7 +832,7 @@ namespace datalog {
class table_plugin;
class table_base;
typedef uint64 table_sort;
typedef uint64_t table_sort;
typedef svector<table_sort> table_signature_base0;
typedef uint64_hash table_sort_hash;

View file

@ -448,7 +448,7 @@ namespace datalog {
}
std::string relation_manager::to_nice_string(const relation_element & el) const {
uint64 val;
uint64_t val;
std::stringstream stm;
if(get_context().get_decl_util().is_numeral_ext(el, val)) {
stm << val;
@ -461,7 +461,7 @@ namespace datalog {
std::string relation_manager::to_nice_string(const relation_sort & s, const relation_element & el) const {
std::stringstream stm;
uint64 val;
uint64_t val;
if(get_context().get_decl_util().is_numeral_ext(el, val)) {
get_context().print_constant_name(s, val, stm);
}
@ -1339,9 +1339,9 @@ namespace datalog {
class relation_manager::default_table_filter_not_equal_fn
: public table_mutator_fn, auxiliary_table_filter_fn {
unsigned m_column;
uint64 m_value;
uint64_t m_value;
public:
default_table_filter_not_equal_fn(context & ctx, unsigned column, uint64 value)
default_table_filter_not_equal_fn(context & ctx, unsigned column, uint64_t value)
: m_column(column),
m_value(value) {
}
@ -1372,7 +1372,7 @@ namespace datalog {
return nullptr;
}
dl_decl_util decl_util(m);
uint64 value = 0;
uint64_t value = 0;
if (!decl_util.is_numeral_ext(y, value)) {
return nullptr;
}

View file

@ -93,7 +93,7 @@ namespace datalog {
//
// -----------------------------------
unsigned get_domain_length(uint64 dom_size) {
unsigned get_domain_length(uint64_t dom_size) {
SASSERT(dom_size>0);
unsigned length = 0;
@ -128,7 +128,7 @@ namespace datalog {
unsigned sig_sz = sig.size();
unsigned first_functional = sig_sz-m_functional_col_cnt;
for (unsigned i=0; i<sig_sz; i++) {
uint64 dom_size = sig[i];
uint64_t dom_size = sig[i];
unsigned length = get_domain_length(dom_size);
SASSERT(length>0);
SASSERT(length<=64);

View file

@ -153,7 +153,7 @@ namespace datalog {
variable. Otherwise \c m_reserve==NO_RESERVE.
The size of m_data is actually 8 bytes larger than stated in m_data_size, so that we may
deref an uint64 pointer at the end of the array.
deref an uint64_t pointer at the end of the array.
*/
storage m_data;
storage_indexer m_data_indexer;
@ -290,10 +290,10 @@ namespace datalog {
//the following two operations allow breaking of the object invariant!
void resize_data(size_t sz) {
m_data_size = sz;
if (sz + sizeof(uint64) < sz) {
if (sz + sizeof(uint64_t) < sz) {
throw default_exception("overflow resizing data section for sparse table");
}
m_data.resize(sz + sizeof(uint64));
m_data.resize(sz + sizeof(uint64_t));
}
bool insert_offset(store_offset ofs) {
@ -321,8 +321,8 @@ namespace datalog {
class column_info {
unsigned m_big_offset;
unsigned m_small_offset;
uint64 m_mask;
uint64 m_write_mask;
uint64_t m_mask;
uint64_t m_write_mask;
public:
unsigned m_offset; //!< in bits
unsigned m_length; //!< in bits
@ -330,7 +330,7 @@ namespace datalog {
column_info(unsigned offset, unsigned length) \
: m_big_offset(offset/8),
m_small_offset(offset%8),
m_mask( length==64 ? ULLONG_MAX : (static_cast<uint64>(1)<<length)-1 ),
m_mask( length==64 ? ULLONG_MAX : (static_cast<uint64_t>(1)<<length)-1 ),
m_write_mask( ~(m_mask<<m_small_offset) ),
m_offset(offset),
m_length(length) {
@ -338,15 +338,15 @@ namespace datalog {
SASSERT(length+m_small_offset<=64);
}
table_element get(const char * rec) const {
const uint64 * ptr = reinterpret_cast<const uint64*>(rec+m_big_offset);
uint64 res = *ptr;
const uint64_t * ptr = reinterpret_cast<const uint64_t*>(rec+m_big_offset);
uint64_t res = *ptr;
res>>=m_small_offset;
res&=m_mask;
return res;
}
void set(char * rec, table_element val) const {
SASSERT( (val&~m_mask)==0 ); //the value fits into the column
uint64 * ptr = reinterpret_cast<uint64*>(rec+m_big_offset);
uint64_t * ptr = reinterpret_cast<uint64_t*>(rec+m_big_offset);
*ptr&=m_write_mask;
*ptr|=val<<m_small_offset;
}

View file

@ -62,13 +62,13 @@ doc* doc_manager::allocate(tbv* t) {
doc* doc_manager::allocate(tbv const& src) {
return allocate(m.allocate(src));
}
doc* doc_manager::allocate(uint64 n) {
doc* doc_manager::allocate(uint64_t n) {
return allocate(m.allocate(n));
}
doc* doc_manager::allocate(rational const& r) {
return allocate(m.allocate(r));
}
doc* doc_manager::allocate(uint64 n, unsigned hi, unsigned lo) {
doc* doc_manager::allocate(uint64_t n, unsigned hi, unsigned lo) {
return allocate(m.allocate(n, hi, lo));
}
doc* doc_manager::allocate(doc const& src, unsigned const* permutation) {

View file

@ -61,9 +61,9 @@ public:
doc* allocate(doc const& src);
doc* allocate(tbv const& src);
doc* allocate(tbv * src);
doc* allocate(uint64 n);
doc* allocate(uint64_t n);
doc* allocate(rational const& r);
doc* allocate(uint64 n, unsigned hi, unsigned lo);
doc* allocate(uint64_t n, unsigned hi, unsigned lo);
doc* allocate(doc const& src, unsigned const* permutation);
void deallocate(doc* src);
void copy(doc& dst, doc const& src);

View file

@ -215,7 +215,7 @@ namespace datalog {
SASSERT(remaining_time_limit>restart_time);
remaining_time_limit -= restart_time;
}
uint64 new_restart_time = static_cast<uint64>(restart_time)*m_context.initial_restart_timeout();
uint64_t new_restart_time = static_cast<uint64_t>(restart_time)*m_context.initial_restart_timeout();
if (new_restart_time > UINT_MAX) {
restart_time = UINT_MAX;
}

View file

@ -72,7 +72,7 @@ tbv* tbv_manager::allocate(tbv const& bv) {
copy(*r, bv);
return r;
}
tbv* tbv_manager::allocate(uint64 val) {
tbv* tbv_manager::allocate(uint64_t val) {
tbv* v = allocate0();
for (unsigned bit = std::min(64u, num_tbits()); bit-- > 0;) {
if (val & (1ULL << bit)) {
@ -84,7 +84,7 @@ tbv* tbv_manager::allocate(uint64 val) {
return v;
}
tbv* tbv_manager::allocate(uint64 val, unsigned hi, unsigned lo) {
tbv* tbv_manager::allocate(uint64_t val, unsigned hi, unsigned lo) {
tbv* v = allocateX();
SASSERT(64 >= num_tbits() && num_tbits() > hi && hi >= lo);
set(*v, val, hi, lo);
@ -134,7 +134,7 @@ void tbv_manager::set(tbv& dst, unsigned index, tbit value) {
}
void tbv_manager::set(tbv& dst, uint64 val, unsigned hi, unsigned lo) {
void tbv_manager::set(tbv& dst, uint64_t val, unsigned hi, unsigned lo) {
SASSERT(lo <= hi && hi < num_tbits());
for (unsigned i = 0; i < hi - lo + 1; ++i) {
set(dst, lo + i, (val & (1ULL << i))?BIT_1:BIT_0);

View file

@ -51,9 +51,9 @@ public:
tbv* allocate0();
tbv* allocateX();
tbv* allocate(tbv const& bv);
tbv* allocate(uint64 n);
tbv* allocate(uint64_t n);
tbv* allocate(rational const& r);
tbv* allocate(uint64 n, unsigned hi, unsigned lo);
tbv* allocate(uint64_t n, unsigned hi, unsigned lo);
tbv* allocate(tbv const& bv, unsigned const* permutation);
tbv* allocate(char const* bv);
@ -80,7 +80,7 @@ public:
std::ostream& display(std::ostream& out, tbv const& b, unsigned hi, unsigned lo) const;
tbv* project(bit_vector const& to_delete, tbv const& src);
bool is_well_formed(tbv const& b) const; // - does not contain BIT_z;
void set(tbv& dst, uint64 n, unsigned hi, unsigned lo);
void set(tbv& dst, uint64_t n, unsigned hi, unsigned lo);
void set(tbv& dst, rational const& r, unsigned hi, unsigned lo);
void set(tbv& dst, tbv const& other, unsigned hi, unsigned lo);
void set(tbv& dst, unsigned index, tbit value);

View file

@ -261,7 +261,7 @@ namespace datalog {
num_bits = 1;
return true;
}
uint64 n, sz;
uint64_t n, sz;
ast_manager& m = get_ast_manager();
if (dl.is_numeral(e, n) && dl.try_get_size(m.get_sort(e), sz)) {
num_bits = 0;
@ -277,7 +277,7 @@ namespace datalog {
return bv.get_bv_size(s);
if (m.is_bool(s))
return 1;
uint64 sz;
uint64_t sz;
if (dl.try_get_size(s, sz)) {
while (sz > 0) ++num_bits, sz /= 2;
return num_bits;