mirror of
https://github.com/Z3Prover/z3
synced 2025-05-08 00:05:46 +00:00
fix bugs related to model-converter
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
ae728374c8
commit
7b8101c502
20 changed files with 211 additions and 112 deletions
|
@ -109,15 +109,12 @@ public:
|
|||
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) {
|
||||
if (!ctx.is_model_available() || ctx.get_check_sat_result() == 0)
|
||||
throw cmd_exception("model is not available");
|
||||
model_ref m;
|
||||
if (!ctx.is_model_available(m) || ctx.get_check_sat_result() == 0)
|
||||
throw cmd_exception("model is not available");
|
||||
if (m_index > 0 && ctx.get_opt()) {
|
||||
ctx.get_opt()->get_box_model(m, m_index);
|
||||
}
|
||||
else {
|
||||
ctx.get_check_sat_result()->get_model(m);
|
||||
}
|
||||
ctx.display_model(m);
|
||||
}
|
||||
virtual void reset(cmd_context& ctx) {
|
||||
|
@ -127,10 +124,9 @@ public:
|
|||
|
||||
|
||||
ATOMIC_CMD(get_assignment_cmd, "get-assignment", "retrieve assignment", {
|
||||
if (!ctx.is_model_available() || ctx.get_check_sat_result() == 0)
|
||||
throw cmd_exception("model is not available");
|
||||
model_ref m;
|
||||
ctx.get_check_sat_result()->get_model(m);
|
||||
if (!ctx.is_model_available(m) || ctx.get_check_sat_result() == 0)
|
||||
throw cmd_exception("model is not available");
|
||||
ctx.regular_stream() << "(";
|
||||
dictionary<macro_decls> const & macros = ctx.get_macros();
|
||||
bool first = true;
|
||||
|
|
|
@ -1696,11 +1696,11 @@ struct contains_underspecified_op_proc {
|
|||
\brief Complete the model if necessary.
|
||||
*/
|
||||
void cmd_context::complete_model() {
|
||||
if (!is_model_available() ||
|
||||
model_ref md;
|
||||
if (!is_model_available(md) ||
|
||||
gparams::get_value("model.completion") != "true")
|
||||
return;
|
||||
|
||||
model_ref md;
|
||||
get_check_sat_result()->get_model(md);
|
||||
SASSERT(md.get() != 0);
|
||||
params_ref p;
|
||||
|
@ -1765,11 +1765,11 @@ void cmd_context::complete_model() {
|
|||
\brief Check if the current model satisfies the quantifier free formulas.
|
||||
*/
|
||||
void cmd_context::validate_model() {
|
||||
model_ref md;
|
||||
if (!validate_model_enabled())
|
||||
return;
|
||||
if (!is_model_available())
|
||||
if (!is_model_available(md))
|
||||
return;
|
||||
model_ref md;
|
||||
get_check_sat_result()->get_model(md);
|
||||
SASSERT(md.get() != 0);
|
||||
params_ref p;
|
||||
|
@ -1897,11 +1897,10 @@ void cmd_context::display_assertions() {
|
|||
regular_stream() << ")" << std::endl;
|
||||
}
|
||||
|
||||
bool cmd_context::is_model_available() const {
|
||||
bool cmd_context::is_model_available(model_ref& md) const {
|
||||
if (produce_models() &&
|
||||
has_manager() &&
|
||||
(cs_state() == css_sat || cs_state() == css_unknown)) {
|
||||
model_ref md;
|
||||
get_check_sat_result()->get_model(md);
|
||||
return md.get() != 0;
|
||||
}
|
||||
|
|
|
@ -445,7 +445,7 @@ public:
|
|||
|
||||
model_converter* get_model_converter() { return m_mc0.get(); }
|
||||
|
||||
bool is_model_available() const;
|
||||
bool is_model_available(model_ref& md) const;
|
||||
|
||||
double get_seconds() const { return m_watch.get_seconds(); }
|
||||
|
||||
|
|
|
@ -56,16 +56,14 @@ public:
|
|||
}
|
||||
|
||||
virtual void execute(cmd_context & ctx) {
|
||||
if (!ctx.is_model_available())
|
||||
model_ref md;
|
||||
if (!ctx.is_model_available(md))
|
||||
throw cmd_exception("model is not available");
|
||||
if (!m_target)
|
||||
throw cmd_exception("no arguments passed to eval");
|
||||
model_ref md;
|
||||
unsigned index = m_params.get_uint("model_index", 0);
|
||||
check_sat_result * last_result = ctx.get_check_sat_result();
|
||||
SASSERT(last_result);
|
||||
if (index == 0 || !ctx.get_opt()) {
|
||||
last_result->get_model(md);
|
||||
// already have model.
|
||||
}
|
||||
else {
|
||||
ctx.get_opt()->get_box_model(md, index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue