1 #define __STDC_FORMAT_MACROS
2 #define __STDC_LIMIT_MACROS
27 using namespace Minisat;
33 static const char*
_cat =
"SIMP";
38 static IntOption opt_grow (
_cat,
"grow",
"Allow a variable elimination step to grow by a number of clauses.", 0);
61 , use_simplification (true)
63 , elim_heap (
ElimLt(n_occ))
126 extra_frozen.
push(v);
135 printf(
"===============================================================================\n");
142 for (
int i = 0; i < extra_frozen.
size(); i++)
153 for (
int i = 0; i < ps.
size(); i++)
176 for (
int i = 0; i < c.
size(); i++){
195 for (
int i = 0; i < c.
size(); i++){
237 bool ps_smallest = _ps.
size() < _qs.
size();
238 const Clause& ps = ps_smallest ? _qs : _ps;
239 const Clause& qs = ps_smallest ? _ps : _qs;
241 for (
int i = 0; i < qs.
size(); i++){
242 if (
var(qs[i]) != v){
243 for (
int j = 0; j < ps.
size(); j++)
244 if (
var(ps[j]) ==
var(qs[i])){
250 out_clause.
push(qs[i]);
255 for (
int i = 0; i < ps.
size(); i++)
257 out_clause.
push(ps[i]);
268 bool ps_smallest = _ps.
size() < _qs.
size();
269 const Clause& ps = ps_smallest ? _qs : _ps;
270 const Clause& qs = ps_smallest ? _ps : _qs;
271 const Lit* __ps = (
const Lit*)ps;
272 const Lit* __qs = (
const Lit*)qs;
276 for (
int i = 0; i < qs.
size(); i++){
277 if (
var(__qs[i]) != v){
278 for (
int j = 0; j < ps.
size(); j++)
279 if (
var(__ps[j]) ==
var(__qs[i])){
280 if (__ps[j] == ~__qs[i])
303 for (i = 0; i <
nVars(); i++)
306 for (j = 0; j < cs.
size(); j++)
307 if (
ca[cs[j]].mark() == 0){
327 for (
int i = 0; i < c.
size(); i++)
347 int deleted_literals = 0;
368 if (c.
mark())
continue;
370 if (verbose &&
verbosity >= 2 && cnt++ % 1000 == 0)
371 printf(
"subsumption left: %10d (%10d subsumed, %10d deleted literals)\r",
subsumption_queue.
size(), subsumed, deleted_literals);
377 for (
int i = 1; i < c.
size(); i++)
385 for (
int j = 0; j < _cs.
size(); j++)
419 for (
int i = 0; i < c.
size(); i++)
446 for (
int i = 0; i < cls.
size(); i++)
447 if (!
asymm(v, cls[i]))
463 int first = elimclauses.
size();
468 for (
int i = 0; i < c.
size(); i++){
477 uint32_t tmp = elimclauses[v_pos];
478 elimclauses[v_pos] = elimclauses[first];
479 elimclauses[first] = tmp;
497 for (
int i = 0; i < cls.
size(); i++)
498 (
find(
ca[cls[i]],
mkLit(v)) ? pos : neg).push(cls[i]);
506 for (
int i = 0; i < pos.
size(); i++)
507 for (
int j = 0; j < neg.
size(); j++)
508 if (
merge(
ca[pos[i]],
ca[neg[j]], v, clause_size) &&
518 for (
int i = 0; i < neg.
size(); i++)
522 for (
int i = 0; i < pos.
size(); i++)
527 for (
int i = 0; i < cls.
size(); i++)
532 for (
int i = 0; i < pos.
size(); i++)
533 for (
int j = 0; j < neg.
size(); j++)
554 if (!
ok)
return false;
561 for (
int i = 0; i < cls.
size(); i++){
564 subst_clause.
clear();
565 for (
int j = 0; j < c.
size(); j++){
612 ok =
false;
goto cleanup; }
623 for (
int cnt = 0; !
elim_heap.empty(); cnt++){
631 printf(
"elimination left: %10d\r",
elim_heap.size());
635 bool was_frozen =
frozen[elim];
638 ok =
false;
goto cleanup; }
639 frozen[elim] = was_frozen; }
644 ok =
false;
goto cleanup; }
675 printf(
"| Eliminated clauses: %10.2f Mb |\n",
692 for (
int i = 0; i <
nVars(); i++){
695 for (
int j = 0; j < cs.
size(); j++)
703 if (
ca[cr].mark())
continue;
724 printf(
"| Garbage collection: %12d bytes => %12d bytes |\n",
RegionAllocator< uint32_t >::Ref CRef
void removeClause(CRef cr)
const lbool l_False((uint8_t) 1)
void insert(K key, V val, V pad)
static DoubleOption opt_simp_garbage_frac(_cat,"simp-gc-frac","The fraction of wasted memory allowed before a garbage collection is triggered during simplification.", 0.5, DoubleRange(0, false, HUGE_VAL, false))
void gatherTouchedClauses()
void relocAll(ClauseAllocator &to)
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
Lit mkLit(Var var, bool sign=false)
lbool modelValue(Var x) const
void setFrozen(Var v, bool b)
void clear(bool dispose=false)
Queue< CRef > subsumption_queue
vec< uint32_t > elimclauses
bool addClause(const vec< Lit > &ps)
static IntOption opt_clause_lim(_cat,"cl-lim","Variables are not eliminated if it produces a resolvent with a length above this limit. -1 means no limit", 20, IntRange(-1, INT32_MAX))
void clear(bool dealloc=false)
const lbool l_Undef((uint8_t) 2)
void attachClause(CRef cr)
const T & last(void) const
void setDecisionVar(Var v, bool b)
void cancelUntil(int level)
Var newVar(lbool upol=l_Undef, bool dvar=true)
void updateElimHeap(Var v)
void detachClause(CRef cr, bool strict=false)
virtual void garbageCollect()
static BoolOption opt_use_asymm(_cat,"asymm","Shrink clauses by asymmetric branching.", false)
bool merge(const Clause &_ps, const Clause &_qs, Var v, vec< Lit > &out_clause)
bool asymm(Var v, CRef cr)
int decisionLevel() const
bool implied(const vec< Lit > &c)
Heap< Var, ElimLt > elim_heap
bool addClause_(vec< Lit > &ps)
bool strengthenClause(CRef cr, Lit l)
void reloc(CRef &cr, ClauseAllocator &to)
bool eliminate(bool turn_off_elim=false)
void removeClause(CRef cr)
void relocAll(ClauseAllocator &to)
bool backwardSubsumptionCheck(bool verbose=false)
Var newVar(lbool upol=l_Undef, bool dvar=true)
bool isEliminated(Var v) const
const lbool l_True((uint8_t) 0)
static BoolOption opt_use_elim(_cat,"elim","Perform variable elimination.", true)
static void mkElimClause(vec< uint32_t > &elimclauses, Lit x)
void clear(bool dealloc=false)
CRef alloc(const vec< Lit > &ps, bool learnt=false)
bool addClause_(vec< Lit > &ps)
bool enqueue(Lit p, CRef from=CRef_Undef)
Lit subsumes(const Clause &other) const
static bool find(V &ts, const T &t)
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
static BoolOption opt_use_rcheck(_cat,"rcheck","Check if a clause is already implied. (costly)", false)
bool substitute(Var v, Lit x)
bool satisfied(const Clause &c) const
OccLists< Lit, vec< Watcher >, WatcherDeleted, MkIndexLit > watches
static IntOption opt_grow(_cat,"grow","Allow a variable elimination step to grow by a number of clauses.", 0)
static IntOption opt_subsumption_lim(_cat,"sub-lim","Do not check if subsumption against a clause larger than this. -1 means no limit.", 1000, IntRange(-1, INT32_MAX))