Skip to content

Commit 3b90816

Browse files
add option to persist clauses #7109
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent a2fa4ff commit 3b90816

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed

src/smt/params/smt_params.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void smt_params::updt_local_params(params_ref const & _p) {
5151
m_core_validate = p.core_validate();
5252
m_logic = _p.get_sym("logic", m_logic);
5353
m_string_solver = p.string_solver();
54+
m_up_persist_clauses = p.up_persist_clauses();
5455
validate_string_solver(m_string_solver);
5556
if (_p.get_bool("arith.greatest_error_pivot", false))
5657
m_arith_pivot_strategy = arith_pivot_strategy::ARITH_PIVOT_GREATEST_ERROR;
@@ -145,6 +146,7 @@ void smt_params::display(std::ostream & out) const {
145146
DISPLAY_PARAM(m_agility_factor);
146147
DISPLAY_PARAM(m_restart_agility_threshold);
147148

149+
DISPLAY_PARAM(m_up_persist_clauses);
148150
DISPLAY_PARAM(m_lemma_gc_strategy);
149151
DISPLAY_PARAM(m_lemma_gc_half);
150152
DISPLAY_PARAM(m_recent_lemmas_size);

src/smt/params/smt_params.h

+8
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ struct smt_params : public preprocessor_params,
170170
unsigned m_old_clause_relevancy = 6; //!< Max. number of unassigned literals to be considered relevant.
171171
double m_inv_clause_decay = 1; //!< clause activity decay
172172

173+
// -----------------------------------
174+
//
175+
// User propagator configuration
176+
//
177+
// -----------------------------------
178+
179+
bool m_up_persist_clauses = false;
180+
173181
// -----------------------------------
174182
//
175183
// SMT-LIB (debug) pretty printer

src/smt/params/smt_params_helper.pyg

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def_module_params(module_name='smt',
102102
('arith.print_ext_var_names', BOOL, False, 'print external variable names'),
103103
('pb.conflict_frequency', UINT, 1000, 'conflict frequency for Pseudo-Boolean theory'),
104104
('pb.learn_complements', BOOL, True, 'learn complement literals for Pseudo-Boolean theory'),
105+
('up.persist_clauses', BOOL, True, 'replay propagated clauses below the levels they are asserted'),
105106
('array.weak', BOOL, False, 'weak array theory'),
106107
('array.extensional', BOOL, True, 'extensional array theory'),
107108
('clause_proof', BOOL, False, 'record a clausal proof'),

src/smt/theory_user_propagator.cpp

+28-17
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void theory_user_propagator::pop_scope_eh(unsigned num_scopes) {
293293
}
294294

295295
bool theory_user_propagator::can_propagate() {
296-
return m_qhead < m_prop.size() || m_to_add_qhead < m_to_add.size();
296+
return m_qhead < m_prop.size() || m_to_add_qhead < m_to_add.size() || m_replay_qhead < m_clauses_to_replay.size();
297297
}
298298

299299
void theory_user_propagator::propagate_consequence(prop_info const& prop) {
@@ -321,12 +321,10 @@ void theory_user_propagator::propagate_consequence(prop_info const& prop) {
321321
ctx.set_conflict(js);
322322
}
323323
else {
324-
#if 1
325324
for (auto& lit : m_lits)
326325
lit.neg();
327326
for (auto const& [a,b] : m_eqs)
328327
m_lits.push_back(~mk_eq(a->get_expr(), b->get_expr(), false));
329-
#endif
330328

331329
literal lit;
332330
if (has_quantifiers(prop.m_conseq)) {
@@ -340,19 +338,17 @@ void theory_user_propagator::propagate_consequence(prop_info const& prop) {
340338
lit = mk_literal(prop.m_conseq);
341339
ctx.mark_as_relevant(lit);
342340

343-
#if 0
344-
justification* js =
345-
ctx.mk_justification(
346-
ext_theory_propagation_justification(
347-
get_id(), ctx, m_lits.size(), m_lits.data(), m_eqs.size(), m_eqs.data(), lit));
348-
349-
ctx.assign(lit, js);
350-
#endif
351-
352-
#if 1
353341
m_lits.push_back(lit);
354-
ctx.mk_th_lemma(get_id(), m_lits);
355-
#endif
342+
if (ctx.get_fparams().m_up_persist_clauses) {
343+
ctx.mk_th_axiom(get_id(), m_lits);
344+
expr_ref_vector clause(m);
345+
for (auto lit : m_lits)
346+
clause.push_back(ctx.literal2expr(lit));
347+
m_clauses_to_replay.push_back(clause);
348+
}
349+
else {
350+
ctx.mk_th_lemma(get_id(), m_lits);
351+
}
356352
TRACE("user_propagate", ctx.display(tout););
357353
}
358354
}
@@ -363,12 +359,20 @@ void theory_user_propagator::propagate_new_fixed(prop_info const& prop) {
363359

364360

365361
void theory_user_propagator::propagate() {
366-
if (m_qhead == m_prop.size() && m_to_add_qhead == m_to_add.size())
362+
if (m_qhead == m_prop.size() && m_to_add_qhead == m_to_add.size() && m_replay_qhead == m_clauses_to_replay.size())
367363
return;
368364
TRACE("user_propagate", tout << "propagating queue head: " << m_qhead << " prop queue: " << m_prop.size() << "\n");
369365
force_push();
370366

371-
unsigned qhead = m_to_add_qhead;
367+
unsigned qhead = m_replay_qhead;
368+
if (qhead < m_clauses_to_replay.size()) {
369+
for (; qhead < m_clauses_to_replay.size() && !ctx.inconsistent(); ++qhead)
370+
replay_clause(m_clauses_to_replay.get(qhead));
371+
ctx.push_trail(value_trail<unsigned>(m_replay_qhead));
372+
m_replay_qhead = qhead;
373+
}
374+
375+
qhead = m_to_add_qhead;
372376
if (qhead < m_to_add.size()) {
373377
for (; qhead < m_to_add.size(); ++qhead)
374378
add_expr(m_to_add.get(qhead), true);
@@ -391,6 +395,13 @@ void theory_user_propagator::propagate() {
391395
}
392396

393397

398+
void theory_user_propagator::replay_clause(expr_ref_vector const& clause) {
399+
m_lits.reset();
400+
for (expr* e : clause)
401+
m_lits.push_back(mk_literal(e));
402+
ctx.mk_th_axiom(get_id(), m_lits);
403+
}
404+
394405
bool theory_user_propagator::internalize_atom(app* atom, bool gate_ctx) {
395406
return internalize_term(atom);
396407
}

src/smt/theory_user_propagator.h

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ namespace smt {
8686
expr* m_next_split_var = nullptr;
8787
unsigned m_next_split_idx = 0;
8888
lbool m_next_split_phase = l_undef;
89+
vector<expr_ref_vector> m_clauses_to_replay;
90+
unsigned m_replay_qhead = 0;
8991

9092
expr* var2expr(theory_var v) { return m_var2expr.get(v); }
9193
theory_var expr2var(expr* e) { check_defined(e); return m_expr2var[e->get_id()]; }
@@ -101,6 +103,8 @@ namespace smt {
101103

102104
bool_var enode_to_bool(enode* n, unsigned bit);
103105

106+
void replay_clause(expr_ref_vector const& clause);
107+
104108
public:
105109
theory_user_propagator(context& ctx);
106110

0 commit comments

Comments
 (0)