Skip to content

Commit 7486e87

Browse files
track quantifier instantiation method in proof hint #7080
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
1 parent 302ebff commit 7486e87

File tree

8 files changed

+38
-9
lines changed

8 files changed

+38
-9
lines changed

src/ast/rewriter/bool_rewriter.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,22 @@ app* bool_rewriter::mk_eq(expr* lhs, expr* rhs) {
699699
return m().mk_eq(lhs, rhs);
700700
}
701701

702+
bool bool_rewriter::try_ite_eq(expr* lhs, expr* rhs, expr_ref& r) {
703+
expr* c, *t, *e;
704+
if (!m().is_ite(lhs, c, t, e))
705+
return false;
706+
if (m().are_equal(t, rhs) && m().are_distinct(e, rhs)) {
707+
r = c;
708+
return true;
709+
}
710+
if (m().are_equal(e, rhs) && m().are_distinct(t, rhs)) {
711+
r = m().mk_not(c);
712+
return true;
713+
}
714+
return false;
715+
}
716+
717+
702718
br_status bool_rewriter::mk_eq_core(expr * lhs, expr * rhs, expr_ref & result) {
703719
if (m().are_equal(lhs, rhs)) {
704720
result = m().mk_true();
@@ -713,6 +729,12 @@ br_status bool_rewriter::mk_eq_core(expr * lhs, expr * rhs, expr_ref & result) {
713729
br_status r = BR_FAILED;
714730

715731

732+
if (try_ite_eq(lhs, rhs, result))
733+
return BR_REWRITE1;
734+
735+
if (try_ite_eq(rhs, lhs, result))
736+
return BR_REWRITE1;
737+
716738
if (m_ite_extra_rules) {
717739
if (m().is_ite(lhs) && m().is_value(rhs)) {
718740
r = try_ite_value(to_app(lhs), to_app(rhs), result);

src/ast/rewriter/bool_rewriter.h

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class bool_rewriter {
7171

7272
void mk_and_as_or(unsigned num_args, expr * const * args, expr_ref & result);
7373

74+
bool try_ite_eq(expr* lhs, expr* rhs, expr_ref& r);
75+
7476
expr * mk_or_app(unsigned num_args, expr * const * args);
7577
bool simp_nested_not_or(unsigned num_args, expr * const * args, expr_fast_mark1 & neg_lits, expr_fast_mark2 & pos_lits, expr_ref & result);
7678
expr * simp_arg(expr * arg, expr_fast_mark1 & neg_lits, expr_fast_mark2 & pos_lits, bool & modified);

src/sat/smt/q_ematch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ namespace q {
390390
m_qs.log_instantiation(lits, &j);
391391
euf::th_proof_hint* ph = nullptr;
392392
if (ctx.use_drat())
393-
ph = q_proof_hint::mk(ctx, j.m_generation, lits, j.m_clause.num_decls(), j.m_binding);
393+
ph = q_proof_hint::mk(ctx, m_ematch, j.m_generation, lits, j.m_clause.num_decls(), j.m_binding);
394394
m_qs.add_clause(lits, ph);
395395
}
396396

src/sat/smt/q_ematch.h

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ namespace q {
9090
unsigned_vector m_clause_queue;
9191
euf::enode_pair_vector m_evidence;
9292
bool m_enable_propagate = true;
93+
symbol m_ematch = symbol("ematch");
9394

9495
euf::enode* const* copy_nodes(clause& c, euf::enode* const* _binding);
9596
binding* tmp_binding(clause& c, app* pat, euf::enode* const* _binding);

src/sat/smt/q_mbi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace q {
7171
for (auto const& [qlit, fml, inst, generation] : m_instantiations) {
7272
euf::solver::scoped_generation sg(ctx, generation + 1);
7373
sat::literal lit = ~ctx.mk_literal(fml);
74-
auto* ph = ctx.use_drat()? q_proof_hint::mk(ctx, generation, ~qlit, lit, inst.size(), inst.data()) : nullptr;
74+
auto* ph = ctx.use_drat()? q_proof_hint::mk(ctx, m_mbqi, generation, ~qlit, lit, inst.size(), inst.data()) : nullptr;
7575
m_qs.add_clause(~qlit, lit, ph);
7676
m_qs.log_instantiation(~qlit, lit);
7777
}

src/sat/smt/q_mbi.h

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ namespace q {
7272
unsigned m_max_choose_candidates = 10;
7373
unsigned m_generation_bound = UINT_MAX;
7474
unsigned m_generation_max = UINT_MAX;
75+
symbol m_mbqi = symbol("mbqi");
7576
typedef std::tuple<sat::literal, expr_ref, expr_ref_vector, unsigned> instantiation_t;
7677
vector<instantiation_t> m_instantiations;
7778
vector<mbp::def> m_defs;

src/sat/smt/q_solver.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -364,21 +364,21 @@ namespace q {
364364
}
365365
}
366366

367-
q_proof_hint* q_proof_hint::mk(euf::solver& s, unsigned generation, sat::literal_vector const& lits, unsigned n, euf::enode* const* bindings) {
367+
q_proof_hint* q_proof_hint::mk(euf::solver& s, symbol const& method, unsigned generation, sat::literal_vector const& lits, unsigned n, euf::enode* const* bindings) {
368368
SASSERT(n > 0);
369369
auto* mem = s.get_region().allocate(q_proof_hint::get_obj_size(n, lits.size()));
370-
q_proof_hint* ph = new (mem) q_proof_hint(generation, n, lits.size());
370+
q_proof_hint* ph = new (mem) q_proof_hint(method, generation, n, lits.size());
371371
for (unsigned i = 0; i < n; ++i)
372372
ph->m_bindings[i] = bindings[i]->get_expr();
373373
for (unsigned i = 0; i < lits.size(); ++i)
374374
ph->m_literals[i] = lits[i];
375375
return ph;
376376
}
377377

378-
q_proof_hint* q_proof_hint::mk(euf::solver& s, unsigned generation, sat::literal l1, sat::literal l2, unsigned n, expr* const* bindings) {
378+
q_proof_hint* q_proof_hint::mk(euf::solver& s, symbol const& method, unsigned generation, sat::literal l1, sat::literal l2, unsigned n, expr* const* bindings) {
379379
SASSERT(n > 0);
380380
auto* mem = s.get_region().allocate(q_proof_hint::get_obj_size(n, 2));
381-
q_proof_hint* ph = new (mem) q_proof_hint(generation, n, 2);
381+
q_proof_hint* ph = new (mem) q_proof_hint(method, generation, n, 2);
382382
for (unsigned i = 0; i < n; ++i)
383383
ph->m_bindings[i] = bindings[i];
384384
ph->m_literals[0] = l1;
@@ -402,6 +402,7 @@ namespace q {
402402
args.push_back(s.literal2expr(~m_literals[i]));
403403
args.push_back(binding);
404404
args.push_back(m.mk_app(symbol("gen"), 1, gens, range));
405+
args.push_back(m.mk_const(m_method, range));
405406
return m.mk_app(symbol("inst"), args.size(), args.data(), range);
406407
}
407408

src/sat/smt/q_solver.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,23 @@ namespace euf {
3030
namespace q {
3131

3232
struct q_proof_hint : public euf::th_proof_hint {
33+
symbol m_method;
3334
unsigned m_generation;
3435
unsigned m_num_bindings;
3536
unsigned m_num_literals;
3637
sat::literal* m_literals;
3738
expr* m_bindings[0];
3839

39-
q_proof_hint(unsigned g, unsigned b, unsigned l) {
40+
q_proof_hint(symbol const& method, unsigned g, unsigned b, unsigned l) {
41+
m_method = method;
4042
m_generation = g;
4143
m_num_bindings = b;
4244
m_num_literals = l;
4345
m_literals = reinterpret_cast<sat::literal*>(m_bindings + m_num_bindings);
4446
}
4547
static size_t get_obj_size(unsigned num_bindings, unsigned num_lits) { return sizeof(q_proof_hint) + num_bindings*sizeof(expr*) + num_lits*sizeof(sat::literal); }
46-
static q_proof_hint* mk(euf::solver& s, unsigned generation, sat::literal_vector const& lits, unsigned n, euf::enode* const* bindings);
47-
static q_proof_hint* mk(euf::solver& s, unsigned generation, sat::literal l1, sat::literal l2, unsigned n, expr* const* bindings);
48+
static q_proof_hint* mk(euf::solver& s, symbol const& method, unsigned generation, sat::literal_vector const& lits, unsigned n, euf::enode* const* bindings);
49+
static q_proof_hint* mk(euf::solver& s, symbol const& method, unsigned generation, sat::literal l1, sat::literal l2, unsigned n, expr* const* bindings);
4850
expr* get_hint(euf::solver& s) const override;
4951
};
5052

0 commit comments

Comments
 (0)