mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-30 19:22:28 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/master' into regex-develop
This commit is contained in:
		
						commit
						47007d3f04
					
				
					 106 changed files with 877 additions and 712 deletions
				
			
		|  | @ -33,8 +33,8 @@ endif() | |||
| # Project version | ||||
| ################################################################################ | ||||
| set(Z3_VERSION_MAJOR 4) | ||||
| set(Z3_VERSION_MINOR 6) | ||||
| set(Z3_VERSION_PATCH 3) | ||||
| set(Z3_VERSION_MINOR 7) | ||||
| set(Z3_VERSION_PATCH 0) | ||||
| set(Z3_VERSION_TWEAK 0) | ||||
| set(Z3_VERSION "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}") | ||||
| set(Z3_FULL_VERSION_STR "${Z3_VERSION}") # Note this might be modified | ||||
|  |  | |||
|  | @ -920,6 +920,19 @@ void enum_sort_example() { | |||
|     std::cout << "2: " << result_goal.as_expr() << std::endl; | ||||
| } | ||||
| 
 | ||||
| void tuple_example() { | ||||
|     std::cout << "tuple example\n"; | ||||
|     context ctx; | ||||
|     const char * names[] = { "first", "second" }; | ||||
|     sort sorts[2] = { ctx.int_sort(), ctx.bool_sort() }; | ||||
|     func_decl_vector projs(ctx); | ||||
|     func_decl pair = ctx.tuple_sort("pair", 2, names, sorts, projs); | ||||
|     sorts[1] = pair.range(); | ||||
|     func_decl pair2 = ctx.tuple_sort("pair2", 2, names, sorts, projs); | ||||
|      | ||||
|     std::cout << pair2 << "\n"; | ||||
| } | ||||
| 
 | ||||
| void expr_vector_example() { | ||||
|     std::cout << "expr_vector example\n"; | ||||
|     context c; | ||||
|  | @ -1179,6 +1192,7 @@ int main() { | |||
|         incremental_example2(); std::cout << "\n"; | ||||
|         incremental_example3(); std::cout << "\n"; | ||||
|         enum_sort_example(); std::cout << "\n"; | ||||
|         tuple_example(); std::cout << "\n"; | ||||
|         expr_vector_example(); std::cout << "\n"; | ||||
|         exists_expr_vector_example(); std::cout << "\n"; | ||||
|         substitute_example(); std::cout << "\n"; | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ from mk_util import * | |||
| 
 | ||||
| # Z3 Project definition | ||||
| def init_project_def(): | ||||
|     set_version(4, 6, 3, 0) | ||||
|     set_version(4, 7, 0, 0) | ||||
|     add_lib('util', []) | ||||
|     add_lib('lp', ['util'], 'util/lp') | ||||
|     add_lib('polynomial', ['util'], 'math/polynomial') | ||||
|  |  | |||
|  | @ -60,7 +60,7 @@ FIRST_OBJ_ID = 100 | |||
| def is_obj(ty): | ||||
|     return ty >= FIRST_OBJ_ID | ||||
| 
 | ||||
| Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : '__int64', UINT64 : '__uint64', DOUBLE : 'double', | ||||
| Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : 'int64_t', UINT64 : 'uint64_t', DOUBLE : 'double', | ||||
|              FLOAT : 'float', STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'Z3_bool', SYMBOL : 'Z3_symbol', | ||||
|              PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code' | ||||
|              } | ||||
|  | @ -577,9 +577,6 @@ def mk_java(java_dir, package_name): | |||
|     java_wrapper = open(java_wrapperf, 'w') | ||||
|     pkg_str = package_name.replace('.', '_') | ||||
|     java_wrapper.write('// Automatically generated file\n') | ||||
|     java_wrapper.write('#ifdef _CYGWIN\n') | ||||
|     java_wrapper.write('typedef long long __int64;\n') | ||||
|     java_wrapper.write('#endif\n') | ||||
|     java_wrapper.write('#include<jni.h>\n') | ||||
|     java_wrapper.write('#include<stdlib.h>\n') | ||||
|     java_wrapper.write('#include"z3.h"\n') | ||||
|  |  | |||
|  | @ -184,7 +184,7 @@ namespace api { | |||
|             e = m_bv_util.mk_numeral(n, s); | ||||
|         } | ||||
|         else if (fid == get_datalog_fid() && n.is_uint64()) { | ||||
|             uint64 sz; | ||||
|             uint64_t sz; | ||||
|             if (m_datalog_util.try_get_size(s, sz) &&  | ||||
|                 sz <= n.get_uint64()) { | ||||
|                 invoke_error_handler(Z3_INVALID_ARG); | ||||
|  |  | |||
|  | @ -189,7 +189,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(nullptr); | ||||
|     } | ||||
| 
 | ||||
|     Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, __uint64 size) { | ||||
|     Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, uint64_t size) { | ||||
|         Z3_TRY; | ||||
|         LOG_Z3_mk_finite_domain_sort(c, name, size); | ||||
|         RESET_ERROR_CODE(); | ||||
|  | @ -199,7 +199,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(nullptr); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, __uint64 * out) { | ||||
|     Z3_bool Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, uint64_t * out) { | ||||
|         Z3_TRY; | ||||
|         if (out) { | ||||
|             *out = 0; | ||||
|  | @ -215,7 +215,6 @@ extern "C" { | |||
|         RESET_ERROR_CODE();   | ||||
|         VERIFY(mk_c(c)->datalog_util().try_get_size(to_sort(s), *out)); | ||||
|         return Z3_TRUE; | ||||
| 
 | ||||
|         Z3_CATCH_RETURN(Z3_FALSE); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -358,7 +358,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(nullptr); | ||||
|     } | ||||
| 
 | ||||
|     Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, __int64 exp, __uint64 sig, Z3_sort ty) { | ||||
|     Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, int64_t exp, uint64_t sig, Z3_sort ty) { | ||||
|         Z3_TRY; | ||||
|         LOG_Z3_mk_fpa_numeral_int64_uint64(c, sgn, exp, sig, ty); | ||||
|         RESET_ERROR_CODE(); | ||||
|  | @ -1035,7 +1035,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(""); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, __uint64 * n) { | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, uint64_t * n) { | ||||
|         Z3_TRY; | ||||
|         LOG_Z3_fpa_get_numeral_significand_uint64(c, t, n); | ||||
|         RESET_ERROR_CODE(); | ||||
|  | @ -1113,7 +1113,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(""); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, __int64 * n, Z3_bool biased) { | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, int64_t * n, Z3_bool biased) { | ||||
|         Z3_TRY; | ||||
|         LOG_Z3_fpa_get_numeral_exponent_int64(c, t, n, biased); | ||||
|         RESET_ERROR_CODE(); | ||||
|  |  | |||
|  | @ -116,7 +116,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(nullptr); | ||||
|     } | ||||
| 
 | ||||
|     Z3_ast Z3_API Z3_mk_int64(Z3_context c, long long value, Z3_sort ty) { | ||||
|     Z3_ast Z3_API Z3_mk_int64(Z3_context c, int64_t value, Z3_sort ty) { | ||||
|         Z3_TRY; | ||||
|         LOG_Z3_mk_int64(c, value, ty); | ||||
|         RESET_ERROR_CODE(); | ||||
|  | @ -129,7 +129,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(nullptr); | ||||
|     } | ||||
| 
 | ||||
|     Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, unsigned long long value, Z3_sort ty) { | ||||
|     Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, uint64_t value, Z3_sort ty) { | ||||
|         Z3_TRY; | ||||
|         LOG_Z3_mk_unsigned_int64(c, value, ty); | ||||
|         RESET_ERROR_CODE(); | ||||
|  | @ -172,7 +172,7 @@ extern "C" { | |||
|         if (mk_c(c)->bvutil().is_numeral(e, r, bv_size)) { | ||||
|             return Z3_TRUE; | ||||
|         } | ||||
|         uint64 v; | ||||
|         uint64_t v; | ||||
|         if (mk_c(c)->datalog_util().is_numeral(e, v)) { | ||||
|             r = rational(v, rational::ui64()); | ||||
|             return Z3_TRUE; | ||||
|  | @ -262,7 +262,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(""); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_get_numeral_small(Z3_context c, Z3_ast a, long long* num, long long* den) { | ||||
|     Z3_bool Z3_API Z3_get_numeral_small(Z3_context c, Z3_ast a, int64_t* num, int64_t* den) { | ||||
|         Z3_TRY; | ||||
|         // This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
 | ||||
|         LOG_Z3_get_numeral_small(c, a, num, den); | ||||
|  | @ -296,7 +296,7 @@ extern "C" { | |||
|             SET_ERROR_CODE(Z3_INVALID_ARG); | ||||
|             return Z3_FALSE; | ||||
|         } | ||||
|         long long l; | ||||
|         int64_t l; | ||||
|         if (Z3_get_numeral_int64(c, v, &l) && l >= INT_MIN && l <= INT_MAX) { | ||||
|             *i = static_cast<int>(l); | ||||
|             return Z3_TRUE; | ||||
|  | @ -314,7 +314,7 @@ extern "C" { | |||
|             SET_ERROR_CODE(Z3_INVALID_ARG); | ||||
|             return Z3_FALSE; | ||||
|         } | ||||
|         unsigned long long l; | ||||
|         uint64_t l; | ||||
|         if (Z3_get_numeral_uint64(c, v, &l) && (l <= 0xFFFFFFFF)) { | ||||
|             *u = static_cast<unsigned>(l); | ||||
|             return Z3_TRUE; | ||||
|  | @ -323,7 +323,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(Z3_FALSE); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, unsigned long long* u) { | ||||
|     Z3_bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, uint64_t* u) { | ||||
|         Z3_TRY; | ||||
|         // This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
 | ||||
|         LOG_Z3_get_numeral_uint64(c, v, u); | ||||
|  | @ -343,7 +343,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(Z3_FALSE); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, long long* i) { | ||||
|     Z3_bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, int64_t* i) { | ||||
|         Z3_TRY; | ||||
|         // This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
 | ||||
|         LOG_Z3_get_numeral_int64(c, v, i); | ||||
|  | @ -362,7 +362,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(Z3_FALSE); | ||||
|     } | ||||
| 
 | ||||
|     Z3_bool Z3_API Z3_get_numeral_rational_int64(Z3_context c, Z3_ast v, long long* num, long long* den) { | ||||
|     Z3_bool Z3_API Z3_get_numeral_rational_int64(Z3_context c, Z3_ast v, int64_t* num, int64_t* den) { | ||||
|         Z3_TRY; | ||||
|         // This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
 | ||||
|         LOG_Z3_get_numeral_rational_int64(c, v, num, den); | ||||
|  |  | |||
|  | @ -130,7 +130,7 @@ extern "C" { | |||
|         Z3_CATCH_RETURN(0.0); | ||||
|     } | ||||
| 
 | ||||
|     __uint64 Z3_API Z3_get_estimated_alloc_size(void) { | ||||
|     uint64_t Z3_API Z3_get_estimated_alloc_size(void) { | ||||
|         return memory::get_allocation_size(); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -267,6 +267,15 @@ namespace z3 { | |||
|            and in \c ts the predicates for testing if terms of the enumeration sort correspond to an enumeration. | ||||
|         */ | ||||
|         sort enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts); | ||||
| 
 | ||||
|         /**
 | ||||
|            \brief Return a tuple constructor. | ||||
|            \c name is the name of the returned constructor, | ||||
|            \c n are the number of arguments, \c names and \c sorts are their projected sorts. | ||||
|            \c projs is an output paramter. It contains the set of projection functions. | ||||
|         */ | ||||
|         func_decl tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs); | ||||
| 
 | ||||
|         /**
 | ||||
|            \brief create an uninterpreted sort with the name given by the string or symbol. | ||||
|          */ | ||||
|  | @ -294,21 +303,21 @@ namespace z3 { | |||
| 
 | ||||
|         expr int_val(int n); | ||||
|         expr int_val(unsigned n); | ||||
|         expr int_val(__int64 n); | ||||
|         expr int_val(__uint64 n); | ||||
|         expr int_val(int64_t n); | ||||
|         expr int_val(uint64_t n); | ||||
|         expr int_val(char const * n); | ||||
| 
 | ||||
|         expr real_val(int n, int d); | ||||
|         expr real_val(int n); | ||||
|         expr real_val(unsigned n); | ||||
|         expr real_val(__int64 n); | ||||
|         expr real_val(__uint64 n); | ||||
|         expr real_val(int64_t n); | ||||
|         expr real_val(uint64_t n); | ||||
|         expr real_val(char const * n); | ||||
| 
 | ||||
|         expr bv_val(int n, unsigned sz); | ||||
|         expr bv_val(unsigned n, unsigned sz); | ||||
|         expr bv_val(__int64 n, unsigned sz); | ||||
|         expr bv_val(__uint64 n, unsigned sz); | ||||
|         expr bv_val(int64_t n, unsigned sz); | ||||
|         expr bv_val(uint64_t n, unsigned sz); | ||||
|         expr bv_val(char const * n, unsigned sz); | ||||
|         expr bv_val(unsigned n, bool const* bits); | ||||
| 
 | ||||
|  | @ -660,8 +669,8 @@ namespace z3 { | |||
|            small integers, 64 bit integers or rational or decimal strings. | ||||
|         */ | ||||
|         bool is_numeral() const { return kind() == Z3_NUMERAL_AST; } | ||||
|         bool is_numeral_i64(__int64& i) const { bool r = 0 != Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;} | ||||
|         bool is_numeral_u64(__uint64& i) const { bool r = 0 != Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;} | ||||
|         bool is_numeral_i64(int64_t& i) const { bool r = 0 != Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;} | ||||
|         bool is_numeral_u64(uint64_t& i) const { bool r = 0 != Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;} | ||||
|         bool is_numeral_i(int& i) const { bool r = 0 != Z3_get_numeral_int(ctx(), m_ast, &i); check_error(); return r;} | ||||
|         bool is_numeral_u(unsigned& i) const { bool r = 0 != Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;} | ||||
|         bool is_numeral(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_string(ctx(), m_ast); check_error(); return true; } | ||||
|  | @ -744,35 +753,35 @@ namespace z3 { | |||
|         } | ||||
|          | ||||
|         /**
 | ||||
|            \brief Return __int64 value of numeral, throw if result cannot fit in | ||||
|            __int64 | ||||
|            \brief Return \c int64_t value of numeral, throw if result cannot fit in | ||||
|            \c int64_t. | ||||
|             | ||||
|            \pre is_numeral() | ||||
|         */ | ||||
|         __int64 get_numeral_int64() const { | ||||
|         int64_t get_numeral_int64() const { | ||||
|             assert(is_numeral()); | ||||
|             __int64 result = 0; | ||||
|             int64_t result = 0; | ||||
|             if (!is_numeral_i64(result)) { | ||||
|                 assert(ctx().enable_exceptions()); | ||||
|                 if (!ctx().enable_exceptions()) return 0; | ||||
|                 Z3_THROW(exception("numeral does not fit in machine __int64")); | ||||
|                 Z3_THROW(exception("numeral does not fit in machine int64_t")); | ||||
|             } | ||||
|             return result; | ||||
|         } | ||||
|          | ||||
|         /**
 | ||||
|            \brief Return __uint64 value of numeral, throw if result cannot fit in | ||||
|            __uint64 | ||||
|            \brief Return \c uint64_t value of numeral, throw if result cannot fit in | ||||
|            \c uint64_t. | ||||
|             | ||||
|            \pre is_numeral() | ||||
|         */ | ||||
|         __uint64 get_numeral_uint64() const { | ||||
|         uint64_t get_numeral_uint64() const { | ||||
|             assert(is_numeral()); | ||||
|             __uint64 result = 0; | ||||
|             uint64_t result = 0; | ||||
|             if (!is_numeral_u64(result)) { | ||||
|                 assert(ctx().enable_exceptions()); | ||||
|                 if (!ctx().enable_exceptions()) return 0; | ||||
|                 Z3_THROW(exception("numeral does not fit in machine __uint64")); | ||||
|                 Z3_THROW(exception("numeral does not fit in machine uint64_t")); | ||||
|             } | ||||
|             return result; | ||||
|         } | ||||
|  | @ -2432,6 +2441,19 @@ namespace z3 { | |||
|         for (unsigned i = 0; i < n; i++) { cs.push_back(func_decl(*this, _cs[i])); ts.push_back(func_decl(*this, _ts[i])); } | ||||
|         return s; | ||||
|     } | ||||
|     inline func_decl context::tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs) { | ||||
|         array<Z3_symbol> _names(n); | ||||
|         array<Z3_sort> _sorts(n); | ||||
|         for (unsigned i = 0; i < n; i++) { _names[i] = Z3_mk_string_symbol(*this, names[i]); _sorts[i] = sorts[i]; } | ||||
|         array<Z3_func_decl> _projs(n); | ||||
|         Z3_symbol _name = Z3_mk_string_symbol(*this, name); | ||||
|         Z3_func_decl tuple; | ||||
|         sort _ignore_s = to_sort(*this, Z3_mk_tuple_sort(*this, _name, n, _names.ptr(), _sorts.ptr(), &tuple, _projs.ptr())); | ||||
|         check_error(); | ||||
|         for (unsigned i = 0; i < n; i++) { projs.push_back(func_decl(*this, _projs[i])); } | ||||
|         return func_decl(*this, tuple); | ||||
|     } | ||||
| 
 | ||||
|     inline sort context::uninterpreted_sort(char const* name) { | ||||
|         Z3_symbol _name = Z3_mk_string_symbol(*this, name); | ||||
|         return to_sort(*this, Z3_mk_uninterpreted_sort(*this, _name)); | ||||
|  | @ -2526,21 +2548,21 @@ namespace z3 { | |||
| 
 | ||||
|     inline expr context::int_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::int_val(unsigned n) { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::int_val(__int64 n) { Z3_ast r = Z3_mk_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::int_val(__uint64 n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::int_val(int64_t n) { Z3_ast r = Z3_mk_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::int_val(uint64_t n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::int_val(char const * n) { Z3_ast r = Z3_mk_numeral(m_ctx, n, int_sort()); check_error(); return expr(*this, r); } | ||||
| 
 | ||||
|     inline expr context::real_val(int n, int d) { Z3_ast r = Z3_mk_real(m_ctx, n, d); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(unsigned n) { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(__int64 n) { Z3_ast r = Z3_mk_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(__uint64 n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(int64_t n) { Z3_ast r = Z3_mk_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(uint64_t n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
|     inline expr context::real_val(char const * n) { Z3_ast r = Z3_mk_numeral(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } | ||||
| 
 | ||||
|     inline expr context::bv_val(int n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(unsigned n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(__int64 n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int64(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(__uint64 n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(int64_t n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int64(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(uint64_t n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(char const * n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_numeral(m_ctx, n, s); check_error(); return expr(*this, r); } | ||||
|     inline expr context::bv_val(unsigned n, bool const* bits) {  | ||||
|         array<Z3_bool> _bits(n); | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ Notes: | |||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <stdbool.h> | ||||
| #include <stdint.h> | ||||
| #include "z3_macros.h" | ||||
| #include "z3_api.h" | ||||
| #include "z3_ast_containers.h" | ||||
|  |  | |||
|  | @ -36,14 +36,6 @@ DEFINE_TYPE(Z3_fixedpoint); | |||
| DEFINE_TYPE(Z3_optimize); | ||||
| DEFINE_TYPE(Z3_rcf_num); | ||||
| 
 | ||||
| #ifndef __int64 | ||||
| #define __int64 long long | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __uint64 | ||||
| #define __uint64 unsigned long long | ||||
| #endif | ||||
| 
 | ||||
| /** \defgroup capi C API */ | ||||
| /*@{*/ | ||||
| 
 | ||||
|  | @ -1843,7 +1835,7 @@ extern "C" { | |||
| 
 | ||||
|        def_API('Z3_mk_finite_domain_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT64))) | ||||
|     */ | ||||
|     Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, __uint64 size); | ||||
|     Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, uint64_t size); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Create an array type. | ||||
|  | @ -3200,26 +3192,26 @@ extern "C" { | |||
|     /**
 | ||||
|        \brief Create a numeral of a int, bit-vector, or finite-domain sort. | ||||
| 
 | ||||
|        This function can be used to create numerals that fit in a machine __int64 integer. | ||||
|        This function can be used to create numerals that fit in a machine \c int64_t integer. | ||||
|        It is slightly faster than #Z3_mk_numeral since it is not necessary to parse a string. | ||||
| 
 | ||||
|        \sa Z3_mk_numeral | ||||
| 
 | ||||
|        def_API('Z3_mk_int64', AST, (_in(CONTEXT), _in(INT64), _in(SORT))) | ||||
|     */ | ||||
|     Z3_ast Z3_API Z3_mk_int64(Z3_context c, __int64 v, Z3_sort ty); | ||||
|     Z3_ast Z3_API Z3_mk_int64(Z3_context c, int64_t v, Z3_sort ty); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Create a numeral of a int, bit-vector, or finite-domain sort. | ||||
| 
 | ||||
|        This function can be used to create numerals that fit in a machine __uint64 integer. | ||||
|        This function can be used to create numerals that fit in a machine \c uint64_t integer. | ||||
|        It is slightly faster than #Z3_mk_numeral since it is not necessary to parse a string. | ||||
| 
 | ||||
|        \sa Z3_mk_numeral | ||||
| 
 | ||||
|        def_API('Z3_mk_unsigned_int64', AST, (_in(CONTEXT), _in(UINT64), _in(SORT))) | ||||
|     */ | ||||
|     Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, __uint64 v, Z3_sort ty); | ||||
|     Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, uint64_t v, Z3_sort ty); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief create a bit-vector numeral from a vector of Booleans. | ||||
|  | @ -3868,7 +3860,7 @@ extern "C" { | |||
| 
 | ||||
|         def_API('Z3_get_finite_domain_sort_size', BOOL, (_in(CONTEXT), _in(SORT), _out(UINT64))) | ||||
|     */ | ||||
|     Z3_bool_opt Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, __uint64* r); | ||||
|     Z3_bool_opt Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, uint64_t* r); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return the domain of the given array sort. | ||||
|  | @ -4425,7 +4417,7 @@ extern "C" { | |||
| 
 | ||||
|        def_API('Z3_get_numeral_small', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _out(INT64))) | ||||
|     */ | ||||
|     Z3_bool Z3_API Z3_get_numeral_small(Z3_context c, Z3_ast a, __int64* num, __int64* den); | ||||
|     Z3_bool Z3_API Z3_get_numeral_small(Z3_context c, Z3_ast a, int64_t* num, int64_t* den); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Similar to #Z3_get_numeral_string, but only succeeds if | ||||
|  | @ -4453,7 +4445,7 @@ extern "C" { | |||
| 
 | ||||
|     /**
 | ||||
|        \brief Similar to #Z3_get_numeral_string, but only succeeds if | ||||
|        the value can fit in a machine __uint64 int. Return Z3_TRUE if the call succeeded. | ||||
|        the value can fit in a machine \c uint64_t int. Return Z3_TRUE if the call succeeded. | ||||
| 
 | ||||
|        \pre Z3_get_ast_kind(c, v) == Z3_NUMERAL_AST | ||||
| 
 | ||||
|  | @ -4461,11 +4453,11 @@ extern "C" { | |||
| 
 | ||||
|        def_API('Z3_get_numeral_uint64', BOOL, (_in(CONTEXT), _in(AST), _out(UINT64))) | ||||
|     */ | ||||
|     Z3_bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, __uint64* u); | ||||
|     Z3_bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, uint64_t* u); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Similar to #Z3_get_numeral_string, but only succeeds if | ||||
|        the value can fit in a machine __int64 int. Return Z3_TRUE if the call succeeded. | ||||
|        the value can fit in a machine \c int64_t int. Return Z3_TRUE if the call succeeded. | ||||
| 
 | ||||
|        \pre Z3_get_ast_kind(c, v) == Z3_NUMERAL_AST | ||||
| 
 | ||||
|  | @ -4473,11 +4465,11 @@ extern "C" { | |||
| 
 | ||||
|        def_API('Z3_get_numeral_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64))) | ||||
|     */ | ||||
|     Z3_bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, __int64* i); | ||||
|     Z3_bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, int64_t* i); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Similar to #Z3_get_numeral_string, but only succeeds if | ||||
|        the value can fit as a rational number as machine __int64 int. Return Z3_TRUE if the call succeeded. | ||||
|        the value can fit as a rational number as machine \c int64_t int. Return Z3_TRUE if the call succeeded. | ||||
| 
 | ||||
|        \pre Z3_get_ast_kind(c, v) == Z3_NUMERAL_AST | ||||
| 
 | ||||
|  | @ -4485,7 +4477,7 @@ extern "C" { | |||
| 
 | ||||
|        def_API('Z3_get_numeral_rational_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _out(INT64))) | ||||
|     */ | ||||
|     Z3_bool Z3_API Z3_get_numeral_rational_int64(Z3_context c, Z3_ast v, __int64* num, __int64* den); | ||||
|     Z3_bool Z3_API Z3_get_numeral_rational_int64(Z3_context c, Z3_ast v, int64_t* num, int64_t* den); | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return a lower bound for the given real algebraic number. | ||||
|  | @ -6248,7 +6240,7 @@ extern "C" { | |||
| 
 | ||||
|     def_API('Z3_get_estimated_alloc_size', UINT64, ()) | ||||
|     */ | ||||
|     __uint64 Z3_API Z3_get_estimated_alloc_size(void); | ||||
|     uint64_t Z3_API Z3_get_estimated_alloc_size(void); | ||||
| 
 | ||||
|     /*@}*/ | ||||
| 
 | ||||
|  |  | |||
|  | @ -349,7 +349,7 @@ extern "C" { | |||
| 
 | ||||
|         def_API('Z3_mk_fpa_numeral_int64_uint64', AST, (_in(CONTEXT), _in(BOOL), _in(INT64), _in(UINT64), _in(SORT))) | ||||
|     */ | ||||
|     Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, __int64 exp, __uint64 sig, Z3_sort ty); | ||||
|     Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, int64_t exp, uint64_t sig, Z3_sort ty); | ||||
| 
 | ||||
|     /**
 | ||||
|         \brief Floating-point absolute value | ||||
|  | @ -956,7 +956,7 @@ extern "C" { | |||
| 
 | ||||
|         def_API('Z3_fpa_get_numeral_significand_uint64', BOOL, (_in(CONTEXT), _in(AST), _out(UINT64))) | ||||
|     */ | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, __uint64 * n); | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, uint64_t * n); | ||||
| 
 | ||||
|     /**
 | ||||
|         \brief Return the exponent value of a floating-point numeral as a string. | ||||
|  | @ -985,7 +985,7 @@ extern "C" { | |||
| 
 | ||||
|         def_API('Z3_fpa_get_numeral_exponent_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _in(BOOL))) | ||||
|     */ | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, __int64 * n, Z3_bool biased); | ||||
|     Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, int64_t * n, Z3_bool biased); | ||||
| 
 | ||||
|     /**
 | ||||
|         \brief Retrieves the exponent of a floating-point literal as a bit-vector expression. | ||||
|  |  | |||
|  | @ -23,8 +23,8 @@ static std::ostream & operator<<(std::ostream & out, ll_escaped const & d); | |||
| 
 | ||||
| static void __declspec(noinline) R()  { *g_z3_log << "R\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) P(void * obj)  { *g_z3_log << "P " << obj << "\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) I(__int64 i)   { *g_z3_log << "I " << i << "\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) U(__uint64 u)   { *g_z3_log << "U " << u << "\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) I(int64_t i)   { *g_z3_log << "I " << i << "\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) U(uint64_t u)   { *g_z3_log << "U " << u << "\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) D(double d)   { *g_z3_log << "D " << d << "\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) S(Z3_string str) { *g_z3_log << "S \"" << ll_escaped(str) << "\"\n"; g_z3_log->flush(); } | ||||
| static void __declspec(noinline) Sy(Z3_symbol sym) {  | ||||
|  |  | |||
|  | @ -40,8 +40,8 @@ struct z3_replayer::imp { | |||
|     int                      m_line;  // line
 | ||||
|     svector<char>            m_string; | ||||
|     symbol                   m_id; | ||||
|     __int64                  m_int64; | ||||
|     __uint64                 m_uint64; | ||||
|     int64_t                  m_int64; | ||||
|     uint64_t                 m_uint64; | ||||
|     double                   m_double; | ||||
|     float                    m_float; | ||||
|     size_t                   m_ptr; | ||||
|  | @ -85,8 +85,8 @@ struct z3_replayer::imp { | |||
|     struct value { | ||||
|         value_kind m_kind; | ||||
|         union { | ||||
|             __int64      m_int; | ||||
|             __uint64     m_uint; | ||||
|             int64_t      m_int; | ||||
|             uint64_t     m_uint; | ||||
|             double       m_double; | ||||
|             char const * m_str; | ||||
|             void *       m_obj; | ||||
|  | @ -95,8 +95,8 @@ struct z3_replayer::imp { | |||
|         value():m_kind(OBJECT), m_int(0) {} | ||||
|         value(void * obj):m_kind(OBJECT), m_obj(obj) {} | ||||
|         value(value_kind k, char const * str):m_kind(k), m_str(str) {} | ||||
|         value(value_kind k, __uint64 u):m_kind(k), m_uint(u) {} | ||||
|         value(value_kind k, __int64 i):m_kind(k), m_int(i) {} | ||||
|         value(value_kind k, uint64_t u):m_kind(k), m_uint(u) {} | ||||
|         value(value_kind k, int64_t i):m_kind(k), m_int(i) {} | ||||
|         value(value_kind k, double d):m_kind(k), m_double(d) {} | ||||
|         value(value_kind k, float f):m_kind(k), m_float(f) {} | ||||
|     }; | ||||
|  | @ -342,7 +342,7 @@ struct z3_replayer::imp { | |||
|         unsigned   asz = m_args.size(); | ||||
|         if (sz > asz) | ||||
|             throw z3_replayer_exception("invalid array size"); | ||||
|         __uint64   aidx; | ||||
|         uint64_t   aidx; | ||||
|         value_kind nk; | ||||
|         for (unsigned i = asz - sz; i < asz; i++) { | ||||
|             if (m_args[i].m_kind != k) | ||||
|  | @ -400,7 +400,7 @@ struct z3_replayer::imp { | |||
| #define TICK_FREQUENCY 100000 | ||||
| 
 | ||||
|     void parse() { | ||||
|         unsigned long long counter = 0; | ||||
|         uint64_t counter = 0; | ||||
|         unsigned tick = 0; | ||||
|         while (true) { | ||||
|             IF_VERBOSE(1, { | ||||
|  | @ -577,7 +577,7 @@ struct z3_replayer::imp { | |||
|         return static_cast<int>(m_args[pos].m_int); | ||||
|     } | ||||
| 
 | ||||
|     __int64 get_int64(unsigned pos) const { | ||||
|     int64_t get_int64(unsigned pos) const { | ||||
|         check_arg(pos, INT64); | ||||
|         return m_args[pos].m_int; | ||||
|     } | ||||
|  | @ -587,7 +587,7 @@ struct z3_replayer::imp { | |||
|         return static_cast<unsigned>(m_args[pos].m_uint); | ||||
|     } | ||||
| 
 | ||||
|     __uint64 get_uint64(unsigned pos) const { | ||||
|     uint64_t get_uint64(unsigned pos) const { | ||||
|         check_arg(pos, UINT64); | ||||
|         return m_args[pos].m_uint; | ||||
|     } | ||||
|  | @ -656,7 +656,7 @@ struct z3_replayer::imp { | |||
|         return reinterpret_cast<int*>(&(m_args[pos].m_int)); | ||||
|     } | ||||
| 
 | ||||
|     __int64 * get_int64_addr(unsigned pos) { | ||||
|     int64_t * get_int64_addr(unsigned pos) { | ||||
|         check_arg(pos, INT64); | ||||
|         return &(m_args[pos].m_int); | ||||
|     } | ||||
|  | @ -666,7 +666,7 @@ struct z3_replayer::imp { | |||
|         return reinterpret_cast<unsigned*>(&(m_args[pos].m_uint)); | ||||
|     } | ||||
| 
 | ||||
|     __uint64 * get_uint64_addr(unsigned pos) { | ||||
|     uint64_t * get_uint64_addr(unsigned pos) { | ||||
|         check_arg(pos, UINT64); | ||||
|         return &(m_args[pos].m_uint); | ||||
|     } | ||||
|  | @ -731,11 +731,11 @@ unsigned z3_replayer::get_uint(unsigned pos) const { | |||
|     return m_imp->get_uint(pos); | ||||
| } | ||||
| 
 | ||||
| __int64 z3_replayer::get_int64(unsigned pos) const { | ||||
| int64_t z3_replayer::get_int64(unsigned pos) const { | ||||
|     return m_imp->get_int64(pos); | ||||
| } | ||||
| 
 | ||||
| __uint64 z3_replayer::get_uint64(unsigned pos) const { | ||||
| uint64_t z3_replayer::get_uint64(unsigned pos) const { | ||||
|     return m_imp->get_uint64(pos); | ||||
| } | ||||
| 
 | ||||
|  | @ -783,7 +783,7 @@ int * z3_replayer::get_int_addr(unsigned pos) { | |||
|     return m_imp->get_int_addr(pos); | ||||
| } | ||||
| 
 | ||||
| __int64 * z3_replayer::get_int64_addr(unsigned pos) { | ||||
| int64_t * z3_replayer::get_int64_addr(unsigned pos) { | ||||
|     return m_imp->get_int64_addr(pos); | ||||
| } | ||||
| 
 | ||||
|  | @ -791,7 +791,7 @@ unsigned * z3_replayer::get_uint_addr(unsigned pos) { | |||
|     return m_imp->get_uint_addr(pos); | ||||
| } | ||||
| 
 | ||||
| __uint64 * z3_replayer::get_uint64_addr(unsigned pos) { | ||||
| uint64_t * z3_replayer::get_uint64_addr(unsigned pos) { | ||||
|     return m_imp->get_uint64_addr(pos); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -40,8 +40,8 @@ public: | |||
| 
 | ||||
|     int get_int(unsigned pos) const; | ||||
|     unsigned get_uint(unsigned pos) const; | ||||
|     __int64 get_int64(unsigned pos) const; | ||||
|     __uint64 get_uint64(unsigned pos) const; | ||||
|     int64_t get_int64(unsigned pos) const; | ||||
|     uint64_t get_uint64(unsigned pos) const; | ||||
|     float get_float(unsigned pos) const; | ||||
|     double get_double(unsigned pos) const; | ||||
|     bool get_bool(unsigned pos) const; | ||||
|  | @ -56,9 +56,9 @@ public: | |||
|     void ** get_obj_array(unsigned pos) const; | ||||
| 
 | ||||
|     int * get_int_addr(unsigned pos); | ||||
|     __int64 * get_int64_addr(unsigned pos); | ||||
|     int64_t * get_int64_addr(unsigned pos); | ||||
|     unsigned * get_uint_addr(unsigned pos); | ||||
|     __uint64 * get_uint64_addr(unsigned pos); | ||||
|     uint64_t * get_uint64_addr(unsigned pos); | ||||
|     Z3_string * get_str_addr(unsigned pos); | ||||
|     void ** get_obj_addr(unsigned pos); | ||||
| 
 | ||||
|  |  | |||
|  | @ -298,11 +298,11 @@ class sort_size { | |||
|         SS_FINITE_VERY_BIG, | ||||
|         SS_INFINITE | ||||
|     } m_kind; | ||||
|     uint64 m_size; // It is only meaningful if m_kind == SS_FINITE
 | ||||
|     sort_size(kind_t k, uint64 r):m_kind(k), m_size(r) {} | ||||
|     uint64_t m_size; // It is only meaningful if m_kind == SS_FINITE
 | ||||
|     sort_size(kind_t k, uint64_t r):m_kind(k), m_size(r) {} | ||||
| public: | ||||
|     sort_size():m_kind(SS_INFINITE) {} | ||||
|     sort_size(uint64 const & sz):m_kind(SS_FINITE), m_size(sz) {} | ||||
|     sort_size(uint64_t const & sz):m_kind(SS_FINITE), m_size(sz) {} | ||||
|     sort_size(sort_size const& other): m_kind(other.m_kind), m_size(other.m_size) {} | ||||
|     explicit sort_size(rational const& r) { | ||||
|         if (r.is_uint64()) { | ||||
|  | @ -316,7 +316,7 @@ public: | |||
|     } | ||||
|     static sort_size mk_infinite() { return sort_size(SS_INFINITE, 0); } | ||||
|     static sort_size mk_very_big() { return sort_size(SS_FINITE_VERY_BIG, 0); } | ||||
|     static sort_size mk_finite(uint64 r) { return sort_size(SS_FINITE, r); } | ||||
|     static sort_size mk_finite(uint64_t r) { return sort_size(SS_FINITE, r); } | ||||
| 
 | ||||
|     bool is_infinite() const { return m_kind == SS_INFINITE; } | ||||
|     bool is_very_big() const { return m_kind == SS_FINITE_VERY_BIG; } | ||||
|  | @ -324,7 +324,7 @@ public: | |||
| 
 | ||||
|     static bool is_very_big_base2(unsigned power) { return power >= 64; } | ||||
| 
 | ||||
|     uint64 size() const { SASSERT(is_finite()); return m_size; } | ||||
|     uint64_t size() const { SASSERT(is_finite()); return m_size; } | ||||
| }; | ||||
| 
 | ||||
| std::ostream& operator<<(std::ostream& out, sort_size const & ss); | ||||
|  | @ -346,7 +346,7 @@ public: | |||
|         decl_info(family_id, k, num_parameters, parameters, private_parameters) { | ||||
|     } | ||||
| 
 | ||||
|     sort_info(family_id family_id, decl_kind k, uint64 num_elements, | ||||
|     sort_info(family_id family_id, decl_kind k, uint64_t num_elements, | ||||
|               unsigned num_parameters = 0, parameter const * parameters = nullptr, bool private_parameters = false): | ||||
|         decl_info(family_id, k, num_parameters, parameters, private_parameters), m_num_elements(num_elements) { | ||||
|     } | ||||
|  |  | |||
|  | @ -387,7 +387,7 @@ format * smt2_pp_environment::pp_string_literal(app * t) { | |||
| } | ||||
| 
 | ||||
| format * smt2_pp_environment::pp_datalog_literal(app * t) { | ||||
|     uint64 v; | ||||
|     uint64_t v; | ||||
|     VERIFY (get_dlutil().is_numeral(t, v)); | ||||
|     std::ostringstream buffer; | ||||
|     buffer << v; | ||||
|  |  | |||
|  | @ -384,7 +384,7 @@ public: | |||
| 
 | ||||
|     app * mk_numeral(rational const & val, sort* s) const; | ||||
|     app * mk_numeral(rational const & val, unsigned bv_size) const; | ||||
|     app * mk_numeral(uint64 u, unsigned bv_size) const { return mk_numeral(rational(u, rational::ui64()), bv_size); } | ||||
|     app * mk_numeral(uint64_t u, unsigned bv_size) const { return mk_numeral(rational(u, rational::ui64()), bv_size); } | ||||
|     sort * mk_sort(unsigned bv_size); | ||||
| 
 | ||||
|     unsigned get_bv_size(sort const * s) const { | ||||
|  |  | |||
|  | @ -652,9 +652,9 @@ namespace datalog { | |||
| 
 | ||||
|     // create a constant belonging to a given finite domain.
 | ||||
| 
 | ||||
|     app* dl_decl_util::mk_numeral(uint64 value, sort* s) { | ||||
|     app* dl_decl_util::mk_numeral(uint64_t value, sort* s) { | ||||
|         if (is_finite_sort(s)) { | ||||
|             uint64 sz = 0; | ||||
|             uint64_t sz = 0; | ||||
|             if (try_get_size(s, sz) && sz <= value) { | ||||
|                 m.raise_exception("value is out of bounds"); | ||||
|             } | ||||
|  | @ -680,7 +680,7 @@ namespace datalog { | |||
|         return nullptr; | ||||
|     } | ||||
| 
 | ||||
|     bool dl_decl_util::is_numeral(const expr* e, uint64& v) const { | ||||
|     bool dl_decl_util::is_numeral(const expr* e, uint64_t& v) const { | ||||
|         if (is_numeral(e)) { | ||||
|             const app* c = to_app(e); | ||||
|             SASSERT(c->get_decl()->get_num_parameters() == 2); | ||||
|  | @ -693,7 +693,7 @@ namespace datalog { | |||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     bool dl_decl_util::is_numeral_ext(expr* e, uint64& v) const { | ||||
|     bool dl_decl_util::is_numeral_ext(expr* e, uint64_t& v) const { | ||||
|         if (is_numeral(e, v)) { | ||||
|             return true; | ||||
|         } | ||||
|  | @ -724,7 +724,7 @@ namespace datalog { | |||
|         return m.is_true(c) || m.is_false(c); | ||||
|     } | ||||
| 
 | ||||
|     sort* dl_decl_util::mk_sort(const symbol& name, uint64  domain_size) { | ||||
|     sort* dl_decl_util::mk_sort(const symbol& name, uint64_t  domain_size) { | ||||
|         if (domain_size == 0) { | ||||
|             std::stringstream sstm; | ||||
|             sstm << "Domain size of sort '" << name << "' may not be 0"; | ||||
|  | @ -734,7 +734,7 @@ namespace datalog { | |||
|         return m.mk_sort(m_fid, DL_FINITE_SORT, 2, params); | ||||
|     } | ||||
| 
 | ||||
|     bool dl_decl_util::try_get_size(const sort * s, uint64& size) const { | ||||
|     bool dl_decl_util::try_get_size(const sort * s, uint64_t& size) const { | ||||
|         sort_size sz = s->get_info()->get_num_elements(); | ||||
|         if (sz.is_finite()) { | ||||
|             size = sz.size(); | ||||
|  |  | |||
|  | @ -122,7 +122,7 @@ namespace datalog { | |||
|         // Contract for func_decl:
 | ||||
|         //   parameters[0]     - array sort
 | ||||
|         // Contract for OP_DL_CONSTANT:
 | ||||
|         //   parameters[0]     - rational containing uint64 with constant value
 | ||||
|         //   parameters[0]     - rational containing uint64_t with constant value
 | ||||
|         //   parameters[1]     - a DL_FINITE_SORT sort of the constant
 | ||||
|         // Contract for others:
 | ||||
|         //   no parameters
 | ||||
|  | @ -166,7 +166,7 @@ namespace datalog { | |||
|         dl_decl_util(ast_manager& m); | ||||
|         // create a constant belonging to a given finite domain.
 | ||||
|         // the options include the DL_FINITE_SORT, BV_SORT, and BOOL_SORT
 | ||||
|         app* mk_numeral(uint64 value, sort* s); | ||||
|         app* mk_numeral(uint64_t value, sort* s); | ||||
| 
 | ||||
|         app* mk_lt(expr* a, expr* b); | ||||
| 
 | ||||
|  | @ -176,19 +176,19 @@ namespace datalog { | |||
| 
 | ||||
|         bool is_numeral(const expr* c) const { return is_app_of(c, m_fid, OP_DL_CONSTANT); } | ||||
| 
 | ||||
|         bool is_numeral(const expr* e, uint64& v) const; | ||||
|         bool is_numeral(const expr* e, uint64_t& v) const; | ||||
| 
 | ||||
|         //
 | ||||
|         // Utilities for extracting constants 
 | ||||
|         // from bit-vectors and finite domains.
 | ||||
|         // 
 | ||||
|         bool is_numeral_ext(expr* c, uint64& v) const; | ||||
|         bool is_numeral_ext(expr* c, uint64_t& v) const; | ||||
| 
 | ||||
|         bool is_numeral_ext(expr* c) const;         | ||||
| 
 | ||||
|         sort* mk_sort(const symbol& name, uint64  domain_size); | ||||
|         sort* mk_sort(const symbol& name, uint64_t  domain_size); | ||||
| 
 | ||||
|         bool try_get_size(const sort *, uint64& size) const; | ||||
|         bool try_get_size(const sort *, uint64_t& size) const; | ||||
| 
 | ||||
|         bool is_finite_sort(sort* s) const {  | ||||
|             return is_sort_of(s, m_fid, DL_FINITE_SORT);  | ||||
|  |  | |||
|  | @ -262,11 +262,11 @@ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl * | |||
| 
 | ||||
|     unsigned arity = bv_f->get_arity(); | ||||
|     func_interp * bv_fi = mc->get_func_interp(bv_f); | ||||
|     result = alloc(func_interp, m, arity); | ||||
| 
 | ||||
|     if (bv_fi) { | ||||
|         fpa_rewriter rw(m); | ||||
|         expr_ref ai(m); | ||||
|         result = alloc(func_interp, m, arity); | ||||
| 
 | ||||
|         for (unsigned i = 0; i < bv_fi->num_entries(); i++) { | ||||
|             func_entry const * bv_fe = bv_fi->get_entry(i); | ||||
|  | @ -465,26 +465,7 @@ void bv2fpa_converter::convert_uf2bvuf(model_core * mc, model_core * target_mode | |||
|         else { | ||||
|             if (it->get_key().get_family_id() == m_fpa_util.get_fid()) { | ||||
|                 // it->m_value contains the model for the unspecified cases of it->m_key.
 | ||||
| 
 | ||||
|                 func_interp * fmv = convert_func_interp(mc, f, it->m_value); | ||||
|                 if (fmv) { | ||||
| #if 0 | ||||
|                     // Upon request, add this 'recursive' definition?
 | ||||
|                     unsigned n = fmv->get_arity(); | ||||
|                     expr_ref_vector args(m); | ||||
|                     for (unsigned i = 0; i < n; i++) | ||||
|                         args.push_back(m.mk_var(i, f->get_domain()[i])); | ||||
|                     fmv->set_else(m.mk_app(it->m_key, n, args.c_ptr())); | ||||
| #else | ||||
| 
 | ||||
|                     fmv->set_else(nullptr); | ||||
| #endif | ||||
|                     target_model->register_decl(f, fmv); | ||||
|                 } | ||||
|             } | ||||
|             else { | ||||
|                 func_interp * fmv = convert_func_interp(mc, f, it->m_value); | ||||
|                 if (fmv) target_model->register_decl(f, fmv); | ||||
|                 target_model->register_decl(f, convert_func_interp(mc, f, it->m_value)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -1071,7 +1071,7 @@ void fpa2bv_converter::mk_rem(sort * s, expr_ref & x, expr_ref & y, expr_ref & r | |||
|     SASSERT(m_mpz_manager.is_int64(max_exp_diff)); | ||||
|     SASSERT(m_mpz_manager.get_uint64(max_exp_diff) <= UINT_MAX); | ||||
| 
 | ||||
|     uint64 max_exp_diff_ui64 = m_mpz_manager.get_uint64(max_exp_diff); | ||||
|     uint64_t max_exp_diff_ui64 = m_mpz_manager.get_uint64(max_exp_diff); | ||||
|     SASSERT(max_exp_diff_ui64 <= UINT_MAX); | ||||
|     unsigned max_exp_diff_ui = (unsigned)max_exp_diff_ui64; | ||||
|     m_mpz_manager.del(max_exp_diff); | ||||
|  | @ -1919,7 +1919,7 @@ void fpa2bv_converter::mk_round_to_integral(sort * s, expr_ref & rm, expr_ref & | |||
| 
 | ||||
|     expr_ref pow_2_sbitsm1(m), m1(m); | ||||
|     pow_2_sbitsm1 = m_bv_util.mk_numeral(fu().fm().m_powers2(sbits - 1), sbits); | ||||
|     m1 = m_bv_util.mk_numeral(-1, ebits); | ||||
|     m1 = m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, ebits)); | ||||
|     m_simp.mk_eq(a_sig, pow_2_sbitsm1, t1); | ||||
|     m_simp.mk_eq(a_exp, m1, t2); | ||||
|     m_simp.mk_and(t1, t2, tie); | ||||
|  | @ -1927,7 +1927,7 @@ void fpa2bv_converter::mk_round_to_integral(sort * s, expr_ref & rm, expr_ref & | |||
| 
 | ||||
|     m_simp.mk_and(tie, rm_is_rte, c421); | ||||
|     m_simp.mk_and(tie, rm_is_rta, c422); | ||||
|     c423 = m_bv_util.mk_sle(a_exp, m_bv_util.mk_numeral(-2, ebits)); | ||||
|     c423 = m_bv_util.mk_sle(a_exp, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(2, ebits))); | ||||
| 
 | ||||
|     dbg_decouple("fpa2bv_r2i_c421", c421); | ||||
|     dbg_decouple("fpa2bv_r2i_c422", c422); | ||||
|  | @ -2452,7 +2452,7 @@ void fpa2bv_converter::mk_to_fp_float(sort * to_srt, expr * rm, expr * x, expr_r | |||
|             const mpz & ovft = m_mpf_manager.m_powers2.m1(to_ebits+1, false); | ||||
|             first_ovf_exp = m_bv_util.mk_numeral(ovft, from_ebits+2); | ||||
|             first_udf_exp = m_bv_util.mk_concat( | ||||
|                 m_bv_util.mk_numeral(-1, ebits_diff + 3), | ||||
|                 m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, ebits_diff + 3)), | ||||
|                 m_bv_util.mk_numeral(1, to_ebits + 1)); | ||||
|             dbg_decouple("fpa2bv_to_float_first_ovf_exp", first_ovf_exp); | ||||
|             dbg_decouple("fpa2bv_to_float_first_udf_exp", first_udf_exp); | ||||
|  | @ -2845,7 +2845,7 @@ void fpa2bv_converter::mk_to_fp_signed(func_decl * f, unsigned num, expr * const | |||
|     expr_ref is_neg(m), x_abs(m), neg_x(m); | ||||
|     is_neg_bit = m_bv_util.mk_extract(bv_sz - 1, bv_sz - 1, x); | ||||
|     is_neg = m.mk_eq(is_neg_bit, bv1_1); | ||||
|     neg_x = m_bv_util.mk_bv_neg(x); | ||||
|     neg_x = m_bv_util.mk_bv_neg(x); // overflow problem?
 | ||||
|     x_abs = m.mk_ite(is_neg, neg_x, x); | ||||
|     dbg_decouple("fpa2bv_to_fp_signed_is_neg", is_neg); | ||||
|     // x_abs has an extra bit in the front.
 | ||||
|  | @ -2882,11 +2882,13 @@ void fpa2bv_converter::mk_to_fp_signed(func_decl * f, unsigned num, expr * const | |||
|         SASSERT(is_well_sorted(m, lz)); | ||||
|     } | ||||
|     SASSERT(m_bv_util.get_bv_size(sig_4) == sig_sz); | ||||
|     dbg_decouple("fpa2bv_to_fp_signed_sig_4", sig_4); | ||||
| 
 | ||||
|     expr_ref s_exp(m), exp_rest(m); | ||||
|     s_exp = m_bv_util.mk_bv_sub(m_bv_util.mk_numeral(bv_sz - 2, bv_sz), lz); | ||||
|     // s_exp = (bv_sz-2) + (-lz) signed
 | ||||
|     SASSERT(m_bv_util.get_bv_size(s_exp) == bv_sz); | ||||
|     dbg_decouple("fpa2bv_to_fp_signed_s_exp", s_exp); | ||||
| 
 | ||||
|     unsigned exp_sz = ebits + 2; // (+2 for rounder)
 | ||||
|     exp_2 = m_bv_util.mk_extract(exp_sz - 1, 0, s_exp); | ||||
|  | @ -2907,10 +2909,9 @@ void fpa2bv_converter::mk_to_fp_signed(func_decl * f, unsigned num, expr * const | |||
|         mk_max_exp(exp_sz, max_exp); | ||||
|         max_exp_bvsz = m_bv_util.mk_zero_extend(bv_sz - exp_sz, max_exp); | ||||
| 
 | ||||
|         exp_too_large = m_bv_util.mk_ule(m_bv_util.mk_bv_add( | ||||
|             max_exp_bvsz, | ||||
|             m_bv_util.mk_numeral(1, bv_sz)), | ||||
|             s_exp); | ||||
|         exp_too_large = m_bv_util.mk_sle( | ||||
|                             m_bv_util.mk_bv_add(max_exp_bvsz, m_bv_util.mk_numeral(1, bv_sz)), | ||||
|                             s_exp); | ||||
|         zero_sig_sz = m_bv_util.mk_numeral(0, sig_sz); | ||||
|         sig_4 = m.mk_ite(exp_too_large, zero_sig_sz, sig_4); | ||||
|         exp_2 = m.mk_ite(exp_too_large, max_exp, exp_2); | ||||
|  | @ -3040,7 +3041,7 @@ void fpa2bv_converter::mk_to_fp_unsigned(func_decl * f, unsigned num, expr * con | |||
|         mk_max_exp(exp_sz, max_exp); | ||||
|         max_exp_bvsz = m_bv_util.mk_zero_extend(bv_sz - exp_sz, max_exp); | ||||
| 
 | ||||
|         exp_too_large = m_bv_util.mk_ule(m_bv_util.mk_bv_add( | ||||
|         exp_too_large = m_bv_util.mk_sle(m_bv_util.mk_bv_add( | ||||
|             max_exp_bvsz, | ||||
|             m_bv_util.mk_numeral(1, bv_sz)), | ||||
|             s_exp); | ||||
|  | @ -3106,7 +3107,7 @@ void fpa2bv_converter::mk_to_ieee_bv_unspecified(func_decl * f, unsigned num, ex | |||
| 
 | ||||
|         expr_ref exp_bv(m), exp_all_ones(m); | ||||
|         exp_bv = m_bv_util.mk_extract(ebits+sbits-2, sbits-1, result); | ||||
|         exp_all_ones = m.mk_eq(exp_bv, m_bv_util.mk_numeral(-1, ebits)); | ||||
|         exp_all_ones = m.mk_eq(exp_bv, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, ebits))); | ||||
|         m_extra_assertions.push_back(exp_all_ones); | ||||
| 
 | ||||
|         expr_ref sig_bv(m), sig_is_non_zero(m); | ||||
|  | @ -3241,18 +3242,32 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args | |||
|     dbg_decouple("fpa2bv_to_bv_inc", inc); | ||||
|     dbg_decouple("fpa2bv_to_bv_pre_rounded", pre_rounded); | ||||
| 
 | ||||
|     pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded); | ||||
|     expr_ref incd(m), pr_is_zero(m), ovfl(m); | ||||
|     incd = m.mk_eq(rounding_decision, bv1); | ||||
|     pr_is_zero = m.mk_eq(pre_rounded, m_bv_util.mk_numeral(0, bv_sz + 3)); | ||||
|     ovfl = m.mk_and(incd, pr_is_zero); | ||||
|     dbg_decouple("fpa2bv_to_bv_incd", incd); | ||||
|     dbg_decouple("fpa2bv_to_bv_ovfl", ovfl); | ||||
| 
 | ||||
|     expr_ref ll(m), ul(m), in_range(m); | ||||
|     expr_ref ul(m), in_range(m); | ||||
|     if (!is_signed) { | ||||
|         ll = m_bv_util.mk_numeral(0, bv_sz+3); | ||||
|         ul = m_bv_util.mk_zero_extend(3, m_bv_util.mk_numeral(-1, bv_sz)); | ||||
|         ul = m_bv_util.mk_zero_extend(3, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, bv_sz))); | ||||
|         in_range = m.mk_and(m.mk_not(x_is_neg), m.mk_not(ovfl), | ||||
|                             m_bv_util.mk_ule(pre_rounded, ul)); | ||||
|     } | ||||
|     else { | ||||
|         expr_ref ll(m); | ||||
|         ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1))); | ||||
|         ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_numeral(-1, bv_sz-1)); | ||||
|         ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, bv_sz-1))); | ||||
|         ovfl = m.mk_or(ovfl, m_bv_util.mk_sle(pre_rounded, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, bv_sz + 3)))); | ||||
|         in_range = m.mk_and(m.mk_not(ovfl), | ||||
|                             m_bv_util.mk_sle(ll, pre_rounded), | ||||
|                             m_bv_util.mk_sle(pre_rounded, ul)); | ||||
|         dbg_decouple("fpa2bv_to_bv_in_range_ll", ll); | ||||
|         pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded); | ||||
|     } | ||||
|     in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul)); | ||||
|     dbg_decouple("fpa2bv_to_bv_in_range_ovfl", ovfl); | ||||
|     dbg_decouple("fpa2bv_to_bv_in_range_ul", ul); | ||||
|     dbg_decouple("fpa2bv_to_bv_in_range", in_range); | ||||
| 
 | ||||
|     expr_ref rounded(m); | ||||
|  |  | |||
|  | @ -680,8 +680,8 @@ br_status bv_rewriter::mk_extract(unsigned high, unsigned low, expr * arg, expr_ | |||
|         if (v.is_neg()) | ||||
|             mod(v, rational::power_of_two(sz), v); | ||||
|         if (v.is_uint64()) { | ||||
|             uint64 u  = v.get_uint64(); | ||||
|             uint64 e  = shift_right(u, low) & (shift_left(1ull, sz) - 1ull); | ||||
|             uint64_t u  = v.get_uint64(); | ||||
|             uint64_t e  = shift_right(u, low) & (shift_left(1ull, sz) - 1ull); | ||||
|             result    = mk_numeral(numeral(e, numeral::ui64()), sz); | ||||
|             return BR_DONE; | ||||
|         } | ||||
|  | @ -811,7 +811,7 @@ br_status bv_rewriter::mk_bv_shl(expr * arg1, expr * arg2, expr_ref & result) { | |||
|                 SASSERT(r1.is_uint64() && r2.is_uint64()); | ||||
|                 SASSERT(r2.get_uint64() < bv_size); | ||||
| 
 | ||||
|                 uint64 r = shift_left(r1.get_uint64(), r2.get_uint64()); | ||||
|                 uint64_t r = shift_left(r1.get_uint64(), r2.get_uint64()); | ||||
|                 numeral rn(r, numeral::ui64()); | ||||
|                 rn = m_util.norm(rn, bv_size); | ||||
|                 result   = mk_numeral(rn, bv_size); | ||||
|  | @ -860,7 +860,7 @@ br_status bv_rewriter::mk_bv_lshr(expr * arg1, expr * arg2, expr_ref & result) { | |||
|             if (bv_size <= 64) { | ||||
|                 SASSERT(r1.is_uint64()); | ||||
|                 SASSERT(r2.is_uint64()); | ||||
|                 uint64 r = shift_right(r1.get_uint64(), r2.get_uint64()); | ||||
|                 uint64_t r = shift_right(r1.get_uint64(), r2.get_uint64()); | ||||
|                 numeral rn(r, numeral::ui64()); | ||||
|                 rn = m_util.norm(rn, bv_size); | ||||
|                 result = mk_numeral(rn, bv_size); | ||||
|  | @ -902,11 +902,11 @@ br_status bv_rewriter::mk_bv_ashr(expr * arg1, expr * arg2, expr_ref & result) { | |||
|     bool is_num1 = is_numeral(arg1, r1, bv_size); | ||||
| 
 | ||||
|     if (bv_size <= 64 && is_num1 && is_num2) { | ||||
|         uint64 n1      = r1.get_uint64(); | ||||
|         uint64 n2_orig = r2.get_uint64(); | ||||
|         uint64 n2      = n2_orig % bv_size; | ||||
|         uint64_t n1      = r1.get_uint64(); | ||||
|         uint64_t n2_orig = r2.get_uint64(); | ||||
|         uint64_t n2      = n2_orig % bv_size; | ||||
|         SASSERT(n2 < bv_size); | ||||
|         uint64 r       = shift_right(n1, n2); | ||||
|         uint64_t r       = shift_right(n1, n2); | ||||
|         bool   sign    = (n1 & shift_left(1ull, bv_size - 1ull)) != 0; | ||||
|         if (n2_orig > n2) { | ||||
|             if (sign) { | ||||
|  | @ -917,9 +917,9 @@ br_status bv_rewriter::mk_bv_ashr(expr * arg1, expr * arg2, expr_ref & result) { | |||
|             } | ||||
|         } | ||||
|         else if (sign) { | ||||
|             uint64 allone  = shift_left(1ull, bv_size) - 1ull; | ||||
|             uint64 mask    = ~(shift_left(1ull, bv_size - n2) - 1ull); | ||||
|             mask          &= allone; | ||||
|             uint64_t allone = shift_left(1ull, bv_size) - 1ull; | ||||
|             uint64_t mask   = ~(shift_left(1ull, bv_size - n2) - 1ull); | ||||
|             mask &= allone; | ||||
|             r |= mask; | ||||
|         } | ||||
|         result = mk_numeral(numeral(r, numeral::ui64()), bv_size); | ||||
|  | @ -2021,7 +2021,7 @@ br_status bv_rewriter::mk_bv_ext_rotate_left(expr * arg1, expr * arg2, expr_ref | |||
|     numeral r2; | ||||
|     unsigned bv_size; | ||||
|     if (is_numeral(arg2, r2, bv_size)) { | ||||
|         unsigned shift = static_cast<unsigned>((r2 % numeral(bv_size)).get_uint64() % static_cast<uint64>(bv_size)); | ||||
|         unsigned shift = static_cast<unsigned>((r2 % numeral(bv_size)).get_uint64() % static_cast<uint64_t>(bv_size)); | ||||
|         return mk_bv_rotate_left(shift, arg1, result); | ||||
|     } | ||||
|     return BR_FAILED; | ||||
|  | @ -2031,7 +2031,7 @@ br_status bv_rewriter::mk_bv_ext_rotate_right(expr * arg1, expr * arg2, expr_ref | |||
|     numeral r2; | ||||
|     unsigned bv_size; | ||||
|     if (is_numeral(arg2, r2, bv_size)) { | ||||
|         unsigned shift = static_cast<unsigned>((r2 % numeral(bv_size)).get_uint64() % static_cast<uint64>(bv_size)); | ||||
|         unsigned shift = static_cast<unsigned>((r2 % numeral(bv_size)).get_uint64() % static_cast<uint64_t>(bv_size)); | ||||
|         return mk_bv_rotate_right(shift, arg1, result); | ||||
|     } | ||||
|     return BR_FAILED; | ||||
|  |  | |||
|  | @ -22,7 +22,7 @@ Revision History: | |||
|     br_status dl_rewriter::mk_app_core( | ||||
|         func_decl * f, unsigned num_args, expr* const* args, expr_ref& result) { | ||||
|         ast_manager& m = result.get_manager(); | ||||
|         uint64 v1, v2; | ||||
|         uint64_t v1, v2; | ||||
|         switch(f->get_decl_kind()) { | ||||
|             case datalog::OP_DL_LT: | ||||
|                 if (m_util.is_numeral_ext(args[0], v1) && | ||||
|  |  | |||
|  | @ -773,7 +773,7 @@ br_status fpa_rewriter::mk_to_ieee_bv(func_decl * f, expr * arg, expr_ref & resu | |||
|         if (m_fm.is_nan(v)) { | ||||
|             if (m_hi_fp_unspecified) { | ||||
|                 expr * args[4] = { bu.mk_numeral(0, 1), | ||||
|                                    bu.mk_numeral(-1, x.get_ebits()), | ||||
|                                    bu.mk_bv_neg(bu.mk_numeral(1, x.get_ebits())), | ||||
|                                    bu.mk_numeral(0, x.get_sbits() - 2), | ||||
|                                    bu.mk_numeral(1, 1) }; | ||||
|                 result = bu.mk_concat(4, args); | ||||
|  |  | |||
|  | @ -213,6 +213,9 @@ std::string zstring::encode() const { | |||
|         else if (ch == '\\') { | ||||
|             strm << "\\\\"; | ||||
|         } | ||||
|         else if (ch >= 128) { | ||||
|             strm << "\\x" << std::hex << (unsigned)ch << std::dec;  | ||||
|         } | ||||
|         else { | ||||
|             strm << (char)(ch); | ||||
|         } | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ Revision History: | |||
| 
 | ||||
|     Hilbert basis can be templatized  | ||||
|     based on traits that define numeral: | ||||
|     as rational, mpz, checked_int64  | ||||
|     as rational, mpz, checked_int64 | ||||
|     (checked or unchecked). | ||||
| 
 | ||||
| --*/ | ||||
|  |  | |||
|  | @ -5479,7 +5479,7 @@ namespace polynomial { | |||
|             } | ||||
|             p_prime = derivative(p, x); | ||||
|             resultant(p, p_prime, x, r); | ||||
|             bool sign = (static_cast<uint64>(m) * static_cast<uint64>(m-1))%4 != 0; | ||||
|             bool sign = (static_cast<uint64_t>(m) * static_cast<uint64_t>(m-1))%4 != 0; | ||||
|             TRACE("resultant", tout << "discriminant sign: " << sign << "\n";); | ||||
|             scoped_numeral lc(m_manager); | ||||
|             if (const_coeff(p, x, m, lc)) { | ||||
|  | @ -6963,7 +6963,7 @@ namespace polynomial { | |||
|         return m_imp->m().set_zp(p); | ||||
|     } | ||||
| 
 | ||||
|     void manager::set_zp(uint64 p) { | ||||
|     void manager::set_zp(uint64_t p) { | ||||
|         return m_imp->m().set_zp(p); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -218,7 +218,7 @@ namespace polynomial { | |||
|            \brief Set manager as Z_p[X1, ..., Xn] | ||||
|         */ | ||||
|         void set_zp(numeral const & p); | ||||
|         void set_zp(uint64 p); | ||||
|         void set_zp(uint64_t p); | ||||
| 
 | ||||
|         /**
 | ||||
|            \brief Abstract event handler. | ||||
|  | @ -1043,7 +1043,7 @@ namespace polynomial { | |||
|         scoped_numeral m_p; | ||||
|     public: | ||||
|         scoped_set_zp(manager & _m, numeral const & p):m(_m), m_modular(m.modular()), m_p(m.m()) {  m_p = m.p(); m.set_zp(p); } | ||||
|         scoped_set_zp(manager & _m, uint64 p):m(_m), m_modular(m.modular()), m_p(m.m()) {  m_p = m.p(); m.set_zp(p); } | ||||
|         scoped_set_zp(manager & _m, uint64_t p):m(_m), m_modular(m.modular()), m_p(m.m()) {  m_p = m.p(); m.set_zp(p); } | ||||
|         ~scoped_set_zp() {  if (m_modular) m.set_zp(m_p); else m.set_z(); } | ||||
|     }; | ||||
| }; | ||||
|  |  | |||
|  | @ -153,7 +153,7 @@ namespace upolynomial { | |||
|            \brief Set manager as Z_p[X] | ||||
|         */ | ||||
|         void set_zp(numeral const & p) { m().set_zp(p); } | ||||
|         void set_zp(uint64 p) { m().set_zp(p); } | ||||
|         void set_zp(uint64_t p) { m().set_zp(p); } | ||||
| 
 | ||||
|         void checkpoint(); | ||||
| 
 | ||||
|  | @ -486,7 +486,7 @@ namespace upolynomial { | |||
|         core_manager::scoped_numeral m_p; | ||||
|     public: | ||||
|         scoped_set_zp(core_manager & _m, numeral const & p):m(_m), m_modular(m.modular()), m_p(m.m()) {  m_p = m.p(); m.set_zp(p); } | ||||
|         scoped_set_zp(core_manager & _m, uint64 p):m(_m), m_modular(m.modular()), m_p(m.m()) {  m_p = m.p(); m.set_zp(p); } | ||||
|         scoped_set_zp(core_manager & _m, uint64_t p):m(_m), m_modular(m.modular()), m_p(m.m()) {  m_p = m.p(); m.set_zp(p); } | ||||
|         ~scoped_set_zp() {  if (m_modular) m.set_zp(m_p); else m.set_z(); } | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -38,9 +38,9 @@ unsigned get_p_from_manager(zp_numeral_manager const & zp_nm) { | |||
|     if (!nm.is_uint64(p)) { | ||||
|         throw upolynomial_exception("The prime number attempted in factorization is too big!"); | ||||
|     } | ||||
|     uint64 p_uint64 = nm.get_uint64(p); | ||||
|     uint64_t p_uint64 = nm.get_uint64(p); | ||||
|     unsigned p_uint = static_cast<unsigned>(p_uint64); | ||||
|     if (((uint64)p_uint) != p_uint64) { | ||||
|     if (((uint64_t)p_uint) != p_uint64) { | ||||
|         throw upolynomial_exception("The prime number attempted in factorization is too big!"); | ||||
|     } | ||||
|     return p_uint; | ||||
|  | @ -1075,7 +1075,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, | |||
|     while (trials < params.m_p_trials) { | ||||
|         upm.checkpoint(); | ||||
|         // construct prime to check 
 | ||||
|         uint64 next_prime = prime_it.next(); | ||||
|         uint64_t next_prime = prime_it.next(); | ||||
|         if (next_prime > params.m_max_p) { | ||||
|             fs.push_back(f_pp, k); | ||||
|             return false; | ||||
|  |  | |||
|  | @ -150,12 +150,12 @@ namespace subpaving { | |||
|         void int2hwf(mpz const & a, hwf & o) { | ||||
|             if (!m_qm.is_int64(a)) | ||||
|                 throw subpaving::exception(); | ||||
|             int64 val   = m_qm.get_int64(a); | ||||
|             int64_t val   = m_qm.get_int64(a); | ||||
|             double dval = static_cast<double>(val); | ||||
|             m_ctx.nm().set(o, dval); | ||||
|             double _dval = m_ctx.nm().m().to_double(o); | ||||
|             // TODO check the following test
 | ||||
|             if (static_cast<int64>(_dval) != val) | ||||
|             if (static_cast<int64_t>(_dval) != val) | ||||
|                 throw subpaving::exception(); | ||||
|         } | ||||
|          | ||||
|  |  | |||
|  | @ -73,17 +73,17 @@ public: | |||
|             // TODO: add SIN, COS, TAN, ...
 | ||||
|         }; | ||||
|     protected: | ||||
|         kind   m_kind; | ||||
|         uint64 m_timestamp; | ||||
|         kind     m_kind; | ||||
|         uint64_t m_timestamp; | ||||
|     public: | ||||
|         constraint(kind k):m_kind(k), m_timestamp(0) {} | ||||
|          | ||||
|         kind get_kind() const { return m_kind; } | ||||
|          | ||||
|         // Return the timestamp of the last propagation visit
 | ||||
|         uint64 timestamp() const { return m_timestamp; } | ||||
|         uint64_t timestamp() const { return m_timestamp; } | ||||
|         // Reset propagation visit time
 | ||||
|         void set_visited(uint64 ts) { m_timestamp = ts; } | ||||
|         void set_visited(uint64_t ts) { m_timestamp = ts; } | ||||
|     }; | ||||
| 
 | ||||
|     /**
 | ||||
|  | @ -149,17 +149,17 @@ public: | |||
|         unsigned      m_lower:1; | ||||
|         unsigned      m_open:1; | ||||
|         unsigned      m_mark:1; | ||||
|         uint64        m_timestamp; | ||||
|         uint64_t      m_timestamp; | ||||
|         bound *       m_prev; | ||||
|         justification m_jst; | ||||
|         void set_timestamp(uint64 ts) { m_timestamp = ts; } | ||||
|         void set_timestamp(uint64_t ts) { m_timestamp = ts; } | ||||
|     public: | ||||
|         var x() const { return static_cast<var>(m_x); } | ||||
|         numeral const & value() const { return m_val; } | ||||
|         numeral & value() { return m_val; } | ||||
|         bool is_lower() const { return m_lower; } | ||||
|         bool is_open() const { return m_open; } | ||||
|         uint64 timestamp() const { return m_timestamp; } | ||||
|         uint64_t timestamp() const { return m_timestamp; } | ||||
|         bound * prev() const { return m_prev; } | ||||
|         justification jst() const { return m_jst; } | ||||
|         void display(std::ostream & out, numeral_manager & nm, display_var_proc const & proc = display_var_proc()); | ||||
|  | @ -486,7 +486,7 @@ private: | |||
|      | ||||
|     id_gen                    m_node_id_gen; | ||||
| 
 | ||||
|     uint64                    m_timestamp; | ||||
|     uint64_t                  m_timestamp; | ||||
|     node *                    m_root; | ||||
|     // m_leaf_head is the head of a doubly linked list of leaf nodes to be processed.
 | ||||
|     node *                    m_leaf_head;  | ||||
|  |  | |||
|  | @ -454,6 +454,7 @@ struct evaluator_cfg : public default_rewriter_cfg { | |||
| 
 | ||||
|         func_decl* f = m_ar.get_as_array_func_decl(to_app(a)); | ||||
|         func_interp* g = m_model.get_func_interp(f); | ||||
| 		if (!g) return false; | ||||
|         unsigned sz = g->num_entries(); | ||||
|         unsigned arity = f->get_arity(); | ||||
|         unsigned base_sz = stores.size(); | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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. | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -165,7 +165,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);             | ||||
|  | @ -621,7 +621,7 @@ 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); | ||||
| #else | ||||
|  | @ -634,9 +634,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; | ||||
|  | @ -664,7 +664,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(); | ||||
|  |  | |||
|  | @ -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_ */ | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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)) { | ||||
|  |  | |||
|  | @ -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)) { | ||||
|  |  | |||
|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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; | ||||
|             } | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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; | ||||
|             } | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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; | ||||
|             } | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -949,8 +949,9 @@ namespace smt2 { | |||
|             check_duplicate(d, line, pos); | ||||
| 
 | ||||
|             d->commit(pm()); | ||||
|             check_rparen_next("invalid end of datatype declaration, ')' expected"); | ||||
|             check_rparen("invalid end of datatype declaration, ')' expected"); | ||||
|             m_ctx.print_success(); | ||||
|             next(); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -70,7 +70,7 @@ namespace qe { | |||
|                 return false; | ||||
|             } | ||||
|             eq_atoms& eqs = get_eqs(x.x(), fml); | ||||
|             uint64 domain_size; | ||||
|             uint64_t domain_size; | ||||
|             if (is_small_domain(x, eqs, domain_size)) { | ||||
|                 num_branches = rational(domain_size, rational::ui64()); | ||||
|             } | ||||
|  | @ -84,7 +84,7 @@ namespace qe { | |||
|             SASSERT(v.is_unsigned()); | ||||
|             eq_atoms& eqs = get_eqs(x.x(), fml);             | ||||
|             unsigned uv = v.get_unsigned(); | ||||
|             uint64 domain_size; | ||||
|             uint64_t domain_size; | ||||
|             if (is_small_domain(x, eqs, domain_size)) { | ||||
|                 SASSERT(v < rational(domain_size, rational::ui64())); | ||||
|                 assign_small_domain(x, eqs, uv); | ||||
|  | @ -98,7 +98,7 @@ namespace qe { | |||
|             SASSERT(v.is_unsigned()); | ||||
|             eq_atoms& eqs = get_eqs(x.x(), fml);            | ||||
|             unsigned uv = v.get_unsigned(); | ||||
|             uint64 domain_size; | ||||
|             uint64_t domain_size; | ||||
|             if (is_small_domain(x, eqs, domain_size)) { | ||||
|                 SASSERT(uv < domain_size); | ||||
|                 subst_small_domain(x, eqs, uv, fml); | ||||
|  | @ -115,7 +115,7 @@ namespace qe { | |||
| 
 | ||||
|     private: | ||||
| 
 | ||||
|         bool is_small_domain(contains_app& x, eq_atoms& eqs, uint64& domain_size) { | ||||
|         bool is_small_domain(contains_app& x, eq_atoms& eqs, uint64_t& domain_size) { | ||||
|             VERIFY(m_util.try_get_size(m.get_sort(x.x()), domain_size)); | ||||
|             return domain_size < eqs.num_eqs() + eqs.num_neqs(); | ||||
|         } | ||||
|  |  | |||
|  | @ -212,7 +212,7 @@ unsigned read_datalog(char const * file) { | |||
|             if (early_termination) { | ||||
|                 IF_VERBOSE(1, verbose_stream() << "restarting saturation\n";); | ||||
|                  | ||||
|                 uint64 new_timeout = static_cast<uint64>(timeout)*ctx.initial_restart_timeout();  | ||||
|                 uint64_t new_timeout = static_cast<uint64_t>(timeout)*ctx.initial_restart_timeout(); | ||||
|                 if(new_timeout>UINT_MAX) { | ||||
|                     timeout=UINT_MAX; | ||||
|                 } | ||||
|  |  | |||
|  | @ -3951,7 +3951,7 @@ namespace smt { | |||
| #if 0 | ||||
|             { | ||||
|                 static unsigned counter = 0; | ||||
|                 static uint64 total = 0; | ||||
|                 static uint64_t total = 0; | ||||
|                 static unsigned max = 0; | ||||
|                 counter++; | ||||
|                 total += num_lits; | ||||
|  |  | |||
|  | @ -216,6 +216,15 @@ namespace smt { | |||
|             return m_args; | ||||
|         } | ||||
| 
 | ||||
|         class args { | ||||
|             enode const& n; | ||||
|         public: | ||||
|             args(enode const& n):n(n) {} | ||||
|             args(enode const* n):n(*n) {} | ||||
|             enode_vector::const_iterator begin() const { return n.get_args(); } | ||||
|             enode_vector::const_iterator end() const { return n.get_args() + n.get_num_args(); } | ||||
|         }; | ||||
| 
 | ||||
|         // unsigned get_id() const { 
 | ||||
|         //    return m_id; 
 | ||||
|         // }
 | ||||
|  | @ -285,6 +294,16 @@ namespace smt { | |||
|             return m_commutative; | ||||
|         } | ||||
| 
 | ||||
|         class parents { | ||||
|             enode const& n; | ||||
|         public: | ||||
|             parents(enode const& _n):n(_n) {} | ||||
|             parents(enode const* _n):n(*_n) {} | ||||
|             enode_vector::const_iterator begin() const { return n.begin_parents(); } | ||||
|             enode_vector::const_iterator end() const { return n.end_parents(); } | ||||
|         }; | ||||
| 
 | ||||
| 
 | ||||
|         unsigned get_num_parents() const { | ||||
|             return m_parents.size(); | ||||
|         } | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ Revision History: | |||
| 
 | ||||
| #include "util/list.h" | ||||
| #include "util/vector.h" | ||||
| #include "util/hashtable.h" | ||||
| #include "util/lbool.h" | ||||
| 
 | ||||
| class model; | ||||
|  |  | |||
|  | @ -36,6 +36,41 @@ namespace smt { | |||
|         theory_id get_from_theory() const override { return null_theory_id; } | ||||
|     }; | ||||
| 
 | ||||
|     theory_datatype::final_check_st::final_check_st(theory_datatype * th) : th(th) { | ||||
|         SASSERT(th->m_to_unmark.empty()); | ||||
|         SASSERT(th->m_to_unmark2.empty()); | ||||
|         th->m_used_eqs.reset(); | ||||
|         th->m_stack.reset(); | ||||
|         th->m_parent.reset(); | ||||
|     } | ||||
| 
 | ||||
|     theory_datatype::final_check_st::~final_check_st() { | ||||
|         unmark_enodes(th->m_to_unmark.size(), th->m_to_unmark.c_ptr()); | ||||
|         unmark_enodes2(th->m_to_unmark2.size(), th->m_to_unmark2.c_ptr()); | ||||
|         th->m_to_unmark.reset(); | ||||
|         th->m_to_unmark2.reset(); | ||||
|         th->m_used_eqs.reset(); | ||||
|         th->m_stack.reset(); | ||||
|         th->m_parent.reset(); | ||||
|     }    | ||||
|      | ||||
|     void theory_datatype::oc_mark_on_stack(enode * n) { | ||||
|         n = n->get_root(); | ||||
|         n->set_mark(); | ||||
|         m_to_unmark.push_back(n);  | ||||
|     } | ||||
| 
 | ||||
|     void theory_datatype::oc_mark_cycle_free(enode * n) { | ||||
|         n = n->get_root(); | ||||
|         n->set_mark2(); | ||||
|         m_to_unmark2.push_back(n);  | ||||
|     } | ||||
| 
 | ||||
|     void theory_datatype::oc_push_stack(enode * n) { | ||||
|         m_stack.push_back(std::make_pair(EXIT, n)); | ||||
|         m_stack.push_back(std::make_pair(ENTER, n)); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     theory* theory_datatype::mk_fresh(context* new_ctx) {  | ||||
|         return alloc(theory_datatype, new_ctx->get_manager(), m_params);  | ||||
|  | @ -389,10 +424,11 @@ namespace smt { | |||
|     final_check_status theory_datatype::final_check_eh() { | ||||
|         int num_vars = get_num_vars(); | ||||
|         final_check_status r = FC_DONE; | ||||
|         final_check_st _guard(this); // RAII for managing state
 | ||||
|         for (int v = 0; v < num_vars; v++) { | ||||
|             if (v == static_cast<int>(m_find.find(v))) { | ||||
|                 enode * node = get_enode(v); | ||||
|                 if (occurs_check(node)) { | ||||
|                 if (!oc_cycle_free(node) && occurs_check(node)) { | ||||
|                     // conflict was detected... 
 | ||||
|                     // return...
 | ||||
|                     return FC_CONTINUE; | ||||
|  | @ -410,6 +446,73 @@ namespace smt { | |||
|         return r; | ||||
|     } | ||||
| 
 | ||||
|     // Assuming `app` is equal to a constructor term, return the constructor enode
 | ||||
|     inline enode * theory_datatype::oc_get_cstor(enode * app) { | ||||
|         theory_var v = app->get_root()->get_th_var(get_id()); | ||||
|         SASSERT(v != null_theory_var); | ||||
|         v = m_find.find(v); | ||||
|         var_data * d = m_var_data[v]; | ||||
|         SASSERT(d->m_constructor); | ||||
|         return d->m_constructor; | ||||
|     } | ||||
| 
 | ||||
|     // explain the cycle root -> ... -> app -> root
 | ||||
|     void theory_datatype::occurs_check_explain(enode * app, enode * root) { | ||||
|         TRACE("datatype", tout << "occurs_check_explain " << mk_bounded_pp(app->get_owner(), get_manager()) << " <-> " << mk_bounded_pp(root->get_owner(), get_manager()) << "\n";); | ||||
|         enode* app_parent = nullptr; | ||||
| 
 | ||||
|         // first: explain that root=v, given that app=cstor(…,v,…)
 | ||||
|         for (enode * arg : enode::args(oc_get_cstor(app))) { | ||||
|             // found an argument which is equal to root
 | ||||
|             if (arg->get_root() == root->get_root()) { | ||||
|                 if (arg != root) | ||||
|                     m_used_eqs.push_back(enode_pair(arg, root)); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // now explain app=cstor(..,v,..) where v=root, and recurse with parent of app
 | ||||
|         while (app->get_root() != root->get_root()) { | ||||
|             enode * app_cstor = oc_get_cstor(app); | ||||
|             if (app != app_cstor) | ||||
|                 m_used_eqs.push_back(enode_pair(app, app_cstor)); | ||||
|             app_parent = m_parent[app->get_root()]; | ||||
|             app = app_parent; | ||||
|         } | ||||
|          | ||||
|         SASSERT(app->get_root() == root->get_root()); | ||||
|         if (app != root) | ||||
|             m_used_eqs.push_back(enode_pair(app, root)); | ||||
|     } | ||||
| 
 | ||||
|     // start exploring subgraph below `app`
 | ||||
|     bool theory_datatype::occurs_check_enter(enode * app) { | ||||
|         oc_mark_on_stack(app); | ||||
|         theory_var v = app->get_root()->get_th_var(get_id()); | ||||
|         if (v != null_theory_var) { | ||||
|             v = m_find.find(v); | ||||
|             var_data * d = m_var_data[v]; | ||||
|             if (d->m_constructor) { | ||||
|                 for (enode * arg : enode::args(d->m_constructor)) { | ||||
|                     if (oc_cycle_free(arg)) { | ||||
|                         continue; | ||||
|                     } | ||||
|                     if (oc_on_stack(arg)) { | ||||
|                         // arg was explored before app, and is still on the stack: cycle
 | ||||
|                         occurs_check_explain(app, arg); | ||||
|                         return true; | ||||
|                     } | ||||
|                     // explore `arg` (with parent `app`)
 | ||||
|                     if (m_util.is_datatype(get_manager().get_sort(arg->get_owner()))) { | ||||
|                         m_parent.insert(arg->get_root(), app); | ||||
|                         oc_push_stack(arg); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Check if n can be reached starting from n and following equalities and constructors. | ||||
|        For example, occur_check(a1) returns true in the following set of equalities: | ||||
|  | @ -418,17 +521,39 @@ namespace smt { | |||
|        a3 = cons(v3, a1) | ||||
|     */ | ||||
|     bool theory_datatype::occurs_check(enode * n) { | ||||
|         TRACE("datatype", tout << "occurs check: #" << n->get_owner_id() << "\n";); | ||||
|         m_to_unmark.reset(); | ||||
|         m_used_eqs.reset(); | ||||
|         m_main   = n; | ||||
|         bool res = occurs_check_core(m_main); | ||||
|         unmark_enodes(m_to_unmark.size(), m_to_unmark.c_ptr()); | ||||
|         TRACE("datatype", tout << "occurs check: #" << n->get_owner_id() << " " << mk_bounded_pp(n->get_owner(), get_manager()) << "\n";); | ||||
|         m_stats.m_occurs_check++; | ||||
| 
 | ||||
|         bool res = false; | ||||
|         oc_push_stack(n); | ||||
| 
 | ||||
|         // DFS traversal from `n`. Look at top element and explore it.
 | ||||
|         while (!res && !m_stack.empty()) { | ||||
|             stack_op op = m_stack.back().first; | ||||
|             enode * app = m_stack.back().second; | ||||
|             m_stack.pop_back(); | ||||
| 
 | ||||
|             if (oc_cycle_free(app)) continue; | ||||
| 
 | ||||
|             TRACE("datatype", tout << "occurs check loop: #" << app->get_owner_id() << " " << mk_bounded_pp(app->get_owner(), get_manager()) << (op==ENTER?" enter":" exit")<< "\n";); | ||||
| 
 | ||||
|             switch (op) { | ||||
|             case ENTER: | ||||
|               res = occurs_check_enter(app); | ||||
|               break; | ||||
| 
 | ||||
|             case EXIT: | ||||
|               oc_mark_cycle_free(app); | ||||
|               break; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (res) { | ||||
|             // m_used_eqs should contain conflict
 | ||||
|             context & ctx = get_context(); | ||||
|             region & r    = ctx.get_region(); | ||||
|             ctx.set_conflict(ctx.mk_justification(ext_theory_conflict_justification(get_id(), r, 0, nullptr, m_used_eqs.size(), m_used_eqs.c_ptr()))); | ||||
|             TRACE("occurs_check", | ||||
|             TRACE("datatype", | ||||
|                   tout << "occurs_check: true\n"; | ||||
|                   for (enode_pair const& p : m_used_eqs) { | ||||
|                       tout << "eq: #" << p.first->get_owner_id() << " #" << p.second->get_owner_id() << "\n"; | ||||
|  | @ -437,48 +562,6 @@ namespace smt { | |||
|         } | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Auxiliary method for occurs_check. | ||||
|        TODO: improve performance. | ||||
|     */ | ||||
|     bool theory_datatype::occurs_check_core(enode * app) { | ||||
|         if (app->is_marked()) | ||||
|             return false; | ||||
|          | ||||
|         m_stats.m_occurs_check++; | ||||
|         app->set_mark(); | ||||
|         m_to_unmark.push_back(app); | ||||
|          | ||||
|         TRACE("datatype", tout << "occurs check_core: #" << app->get_owner_id() << " #" << m_main->get_owner_id() << "\n";); | ||||
| 
 | ||||
|         theory_var v = app->get_root()->get_th_var(get_id()); | ||||
|         if (v != null_theory_var) { | ||||
|             v = m_find.find(v); | ||||
|             var_data * d = m_var_data[v]; | ||||
|             if (d->m_constructor) { | ||||
|                 if (app != d->m_constructor) | ||||
|                     m_used_eqs.push_back(enode_pair(app, d->m_constructor)); | ||||
|                 unsigned num_args = d->m_constructor->get_num_args(); | ||||
|                 for (unsigned i = 0; i < num_args; i++) { | ||||
|                     enode * arg = d->m_constructor->get_arg(i); | ||||
|                     if (arg->get_root() == m_main->get_root()) { | ||||
|                         if (arg != m_main) | ||||
|                             m_used_eqs.push_back(enode_pair(arg, m_main)); | ||||
|                         return true; | ||||
|                     } | ||||
|                     if (m_util.is_datatype(get_manager().get_sort(arg->get_owner())) && occurs_check_core(arg)) | ||||
|                         return true; | ||||
|                 } | ||||
|                 if (app != d->m_constructor) { | ||||
|                     SASSERT(m_used_eqs.back().first  == app); | ||||
|                     SASSERT(m_used_eqs.back().second == d->m_constructor); | ||||
|                     m_used_eqs.pop_back(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|          | ||||
|     void theory_datatype::reset_eh() { | ||||
|         m_trail_stack.reset(); | ||||
|  |  | |||
|  | @ -26,7 +26,6 @@ Revision History: | |||
| #include "smt/proto_model/datatype_factory.h" | ||||
| 
 | ||||
| namespace smt { | ||||
|      | ||||
|     class theory_datatype : public theory { | ||||
|         typedef trail_stack<theory_datatype> th_trail_stack; | ||||
|         typedef union_find<theory_datatype>  th_union_find; | ||||
|  | @ -73,11 +72,36 @@ namespace smt { | |||
|         void propagate_recognizer(theory_var v, enode * r); | ||||
|         void sign_recognizer_conflict(enode * c, enode * r); | ||||
| 
 | ||||
|         ptr_vector<enode>    m_to_unmark; | ||||
|         enode_pair_vector    m_used_eqs; | ||||
|         enode *              m_main; | ||||
|         typedef enum { ENTER, EXIT } stack_op; | ||||
|         typedef map<enode*, enode*, obj_ptr_hash<enode>, ptr_eq<enode> > parent_tbl; | ||||
|         typedef std::pair<stack_op, enode*> stack_entry; | ||||
| 
 | ||||
|         ptr_vector<enode>     m_to_unmark; | ||||
|         ptr_vector<enode>     m_to_unmark2; | ||||
|         enode_pair_vector     m_used_eqs; // conflict, if any
 | ||||
|         parent_tbl            m_parent; // parent explanation for occurs_check
 | ||||
|         svector<stack_entry>  m_stack; // stack for DFS for occurs_check
 | ||||
| 
 | ||||
|         void oc_mark_on_stack(enode * n); | ||||
|         bool oc_on_stack(enode * n) const { return n->get_root()->is_marked(); } | ||||
| 
 | ||||
|         void oc_mark_cycle_free(enode * n); | ||||
|         bool oc_cycle_free(enode * n) const { return n->get_root()->is_marked2(); } | ||||
| 
 | ||||
|         void oc_push_stack(enode * n); | ||||
| 
 | ||||
|         // class for managing state of final_check
 | ||||
|         class final_check_st { | ||||
|             theory_datatype * th; | ||||
|         public: | ||||
|             final_check_st(theory_datatype * th); | ||||
|             ~final_check_st(); | ||||
|         }; | ||||
| 
 | ||||
|         enode * oc_get_cstor(enode * n); | ||||
|         bool occurs_check(enode * n); | ||||
|         bool occurs_check_core(enode * n); | ||||
|         bool occurs_check_enter(enode * n); | ||||
|         void occurs_check_explain(enode * top, enode * root); | ||||
| 
 | ||||
|         void mk_split(theory_var v); | ||||
| 
 | ||||
|  |  | |||
|  | @ -182,7 +182,7 @@ namespace smt { | |||
|                  | ||||
|                 if (n->get_decl() != v) { | ||||
|                     expr* rep = m().mk_app(r, n); | ||||
|                     uint64 vl; | ||||
|                     uint64_t vl; | ||||
|                     if (u().is_numeral_ext(n, vl)) { | ||||
|                         assert_cnstr(m().mk_eq(rep, mk_bv_constant(vl, s))); | ||||
|                     } | ||||
|  | @ -237,12 +237,12 @@ namespace smt { | |||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         app* mk_bv_constant(uint64 val, sort* s) { | ||||
|         app* mk_bv_constant(uint64_t val, sort* s) { | ||||
|             return b().mk_numeral(rational(val, rational::ui64()), 64); | ||||
|         } | ||||
| 
 | ||||
|         app* max_value(sort* s) { | ||||
|             uint64 sz; | ||||
|             uint64_t sz; | ||||
|             VERIFY(u().try_get_size(s, sz)); | ||||
|             SASSERT(sz > 0); | ||||
|             return mk_bv_constant(sz-1, s); | ||||
|  |  | |||
|  | @ -446,7 +446,16 @@ namespace smt { | |||
|             expr* arg = atom->get_arg(i); | ||||
|             literal l = compile_arg(arg); | ||||
|             numeral c = m_util.get_coeff(atom, i); | ||||
|             args.push_back(std::make_pair(l, c)); | ||||
|             switch (ctx.get_assignment(l)) { | ||||
|             case l_true:  | ||||
|                 k -= c; | ||||
|                 break; | ||||
|             case l_false: | ||||
|                 break; | ||||
|             default: | ||||
|                 args.push_back(std::make_pair(l, c)); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         if (m_util.is_at_most_k(atom) || m_util.is_le(atom)) { | ||||
|             // turn W <= k into -W >= -k
 | ||||
|  | @ -458,7 +467,7 @@ namespace smt { | |||
|         else { | ||||
|             SASSERT(m_util.is_at_least_k(atom) || m_util.is_ge(atom) || m_util.is_eq(atom)); | ||||
|         } | ||||
|         TRACE("pb", display(tout, *c););         | ||||
|         TRACE("pb", display(tout, *c, true););         | ||||
|         //app_ref fml1(m), fml2(m);
 | ||||
|         //fml1 = c->to_expr(ctx, m);
 | ||||
|         c->unique(); | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ Author: | |||
| #include "ast/ast_pp.h" | ||||
| #include <climits> | ||||
| 
 | ||||
| static uint64 uMaxInt(unsigned sz) { | ||||
| static uint64_t uMaxInt(unsigned sz) { | ||||
|     SASSERT(sz <= 64); | ||||
|     return ULLONG_MAX >> (64u - sz); | ||||
| } | ||||
|  | @ -35,12 +35,12 @@ namespace { | |||
|     struct interval { | ||||
|         // l < h: [l, h]
 | ||||
|         // l > h: [0, h] U [l, UMAX_INT]
 | ||||
|         uint64 l, h; | ||||
|         uint64_t l, h; | ||||
|         unsigned sz; | ||||
|         bool tight; | ||||
| 
 | ||||
|         interval() {} | ||||
|         interval(uint64 l, uint64 h, unsigned sz, bool tight = false) : l(l), h(h), sz(sz), tight(tight) { | ||||
|         interval(uint64_t l, uint64_t h, unsigned sz, bool tight = false) : l(l), h(h), sz(sz), tight(tight) { | ||||
|             // canonicalize full set
 | ||||
|             if (is_wrapped() && l == h + 1) { | ||||
|                 this->l = 0; | ||||
|  | @ -183,7 +183,7 @@ namespace { | |||
|         svector<expr_set*> m_expr_vars; | ||||
|         svector<expr_cnt*> m_bound_exprs; | ||||
| 
 | ||||
|         bool is_number(expr *e, uint64& n, unsigned& sz) const { | ||||
|         bool is_number(expr *e, uint64_t& n, unsigned& sz) const { | ||||
|             rational r; | ||||
|             if (m_bv.is_numeral(e, r, sz) && sz <= 64) { | ||||
|                 n = r.get_uint64(); | ||||
|  | @ -193,7 +193,7 @@ namespace { | |||
|         } | ||||
| 
 | ||||
|         bool is_bound(expr *e, expr*& v, interval& b) const { | ||||
|             uint64 n; | ||||
|             uint64_t n; | ||||
|             expr *lhs = nullptr, *rhs = nullptr; | ||||
|             unsigned sz; | ||||
| 
 | ||||
|  | @ -550,7 +550,7 @@ namespace { | |||
|         svector<expr_set*> m_expr_vars; | ||||
|         svector<expr_cnt*> m_bound_exprs; | ||||
| 
 | ||||
|         bool is_number(expr *e, uint64& n, unsigned& sz) const { | ||||
|         bool is_number(expr *e, uint64_t& n, unsigned& sz) const { | ||||
|             rational r; | ||||
|             if (m_bv.is_numeral(e, r, sz) && sz <= 64) { | ||||
|                 n = r.get_uint64(); | ||||
|  | @ -560,7 +560,7 @@ namespace { | |||
|         } | ||||
| 
 | ||||
|         bool is_bound(expr *e, expr*& v, interval& b) const { | ||||
|             uint64 n; | ||||
|             uint64_t n; | ||||
|             expr *lhs = nullptr, *rhs = nullptr; | ||||
|             unsigned sz = 0; | ||||
| 
 | ||||
|  |  | |||
|  | @ -93,7 +93,7 @@ class fpa2bv_tactic : public tactic { | |||
|                         expr * sgn, *sig, *exp; | ||||
|                         m_conv.split_fp(new_curr, sgn, exp, sig); | ||||
|                         result.back()->assert_expr(m.mk_eq(sgn, m_conv.bu().mk_numeral(0, 1))); | ||||
|                         result.back()->assert_expr(m.mk_eq(exp, m_conv.bu().mk_numeral(-1, m_conv.bu().get_bv_size(exp)))); | ||||
|                         result.back()->assert_expr(m.mk_eq(exp, m_conv.bu().mk_bv_neg(m_conv.bu().mk_numeral(1, m_conv.bu().get_bv_size(exp))))); | ||||
|                         result.back()->assert_expr(m.mk_eq(sig, m_conv.bu().mk_numeral(1, m_conv.bu().get_bv_size(sig)))); | ||||
|                     } | ||||
|                 } | ||||
|  |  | |||
|  | @ -35,25 +35,25 @@ class sine_tactic : public tactic { | |||
| 
 | ||||
| public: | ||||
| 
 | ||||
|     sine_tactic(ast_manager& m, params_ref const& p):  | ||||
|     sine_tactic(ast_manager& m, params_ref const& p): | ||||
|         m(m), m_params(p) {} | ||||
|      | ||||
|     tactic * translate(ast_manager & m) override { | ||||
| 
 | ||||
|     virtual tactic * translate(ast_manager & m) { | ||||
|         return alloc(sine_tactic, m, m_params); | ||||
|     } | ||||
| 
 | ||||
|     void updt_params(params_ref const & p) override { | ||||
|     virtual void updt_params(params_ref const & p) { | ||||
|     } | ||||
| 
 | ||||
|     void collect_param_descrs(param_descrs & r) override { | ||||
|     virtual void collect_param_descrs(param_descrs & r) { | ||||
|     } | ||||
| 
 | ||||
|     void operator()(goal_ref const & g, | ||||
|                     goal_ref_buffer & result, | ||||
|                     model_converter_ref & mc, | ||||
|                     proof_converter_ref & pc, | ||||
|                     expr_dependency_ref & core) override { | ||||
|         mc = nullptr; pc = nullptr; core = nullptr; | ||||
|     virtual void operator()(goal_ref const & g, | ||||
|                             goal_ref_buffer & result, | ||||
|                             model_converter_ref & mc, | ||||
|                             proof_converter_ref & pc, | ||||
|                             expr_dependency_ref & core) { | ||||
|         mc = 0; pc = 0; core = 0; | ||||
| 
 | ||||
|         TRACE("sine", g->display(tout);); | ||||
|         TRACE("sine", tout << g->size();); | ||||
|  | @ -62,7 +62,7 @@ public: | |||
|         TRACE("sine", tout << new_forms.size();); | ||||
|         g->reset(); | ||||
|         for (unsigned i = 0; i < new_forms.size(); i++) { | ||||
|             g->assert_expr(new_forms.get(i), nullptr, nullptr); | ||||
|             g->assert_expr(new_forms.get(i), 0, 0); | ||||
|         } | ||||
|         g->inc_depth(); | ||||
|         g->updt_prec(goal::OVER); | ||||
|  | @ -72,115 +72,120 @@ public: | |||
|         filter_model_converter * fmc = alloc(filter_model_converter, m); | ||||
|         mc = fmc; | ||||
|     } | ||||
|      | ||||
|     void cleanup() override { | ||||
| 
 | ||||
|     virtual void cleanup() { | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
| 
 | ||||
|     typedef std::pair<expr*,expr*> t_work_item; | ||||
| 
 | ||||
|     t_work_item work_item(expr *e, expr *root) { | ||||
|     t_work_item work_item(expr * e, expr * root) { | ||||
|         return std::pair<expr*, expr*>(e, root); | ||||
|     } | ||||
| 
 | ||||
|     void find_constants(expr *e, obj_hashtable<func_decl> &consts) { | ||||
|     void find_constants(expr * e, obj_hashtable<func_decl> &consts) { | ||||
|         ptr_vector<expr> stack; | ||||
|         stack.push_back(e); | ||||
|         expr *curr; | ||||
|         expr * curr; | ||||
|         while (!stack.empty()) { | ||||
|             curr = stack.back(); | ||||
|             stack.pop_back(); | ||||
|             if (is_app(curr)) { | ||||
|             if (is_app(curr) && is_uninterp(curr)) { | ||||
|                 app *a = to_app(curr); | ||||
|                 if (is_uninterp(a)) { | ||||
|                     func_decl *f = a->get_decl(); | ||||
|                     consts.insert_if_not_there(f); | ||||
|                 } | ||||
|                 func_decl *f = a->get_decl(); | ||||
|                 consts.insert_if_not_there(f); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     bool quantifier_matches(quantifier *q, | ||||
|     bool quantifier_matches(quantifier * q, | ||||
|                             obj_hashtable<func_decl> const & consts, | ||||
|                             ptr_vector<func_decl> & next_consts) { | ||||
|         TRACE("sine", tout << "size of consts is "; tout << consts.size(); tout << "\n";); | ||||
|         for (obj_hashtable<func_decl>::iterator constit = consts.begin(), constend = consts.end(); constit != constend; constit++) { | ||||
|             TRACE("sine", tout << *constit; tout << "\n";); | ||||
|         } | ||||
|         TRACE("sine", | ||||
|             tout << "size of consts is "; tout << consts.size(); tout << "\n"; | ||||
|             obj_hashtable<func_decl>::iterator it = consts.begin(); | ||||
|             obj_hashtable<func_decl>::iterator end = consts.end(); | ||||
|             for (; it != end; it++) | ||||
|                 tout << *it << "\n"; ); | ||||
| 
 | ||||
|         bool matched = false; | ||||
|         for (unsigned i = 0; i < q->get_num_patterns(); i++) { | ||||
|             bool p_matched = true; | ||||
|             ptr_vector<expr> stack; | ||||
|             expr *curr; | ||||
|             expr * curr; | ||||
| 
 | ||||
|             // patterns are wrapped with "pattern"
 | ||||
|             if (!m.is_pattern(q->get_pattern(i), stack)) { | ||||
|             if (!m.is_pattern(q->get_pattern(i), stack)) | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             while (!stack.empty()) { | ||||
|                 curr = stack.back(); | ||||
|                 stack.pop_back(); | ||||
| 
 | ||||
|                 if (is_app(curr)) { | ||||
|                     app *a = to_app(curr); | ||||
|                     func_decl *f = a->get_decl(); | ||||
|                     app * a = to_app(curr); | ||||
|                     func_decl * f = a->get_decl(); | ||||
|                     if (!consts.contains(f)) { | ||||
|                         TRACE("sine", tout << mk_pp(f, m) << "\n";); | ||||
|                         p_matched = false; | ||||
|                         next_consts.push_back(f); | ||||
|                         break; | ||||
|                     } | ||||
|                     for (unsigned j = 0; j < a->get_num_args(); j++) { | ||||
|                     for (unsigned j = 0; j < a->get_num_args(); j++) | ||||
|                         stack.push_back(a->get_arg(j)); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (p_matched) { | ||||
|                 matched = true; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return matched; | ||||
|     } | ||||
|    | ||||
| 
 | ||||
|     void filter_expressions(goal_ref const & g, ptr_vector<expr> & new_exprs) { | ||||
|         obj_map<func_decl, obj_hashtable<expr> > const2exp; | ||||
|         obj_map<expr, obj_hashtable<func_decl> > exp2const; | ||||
|         obj_map<func_decl, obj_pair_hashtable<expr, expr> > const2quantifier; | ||||
|         obj_hashtable<func_decl> consts; | ||||
|         vector<t_work_item> stack; | ||||
|         for (unsigned i = 0; i < g->size(); i++) { | ||||
|             stack.push_back(work_item(g->form(i), g->form(i))); | ||||
|         } | ||||
|         t_work_item curr; | ||||
| 
 | ||||
|         for (unsigned i = 0; i < g->size(); i++) | ||||
|             stack.push_back(work_item(g->form(i), g->form(i))); | ||||
| 
 | ||||
|         while (!stack.empty()) { | ||||
|             curr = stack.back(); | ||||
|             stack.pop_back(); | ||||
|             if (is_app(curr.first)) { | ||||
|                 app *a = to_app(curr.first); | ||||
|                 if (is_uninterp(a)) { | ||||
|                     func_decl *f = a->get_decl(); | ||||
|                     if (!consts.contains(f)) { | ||||
|                         consts.insert(f); | ||||
|                         if (const2quantifier.contains(f)) { | ||||
|                             for (obj_pair_hashtable<expr, expr>::iterator it = const2quantifier[f].begin(), end = const2quantifier[f].end(); it != end; it++) { | ||||
|                                 stack.push_back(*it); | ||||
|                             } | ||||
|                             const2quantifier.remove(f); | ||||
|                         } | ||||
|                     } | ||||
|                     if (!const2exp.contains(f)) { | ||||
|                         const2exp.insert(f, obj_hashtable<expr>()); | ||||
|                     } | ||||
|                     if (!const2exp[f].contains(curr.second)) { | ||||
|                         const2exp[f].insert(curr.second); | ||||
|                     } | ||||
|                     if (!exp2const.contains(curr.second)) { | ||||
|                         exp2const.insert(curr.second, obj_hashtable<func_decl>()); | ||||
|                     } | ||||
|                     if (!exp2const[curr.second].contains(f)) { | ||||
|                         exp2const[curr.second].insert(f); | ||||
|             if (is_app(curr.first) && is_uninterp(curr.first)) { | ||||
|                 app * a = to_app(curr.first); | ||||
|                 func_decl * f = a->get_decl(); | ||||
|                 if (!consts.contains(f)) { | ||||
|                     consts.insert(f); | ||||
|                     if (const2quantifier.contains(f)) { | ||||
|                         obj_pair_hashtable<expr, expr>::iterator it = const2quantifier[f].begin(); | ||||
|                         obj_pair_hashtable<expr, expr>::iterator end = const2quantifier[f].end(); | ||||
|                         for (; it != end; it++) | ||||
|                             stack.push_back(*it); | ||||
|                         const2quantifier.remove(f); | ||||
|                     } | ||||
|                 } | ||||
|                 if (!const2exp.contains(f)) { | ||||
|                     const2exp.insert(f, obj_hashtable<expr>()); | ||||
|                 } | ||||
|                 if (!const2exp[f].contains(curr.second)) { | ||||
|                     const2exp[f].insert(curr.second); | ||||
|                 } | ||||
|                 if (!exp2const.contains(curr.second)) { | ||||
|                     exp2const.insert(curr.second, obj_hashtable<func_decl>()); | ||||
|                 } | ||||
|                 if (!exp2const[curr.second].contains(f)) { | ||||
|                     exp2const[curr.second].insert(f); | ||||
|                 } | ||||
| 
 | ||||
|                 for (unsigned i = 0; i < a->get_num_args(); i++) { | ||||
|                     stack.push_back(work_item(a->get_arg(i), curr.second)); | ||||
|                 } | ||||
|  | @ -214,28 +219,32 @@ private: | |||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // ok, now we just need to find the connected component of the last term
 | ||||
|      | ||||
|         obj_hashtable<expr> visited; | ||||
|         ptr_vector<expr> to_visit; | ||||
|         to_visit.push_back(g->form(g->size() - 1)); | ||||
|         expr *visiting; | ||||
|         expr * visiting; | ||||
| 
 | ||||
|         while (!to_visit.empty()) { | ||||
|             visiting = to_visit.back(); | ||||
|             to_visit.pop_back(); | ||||
|             visited.insert(visiting); | ||||
|             for (obj_hashtable<func_decl>::iterator constit = exp2const[visiting].begin(), constend = exp2const[visiting].end(); constit != constend; constit++) { | ||||
|                 for (obj_hashtable<expr>::iterator exprit = const2exp[*constit].begin(), exprend = const2exp[*constit].end(); exprit != exprend; exprit++) { | ||||
|                     if (!visited.contains(*exprit)) { | ||||
|             obj_hashtable<func_decl>::iterator it = exp2const[visiting].begin(); | ||||
|             obj_hashtable<func_decl>::iterator end = exp2const[visiting].end(); | ||||
|             for (; it != end; it++) { | ||||
|                 obj_hashtable<expr>::iterator exprit = const2exp[*it].begin(); | ||||
|                 obj_hashtable<expr>::iterator exprend = const2exp[*it].end(); | ||||
|                 for (; exprit != exprend; exprit++) { | ||||
|                     if (!visited.contains(*exprit)) | ||||
|                         to_visit.push_back(*exprit); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         for (unsigned i = 0; i < g->size(); i++) { | ||||
|             if (visited.contains(g->form(i))) { | ||||
|             if (visited.contains(g->form(i))) | ||||
|                 new_exprs.push_back(g->form(i)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| }; | ||||
|  |  | |||
|  | @ -278,7 +278,7 @@ static void tst_select_small(mpbq_manager & m, scoped_mpbq const & l, scoped_mpb | |||
|     std::cout << "choice: " << r << " as decimal: "; m.display_decimal(std::cout, r); std::cout << std::endl; | ||||
| } | ||||
| 
 | ||||
| static void tst_select_small(mpbq_manager & m, int64 n1, unsigned k1, int64 n2, unsigned k2, bool expected) { | ||||
| static void tst_select_small(mpbq_manager & m, int64_t n1, unsigned k1, int64_t n2, unsigned k2, bool expected) { | ||||
|     scoped_mpbq l(m); | ||||
|     scoped_mpbq u(m); | ||||
|     m.set(l, n1, k1); | ||||
|  |  | |||
|  | @ -95,12 +95,12 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, | |||
|             f_b.reset(); | ||||
|             f_q.reset(); | ||||
|             for(unsigned col=0; col<sig_b.size(); col++) { | ||||
|                 uint64 sort_sz; | ||||
|                 uint64_t sort_sz; | ||||
|                 if(!decl_util.try_get_size(sig_q[col], sort_sz)) { | ||||
|                     warning_msg("cannot get sort size"); | ||||
|                     return; | ||||
|                 } | ||||
|                 uint64 num = ran()%sort_sz; | ||||
|                 uint64_t num = ran()%sort_sz; | ||||
|                 app * el_b = decl_util.mk_numeral(num, sig_b[col]); | ||||
|                 f_b.push_back(el_b); | ||||
|                 app * el_q = decl_util.mk_numeral(num, sig_q[col]); | ||||
|  | @ -167,7 +167,7 @@ void dl_query_test_wpa(smt_params & fparams, params_ref& params) { | |||
|     ENSURE(v_pred); | ||||
|     sort * var_sort = v_pred->get_domain(0); | ||||
| 
 | ||||
|     uint64 var_sz; | ||||
|     uint64_t var_sz; | ||||
|     TRUSTME( ctx.try_get_sort_constant_count(var_sort, var_sz) ); | ||||
| 
 | ||||
|     for(unsigned attempt=0; attempt<attempts; attempt++) { | ||||
|  |  | |||
|  | @ -43,8 +43,8 @@ static void tst1() { | |||
| static void tst2() { | ||||
|     mpff_manager m; | ||||
|     scoped_mpff a(m), b(m); | ||||
|     m.set(a, static_cast<uint64>(100)); | ||||
|     m.set(b, static_cast<int64>(-100)); | ||||
|     m.set(a, static_cast<uint64_t>(100)); | ||||
|     m.set(b, static_cast<int64_t>(-100)); | ||||
|     std::cout << "[test2], a: " << a << ", b: " << b << "\n"; | ||||
| } | ||||
| 
 | ||||
|  | @ -75,7 +75,7 @@ static void tst4() { | |||
| static void tst5() { | ||||
|     mpff_manager m; | ||||
|     scoped_mpff a(m), b(m); | ||||
|     m.set(a, static_cast<uint64>(1) << 63); | ||||
|     m.set(a, static_cast<uint64_t>(1) << 63); | ||||
|     m.display_raw(std::cout, a); std::cout << "\n"; | ||||
|     ENSURE(m.is_zero(b)); | ||||
|     ENSURE(m.lt(b, a)); | ||||
|  | @ -117,7 +117,7 @@ static void tst7() { | |||
| 
 | ||||
| 
 | ||||
| #define MK_BIN_OP(OP)                                                   \ | ||||
| static void tst_ ## OP ## _core(int64 n1, uint64 d1, int64 n2, uint64 d2, unsigned precision = 2, unsigned exp = 0) { \ | ||||
| static void tst_ ## OP ## _core(int64_t n1, uint64_t d1, int64_t n2, uint64_t d2, unsigned precision = 2, unsigned exp = 0) { \ | ||||
|     TRACE("mpff_bug", tout << n1 << "/" << d1 << ", " << n2 << "/" << d2 << "\n";); \ | ||||
|     unsynch_mpq_manager qm;                                             \ | ||||
|     scoped_mpq  qa(qm), qb(qm), qc(qm), qt(qm);                         \ | ||||
|  | @ -207,7 +207,7 @@ static void tst_set64(unsigned N, unsigned prec) { | |||
|     mpff_manager fm(prec); | ||||
|     scoped_mpff a(fm); | ||||
| 
 | ||||
|     fm.set(a, static_cast<int64>(INT64_MAX)); | ||||
|     fm.set(a, static_cast<int64_t>(INT64_MAX)); | ||||
|     ENSURE(fm.is_int64(a)); | ||||
|     ENSURE(fm.is_uint64(a)); | ||||
|     fm.inc(a); | ||||
|  | @ -221,7 +221,7 @@ static void tst_set64(unsigned N, unsigned prec) { | |||
|     ENSURE(fm.is_int64(a)); | ||||
|     ENSURE(fm.is_uint64(a)); | ||||
| 
 | ||||
|     fm.set(a, static_cast<int64>(INT64_MIN)); | ||||
|     fm.set(a, static_cast<int64_t>(INT64_MIN)); | ||||
|     ENSURE(fm.is_int64(a)); | ||||
|     ENSURE(!fm.is_uint64(a)); | ||||
|     fm.dec(a); | ||||
|  | @ -235,7 +235,7 @@ static void tst_set64(unsigned N, unsigned prec) { | |||
|     ENSURE(fm.is_int64(a)); | ||||
|     ENSURE(!fm.is_uint64(a)); | ||||
| 
 | ||||
|     fm.set(a, static_cast<uint64>(UINT64_MAX)); | ||||
|     fm.set(a, static_cast<uint64_t>(UINT64_MAX)); | ||||
|     ENSURE(fm.is_uint64(a)); | ||||
|     ENSURE(!fm.is_int64(a)); | ||||
|     fm.inc(a); | ||||
|  | @ -250,23 +250,23 @@ static void tst_set64(unsigned N, unsigned prec) { | |||
| 
 | ||||
|     for (unsigned i = 0; i < N; i++) { | ||||
|         { | ||||
|             uint64 v = (static_cast<uint64>(rand()) << 32) + static_cast<uint64>(rand());  | ||||
|             uint64_t v = (static_cast<uint64_t>(rand()) << 32) + static_cast<uint64_t>(rand());  | ||||
|             fm.set(a, v); | ||||
|             ENSURE(fm.is_uint64(a)); | ||||
|              | ||||
|             v = (static_cast<uint64>(rand() % 3) << 32) + static_cast<uint64>(rand());  | ||||
|             v = (static_cast<uint64_t>(rand() % 3) << 32) + static_cast<uint64_t>(rand());  | ||||
|             fm.set(a, v); | ||||
|             ENSURE(fm.is_uint64(a)); | ||||
|         } | ||||
|         { | ||||
|             int64 v = (static_cast<uint64>(rand() % INT_MAX) << 32) + static_cast<uint64>(rand()); | ||||
|             int64_t v = (static_cast<uint64_t>(rand() % INT_MAX) << 32) + static_cast<uint64_t>(rand()); | ||||
|             if (rand()%2 == 0) | ||||
|                 v = -v; | ||||
|             fm.set(a, v); | ||||
|             ENSURE(fm.is_int64(a)); | ||||
| 
 | ||||
| 
 | ||||
|             v = (static_cast<uint64>(rand() % 3) << 32) + static_cast<uint64>(rand()); | ||||
|             v = (static_cast<uint64_t>(rand() % 3) << 32) + static_cast<uint64_t>(rand()); | ||||
|             if (rand()%2 == 0) | ||||
|                 v = -v; | ||||
|             fm.set(a, v); | ||||
|  | @ -336,7 +336,7 @@ static void tst_power(unsigned prec = 2) { | |||
|     m.set(a, UINT_MAX); | ||||
|     m.inc(a); | ||||
|     ENSURE(m.is_power_of_two(a, k) && k == 32); | ||||
|     ENSURE(m.get_uint64(a) == static_cast<uint64>(UINT_MAX) + 1); | ||||
|     ENSURE(m.get_uint64(a) == static_cast<uint64_t>(UINT_MAX) + 1); | ||||
|     m.power(a, 2, a); | ||||
|     ENSURE(m.is_power_of_two(a, k) && k == 64); | ||||
|     m.power(a, 4, a); | ||||
|  | @ -538,7 +538,7 @@ static void tst_add_corner(unsigned prec) { | |||
| } | ||||
| #endif | ||||
| 
 | ||||
| static void tst_decimal(int64 n, uint64 d, bool to_plus_inf, unsigned prec, char const * expected, unsigned decimal_places = UINT_MAX) { | ||||
| static void tst_decimal(int64_t n, uint64_t d, bool to_plus_inf, unsigned prec, char const * expected, unsigned decimal_places = UINT_MAX) { | ||||
|     mpff_manager m(prec); | ||||
|     scoped_mpff a(m); | ||||
|     m.set_rounding(to_plus_inf); | ||||
|  | @ -567,7 +567,7 @@ static void tst_decimal() { | |||
|     tst_decimal(-32, 5, true, 2, "-6.39999999999999999965305530480463858111761510372161865234375"); | ||||
| } | ||||
| 
 | ||||
| static void tst_prev_power_2(int64 n, uint64 d, unsigned expected) { | ||||
| static void tst_prev_power_2(int64_t n, uint64_t d, unsigned expected) { | ||||
|     mpff_manager m; | ||||
|     scoped_mpff a(m); | ||||
|     m.set(a, n, d); | ||||
|  | @ -598,7 +598,7 @@ static void tst_div(unsigned prec) { | |||
|     scoped_mpff a(m), b(m), c(m); | ||||
|     m.round_to_plus_inf(); | ||||
|     m.set(a, 1); | ||||
|     m.set(b, static_cast<uint64>(UINT64_MAX)); | ||||
|     m.set(b, static_cast<uint64_t>(UINT64_MAX)); | ||||
|     m.div(a, b, c); | ||||
|     m.display_raw(std::cout, a); std::cout << "\n"; | ||||
|     m.display_raw(std::cout, b); std::cout << "\n"; | ||||
|  |  | |||
|  | @ -35,7 +35,7 @@ static void tst1() { | |||
|     m.display_decimal(std::cout, a); std::cout << "\n"; | ||||
| } | ||||
| 
 | ||||
| static void tst_prev_power_2(int64 n, uint64 d, unsigned expected) { | ||||
| static void tst_prev_power_2(int64_t n, uint64_t d, unsigned expected) { | ||||
|     mpfx_manager m; | ||||
|     scoped_mpfx a(m); | ||||
|     m.set(a, n, d); | ||||
|  |  | |||
|  | @ -133,7 +133,7 @@ static void set_str_bug() { | |||
|     ENSURE(a == b); | ||||
| } | ||||
| 
 | ||||
| static void tst_prev_power_2(int64 n, uint64 d, unsigned expected) { | ||||
| static void tst_prev_power_2(int64_t n, uint64_t d, unsigned expected) { | ||||
|     unsynch_mpq_manager m; | ||||
|     scoped_mpq a(m); | ||||
|     m.set(a, n, d); | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ static void tst1() { | |||
| static void tst2() { | ||||
|     synch_mpz_manager m; | ||||
|     mpz v1, v2, v3; | ||||
|     m.set(v1, static_cast<int64>(UINT_MAX)); | ||||
|     m.set(v1, static_cast<int64_t>(UINT_MAX)); | ||||
|     m.add(v1, m.mk_z(1), v2); | ||||
|     m.mul(v2, v2, v3); | ||||
|     std::cout << "v2:\n" << m.to_string(v2) << "\n"; | ||||
|  | @ -63,7 +63,7 @@ static void tst2() { | |||
| static void tst2b() { | ||||
|     synch_mpz_manager m; | ||||
|     mpz v1, v2, v3; | ||||
|     m.set(v1, static_cast<int64>(UINT_MAX)); | ||||
|     m.set(v1, static_cast<int64_t>(UINT_MAX)); | ||||
|     m.add(v1, m.mk_z(1), v2); | ||||
|     m.mul(v2, v2, v3); | ||||
|     std::cout << "v2:\n" << m.to_string(v2) << "\n"; | ||||
|  | @ -127,8 +127,8 @@ static void bug3() { | |||
| static void bug4() { | ||||
|     synch_mpz_manager m; | ||||
|     mpz x, y; | ||||
|     m.set(y, 4294967295ull); | ||||
|     m.set(x, 4026531839ull); | ||||
|     m.set(y, static_cast<uint64_t>(4294967295ull)); | ||||
|     m.set(x, static_cast<uint64_t>(4026531839ull)); | ||||
|     mpz result1; | ||||
|     m.bitwise_or(x, y, result1); | ||||
| 
 | ||||
|  | @ -282,7 +282,7 @@ void tst_int_min_bug() { | |||
|     mpz big; | ||||
|     mpz expected; | ||||
|     mpz r; | ||||
|     m.set(big, static_cast<uint64>(UINT64_MAX)); | ||||
|     m.set(big, static_cast<uint64_t>(UINT64_MAX)); | ||||
|     m.set(expected, "18446744075857035263"); | ||||
|     m.sub(big, intmin, r); | ||||
|     std::cout << "r: " << m.to_string(r) << "\nexpected: " << m.to_string(expected) << "\n"; | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ void tst_prime_generator() { | |||
| 
 | ||||
|     prime_generator gen; | ||||
|     for (unsigned i = 0; i < 10000; i++) { | ||||
|         uint64 p = gen(i); | ||||
|         uint64_t p = gen(i); | ||||
|         std::cout << p << ", "; | ||||
|         if (i % 11 == 0) std::cout << "\n"; | ||||
|         std::cout.flush(); | ||||
|  | @ -33,8 +33,8 @@ void tst_prime_generator() { | |||
|             continue; | ||||
|         m.set(sqrt_p, p); | ||||
|         m.root(sqrt_p, 2); | ||||
|         uint64 k = m.get_uint64(sqrt_p); | ||||
|         for (uint64 i = 2; i <= k; i++) { | ||||
|         uint64_t k = m.get_uint64(sqrt_p); | ||||
|         for (uint64_t i = 2; i <= k; i++) { | ||||
|             ENSURE(p % i != 0); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -194,8 +194,8 @@ static void tst2() { | |||
|     ENSURE(uint64_max.is_uint64()); | ||||
| 
 | ||||
|     // get_int64, get_uint64
 | ||||
|     uint64 u1 = uint64_max.get_uint64(); | ||||
|     uint64 u2 = UINT64_MAX; | ||||
|     uint64_t u1 = uint64_max.get_uint64(); | ||||
|     uint64_t u2 = UINT64_MAX; | ||||
|     VERIFY(u1 == u2); | ||||
|     std::cout << "int64_max: " << int64_max << ", INT64_MAX: " << INT64_MAX << ", int64_max.get_int64(): " << int64_max.get_int64() << ", int64_max.get_uint64(): " << int64_max.get_uint64() << "\n"; | ||||
|     ENSURE(int64_max.get_int64() == INT64_MAX); | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ Module Name: | |||
| 
 | ||||
| Abstract: | ||||
| 
 | ||||
|     A class for wrapping checked (and unchecked) int64 operations. | ||||
|     A class for wrapping checked (and unchecked) int64_t operations. | ||||
|     Note: the mpfx class defines a more general class of fixed-point operations. | ||||
|     A tradeoff is that it relies on a manager. | ||||
|     This class several of the most common operations from rational, so | ||||
|  | @ -29,15 +29,15 @@ Revision History: | |||
| 
 | ||||
| template<bool CHECK> | ||||
| class checked_int64 { | ||||
|     int64 m_value; | ||||
|     int64_t m_value; | ||||
|     typedef checked_int64 ci; | ||||
|      | ||||
|     rational r64(int64 i) { return rational(i, rational::i64()); } | ||||
|     rational r64(int64_t i) { return rational(i, rational::i64()); } | ||||
| 
 | ||||
| public: | ||||
| 
 | ||||
|     checked_int64(): m_value(0) {} | ||||
|     checked_int64(int64 v): m_value(v) {} | ||||
|     checked_int64(int64_t v): m_value(v) {} | ||||
|     checked_int64(checked_int64 const& other) { m_value = other.m_value; } | ||||
| 
 | ||||
|     class overflow_exception : public z3_exception { | ||||
|  | @ -57,7 +57,7 @@ public: | |||
|     static checked_int64 one() { return ci(1); } | ||||
|     static checked_int64 minus_one() { return ci(-1);} | ||||
| 
 | ||||
|     int64 get_int64() const { return m_value; } | ||||
|     int64_t get_int64() const { return m_value; } | ||||
| 
 | ||||
|     checked_int64 abs() const {  | ||||
|         if (m_value >= 0) { | ||||
|  | @ -117,9 +117,9 @@ public: | |||
| 
 | ||||
|     checked_int64& operator+=(checked_int64 const& other) {  | ||||
|         if (CHECK) { | ||||
|             uint64 x = static_cast<uint64>(m_value); | ||||
|             uint64 y = static_cast<uint64>(other.m_value); | ||||
|             int64 r = static_cast<int64>(x + y); | ||||
|             uint64_t x = static_cast<uint64_t>(m_value); | ||||
|             uint64_t y = static_cast<uint64_t>(other.m_value); | ||||
|             int64_t r = static_cast<int64_t>(x + y); | ||||
|             if (m_value > 0 && other.m_value > 0 && r <= 0) throw overflow_exception(); | ||||
|             if (m_value < 0 && other.m_value < 0 && r >= 0) throw overflow_exception(); | ||||
|             m_value = r; | ||||
|  | @ -132,9 +132,9 @@ public: | |||
| 
 | ||||
|     checked_int64& operator-=(checked_int64 const& other) { | ||||
|         if (CHECK) { | ||||
|             uint64 x = static_cast<uint64>(m_value); | ||||
|             uint64 y = static_cast<uint64>(other.m_value); | ||||
|             int64 r = static_cast<int64>(x - y); | ||||
|             uint64_t x = static_cast<uint64_t>(m_value); | ||||
|             uint64_t y = static_cast<uint64_t>(other.m_value); | ||||
|             int64_t r = static_cast<int64_t>(x - y); | ||||
|             if (m_value > 0 && other.m_value < 0 && r <= 0) throw overflow_exception(); | ||||
|             if (m_value < 0 && other.m_value > 0 && r >= 0) throw overflow_exception(); | ||||
|             m_value = r;             | ||||
|  |  | |||
|  | @ -75,8 +75,8 @@ public: | |||
|     static void set(double & a, char const * val) { a = atof(val); } | ||||
|     static void set(double & a, int val) { a = static_cast<double>(val); } | ||||
|     static void set(double & a, unsigned val) { a = static_cast<double>(val); } | ||||
|     static void set(double & a, int64 val) { a = static_cast<double>(val); } | ||||
|     static void set(double & a, uint64 val) { a = static_cast<double>(val); } | ||||
|     static void set(double & a, int64_t val) { a = static_cast<double>(val); } | ||||
|     static void set(double & a, uint64_t val) { a = static_cast<double>(val); } | ||||
|     static void swap(double & a, double & b) { std::swap(a, b); } | ||||
|     bool is_pos(double a) const { return a > m_zero_tolerance; } | ||||
|     bool is_neg(double a) const { return a < m_zero_tolerance; } | ||||
|  | @ -93,11 +93,11 @@ public: | |||
|     } | ||||
| 
 | ||||
|     static unsigned hash(double a) {  | ||||
|         return hash_ull(static_cast<uint64>(a)); | ||||
|         return hash_ull(static_cast<uint64_t>(a)); | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| static_assert(sizeof(uint64) == sizeof(double), ""); | ||||
| static_assert(sizeof(uint64_t) == sizeof(double), ""); | ||||
| 
 | ||||
| #endif /* DOUBLE_MANAGER_H_ */ | ||||
| 
 | ||||
|  |  | |||
|  | @ -140,8 +140,8 @@ struct size_t_hash { | |||
| }; | ||||
| 
 | ||||
| struct uint64_hash { | ||||
|     typedef uint64 data; | ||||
|     unsigned operator()(uint64 x) const { return static_cast<unsigned>(x); } | ||||
|     typedef uint64_t data; | ||||
|     unsigned operator()(uint64_t x) const { return static_cast<unsigned>(x); } | ||||
| }; | ||||
| 
 | ||||
| struct bool_hash { | ||||
|  |  | |||
|  | @ -91,8 +91,8 @@ hwf_manager::~hwf_manager() | |||
| { | ||||
| } | ||||
| 
 | ||||
| uint64 RAW(double X) { uint64 tmp; memcpy(&tmp, &(X), sizeof(uint64)); return tmp; } | ||||
| double DBL(uint64 X) { double tmp; memcpy(&tmp, &(X), sizeof(double)); return tmp; } | ||||
| uint64_t RAW(double X) { uint64_t tmp; memcpy(&tmp, &(X), sizeof(uint64_t)); return tmp; } | ||||
| double DBL(uint64_t X) { double tmp; memcpy(&tmp, &(X), sizeof(double)); return tmp; } | ||||
| 
 | ||||
| void hwf_manager::set(hwf & o, int value) { | ||||
|     o.value = (double) value; | ||||
|  | @ -147,7 +147,7 @@ void hwf_manager::set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mp | |||
| 
 | ||||
|     mpq sig; | ||||
|     m_mpq_manager.set(sig, significand); | ||||
|     int64 exp = m_mpz_manager.get_int64(exponent); | ||||
|     int64_t exp = m_mpz_manager.get_int64(exponent); | ||||
| 
 | ||||
|     if (m_mpq_manager.is_zero(significand)) | ||||
|         o.value = 0.0; | ||||
|  | @ -160,17 +160,17 @@ void hwf_manager::set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mp | |||
|         } | ||||
| 
 | ||||
|         hwf s; s.value = m_mpq_manager.get_double(sig); | ||||
|         uint64 r = (RAW(s.value) & 0x800FFFFFFFFFFFFFull) | ((exp + 1023) << 52); | ||||
|         uint64_t r = (RAW(s.value) & 0x800FFFFFFFFFFFFFull) | ((exp + 1023) << 52); | ||||
|         o.value = DBL(r); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void hwf_manager::set(hwf & o, bool sign, uint64 significand, int exponent) { | ||||
| void hwf_manager::set(hwf & o, bool sign, uint64_t significand, int exponent) { | ||||
|     // Assumption: this represents (sign * -1) * (significand/2^sbits) * 2^exponent.
 | ||||
|     SASSERT(significand <= 0x000FFFFFFFFFFFFFull); | ||||
|     SASSERT(-1022 <= exponent && exponent <= 1023); | ||||
|     uint64 raw = (sign?0x8000000000000000ull:0); | ||||
|     raw |= (((uint64)exponent) + 1023) << 52; | ||||
|     uint64_t raw = (sign?0x8000000000000000ull:0); | ||||
|     raw |= (((uint64_t)exponent) + 1023) << 52; | ||||
|     raw |= significand; | ||||
|     memcpy(&o.value, &raw, sizeof(double)); | ||||
| } | ||||
|  | @ -413,12 +413,12 @@ void hwf_manager::to_rational(hwf const & x, unsynch_mpq_manager & qm, mpq & o) | |||
|     scoped_mpz n(qm), d(qm); | ||||
| 
 | ||||
|     if (is_normal(x)) | ||||
|         qm.set(n, sig(x) | 0x0010000000000000ull); | ||||
|         qm.set(n, (uint64_t)(sig(x) | 0x0010000000000000ull)); | ||||
|     else | ||||
|         qm.set(n, sig(x)); | ||||
|     if (sgn(x)) | ||||
|         qm.neg(n); | ||||
|     qm.set(d, 0x0010000000000000ull); | ||||
|     qm.set(d, (uint64_t)0x0010000000000000ull); | ||||
|     int e = exp(x); | ||||
|     if (e >= 0) | ||||
|         qm.mul2k(n, (unsigned)e); | ||||
|  | @ -428,7 +428,7 @@ void hwf_manager::to_rational(hwf const & x, unsynch_mpq_manager & qm, mpq & o) | |||
| } | ||||
| 
 | ||||
| bool hwf_manager::is_zero(hwf const & x) { | ||||
|     uint64 t = RAW(x.value) & 0x7FFFFFFFFFFFFFFFull; | ||||
|     uint64_t t = RAW(x.value) & 0x7FFFFFFFFFFFFFFFull; | ||||
|     return (t == 0x0ull); | ||||
|     // CMW: I tried, and these are slower:
 | ||||
|     // return (t != 0x0ull) ? false  : true;
 | ||||
|  | @ -483,12 +483,12 @@ bool hwf_manager::is_ninf(hwf const & x) { | |||
| } | ||||
| 
 | ||||
| bool hwf_manager::is_normal(hwf const & x) { | ||||
|     uint64 t = RAW(x.value) & 0x7FF0000000000000ull; | ||||
|     uint64_t t = RAW(x.value) & 0x7FF0000000000000ull; | ||||
|     return (t != 0x0ull && t != 0x7FF0000000000000ull); | ||||
| } | ||||
| 
 | ||||
| bool hwf_manager::is_denormal(hwf const & x) { | ||||
|     uint64 t = RAW(x.value); | ||||
|     uint64_t t = RAW(x.value); | ||||
|     return ((t & 0x7FF0000000000000ull) == 0x0 && | ||||
|             (t & 0x000FFFFFFFFFFFFFull) != 0x0); | ||||
| } | ||||
|  | @ -498,7 +498,7 @@ bool hwf_manager::is_regular(hwf const & x) { | |||
|     // Note that +-0.0 and denormal numbers have exponent==0; these are regular.
 | ||||
|     // All normal numbers are also regular. What remains is +-Inf and NaN, they are
 | ||||
|     // not regular and they are the only numbers that have exponent 7FF.
 | ||||
|     uint64 e = RAW(x.value) & 0x7FF0000000000000ull; // the exponent
 | ||||
|     uint64_t e = RAW(x.value) & 0x7FF0000000000000ull; // the exponent
 | ||||
|     return (e != 0x7FF0000000000000ull); | ||||
| } | ||||
| 
 | ||||
|  | @ -513,15 +513,15 @@ bool hwf_manager::is_int(hwf const & x) { | |||
|         return false; | ||||
|     else | ||||
|     { | ||||
|         uint64 t = sig(x); | ||||
|         uint64_t t = sig(x); | ||||
|         unsigned shift = 52 - ((unsigned)e); | ||||
|         uint64 mask = (0x1ull << shift) - 1; | ||||
|         uint64_t mask = (0x1ull << shift) - 1; | ||||
|         return (t & mask) == 0; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void hwf_manager::mk_nzero(hwf & o) { | ||||
|     uint64 raw = 0x8000000000000000ull; | ||||
|     uint64_t raw = 0x8000000000000000ull; | ||||
|     o.value = DBL(raw); | ||||
| } | ||||
| 
 | ||||
|  | @ -537,22 +537,22 @@ void hwf_manager::mk_zero(bool sign, hwf & o) { | |||
| } | ||||
| 
 | ||||
| void hwf_manager::mk_nan(hwf & o) { | ||||
|     uint64 raw = 0x7FF0000000000001ull; | ||||
|     uint64_t raw = 0x7FF0000000000001ull; | ||||
|     o.value = DBL(raw); | ||||
| } | ||||
| 
 | ||||
| void hwf_manager::mk_inf(bool sign, hwf & o) { | ||||
|     uint64 raw = (sign) ? 0xFFF0000000000000ull : 0x7FF0000000000000ull; | ||||
|     uint64_t raw = (sign) ? 0xFFF0000000000000ull : 0x7FF0000000000000ull; | ||||
|     o.value = DBL(raw); | ||||
| } | ||||
| 
 | ||||
| void hwf_manager::mk_pinf(hwf & o) { | ||||
|     uint64 raw = 0x7FF0000000000000ull; | ||||
|     uint64_t raw = 0x7FF0000000000000ull; | ||||
|     o.value = DBL(raw); | ||||
| } | ||||
| 
 | ||||
| void hwf_manager::mk_ninf(hwf & o) { | ||||
|     uint64 raw = 0xFFF0000000000000ull; | ||||
|     uint64_t raw = 0xFFF0000000000000ull; | ||||
|     o.value = DBL(raw); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,8 +28,8 @@ class hwf { | |||
|     friend class hwf_manager; | ||||
|     double value; | ||||
|     hwf & operator=(hwf const & other) { UNREACHABLE(); return *this; } | ||||
|     uint64 get_raw() const { | ||||
|       uint64 n; | ||||
|     uint64_t get_raw() const { | ||||
|       uint64_t n; | ||||
|       SASSERT(sizeof(n) == sizeof(value)); | ||||
|       memcpy(&n, &value, sizeof(value)); | ||||
|       return n; | ||||
|  | @ -60,7 +60,7 @@ public: | |||
|     void set(hwf & o, mpf_rounding_mode rm, mpq const & value); | ||||
|     void set(hwf & o, mpf_rounding_mode rm, char const * value); | ||||
|     void set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mpz const & exponent); | ||||
|     void set(hwf & o, bool sign, uint64 significand, int exponent); | ||||
|     void set(hwf & o, bool sign, uint64_t significand, int exponent); | ||||
|     void set(hwf & o, hwf const & x); | ||||
|      | ||||
|     // auxiliary methods to make the interface compatible with mpf
 | ||||
|  | @ -128,7 +128,7 @@ public: | |||
|         return (x.get_raw() & 0x8000000000000000ull) != 0;  | ||||
|     } | ||||
| 
 | ||||
|     uint64 sig(hwf const & x) const { | ||||
|     uint64_t sig(hwf const & x) const { | ||||
|         return x.get_raw() & 0x000FFFFFFFFFFFFFull; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -118,12 +118,12 @@ class inf_eps_rational { | |||
| 
 | ||||
|     bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); } | ||||
| 
 | ||||
|     int64 get_int64() const { | ||||
|     int64_t get_int64() const { | ||||
|         SASSERT(is_int64()); | ||||
|         return m_r.get_int64(); | ||||
|     } | ||||
| 
 | ||||
|     uint64 get_uint64() const { | ||||
|     uint64_t get_uint64() const { | ||||
|         SASSERT(is_uint64()); | ||||
|         return m_r.get_uint64(); | ||||
|     } | ||||
|  |  | |||
|  | @ -109,12 +109,12 @@ class inf_int_rational { | |||
| 
 | ||||
|     bool is_rational() const { return m_second == 0; } | ||||
| 
 | ||||
|     int64 get_int64() const { | ||||
|     int64_t get_int64() const { | ||||
|         SASSERT(is_int64()); | ||||
|         return m_first.get_int64(); | ||||
|     } | ||||
| 
 | ||||
|     uint64 get_uint64() const { | ||||
|     uint64_t get_uint64() const { | ||||
|         SASSERT(is_uint64()); | ||||
|         return m_first.get_uint64(); | ||||
|     } | ||||
|  |  | |||
|  | @ -122,12 +122,12 @@ class inf_rational { | |||
| 
 | ||||
|     bool is_rational() const { return m_second.is_zero(); } | ||||
| 
 | ||||
|     int64 get_int64() const { | ||||
|     int64_t get_int64() const { | ||||
|         SASSERT(is_int64()); | ||||
|         return m_first.get_int64(); | ||||
|     } | ||||
| 
 | ||||
|     uint64 get_uint64() const { | ||||
|     uint64_t get_uint64() const { | ||||
|         SASSERT(is_uint64()); | ||||
|         return m_first.get_uint64(); | ||||
|     } | ||||
|  |  | |||
|  | @ -60,8 +60,8 @@ class inf_s_integer { | |||
|     bool is_int64() const { return m_second == 0; } | ||||
|     bool is_uint64() const { return m_second == 0; } | ||||
|     bool is_rational() const { return m_second == 0; } | ||||
|     int64 get_int64() const { return m_first; } | ||||
|     uint64 get_uint64() const { return m_first; } | ||||
|     int64_t get_int64() const { return m_first; } | ||||
|     uint64_t get_uint64() const { return m_first; } | ||||
|     s_integer get_rational() const { return s_integer(m_first); } | ||||
|     s_integer get_infinitesimal() const { return s_integer(m_second); } | ||||
|     inf_s_integer & operator=(const inf_s_integer & r) {  | ||||
|  |  | |||
|  | @ -250,7 +250,7 @@ void mpbq_manager::mul(mpbq const & a, mpz const & b, mpbq & r) { | |||
| } | ||||
| 
 | ||||
| void mpbq_manager::power(mpbq & a, unsigned k) { | ||||
|     SASSERT(static_cast<uint64>(k) * static_cast<uint64>(a.k()) <= static_cast<uint64>(UINT_MAX)); | ||||
|     SASSERT(static_cast<uint64_t>(k) * static_cast<uint64_t>(a.k()) <= static_cast<uint64_t>(UINT_MAX)); | ||||
|     // We don't need to normalize because:
 | ||||
|     //   If a.m_k == 0, then a is an integer, and the result be an integer
 | ||||
|     //   If a.m_k > 0, then a.m_num must be odd, and the (a.m_num)^k will also be odd
 | ||||
|  |  | |||
|  | @ -84,7 +84,7 @@ public: | |||
|     void set(mpbq & a, mpz const & n, unsigned k) { m_manager.set(a.m_num, n); a.m_k = k; normalize(a); } | ||||
|     void set(mpbq & a, mpz const & n) { m_manager.set(a.m_num, n); a.m_k = 0; } | ||||
|     void set(mpbq & a, mpbq const & b) { m_manager.set(a.m_num, b.m_num); a.m_k = b.m_k; } | ||||
|     void set(mpbq & a, int64 n, unsigned k) { m_manager.set(a.m_num, n); a.m_k = k; normalize(a); } | ||||
|     void set(mpbq & a, int64_t n, unsigned k) { m_manager.set(a.m_num, n); a.m_k = k; normalize(a); } | ||||
| 
 | ||||
|     bool is_int(mpbq const & a) const { return a.m_k == 0; } | ||||
|     void get_numerator(mpbq const & a, mpz & n) { m_manager.set(n, a.m_num); } | ||||
|  |  | |||
|  | @ -115,11 +115,11 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) { | |||
|     // double === mpf(11, 53)
 | ||||
|     static_assert(sizeof(double) == 8, "doubles are 8 bytes"); | ||||
| 
 | ||||
|     uint64 raw; | ||||
|     uint64_t raw; | ||||
|     memcpy(&raw, &value, sizeof(double)); | ||||
|     bool sign = (raw >> 63) != 0; | ||||
|     int64 e =  ((raw & 0x7FF0000000000000ull) >> 52) - 1023; | ||||
|     uint64 s = raw & 0x000FFFFFFFFFFFFFull; | ||||
|     int64_t e =  ((raw & 0x7FF0000000000000ull) >> 52) - 1023; | ||||
|     uint64_t s = raw & 0x000FFFFFFFFFFFFFull; | ||||
| 
 | ||||
|     TRACE("mpf_dbg", tout << "set: " << value << " is: raw=" << raw << " (double)" << | ||||
|                           " sign=" << sign << " s=" << s << " e=" << e << std::endl;); | ||||
|  | @ -300,7 +300,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode | |||
|     TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;); | ||||
| } | ||||
| 
 | ||||
| void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64 significand) { | ||||
| void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64_t significand) { | ||||
|     // Assumption: this represents (sign * -1) * (significand/2^sbits) * 2^exponent.
 | ||||
|     o.ebits = ebits; | ||||
|     o.sbits = sbits; | ||||
|  | @ -1194,7 +1194,7 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o | |||
|     m_mpz_manager.set(z, t.significand()); | ||||
|     mpf_exp_t e = (mpf_exp_t)t.exponent() - t.sbits() + 1; | ||||
|     if (e < 0) { | ||||
|         bool last = false, round = false, sticky = m_mpz_manager.is_odd(z); | ||||
|         bool last = m_mpz_manager.is_odd(z), round = false, sticky = false; | ||||
|         for (; e != 0; e++) { | ||||
|             m_mpz_manager.machine_div2k(z, 1); | ||||
|             sticky |= round; | ||||
|  | @ -1204,7 +1204,7 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o | |||
|         bool inc = false; | ||||
|         switch (rm) { | ||||
|         case MPF_ROUND_NEAREST_TEVEN: inc = round && (last || sticky); break; | ||||
|         case MPF_ROUND_NEAREST_TAWAY: inc = round && (!last || sticky); break; // CMW: Check!
 | ||||
|         case MPF_ROUND_NEAREST_TAWAY: inc = round; break; | ||||
|         case MPF_ROUND_TOWARD_POSITIVE: inc = (!x.sign && (round || sticky)); break; | ||||
|         case MPF_ROUND_TOWARD_NEGATIVE: inc = (x.sign && (round || sticky)); break; | ||||
|         case MPF_ROUND_TOWARD_ZERO: inc = false; break; | ||||
|  | @ -1711,8 +1711,8 @@ void mpf_manager::to_rational(mpf const & x, unsynch_mpq_manager & qm, mpq & o) | |||
| 
 | ||||
| double mpf_manager::to_double(mpf const & x) { | ||||
|     SASSERT(x.ebits <= 11 && x.sbits <= 53); | ||||
|     uint64 raw = 0; | ||||
|     int64 sig = 0, exp = 0; | ||||
|     uint64_t raw = 0; | ||||
|     int64_t sig = 0, exp = 0; | ||||
| 
 | ||||
|     sig = m_mpz_manager.get_uint64(x.significand); | ||||
|     sig <<= 53 - x.sbits; | ||||
|  | @ -1741,7 +1741,7 @@ float mpf_manager::to_float(mpf const & x) { | |||
|     unsigned int raw = 0; | ||||
|     unsigned int sig = 0, exp = 0; | ||||
| 
 | ||||
|     uint64 q = m_mpz_manager.get_uint64(x.significand); | ||||
|     uint64_t q = m_mpz_manager.get_uint64(x.significand); | ||||
|     SASSERT(q < 4294967296ull); | ||||
|     sig = q & 0x00000000FFFFFFFF; | ||||
|     sig <<= 24 - x.sbits; | ||||
|  | @ -1751,7 +1751,7 @@ float mpf_manager::to_float(mpf const & x) { | |||
|     else if (has_bot_exp(x)) | ||||
|         exp = -127; | ||||
|     else { | ||||
|         int64 q = x.exponent; | ||||
|         int64_t q = x.exponent; | ||||
|         SASSERT(q < 4294967296ll); | ||||
|         exp = q & 0x00000000FFFFFFFF; | ||||
|     } | ||||
|  |  | |||
|  | @ -35,7 +35,7 @@ typedef enum { | |||
|     MPF_ROUND_TOWARD_ZERO | ||||
| } mpf_rounding_mode; | ||||
| 
 | ||||
| typedef int64 mpf_exp_t; | ||||
| typedef int64_t mpf_exp_t; | ||||
| 
 | ||||
| class mpf { | ||||
|     friend class mpf_manager; | ||||
|  | @ -80,7 +80,7 @@ public: | |||
|     void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpq const & value); | ||||
|     void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, char const * value); | ||||
|     void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpz const & exponent, mpq const & significand); | ||||
|     void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64 significand); | ||||
|     void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64_t significand); | ||||
|     void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, mpz const & significand); | ||||
|     void set(mpf & o, mpf const & x); | ||||
|     void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpf const & x); | ||||
|  |  | |||
|  | @ -155,27 +155,27 @@ bool mpff_manager::is_uint64(mpff const & n) const { | |||
|         !has_one_at_first_k_bits(m_precision, sig(n), -n.m_exponent);                        | ||||
| } | ||||
| 
 | ||||
| uint64 mpff_manager::get_uint64(mpff const & a) const { | ||||
| uint64_t mpff_manager::get_uint64(mpff const & a) const { | ||||
|     SASSERT(is_uint64(a)); | ||||
|     if (is_zero(a)) return 0; | ||||
|     int exp = -a.m_exponent - sizeof(unsigned) * 8 * (m_precision - 2); | ||||
|     SASSERT(exp >= 0); | ||||
|     uint64 * s = reinterpret_cast<uint64*>(sig(a) + (m_precision - 2)); | ||||
|     uint64_t * s = reinterpret_cast<uint64_t*>(sig(a) + (m_precision - 2)); | ||||
|     return *s >> exp; | ||||
| } | ||||
| 
 | ||||
| int64 mpff_manager::get_int64(mpff const & a) const { | ||||
| int64_t mpff_manager::get_int64(mpff const & a) const { | ||||
|     SASSERT(is_int64(a)); | ||||
|     if (is_zero(a)) return 0; | ||||
|     int exp = -a.m_exponent - sizeof(unsigned) * 8 * (m_precision - 2); | ||||
|     SASSERT(exp >= 0); | ||||
|     uint64 * s = reinterpret_cast<uint64*>(sig(a) + (m_precision - 2)); | ||||
|     uint64_t * s = reinterpret_cast<uint64_t*>(sig(a) + (m_precision - 2)); | ||||
|     // INT64_MIN case
 | ||||
|     if (exp == 0 && *s == 0x8000000000000000ull && is_neg(a)) { | ||||
|         return INT64_MIN; | ||||
|     } | ||||
|     else { | ||||
|         int64 r = *s >> exp; | ||||
|         int64_t r = *s >> exp; | ||||
|         if (is_neg(a)) | ||||
|             r = -r; | ||||
|         return r; | ||||
|  | @ -249,26 +249,26 @@ void mpff_manager::set(mpff & n, unsigned v) { | |||
|     SASSERT(check(n)); | ||||
| } | ||||
| 
 | ||||
| void mpff_manager::set(mpff & n, int64 v) { | ||||
| void mpff_manager::set(mpff & n, int64_t v) { | ||||
|     if (v == 0) { | ||||
|         reset(n); | ||||
|     } | ||||
|     else { | ||||
|         if (v < 0) { | ||||
|             set(n, 1 + static_cast<uint64>(-(1+v))); | ||||
|             set(n, 1 + static_cast<uint64_t>(-(1+v))); | ||||
|             n.m_sign = 1; | ||||
|         } | ||||
|         else { | ||||
|             set(n, static_cast<uint64>(v)); | ||||
|             set(n, static_cast<uint64_t>(v)); | ||||
|         } | ||||
|     } | ||||
|     SASSERT(check(n)); | ||||
|     SASSERT(get_int64(n) == v); | ||||
| } | ||||
| 
 | ||||
| void mpff_manager::set(mpff & n, uint64 v) { | ||||
| void mpff_manager::set(mpff & n, uint64_t v) { | ||||
| #ifdef Z3DEBUG | ||||
|     uint64 old_v = v; | ||||
|     uint64_t old_v = v; | ||||
| #endif | ||||
|     if (v == 0) { | ||||
|         reset(n); | ||||
|  | @ -278,7 +278,7 @@ void mpff_manager::set(mpff & n, uint64 v) { | |||
|         n.m_sign              = 0; | ||||
|         unsigned * _v         = reinterpret_cast<unsigned*>(&v); | ||||
|         int num_leading_zeros = nlz(2, _v); | ||||
|         n.m_exponent          = static_cast<int>(8 * sizeof(uint64)) - num_leading_zeros - static_cast<int>(m_precision_bits); | ||||
|         n.m_exponent          = static_cast<int>(8 * sizeof(uint64_t)) - num_leading_zeros - static_cast<int>(m_precision_bits); | ||||
|         v <<= num_leading_zeros; | ||||
|         SASSERT(m_precision >= 2); | ||||
|         unsigned * s          = sig(n); | ||||
|  | @ -299,7 +299,7 @@ void mpff_manager::set(mpff & n, int num, unsigned den) { | |||
|     SASSERT(check(n)); | ||||
| } | ||||
| 
 | ||||
| void mpff_manager::set(mpff & n, int64 num, uint64 den) { | ||||
| void mpff_manager::set(mpff & n, int64_t num, uint64_t den) { | ||||
|     scoped_mpff a(*this), b(*this); | ||||
|     set(a, num); | ||||
|     set(b, den); | ||||
|  | @ -470,7 +470,7 @@ bool mpff_manager::lt(mpff const & a, mpff const & b) const { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void mpff_manager::inc_significand(unsigned * s, int64 & exp) { | ||||
| void mpff_manager::inc_significand(unsigned * s, int64_t & exp) { | ||||
|     if (!::inc(m_precision, s)) { | ||||
|         SASSERT(::is_zero(m_precision, s)); | ||||
|         s[m_precision - 1] = MIN_MSW; | ||||
|  | @ -597,7 +597,7 @@ void mpff_manager::prev(mpff & a) { | |||
|     SASSERT(check(a)); | ||||
| } | ||||
| 
 | ||||
| void mpff_manager::set_big_exponent(mpff & a, int64 e) { | ||||
| void mpff_manager::set_big_exponent(mpff & a, int64_t e) { | ||||
|     SASSERT(e > INT_MAX || e < INT_MIN); | ||||
|     if (e > INT_MAX) { | ||||
|         if (a.m_sign == 1) { | ||||
|  | @ -715,7 +715,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c | |||
|         else if (num_leading_zeros == sizeof(unsigned) * 8 - 1) { | ||||
|             // shift 1 right
 | ||||
|             bool _inc_significand = ((c.m_sign == 1) != m_to_plus_inf) && has_one_at_first_k_bits(m_precision*2, sig_r, 1); | ||||
|             int64 exp_c = exp_a; | ||||
|             int64_t exp_c = exp_a; | ||||
|             exp_c++; | ||||
|             shr(m_precision + 1, sig_r, 1, m_precision, sig_c); | ||||
|             if (_inc_significand) | ||||
|  | @ -728,7 +728,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c | |||
|             // Now, we can assume sig_r has size m_precision 
 | ||||
|             SASSERT(num_leading_zeros > 0); | ||||
|             // shift left num_leading_zeros
 | ||||
|             int64 exp_c = exp_a; | ||||
|             int64_t exp_c = exp_a; | ||||
|             exp_c -= num_leading_zeros; | ||||
|             shl(m_precision, sig_r, num_leading_zeros, m_precision, sig_c); | ||||
|             set_exponent(c, exp_c); | ||||
|  | @ -752,7 +752,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c | |||
|             reset(c); | ||||
|         } | ||||
|         else if (num_leading_zeros > 0) { | ||||
|             int64 exp_c = exp_a; | ||||
|             int64_t exp_c = exp_a; | ||||
|             exp_c -= num_leading_zeros; | ||||
|             shl(m_precision, sig_c, num_leading_zeros, m_precision, sig_c); | ||||
|             set_exponent(c, exp_c); | ||||
|  | @ -787,10 +787,10 @@ void mpff_manager::mul(mpff const & a, mpff const & b, mpff & c) { | |||
|         allocate_if_needed(c); | ||||
|         TRACE("mpff", tout << "mul("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";); | ||||
|         c.m_sign    = a.m_sign ^ b.m_sign; | ||||
|         // use int64 to make sure we do not have overflows
 | ||||
|         int64 exp_a = a.m_exponent; | ||||
|         int64 exp_b = b.m_exponent; | ||||
|         int64 exp_c = exp_a + exp_b; | ||||
|         // use int64_t to make sure we do not have overflows
 | ||||
|         int64_t exp_a = a.m_exponent; | ||||
|         int64_t exp_b = b.m_exponent; | ||||
|         int64_t exp_c = exp_a + exp_b; | ||||
|         // store result in m_buffers[0]
 | ||||
|         unsigned * r = m_buffers[0].c_ptr(); | ||||
|         m_mpn_manager.mul(sig(a), m_precision, sig(b), m_precision, r); | ||||
|  | @ -834,7 +834,7 @@ void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) { | |||
| #if 1 | ||||
|     else if (is_two(b)) { | ||||
|         set(c, a); | ||||
|         int64 exp_c = a.m_exponent; | ||||
|         int64_t exp_c = a.m_exponent; | ||||
|         exp_c--; | ||||
|         set_exponent(c, exp_c); | ||||
|     } | ||||
|  | @ -842,10 +842,10 @@ void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) { | |||
|     else { | ||||
|         allocate_if_needed(c); | ||||
|         c.m_sign    = a.m_sign ^ b.m_sign; | ||||
|         // use int64 to make sure we do not have overflows
 | ||||
|         int64 exp_a = a.m_exponent; | ||||
|         int64 exp_b = b.m_exponent; | ||||
|         int64 exp_c = exp_a - exp_b; | ||||
|         // use int64_t to make sure we do not have overflows
 | ||||
|         int64_t exp_a = a.m_exponent; | ||||
|         int64_t exp_b = b.m_exponent; | ||||
|         int64_t exp_c = exp_a - exp_b; | ||||
|          | ||||
|         exp_c      -= m_precision_bits; // we will multiplying (shifting) a by 2^m_precision_bits.
 | ||||
|         // copy a to buffer 0, and shift by m_precision_bits
 | ||||
|  | @ -1023,7 +1023,7 @@ void mpff_manager::power(mpff const & a, unsigned p, mpff & b) { | |||
|                 b.m_sign = 0; | ||||
|             else | ||||
|                 b.m_sign = a.m_sign; | ||||
|             int64 exp = a.m_exponent; | ||||
|             int64_t exp = a.m_exponent; | ||||
|             exp *= p; | ||||
|             if (exp > INT_MAX || exp < INT_MIN) | ||||
|                 throw overflow_exception(); | ||||
|  | @ -1057,7 +1057,7 @@ void mpff_manager::power(mpff const & a, unsigned p, mpff & b) { | |||
| bool mpff_manager::is_power_of_two(mpff const & a, unsigned & k) const { | ||||
|     if (!is_power_of_two(a)) | ||||
|         return false; | ||||
|     int64 exp = a.m_exponent + m_precision_bits - 1; | ||||
|     int64_t exp = a.m_exponent + m_precision_bits - 1; | ||||
|     SASSERT(exp >= 0); | ||||
|     k = static_cast<unsigned>(exp); | ||||
|     return true; | ||||
|  | @ -1132,7 +1132,7 @@ void mpff_manager::to_mpq_core(mpff const & n, mpq_manager<SYNCH> & m, mpq & t) | |||
|             if (exp < 0) { | ||||
|                 // Avoid -INT_MIN == INT_MIN issue. It is not really useful, since we will run out of memory anyway.
 | ||||
|                 if (exp == INT_MIN) | ||||
|                     abs_exp = static_cast<unsigned>(-static_cast<int64>(INT_MIN)); | ||||
|                     abs_exp = static_cast<unsigned>(-static_cast<int64_t>(INT_MIN)); | ||||
|                 else | ||||
|                     abs_exp = -exp; | ||||
|             } | ||||
|  | @ -1177,7 +1177,7 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const { | |||
|     svector<unsigned> & u_buffer = const_cast<mpff_manager*>(this)->m_buffers[0]; | ||||
|     int num_trailing_zeros = ntz(m_precision, u_buffer.c_ptr()); | ||||
|     int shift = 0; | ||||
|     int64 exp = n.m_exponent; // use int64 to avoid -INT_MIN == INT_MIN issue
 | ||||
|     int64_t exp = n.m_exponent; // use int64_t to avoid -INT_MIN == INT_MIN issue
 | ||||
|     if (exp < 0) { | ||||
|         if (num_trailing_zeros >= -exp) { | ||||
|             shift = static_cast<int>(-exp); | ||||
|  | @ -1194,7 +1194,7 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const { | |||
|     out << m_mpn_manager.to_string(u_buffer.c_ptr(), m_precision, str_buffer.begin(), str_buffer.size()); | ||||
|     if (exp > 0) { | ||||
|         if (exp <= 63) { | ||||
|             uint64 _exp = 1; | ||||
|             uint64_t _exp = 1; | ||||
|             _exp <<= exp; | ||||
|             out << "*" << _exp; | ||||
|         } | ||||
|  | @ -1209,7 +1209,7 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const { | |||
|     else if (exp < 0) { | ||||
|         exp = -exp; | ||||
|         if (exp <= 63) { | ||||
|             uint64 _exp = 1; | ||||
|             uint64_t _exp = 1; | ||||
|             _exp <<= exp; | ||||
|             out << "/" << _exp; | ||||
|         } | ||||
|  | @ -1225,8 +1225,8 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const { | |||
| 
 | ||||
| void mpff_manager::display_decimal(std::ostream & out, mpff const & n, unsigned prec, unsigned min_exponent) { | ||||
|     // The result in scientific notation when n.m_exponent >= min_exponent or n.m_exponent <= - min_exponent - m_precision_bits
 | ||||
|     int64 exp  = n.m_exponent; | ||||
|     if (exp >= min_exponent || exp <= -static_cast<int64>(min_exponent) - m_precision_bits || is_int(n)) { | ||||
|     int64_t exp  = n.m_exponent; | ||||
|     if (exp >= min_exponent || exp <= -static_cast<int64_t>(min_exponent) - m_precision_bits || is_int(n)) { | ||||
|         display(out, n); | ||||
|         return; | ||||
|     } | ||||
|  | @ -1327,7 +1327,7 @@ void mpff_manager::display_smt2(std::ostream & out, mpff const & n, bool decimal | |||
|     svector<unsigned> & u_buffer = const_cast<mpff_manager*>(this)->m_buffers[0]; | ||||
|     int num_trailing_zeros = ntz(m_precision, u_buffer.c_ptr()); | ||||
|     int shift = 0; | ||||
|     int64 exp = n.m_exponent; | ||||
|     int64_t exp = n.m_exponent; | ||||
|     if (exp < 0) { | ||||
|         if (num_trailing_zeros >= -exp) { | ||||
|             shift = static_cast<int>(-exp); | ||||
|  | @ -1353,7 +1353,7 @@ void mpff_manager::display_smt2(std::ostream & out, mpff const & n, bool decimal | |||
|     if (exp != 0) { | ||||
|         if (exp < 0) exp = -exp; | ||||
|         if (exp <= 63) { | ||||
|             uint64 _exp = 1; | ||||
|             uint64_t _exp = 1; | ||||
|             _exp <<= exp; | ||||
|             out << _exp; | ||||
|             if (decimal) out << ".0"; | ||||
|  | @ -1387,8 +1387,8 @@ unsigned mpff_manager::prev_power_of_two(mpff const & a) { | |||
|         return 0; | ||||
|     if (a.m_exponent <= -static_cast<int>(m_precision_bits)) | ||||
|         return 0; // Number is smaller than 1
 | ||||
|     SASSERT(static_cast<int64>(a.m_exponent) + static_cast<int64>(m_precision_bits) - 1 >= 0); | ||||
|     SASSERT(static_cast<int64>(a.m_exponent) + static_cast<int64>(m_precision_bits) - 1 <= static_cast<int64>(static_cast<uint64>(UINT_MAX))); | ||||
|     SASSERT(static_cast<int64_t>(a.m_exponent) + static_cast<int64_t>(m_precision_bits) - 1 >= 0); | ||||
|     SASSERT(static_cast<int64_t>(a.m_exponent) + static_cast<int64_t>(m_precision_bits) - 1 <= static_cast<int64_t>(static_cast<uint64_t>(UINT_MAX))); | ||||
|     return m_precision_bits + a.m_exponent - 1; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -92,7 +92,7 @@ class mpff_manager { | |||
|     // 
 | ||||
|     // Remarks:
 | ||||
|     //
 | ||||
|     // - All values of type int, unsigned, int64 and uint64 can be precisely represented as mpff numerals.
 | ||||
|     // - All values of type int, unsigned, int64_t and uint64_t can be precisely represented as mpff numerals.
 | ||||
|     //
 | ||||
|     // - Hardware float and double values (corresponding to rationals) can also be precisely represented as mpff numerals.
 | ||||
|     //   That is, NaN, +oo and -oo are not supported by this module.
 | ||||
|  | @ -141,14 +141,14 @@ class mpff_manager { | |||
|     // copy (and shift by m_precision_bits) n to buffer idx 
 | ||||
|     void to_buffer_shifting(unsigned idx, mpff const & n) const; | ||||
| 
 | ||||
|     void inc_significand(unsigned * s, int64 & exp); | ||||
|     void inc_significand(unsigned * s, int64_t & exp); | ||||
|     void inc_significand(mpff & a); | ||||
|     void dec_significand(mpff & a); | ||||
|     bool min_significand(mpff const & a) const; | ||||
|     void set_min_significand(mpff & a); | ||||
|     void set_max_significand(mpff & a); | ||||
|     void set_big_exponent(mpff & a, int64 e); | ||||
|     void set_exponent(mpff & a, int64 e) { | ||||
|     void set_big_exponent(mpff & a, int64_t e); | ||||
|     void set_exponent(mpff & a, int64_t e) { | ||||
|         if (e > INT_MAX || e < INT_MIN)  | ||||
|             set_big_exponent(a, e); | ||||
|         else | ||||
|  | @ -286,12 +286,12 @@ public: | |||
|     bool is_plus_epsilon(mpff const & a) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return true if \c a is an integer and fits in an int64 machine integer. | ||||
|        \brief Return true if \c a is an integer and fits in an int64_t machine integer. | ||||
|     */ | ||||
|     bool is_int64(mpff const & a) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return true if \c a is a non-negative integer and fits in an int64 machine integer. | ||||
|        \brief Return true if \c a is a non-negative integer and fits in an int64_t machine integer. | ||||
|     */ | ||||
|     bool is_uint64(mpff const & a) const; | ||||
|      | ||||
|  | @ -372,10 +372,10 @@ public: | |||
|      | ||||
|     void set(mpff & n, int v); | ||||
|     void set(mpff & n, unsigned v); | ||||
|     void set(mpff & n, int64 v); | ||||
|     void set(mpff & n, uint64 v); | ||||
|     void set(mpff & n, int64_t v); | ||||
|     void set(mpff & n, uint64_t v); | ||||
|     void set(mpff & n, int num, unsigned den); | ||||
|     void set(mpff & n, int64 num, uint64 den); | ||||
|     void set(mpff & n, int64_t num, uint64_t den); | ||||
|     void set(mpff & n, mpff const & v); | ||||
|     void set(mpff & n, unsynch_mpz_manager & m, mpz const & v); | ||||
|     void set(mpff & n, synch_mpz_manager & m, mpz const & v);  | ||||
|  | @ -448,14 +448,14 @@ public: | |||
| 
 | ||||
|        \pre is_int64(n) | ||||
|     */ | ||||
|     int64 get_int64(mpff const & n) const; | ||||
|     int64_t get_int64(mpff const & n) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return n as an uint64. | ||||
| 
 | ||||
|        \pre is_uint64(n) | ||||
|     */ | ||||
|     uint64 get_uint64(mpff const & n) const; | ||||
|     uint64_t get_uint64(mpff const & n) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return the biggest k s.t. 2^k <= a. | ||||
|  |  | |||
|  | @ -164,10 +164,10 @@ void mpfx_manager::set(mpfx & n, unsigned v) { | |||
|     SASSERT(check(n)); | ||||
| } | ||||
| 
 | ||||
| void mpfx_manager::set(mpfx & n, int64 v) { | ||||
| void mpfx_manager::set(mpfx & n, int64_t v) { | ||||
|     if (m_int_part_sz == 1) { | ||||
|         if (v < -static_cast<int64>(static_cast<uint64>(UINT_MAX)) ||  | ||||
|             v > static_cast<int64>(static_cast<uint64>(UINT_MAX))) | ||||
|         if (v < -static_cast<int64_t>(static_cast<uint64_t>(UINT_MAX)) || | ||||
|             v > static_cast<int64_t>(static_cast<uint64_t>(UINT_MAX))) | ||||
|             throw overflow_exception(); | ||||
|     } | ||||
|     if (v == 0) { | ||||
|  | @ -175,11 +175,11 @@ void mpfx_manager::set(mpfx & n, int64 v) { | |||
|     } | ||||
|     else { | ||||
|         if (v < 0) { | ||||
|             set(n, static_cast<uint64>(-v)); | ||||
|             set(n, static_cast<uint64_t>(-v)); | ||||
|             n.m_sign = 1; | ||||
|         } | ||||
|         else { | ||||
|             set(n, static_cast<uint64>(v)); | ||||
|             set(n, static_cast<uint64_t>(v)); | ||||
|         } | ||||
|     } | ||||
|     SASSERT(is_int(n)); | ||||
|  | @ -187,9 +187,9 @@ void mpfx_manager::set(mpfx & n, int64 v) { | |||
|     SASSERT(check(n)); | ||||
| } | ||||
| 
 | ||||
| void mpfx_manager::set(mpfx & n, uint64 v) { | ||||
| void mpfx_manager::set(mpfx & n, uint64_t v) { | ||||
|     if (m_int_part_sz == 1) { | ||||
|         if (v > static_cast<uint64>(UINT_MAX)) | ||||
|         if (v > static_cast<uint64_t>(UINT_MAX)) | ||||
|             throw overflow_exception(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -200,7 +200,7 @@ void mpfx_manager::set(mpfx & n, uint64 v) { | |||
|         allocate_if_needed(n); | ||||
|         n.m_sign              = 0; | ||||
|         unsigned * w          = words(n); | ||||
|         uint64 * _vp          = &v; | ||||
|         uint64_t * _vp        = &v; | ||||
|         unsigned * _v         = nullptr; | ||||
|         memcpy(&_v, &_vp, sizeof(unsigned*)); | ||||
|         for (unsigned i = 0; i < m_total_sz; i++)  | ||||
|  | @ -226,7 +226,7 @@ void mpfx_manager::set(mpfx & n, int num, unsigned den) { | |||
|     SASSERT(check(n)); | ||||
| } | ||||
| 
 | ||||
| void mpfx_manager::set(mpfx & n, int64 num, uint64 den) { | ||||
| void mpfx_manager::set(mpfx & n, int64_t num, uint64_t den) { | ||||
|     scoped_mpfx a(*this), b(*this); | ||||
|     set(a, num); | ||||
|     set(b, den); | ||||
|  | @ -677,27 +677,27 @@ bool mpfx_manager::is_power_of_two(mpfx const & a) const { | |||
|     return is_power_of_two(a, k); | ||||
| } | ||||
| 
 | ||||
| int64 mpfx_manager::get_int64(mpfx const & n) const { | ||||
| int64_t mpfx_manager::get_int64(mpfx const & n) const { | ||||
|     SASSERT(is_int64(n)); | ||||
|     unsigned * w = words(n); | ||||
|     w += m_frac_part_sz; | ||||
|     uint64 r = 0; | ||||
|     memcpy(&r, w, sizeof(uint64)); | ||||
|     uint64_t r = 0; | ||||
|     memcpy(&r, w, sizeof(uint64_t)); | ||||
|     if (r == 0x8000000000000000ull) { | ||||
|         SASSERT(is_neg(n)); | ||||
|         return INT64_MIN; | ||||
|     } | ||||
|     else { | ||||
|         return is_neg(n) ? -static_cast<int64>(r) : r; | ||||
|         return is_neg(n) ? -static_cast<int64_t>(r) : r; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| uint64 mpfx_manager::get_uint64(mpfx const & n) const { | ||||
| uint64_t mpfx_manager::get_uint64(mpfx const & n) const { | ||||
|     SASSERT(is_uint64(n)); | ||||
|     unsigned * w = words(n); | ||||
|     w += m_frac_part_sz; | ||||
|     uint64 r = 0; | ||||
|     memcpy(&r, w, sizeof(uint64)); | ||||
|     uint64_t r = 0; | ||||
|     memcpy(&r, w, sizeof(uint64_t)); | ||||
|     return r; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -200,12 +200,12 @@ public: | |||
|     bool is_minus_one(mpfx const & n) const { return is_neg(n) && is_abs_one(n); } | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return true if \c a is an integer and fits in an int64 machine integer. | ||||
|        \brief Return true if \c a is an integer and fits in an \c int64_t machine integer. | ||||
|     */ | ||||
|     bool is_int64(mpfx const & a) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return true if \c a is a non-negative integer and fits in an int64 machine integer. | ||||
|        \brief Return true if \c a is a non-negative integer and fits in an \c int64_t machine integer. | ||||
|     */ | ||||
|     bool is_uint64(mpfx const & a) const; | ||||
|      | ||||
|  | @ -306,10 +306,10 @@ public: | |||
| 
 | ||||
|     void set(mpfx & n, int v); | ||||
|     void set(mpfx & n, unsigned v); | ||||
|     void set(mpfx & n, int64 v); | ||||
|     void set(mpfx & n, uint64 v); | ||||
|     void set(mpfx & n, int64_t v); | ||||
|     void set(mpfx & n, uint64_t v); | ||||
|     void set(mpfx & n, int num, unsigned den); | ||||
|     void set(mpfx & n, int64 num, uint64 den); | ||||
|     void set(mpfx & n, int64_t num, uint64_t den); | ||||
|     void set(mpfx & n, mpfx const & v); | ||||
|     void set(mpfx & n, unsynch_mpz_manager & m, mpz const & v); | ||||
|     void set(mpfx & n, synch_mpz_manager & m, mpz const & v);  | ||||
|  | @ -343,14 +343,14 @@ public: | |||
| 
 | ||||
|        \pre is_int64(n) | ||||
|     */ | ||||
|     int64 get_int64(mpfx const & n) const; | ||||
|     int64_t get_int64(mpfx const & n) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Return n as an uint64. | ||||
| 
 | ||||
|        \pre is_uint64(n) | ||||
|     */ | ||||
|     uint64 get_uint64(mpfx const & n) const; | ||||
|     uint64_t get_uint64(mpfx const & n) const; | ||||
| 
 | ||||
|     /**
 | ||||
|        \brief Convert n into a mpz numeral. | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ Revision History: | |||
| 
 | ||||
| #define max(a,b)    (((a) > (b)) ? (a) : (b)) | ||||
| 
 | ||||
| typedef uint64 mpn_double_digit; | ||||
| typedef uint64_t mpn_double_digit; | ||||
| static_assert(sizeof(mpn_double_digit) == 2 * sizeof(mpn_digit), "size alignment"); | ||||
| 
 | ||||
| const mpn_digit mpn_manager::zero = 0; | ||||
|  |  | |||
|  | @ -686,7 +686,7 @@ public: | |||
|         normalize(a); | ||||
|     } | ||||
| 
 | ||||
|     void set(mpq & a, int64 n, uint64 d) { | ||||
|     void set(mpq & a, int64_t n, uint64_t d) { | ||||
|         SASSERT(d != 0); | ||||
|         set(a.m_num, n); | ||||
|         set(a.m_den, d); | ||||
|  | @ -718,16 +718,16 @@ public: | |||
| 
 | ||||
|     void set(mpq & a, char const * val); | ||||
| 
 | ||||
|     void set(mpz & a, int64 val) { mpz_manager<SYNCH>::set(a, val); } | ||||
|     void set(mpz & a, int64_t val) { mpz_manager<SYNCH>::set(a, val); } | ||||
| 
 | ||||
|     void set(mpq & a, int64 val) { | ||||
|     void set(mpq & a, int64_t val) { | ||||
|         set(a.m_num, val); | ||||
|         reset_denominator(a); | ||||
|     } | ||||
| 
 | ||||
|     void set(mpz & a, uint64 val) { mpz_manager<SYNCH>::set(a, val); } | ||||
|     void set(mpz & a, uint64_t val) { mpz_manager<SYNCH>::set(a, val); } | ||||
|      | ||||
|     void set(mpq & a, uint64 val) {  | ||||
|     void set(mpq & a, uint64_t val) { | ||||
|         set(a.m_num, val); | ||||
|         reset_denominator(a); | ||||
|     } | ||||
|  | @ -765,17 +765,17 @@ public: | |||
| 
 | ||||
|     bool is_int64(mpz const & a) const { return mpz_manager<SYNCH>::is_int64(a); } | ||||
| 
 | ||||
|     uint64 get_uint64(mpz const & a) const { return mpz_manager<SYNCH>::get_uint64(a); } | ||||
|     uint64_t get_uint64(mpz const & a) const { return mpz_manager<SYNCH>::get_uint64(a); } | ||||
| 
 | ||||
|     int64 get_int64(mpz const & a) const { return mpz_manager<SYNCH>::get_int64(a); } | ||||
|     int64_t get_int64(mpz const & a) const { return mpz_manager<SYNCH>::get_int64(a); } | ||||
| 
 | ||||
|     bool is_uint64(mpq const & a) const { return is_int(a) && is_uint64(a.m_num); } | ||||
| 
 | ||||
|     bool is_int64(mpq const & a) const { return is_int(a) && is_int64(a.m_num); } | ||||
| 
 | ||||
|     uint64 get_uint64(mpq const & a) const { SASSERT(is_uint64(a)); return get_uint64(a.m_num); } | ||||
|     uint64_t get_uint64(mpq const & a) const { SASSERT(is_uint64(a)); return get_uint64(a.m_num); } | ||||
| 
 | ||||
|     int64 get_int64(mpq const & a) const { SASSERT(is_int64(a)); return get_int64(a.m_num); } | ||||
|     int64_t get_int64(mpq const & a) const { SASSERT(is_int64(a)); return get_int64(a.m_num); } | ||||
| 
 | ||||
|     double get_double(mpz const & a) const { return mpz_manager<SYNCH>::get_double(a); } | ||||
| 
 | ||||
|  |  | |||
|  | @ -81,7 +81,7 @@ static T gcd_core(T u, T v) { | |||
| } | ||||
| 
 | ||||
| unsigned u_gcd(unsigned u, unsigned v) { return gcd_core(u, v); } | ||||
| uint64 u64_gcd(uint64 u, uint64 v) { return gcd_core(u, v); } | ||||
| uint64_t u64_gcd(uint64_t u, uint64_t v) { return gcd_core(u, v); } | ||||
| 
 | ||||
| template<bool SYNCH> | ||||
| mpz_manager<SYNCH>::mpz_manager(): | ||||
|  | @ -89,7 +89,7 @@ mpz_manager<SYNCH>::mpz_manager(): | |||
|     if (SYNCH) | ||||
|         omp_init_nest_lock(&m_lock); | ||||
| #ifndef _MP_GMP | ||||
|     if (sizeof(digit_t) == sizeof(uint64)) { | ||||
|     if (sizeof(digit_t) == sizeof(uint64_t)) { | ||||
|         // 64-bit machine
 | ||||
|         m_init_cell_capacity = 4; | ||||
|     } | ||||
|  | @ -101,7 +101,7 @@ mpz_manager<SYNCH>::mpz_manager(): | |||
|         m_arg[i] = allocate(m_init_cell_capacity); | ||||
|         m_arg[i]->m_size = 1; | ||||
|     } | ||||
|     set(m_int_min, -static_cast<int64>(INT_MIN)); | ||||
|     set(m_int_min, -static_cast<int64_t>(INT_MIN)); | ||||
| #else | ||||
|     // GMP
 | ||||
|     mpz_init(m_tmp); | ||||
|  | @ -122,8 +122,8 @@ mpz_manager<SYNCH>::mpz_manager(): | |||
|     mpz_init(m_int64_max); | ||||
|     mpz_init(m_int64_min); | ||||
| 
 | ||||
|     max_l = static_cast<unsigned>(INT64_MAX % static_cast<int64>(UINT_MAX)); | ||||
|     max_h = static_cast<unsigned>(INT64_MAX / static_cast<int64>(UINT_MAX)); | ||||
|     max_l = static_cast<unsigned>(INT64_MAX % static_cast<int64_t>(UINT_MAX)); | ||||
|     max_h = static_cast<unsigned>(INT64_MAX / static_cast<int64_t>(UINT_MAX)); | ||||
|     mpz_set_ui(m_int64_max, max_h); | ||||
|     mpz_set_ui(m_tmp, UINT_MAX); | ||||
|     mpz_mul(m_int64_max, m_tmp, m_int64_max); | ||||
|  | @ -134,7 +134,7 @@ mpz_manager<SYNCH>::mpz_manager(): | |||
| #endif | ||||
|      | ||||
|     mpz one(1); | ||||
|     set(m_two64, (uint64)UINT64_MAX); | ||||
|     set(m_two64, (uint64_t)UINT64_MAX); | ||||
|     add(m_two64, one, m_two64); | ||||
| } | ||||
| 
 | ||||
|  | @ -162,13 +162,13 @@ mpz_manager<SYNCH>::~mpz_manager() { | |||
| } | ||||
| 
 | ||||
| template<bool SYNCH> | ||||
| void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) { | ||||
| void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64_t v) { | ||||
| #ifndef _MP_GMP | ||||
|     if (is_small(c)) { | ||||
|         c.m_ptr = allocate(m_init_cell_capacity); | ||||
|     } | ||||
|     SASSERT(capacity(c) >= m_init_cell_capacity); | ||||
|     uint64 _v; | ||||
|     uint64_t _v; | ||||
|     if (v < 0) { | ||||
|         _v = -v; | ||||
|         c.m_val = -1; | ||||
|  | @ -177,7 +177,7 @@ void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) { | |||
|         _v = v; | ||||
|         c.m_val = 1; | ||||
|     } | ||||
|     if (sizeof(digit_t) == sizeof(uint64)) { | ||||
|     if (sizeof(digit_t) == sizeof(uint64_t)) { | ||||
|         // 64-bit machine
 | ||||
|         digits(c)[0] = static_cast<digit_t>(_v); | ||||
|         c.m_ptr->m_size = 1; | ||||
|  | @ -192,7 +192,7 @@ void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) { | |||
|     if (is_small(c)) { | ||||
|         c.m_ptr = allocate(); | ||||
|     } | ||||
|     uint64 _v; | ||||
|     uint64_t _v; | ||||
|     bool sign; | ||||
|     if (v < 0) { | ||||
|         _v   = -v; | ||||
|  | @ -212,14 +212,14 @@ void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) { | |||
| } | ||||
| 
 | ||||
| template<bool SYNCH> | ||||
| void mpz_manager<SYNCH>::set_big_ui64(mpz & c, uint64 v) { | ||||
| void mpz_manager<SYNCH>::set_big_ui64(mpz & c, uint64_t v) { | ||||
| #ifndef _MP_GMP | ||||
|     if (is_small(c)) { | ||||
|         c.m_ptr = allocate(m_init_cell_capacity); | ||||
|     } | ||||
|     SASSERT(capacity(c) >= m_init_cell_capacity); | ||||
|     c.m_val = 1; | ||||
|     if (sizeof(digit_t) == sizeof(uint64)) { | ||||
|     if (sizeof(digit_t) == sizeof(uint64_t)) { | ||||
|         // 64-bit machine
 | ||||
|         digits(c)[0] = static_cast<digit_t>(v); | ||||
|         c.m_ptr->m_size = 1; | ||||
|  | @ -726,7 +726,7 @@ void mpz_manager<SYNCH>::gcd(mpz const & a, mpz const & b, mpz & c) { | |||
|         // For now, it only works if sizeof(digit_t) == sizeof(unsigned)
 | ||||
|         static_assert(sizeof(digit_t) == sizeof(unsigned), ""); | ||||
|          | ||||
|         int64 a_hat, b_hat, A, B, C, D, T, q, a_sz, b_sz; | ||||
|         int64_t a_hat, b_hat, A, B, C, D, T, q, a_sz, b_sz; | ||||
|         mpz a1, b1, t, r, tmp; | ||||
|         set(a1, a); | ||||
|         set(b1, b); | ||||
|  | @ -766,10 +766,10 @@ void mpz_manager<SYNCH>::gcd(mpz const & a, mpz const & b, mpz & c) { | |||
|             D = 1; | ||||
|             while (true) { | ||||
|                 // Loop invariants
 | ||||
|                 SASSERT(a_hat + A <= static_cast<int64>(UINT_MAX) + 1); | ||||
|                 SASSERT(a_hat + B <  static_cast<int64>(UINT_MAX) + 1); | ||||
|                 SASSERT(b_hat + C <  static_cast<int64>(UINT_MAX) + 1); | ||||
|                 SASSERT(b_hat + D <= static_cast<int64>(UINT_MAX) + 1); | ||||
|                 SASSERT(a_hat + A <= static_cast<int64_t>(UINT_MAX) + 1); | ||||
|                 SASSERT(a_hat + B <  static_cast<int64_t>(UINT_MAX) + 1); | ||||
|                 SASSERT(b_hat + C <  static_cast<int64_t>(UINT_MAX) + 1); | ||||
|                 SASSERT(b_hat + D <= static_cast<int64_t>(UINT_MAX) + 1); | ||||
|                 // overflows can't happen since I'm using int64
 | ||||
|                 if (b_hat + C == 0 || b_hat + D == 0) | ||||
|                     break; | ||||
|  | @ -1035,7 +1035,7 @@ void mpz_manager<SYNCH>::bitwise_or(mpz const & a, mpz const & b, mpz & c) { | |||
|             mod(a1, m_two64, a2); | ||||
|             mod(b1, m_two64, b2); | ||||
|             TRACE("mpz", tout << "a2: " << to_string(a2) << ", b2: " << to_string(b2) << "\n";); | ||||
|             uint64 v = get_uint64(a2) | get_uint64(b2); | ||||
|             uint64_t v = get_uint64(a2) | get_uint64(b2); | ||||
|             TRACE("mpz", tout << "uint(a2): " << get_uint64(a2) << ", uint(b2): " << get_uint64(b2) << "\n";); | ||||
|             set(tmp, v); | ||||
|             mul(tmp, m, tmp); | ||||
|  | @ -1082,7 +1082,7 @@ void mpz_manager<SYNCH>::bitwise_and(mpz const & a, mpz const & b, mpz & c) { | |||
|         while (!is_zero(a1) && !is_zero(b1)) { | ||||
|             mod(a1, m_two64, a2); | ||||
|             mod(b1, m_two64, b2); | ||||
|             uint64 v = get_uint64(a2) & get_uint64(b2); | ||||
|             uint64_t v = get_uint64(a2) & get_uint64(b2); | ||||
|             set(tmp, v); | ||||
|             mul(tmp, m, tmp); | ||||
|             add(c, tmp, c); // c += m * v
 | ||||
|  | @ -1119,7 +1119,7 @@ void mpz_manager<SYNCH>::bitwise_xor(mpz const & a, mpz const & b, mpz & c) { | |||
|         while (!is_zero(a1) && !is_zero(b1)) { | ||||
|             mod(a1, m_two64, a2); | ||||
|             mod(b1, m_two64, b2); | ||||
|             uint64 v = get_uint64(a2) ^ get_uint64(b2); | ||||
|             uint64_t v = get_uint64(a2) ^ get_uint64(b2); | ||||
|             set(tmp, v); | ||||
|             mul(tmp, m, tmp); | ||||
|             add(c, tmp, c); // c += m * v
 | ||||
|  | @ -1151,7 +1151,7 @@ template<bool SYNCH> | |||
| void mpz_manager<SYNCH>::bitwise_not(unsigned sz, mpz const & a, mpz & c) { | ||||
|     SASSERT(is_nonneg(a)); | ||||
|     if (is_small(a) && sz <= 63) { | ||||
|         int64 mask = (static_cast<int64>(1) << sz) - static_cast<int64>(1); | ||||
|         int64_t mask = (static_cast<int64_t>(1) << sz) - static_cast<int64_t>(1); | ||||
|         set_i64(c, (~ i64(a)) & mask); | ||||
|     } | ||||
|     else { | ||||
|  | @ -1161,11 +1161,11 @@ void mpz_manager<SYNCH>::bitwise_not(unsigned sz, mpz const & a, mpz & c) { | |||
|         set(c, 0); | ||||
|         while (sz > 0) { | ||||
|             mod(a1, m_two64, a2); | ||||
|             uint64 n = get_uint64(a2); | ||||
|             uint64 v = ~n; | ||||
|             uint64_t n = get_uint64(a2); | ||||
|             uint64_t v = ~n; | ||||
|             SASSERT(~v == n); | ||||
|             if (sz < 64) { | ||||
|                 uint64 mask = (1ull << static_cast<uint64>(sz)) - 1ull; | ||||
|                 uint64_t mask = (1ull << static_cast<uint64_t>(sz)) - 1ull; | ||||
|                 v = mask & v; | ||||
|             } | ||||
|             TRACE("bitwise_not", tout << "sz: " << sz << ", v: " << v << ", n: " << n << "\n";); | ||||
|  | @ -1265,7 +1265,7 @@ bool mpz_manager<SYNCH>::is_uint64(mpz const & a) const { | |||
|         return false; | ||||
|     if (is_small(a)) | ||||
|         return true; | ||||
|     if (sizeof(digit_t) == sizeof(uint64)) { | ||||
|     if (sizeof(digit_t) == sizeof(uint64_t)) { | ||||
|         return size(a) <= 1; | ||||
|     } | ||||
|     else { | ||||
|  | @ -1286,9 +1286,9 @@ bool mpz_manager<SYNCH>::is_int64(mpz const & a) const { | |||
| #ifndef _MP_GMP | ||||
|     if (!is_abs_uint64(a))  | ||||
|         return false; | ||||
|     uint64 num = big_abs_to_uint64(a); | ||||
|     uint64 msb = static_cast<uint64>(1) << 63; | ||||
|     uint64 msb_val = msb & num; | ||||
|     uint64_t num = big_abs_to_uint64(a); | ||||
|     uint64_t msb = static_cast<uint64_t>(1) << 63; | ||||
|     uint64_t msb_val = msb & num; | ||||
|     if (a.m_val >= 0) { | ||||
|         // non-negative number.
 | ||||
|         return (0 == msb_val); | ||||
|  | @ -1307,54 +1307,54 @@ bool mpz_manager<SYNCH>::is_int64(mpz const & a) const { | |||
| } | ||||
| 
 | ||||
| template<bool SYNCH> | ||||
| uint64 mpz_manager<SYNCH>::get_uint64(mpz const & a) const { | ||||
| uint64_t mpz_manager<SYNCH>::get_uint64(mpz const & a) const { | ||||
|     if (is_small(a))  | ||||
|         return static_cast<uint64>(a.m_val); | ||||
|         return static_cast<uint64_t>(a.m_val); | ||||
| #ifndef _MP_GMP | ||||
|     SASSERT(a.m_ptr->m_size > 0); | ||||
|     return big_abs_to_uint64(a); | ||||
| #else | ||||
|     // GMP version
 | ||||
|     if (sizeof(uint64) == sizeof(unsigned long)) { | ||||
|     if (sizeof(uint64_t) == sizeof(unsigned long)) { | ||||
|         return mpz_get_ui(*a.m_ptr); | ||||
|     } | ||||
|     else { | ||||
|         mpz_manager * _this = const_cast<mpz_manager*>(this); | ||||
|         mpz_set(_this->m_tmp, *a.m_ptr); | ||||
|         mpz_mod(_this->m_tmp, m_tmp, m_two32); | ||||
|         uint64 r = static_cast<uint64>(mpz_get_ui(m_tmp)); | ||||
|         uint64_t r = static_cast<uint64_t>(mpz_get_ui(m_tmp)); | ||||
|         mpz_set(_this->m_tmp, *a.m_ptr); | ||||
|         mpz_div(_this->m_tmp, m_tmp, m_two32); | ||||
|         r += static_cast<uint64>(mpz_get_ui(m_tmp)) << static_cast<uint64>(32); | ||||
|         r += static_cast<uint64_t>(mpz_get_ui(m_tmp)) << static_cast<uint64_t>(32); | ||||
|         return r; | ||||
|     } | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| template<bool SYNCH> | ||||
| int64 mpz_manager<SYNCH>::get_int64(mpz const & a) const { | ||||
| int64_t mpz_manager<SYNCH>::get_int64(mpz const & a) const { | ||||
|     if (is_small(a)) | ||||
|         return static_cast<int64>(a.m_val); | ||||
|         return static_cast<int64_t>(a.m_val); | ||||
| #ifndef _MP_GMP | ||||
|     SASSERT(is_int64(a)); | ||||
|     uint64 num = big_abs_to_uint64(a); | ||||
|     uint64_t num = big_abs_to_uint64(a); | ||||
|     if (a.m_val < 0) { | ||||
|         if (num != 0 && (num << 1) == 0) | ||||
|             return INT64_MIN; | ||||
|         return -static_cast<int64>(num); | ||||
|         return -static_cast<int64_t>(num); | ||||
|     } | ||||
|     return static_cast<int64>(num); | ||||
|     return static_cast<int64_t>(num); | ||||
| #else | ||||
|     // GMP
 | ||||
|     if (sizeof(int64) == sizeof(long) || mpz_fits_slong_p(*a.m_ptr)) { | ||||
|     if (sizeof(int64_t) == sizeof(long) || mpz_fits_slong_p(*a.m_ptr)) { | ||||
|         return mpz_get_si(*a.m_ptr); | ||||
|     } | ||||
|     else { | ||||
|         mpz_manager * _this = const_cast<mpz_manager*>(this); | ||||
|         mpz_mod(_this->m_tmp, *a.m_ptr, m_two32); | ||||
|         int64 r = static_cast<int64>(mpz_get_ui(m_tmp)); | ||||
|         int64_t r = static_cast<int64_t>(mpz_get_ui(m_tmp)); | ||||
|         mpz_div(_this->m_tmp, *a.m_ptr, m_two32); | ||||
|         r += static_cast<int64>(mpz_get_si(m_tmp)) << static_cast<int64>(32); | ||||
|         r += static_cast<int64_t>(mpz_get_si(m_tmp)) << static_cast<int64_t>(32); | ||||
|         return r; | ||||
|     } | ||||
| #endif | ||||
|  | @ -1370,7 +1370,7 @@ double mpz_manager<SYNCH>::get_double(mpz const & a) const { | |||
|     unsigned sz = size(a); | ||||
|     for (unsigned i = 0; i < sz; i++) { | ||||
|         r += d * static_cast<double>(digits(a)[i]); | ||||
|         if (sizeof(digit_t) == sizeof(uint64)) | ||||
|         if (sizeof(digit_t) == sizeof(uint64_t)) | ||||
|             d *= static_cast<double>(UINT64_MAX); // 64-bit version
 | ||||
|         else | ||||
|             d *= static_cast<double>(UINT_MAX);   // 32-bit version
 | ||||
|  | @ -1696,7 +1696,7 @@ void mpz_manager<SYNCH>::mul2k(mpz & a, unsigned k) { | |||
|     if (k == 0 || is_zero(a)) | ||||
|         return; | ||||
|     if (is_small(a) && k < 32) { | ||||
|         set_i64(a, i64(a) * (static_cast<int64>(1) << k)); | ||||
|         set_i64(a, i64(a) * (static_cast<int64_t>(1) << k)); | ||||
|         return; | ||||
|     } | ||||
| #ifndef _MP_GMP | ||||
|  | @ -1798,9 +1798,9 @@ unsigned mpz_manager<SYNCH>::power_of_two_multiple(mpz const & a) { | |||
|             if (sizeof(digit_t) == 8) { | ||||
|                 // TODO: we can remove this if after we move to MPN
 | ||||
|                 // In MPN the digit_t is always an unsigned integer
 | ||||
|                 if (static_cast<uint64>(v) % (static_cast<uint64>(1) << 32) == 0) { | ||||
|                 if (static_cast<uint64_t>(v) % (static_cast<uint64_t>(1) << 32) == 0) { | ||||
|                     r += 32;                      | ||||
|                     v = static_cast<digit_t>(static_cast<uint64>(v) / (static_cast<uint64>(1) << 32)); | ||||
|                     v = static_cast<digit_t>(static_cast<uint64_t>(v) / (static_cast<uint64_t>(1) << 32)); | ||||
|                 }                                 | ||||
|             } | ||||
|             COUNT_DIGIT_RIGHT_ZEROS(); | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ Revision History: | |||
| #include "util/mpn.h" | ||||
| 
 | ||||
| unsigned u_gcd(unsigned u, unsigned v); | ||||
| uint64 u64_gcd(uint64 u, uint64 v); | ||||
| uint64_t u64_gcd(uint64_t u, uint64_t v); | ||||
| 
 | ||||
| #ifdef _MP_GMP | ||||
| typedef unsigned digit_t; | ||||
|  | @ -192,11 +192,11 @@ class mpz_manager { | |||
|     template<int IDX> | ||||
|     void set(mpz & a, int sign, unsigned sz); | ||||
| 
 | ||||
|     static int64 i64(mpz const & a) { return static_cast<int64>(a.m_val); } | ||||
|     static int64_t i64(mpz const & a) { return static_cast<int64_t>(a.m_val); } | ||||
| 
 | ||||
|     void set_big_i64(mpz & c, int64 v); | ||||
|     void set_big_i64(mpz & c, int64_t v); | ||||
| 
 | ||||
|     void set_i64(mpz & c, int64 v) {  | ||||
|     void set_i64(mpz & c, int64_t v) { | ||||
|         if (v >= INT_MIN && v <= INT_MAX) { | ||||
|             del(c); | ||||
|             c.m_val = static_cast<int>(v);  | ||||
|  | @ -208,7 +208,7 @@ class mpz_manager { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     void set_big_ui64(mpz & c, uint64 v); | ||||
|     void set_big_ui64(mpz & c, uint64_t v); | ||||
| 
 | ||||
| #ifndef _MP_GMP | ||||
|     static unsigned capacity(mpz const & c) { return c.m_ptr->m_capacity; } | ||||
|  | @ -221,24 +221,24 @@ class mpz_manager { | |||
|     static bool is_abs_uint64(mpz const & a) { | ||||
|         if (is_small(a)) | ||||
|             return true; | ||||
|         if (sizeof(digit_t) == sizeof(uint64)) | ||||
|         if (sizeof(digit_t) == sizeof(uint64_t)) | ||||
|             return size(a) <= 1; | ||||
|         else | ||||
|             return size(a) <= 2; | ||||
|     } | ||||
|      | ||||
|     // CAST the absolute value into a UINT64
 | ||||
|     static uint64 big_abs_to_uint64(mpz const & a) { | ||||
|     static uint64_t big_abs_to_uint64(mpz const & a) { | ||||
|         SASSERT(is_abs_uint64(a)); | ||||
|         SASSERT(!is_small(a)); | ||||
|         if (a.m_ptr->m_size == 1) | ||||
|             return digits(a)[0]; | ||||
|         if (sizeof(digit_t) == sizeof(uint64)) | ||||
|         if (sizeof(digit_t) == sizeof(uint64_t)) | ||||
|             // 64-bit machine
 | ||||
|             return digits(a)[0]; | ||||
|         else  | ||||
|             // 32-bit machine
 | ||||
|             return ((static_cast<uint64>(digits(a)[1]) << 32) | (static_cast<uint64>(digits(a)[0]))); | ||||
|             return ((static_cast<uint64_t>(digits(a)[1]) << 32) | (static_cast<uint64_t>(digits(a)[0]))); | ||||
|     } | ||||
| 
 | ||||
|     template<int IDX> | ||||
|  | @ -426,8 +426,8 @@ public: | |||
|     void machine_div_rem(mpz const & a, mpz const & b, mpz & q, mpz & r) { | ||||
|         STRACE("mpz", tout << "[mpz-ext] divrem(" << to_string(a) << ",  " << to_string(b) << ") == ";);  | ||||
|         if (is_small(a) && is_small(b)) { | ||||
|             int64 _a = i64(a); | ||||
|             int64 _b = i64(b); | ||||
|             int64_t _a = i64(a); | ||||
|             int64_t _b = i64(b); | ||||
|             set_i64(q, _a / _b); | ||||
|             set_i64(r, _a % _b); | ||||
|         } | ||||
|  | @ -686,16 +686,16 @@ public: | |||
|         if (val <= INT_MAX) | ||||
|             set(a, static_cast<int>(val)); | ||||
|         else | ||||
|             set(a, static_cast<int64>(static_cast<uint64>(val))); | ||||
|             set(a, static_cast<int64_t>(static_cast<uint64_t>(val))); | ||||
|     } | ||||
| 
 | ||||
|     void set(mpz & a, char const * val); | ||||
| 
 | ||||
|     void set(mpz & a, int64 val) { | ||||
|     void set(mpz & a, int64_t val) { | ||||
|         set_i64(a, val); | ||||
|     } | ||||
| 
 | ||||
|     void set(mpz & a, uint64 val) { | ||||
|     void set(mpz & a, uint64_t val) { | ||||
|         if (val < INT_MAX) { | ||||
|             del(a); | ||||
|             a.m_val = static_cast<int>(val); | ||||
|  | @ -729,9 +729,9 @@ public: | |||
| 
 | ||||
|     bool is_int64(mpz const & a) const; | ||||
| 
 | ||||
|     uint64 get_uint64(mpz const & a) const; | ||||
|     uint64_t get_uint64(mpz const & a) const; | ||||
| 
 | ||||
|     int64 get_int64(mpz const & a) const; | ||||
|     int64_t get_int64(mpz const & a) const; | ||||
| 
 | ||||
|     bool is_uint(mpz const & a) const { return is_uint64(a) && get_uint64(a) < UINT_MAX; } | ||||
|      | ||||
|  |  | |||
|  | @ -87,7 +87,7 @@ public: | |||
|         setup_p(); | ||||
|     } | ||||
| 
 | ||||
|     mpzzp_manager(numeral_manager & _m, uint64 p, bool prime = true): | ||||
|     mpzzp_manager(numeral_manager & _m, uint64_t p, bool prime = true): | ||||
|         m_manager(_m), | ||||
|         m_z(false) { | ||||
|         m().set(m_p, p); | ||||
|  | @ -120,7 +120,7 @@ public: | |||
| 
 | ||||
|     void set_z() { m_z = true; } | ||||
|     void set_zp(mpz const & new_p) { m_z = false; m_p_prime = true; m().set(m_p, new_p); setup_p(); } | ||||
|     void set_zp(uint64 new_p) { m_z = false; m_p_prime = true; m().set(m_p, new_p); setup_p(); } | ||||
|     void set_zp(uint64_t new_p) { m_z = false; m_p_prime = true; m().set(m_p, new_p); setup_p(); } | ||||
|     // p = p^2
 | ||||
|     void set_p_sq() { SASSERT(!m_z); m_p_prime = false; m().mul(m_p, m_p, m_p); setup_p(); } | ||||
|     void set_zp_swap(mpz & new_p) { SASSERT(!m_z); m().swap(m_p, new_p); setup_p(); } | ||||
|  | @ -230,14 +230,14 @@ public: | |||
|     void set(mpz & a, int val) { m().set(a, val); p_normalize(a); }     | ||||
|     void set(mpz & a, unsigned val) { m().set(a, val); p_normalize(a); } | ||||
|     void set(mpz & a, char const * val) { m().set(a, val); p_normalize(a); } | ||||
|     void set(mpz & a, int64 val) { m().set(a, val); p_normalize(a); } | ||||
|     void set(mpz & a, uint64 val) { m().set(a, val); p_normalize(a); } | ||||
|     void set(mpz & a, int64_t val) { m().set(a, val); p_normalize(a); } | ||||
|     void set(mpz & a, uint64_t val) { m().set(a, val); p_normalize(a); } | ||||
|     void set(mpz & a, mpz const & val) { m().set(a, val); p_normalize(a); } | ||||
| 
 | ||||
|     bool is_uint64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().is_uint64(a); } | ||||
|     bool is_int64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().is_int64(a); } | ||||
|     uint64 get_uint64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_uint64(a); } | ||||
|     int64 get_int64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_int64(a); } | ||||
|     uint64_t get_uint64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_uint64(a); } | ||||
|     int64_t get_int64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_int64(a); } | ||||
|     double get_double(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_double(a); } | ||||
|     void power(mpz const & a, unsigned k, mpz & b) {  | ||||
|         SASSERT(is_p_normalized(a)); | ||||
|  | @ -265,8 +265,8 @@ public: | |||
| 
 | ||||
|     bool is_uint64(mpz const & a) const { return m().is_uint64(a); } | ||||
|     bool is_int64(mpz const & a) const { return m().is_int64(a); } | ||||
|     uint64 get_uint64(mpz const & a) const { return m().get_uint64(a); } | ||||
|     int64 get_int64(mpz const & a) const { return m().get_int64(a); } | ||||
|     uint64_t get_uint64(mpz const & a) const { return m().get_uint64(a); } | ||||
|     int64_t get_int64(mpz const & a) const { return m().get_int64(a); } | ||||
| 
 | ||||
|     void mul2k(mpz & a, unsigned k) { m().mul2k(a, k); p_normalize(a); } | ||||
|     void mul2k(mpz const & a, unsigned k, mpz & r) { m().mul2k(a, k, r); p_normalize(r); } | ||||
|  |  | |||
|  | @ -26,11 +26,11 @@ prime_generator::prime_generator() { | |||
|     process_next_k_numbers(128); | ||||
| } | ||||
| 
 | ||||
| void prime_generator::process_next_k_numbers(uint64 k) { | ||||
|     svector<uint64> todo; | ||||
|     uint64 begin = m_primes.back() + 2; | ||||
|     uint64 end   = begin + k; | ||||
|     for (uint64 i = begin; i < end; i+=2) { | ||||
| void prime_generator::process_next_k_numbers(uint64_t k) { | ||||
|     svector<uint64_t> todo; | ||||
|     uint64_t begin = m_primes.back() + 2; | ||||
|     uint64_t end   = begin + k; | ||||
|     for (uint64_t i = begin; i < end; i+=2) { | ||||
|         todo.push_back(i); | ||||
|     } | ||||
|     unsigned j = 1; | ||||
|  | @ -38,7 +38,7 @@ void prime_generator::process_next_k_numbers(uint64 k) { | |||
|     while (!todo.empty()) { | ||||
|         unsigned sz = m_primes.size(); | ||||
|         for (; j < sz; j++) { | ||||
|             uint64 p = m_primes[j]; | ||||
|             uint64_t p = m_primes[j]; | ||||
|             unsigned todo_sz = todo.size(); | ||||
|             unsigned k1 = 0; | ||||
|             unsigned k2 = 0; | ||||
|  | @ -59,7 +59,7 @@ void prime_generator::process_next_k_numbers(uint64 k) { | |||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         uint64 p = m_primes.back(); | ||||
|         uint64_t p = m_primes.back(); | ||||
|         p = p*p; | ||||
|         unsigned todo_sz = todo.size(); | ||||
|         unsigned k1 = 0; | ||||
|  | @ -83,7 +83,7 @@ void prime_generator::finalize() { | |||
|     m_primes.finalize(); | ||||
| } | ||||
| 
 | ||||
| uint64 prime_generator::operator()(unsigned idx) { | ||||
| uint64_t prime_generator::operator()(unsigned idx) { | ||||
|     if (idx < m_primes.size()) | ||||
|         return m_primes[idx]; | ||||
|     if (idx > PRIME_LIST_MAX_SIZE) | ||||
|  | @ -109,14 +109,14 @@ prime_iterator::prime_iterator(prime_generator * g):m_idx(0) { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| uint64 prime_iterator::next() { | ||||
| uint64_t prime_iterator::next() { | ||||
|     unsigned idx = m_idx; | ||||
|     m_idx++; | ||||
|     if (!m_global) { | ||||
|         return (*m_generator)(idx); | ||||
|     } | ||||
|     else { | ||||
|         uint64 r; | ||||
|         uint64_t r; | ||||
|         #pragma omp critical (prime_iterator) | ||||
|         { | ||||
|             r = (*m_generator)(idx); | ||||
|  |  | |||
|  | @ -32,11 +32,11 @@ public: | |||
|    \brief Prime generator | ||||
| */ | ||||
| class prime_generator { | ||||
|     svector<uint64> m_primes; | ||||
|     void process_next_k_numbers(uint64 k); | ||||
|     svector<uint64_t> m_primes; | ||||
|     void process_next_k_numbers(uint64_t k); | ||||
| public: | ||||
|     prime_generator(); | ||||
|     uint64 operator()(unsigned idx); | ||||
|     uint64_t operator()(unsigned idx); | ||||
|     void finalize(); | ||||
| }; | ||||
| 
 | ||||
|  | @ -46,7 +46,7 @@ class prime_iterator { | |||
|     bool              m_global; | ||||
| public: | ||||
|     prime_iterator(prime_generator * g = nullptr); | ||||
|     uint64 next(); | ||||
|     uint64_t next(); | ||||
|     static void finalize(); | ||||
|     /*
 | ||||
|       ADD_FINALIZER('prime_iterator::finalize();') | ||||
|  |  | |||
|  | @ -59,10 +59,10 @@ public: | |||
|     explicit rational(char const * v) { m().set(m_val, v); } | ||||
| 
 | ||||
|     struct i64 {}; | ||||
|     rational(int64 i, i64) { m().set(m_val, i); } | ||||
|     rational(int64_t i, i64) { m().set(m_val, i); } | ||||
| 
 | ||||
|     struct ui64 {}; | ||||
|     rational(uint64 i, ui64) { m().set(m_val, i); } | ||||
|     rational(uint64_t i, ui64) { m().set(m_val, i); } | ||||
|      | ||||
|     ~rational() { m().del(m_val); } | ||||
|      | ||||
|  | @ -98,9 +98,9 @@ public: | |||
| 
 | ||||
|     bool is_int64() const { return m().is_int64(m_val); } | ||||
| 
 | ||||
|     uint64 get_uint64() const { return m().get_uint64(m_val); } | ||||
|     uint64_t get_uint64() const { return m().get_uint64(m_val); } | ||||
| 
 | ||||
|     int64 get_int64() const { return m().get_int64(m_val); } | ||||
|     int64_t get_int64() const { return m().get_int64(m_val); } | ||||
|      | ||||
|     bool is_unsigned() const { return is_uint64() && (get_uint64() < (1ull << 32)); } | ||||
| 
 | ||||
|  | @ -113,7 +113,7 @@ public: | |||
|         if (is_small() && is_int()) return true;  | ||||
|         // we don't assume that if it is small, then it is int32.
 | ||||
|         if (!is_int64()) return false; | ||||
|         int64 v = get_int64(); | ||||
|         int64_t v = get_int64(); | ||||
|         return INT_MIN <= v && v <= INT_MAX; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue