3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 11:55:51 +00:00

merge with master

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-03-25 14:57:01 -07:00
commit c513f3ca09
883 changed files with 13979 additions and 16480 deletions

View file

@ -49,14 +49,14 @@ class help_cmd : public cmd {
public:
help_cmd():cmd("help") {}
virtual char const * get_usage() const { return "<symbol>*"; }
virtual char const * get_descr(cmd_context & ctx) const { return "print this help."; }
virtual unsigned get_arity() const { return VAR_ARITY; }
virtual void prepare(cmd_context & ctx) { m_cmds.reset(); }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_SYMBOL; }
virtual void set_next_arg(cmd_context & ctx, symbol const & s) {
char const * get_usage() const override { return "<symbol>*"; }
char const * get_descr(cmd_context & ctx) const override { return "print this help."; }
unsigned get_arity() const override { return VAR_ARITY; }
void prepare(cmd_context & ctx) override { m_cmds.reset(); }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_SYMBOL; }
void set_next_arg(cmd_context & ctx, symbol const & s) override {
cmd * c = ctx.find_cmd(s);
if (c == 0) {
if (c == nullptr) {
std::string err_msg("unknown command '");
err_msg = err_msg + s.bare_str() + "'";
throw cmd_exception(err_msg);
@ -69,7 +69,7 @@ public:
bool operator()(named_cmd const & c1, named_cmd const & c2) const { return c1.first.str() < c2.first.str(); }
};
virtual void execute(cmd_context & ctx) {
void execute(cmd_context & ctx) override {
ctx.regular_stream() << "\"";
if (m_cmds.empty()) {
vector<named_cmd> cmds;
@ -101,25 +101,26 @@ class get_model_cmd : public cmd {
unsigned m_index;
public:
get_model_cmd(): cmd("get-model"), m_index(0) {}
virtual char const * get_usage() const { return "[<index of box objective>]"; }
virtual char const * get_descr(cmd_context & ctx) const {
char const * get_usage() const override { return "[<index of box objective>]"; }
char const * get_descr(cmd_context & ctx) const override {
return "retrieve model for the last check-sat command.\nSupply optional index if retrieving a model corresponding to a box optimization objective";
}
virtual unsigned get_arity() const { return VAR_ARITY; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_UINT; }
virtual void set_next_arg(cmd_context & ctx, unsigned index) { m_index = index; }
virtual void execute(cmd_context & ctx) {
unsigned get_arity() const override { return VAR_ARITY; }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_UINT; }
void set_next_arg(cmd_context & ctx, unsigned index) override { m_index = index; }
void execute(cmd_context & ctx) override {
model_ref m;
if (ctx.ignore_check())
return;
if (!ctx.is_model_available(m) || ctx.get_check_sat_result() == 0)
if (!ctx.is_model_available(m) || !ctx.get_check_sat_result())
throw cmd_exception("model is not available");
if (m_index > 0 && ctx.get_opt()) {
ctx.get_opt()->get_box_model(m, m_index);
}
ctx.display_model(m);
}
virtual void reset(cmd_context& ctx) {
void reset(cmd_context& ctx) override {
m_index = 0;
}
};
@ -164,10 +165,10 @@ class cmd_is_declared : public ast_smt_pp::is_declared {
public:
cmd_is_declared(cmd_context& ctx): m_ctx(ctx) {}
virtual bool operator()(func_decl* d) const {
bool operator()(func_decl* d) const override {
return m_ctx.is_func_decl(d->get_name());
}
virtual bool operator()(sort* s) const {
bool operator()(sort* s) const override {
return m_ctx.is_sort_decl(s->get_name());
}
};
@ -358,7 +359,7 @@ public:
m_int_real_coercions(":int-real-coercions"),
m_reproducible_resource_limit(":reproducible-resource-limit") {
}
virtual ~set_get_option_cmd() {}
~set_get_option_cmd() override {}
};
@ -475,19 +476,19 @@ public:
m_unsupported(false) {
}
virtual char const * get_usage() const { return "<keyword> <value>"; }
char const * get_usage() const override { return "<keyword> <value>"; }
virtual char const * get_descr(cmd_context & ctx) const { return "set configuration option."; }
char const * get_descr(cmd_context & ctx) const override { return "set configuration option."; }
virtual unsigned get_arity() const { return 2; }
unsigned get_arity() const override { return 2; }
virtual void prepare(cmd_context & ctx) { m_unsupported = false; m_option = symbol::null; }
void prepare(cmd_context & ctx) override { m_unsupported = false; m_option = symbol::null; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const {
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override {
return m_option == symbol::null ? CPK_KEYWORD : CPK_OPTION_VALUE;
}
virtual void set_next_arg(cmd_context & ctx, symbol const & opt) {
void set_next_arg(cmd_context & ctx, symbol const & opt) override {
if (m_option == symbol::null) {
m_option = opt;
}
@ -496,7 +497,7 @@ public:
}
}
virtual void set_next_arg(cmd_context & ctx, rational const & val) {
void set_next_arg(cmd_context & ctx, rational const & val) override {
if (m_option == m_random_seed) {
ctx.set_random_seed(to_unsigned(val));
}
@ -515,7 +516,7 @@ public:
}
}
virtual void set_next_arg(cmd_context & ctx, char const * value) {
void set_next_arg(cmd_context & ctx, char const * value) override {
if (m_option == m_regular_output_channel) {
ctx.set_regular_stream(value);
}
@ -530,7 +531,7 @@ public:
}
}
virtual void execute(cmd_context & ctx) {
void execute(cmd_context & ctx) override {
if (m_unsupported)
ctx.print_unsupported(m_option, m_line, m_pos);
else
@ -555,11 +556,11 @@ public:
get_option_cmd():
set_get_option_cmd("get-option") {
}
virtual char const * get_usage() const { return "<keyword>"; }
virtual char const * get_descr(cmd_context & ctx) const { return "get configuration option."; }
virtual unsigned get_arity() const { return 1; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_KEYWORD; }
virtual void set_next_arg(cmd_context & ctx, symbol const & opt) {
char const * get_usage() const override { return "<keyword>"; }
char const * get_descr(cmd_context & ctx) const override { return "get configuration option."; }
unsigned get_arity() const override { return 1; }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_KEYWORD; }
void set_next_arg(cmd_context & ctx, symbol const & opt) override {
if (opt == m_print_success) {
print_bool(ctx, ctx.print_success_enabled());
}
@ -649,11 +650,11 @@ public:
m_all_statistics(":all-statistics"),
m_assertion_stack_levels(":assertion-stack-levels") {
}
virtual char const * get_usage() const { return "<keyword>"; }
virtual char const * get_descr(cmd_context & ctx) const { return "get information."; }
virtual unsigned get_arity() const { return 1; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_KEYWORD; }
virtual void set_next_arg(cmd_context & ctx, symbol const & opt) {
char const * get_usage() const override { return "<keyword>"; }
char const * get_descr(cmd_context & ctx) const override { return "get information."; }
unsigned get_arity() const override { return 1; }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_KEYWORD; }
void set_next_arg(cmd_context & ctx, symbol const & opt) override {
if (opt == m_error_behavior) {
if (ctx.exit_on_error())
ctx.regular_stream() << "(:error-behavior immediate-exit)" << std::endl;
@ -705,16 +706,16 @@ public:
m_sat("sat"),
m_unknown("unknown") {
}
virtual char const * get_usage() const { return "<keyword> <value>"; }
virtual char const * get_descr(cmd_context & ctx) const { return "set information."; }
virtual unsigned get_arity() const { return 2; }
virtual void prepare(cmd_context & ctx) { m_info = symbol::null; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const {
char const * get_usage() const override { return "<keyword> <value>"; }
char const * get_descr(cmd_context & ctx) const override { return "set information."; }
unsigned get_arity() const override { return 2; }
void prepare(cmd_context & ctx) override { m_info = symbol::null; }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override {
return m_info == symbol::null ? CPK_KEYWORD : CPK_OPTION_VALUE;
}
virtual void set_next_arg(cmd_context & ctx, rational const & val) {}
virtual void set_next_arg(cmd_context & ctx, char const * val) {}
virtual void set_next_arg(cmd_context & ctx, symbol const & s) {
void set_next_arg(cmd_context & ctx, rational const & val) override {}
void set_next_arg(cmd_context & ctx, char const * val) override {}
void set_next_arg(cmd_context & ctx, symbol const & s) override {
if (m_info == symbol::null) {
m_info = s;
}
@ -735,7 +736,7 @@ public:
}
}
}
virtual void execute(cmd_context & ctx) {
void execute(cmd_context & ctx) override {
ctx.print_success();
}
};
@ -758,32 +759,32 @@ public:
}
return m_array_fid;
}
virtual char const * get_usage() const { return "<symbol> (<sort>+) <func-decl-ref>"; }
virtual char const * get_descr(cmd_context & ctx) const { return "declare a new array map operator with name <symbol> using the given function declaration.\n<func-decl-ref> ::= <symbol>\n | (<symbol> (<sort>*) <sort>)\n | ((_ <symbol> <numeral>+) (<sort>*) <sort>)\nThe last two cases are used to disumbiguate between declarations with the same name and/or select (indexed) builtin declarations.\nFor more details about the the array map operator, see 'Generalized and Efficient Array Decision Procedures' (FMCAD 2009).\nExample: (declare-map set-union (Int) (or (Bool Bool) Bool))\nDeclares a new function (declare-fun set-union ((Array Int Bool) (Array Int Bool)) (Array Int Bool)).\nThe instance of the map axiom for this new declaration is:\n(forall ((a1 (Array Int Bool)) (a2 (Array Int Bool)) (i Int)) (= (select (set-union a1 a2) i) (or (select a1 i) (select a2 i))))"; }
virtual unsigned get_arity() const { return 3; }
virtual void prepare(cmd_context & ctx) { m_name = symbol::null; m_domain.reset(); }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const {
char const * get_usage() const override { return "<symbol> (<sort>+) <func-decl-ref>"; }
char const * get_descr(cmd_context & ctx) const override { return "declare a new array map operator with name <symbol> using the given function declaration.\n<func-decl-ref> ::= <symbol>\n | (<symbol> (<sort>*) <sort>)\n | ((_ <symbol> <numeral>+) (<sort>*) <sort>)\nThe last two cases are used to disumbiguate between declarations with the same name and/or select (indexed) builtin declarations.\nFor more details about the array map operator, see 'Generalized and Efficient Array Decision Procedures' (FMCAD 2009).\nExample: (declare-map set-union (Int) (or (Bool Bool) Bool))\nDeclares a new function (declare-fun set-union ((Array Int Bool) (Array Int Bool)) (Array Int Bool)).\nThe instance of the map axiom for this new declaration is:\n(forall ((a1 (Array Int Bool)) (a2 (Array Int Bool)) (i Int)) (= (select (set-union a1 a2) i) (or (select a1 i) (select a2 i))))"; }
unsigned get_arity() const override { return 3; }
void prepare(cmd_context & ctx) override { m_name = symbol::null; m_domain.reset(); }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override {
if (m_name == symbol::null) return CPK_SYMBOL;
if (m_domain.empty()) return CPK_SORT_LIST;
return CPK_FUNC_DECL;
}
virtual void set_next_arg(cmd_context & ctx, symbol const & s) { m_name = s; }
virtual void set_next_arg(cmd_context & ctx, unsigned num, sort * const * slist) {
void set_next_arg(cmd_context & ctx, symbol const & s) override { m_name = s; }
void set_next_arg(cmd_context & ctx, unsigned num, sort * const * slist) override {
if (num == 0)
throw cmd_exception("invalid map declaration, empty sort list");
m_domain.append(num, slist);
}
virtual void set_next_arg(cmd_context & ctx, func_decl * f) {
void set_next_arg(cmd_context & ctx, func_decl * f) override {
m_f = f;
if (m_f->get_arity() == 0)
throw cmd_exception("invalid map declaration, function declaration must have arity > 0");
}
virtual void reset(cmd_context & ctx) {
void reset(cmd_context & ctx) override {
m_array_fid = null_family_id;
}
virtual void execute(cmd_context & ctx) {
void execute(cmd_context & ctx) override {
psort_decl * array_sort = ctx.find_psort_decl(m_array_sort);
if (array_sort == 0)
if (array_sort == nullptr)
throw cmd_exception("Array sort is not available");
ptr_vector<sort> & array_sort_args = m_domain;
sort_ref_buffer domain(ctx.m());
@ -811,11 +812,11 @@ class get_consequences_cmd : public cmd {
unsigned m_count;
public:
get_consequences_cmd(): cmd("get-consequences"), m_count(0) {}
virtual char const * get_usage() const { return "(<boolean-variable>*) (<variable>*)"; }
virtual char const * get_descr(cmd_context & ctx) const { return "retrieve consequences that fix values for supplied variables"; }
virtual unsigned get_arity() const { return 2; }
virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_EXPR_LIST; }
virtual void set_next_arg(cmd_context & ctx, unsigned num, expr * const * tlist) {
char const * get_usage() const override { return "(<boolean-variable>*) (<variable>*)"; }
char const * get_descr(cmd_context & ctx) const override { return "retrieve consequences that fix values for supplied variables"; }
unsigned get_arity() const override { return 2; }
cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_EXPR_LIST; }
void set_next_arg(cmd_context & ctx, unsigned num, expr * const * tlist) override {
if (m_count == 0) {
m_assumptions.append(num, tlist);
++m_count;
@ -824,8 +825,8 @@ public:
m_variables.append(num, tlist);
}
}
virtual void failure_cleanup(cmd_context & ctx) {}
virtual void execute(cmd_context & ctx) {
void failure_cleanup(cmd_context & ctx) override {}
void execute(cmd_context & ctx) override {
ast_manager& m = ctx.m();
expr_ref_vector assumptions(m), variables(m), consequences(m);
assumptions.append(m_assumptions.size(), m_assumptions.c_ptr());
@ -833,12 +834,12 @@ public:
ctx.get_consequences(assumptions, variables, consequences);
ctx.regular_stream() << consequences << "\n";
}
virtual void prepare(cmd_context & ctx) { reset(ctx); }
void prepare(cmd_context & ctx) override { reset(ctx); }
virtual void reset(cmd_context& ctx) {
void reset(cmd_context& ctx) override {
m_assumptions.reset(); m_variables.reset(); m_count = 0;
}
virtual void finalize(cmd_context & ctx) {}
void finalize(cmd_context & ctx) override {}
};
// provides "help" for builtin cmds
@ -848,8 +849,8 @@ class builtin_cmd : public cmd {
public:
builtin_cmd(char const * name, char const * usage, char const * descr):
cmd(name), m_usage(usage), m_descr(descr) {}
virtual char const * get_usage() const { return m_usage; }
virtual char const * get_descr(cmd_context & ctx) const { return m_descr; }
char const * get_usage() const override { return m_usage; }
char const * get_descr(cmd_context & ctx) const override { return m_descr; }
};
@ -890,7 +891,7 @@ void install_ext_basic_cmds(cmd_context & ctx) {
ctx.insert(alloc(echo_cmd));
ctx.insert(alloc(labels_cmd));
ctx.insert(alloc(declare_map_cmd));
ctx.insert(alloc(builtin_cmd, "reset", 0, "reset the shell (all declarations and assertions will be erased)"));
ctx.insert(alloc(builtin_cmd, "reset", nullptr, "reset the shell (all declarations and assertions will be erased)"));
install_simplify_cmd(ctx);
install_eval_cmd(ctx);
}