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

checkpoint

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-10-21 18:12:34 -07:00
parent ffaf88798d
commit 56ab7a7495
29 changed files with 25 additions and 66 deletions

View file

@ -31,10 +31,11 @@ add_lib('simplifier', ['rewriter'])
# Model module should not depend on simplifier module. # Model module should not depend on simplifier module.
# We must replace all occurrences of simplifier with rewriter. # We must replace all occurrences of simplifier with rewriter.
add_lib('model', ['rewriter', 'simplifier']) add_lib('model', ['rewriter', 'simplifier'])
add_lib('tactic', ['ast', 'model'])
# Old (non-modular) parameter framework. It has been subsumed by util\params.h. # Old (non-modular) parameter framework. It has been subsumed by util\params.h.
# However, it is still used by many old components. # However, it is still used by many old components.
add_lib('old_params', ['model', 'simplifier']) add_lib('old_params', ['model', 'simplifier'])
add_lib('framework', ['rewriter', 'model', 'old_params', 'simplifier']) add_lib('framework', ['tactic', 'rewriter', 'model', 'old_params', 'simplifier'])
# Assertion set is the old tactic framework used in Z3 3.x. It will be deleted as soon as we finish the porting old # Assertion set is the old tactic framework used in Z3 3.x. It will be deleted as soon as we finish the porting old
# code to the new tactic framework. # code to the new tactic framework.
add_lib('assertion_set', ['framework']) add_lib('assertion_set', ['framework'])

View file

@ -280,6 +280,7 @@ public:
bool has_manager() const { return m_manager != 0; } bool has_manager() const { return m_manager != 0; }
ast_manager & m() const { if (!m_manager) const_cast<cmd_context*>(this)->init_manager(); return *m_manager; } ast_manager & m() const { if (!m_manager) const_cast<cmd_context*>(this)->init_manager(); return *m_manager; }
virtual ast_manager & get_ast_manager() { return m(); }
pdecl_manager & pm() const { if (!m_pmanager) const_cast<cmd_context*>(this)->init_manager(); return *m_pmanager; } pdecl_manager & pm() const { if (!m_pmanager) const_cast<cmd_context*>(this)->init_manager(); return *m_pmanager; }
sexpr_manager & sm() const { if (!m_sexpr_manager) const_cast<cmd_context*>(this)->m_sexpr_manager = alloc(sexpr_manager); return *m_sexpr_manager; } sexpr_manager & sm() const { if (!m_sexpr_manager) const_cast<cmd_context*>(this)->m_sexpr_manager = alloc(sexpr_manager); return *m_sexpr_manager; }
front_end_params & params() const { return m_params; } front_end_params & params() const { return m_params; }
@ -383,9 +384,10 @@ public:
} }
format_ns::format * pp(sort * s) const; format_ns::format * pp(sort * s) const;
void pp(func_decl * f, format_ns::format_ref & r) const; virtual void pp(sort * s, format_ns::format_ref & r) const { r = pp(s); }
void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer<symbol> & var_names) const; virtual void pp(func_decl * f, format_ns::format_ref & r) const;
void pp(expr * n, format_ns::format_ref & r) const; virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer<symbol> & var_names) const;
virtual void pp(expr * n, format_ns::format_ref & r) const;
virtual void display(std::ostream & out, sort * s, unsigned indent = 0) const; virtual void display(std::ostream & out, sort * s, unsigned indent = 0) const;
virtual void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer<symbol> & var_names) const; virtual void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer<symbol> & var_names) const;
virtual void display(std::ostream & out, expr * n, unsigned indent = 0) const; virtual void display(std::ostream & out, expr * n, unsigned indent = 0) const;

View file

