mirror of
https://github.com/Z3Prover/z3
synced 2025-10-09 01:11:55 +00:00
logging support for theory axioms
This commit is contained in:
parent
279413412d
commit
28c03ed1de
26 changed files with 508 additions and 127 deletions
|
@ -2169,6 +2169,12 @@ void theory_seq::propagate_lit(dependency* dep, unsigned n, literal const* _lits
|
|||
|
||||
m_new_propagation = true;
|
||||
ctx.assign(lit, js);
|
||||
if (m.has_trace_stream()) {
|
||||
expr* expr = ctx.bool_var2expr(lit.var());
|
||||
if (lit.sign()) expr = get_manager().mk_not(expr);
|
||||
log_axiom_instantiation(expr);
|
||||
m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
}
|
||||
|
||||
void theory_seq::set_conflict(dependency* dep, literal_vector const& _lits) {
|
||||
|
@ -2202,7 +2208,9 @@ void theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) {
|
|||
justification* js = ctx.mk_justification(
|
||||
ext_theory_eq_propagation_justification(
|
||||
get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), n1, n2));
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(get_manager().mk_eq(n1->get_owner(), n2->get_owner()));
|
||||
ctx.assign_eq(n1, n2, eq_justification(js));
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
m_new_propagation = true;
|
||||
|
||||
enforce_length_coherence(n1, n2);
|
||||
|
@ -3165,6 +3173,16 @@ bool theory_seq::solve_nc(unsigned idx) {
|
|||
}
|
||||
TRACE("seq", ctx.display_literals_verbose(tout, lits.size(), lits.c_ptr()) << "\n";);
|
||||
ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
|
||||
if (m.has_trace_stream()) {
|
||||
ptr_vector<expr> exprs;
|
||||
for (literal l : lits) {
|
||||
expr* e = ctx.bool_var2expr(l.var());
|
||||
if (l.sign()) e = get_manager().mk_not(e);
|
||||
exprs.push_back(e);
|
||||
}
|
||||
log_axiom_instantiation(get_manager().mk_or(exprs.size(), exprs.c_ptr()));
|
||||
m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4571,12 +4589,17 @@ void theory_seq::propagate_in_re(expr* n, bool is_true) {
|
|||
if (!lits.empty()) {
|
||||
TRACE("seq", tout << "creating intersection " << e3 << "\n";);
|
||||
lits.push_back(lit);
|
||||
literal inter = mk_literal(m_util.re.mk_in_re(s, e3));
|
||||
expr* e = m_util.re.mk_in_re(s, e3);
|
||||
literal inter = mk_literal(e);
|
||||
justification* js =
|
||||
ctx.mk_justification(
|
||||
ext_theory_propagation_justification(
|
||||
get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), inter));
|
||||
ctx.assign(inter, js);
|
||||
if (m.has_trace_stream()) {
|
||||
log_axiom_instantiation(e);
|
||||
m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4592,16 +4615,21 @@ void theory_seq::propagate_in_re(expr* n, bool is_true) {
|
|||
unsigned_vector states;
|
||||
a->get_epsilon_closure(a->init(), states);
|
||||
lits.push_back(~lit);
|
||||
ptr_vector<expr> exprs;
|
||||
|
||||
for (unsigned st : states) {
|
||||
lits.push_back(mk_accept(s, zero, e3, st));
|
||||
literal acc = mk_accept(s, zero, e3, st);
|
||||
lits.push_back(acc);
|
||||
exprs.push_back(ctx.bool_var2expr(acc.var()));
|
||||
}
|
||||
if (lits.size() == 2) {
|
||||
propagate_lit(nullptr, 1, &lit, lits[1]);
|
||||
}
|
||||
else {
|
||||
TRACE("seq", ctx.display_literals_verbose(tout, lits) << "\n";);
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(get_manager().mk_implies(n, get_manager().mk_or(exprs.size(), exprs.c_ptr())));
|
||||
ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5060,19 +5088,28 @@ literal theory_seq::mk_eq_empty(expr* _e, bool phase) {
|
|||
return lit;
|
||||
}
|
||||
|
||||
void theory_seq::push_lit_as_expr(literal l, ptr_vector<expr>& buf) {
|
||||
expr* e = get_context().bool_var2expr(l.var());
|
||||
if (l.sign()) e = get_manager().mk_not(e);
|
||||
buf.push_back(e);
|
||||
}
|
||||
|
||||
void theory_seq::add_axiom(literal l1, literal l2, literal l3, literal l4, literal l5) {
|
||||
context& ctx = get_context();
|
||||
literal_vector lits;
|
||||
ptr_vector<expr> exprs;
|
||||
if (l1 == true_literal || l2 == true_literal || l3 == true_literal || l4 == true_literal || l5 == true_literal) return;
|
||||
if (l1 != null_literal && l1 != false_literal) { ctx.mark_as_relevant(l1); lits.push_back(l1); }
|
||||
if (l2 != null_literal && l2 != false_literal) { ctx.mark_as_relevant(l2); lits.push_back(l2); }
|
||||
if (l3 != null_literal && l3 != false_literal) { ctx.mark_as_relevant(l3); lits.push_back(l3); }
|
||||
if (l4 != null_literal && l4 != false_literal) { ctx.mark_as_relevant(l4); lits.push_back(l4); }
|
||||
if (l5 != null_literal && l5 != false_literal) { ctx.mark_as_relevant(l5); lits.push_back(l5); }
|
||||
if (l1 != null_literal && l1 != false_literal) { ctx.mark_as_relevant(l1); lits.push_back(l1); push_lit_as_expr(l1, exprs); }
|
||||
if (l2 != null_literal && l2 != false_literal) { ctx.mark_as_relevant(l2); lits.push_back(l2); push_lit_as_expr(l2, exprs); }
|
||||
if (l3 != null_literal && l3 != false_literal) { ctx.mark_as_relevant(l3); lits.push_back(l3); push_lit_as_expr(l3, exprs); }
|
||||
if (l4 != null_literal && l4 != false_literal) { ctx.mark_as_relevant(l4); lits.push_back(l4); push_lit_as_expr(l4, exprs); }
|
||||
if (l5 != null_literal && l5 != false_literal) { ctx.mark_as_relevant(l5); lits.push_back(l5); push_lit_as_expr(l5, exprs); }
|
||||
TRACE("seq", ctx.display_literals_verbose(tout << "assert:\n", lits) << "\n";);
|
||||
m_new_propagation = true;
|
||||
++m_stats.m_add_axiom;
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(get_manager().mk_or(exprs.size(), exprs.c_ptr()));
|
||||
ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
|
||||
expr* theory_seq::coalesce_chars(expr* const& e) {
|
||||
|
@ -5195,7 +5232,9 @@ void theory_seq::propagate_eq(dependency* deps, literal_vector const& _lits, exp
|
|||
get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), n1, n2));
|
||||
|
||||
m_new_propagation = true;
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(get_manager().mk_eq(e1, e2));
|
||||
ctx.assign_eq(n1, n2, eq_justification(js));
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -5237,7 +5276,9 @@ void theory_seq::assign_eh(bool_var v, bool is_true) {
|
|||
lits.push_back(mk_literal(d));
|
||||
}
|
||||
++m_stats.m_add_axiom;
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(get_manager().mk_implies(e, get_manager().mk_or(disj.size(), disj.c_ptr())));
|
||||
ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
for (expr* d : disj) {
|
||||
add_axiom(lit, ~mk_literal(d));
|
||||
}
|
||||
|
@ -5557,14 +5598,19 @@ void theory_seq::propagate_accept(literal lit, expr* acc) {
|
|||
eautomaton::moves mvs;
|
||||
aut->get_moves_from(src, mvs);
|
||||
TRACE("seq", tout << mvs.size() << "\n";);
|
||||
ptr_vector<expr> exprs;
|
||||
for (auto const& mv : mvs) {
|
||||
expr_ref nth = mk_nth(e, idx);
|
||||
expr_ref t = mv.t()->accept(nth);
|
||||
get_context().get_rewriter()(t);
|
||||
literal step = mk_literal(mk_step(e, idx, re, src, mv.dst(), t));
|
||||
expr* step_e = mk_step(e, idx, re, src, mv.dst(), t);
|
||||
literal step = mk_literal(step_e);
|
||||
lits.push_back(step);
|
||||
exprs.push_back(step_e);
|
||||
}
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(get_manager().mk_implies(acc, get_manager().mk_or(exprs.size(), exprs.c_ptr())));
|
||||
get_context().mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
}
|
||||
|
||||
void theory_seq::add_theory_assumptions(expr_ref_vector & assumptions) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue