Skip to content

Commit

Permalink
add destructive equality resolution to the main simplifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Feb 19, 2023
1 parent c0f80f9 commit cb81473
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ast/rewriter/der.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ void der::reduce1(quantifier * q, expr_ref & r, proof_ref & pr) {

m_pos2var.reserve(num_args, -1);

// Find all disequalities
// Find all equalities/disequalities
for (unsigned i = 0; i < num_args; i++) {
is_eq = is_forall(q) ? is_var_diseq(literals.get(i), num_decls, v, t) : is_var_eq(literals.get(i), num_decls, v, t);
expr* arg = literals.get(i);
is_eq = is_forall(q) ? is_var_diseq(arg, num_decls, v, t) : is_var_eq(arg, num_decls, v, t);
if (is_eq) {
unsigned idx = v->get_idx();
if (m_map.get(idx, nullptr) == nullptr) {
Expand Down
12 changes: 12 additions & 0 deletions src/ast/rewriter/th_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Module Name:
#include "ast/rewriter/seq_rewriter.h"
#include "ast/rewriter/rewriter_def.h"
#include "ast/rewriter/var_subst.h"
#include "ast/rewriter/der.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "ast/expr_substitution.h"
#include "ast/ast_smt2_pp.h"
Expand All @@ -54,6 +55,7 @@ struct th_rewriter_cfg : public default_rewriter_cfg {
recfun_rewriter m_rec_rw;
arith_util m_a_util;
bv_util m_bv_util;
der m_der;
expr_safe_replace m_rep;
expr_ref_vector m_pinned;
// substitution support
Expand Down Expand Up @@ -819,6 +821,15 @@ struct th_rewriter_cfg : public default_rewriter_cfg {
result_pr = m().mk_transitivity(p1, p2);
}

if (is_quantifier(result)) {
proof_ref p2(m());
expr_ref r(m());
m_der(to_quantifier(result), r, p2);
if (m().proofs_enabled() && result.get() != r.get())
result_pr = m().mk_transitivity(result_pr, p2);
result = r;
}

TRACE("reduce_quantifier", tout << "after elim_unused_vars:\n" << result << " " << result_pr << "\n" ;);

SASSERT(old_q->get_sort() == result->get_sort());
Expand All @@ -839,6 +850,7 @@ struct th_rewriter_cfg : public default_rewriter_cfg {
m_rec_rw(m),
m_a_util(m),
m_bv_util(m),
m_der(m),
m_rep(m),
m_pinned(m),
m_used_dependencies(m) {
Expand Down

0 comments on commit cb81473

Please sign in to comment.