3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-14 01:46:15 +00:00

Tabs, formatting.

This commit is contained in:
Christoph M. Wintersteiger 2017-09-17 14:29:32 +01:00
parent 8871cb120a
commit 00651f8f21
63 changed files with 715 additions and 717 deletions

View file

@ -15,16 +15,16 @@ Copyright (c) 2015 Microsoft Corporation
BOOL APIENTRY DllMain( HMODULE hModule, BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
) )
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
break; break;
} }
return TRUE; return TRUE;
} }

View file

@ -3332,18 +3332,18 @@ 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_inc", inc);
dbg_decouple("fpa2bv_to_bv_pre_rounded", pre_rounded); 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); pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
expr_ref ll(m), ul(m), in_range(m); expr_ref ll(m), ul(m), in_range(m);
if (!is_signed) { if (!is_signed) {
ll = m_bv_util.mk_numeral(0, bv_sz+3); 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_numeral(-1, bv_sz));
} }
else { else {
ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1))); 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_numeral(-1, bv_sz-1));
} }
in_range = m.mk_and(m_bv_util.mk_sle(ll, pre_rounded), m_bv_util.mk_sle(pre_rounded, ul)); 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", in_range); dbg_decouple("fpa2bv_to_bv_in_range", in_range);
expr_ref rounded(m); expr_ref rounded(m);

View file