@ -17,6 +17,7 @@ Revision History:
--*/ --*/
#include<sstream>
#include"model_smt2_pp.h" #include"model_smt2_pp.h"
#include"ast_smt2_pp.h" #include"ast_smt2_pp.h"
#include"func_decl_dependencies.h" #include"func_decl_dependencies.h"
@ -47,53 +48,8 @@ static unsigned pp_symbol(std::ostream & out, symbol const & s) {
#define TAB_SZ 2 #define TAB_SZ 2
class model_smt2_pp_ctx { static void pp_uninterp_sorts(std::ostream & out, ast_printer_context & ctx, model_core const & md, unsigned indent) {
public: ast_manager & m = ctx.get_ast_manager();
virtual ast_manager & m() const = 0;
virtual void display(std::ostream & out, sort * s, unsigned indent = 0) = 0;
virtual void display(std::ostream & out, expr * n, unsigned indent = 0) = 0;
virtual void pp(sort * s, format_ns::format_ref & r) = 0;
virtual void pp(func_decl * f, format_ns::format_ref & r) = 0;
virtual void pp(expr * n, format_ns::format_ref & r) = 0;
virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer<symbol> & var_names) = 0;
};
class model_smt2_pp_cmd_ctx : public model_smt2_pp_ctx {
cmd_context & m_ctx;
public:
model_smt2_pp_cmd_ctx(cmd_context & ctx):m_ctx(ctx) {}
virtual ast_manager & m() const { return m_ctx.m(); }
virtual void display(std::ostream & out, sort * s, unsigned indent = 0) { m_ctx.display(out, s, indent); }
virtual void display(std::ostream & out, expr * n, unsigned indent = 0) { m_ctx.display(out, n, indent); }
virtual void pp(sort * s, format_ns::format_ref & r) { r = m_ctx.pp(s); }
virtual void pp(func_decl * f, format_ns::format_ref & r) { return m_ctx.pp(f, r); }
virtual void pp(expr * n, format_ns::format_ref & r) { return m_ctx.pp(n, r); }
virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer<symbol> & var_names) {
return m_ctx.pp(n, num_vars, var_prefix, r, var_names);
}
};
class model_smt2_pp_simple_ctx : public model_smt2_pp_ctx {
ast_manager & m_manager;
smt2_pp_environment_dbg m_env;
public:
model_smt2_pp_simple_ctx(ast_manager & m):m_manager(m), m_env(m) {}
virtual ast_manager & m() const { return m_manager; }
virtual void display(std::ostream & out, sort * s, unsigned indent = 0) { out << mk_ismt2_pp(s, m(), indent); }
virtual void display(std::ostream & out, expr * n, unsigned indent = 0) { out << mk_ismt2_pp(n, m(), indent); }
virtual void pp(sort * s, format_ns::format_ref & r) { mk_smt2_format(s, m_env, get_pp_default_params(), r); }
virtual void pp(func_decl * f, format_ns::format_ref & r) { mk_smt2_format(f, m_env, get_pp_default_params(), r); }
virtual void pp(expr * n, format_ns::format_ref & r) {
sbuffer<symbol> buf;
mk_smt2_format(n, m_env, get_pp_default_params(), 0, 0, r, buf);
}
virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer<symbol> & var_names) {
mk_smt2_format(n, m_env, get_pp_default_params(), num_vars, var_prefix, r, var_names);
}
};
static void pp_uninterp_sorts(std::ostream & out, model_smt2_pp_ctx & ctx, model_core const & md, unsigned indent) {
ast_manager & m = ctx.m();
ptr_buffer<format> f_conds; ptr_buffer<format> f_conds;
unsigned num = md.get_num_uninterpreted_sorts(); unsigned num = md.get_num_uninterpreted_sorts();
for (unsigned i = 0; i < num; i++) { for (unsigned i = 0; i < num; i++) {
@ -179,7 +135,7 @@ static void pp_uninterp_sorts(std::ostream & out, model_smt2_pp_ctx & ctx, model
} }
} }
static void pp_consts(std::ostream & out, model_smt2_pp_ctx & ctx, model_core const & md, unsigned indent) { static void pp_consts(std::ostream & out, ast_printer_context & ctx, model_core const & md, unsigned indent) {
unsigned num = md.get_num_constants(); unsigned num = md.get_num_constants();
for (unsigned i = 0; i < num; i++) { for (unsigned i = 0; i < num; i++) {
func_decl * c = md.get_constant(i); func_decl * c = md.get_constant(i);
@ -233,8 +189,8 @@ void sort_fun_decls(ast_manager & m, model_core const & md, ptr_buffer<func_decl
} }
} }
static void pp_funs(std::ostream & out, model_smt2_pp_ctx & ctx, model_core const & md, unsigned indent) { static void pp_funs(std::ostream & out, ast_printer_context & ctx, model_core const & md, unsigned indent) {
ast_manager & m = ctx.m(); ast_manager & m = ctx.get_ast_manager();
sbuffer<symbol> var_names; sbuffer<symbol> var_names;
ptr_buffer<format> f_var_names; ptr_buffer<format> f_var_names;
ptr_buffer<format> f_arg_decls; ptr_buffer<format> f_arg_decls;
@ -333,16 +289,16 @@ static void pp_funs(std::ostream & out, model_smt2_pp_ctx & ctx, model_core cons
} }
} }
void model_smt2_pp(std::ostream & out, cmd_context & ctx, model_core const & m, unsigned indent) { void model_smt2_pp(std::ostream & out, ast_printer_context & ctx, model_core const & m, unsigned indent) {
model_smt2_pp_cmd_ctx _ctx(ctx); pp_uninterp_sorts(out, ctx, m, indent);
pp_uninterp_sorts(out, _ctx, m, indent); pp_consts(out, ctx, m, indent);
pp_consts(out, _ctx, m, indent); pp_funs(out, ctx, m, indent);
pp_funs(out, _ctx, m, indent);
} }
void model_smt2_pp(std::ostream & out, ast_manager & m, model_core const & md, unsigned indent) { void model_smt2_pp(std::ostream & out, ast_manager & m, model_core const & md, unsigned indent) {
model_smt2_pp_simple_ctx _ctx(m); scoped_ptr<ast_printer_context> ctx;
pp_uninterp_sorts(out, _ctx, md, indent); ctx = mk_simple_ast_printer_context(m);
pp_consts(out, _ctx, md, indent); pp_uninterp_sorts(out, *(ctx.get()), md, indent);
pp_funs(out, _ctx, md, indent); pp_consts(out, *(ctx.get()), md, indent);
pp_funs(out, *(ctx.get()), md, indent);
} }

View file

@ -20,9 +20,10 @@ Revision History:
#ifndef _MODEL_SMT2_PP_H_ #ifndef _MODEL_SMT2_PP_H_
#define _MODEL_SMT2_PP_H_ #define _MODEL_SMT2_PP_H_
#include"cmd_context.h" #include"ast_printer.h"
#include"model_core.h"
void model_smt2_pp(std::ostream & out, cmd_context & ctx, model_core const & m, unsigned indent); void model_smt2_pp(std::ostream & out, ast_printer_context & ctx, model_core const & m, unsigned indent);
void model_smt2_pp(std::ostream & out, ast_manager & m, model_core const & md, unsigned indent); void model_smt2_pp(std::ostream & out, ast_manager & m, model_core const & md, unsigned indent);
#endif #endif

View file

@ -21,7 +21,6 @@ Notes:
#include"probe.h" #include"probe.h"
#include"stopwatch.h" #include"stopwatch.h"
#include"model_v2_pp.h" #include"model_v2_pp.h"
#include"cmd_context.h"
void tactic::cancel() { void tactic::cancel() {
#pragma omp critical (tactic_cancel) #pragma omp critical (tactic_cancel)