3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-04 10:20:23 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2023-08-10 10:54:20 -07:00
parent f624890b04
commit 2209d09cd9

View file

@ -202,7 +202,7 @@ namespace synth {
} }
expr_ref solver::compute_solution(app* e) { expr_ref solver::compute_solution(app* e) {
auto * n = expr2enode(synth_output(e)); auto* n = expr2enode(synth_output(e));
expr_ref_vector repr(m); expr_ref_vector repr(m);
auto get_rep = [&](euf::enode* n) { return repr.get(n->get_root_id(), nullptr); }; auto get_rep = [&](euf::enode* n) { return repr.get(n->get_root_id(), nullptr); };
auto has_rep = [&](euf::enode* n) { return !!get_rep(n); }; auto has_rep = [&](euf::enode* n) { return !!get_rep(n); };
@ -212,7 +212,7 @@ namespace synth {
struct rep_lt { struct rep_lt {
expr_ref_vector const& repr; expr_ref_vector const& repr;
rep_lt(expr_ref_vector& repr): repr(repr) {} rep_lt(expr_ref_vector& repr) : repr(repr) {}
bool operator()(int v1, int v2) const { bool operator()(int v1, int v2) const {
return get_depth(repr.get(v1)) < get_depth(repr.get(v2)); return get_depth(repr.get(v1)) < get_depth(repr.get(v2));
}; };
@ -229,10 +229,9 @@ namespace synth {
heap.insert(id); heap.insert(id);
}; };
for (unsigned i = 1; i < e->get_num_args(); ++i) { for (unsigned i = 1; i < e->get_num_args(); ++i) {
expr * arg = e->get_arg(i); expr* arg = e->get_arg(i);
auto * narg = expr2enode(arg); auto* narg = expr2enode(arg);
insert_repr(narg, arg); insert_repr(narg, arg);
} }
// make sure we only insert non-input symbols. // make sure we only insert non-input symbols.
@ -241,13 +240,13 @@ namespace synth {
insert_repr(n, n->get_expr()); insert_repr(n, n->get_expr());
} }
while (!heap.empty()) { while (!heap.empty()) {
auto * nn = nodes[heap.erase_min()]; auto* nn = nodes[heap.erase_min()];
for (auto * p : euf::enode_parents(nn)) { for (auto* p : euf::enode_parents(nn)) {
if (has_rep(p)) if (has_rep(p))
continue; continue;
if (is_uncomputable(p->get_decl())) if (is_uncomputable(p->get_decl()))
continue; continue;
if (!all_of(euf::enode_args(p), [&](auto * ch) { return has_rep(ch); })) if (!all_of(euf::enode_args(p), [&](auto* ch) { return has_rep(ch); }))
continue; continue;
expr* r = get_rep(p); expr* r = get_rep(p);
if (r) { if (r) {
@ -257,7 +256,7 @@ namespace synth {
heap.erase(p->get_root_id()); heap.erase(p->get_root_id());
} }
ptr_buffer<expr> args; ptr_buffer<expr> args;
for (auto * ch : euf::enode_args(p)) for (auto* ch : euf::enode_args(p))
args.push_back(get_rep(ch)); args.push_back(get_rep(ch));
expr_ref papp(m.mk_app(p->get_decl(), args), m); expr_ref papp(m.mk_app(p->get_decl(), args), m);
insert_repr(p, papp); insert_repr(p, papp);