3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

adding ematching engine, fixing seq_unicode

This commit is contained in:
Nikolaj Bjorner 2021-01-22 17:10:45 -08:00
parent db17ae03c6
commit 680b185872
10 changed files with 4147 additions and 20 deletions

View file

@ -3,7 +3,7 @@ Copyright (c) 2020 Microsoft Corporation
Module Name:
a_solver.cpp
q_solver.cpp
Abstract:
@ -15,18 +15,21 @@ Author:
--*/
#include "ast/ast_util.h"
#include "ast/well_sorted.h"
#include "ast/rewriter/var_subst.h"
#include "ast/normal_forms/pull_quant.h"
#include "sat/smt/q_solver.h"
#include "sat/smt/euf_solver.h"
#include "sat/smt/sat_th.h"
#include "ast/normal_forms/pull_quant.h"
#include "ast/well_sorted.h"
namespace q {
solver::solver(euf::solver& ctx, family_id fid) :
th_euf_solver(ctx, ctx.get_manager().get_family_name(fid), fid),
m_mbqi(ctx, *this)
m_mbqi(ctx, *this),
m_expanded(ctx.get_manager())
{
}
@ -34,12 +37,19 @@ namespace q {
expr* e = bool_var2expr(l.var());
if (!is_forall(e) && !is_exists(e))
return;
if (l.sign() == is_forall(e))
add_clause(~l, skolemize(to_quantifier(e)));
else {
// add_clause(~l, specialize(to_quantifier(e)));
ctx.push_vec(m_universal, l);
quantifier* q = to_quantifier(e);
auto const& exp = expand(q);
if (exp.size() > 1) {
for (expr* e : exp)
add_clause(~l, ctx.internalize(e, l.sign(), false, false));
return;
}
if (l.sign() == is_forall(e))
add_clause(~l, skolemize(q));
else
ctx.push_vec(m_universal, l);
m_stats.m_num_quantifier_asserts++;
}
@ -204,4 +214,26 @@ namespace q {
return g;
}
expr_ref_vector const& solver::expand(quantifier* q) {
m_expanded.reset();
if (is_forall(q))
flatten_and(q->get_expr(), m_expanded);
else if (is_exists(q))
flatten_or(q->get_expr(), m_expanded);
else
UNREACHABLE();
if (m_expanded.size() > 1) {
for (unsigned i = m_expanded.size(); i-- > 0; ) {
expr_ref tmp(m.update_quantifier(q, m_expanded.get(i)), m);
ctx.get_rewriter()(tmp);
m_expanded[i] = tmp;
}
return m_expanded;
}
m_expanded.reset();
m_expanded.push_back(q);
return m_expanded;
}
}

View file

@ -3,7 +3,7 @@ Copyright (c) 2020 Microsoft Corporation
Module Name:
a_solver.h
q_solver.h
Abstract:
@ -45,12 +45,15 @@ namespace q {
sat::literal_vector m_universal;
obj_map<sort, expr*> m_unit_table;
mutable ptr_vector<expr> m_todo;
expr_ref_vector m_expanded;
sat::literal instantiate(quantifier* q, bool negate, std::function<expr* (quantifier*, unsigned)>& mk_var);
sat::literal skolemize(quantifier* q);
sat::literal specialize(quantifier* q);
void init_units();
expr* get_unit(sort* s);
expr_ref_vector const& expand(quantifier* q);
public: