diff --git a/src/sat/sat_drat.cpp b/src/sat/sat_drat.cpp index fb161a998..6d0c2979b 100644 --- a/src/sat/sat_drat.cpp +++ b/src/sat/sat_drat.cpp @@ -58,7 +58,6 @@ namespace sat { } void drat::dump(unsigned n, literal const* c, status st) { - if (is_cleaned(n, c)) return; switch (st) { case status::asserted: return; case status::external: return; // requires extension to drat format. @@ -69,8 +68,9 @@ namespace sat { (*m_out) << "0\n"; } - bool drat::is_cleaned(unsigned n, literal const* c) const { + bool drat::is_cleaned(clause& c) const { literal last = null_literal; + unsigned n = c.size(); for (unsigned i = 0; i < n; ++i) { if (c[i] == last) return true; last = c[i]; @@ -133,7 +133,6 @@ namespace sat { void drat::append(clause& c, status st) { unsigned n = c.size(); - if (is_cleaned(n, c.begin())) return; trace(std::cout, n, c.begin(), st); if (st == status::learned) { @@ -394,10 +393,13 @@ namespace sat { void drat::del(literal l1, literal l2) { literal ls[2] = {l1, l2}; if (m_out) dump(2, ls, status::deleted); - if (s.m_config.m_drat_check) append(l1, l2, status::deleted); + if (s.m_config.m_drat_check) + append(l1, l2, status::deleted); } void drat::del(clause& c) { if (m_out) dump(c.size(), c.begin(), status::deleted); - if (s.m_config.m_drat_check) append(c, status::deleted); + if (s.m_config.m_drat_check) + append(c, status::deleted); + else s.m_cls_allocator.del_clause(&c); } } diff --git a/src/sat/sat_drat.h b/src/sat/sat_drat.h index fd4b3f868..7236d8065 100644 --- a/src/sat/sat_drat.h +++ b/src/sat/sat_drat.h @@ -28,10 +28,10 @@ namespace sat { enum { t_clause, t_unit, t_ext } m_type; union { clause* m_clause; - literal m_literal; + unsigned m_literal; }; - premise(s_ext, literal l): m_type(t_ext), m_literal(l) {} - premise(s_unit, literal l): m_type(t_unit), m_literal(l) {} + premise(s_ext, literal l): m_type(t_ext), m_literal(l.index()) {} + premise(s_unit, literal l): m_type(t_unit), m_literal(l.index()) {} premise(clause* c): m_type(t_clause), m_clause(c) {} }; private: @@ -52,7 +52,6 @@ namespace sat { void append(clause& c, status st); friend std::ostream& operator<<(std::ostream & out, status st); status get_status(bool learned) const; - bool is_cleaned(unsigned n, literal const* lits) const; void declare(literal l); void assign(literal l); @@ -74,7 +73,8 @@ namespace sat { void add(literal l1, literal l2, bool learned); void add(clause& c, bool learned); void add(literal_vector const& c, svector const& premises); - + + bool is_cleaned(clause& c) const; void del(literal l); void del(literal l1, literal l2); void del(clause& c); diff --git a/src/sat/sat_par.cpp b/src/sat/sat_par.cpp index ec6e39822..8d2c20d56 100644 --- a/src/sat/sat_par.cpp +++ b/src/sat/sat_par.cpp @@ -84,7 +84,7 @@ namespace sat { break; } SASSERT(head < m_size); - IF_VERBOSE((iterations > m_size ? 0 : 3), verbose_stream() << owner << ": head: " << head << " tail: " << m_tail << "\n";); + IF_VERBOSE(static_cast(iterations > m_size ? 0 : 3), verbose_stream() << owner << ": head: " << head << " tail: " << m_tail << "\n";); bool is_self = owner == get_owner(head); next(m_heads[owner]); if (!is_self) { diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 9b50db8e8..221140590 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -209,10 +209,10 @@ namespace sat { if (!c.is_learned()) { m_stats.m_non_learned_generation++; } - if (m_config.m_drat) { + if (m_config.m_drat && !m_drat.is_cleaned(c)) { m_drat.del(c); } - else if (!m_config.m_drat || !m_config.m_drat_check) { + else if (!m_config.m_drat || !m_config.m_drat_check || m_drat.is_cleaned(c)) { m_cls_allocator.del_clause(&c); } m_stats.m_del_clause++;