@ -38,7 +38,7 @@ public:
bv_bounds(ast_manager& m) : m_m(m), m_bv_util(m), m_okay(true) {}; bv_bounds(ast_manager& m) : m_m(m), m_bv_util(m), m_okay(true) {};
~bv_bounds(); ~bv_bounds();
public: // bounds addition methods public: // bounds addition methods
br_status rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result); br_status rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result);
/** \brief Add a constraint to the system. /** \brief Add a constraint to the system.
@ -82,7 +82,7 @@ protected:
bv_util m_bv_util; bv_util m_bv_util;
bool m_okay; bool m_okay;
bool is_sat(app * v); bool is_sat(app * v);
bool is_sat_core(app * v); bool is_sat_core(app * v);
inline bool in_range(app *v, numeral l); inline bool in_range(app *v, numeral l);
inline bool is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val); inline bool is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val);
void record_singleton(app * v, numeral& singleton_value); void record_singleton(app * v, numeral& singleton_value);
@ -94,7 +94,7 @@ protected:
inline bool bv_bounds::is_okay() { return m_okay; } inline bool bv_bounds::is_okay() { return m_okay; }
inline bool bv_bounds::to_bound(const expr * e) const { inline bool bv_bounds::to_bound(const expr * e) const {
return is_app(e) && m_bv_util.is_bv(e) return is_app(e) && m_bv_util.is_bv(e)
&& !m_bv_util.is_bv_add(e) && !m_bv_util.is_bv_add(e)
&& !m_bv_util.is_numeral(e); && !m_bv_util.is_numeral(e);
} }

View file

@ -21,6 +21,7 @@
#pragma once #pragma once
#include "duality/duality_wrapper.h" #include "duality/duality_wrapper.h"
#include <vector>
#include <list> #include <list>
#include <map> #include <map>
@ -831,8 +832,8 @@ namespace Duality {
symbol name; symbol name;
expr value; expr value;
bool pos; bool pos;
label_struct(const symbol &s, const expr &e, bool b) label_struct(const symbol &s, const expr &e, bool b)
: name(s), value(e), pos(b) {} : name(s), value(e), pos(b) {}
}; };

View file

@ -281,17 +281,17 @@ namespace Duality {
object(object const & s):m_ctx(s.m_ctx) {} object(object const & s):m_ctx(s.m_ctx) {}
context & ctx() const { return *m_ctx; } context & ctx() const { return *m_ctx; }
friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); } friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
ast_manager &m() const {return m_ctx->m();} ast_manager &m() const {return m_ctx->m();}
}; };
class symbol : public object { class symbol : public object {
::symbol m_sym; ::symbol m_sym;
public: public:
symbol(context & c, ::symbol s):object(c), m_sym(s) {} symbol(context & c, ::symbol s):object(c), m_sym(s) {}
symbol(symbol const & s):object(s), m_sym(s.m_sym) {} symbol(symbol const & s):object(s), m_sym(s.m_sym) {}
symbol & operator=(symbol const & s) { m_ctx = s.m_ctx; m_sym = s.m_sym; return *this; } symbol & operator=(symbol const & s) { m_ctx = s.m_ctx; m_sym = s.m_sym; return *this; }
operator ::symbol() const {return m_sym;} operator ::symbol() const {return m_sym;}
std::string str() const { std::string str() const {
if (m_sym.is_numerical()) { if (m_sym.is_numerical()) {
std::ostringstream buffer; std::ostringstream buffer;
buffer << m_sym.get_num(); buffer << m_sym.get_num();
@ -300,13 +300,13 @@ namespace Duality {
else { else {
return m_sym.bare_str(); return m_sym.bare_str();
} }
} }
friend std::ostream & operator<<(std::ostream & out, symbol const & s){ friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
return out << s.str(); return out << s.str();
} }
friend bool operator==(const symbol &x, const symbol &y){ friend bool operator==(const symbol &x, const symbol &y) {
return x.m_sym == y.m_sym; return x.m_sym == y.m_sym;
} }
}; };
class params : public config {}; class params : public config {};
@ -434,9 +434,9 @@ namespace Duality {
expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const; expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const;
expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const; expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const;
func_decl get_func_decl_parameter(unsigned idx){ func_decl get_func_decl_parameter(unsigned idx){
return func_decl(ctx(),to_func_decl(to_func_decl(raw())->get_parameters()[idx].get_ast())); return func_decl(ctx(),to_func_decl(to_func_decl(raw())->get_parameters()[idx].get_ast()));
} }
}; };
@ -447,8 +447,8 @@ namespace Duality {
expr(context & c, ::ast *n):ast(c, n) {} expr(context & c, ::ast *n):ast(c, n) {}
expr(expr const & n):ast(n) {} expr(expr const & n):ast(n) {}
expr & operator=(expr const & n) { return static_cast<expr&>(ast::operator=(n)); } expr & operator=(expr const & n) { return static_cast<expr&>(ast::operator=(n)); }
operator ::expr*() const { return to_expr(raw()); } operator ::expr*() const { return to_expr(raw()); }
unsigned get_id() const {return to_expr(raw())->get_id();} unsigned get_id() const {return to_expr(raw())->get_id();}
sort get_sort() const { return sort(ctx(),m().get_sort(to_expr(raw()))); } sort get_sort() const { return sort(ctx(),m().get_sort(to_expr(raw()))); }
@ -460,27 +460,27 @@ namespace Duality {
bool is_datatype() const { return get_sort().is_datatype(); } bool is_datatype() const { return get_sort().is_datatype(); }
bool is_relation() const { return get_sort().is_relation(); } bool is_relation() const { return get_sort().is_relation(); }
bool is_finite_domain() const { return get_sort().is_finite_domain(); } bool is_finite_domain() const { return get_sort().is_finite_domain(); }
bool is_true() const {return is_app() && decl().get_decl_kind() == True; } bool is_true() const {return is_app() && decl().get_decl_kind() == True; }
bool is_numeral() const { bool is_numeral() const {
return is_app() && decl().get_decl_kind() == OtherArith && m().is_unique_value(to_expr(raw())); return is_app() && decl().get_decl_kind() == OtherArith && m().is_unique_value(to_expr(raw()));
} }
bool is_app() const {return raw()->get_kind() == AST_APP;} bool is_app() const {return raw()->get_kind() == AST_APP;}
bool is_quantifier() const {return raw()->get_kind() == AST_QUANTIFIER;} bool is_quantifier() const {return raw()->get_kind() == AST_QUANTIFIER;}
bool is_var() const {return raw()->get_kind() == AST_VAR;} bool is_var() const {return raw()->get_kind() == AST_VAR;}
bool is_label (bool &pos,std::vector<symbol> &names) const ; bool is_label (bool &pos,std::vector<symbol> &names) const ;
bool is_ground() const {return to_app(raw())->is_ground();} bool is_ground() const {return to_app(raw())->is_ground();}
bool has_quantifiers() const {return to_app(raw())->has_quantifiers();} bool has_quantifiers() const {return to_app(raw())->has_quantifiers();}
bool has_free(int idx) const { bool has_free(int idx) const {
used_vars proc; used_vars proc;
proc.process(to_expr(raw())); proc.process(to_expr(raw()));
return proc.contains(idx); return proc.contains(idx);
} }
unsigned get_max_var_idx_plus_1() const { unsigned get_max_var_idx_plus_1() const {
used_vars proc; used_vars proc;
proc.process(to_expr(raw())); proc.process(to_expr(raw()));
return proc.get_max_found_var_idx_plus_1(); return proc.get_max_found_var_idx_plus_1();
} }
// operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); } // operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
func_decl decl() const {return func_decl(ctx(),to_app(raw())->get_decl());} func_decl decl() const {return func_decl(ctx(),to_app(raw())->get_decl());}
@ -497,7 +497,7 @@ namespace Duality {
} }
SASSERT(0); SASSERT(0);
return 0; return 0;
} }
expr arg(unsigned i) const { expr arg(unsigned i) const {
ast_kind dk = raw()->get_kind(); ast_kind dk = raw()->get_kind();
switch(dk){ switch(dk){
@ -509,20 +509,20 @@ namespace Duality {
} }
assert(0); assert(0);
return expr(); return expr();
} }
expr body() const { expr body() const {
return ctx().cook(to_quantifier(raw())->get_expr()); return ctx().cook(to_quantifier(raw())->get_expr());
} }
friend expr operator!(expr const & a) { friend expr operator!(expr const & a) {
// ::expr *e = a; // ::expr *e = a;
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_NOT,a)); return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_NOT,a));
} }
friend expr operator&&(expr const & a, expr const & b) { friend expr operator&&(expr const & a, expr const & b) {
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_AND,a,b)); return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_AND,a,b));
} }
friend expr operator||(expr const & a, expr const & b) { friend expr operator||(expr const & a, expr const & b) {
return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_OR,a,b)); return expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_OR,a,b));
@ -546,7 +546,7 @@ namespace Duality {
friend expr operator*(expr const & a, expr const & b) { friend expr operator*(expr const & a, expr const & b) {
return a.ctx().make(Times,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_MUL,a,b)); return a.ctx().make(Times,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_MUL,a,b));
} }
friend expr operator/(expr const & a, expr const & b) { friend expr operator/(expr const & a, expr const & b) {
return a.ctx().make(Div,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_DIV,a,b)); return a.ctx().make(Div,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_DIV,a,b));
@ -562,7 +562,7 @@ namespace Duality {
friend expr operator<=(expr const & a, expr const & b) { friend expr operator<=(expr const & a, expr const & b) {
return a.ctx().make(Leq,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LE,a,b)); return a.ctx().make(Leq,a,b); // expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_LE,a,b));
} }
friend expr operator>=(expr const & a, expr const & b) { friend expr operator>=(expr const & a, expr const & b) {
return a.ctx().make(Geq,a,b); //expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GE,a,b)); return a.ctx().make(Geq,a,b); //expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GE,a,b));
@ -574,7 +574,7 @@ namespace Duality {
friend expr operator>(expr const & a, expr const & b) { friend expr operator>(expr const & a, expr const & b) {
return a.ctx().make(Gt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GT,a,b)); return a.ctx().make(Gt,a,b); expr(a.ctx(),a.m().mk_app(a.m().get_basic_family_id(),OP_GT,a,b));
} }
expr simplify() const; expr simplify() const;
@ -582,45 +582,45 @@ namespace Duality {
expr qe_lite() const; expr qe_lite() const;
expr qe_lite(const std::set<int> &idxs, bool index_of_bound) const; expr qe_lite(const std::set<int> &idxs, bool index_of_bound) const;
friend expr clone_quantifier(const expr &, const expr &); friend expr clone_quantifier(const expr &, const expr &);
friend expr clone_quantifier(const expr &q, const expr &b, const std::vector<expr> &patterns); friend expr clone_quantifier(const expr &q, const expr &b, const std::vector<expr> &patterns);
friend expr clone_quantifier(decl_kind, const expr &, const expr &); friend expr clone_quantifier(decl_kind, const expr &, const expr &);
friend std::ostream & operator<<(std::ostream & out, expr const & m){ friend std::ostream & operator<<(std::ostream & out, expr const & m){
m.ctx().print_expr(out,m); m.ctx().print_expr(out,m);
return out; return out;
} }
void get_patterns(std::vector<expr> &pats) const ; void get_patterns(std::vector<expr> &pats) const ;
unsigned get_quantifier_num_bound() const { unsigned get_quantifier_num_bound() const {
return to_quantifier(raw())->get_num_decls(); return to_quantifier(raw())->get_num_decls();
} }
unsigned get_index_value() const { unsigned get_index_value() const {
var* va = to_var(raw()); var* va = to_var(raw());
return va->get_idx(); return va->get_idx();
} }
bool is_quantifier_forall() const { bool is_quantifier_forall() const {
return to_quantifier(raw())->is_forall(); return to_quantifier(raw())->is_forall();
} }
sort get_quantifier_bound_sort(unsigned n) const { sort get_quantifier_bound_sort(unsigned n) const {
return sort(ctx(),to_quantifier(raw())->get_decl_sort(n)); return sort(ctx(),to_quantifier(raw())->get_decl_sort(n));
} }
symbol get_quantifier_bound_name(unsigned n) const { symbol get_quantifier_bound_name(unsigned n) const {
return symbol(ctx(),to_quantifier(raw())->get_decl_names()[n]); return symbol(ctx(),to_quantifier(raw())->get_decl_names()[n]);
} }
friend expr forall(const std::vector<expr> &quants, const expr &body); friend expr forall(const std::vector<expr> &quants, const expr &body);
friend expr exists(const std::vector<expr> &quants, const expr &body); friend expr exists(const std::vector<expr> &quants, const expr &body);
}; };
@ -729,9 +729,9 @@ namespace Duality {
m_model = m; m_model = m;
} }
public: public:
model(context & c, ::model * m = 0):object(c), m_model(m) { } model(context & c, ::model * m = 0):object(c), m_model(m) { }
model(model const & s):object(s), m_model(s.m_model) { } model(model const & s):object(s), m_model(s.m_model) { }
~model() { } ~model() { }
operator ::model *() const { return m_model.get(); } operator ::model *() const { return m_model.get(); }
model & operator=(model const & s) { model & operator=(model const & s) {
// ::model *_inc_ref(s.ctx(), s.m_model); // ::model *_inc_ref(s.ctx(), s.m_model);
@ -741,10 +741,10 @@ namespace Duality {
return *this; return *this;
} }
model & operator=(::model *s) { model & operator=(::model *s) {
m_model = s; m_model = s;
return *this; return *this;
} }
bool null() const {return !m_model;} bool null() const {return !m_model;}
expr eval(expr const & n, bool model_completion=true) const { expr eval(expr const & n, bool model_completion=true) const {
::model * _m = m_model.get(); ::model * _m = m_model.get();
@ -754,7 +754,7 @@ namespace Duality {
} }
void show() const; void show() const;
void show_hash() const; void show_hash() const;
unsigned num_consts() const {return m_model.get()->get_num_constants();} unsigned num_consts() const {return m_model.get()->get_num_constants();}
unsigned num_funcs() const {return m_model.get()->get_num_functions();} unsigned num_funcs() const {return m_model.get()->get_num_functions();}
@ -765,11 +765,11 @@ namespace Duality {
expr get_const_interp(func_decl f) const { expr get_const_interp(func_decl f) const {
return ctx().cook(m_model->get_const_interp(to_func_decl(f.raw()))); return ctx().cook(m_model->get_const_interp(to_func_decl(f.raw())));
} }
func_interp get_func_interp(func_decl f) const { func_interp get_func_interp(func_decl f) const {
return func_interp(ctx(),m_model->get_func_interp(to_func_decl(f.raw()))); return func_interp(ctx(),m_model->get_func_interp(to_func_decl(f.raw())));
} }
#if 0 #if 0
friend std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; } friend std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }
@ -837,30 +837,30 @@ namespace Duality {
protected: protected:
::solver *m_solver; ::solver *m_solver;
model the_model; model the_model;
bool canceled; bool canceled;
proof_gen_mode m_mode; proof_gen_mode m_mode;
bool extensional; bool extensional;
public: public:
solver(context & c, bool extensional = false, bool models = true); solver(context & c, bool extensional = false, bool models = true);
solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; canceled = false;} solver(context & c, ::solver *s):object(c),the_model(c) { m_solver = s; canceled = false;}
solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;} solver(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;}
~solver() { ~solver() {
if(m_solver) if(m_solver)
dealloc(m_solver); dealloc(m_solver);
} }
operator ::solver*() const { return m_solver; } operator ::solver*() const { return m_solver; }
solver & operator=(solver const & s) { solver & operator=(solver const & s) {
m_ctx = s.m_ctx; m_ctx = s.m_ctx;
m_solver = s.m_solver; m_solver = s.m_solver;
the_model = s.the_model; the_model = s.the_model;
m_mode = s.m_mode; m_mode = s.m_mode;
return *this; return *this;
} }
struct cancel_exception {}; struct cancel_exception {};
void checkpoint(){ void checkpoint(){
if(canceled) if(canceled)
throw(cancel_exception()); throw(cancel_exception());
} }
// void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); } // void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
void push() { scoped_proof_mode spm(m(),m_mode); m_solver->push(); } void push() { scoped_proof_mode spm(m(),m_mode); m_solver->push(); }
void pop(unsigned n = 1) { scoped_proof_mode spm(m(),m_mode); m_solver->pop(n); } void pop(unsigned n = 1) { scoped_proof_mode spm(m(),m_mode); m_solver->pop(n); }
@ -874,7 +874,7 @@ namespace Duality {
m_solver->get_model(m); m_solver->get_model(m);
the_model = m.get(); the_model = m.get();
return to_check_result(r); return to_check_result(r);
} }
check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) { check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
scoped_proof_mode spm(m(),m_mode); scoped_proof_mode spm(m(),m_mode);
model old_model(the_model); model old_model(the_model);
@ -882,7 +882,7 @@ namespace Duality {
if(the_model == 0) if(the_model == 0)
the_model = old_model; the_model = old_model;
return res; return res;
} }
check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) { check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
scoped_proof_mode spm(m(),m_mode); scoped_proof_mode spm(m(),m_mode);
checkpoint(); checkpoint();
@ -930,27 +930,26 @@ namespace Duality {
#endif #endif
// expr proof() const { Z3_ast r = Z3_solver_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); } // expr proof() const { Z3_ast r = Z3_solver_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
// friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; } // friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
int get_num_decisions();
int get_num_decisions(); void cancel(){
void cancel(){
scoped_proof_mode spm(m(),m_mode); scoped_proof_mode spm(m(),m_mode);
canceled = true; canceled = true;
m().limit().cancel(); m().limit().cancel();
} }
unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();} unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();}
void show(); void show();
void print(const char *filename); void print(const char *filename);
void show_assertion_ids(); void show_assertion_ids();
proof get_proof(){ proof get_proof(){
scoped_proof_mode spm(m(),m_mode); scoped_proof_mode spm(m(),m_mode);
return proof(ctx(),m_solver->get_proof()); return proof(ctx(),m_solver->get_proof());
} }
bool extensional_array_theory() {return extensional;} bool extensional_array_theory() {return extensional;}
}; };
#if 0 #if 0
@ -1196,7 +1195,7 @@ namespace Duality {
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) { inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {
sort args[2] = { d1, d2 }; sort args[2] = { d1, d2 };
return function(name, 2, args, range); return function(name, 2, args, range);
} }
inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) { inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {

View file

@ -66,35 +66,35 @@ class iz3base : public iz3mgr, public scopes {
/** Constructor */ /** Constructor */
iz3base(ast_manager &_m_manager, iz3base(ast_manager &_m_manager,
const std::vector<ast> &_cnsts, const std::vector<ast> &_cnsts,
const std::vector<int> &_parents, const std::vector<int> &_parents,
const std::vector<ast> &_theory) const std::vector<ast> &_theory)
: iz3mgr(_m_manager), scopes(_parents) { : iz3mgr(_m_manager), scopes(_parents) {
initialize(_cnsts,_parents,_theory); initialize(_cnsts,_parents,_theory);
weak = false; weak = false;
} }
iz3base(const iz3mgr& other, iz3base(const iz3mgr& other,
const std::vector<ast> &_cnsts, const std::vector<ast> &_cnsts,
const std::vector<int> &_parents, const std::vector<int> &_parents,
const std::vector<ast> &_theory) const std::vector<ast> &_theory)
: iz3mgr(other), scopes(_parents) { : iz3mgr(other), scopes(_parents) {
initialize(_cnsts,_parents,_theory); initialize(_cnsts,_parents,_theory);
weak = false; weak = false;
} }
iz3base(const iz3mgr& other, iz3base(const iz3mgr& other,
const std::vector<std::vector<ast> > &_cnsts, const std::vector<std::vector<ast> > &_cnsts,
const std::vector<int> &_parents, const std::vector<int> &_parents,
const std::vector<ast> &_theory) const std::vector<ast> &_theory)
: iz3mgr(other), scopes(_parents) { : iz3mgr(other), scopes(_parents) {
initialize(_cnsts,_parents,_theory); initialize(_cnsts,_parents,_theory);
weak = false; weak = false;
} }
iz3base(const iz3mgr& other) iz3base(const iz3mgr& other)
: iz3mgr(other), scopes() { : iz3mgr(other), scopes() {
weak = false; weak = false;
} }

View file

@ -24,26 +24,26 @@
#include "solver/solver.h" #include "solver/solver.h"
bool iz3check(ast_manager &_m_manager, bool iz3check(ast_manager &_m_manager,
solver *s, solver *s,
std::ostream &err, std::ostream &err,
const ptr_vector<ast> &cnsts, const ptr_vector<ast> &cnsts,
const ::vector<int> &parents, const ::vector<int> &parents,
const ptr_vector<ast> &interps, const ptr_vector<ast> &interps,
const ptr_vector<ast> &theory); const ptr_vector<ast> &theory);
bool iz3check(ast_manager &_m_manager, bool iz3check(ast_manager &_m_manager,
solver *s, solver *s,
std::ostream &err, std::ostream &err,
const ptr_vector<ast> &cnsts, const ptr_vector<ast> &cnsts,
ast *tree, ast *tree,
const ptr_vector<ast> &interps); const ptr_vector<ast> &interps);
bool iz3check(iz3mgr &mgr, bool iz3check(iz3mgr &mgr,
solver *s, solver *s,
std::ostream &err, std::ostream &err,
const std::vector<iz3mgr::ast> &cnsts, const std::vector<iz3mgr::ast> &cnsts,
const std::vector<int> &parents, const std::vector<int> &parents,
const std::vector<iz3mgr::ast> &interps, const std::vector<iz3mgr::ast> &interps,
const ptr_vector<iz3mgr::ast> &theory); const ptr_vector<iz3mgr::ast> &theory);
#endif #endif

View file

@ -468,10 +468,10 @@ namespace hash_space {
: hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>(7) {} : hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>(7) {}
Value &operator[](const Key& key) { Value &operator[](const Key& key) {
std::pair<Key,Value> kvp(key,Value()); std::pair<Key,Value> kvp(key,Value());
return return
hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>:: hashtable<std::pair<Key,Value>,Key,HashFun,proj1<Key,Value>,EqFun>::
lookup(kvp,true)->val.second; lookup(kvp,true)->val.second;
} }
}; };

View file

@ -73,22 +73,22 @@ typedef interpolation_options_struct *interpolation_options;
representation, for compatibility with the old API. */ representation, for compatibility with the old API. */
void iz3interpolate(ast_manager &_m_manager, void iz3interpolate(ast_manager &_m_manager,
ast *proof, ast *proof,
const ptr_vector<ast> &cnsts, const ptr_vector<ast> &cnsts,
const ::vector<int> &parents, const ::vector<int> &parents,
ptr_vector<ast> &interps, ptr_vector<ast> &interps,
const ptr_vector<ast> &theory, const ptr_vector<ast> &theory,
interpolation_options_struct * options = 0); interpolation_options_struct * options = 0);
/* Same as above, but each constraint is a vector of formulas. */ /* Same as above, but each constraint is a vector of formulas. */
void iz3interpolate(ast_manager &_m_manager, void iz3interpolate(ast_manager &_m_manager,
ast *proof, ast *proof,
const vector<ptr_vector<ast> > &cnsts, const vector<ptr_vector<ast> > &cnsts,
const ::vector<int> &parents, const ::vector<int> &parents,
ptr_vector<ast> &interps, ptr_vector<ast> &interps,
const ptr_vector<ast> &theory, const ptr_vector<ast> &theory,
interpolation_options_struct * options = 0); interpolation_options_struct * options = 0);
/* Compute an interpolant from a proof. This version uses the ast /* Compute an interpolant from a proof. This version uses the ast
representation, for compatibility with the new API. Here, cnsts is representation, for compatibility with the new API. Here, cnsts is
@ -98,11 +98,11 @@ void iz3interpolate(ast_manager &_m_manager,
proof, so it can be considered a hint. */ proof, so it can be considered a hint. */
void iz3interpolate(ast_manager &_m_manager, void iz3interpolate(ast_manager &_m_manager,
ast *proof, ast *proof,
const ptr_vector<ast> &cnsts, const ptr_vector<ast> &cnsts,
ast *tree, ast *tree,
ptr_vector<ast> &interps, ptr_vector<ast> &interps,
interpolation_options_struct * options); interpolation_options_struct * options);
/* Compute an interpolant from an ast representing an interpolation /* Compute an interpolant from an ast representing an interpolation
@ -112,12 +112,12 @@ void iz3interpolate(ast_manager &_m_manager,
*/ */
lbool iz3interpolate(ast_manager &_m_manager, lbool iz3interpolate(ast_manager &_m_manager,
solver &s, solver &s,
ast *tree, ast *tree,
ptr_vector<ast> &cnsts, ptr_vector<ast> &cnsts,
ptr_vector<ast> &interps, ptr_vector<ast> &interps,
model_ref &m, model_ref &m,
interpolation_options_struct * options); interpolation_options_struct * options);
#endif #endif

View file

@ -30,7 +30,7 @@ struct iz3pp_bad_tree: public iz3_exception {
}; };
void iz3pp(ast_manager &m, void iz3pp(ast_manager &m,
const ptr_vector<expr> &cnsts_vec, const ptr_vector<expr> &cnsts_vec,
expr *tree, expr *tree,
std::ostream& out); std::ostream& out);
#endif #endif

View file

@ -105,7 +105,7 @@ class scopes {
void range_add(int i, range &n){ void range_add(int i, range &n){
#if 0 #if 0
if(i < n.lo) n.lo = i; if(i < n.lo) n.lo = i;
if(i > n.hi) n.hi = i; if(i > n.hi) n.hi = i;
#else #else
range rng; rng.lo = i; rng.hi = i; range rng; rng.lo = i; rng.hi = i;
@ -119,7 +119,7 @@ class scopes {
int thing = tree_lca(rng1.lo,rng2.hi); int thing = tree_lca(rng1.lo,rng2.hi);
if(thing == rng1.lo) frame = rng1.lo; if(thing == rng1.lo) frame = rng1.lo;
else frame = tree_gcd(thing,rng1.hi); else frame = tree_gcd(thing,rng1.hi);
return frame; return frame;
} }
#else #else

View file

@ -47,9 +47,9 @@ class iz3translation : public iz3base {
protected: protected:
iz3translation(iz3mgr &mgr, iz3translation(iz3mgr &mgr,
const std::vector<std::vector<ast> > &_cnsts, const std::vector<std::vector<ast> > &_cnsts,
const std::vector<int> &_parents, const std::vector<int> &_parents,
const std::vector<ast> &_theory) const std::vector<ast> &_theory)
: iz3base(mgr,_cnsts,_parents,_theory) {} : iz3base(mgr,_cnsts,_parents,_theory) {}
}; };

View file

@ -41,8 +41,6 @@ class boolean_algebra : public positive_boolean_algebra<T> {
public: public:
virtual ~boolean_algebra() {} virtual ~boolean_algebra() {}
virtual T mk_not(T x) = 0; virtual T mk_not(T x) = 0;
//virtual lbool are_equivalent(T x, T y) = 0;
//virtual T simplify(T x) = 0;
}; };
#endif #endif

View file

@ -63,8 +63,8 @@ namespace polynomial {
public: public:
void set_degree(var x, unsigned d) { m_var2degree.setx(x, d, 0); } void set_degree(var x, unsigned d) { m_var2degree.setx(x, d, 0); }
unsigned degree(var x) const { return m_var2degree.get(x, 0); } unsigned degree(var x) const { return m_var2degree.get(x, 0); }
void display(std::ostream & out) const; void display(std::ostream & out) const;
friend std::ostream & operator<<(std::ostream & out, var2degree const & ideal) { ideal.display(out); return out; } friend std::ostream & operator<<(std::ostream & out, var2degree const & ideal) { ideal.display(out); return out; }
}; };
template<typename ValManager, typename Value = typename ValManager::numeral> template<typename ValManager, typename Value = typename ValManager::numeral>

View file

@ -434,11 +434,11 @@ namespace upolynomial {
m().reset(r[i]); m().reset(r[i]);
} }
for (unsigned i = 0; i < sz; i++) { for (unsigned i = 0; i < sz; i++) {
typename polynomial::monomial * mon = pm.get_monomial(p, i); typename polynomial::monomial * mon = pm.get_monomial(p, i);
if (pm.size(mon) == 0) { if (pm.size(mon) == 0) {
m().set(r[0], pm.coeff(p, i)); m().set(r[0], pm.coeff(p, i));
} else if (pm.size(mon) == 1 && pm.get_var(mon, 0) == x) { } else if (pm.size(mon) == 1 && pm.get_var(mon, 0) == x) {
unsigned m_deg_x = pm.degree(mon, 0); unsigned m_deg_x = pm.degree(mon, 0);
m().set(r[m_deg_x], pm.coeff(p, i)); m().set(r[m_deg_x], pm.coeff(p, i));
} }
} }

View file

