mirror of
https://github.com/Z3Prover/z3
synced 2025-08-15 15:25:26 +00:00
Merge branch 'unstable' of https://git01.codeplex.com/z3 into opt
This commit is contained in:
commit
c42ee3bb01
37 changed files with 2162 additions and 182 deletions
|
@ -26,6 +26,7 @@ Revision History:
|
|||
#include<sstream>
|
||||
#include<vector>
|
||||
#include<list>
|
||||
#include <set>
|
||||
#include"version.h"
|
||||
#include<limits.h>
|
||||
|
||||
|
@ -50,6 +51,7 @@ Revision History:
|
|||
#include"scoped_ctrl_c.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"scoped_proof.h"
|
||||
|
||||
namespace Duality {
|
||||
|
||||
|
@ -449,6 +451,7 @@ namespace Duality {
|
|||
bool is_datatype() const { return get_sort().is_datatype(); }
|
||||
bool is_relation() const { return get_sort().is_relation(); }
|
||||
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_numeral() const {
|
||||
return is_app() && decl().get_decl_kind() == OtherArith && m().is_unique_value(to_expr(raw()));
|
||||
|
@ -560,6 +563,8 @@ namespace Duality {
|
|||
|
||||
expr qe_lite() 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 &q, const expr &b, const std::vector<expr> &patterns);
|
||||
|
@ -718,6 +723,7 @@ namespace Duality {
|
|||
m_model = s;
|
||||
return *this;
|
||||
}
|
||||
bool null() const {return !m_model;}
|
||||
|
||||
expr eval(expr const & n, bool model_completion=true) const {
|
||||
::model * _m = m_model.get();
|
||||
|
@ -811,8 +817,9 @@ namespace Duality {
|
|||
::solver *m_solver;
|
||||
model the_model;
|
||||
bool canceled;
|
||||
proof_gen_mode m_mode;
|
||||
public:
|
||||
solver(context & c, bool extensional = false);
|
||||
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(solver const & s):object(s), the_model(s.the_model) { m_solver = s.m_solver; canceled = false;}
|
||||
~solver() {
|
||||
|
@ -824,6 +831,7 @@ namespace Duality {
|
|||
m_ctx = s.m_ctx;
|
||||
m_solver = s.m_solver;
|
||||
the_model = s.the_model;
|
||||
m_mode = s.m_mode;
|
||||
return *this;
|
||||
}
|
||||
struct cancel_exception {};
|
||||
|
@ -832,11 +840,12 @@ namespace Duality {
|
|||
throw(cancel_exception());
|
||||
}
|
||||
// void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
|
||||
void push() { m_solver->push(); }
|
||||
void pop(unsigned n = 1) { m_solver->pop(n); }
|
||||
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 reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }
|
||||
void add(expr const & e) { m_solver->assert_expr(e); }
|
||||
void add(expr const & e) { scoped_proof_mode spm(m(),m_mode); m_solver->assert_expr(e); }
|
||||
check_result check() {
|
||||
scoped_proof_mode spm(m(),m_mode);
|
||||
checkpoint();
|
||||
lbool r = m_solver->check_sat(0,0);
|
||||
model_ref m;
|
||||
|
@ -845,6 +854,7 @@ namespace Duality {
|
|||
return to_check_result(r);
|
||||
}
|
||||
check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
|
||||
scoped_proof_mode spm(m(),m_mode);
|
||||
model old_model(the_model);
|
||||
check_result res = check(n,assumptions,core_size,core);
|
||||
if(the_model == 0)
|
||||
|
@ -852,6 +862,7 @@ namespace Duality {
|
|||
return res;
|
||||
}
|
||||
check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) {
|
||||
scoped_proof_mode spm(m(),m_mode);
|
||||
checkpoint();
|
||||
std::vector< ::expr *> _assumptions(n);
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
|
@ -876,6 +887,7 @@ namespace Duality {
|
|||
}
|
||||
#if 0
|
||||
check_result check(expr_vector assumptions) {
|
||||
scoped_proof_mode spm(m(),m_mode);
|
||||
unsigned n = assumptions.size();
|
||||
z3array<Z3_ast> _assumptions(n);
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
|
@ -900,17 +912,19 @@ namespace Duality {
|
|||
int get_num_decisions();
|
||||
|
||||
void cancel(){
|
||||
scoped_proof_mode spm(m(),m_mode);
|
||||
canceled = true;
|
||||
if(m_solver)
|
||||
m_solver->cancel();
|
||||
}
|
||||
|
||||
unsigned get_scope_level(){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_assertion_ids();
|
||||
|
||||
proof get_proof(){
|
||||
scoped_proof_mode spm(m(),m_mode);
|
||||
return proof(ctx(),m_solver->get_proof());
|
||||
}
|
||||
|
||||
|
@ -1294,8 +1308,8 @@ namespace Duality {
|
|||
|
||||
class interpolating_solver : public solver {
|
||||
public:
|
||||
interpolating_solver(context &ctx)
|
||||
: solver(ctx)
|
||||
interpolating_solver(context &ctx, bool models = true)
|
||||
: solver(ctx, true, models)
|
||||
{
|
||||
weak_mode = false;
|
||||
}
|
||||
|
@ -1359,6 +1373,21 @@ namespace Duality {
|
|||
typedef double clock_t;
|
||||
clock_t current_time();
|
||||
inline void output_time(std::ostream &os, clock_t time){os << time;}
|
||||
|
||||
template <class X> class uptr {
|
||||
public:
|
||||
X *ptr;
|
||||
uptr(){ptr = 0;}
|
||||
void set(X *_ptr){
|
||||
if(ptr) delete ptr;
|
||||
ptr = _ptr;
|
||||
}
|
||||
X *get(){ return ptr;}
|
||||
~uptr(){
|
||||
if(ptr) delete ptr;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// to make Duality::ast hashable
|
||||
|
@ -1393,6 +1422,18 @@ namespace std {
|
|||
};
|
||||
}
|
||||
|
||||
// to make Duality::ast usable in ordered collections
|
||||
namespace std {
|
||||
template <>
|
||||
class less<Duality::expr> {
|
||||
public:
|
||||
bool operator()(const Duality::expr &s, const Duality::expr &t) const {
|
||||
// return s.raw() < t.raw();
|
||||
return s.raw()->get_id() < t.raw()->get_id();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// to make Duality::func_decl hashable
|
||||
namespace hash_space {
|
||||
template <>
|
||||
|
@ -1425,6 +1466,5 @@ namespace std {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue