3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00

Style, formatting

This commit is contained in:
Christoph M. Wintersteiger 2017-09-14 17:34:51 +01:00
parent e0ff9d8fd9
commit 8b6d7c0251
2 changed files with 35 additions and 34 deletions

View file

@ -3,13 +3,13 @@ Copyright (c) 2015 Microsoft Corporation
Module Name: Module Name:
ackr_model_converter.cpp ackr_model_converter.cpp
Abstract: Abstract:
Author: Author:
Mikolas Janota Mikolas Janota
Revision History: Revision History:
--*/ --*/
@ -22,8 +22,8 @@ Revision History:
class ackr_model_converter : public model_converter { class ackr_model_converter : public model_converter {
public: public:
ackr_model_converter(ast_manager & m, ackr_model_converter(ast_manager & m,
const ackr_info_ref& info, const ackr_info_ref& info,
model_ref& abstr_model) model_ref& abstr_model)
: m(m) : m(m)
, info(info) , info(info)
, abstr_model(abstr_model) , abstr_model(abstr_model)
@ -31,7 +31,7 @@ public:
{ } { }
ackr_model_converter(ast_manager & m, ackr_model_converter(ast_manager & m,
const ackr_info_ref& info) const ackr_info_ref& info)
: m(m) : m(m)
, info(info) , info(info)
, fixed_model(false) , fixed_model(false)
@ -51,8 +51,6 @@ public:
virtual void operator()(model_ref & md) { operator()(md, 0); } virtual void operator()(model_ref & md) { operator()(md, 0); }
//void display(std::ostream & out);
virtual model_converter * translate(ast_translation & translator) { virtual model_converter * translate(ast_translation & translator) {
ackr_info_ref retv_info = info->translate(translator); ackr_info_ref retv_info = info->translate(translator);
if (fixed_model) { if (fixed_model) {
@ -63,22 +61,23 @@ public:
return alloc(ackr_model_converter, translator.to(), retv_info); return alloc(ackr_model_converter, translator.to(), retv_info);
} }
} }
protected: protected:
ast_manager& m; ast_manager & m;
const ackr_info_ref info; const ackr_info_ref info;
model_ref abstr_model; model_ref abstr_model;
bool fixed_model; bool fixed_model;
void convert(model * source, model * destination); void convert(model * source, model * destination);
void add_entry(model_evaluator & evaluator, void add_entry(model_evaluator & evaluator,
app* term, expr* value, app* term, expr* value,
obj_map<func_decl, func_interp*>& interpretations); obj_map<func_decl, func_interp*>& interpretations);
void convert_constants(model * source, model * destination); void convert_constants(model * source, model * destination);
}; };
void ackr_model_converter::convert(model * source, model * destination) { void ackr_model_converter::convert(model * source, model * destination) {
destination->copy_func_interps(*source); destination->copy_func_interps(*source);
destination->copy_usort_interps(*source); destination->copy_usort_interps(*source);
convert_constants(source,destination); convert_constants(source, destination);
} }
void ackr_model_converter::convert_constants(model * source, model * destination) { void ackr_model_converter::convert_constants(model * source, model * destination) {
@ -89,16 +88,17 @@ void ackr_model_converter::convert_constants(model * source, model * destination
func_decl * const c = source->get_constant(i); func_decl * const c = source->get_constant(i);
app * const term = info->find_term(c); app * const term = info->find_term(c);
expr * value = source->get_const_interp(c); expr * value = source->get_const_interp(c);
if(!term) { if (!term) {
destination->register_decl(c, value); destination->register_decl(c, value);
} else { }
else {
add_entry(evaluator, term, value, interpretations); add_entry(evaluator, term, value, interpretations);
} }
} }
obj_map<func_decl, func_interp*>::iterator e = interpretations.end(); obj_map<func_decl, func_interp*>::iterator e = interpretations.end();
for (obj_map<func_decl, func_interp*>::iterator i = interpretations.begin(); for (obj_map<func_decl, func_interp*>::iterator i = interpretations.begin();
i!=e; ++i) { i != e; ++i) {
func_decl* const fd = i->m_key; func_decl* const fd = i->m_key;
func_interp* const fi = i->get_value(); func_interp* const fi = i->get_value();
fi->set_else(m.get_some_value(fd->get_range())); fi->set_else(m.get_some_value(fd->get_range()));
@ -107,34 +107,35 @@ void ackr_model_converter::convert_constants(model * source, model * destination
} }
void ackr_model_converter::add_entry(model_evaluator & evaluator, void ackr_model_converter::add_entry(model_evaluator & evaluator,
app* term, expr* value, app* term, expr* value,
obj_map<func_decl, func_interp*>& interpretations) { obj_map<func_decl, func_interp*>& interpretations) {
TRACE("ackr_model", tout << "add_entry" TRACE("ackr_model", tout << "add_entry"
<< mk_ismt2_pp(term, m, 2) << mk_ismt2_pp(term, m, 2)
<< "->" << "->"
<< mk_ismt2_pp(value, m, 2) << "\n"; << mk_ismt2_pp(value, m, 2) << "\n";
); );
func_interp* fi = 0; func_interp * fi = 0;
func_decl * const declaration = term->get_decl(); func_decl * const declaration = term->get_decl();
const unsigned sz = declaration->get_arity(); const unsigned sz = declaration->get_arity();
SASSERT(sz == term->get_num_args()); SASSERT(sz == term->get_num_args());
if (!interpretations.find(declaration, fi)) { if (!interpretations.find(declaration, fi)) {
fi = alloc(func_interp,m,sz); fi = alloc(func_interp, m, sz);
interpretations.insert(declaration, fi); interpretations.insert(declaration, fi);
} }
expr_ref_vector args(m); expr_ref_vector args(m);
for (unsigned gi = 0; gi < sz; ++gi) { for (unsigned gi = 0; gi < sz; ++gi) {
expr * const arg = term->get_arg(gi); expr * const arg = term->get_arg(gi);
expr_ref aarg(m); expr_ref aarg(m);
info->abstract(arg, aarg); info->abstract(arg, aarg);
expr_ref arg_value(m); expr_ref arg_value(m);
evaluator(aarg,arg_value); evaluator(aarg, arg_value);
args.push_back(arg_value); args.push_back(arg_value);
} }
if (fi->get_entry(args.c_ptr()) == 0) { if (fi->get_entry(args.c_ptr()) == 0) {
fi->insert_new_entry(args.c_ptr(), value); fi->insert_new_entry(args.c_ptr(), value);
} else { }
else {
TRACE("ackr_model", tout << "entry already present\n";); TRACE("ackr_model", tout << "entry already present\n";);
} }
} }

View file

@ -3,13 +3,13 @@ Copyright (c) 2015 Microsoft Corporation
Module Name: Module Name:
ackr_model_converter.h ackr_model_converter.h
Abstract: Abstract:
Author: Author:
Mikolas Janota Mikolas Janota
Revision History: Revision History:
--*/ --*/
@ -19,7 +19,7 @@ Revision History:
#include "tactic/model_converter.h" #include "tactic/model_converter.h"
#include "ackermannization/ackr_info.h" #include "ackermannization/ackr_info.h"
model_converter * mk_ackr_model_converter(ast_manager & m, const ackr_info_ref& info, model_ref& abstr_model); model_converter * mk_ackr_model_converter(ast_manager & m, const ackr_info_ref & info, model_ref & abstr_model);
model_converter * mk_ackr_model_converter(ast_manager & m, const ackr_info_ref& info); model_converter * mk_ackr_model_converter(ast_manager & m, const ackr_info_ref & info);
#endif /* LACKR_MODEL_CONVERTER_H_ */ #endif /* LACKR_MODEL_CONVERTER_H_ */