@ -86,8 +86,8 @@ void model_core::register_decl(func_decl * d, func_interp * fi) {
void model_core::unregister_decl(func_decl * d) { void model_core::unregister_decl(func_decl * d) {
decl2expr::obj_map_entry * ec = m_interp.find_core(d); decl2expr::obj_map_entry * ec = m_interp.find_core(d);
if (ec && ec->get_data().m_value != 0) { if (ec && ec->get_data().m_value != 0) {
m_manager.dec_ref(ec->get_data().m_key); m_manager.dec_ref(ec->get_data().m_key);
m_manager.dec_ref(ec->get_data().m_value); m_manager.dec_ref(ec->get_data().m_value);
m_interp.remove(d); m_interp.remove(d);
m_const_decls.erase(d); m_const_decls.erase(d);
return; return;

View file

@ -54,7 +54,7 @@ namespace datalog {
MEMOUT, MEMOUT,
INPUT_ERROR, INPUT_ERROR,
APPROX, APPROX,
BOUNDED, BOUNDED,
CANCELED CANCELED
}; };
@ -318,7 +318,7 @@ namespace datalog {
\brief Retrieve predicates \brief Retrieve predicates
*/ */
func_decl_set const& get_predicates() const { return m_preds; } func_decl_set const& get_predicates() const { return m_preds; }
ast_ref_vector const &get_pinned() const {return m_pinned; } ast_ref_vector const &get_pinned() const {return m_pinned; }
bool is_predicate(func_decl* pred) const { return m_preds.contains(pred); } bool is_predicate(func_decl* pred) const { return m_preds.contains(pred); }
bool is_predicate(expr * e) const { return is_app(e) && is_predicate(to_app(e)->get_decl()); } bool is_predicate(expr * e) const { return is_app(e) && is_predicate(to_app(e)->get_decl()); }
@ -534,7 +534,7 @@ namespace datalog {
\brief retrieve proof from derivation of the query. \brief retrieve proof from derivation of the query.
\pre engine == 'pdr' || engine == 'duality'- this option is only supported \pre engine == 'pdr' || engine == 'duality'- this option is only supported
for PDR mode and Duality mode. for PDR mode and Duality mode.
*/ */
proof_ref get_proof(); proof_ref get_proof();

View file

@ -32,7 +32,7 @@ namespace datalog {
QBMC_ENGINE, QBMC_ENGINE,
TAB_ENGINE, TAB_ENGINE,
CLP_ENGINE, CLP_ENGINE,
DUALITY_ENGINE, DUALITY_ENGINE,
DDNF_ENGINE, DDNF_ENGINE,
LAST_ENGINE LAST_ENGINE
}; };

View file

@ -37,7 +37,7 @@ namespace Duality {
class dl_interface : public datalog::engine_base { class dl_interface : public datalog::engine_base {
duality_data *_d; duality_data *_d;
datalog::context &m_ctx; datalog::context &m_ctx;
public: public:
dl_interface(datalog::context& ctx); dl_interface(datalog::context& ctx);
@ -69,7 +69,7 @@ namespace Duality {
proof_ref get_proof(); proof_ref get_proof();
duality_data *dd(){return _d;} duality_data *dd(){return _d;}
private: private:
void display_certificate_non_const(std::ostream& out); void display_certificate_non_const(std::ostream& out);

View file

@ -53,7 +53,7 @@ namespace datalog {
*/ */
class mk_similarity_compressor : public rule_transformer::plugin { class mk_similarity_compressor : public rule_transformer::plugin {
context & m_context; context & m_context;
ast_manager & m_manager; ast_manager & m_manager;
/** number of similar rules necessary for a group to be introduced */ /** number of similar rules necessary for a group to be introduced */
unsigned m_threshold_count; unsigned m_threshold_count;

View file

@ -49,7 +49,7 @@ namespace datalog {
We say that a rule containing C_i's is a rule with a "big tail". We say that a rule containing C_i's is a rule with a "big tail".
*/ */
class mk_simple_joins : public rule_transformer::plugin { class mk_simple_joins : public rule_transformer::plugin {
context & m_context; context & m_context;
rule_manager & rm; rule_manager & rm;
public: public:
mk_simple_joins(context & ctx); mk_simple_joins(context & ctx);

View file

@ -1209,7 +1209,7 @@ namespace qe {
void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml) { void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml) {
expr_map map (m); expr_map map (m);
operator()(mdl, vars, fml, map); operator()(mdl, vars, fml, map);
} }
void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml, expr_map& map) { void operator()(model& mdl, app_ref_vector& vars, expr_ref& fml, expr_map& map) {

View file

@ -93,7 +93,7 @@ namespace datalog {
typedef obj_map<func_decl, adornment> pred_adornment_map; typedef obj_map<func_decl, adornment> pred_adornment_map;
typedef obj_map<func_decl, func_decl *> pred2pred; typedef obj_map<func_decl, func_decl *> pred2pred;
context & m_context; context & m_context;
ast_manager & m; ast_manager & m;
rule_manager& rm; rule_manager& rm;
ast_ref_vector m_pinned; ast_ref_vector m_pinned;

View file

@ -50,7 +50,7 @@ namespace datalog {
typedef hashtable<c_info, c_info_hash, default_eq<c_info> > in_progress_table; typedef hashtable<c_info, c_info_hash, default_eq<c_info> > in_progress_table;
typedef svector<c_info> todo_stack; typedef svector<c_info> todo_stack;
context & m_context; context & m_context;
ast_manager & m; ast_manager & m;
rule_manager & rm; rule_manager & rm;
rule_ref_vector m_rules; rule_ref_vector m_rules;

View file

@ -956,8 +956,8 @@ public:
} }
void get_neighbours_undirected(dl_var current, svector<dl_var> & neighbours) { void get_neighbours_undirected(dl_var current, svector<dl_var> & neighbours) {
neighbours.reset(); neighbours.reset();
edge_id_vector & out_edges = m_out_edges[current]; edge_id_vector & out_edges = m_out_edges[current];
typename edge_id_vector::iterator it = out_edges.begin(), end = out_edges.end(); typename edge_id_vector::iterator it = out_edges.begin(), end = out_edges.end();
for (; it != end; ++it) { for (; it != end; ++it) {
edge_id e_id = *it; edge_id e_id = *it;
@ -968,7 +968,7 @@ public:
} }
edge_id_vector & in_edges = m_in_edges[current]; edge_id_vector & in_edges = m_in_edges[current];
typename edge_id_vector::iterator it2 = in_edges.begin(), end2 = in_edges.end(); typename edge_id_vector::iterator it2 = in_edges.begin(), end2 = in_edges.end();
for (; it2 != end2; ++it2) { for (; it2 != end2; ++it2) {
edge_id e_id = *it2; edge_id e_id = *it2;
edge & e = m_edges[e_id]; edge & e = m_edges[e_id];
SASSERT(e.get_target() == current); SASSERT(e.get_target() == current);
@ -980,19 +980,19 @@ public:
void dfs_undirected(dl_var start, svector<dl_var> & threads) { void dfs_undirected(dl_var start, svector<dl_var> & threads) {
threads.reset(); threads.reset();
threads.resize(get_num_nodes()); threads.resize(get_num_nodes());
uint_set discovered, explored; uint_set discovered, explored;
svector<dl_var> nodes; svector<dl_var> nodes;
discovered.insert(start); discovered.insert(start);
nodes.push_back(start); nodes.push_back(start);
dl_var prev = start; dl_var prev = start;
while(!nodes.empty()) { while(!nodes.empty()) {
dl_var current = nodes.back(); dl_var current = nodes.back();
SASSERT(discovered.contains(current) && !explored.contains(current)); SASSERT(discovered.contains(current) && !explored.contains(current));
svector<dl_var> neighbours; svector<dl_var> neighbours;
get_neighbours_undirected(current, neighbours); get_neighbours_undirected(current, neighbours);
SASSERT(!neighbours.empty()); SASSERT(!neighbours.empty());
bool found = false; bool found = false;
for (unsigned i = 0; i < neighbours.size(); ++i) { for (unsigned i = 0; i < neighbours.size(); ++i) {
dl_var next = neighbours[i]; dl_var next = neighbours[i];
DEBUG_CODE( DEBUG_CODE(
edge_id id; edge_id id;
@ -1002,18 +1002,18 @@ public:
threads[prev] = next; threads[prev] = next;
prev = next; prev = next;
discovered.insert(next); discovered.insert(next);
nodes.push_back(next); nodes.push_back(next);
found = true; found = true;
break; break;
} }
} }
SASSERT(!nodes.empty()); SASSERT(!nodes.empty());
if (!found) { if (!found) {
explored.insert(current); explored.insert(current);
nodes.pop_back(); nodes.pop_back();
} }
} }
threads[prev] = start; threads[prev] = start;
} }
void bfs_undirected(dl_var start, svector<dl_var> & parents, svector<dl_var> & depths) { void bfs_undirected(dl_var start, svector<dl_var> & parents, svector<dl_var> & depths) {
@ -1022,31 +1022,31 @@ public:
parents[start] = -1; parents[start] = -1;
depths.reset(); depths.reset();
depths.resize(get_num_nodes()); depths.resize(get_num_nodes());
uint_set visited; uint_set visited;
std::deque<dl_var> nodes; std::deque<dl_var> nodes;
visited.insert(start); visited.insert(start);
nodes.push_front(start); nodes.push_front(start);
while(!nodes.empty()) { while(!nodes.empty()) {
dl_var current = nodes.back(); dl_var current = nodes.back();
nodes.pop_back(); nodes.pop_back();
SASSERT(visited.contains(current)); SASSERT(visited.contains(current));
svector<dl_var> neighbours; svector<dl_var> neighbours;
get_neighbours_undirected(current, neighbours); get_neighbours_undirected(current, neighbours);
SASSERT(!neighbours.empty()); SASSERT(!neighbours.empty());
for (unsigned i = 0; i < neighbours.size(); ++i) { for (unsigned i = 0; i < neighbours.size(); ++i) {
dl_var next = neighbours[i]; dl_var next = neighbours[i];
DEBUG_CODE( DEBUG_CODE(
edge_id id; edge_id id;
SASSERT(get_edge_id(current, next, id) || get_edge_id(next, current, id));); SASSERT(get_edge_id(current, next, id) || get_edge_id(next, current, id)););
if (!visited.contains(next)) { if (!visited.contains(next)) {
TRACE("diff_logic", tout << "parents[" << next << "] --> " << current << std::endl;); TRACE("diff_logic", tout << "parents[" << next << "] --> " << current << std::endl;);
parents[next] = current; parents[next] = current;
depths[next] = depths[current] + 1; depths[next] = depths[current] + 1;
visited.insert(next); visited.insert(next);
nodes.push_front(next); nodes.push_front(next);
} }
} }
} }
} }
template<typename Functor> template<typename Functor>

View file

@ -40,10 +40,10 @@ namespace smt {
/** \ brief Use sparse maps in SMT solver. /** \ brief Use sparse maps in SMT solver.
Define this to use hash maps rather than vectors over ast Define this to use hash maps rather than vectors over ast
nodes. This is useful in the case there are many solvers, each nodes. This is useful in the case there are many solvers, each
referencing few nodes from a large ast manager. There is some referencing few nodes from a large ast manager. There is some
unknown performance penalty for this. */ unknown performance penalty for this. */
// #define SPARSE_MAP // #define SPARSE_MAP

View file

@ -149,7 +149,7 @@ namespace smt {
/** /**
\brief Is "model based" instantiate allowed to instantiate this quantifier? \brief Is "model based" instantiate allowed to instantiate this quantifier?
*/ */
virtual bool mbqi_enabled(quantifier *q) const {return true;} virtual bool mbqi_enabled(quantifier *q) const {return true;}
/** /**
\brief Give a change to the plugin to adjust the interpretation of unintepreted functions. \brief Give a change to the plugin to adjust the interpretation of unintepreted functions.

View file

@ -45,7 +45,7 @@ namespace smt {
typedef trail_stack<theory_seq> th_trail_stack; typedef trail_stack<theory_seq> th_trail_stack;
typedef std::pair<expr*, dependency*> expr_dep; typedef std::pair<expr*, dependency*> expr_dep;
typedef obj_map<expr, expr_dep> eqdep_map_t; typedef obj_map<expr, expr_dep> eqdep_map_t;
typedef union_find<theory_seq> th_union_find; typedef union_find<theory_seq> th_union_find;
class seq_value_proc; class seq_value_proc;
@ -299,7 +299,7 @@ namespace smt {
scoped_vector<ne> m_nqs; // set of current disequalities. scoped_vector<ne> m_nqs; // set of current disequalities.
scoped_vector<nc> m_ncs; // set of non-contains constraints. scoped_vector<nc> m_ncs; // set of non-contains constraints.
unsigned m_eq_id; unsigned m_eq_id;
th_union_find m_find; th_union_find m_find;
seq_factory* m_factory; // value factory seq_factory* m_factory; // value factory
exclusion_table m_exclude; // set of asserted disequalities. exclusion_table m_exclude; // set of asserted disequalities.
@ -584,7 +584,7 @@ namespace smt {
// model building // model building
app* mk_value(app* a); app* mk_value(app* a);
th_trail_stack& get_trail_stack() { return m_trail_stack; } th_trail_stack& get_trail_stack() { return m_trail_stack; }
void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2) {} void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2) {}
void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) { } void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) { }
void unmerge_eh(theory_var v1, theory_var v2) {} void unmerge_eh(theory_var v1, theory_var v2) {}

View file

@ -4748,10 +4748,10 @@ namespace smt {
context& ctx = get_context(); context& ctx = get_context();
ast_manager & m = get_manager(); ast_manager & m = get_manager();
// safety // safety
if (!ctx.e_internalized(e)) { if (!ctx.e_internalized(e)) {
return false; return false;
} }
// if an integer constant exists in the eqc, it should be the root // if an integer constant exists in the eqc, it should be the root
enode * en_e = ctx.get_enode(e); enode * en_e = ctx.get_enode(e);
@ -7028,7 +7028,7 @@ namespace smt {
ast_manager & m = get_manager(); ast_manager & m = get_manager();
if (lenTester_fvar_map.contains(lenTester)) { if (lenTester_fvar_map.contains(lenTester)) {
expr * fVar = lenTester_fvar_map[lenTester]; expr * fVar = lenTester_fvar_map[lenTester];
expr_ref toAssert(gen_len_val_options_for_free_var(fVar, lenTester, lenTesterValue), m); expr_ref toAssert(gen_len_val_options_for_free_var(fVar, lenTester, lenTesterValue), m);
TRACE("str", tout << "asserting more length tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;); TRACE("str", tout << "asserting more length tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;);
if (toAssert) { if (toAssert) {
assert_axiom(toAssert); assert_axiom(toAssert);

View file

@ -36,10 +36,10 @@ namespace smt {
void watch_list::expand() { void watch_list::expand() {
if (m_data == 0) { if (m_data == 0) {
unsigned size = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE; unsigned size = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE;
unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, size)); unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, size));
#ifdef _AMD64_ #ifdef _AMD64_
++mem; // make sure data is aligned in 64 bit machines ++mem; // make sure data is aligned in 64 bit machines
#endif #endif
*mem = 0; *mem = 0;
++mem; ++mem;
@ -62,9 +62,9 @@ namespace smt {
unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, new_capacity + HEADER_SIZE)); unsigned * mem = reinterpret_cast<unsigned*>(alloc_svect(char, new_capacity + HEADER_SIZE));
unsigned curr_end_cls = end_cls_core(); unsigned curr_end_cls = end_cls_core();
#ifdef _AMD64_ #ifdef _AMD64_
++mem; // make sure data is aligned in 64 bit machines ++mem; // make sure data is aligned in 64 bit machines
#endif #endif
*mem = curr_end_cls; *mem = curr_end_cls;
++mem; ++mem;
SASSERT(bin_bytes <= new_capacity); SASSERT(bin_bytes <= new_capacity);
unsigned new_begin_bin = new_capacity - bin_bytes; unsigned new_begin_bin = new_capacity - bin_bytes;

View file

@ -68,7 +68,7 @@ private:
typedef obj_map<expr, value_score> scores_type; typedef obj_map<expr, value_score> scores_type;
typedef obj_map<expr, ptr_vector<expr> > uplinks_type; typedef obj_map<expr, ptr_vector<expr> > uplinks_type;
typedef obj_map<expr, ptr_vector<func_decl> > occ_type; typedef obj_map<expr, ptr_vector<func_decl> > occ_type;
obj_hashtable<expr> m_top_expr; obj_hashtable<expr> m_top_expr;
scores_type m_scores; scores_type m_scores;
uplinks_type m_uplinks; uplinks_type m_uplinks;
entry_point_type m_entry_points; entry_point_type m_entry_points;
@ -85,11 +85,11 @@ private:
unsigned m_touched; unsigned m_touched;
double m_scale_unsat; double m_scale_unsat;
unsigned m_paws_init; unsigned m_paws_init;
obj_map<expr, unsigned> m_where_false; obj_map<expr, unsigned> m_where_false;
expr** m_list_false; expr** m_list_false;
unsigned m_track_unsat; unsigned m_track_unsat;
obj_map<expr, unsigned> m_weights; obj_map<expr, unsigned> m_weights;
double m_top_sum; double m_top_sum;
obj_hashtable<expr> m_temp_seen; obj_hashtable<expr> m_temp_seen;
public: public:
@ -450,7 +450,7 @@ public:
m_list_false = new expr*[sz]; m_list_false = new expr*[sz];
for (unsigned i = 0; i < sz; i++) for (unsigned i = 0; i < sz; i++)
{ {
if (m_mpz_manager.eq(get_value(as[i]), m_zero)) if (m_mpz_manager.eq(get_value(as[i]), m_zero))
break_assertion(as[i]); break_assertion(as[i]);
} }
} }
@ -462,7 +462,7 @@ public:
// initialize weights // initialize weights
if (!m_weights.contains(e)) if (!m_weights.contains(e))
m_weights.insert(e, m_paws_init); m_weights.insert(e, m_paws_init);
// positive/negative occurrences used for early pruning // positive/negative occurrences used for early pruning
setup_occs(as[i]); setup_occs(as[i]);

View file

@ -27,36 +27,36 @@ static void tst1() {
unsigned n = rand()%10000; unsigned n = rand()%10000;
for (unsigned i = 0; i < n; i++) { for (unsigned i = 0; i < n; i++) {
int op = rand()%6; int op = rand()%6;
if (op <= 1) { if (op <= 1) {
bool val = (rand()%2) != 0; bool val = (rand()%2) != 0;
v1.push_back(val); v1.push_back(val);
v2.push_back(val); v2.push_back(val);
ENSURE(v1.size() == v2.size()); ENSURE(v1.size() == v2.size());
} }
else if (op <= 3) { else if (op <= 3) {
ENSURE(v1.size() == v2.size()); ENSURE(v1.size() == v2.size());
if (v1.size() > 0) { if (v1.size() > 0) {
bool val = (rand()%2) != 0; bool val = (rand()%2) != 0;
unsigned idx = rand()%v1.size(); unsigned idx = rand()%v1.size();
ENSURE(v1.get(idx) == v2[idx]); ENSURE(v1.get(idx) == v2[idx]);
v1.set(idx, val); v1.set(idx, val);
v2[idx] = val; v2[idx] = val;
ENSURE(v1.get(idx) == v2[idx]); ENSURE(v1.get(idx) == v2[idx]);
} }
} }
else if (op <= 4) { else if (op <= 4) {
ENSURE(v1.size() == v2.size()); ENSURE(v1.size() == v2.size());
if (v1.size() > 0) { if (v1.size() > 0) {
unsigned idx = rand()%v1.size(); unsigned idx = rand()%v1.size();
VERIFY(v1.get(idx) == v2[idx]); VERIFY(v1.get(idx) == v2[idx]);
} }
} }
else if (op <= 5) { else if (op <= 5) {
ENSURE(v1.size() == v2.size()); ENSURE(v1.size() == v2.size());
for (unsigned j = 0; j < v1.size(); j++) { for (unsigned j = 0; j < v1.size(); j++) {
ENSURE(v1.get(j) == v2[j]); ENSURE(v1.get(j) == v2[j]);
} }
} }
} }
} }
@ -309,6 +309,6 @@ void tst_bit_vector() {
tst2(); tst2();
for (unsigned i = 0; i < 20; i++) { for (unsigned i = 0; i < 20; i++) {
std::cerr << i << std::endl; std::cerr << i << std::endl;
tst1(); tst1();
} }
} }

View file

@ -33,7 +33,7 @@ template class dl_graph<diff_logic_ext>;
typedef dl_graph<diff_logic_ext> dlg; typedef dl_graph<diff_logic_ext> dlg;
struct tst_dl_functor { struct tst_dl_functor {
smt::literal_vector m_literals; smt::literal_vector m_literals;
void operator()(smt::literal l) { void operator()(smt::literal l) {
m_literals.push_back(l); m_literals.push_back(l);
} }

View file

@ -98,8 +98,8 @@ void tst_expr_rand(char** argv, int argc, int& i) {
i += 1; i += 1;
if (i + 1 < argc && 0 == strncmp(argv[i+1],"/rs:",3)) { if (i + 1 < argc && 0 == strncmp(argv[i+1],"/rs:",3)) {
rand_seed = atol(argv[i+1]+4); rand_seed = atol(argv[i+1]+4);
std::cout << "random seed:" << rand_seed << "\n"; std::cout << "random seed:" << rand_seed << "\n";
i += 1; i += 1;
} }
if (i + 1 < argc && 0 == strcmp(argv[i+1],"/arith")) { if (i + 1 < argc && 0 == strcmp(argv[i+1],"/arith")) {

View file

@ -16,20 +16,20 @@
// and print "PASS" to indicate success. // and print "PASS" to indicate success.
// //
#define TST(MODULE) { \ #define TST(MODULE) { \
std::string s("test "); \ std::string s("test "); \
s += #MODULE; \ s += #MODULE; \
void tst_##MODULE(); \ void tst_##MODULE(); \
if (do_display_usage) \ if (do_display_usage) \
std::cout << #MODULE << "\n"; \ std::cout << #MODULE << "\n"; \
for (int i = 0; i < argc; i++) \ for (int i = 0; i < argc; i++) \
if (test_all || strcmp(argv[i], #MODULE) == 0) { \ if (test_all || strcmp(argv[i], #MODULE) == 0) { \
enable_trace(#MODULE); \ enable_trace(#MODULE); \
enable_debug(#MODULE); \ enable_debug(#MODULE); \
timeit timeit(true, s.c_str()); \ timeit timeit(true, s.c_str()); \
tst_##MODULE(); \ tst_##MODULE(); \
std::cout << "PASS" << std::endl; \ std::cout << "PASS" << std::endl; \
} \ } \
} }
#define TST_ARGV(MODULE) { \ #define TST_ARGV(MODULE) { \
@ -39,13 +39,13 @@
if (do_display_usage) \ if (do_display_usage) \
std::cout << #MODULE << "\n"; \ std::cout << #MODULE << "\n"; \
for (int i = 0; i < argc; i++) \ for (int i = 0; i < argc; i++) \
if (strcmp(argv[i], #MODULE) == 0) { \ if (strcmp(argv[i], #MODULE) == 0) { \
enable_trace(#MODULE); \ enable_trace(#MODULE); \
enable_debug(#MODULE); \ enable_debug(#MODULE); \
timeit timeit(true, s.c_str()); \ timeit timeit(true, s.c_str()); \
tst_##MODULE(argv, argc, i); \ tst_##MODULE(argv, argc, i); \
std::cout << "PASS" << std::endl; \ std::cout << "PASS" << std::endl; \
} \ } \
} }
void error(const char * msg) { void error(const char * msg) {
@ -76,49 +76,49 @@ void display_usage() {
void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& test_all) { void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& test_all) {
int i = 1; int i = 1;
while (i < argc) { while (i < argc) {
char * arg = argv[i], *eq_pos = 0; char * arg = argv[i], *eq_pos = 0;
if (arg[0] == '-' || arg[0] == '/') { if (arg[0] == '-' || arg[0] == '/') {
char * opt_name = arg + 1; char * opt_name = arg + 1;
char * opt_arg = 0; char * opt_arg = 0;
char * colon = strchr(arg, ':'); char * colon = strchr(arg, ':');
if (colon) { if (colon) {
opt_arg = colon + 1; opt_arg = colon + 1;
*colon = 0; *colon = 0;
} }
if (strcmp(opt_name, "h") == 0 || if (strcmp(opt_name, "h") == 0 ||
strcmp(opt_name, "?") == 0) { strcmp(opt_name, "?") == 0) {
display_usage(); display_usage();
do_display_usage = true; do_display_usage = true;
return; return;
} }
else if (strcmp(opt_name, "v") == 0) { else if (strcmp(opt_name, "v") == 0) {
if (!opt_arg) if (!opt_arg)
error("option argument (/v:level) is missing."); error("option argument (/v:level) is missing.");
long lvl = strtol(opt_arg, 0, 10); long lvl = strtol(opt_arg, 0, 10);
set_verbosity_level(lvl); set_verbosity_level(lvl);
} }
else if (strcmp(opt_name, "w") == 0) { else if (strcmp(opt_name, "w") == 0) {
enable_warning_messages(true); enable_warning_messages(true);
} }
else if (strcmp(opt_name, "a") == 0) { else if (strcmp(opt_name, "a") == 0) {
test_all = true; test_all = true;
} }
#ifdef _TRACE #ifdef _TRACE
else if (strcmp(opt_name, "tr") == 0) { else if (strcmp(opt_name, "tr") == 0) {
if (!opt_arg) if (!opt_arg)
error("option argument (/tr:tag) is missing."); error("option argument (/tr:tag) is missing.");
enable_trace(opt_arg); enable_trace(opt_arg);
} }
#endif #endif
#ifdef Z3DEBUG #ifdef Z3DEBUG
else if (strcmp(opt_name, "dbg") == 0) { else if (strcmp(opt_name, "dbg") == 0) {
if (!opt_arg) if (!opt_arg)
error("option argument (/dbg:tag) is missing."); error("option argument (/dbg:tag) is missing.");
enable_debug(opt_arg); enable_debug(opt_arg);
} }
#endif #endif
} }
else if (arg[0] != '"' && (eq_pos = strchr(arg, '='))) { else if (arg[0] != '"' && (eq_pos = strchr(arg, '='))) {
char * key = arg; char * key = arg;
*eq_pos = 0; *eq_pos = 0;
@ -130,7 +130,7 @@ void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& t
std::cerr << ex.msg() << "\n"; std::cerr << ex.msg() << "\n";
} }
} }
i++; i++;
} }
} }

View file

@ -54,7 +54,7 @@ static void add_random_ineq(opt::model_based_opt& mbo,
continue; continue;
} }
unsigned sign = r(2); unsigned sign = r(2);
coeff = sign == 0 ? coeff : -coeff; coeff = sign == 0 ? coeff : -coeff;
vars.push_back(var(x, rational(coeff))); vars.push_back(var(x, rational(coeff)));
value += coeff*values[x]; value += coeff*values[x];
} }

View file

@ -36,11 +36,11 @@ struct OptFoo {
int m_y; int m_y;
OptFoo(int x, int y):m_x(x), m_y(y) { OptFoo(int x, int y):m_x(x), m_y(y) {
TRACE("optional", tout << "OptFoo created: " << m_x << " : " << m_y << "\n";); TRACE("optional", tout << "OptFoo created: " << m_x << " : " << m_y << "\n";);
} }
~OptFoo() { ~OptFoo() {
TRACE("optional", tout << "OptFoo deleted: " << m_x << " : " << m_y << "\n";); TRACE("optional", tout << "OptFoo deleted: " << m_x << " : " << m_y << "\n";);
} }
}; };

View file

@ -201,7 +201,7 @@ public:
m_todo.push_back(d); m_todo.push_back(d);
unsigned qhead = 0; unsigned qhead = 0;
while (qhead < m_todo.size()) { while (qhead < m_todo.size()) {
d = m_todo[qhead]; d = m_todo[qhead];
qhead++; qhead++;
if (d->is_leaf()) { if (d->is_leaf()) {
vs.push_back(to_leaf(d)->m_value); vs.push_back(to_leaf(d)->m_value);

View file

@ -236,7 +236,7 @@ template<typename T>
struct ptr_hash { struct ptr_hash {
typedef T * data; typedef T * data;
unsigned operator()(T * ptr) const { unsigned operator()(T * ptr) const {
return get_ptr_hash(ptr); return get_ptr_hash(ptr);
} }
}; };

View file

@ -119,12 +119,12 @@ class inf_eps_rational {
bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); } bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); }
int64 get_int64() const { int64 get_int64() const {
SASSERT(is_int64()); SASSERT(is_int64());
return m_r.get_int64(); return m_r.get_int64();
} }
uint64 get_uint64() const { uint64 get_uint64() const {
SASSERT(is_uint64()); SASSERT(is_uint64());
return m_r.get_uint64(); return m_r.get_uint64();
} }
@ -168,45 +168,45 @@ class inf_eps_rational {
inf_eps_rational & operator=(const inf_eps_rational & r) { inf_eps_rational & operator=(const inf_eps_rational & r) {
m_infty = r.m_infty; m_infty = r.m_infty;
m_r = r.m_r; m_r = r.m_r;
return *this; return *this;
} }
inf_eps_rational & operator=(const Numeral & r) { inf_eps_rational & operator=(const Numeral & r) {
m_infty.reset(); m_infty.reset();
m_r = r; m_r = r;
return *this; return *this;
} }
inf_eps_rational & operator+=(const inf_eps_rational & r) { inf_eps_rational & operator+=(const inf_eps_rational & r) {
m_infty += r.m_infty; m_infty += r.m_infty;
m_r += r.m_r; m_r += r.m_r;
return *this; return *this;
} }
inf_eps_rational & operator-=(const inf_eps_rational & r) { inf_eps_rational & operator-=(const inf_eps_rational & r) {
m_infty -= r.m_infty; m_infty -= r.m_infty;
m_r -= r.m_r; m_r -= r.m_r;
return *this; return *this;
} }
inf_eps_rational & operator-=(const inf_rational & r) { inf_eps_rational & operator-=(const inf_rational & r) {
m_r -= r; m_r -= r;
return *this; return *this;
} }
inf_eps_rational & operator+=(const inf_rational & r) { inf_eps_rational & operator+=(const inf_rational & r) {
m_r += r; m_r += r;
return *this; return *this;
} }
inf_eps_rational & operator+=(const rational & r) { inf_eps_rational & operator+=(const rational & r) {
m_r += r; m_r += r;
return *this; return *this;
} }
inf_eps_rational & operator-=(const rational & r) { inf_eps_rational & operator-=(const rational & r) {
m_r -= r; m_r -= r;
return *this; return *this;
} }
inf_eps_rational & operator*=(const rational & r1) { inf_eps_rational & operator*=(const rational & r1) {

View file

@ -110,12 +110,12 @@ class inf_int_rational {
bool is_rational() const { return m_second == 0; } bool is_rational() const { return m_second == 0; }
int64 get_int64() const { int64 get_int64() const {
SASSERT(is_int64()); SASSERT(is_int64());
return m_first.get_int64(); return m_first.get_int64();
} }
uint64 get_uint64() const { uint64 get_uint64() const {
SASSERT(is_uint64()); SASSERT(is_uint64());
return m_first.get_uint64(); return m_first.get_uint64();
} }
@ -132,7 +132,7 @@ class inf_int_rational {
inf_int_rational & operator=(const inf_int_rational & r) { inf_int_rational & operator=(const inf_int_rational & r) {
m_first = r.m_first; m_first = r.m_first;
m_second = r.m_second; m_second = r.m_second;
return *this; return *this;
} }
inf_int_rational & operator=(const rational & r) { inf_int_rational & operator=(const rational & r) {
@ -154,7 +154,7 @@ class inf_int_rational {
inf_int_rational & operator+=(const inf_int_rational & r) { inf_int_rational & operator+=(const inf_int_rational & r) {
m_first += r.m_first; m_first += r.m_first;
m_second += r.m_second; m_second += r.m_second;
return *this; return *this;
} }
inf_int_rational & operator*=(const rational & r) { inf_int_rational & operator*=(const rational & r) {
@ -163,7 +163,7 @@ class inf_int_rational {
} }
m_first *= r; m_first *= r;
m_second *= r.get_int32(); m_second *= r.get_int32();
return *this; return *this;
} }
@ -171,17 +171,17 @@ class inf_int_rational {
inf_int_rational & operator-=(const inf_int_rational & r) { inf_int_rational & operator-=(const inf_int_rational & r) {
m_first -= r.m_first; m_first -= r.m_first;
m_second -= r.m_second; m_second -= r.m_second;
return *this; return *this;
} }
inf_int_rational & operator+=(const rational & r) { inf_int_rational & operator+=(const rational & r) {
m_first += r; m_first += r;
return *this; return *this;
} }
inf_int_rational & operator-=(const rational & r) { inf_int_rational & operator-=(const rational & r) {
m_first -= r; m_first -= r;
return *this; return *this;
} }
inf_int_rational & operator++() { inf_int_rational & operator++() {

View file

@ -123,12 +123,12 @@ class inf_rational {
bool is_rational() const { return m_second.is_zero(); } bool is_rational() const { return m_second.is_zero(); }
int64 get_int64() const { int64 get_int64() const {
SASSERT(is_int64()); SASSERT(is_int64());
return m_first.get_int64(); return m_first.get_int64();
} }
uint64 get_uint64() const { uint64 get_uint64() const {
SASSERT(is_uint64()); SASSERT(is_uint64());
return m_first.get_uint64(); return m_first.get_uint64();
} }
@ -145,7 +145,7 @@ class inf_rational {
inf_rational & operator=(const inf_rational & r) { inf_rational & operator=(const inf_rational & r) {
m_first = r.m_first; m_first = r.m_first;
m_second = r.m_second; m_second = r.m_second;
return *this; return *this;
} }
inf_rational & operator=(const rational & r) { inf_rational & operator=(const rational & r) {
@ -167,23 +167,23 @@ class inf_rational {
inf_rational & operator+=(const inf_rational & r) { inf_rational & operator+=(const inf_rational & r) {
m_first += r.m_first; m_first += r.m_first;
m_second += r.m_second; m_second += r.m_second;
return *this; return *this;
} }
inf_rational & operator-=(const inf_rational & r) { inf_rational & operator-=(const inf_rational & r) {
m_first -= r.m_first; m_first -= r.m_first;
m_second -= r.m_second; m_second -= r.m_second;
return *this; return *this;
} }
inf_rational & operator+=(const rational & r) { inf_rational & operator+=(const rational & r) {
m_first += r; m_first += r;
return *this; return *this;
} }
inf_rational & operator-=(const rational & r) { inf_rational & operator-=(const rational & r) {
m_first -= r; m_first -= r;
return *this; return *this;
} }
inf_rational & operator*=(const rational & r1) { inf_rational & operator*=(const rational & r1) {

View file

@ -67,7 +67,7 @@ class inf_s_integer {
inf_s_integer & operator=(const inf_s_integer & r) { inf_s_integer & operator=(const inf_s_integer & r) {
m_first = r.m_first; m_first = r.m_first;
m_second = r.m_second; m_second = r.m_second;
return *this; return *this;
} }
inf_s_integer & operator=(const rational & r) { inf_s_integer & operator=(const rational & r) {
m_first = static_cast<int>(r.get_int64()); m_first = static_cast<int>(r.get_int64());
@ -90,20 +90,20 @@ class inf_s_integer {
inf_s_integer & operator+=(const inf_s_integer & r) { inf_s_integer & operator+=(const inf_s_integer & r) {
m_first += r.m_first; m_first += r.m_first;
m_second += r.m_second; m_second += r.m_second;
return *this; return *this;
} }
inf_s_integer & operator-=(const inf_s_integer & r) { inf_s_integer & operator-=(const inf_s_integer & r) {
m_first -= r.m_first; m_first -= r.m_first;
m_second -= r.m_second; m_second -= r.m_second;
return *this; return *this;
} }
inf_s_integer & operator+=(const s_integer & r) { inf_s_integer & operator+=(const s_integer & r) {
m_first += r.get_int(); m_first += r.get_int();
return *this; return *this;
} }
inf_s_integer & operator-=(const s_integer & r) { inf_s_integer & operator-=(const s_integer & r) {
m_first -= r.get_int(); m_first -= r.get_int();
return *this; return *this;
} }
inf_s_integer & operator*=(const s_integer & r1) { inf_s_integer & operator*=(const s_integer & r1) {
m_first *= r1.get_int(); m_first *= r1.get_int();

View file

@ -114,22 +114,22 @@ public :
} }
return a * lb(j).x; return a * lb(j).x;
} }
mpq monoid_max(const mpq & a, unsigned j, bool & strict) const { mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
if (is_pos(a)) { if (is_pos(a)) {
strict = !is_zero(ub(j).y); strict = !is_zero(ub(j).y);
return a * ub(j).x; return a * ub(j).x;
} }
strict = !is_zero(lb(j).y); strict = !is_zero(lb(j).y);
return a * lb(j).x; return a * lb(j).x;
} }
const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const { const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
if (!a_is_pos) { if (!a_is_pos) {
strict = !is_zero(ub(j).y); strict = !is_zero(ub(j).y);
return ub(j).x; return ub(j).x;
} }
strict = !is_zero(lb(j).y); strict = !is_zero(lb(j).y);
return lb(j).x; return lb(j).x;
} }
mpq monoid_min(const mpq & a, unsigned j, bool& strict) const { mpq monoid_min(const mpq & a, unsigned j, bool& strict) const {
if (is_neg(a)) { if (is_neg(a)) {
@ -166,7 +166,7 @@ public :
m_it.reset(); m_it.reset();
while (m_it.next(a, j)) { while (m_it.next(a, j)) {
bool str; bool str;
bool a_is_pos = is_pos(a); bool a_is_pos = is_pos(a);
mpq bound = total / a + monoid_min_no_mult(a_is_pos, j, str); mpq bound = total / a + monoid_min_no_mult(a_is_pos, j, str);
if (a_is_pos) { if (a_is_pos) {
limit_j(j, bound, true, false, strict - static_cast<int>(str) > 0); limit_j(j, bound, true, false, strict - static_cast<int>(str) > 0);
@ -192,8 +192,8 @@ public :
m_it.reset(); m_it.reset();
while (m_it.next(a, j)) { while (m_it.next(a, j)) {
bool str; bool str;
bool a_is_pos = is_pos(a); bool a_is_pos = is_pos(a);
mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str); mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
bool astrict = strict - static_cast<int>(str) > 0; bool astrict = strict - static_cast<int>(str) > 0;
if (a_is_pos) { if (a_is_pos) {
limit_j(j, bound, true, true, astrict); limit_j(j, bound, true, true, astrict);

View file

@ -123,7 +123,7 @@ void add_row_for_term(const lar_term * term, unsigned term_ext_index) {
void add_row_from_term_no_constraint(const lar_term * term, unsigned term_ext_index) { void add_row_from_term_no_constraint(const lar_term * term, unsigned term_ext_index) {
register_new_ext_var_index(term_ext_index); register_new_ext_var_index(term_ext_index);
// j will be a new variable // j will be a new variable
unsigned j = A_r().column_count(); unsigned j = A_r().column_count();
ul_pair ul(j); ul_pair ul(j);
m_vars_to_ul_pairs.push_back(ul); m_vars_to_ul_pairs.push_back(ul);
add_basic_var_to_core_fields(); add_basic_var_to_core_fields();
@ -152,7 +152,7 @@ void add_basic_var_to_core_fields() {
} }
constraint_index add_var_bound(var_index j, lconstraint_kind kind, const mpq & right_side) { constraint_index add_var_bound(var_index j, lconstraint_kind kind, const mpq & right_side) {
constraint_index ci = m_constraints.size(); constraint_index ci = m_constraints.size();
if (!is_term(j)) { // j is a var if (!is_term(j)) { // j is a var
auto vc = new lar_var_constraint(j, kind, right_side); auto vc = new lar_var_constraint(j, kind, right_side);
m_constraints.push_back(vc); m_constraints.push_back(vc);
@ -212,8 +212,8 @@ void add_constraint_from_term_and_create_new_column_row(unsigned term_j, const l
} }
void decide_on_strategy_and_adjust_initial_state() { void decide_on_strategy_and_adjust_initial_state() {
lean_assert(strategy_is_undecided()); lean_assert(strategy_is_undecided());
if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) { if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) {
m_settings.simplex_strategy() = simplex_strategy_enum::lu; m_settings.simplex_strategy() = simplex_strategy_enum::lu;
} else { } else {
m_settings.simplex_strategy() = simplex_strategy_enum::tableau_rows; // todo: when to switch to tableau_costs? m_settings.simplex_strategy() = simplex_strategy_enum::tableau_rows; // todo: when to switch to tableau_costs?
@ -239,14 +239,14 @@ void adjust_initial_state() {
void adjust_initial_state_for_lu() { void adjust_initial_state_for_lu() {
copy_from_mpq_matrix(A_d()); copy_from_mpq_matrix(A_d());
unsigned n = A_d().column_count(); unsigned n = A_d().column_count();
m_mpq_lar_core_solver.m_d_x.resize(n); m_mpq_lar_core_solver.m_d_x.resize(n);
m_mpq_lar_core_solver.m_d_low_bounds.resize(n); m_mpq_lar_core_solver.m_d_low_bounds.resize(n);
m_mpq_lar_core_solver.m_d_upper_bounds.resize(n); m_mpq_lar_core_solver.m_d_upper_bounds.resize(n);
m_mpq_lar_core_solver.m_d_heading = m_mpq_lar_core_solver.m_r_heading; m_mpq_lar_core_solver.m_d_heading = m_mpq_lar_core_solver.m_r_heading;
m_mpq_lar_core_solver.m_d_basis = m_mpq_lar_core_solver.m_r_basis; m_mpq_lar_core_solver.m_d_basis = m_mpq_lar_core_solver.m_r_basis;
/* /*
unsigned j = A_d().column_count(); unsigned j = A_d().column_count();
A_d().add_column(); A_d().add_column();
lean_assert(m_mpq_lar_core_solver.m_d_x.size() == j); lean_assert(m_mpq_lar_core_solver.m_d_x.size() == j);

View file

@ -550,7 +550,7 @@ public:
lean_assert(m_r_solver.m_basis_heading[leaving] >= 0); lean_assert(m_r_solver.m_basis_heading[leaving] >= 0);
m_r_solver.change_basis_unconditionally(entering, leaving); m_r_solver.change_basis_unconditionally(entering, leaving);
if(!m_r_solver.pivot_column_tableau(entering, m_r_solver.m_basis_heading[entering])) { if(!m_r_solver.pivot_column_tableau(entering, m_r_solver.m_basis_heading[entering])) {
// unroll the last step // unroll the last step
m_r_solver.change_basis_unconditionally(leaving, entering); m_r_solver.change_basis_unconditionally(leaving, entering);
#ifdef LEAN_DEBUG #ifdef LEAN_DEBUG
bool t = bool t =

View file

@ -380,8 +380,8 @@ public:
bool term_is_used_as_row(unsigned term) const { bool term_is_used_as_row(unsigned term) const {
lean_assert(is_term(term)); lean_assert(is_term(term));
return contains(m_ext_vars_to_columns, term); return contains(m_ext_vars_to_columns, term);
} }
void propagate_bounds_on_terms(lp_bound_propagator & bp) { void propagate_bounds_on_terms(lp_bound_propagator & bp) {
@ -484,16 +484,16 @@ public:
void pop(unsigned k) { void pop(unsigned k) {
int n_was = static_cast<int>(m_ext_vars_to_columns.size()); int n_was = static_cast<int>(m_ext_vars_to_columns.size());
m_status.pop(k); m_status.pop(k);
m_infeasible_column_index.pop(k); m_infeasible_column_index.pop(k);
unsigned n = m_vars_to_ul_pairs.peek_size(k); unsigned n = m_vars_to_ul_pairs.peek_size(k);
for (unsigned j = n_was; j-- > n;) for (unsigned j = n_was; j-- > n;)
m_ext_vars_to_columns.erase(m_columns_to_ext_vars_or_term_indices[j]); m_ext_vars_to_columns.erase(m_columns_to_ext_vars_or_term_indices[j]);
m_columns_to_ext_vars_or_term_indices.resize(n); m_columns_to_ext_vars_or_term_indices.resize(n);
if (m_settings.use_tableau()) { if (m_settings.use_tableau()) {
pop_tableau(); pop_tableau();
} }
m_vars_to_ul_pairs.pop(k); m_vars_to_ul_pairs.pop(k);
m_mpq_lar_core_solver.pop(k); m_mpq_lar_core_solver.pop(k);
clean_large_elements_after_pop(n, m_columns_with_changed_bound); clean_large_elements_after_pop(n, m_columns_with_changed_bound);
@ -501,7 +501,7 @@ public:
clean_large_elements_after_pop(m, m_rows_with_changed_bounds); clean_large_elements_after_pop(m, m_rows_with_changed_bounds);
clean_inf_set_of_r_solver_after_pop(); clean_inf_set_of_r_solver_after_pop();
lean_assert(m_settings.simplex_strategy() == simplex_strategy_enum::undecided || lean_assert(m_settings.simplex_strategy() == simplex_strategy_enum::undecided ||
(!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau()); (!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
lean_assert(ax_is_correct()); lean_assert(ax_is_correct());
@ -518,9 +518,9 @@ public:
} }
m_terms.resize(m_term_count); m_terms.resize(m_term_count);
m_orig_terms.resize(m_term_count); m_orig_terms.resize(m_term_count);
m_simplex_strategy.pop(k); m_simplex_strategy.pop(k);
m_settings.simplex_strategy() = m_simplex_strategy; m_settings.simplex_strategy() = m_simplex_strategy;
lean_assert(sizes_are_correct()); lean_assert(sizes_are_correct());
lean_assert((!m_settings.use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau()); lean_assert((!m_settings.use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
} }
@ -967,8 +967,8 @@ public:
template <typename U, typename V> template <typename U, typename V>
void copy_from_mpq_matrix(static_matrix<U, V> & matr) { void copy_from_mpq_matrix(static_matrix<U, V> & matr) {
matr.m_rows.resize(A_r().row_count()); matr.m_rows.resize(A_r().row_count());
matr.m_columns.resize(A_r().column_count()); matr.m_columns.resize(A_r().column_count());
for (unsigned i = 0; i < matr.row_count(); i++) { for (unsigned i = 0; i < matr.row_count(); i++) {
for (auto & it : A_r().m_rows[i]) { for (auto & it : A_r().m_rows[i]) {
matr.set(i, it.m_j, convert_struct<U, mpq>::convert(it.get_val())); matr.set(i, it.m_j, convert_struct<U, mpq>::convert(it.get_val()));

View file

@ -17,11 +17,11 @@ const impq & lp_bound_propagator::get_upper_bound(unsigned j) const {
} }
void lp_bound_propagator::try_add_bound(const mpq & v, unsigned j, bool is_low, bool coeff_before_j_is_pos, unsigned row_or_term_index, bool strict) { void lp_bound_propagator::try_add_bound(const mpq & v, unsigned j, bool is_low, bool coeff_before_j_is_pos, unsigned row_or_term_index, bool strict) {
unsigned term_j = m_lar_solver.adjust_column_index_to_term_index(j); unsigned term_j = m_lar_solver.adjust_column_index_to_term_index(j);
mpq w = v; mpq w = v;
if (term_j != j) { if (term_j != j) {
j = term_j; j = term_j;
w += m_lar_solver.get_term(term_j).m_v; // when terms are turned into the columns they "lose" the right side, at this moment they aquire it back w += m_lar_solver.get_term(term_j).m_v; // when terms are turned into the columns they "lose" the right side, at this moment they aquire it back
} }
lconstraint_kind kind = is_low? GE : LE; lconstraint_kind kind = is_low? GE : LE;
if (strict) if (strict)
kind = static_cast<lconstraint_kind>(kind / 2); kind = static_cast<lconstraint_kind>(kind / 2);

View file

@ -278,13 +278,13 @@ public:
return m_simplex_strategy; return m_simplex_strategy;
} }
bool use_lu() const { bool use_lu() const {
return m_simplex_strategy == simplex_strategy_enum::lu; return m_simplex_strategy == simplex_strategy_enum::lu;
} }
bool use_tableau() const { bool use_tableau() const {
return m_simplex_strategy == simplex_strategy_enum::tableau_rows || return m_simplex_strategy == simplex_strategy_enum::tableau_rows ||
m_simplex_strategy == simplex_strategy_enum::tableau_costs; m_simplex_strategy == simplex_strategy_enum::tableau_costs;
} }
bool use_tableau_rows() const { bool use_tableau_rows() const {

View file

@ -18,7 +18,7 @@ bool try_get_val(const std::unordered_map<A,B> & map, const A& key, B & val) {
template <typename A, typename B> template <typename A, typename B>
bool contains(const std::unordered_map<A, B> & map, const A& key) { bool contains(const std::unordered_map<A, B> & map, const A& key) {
return map.find(key) != map.end(); return map.find(key) != map.end();
} }
#ifdef lp_for_z3 #ifdef lp_for_z3

View file

@ -51,10 +51,10 @@ public:
private: private:
void emplace_replace(unsigned i,const B & b) { void emplace_replace(unsigned i,const B & b) {
if (m_vector[i] != b) { if (m_vector[i] != b) {
m_changes.push_back(std::make_pair(i, m_vector[i])); m_changes.push_back(std::make_pair(i, m_vector[i]));
m_vector[i] = b; m_vector[i] = b;
} }
} }
public: public:
@ -87,14 +87,14 @@ public:
} }
template <typename T> template <typename T>
void pop_tail(vector<T> & v, unsigned k) { void pop_tail(vector<T> & v, unsigned k) {
lean_assert(v.size() >= k); lean_assert(v.size() >= k);
v.resize(v.size() - k); v.resize(v.size() - k);
} }
template <typename T> template <typename T>
void resize(vector<T> & v, unsigned new_size) { void resize(vector<T> & v, unsigned new_size) {
v.resize(new_size); v.resize(new_size);
} }
void pop(unsigned k) { void pop(unsigned k) {
@ -156,10 +156,10 @@ public:
m_vector.resize(m_vector.size() + 1); m_vector.resize(m_vector.size() + 1);
} }
unsigned peek_size(unsigned k) const { unsigned peek_size(unsigned k) const {
lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size()); lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size());
return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k]; return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k];
} }
const vector<B>& operator()() const { return m_vector; } const vector<B>& operator()() const { return m_vector; }
}; };

View file

@ -47,7 +47,7 @@ class static_matrix
dim(unsigned m, unsigned n) :m_m(m), m_n(n) {} dim(unsigned m, unsigned n) :m_m(m), m_n(n) {}
}; };
std::stack<dim> m_stack; std::stack<dim> m_stack;
vector<unsigned> m_became_zeros; // the row indices that became zeroes during the pivoting vector<unsigned> m_became_zeros; // the row indices that became zeroes during the pivoting
public: public:
typedef vector<row_cell<T>> row_strip; typedef vector<row_cell<T>> row_strip;
typedef vector<column_cell> column_strip; typedef vector<column_cell> column_strip;

View file

@ -49,8 +49,8 @@ public:
&& m_upper_bound_witness == p.m_upper_bound_witness && && m_upper_bound_witness == p.m_upper_bound_witness &&
m_i == p.m_i; m_i == p.m_i;
} }
// empty constructor // empty constructor
ul_pair() : ul_pair() :
m_low_bound_witness(static_cast<constraint_index>(-1)), m_low_bound_witness(static_cast<constraint_index>(-1)),
m_upper_bound_witness(static_cast<constraint_index>(-1)), m_upper_bound_witness(static_cast<constraint_index>(-1)),
m_i(static_cast<row_index>(-1)) m_i(static_cast<row_index>(-1))

View file

@ -135,7 +135,7 @@ public:
value const& get(key const& k, value const& default_value) const { value const& get(key const& k, value const& default_value) const {
entry* e = find_core(k); entry* e = find_core(k);
if (e) { if (e) {
return e->get_data().m_value; return e->get_data().m_value;
} }
else { else {
return default_value; return default_value;

View file

@ -92,7 +92,7 @@ public:
m_next.reserve(std::max(src, dst) + 1); m_next.reserve(std::max(src, dst) + 1);
m_next.reserve(std::max(negate(src), negate(dst)) + 1); m_next.reserve(std::max(negate(src), negate(dst)) + 1);
m_next[src].push_back(dst); m_next[src].push_back(dst);
m_next[dst].push_back(src); m_next[dst].push_back(src);
} }
void cliques(unsigned_vector const& ps, vector<unsigned_vector>& cliques) { void cliques(unsigned_vector const& ps, vector<unsigned_vector>& cliques) {
@ -104,7 +104,7 @@ public:
max = std::max(max, std::max(np, p) + 1); max = std::max(max, std::max(np, p) + 1);
} }
m_next.reserve(max); m_next.reserve(max);
m_tc.reserve(m_next.size()); m_tc.reserve(m_next.size());
unsigned_vector clique; unsigned_vector clique;
uint_set vars; uint_set vars;
for (unsigned i = 0; i < num_ps; ++i) { for (unsigned i = 0; i < num_ps; ++i) {

View file

@ -422,7 +422,7 @@ inline bool operator>(rational const & r1, rational const & r2) {
} }
inline bool operator<(rational const & r1, int r2) { inline bool operator<(rational const & r1, int r2) {
return r1 < rational(r2); return r1 < rational(r2);
} }
inline bool operator<=(rational const & r1, rational const & r2) { inline bool operator<=(rational const & r1, rational const & r2) {
@ -450,11 +450,11 @@ inline rational operator+(rational const & r1, rational const & r2) {
} }
inline rational operator+(int r1, rational const & r2) { inline rational operator+(int r1, rational const & r2) {
return rational(r1) + r2; return rational(r1) + r2;
} }
inline rational operator+(rational const & r1, int r2) { inline rational operator+(rational const & r1, int r2) {
return r1 + rational(r2); return r1 + rational(r2);
} }
@ -463,11 +463,11 @@ inline rational operator-(rational const & r1, rational const & r2) {
} }
inline rational operator-(rational const & r1, int r2) { inline rational operator-(rational const & r1, int r2) {
return r1 - rational(r2); return r1 - rational(r2);
} }
inline rational operator-(int r1, rational const & r2) { inline rational operator-(int r1, rational const & r2) {
return rational(r1) - r2; return rational(r1) - r2;
} }
inline rational operator-(rational const & r) { inline rational operator-(rational const & r) {
@ -492,11 +492,11 @@ inline rational operator/(rational const & r1, rational const & r2) {
} }
inline rational operator/(rational const & r1, int r2) { inline rational operator/(rational const & r1, int r2) {
return r1 / rational(r2); return r1 / rational(r2);
} }
inline rational operator/(int r1, rational const & r2) { inline rational operator/(int r1, rational const & r2) {
return rational(r1) / r2; return rational(r1) / r2;
} }
inline rational power(rational const & r, unsigned p) { inline rational power(rational const & r, unsigned p) {

View file

@ -110,7 +110,7 @@ public:
mach_timespec_t _stop; mach_timespec_t _stop;
clock_get_time(m_host_clock, &_stop); clock_get_time(m_host_clock, &_stop);
m_time += (_stop.tv_sec - m_start.tv_sec) * 1000000000ull; m_time += (_stop.tv_sec - m_start.tv_sec) * 1000000000ull;
m_time += (_stop.tv_nsec - m_start.tv_nsec); m_time += (_stop.tv_nsec - m_start.tv_nsec);
m_running = false; m_running = false;
} }
} }
@ -163,8 +163,8 @@ public:
struct timespec _stop; struct timespec _stop;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &_stop); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &_stop);
m_time += (_stop.tv_sec - m_start.tv_sec) * 1000000000ull; m_time += (_stop.tv_sec - m_start.tv_sec) * 1000000000ull;
if (m_time != 0 || _stop.tv_nsec >= m_start.tv_nsec) if (m_time != 0 || _stop.tv_nsec >= m_start.tv_nsec)
m_time += (_stop.tv_nsec - m_start.tv_nsec); m_time += (_stop.tv_nsec - m_start.tv_nsec);
m_running = false; m_running = false;
} }
} }

View file

@ -153,13 +153,13 @@ template<class T, size_t N> char (*ArraySizer(T (&)[N]))[N];
template<typename IT> template<typename IT>
void display(std::ostream & out, const IT & begin, const IT & end, const char * sep, bool & first) { void display(std::ostream & out, const IT & begin, const IT & end, const char * sep, bool & first) {
for(IT it = begin; it != end; ++it) { for(IT it = begin; it != end; ++it) {
if (first) { if (first) {
first = false; first = false;
} }
else { else {
out << sep; out << sep;
} }
out << *it; out << *it;
} }
} }
@ -172,9 +172,9 @@ void display(std::ostream & out, const IT & begin, const IT & end, const char *
template<typename T> template<typename T>
struct delete_proc { struct delete_proc {
void operator()(T * ptr) { void operator()(T * ptr) {
if (ptr) { if (ptr) {
dealloc(ptr); dealloc(ptr);
} }
} }
}; };