Skip to content

Commit

Permalink
fix #4794
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Dec 2, 2020
1 parent 9156e35 commit 12198d1
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 28 deletions.
5 changes: 0 additions & 5 deletions src/sat/sat_drat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ namespace sat {
buffer[len++] = '\n';
m_out->write(buffer, len);

if (n == 3 && c[0] == literal(9357, true) && c[1] == literal(25, true) && c[2] == literal(8691, false)) {
m_out->flush();
SASSERT(false);
UNREACHABLE();
}
}

void drat::dump_activity() {
Expand Down
5 changes: 3 additions & 2 deletions src/sat/sat_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3486,7 +3486,6 @@ namespace sat {
return value(v) != l_undef && lvl(v) <= new_lvl;
};


for (unsigned i = old_num_vars; i < sz; ++i) {
bool_var v = m_active_vars[i];
if (is_visited(v) || is_active(v)) {
Expand All @@ -3496,7 +3495,9 @@ namespace sat {
}
else {
set_eliminated(v, true);
m_free_vars.push_back(v);
if (!is_external(v) || true) {
m_free_vars.push_back(v);
}
}
}
m_active_vars.shrink(j);
Expand Down
1 change: 1 addition & 0 deletions src/sat/sat_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ namespace sat {
void set_should_simplify() { m_next_simplify = m_conflicts_since_init; }
bool_var_vector const& get_vars_to_reinit() const { return m_vars_to_reinit; }
bool is_probing() const { return m_is_probing; }
bool is_free(bool_var v) const { return m_free_vars.contains(v); }

public:
void user_push() override;
Expand Down
1 change: 1 addition & 0 deletions src/sat/smt/arith_internalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ namespace arith {
if (_has_var)
return v;
theory_var w = mk_evar(n);
internalize_term(n);
svector<lpvar> vars;
for (unsigned i = 0; i < p; ++i)
vars.push_back(register_theory_var_in_lar_solver(w));
Expand Down
9 changes: 4 additions & 5 deletions src/sat/smt/bv_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,12 @@ namespace bv {
case bv_justification::kind_t::eq2bit:
++s_count;
// std::cout << "eq2bit " << s_count << "\n";
#if 1
#if 0
if (s_count == 1899) {
std::cout << "eq2bit " << mk_bounded_pp(var2expr(c.m_v1), m) << " == " << mk_bounded_pp(var2expr(c.m_v2), m) << "\n";
std::cout << mk_bounded_pp(literal2expr(~c.m_antecedent), m, 2) << "\n";
std::cout << mk_bounded_pp(literal2expr(c.m_consequent), m, 2) << "\n";
std::cout << mk_bounded_pp(literal2expr(~c.m_antecedent), m, 4) << "\n";
std::cout << mk_bounded_pp(literal2expr(c.m_consequent), m, 4) << "\n";
std::cout << literal2expr(c.m_consequent) << "\n";
#if 0
solver_ref slv = mk_smt2_solver(m, ctx.s().params());
slv->assert_expr(eq);
Expand Down Expand Up @@ -779,8 +780,6 @@ namespace bv {
}

sat::justification solver::mk_eq2bit_justification(theory_var v1, theory_var v2, sat::literal c, sat::literal a) {
if (v1 == 3202 && v2 == 3404) std::cout << a << " -> " << c << "\n";
SASSERT(!(v1 == 3202 && v2 == 3404 && c.var() == 8691));
void* mem = get_region().allocate(bv_justification::get_obj_size());
sat::constraint_base::initialize(mem, this);
auto* constraint = new (sat::constraint_base::ptr2mem(mem)) bv_justification(v1, v2, c, a);
Expand Down
3 changes: 2 additions & 1 deletion src/sat/smt/euf_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ namespace euf {
if (!use_drat())
return;
literal_vector lits;
for (literal lit : r) lits.push_back(~lit);
for (literal lit : r)
lits.push_back(~lit);
if (l != sat::null_literal)
lits.push_back(l);
get_drat().add(lits, sat::status::th(true, get_id()));
Expand Down
7 changes: 7 additions & 0 deletions src/sat/smt/euf_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,13 @@ namespace euf {
finish_reinit();
for (auto* e : m_solvers)
e->pop_reinit();

#if 0
for (enode* n : m_egraph.nodes()) {
if (n->bool_var() != sat::null_bool_var && s().is_free(n->bool_var()))
std::cout << "has free " << n->bool_var() << "\n";
}
#endif
}

bool solver::validate() {
Expand Down
2 changes: 1 addition & 1 deletion src/sat/tactic/goal2sat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
sat::bool_var to_bool_var(expr* e) override {
sat::literal l;
sat::bool_var v = m_map.to_bool_var(e);
if (v != sat::null_bool_var)
if (v != sat::null_bool_var)
return v;
if (is_app(e) && m_cache.find(to_app(e), l) && !l.sign())
return l.var();
Expand Down
22 changes: 14 additions & 8 deletions src/shell/drat_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ class smt_checker {

void add_units() {
auto const& units = m_drat.units();
#if 0
for (unsigned i = m_units.size(); i < units.size(); ++i) {
sat::literal lit = units[i];
m_lemma_solver->assert_expr(lit2expr(lit));
}
#endif
m_units.append(units.size() - m_units.size(), units.c_ptr() + m_units.size());
}

Expand Down Expand Up @@ -113,20 +115,22 @@ class smt_checker {
std::cout << "drup\n";
return;
}
m_lemma_solver->push();
for (auto lit : drup_units)
m_lemma_solver->assert_expr(lit2expr(lit));
lbool is_sat = m_lemma_solver->check_sat();
m_input_solver->push();
// for (auto lit : drup_units)
// m_input_solver->assert_expr(lit2expr(lit));
for (auto lit : lits)
m_input_solver->assert_expr(lit2expr(~lit));
lbool is_sat = m_input_solver->check_sat();
if (is_sat != l_false) {
std::cout << "did not verify: " << lits << "\n";
for (sat::literal lit : lits) {
std::cout << lit2expr(lit) << "\n";
}
std::cout << "\n";
m_lemma_solver->display(std::cout);
m_input_solver->display(std::cout);
exit(0);
}
m_lemma_solver->pop(1);
m_input_solver->pop(1);
std::cout << "smt\n";
// check_assertion_redundant(lits);
}
Expand Down Expand Up @@ -280,8 +284,10 @@ static void verify_smt(char const* drat_file, char const* smt_file) {
switch (r.m_tag) {
case dimacs::drat_record::tag_t::is_clause:
checker.add(r.m_lits, r.m_status);
if (drat_checker.inconsistent())
std::cout << "inconsistent\n";
if (drat_checker.inconsistent()) {
std::cout << "inconsistent\n";
return;
}
break;
case dimacs::drat_record::tag_t::is_node: {
expr_ref e(m);
Expand Down
15 changes: 9 additions & 6 deletions src/smt/seq_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,15 @@ namespace smt {
return;
}

update_state_graph(r);

if (m_state_graph.is_dead(get_state_id(r))) {
STRACE("seq_regex_brief", tout << "(dead) ";);
th.add_axiom(~lit);
return;
auto info = re().get_info(r);
if (info.interpreted) {
update_state_graph(r);

if (m_state_graph.is_dead(get_state_id(r))) {
STRACE("seq_regex_brief", tout << "(dead) ";);
th.add_axiom(~lit);
return;
}
}

if (block_unfolding(lit, idx)) {
Expand Down

0 comments on commit 12198d1

Please sign in to comment.