3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-27 17:59:24 +00:00

make static features avoid stack #5758

This commit is contained in:
Nikolaj Bjorner 2022-01-08 11:20:18 -08:00
parent 2c44454a17
commit ef481073b2
2 changed files with 114 additions and 60 deletions

View file

@ -28,6 +28,12 @@ Revision History:
#include "util/map.h"
struct static_features {
struct to_process {
expr* e;
bool form_ctx;
bool and_or_ctx;
bool ite_ctx;
};
ast_manager & m;
arith_util m_autil;
bv_util m_bvutil;
@ -39,7 +45,7 @@ struct static_features {
family_id m_lfid;
family_id m_arrfid;
family_id m_srfid;
ast_mark m_already_visited;
ast_mark m_pre_processed, m_post_processed;
bool m_cnf;
unsigned m_num_exprs; //
unsigned m_num_roots; //
@ -111,14 +117,17 @@ struct static_features {
u_map<unsigned> m_expr2formula_depth;
unsigned m_num_theories;
bool_vector m_theories; // mapping family_id -> bool
bool_vector m_theories; // mapping family_id -> bool
symbol m_label_sym;
symbol m_pattern_sym;
symbol m_expr_list_sym;
svector<to_process> m_to_process;
bool is_marked(ast * e) const { return m_already_visited.is_marked(e); }
void mark(ast * e) { m_already_visited.mark(e, true); }
bool is_marked_pre(ast * e) const { return m_pre_processed.is_marked(e); }
void mark_pre(ast * e) { m_pre_processed.mark(e, true); }
bool is_marked_post(ast * e) const { return m_post_processed.is_marked(e); }
void mark_post(ast * e) { m_post_processed.mark(e, true); }
bool is_bool(expr const * e) const { return m.is_bool(e); }
bool is_basic_expr(expr const * e) const { return is_app(e) && to_app(e)->get_family_id() == m_bfid; }
bool is_arith_expr(expr const * e) const { return is_app(e) && to_app(e)->get_family_id() == m_afid; }
@ -161,7 +170,12 @@ struct static_features {
void inc_num_aliens(family_id fid) { m_num_aliens_per_family.reserve(fid+1, 0); m_num_aliens_per_family[fid]++; }
void update_core(expr * e);
void update_core(sort * s);
void process(expr * e, bool form_ctx, bool or_and_ctx, bool ite_ctx, unsigned stack_depth);
// void process(expr * e, bool form_ctx, bool or_and_ctx, bool ite_ctx, unsigned stack_depth);
bool pre_process(expr * e, bool form_ctx, bool or_and_ctx, bool ite_ctx);
void post_process(expr * e, bool form_ctx, bool or_and_ctx, bool ite_ctx);
void add_process(expr * e, bool form_ctx, bool or_and_ctx, bool ite_ctx) { m_to_process.push_back({e, form_ctx, or_and_ctx, ite_ctx}); }
void process_all();
std::tuple<bool, bool, bool> new_ctx(expr* );
void process_root(expr * e);
unsigned get_depth(expr const * e) const { return m_expr2depth.get(e->get_id(), 1); }
void set_depth(expr const * e, unsigned d) { m_expr2depth.setx(e->get_id(), d, 1); }