abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SimpSolver.cpp
Go to the documentation of this file.
1 /***********************************************************************************[SimpSolver.cc]
2 Copyright (c) 2006, Niklas Een, Niklas Sorensson
3 Copyright (c) 2007-2010, Niklas Sorensson
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 associated documentation files (the "Software"), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge, publish, distribute,
8 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all copies or
12 substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
18 OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 **************************************************************************************************/
20 
21 #include "Sort.h"
22 #include "SimpSolver.h"
23 #include "System.h"
24 
25 using namespace Minisat;
26 
27 //=================================================================================================
28 // Options:
29 
30 
31 static const char* _cat = "SIMP";
32 
33 static BoolOption opt_use_asymm (_cat, "asymm", "Shrink clauses by asymmetric branching.", false);
34 static BoolOption opt_use_rcheck (_cat, "rcheck", "Check if a clause is already implied. (costly)", false);
35 static BoolOption opt_use_elim (_cat, "elim", "Perform variable elimination.", true);
36 static IntOption opt_grow (_cat, "grow", "Allow a variable elimination step to grow by a number of clauses.", 0);
37 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));
38 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));
39 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));
40 
41 
42 //=================================================================================================
43 // Constructor/Destructor:
44 
45 
47  grow (opt_grow)
48  , clause_lim (opt_clause_lim)
49  , subsumption_lim (opt_subsumption_lim)
50  , simp_garbage_frac (opt_simp_garbage_frac)
51  , use_asymm (opt_use_asymm)
52  , use_rcheck (opt_use_rcheck)
53  , use_elim (opt_use_elim)
54  , merges (0)
55  , asymm_lits (0)
56  , eliminated_vars (0)
57  , elimorder (1)
58  , use_simplification (true)
59  , occurs (ClauseDeleted(ca))
60  , elim_heap (ElimLt(n_occ))
61  , bwdsub_assigns (0)
62  , n_touched (0)
63 {
64  vec<Lit> dummy(1,lit_Undef);
65  ca.extra_clause_field = true; // NOTE: must happen before allocating the dummy clause below.
66  bwdsub_tmpunit = ca.alloc(dummy);
67  remove_satisfied = false;
68 }
69 
70 
72 {
73 }
74 
75 
76 Var SimpSolver::newVar(bool sign, bool dvar) {
77  Var v = Solver::newVar(sign, dvar);
78 
79  frozen .push((char)false);
80  eliminated.push((char)false);
81 
82  if (use_simplification){
83  n_occ .push(0);
84  n_occ .push(0);
85  occurs .init(v);
86  touched .push(0);
87  elim_heap .insert(v);
88  }
89  return v; }
90 
91 
92 
93 lbool SimpSolver::solve_(bool do_simp, bool turn_off_simp)
94 {
95  vec<Var> extra_frozen;
97 
98  do_simp &= use_simplification;
99 
100  if (do_simp){
101  // Assumptions must be temporarily frozen to run variable elimination:
102  for (int i = 0; i < assumptions.size(); i++){
103  Var v = var(assumptions[i]);
104 
105  // If an assumption has been eliminated, remember it.
106  assert(!isEliminated(v));
107 
108  if (!frozen[v]){
109  // Freeze and store.
110  setFrozen(v, true);
111  extra_frozen.push(v);
112  } }
113 
114  result = lbool(eliminate(turn_off_simp));
115  }
116 
117  if (result == l_True)
118  result = Solver::solve_();
119  else if (verbosity >= 1)
120  printf("===============================================================================\n");
121 
122  if (result == l_True)
123  extendModel();
124 
125  if (do_simp)
126  // Unfreeze the assumptions that were frozen:
127  for (int i = 0; i < extra_frozen.size(); i++)
128  setFrozen(extra_frozen[i], false);
129 
130  return result;
131 }
132 
133 
134 
136 {
137 #ifndef NDEBUG
138  for (int i = 0; i < ps.size(); i++)
139  assert(!isEliminated(var(ps[i])));
140 #endif
141 
142  int nclauses = clauses.size();
143 
144  if (use_rcheck && implied(ps))
145  return true;
146 
147  if (!Solver::addClause_(ps))
148  return false;
149 
150  if (use_simplification && clauses.size() == nclauses + 1){
151  CRef cr = clauses.last();
152  const Clause& c = ca[cr];
153 
154  // NOTE: the clause is added to the queue immediately and then
155  // again during 'gatherTouchedClauses()'. If nothing happens
156  // in between, it will only be checked once. Otherwise, it may
157  // be checked twice unnecessarily. This is an unfortunate
158  // consequence of how backward subsumption is used to mimic
159  // forward subsumption.
161  for (int i = 0; i < c.size(); i++){
162  occurs[var(c[i])].push(cr);
163  n_occ[toInt(c[i])]++;
164  touched[var(c[i])] = 1;
165  n_touched++;
166  if (elim_heap.inHeap(var(c[i])))
167  elim_heap.increase(var(c[i]));
168  }
169  }
170 
171  return true;
172 }
173 
174 
176 {
177  const Clause& c = ca[cr];
178 
179  if (use_simplification)
180  for (int i = 0; i < c.size(); i++){
181  n_occ[toInt(c[i])]--;
182  updateElimHeap(var(c[i]));
183  occurs.smudge(var(c[i]));
184  }
185 
187 }
188 
189 
191 {
192  Clause& c = ca[cr];
193  assert(decisionLevel() == 0);
195 
196  // FIX: this is too inefficient but would be nice to have (properly implemented)
197  // if (!find(subsumption_queue, &c))
199 
200  if (c.size() == 2){
201  removeClause(cr);
202  c.strengthen(l);
203  }else{
204  detachClause(cr, true);
205  c.strengthen(l);
206  attachClause(cr);
207  remove(occurs[var(l)], cr);
208  n_occ[toInt(l)]--;
209  updateElimHeap(var(l));
210  }
211 
212  return c.size() == 1 ? enqueue(c[0]) && propagate() == CRef_Undef : true;
213 }
214 
215 
216 // Returns FALSE if clause is always satisfied ('out_clause' should not be used).
217 bool SimpSolver::merge(const Clause& _ps, const Clause& _qs, Var v, vec<Lit>& out_clause)
218 {
219  merges++;
220  out_clause.clear();
221 
222  bool ps_smallest = _ps.size() < _qs.size();
223  const Clause& ps = ps_smallest ? _qs : _ps;
224  const Clause& qs = ps_smallest ? _ps : _qs;
225  int i, j;
226 
227  for (i = 0; i < qs.size(); i++){
228  if (var(qs[i]) != v){
229  for (j = 0; j < ps.size(); j++)
230  if (var(ps[j]) == var(qs[i]))
231  if (ps[j] == ~qs[i])
232  return false;
233  else
234  goto next;
235  out_clause.push(qs[i]);
236  }
237  next:;
238  }
239 
240  for (i = 0; i < ps.size(); i++)
241  if (var(ps[i]) != v)
242  out_clause.push(ps[i]);
243 
244  return true;
245 }
246 
247 
248 // Returns FALSE if clause is always satisfied.
249 bool SimpSolver::merge(const Clause& _ps, const Clause& _qs, Var v, int& size)
250 {
251  merges++;
252 
253  bool ps_smallest = _ps.size() < _qs.size();
254  const Clause& ps = ps_smallest ? _qs : _ps;
255  const Clause& qs = ps_smallest ? _ps : _qs;
256  const Lit* __ps = (const Lit*)ps;
257  const Lit* __qs = (const Lit*)qs;
258 
259  size = ps.size()-1;
260 
261  for (int i = 0; i < qs.size(); i++){
262  if (var(__qs[i]) != v){
263  for (int j = 0; j < ps.size(); j++)
264  if (var(__ps[j]) == var(__qs[i]))
265  if (__ps[j] == ~__qs[i])
266  return false;
267  else
268  goto next;
269  size++;
270  }
271  next:;
272  }
273 
274  return true;
275 }
276 
277 
279 {
280  if (n_touched == 0) return;
281 
282  int i,j;
283  for (i = j = 0; i < subsumption_queue.size(); i++)
284  if (ca[subsumption_queue[i]].mark() == 0)
285  ca[subsumption_queue[i]].mark(2);
286 
287  for (i = 0; i < touched.size(); i++)
288  if (touched[i]){
289  const vec<CRef>& cs = occurs.lookup(i);
290  for (j = 0; j < cs.size(); j++)
291  if (ca[cs[j]].mark() == 0){
292  subsumption_queue.insert(cs[j]);
293  ca[cs[j]].mark(2);
294  }
295  touched[i] = 0;
296  }
297 
298  for (i = 0; i < subsumption_queue.size(); i++)
299  if (ca[subsumption_queue[i]].mark() == 2)
300  ca[subsumption_queue[i]].mark(0);
301 
302  n_touched = 0;
303 }
304 
305 
307 {
308  assert(decisionLevel() == 0);
309 
310  trail_lim.push(trail.size());
311  for (int i = 0; i < c.size(); i++)
312  if (value(c[i]) == l_True){
313  cancelUntil(0);
314  return false;
315  }else if (value(c[i]) != l_False){
316  assert(value(c[i]) == l_Undef);
317  uncheckedEnqueue(~c[i]);
318  }
319 
320  bool result = propagate() != CRef_Undef;
321  cancelUntil(0);
322  return result;
323 }
324 
325 
326 // Backward subsumption + backward subsumption resolution
328 {
329  int cnt = 0;
330  int subsumed = 0;
331  int deleted_literals = 0;
332  assert(decisionLevel() == 0);
333 
334  while (subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()){
335 
336  // Empty subsumption queue and return immediately on user-interrupt:
337  if (asynch_interrupt){
339  bwdsub_assigns = trail.size();
340  break; }
341 
342  // Check top-level assignments by creating a dummy clause and placing it in the queue:
343  if (subsumption_queue.size() == 0 && bwdsub_assigns < trail.size()){
344  Lit l = trail[bwdsub_assigns++];
345  ca[bwdsub_tmpunit][0] = l;
346  ca[bwdsub_tmpunit].calcAbstraction();
348 
350  Clause& c = ca[cr];
351 
352  if (c.mark()) continue;
353 
354  if (verbose && verbosity >= 2 && cnt++ % 1000 == 0)
355  printf("subsumption left: %10d (%10d subsumed, %10d deleted literals)\r", subsumption_queue.size(), subsumed, deleted_literals);
356 
357  assert(c.size() > 1 || value(c[0]) == l_True); // Unit-clauses should have been propagated before this point.
358 
359  // Find best variable to scan:
360  Var best = var(c[0]);
361  for (int i = 1; i < c.size(); i++)
362  if (occurs[var(c[i])].size() < occurs[best].size())
363  best = var(c[i]);
364 
365  // Search all candidates:
366  vec<CRef>& _cs = occurs.lookup(best);
367  CRef* cs = (CRef*)_cs;
368 
369  for (int j = 0; j < _cs.size(); j++)
370  if (c.mark())
371  break;
372  else if (!ca[cs[j]].mark() && cs[j] != cr && (subsumption_lim == -1 || ca[cs[j]].size() < subsumption_lim)){
373  Lit l = c.subsumes(ca[cs[j]]);
374 
375  if (l == lit_Undef)
376  subsumed++, removeClause(cs[j]);
377  else if (l != lit_Error){
378  deleted_literals++;
379 
380  if (!strengthenClause(cs[j], ~l))
381  return false;
382 
383  // Did current candidate get deleted from cs? Then check candidate at index j again:
384  if (var(l) == best)
385  j--;
386  }
387  }
388  }
389 
390  return true;
391 }
392 
393 
395 {
396  Clause& c = ca[cr];
397  assert(decisionLevel() == 0);
398 
399  if (c.mark() || satisfied(c)) return true;
400 
401  trail_lim.push(trail.size());
402  Lit l = lit_Undef;
403  for (int i = 0; i < c.size(); i++)
404  if (var(c[i]) != v && value(c[i]) != l_False)
405  uncheckedEnqueue(~c[i]);
406  else
407  l = c[i];
408 
409  if (propagate() != CRef_Undef){
410  cancelUntil(0);
411  asymm_lits++;
412  if (!strengthenClause(cr, l))
413  return false;
414  }else
415  cancelUntil(0);
416 
417  return true;
418 }
419 
420 
422 {
424 
425  const vec<CRef>& cls = occurs.lookup(v);
426 
427  if (value(v) != l_Undef || cls.size() == 0)
428  return true;
429 
430  for (int i = 0; i < cls.size(); i++)
431  if (!asymm(v, cls[i]))
432  return false;
433 
434  return backwardSubsumptionCheck();
435 }
436 
437 
438 static void mkElimClause(vec<uint32_t>& elimclauses, Lit x)
439 {
440  elimclauses.push(toInt(x));
441  elimclauses.push(1);
442 }
443 
444 
445 static void mkElimClause(vec<uint32_t>& elimclauses, Var v, Clause& c)
446 {
447  int first = elimclauses.size();
448  int v_pos = -1;
449 
450  // Copy clause to elimclauses-vector. Remember position where the
451  // variable 'v' occurs:
452  for (int i = 0; i < c.size(); i++){
453  elimclauses.push(toInt(c[i]));
454  if (var(c[i]) == v)
455  v_pos = i + first;
456  }
457  assert(v_pos != -1);
458 
459  // Swap the first literal with the 'v' literal, so that the literal
460  // containing 'v' will occur first in the clause:
461  uint32_t tmp = elimclauses[v_pos];
462  elimclauses[v_pos] = elimclauses[first];
463  elimclauses[first] = tmp;
464 
465  // Store the length of the clause last:
466  elimclauses.push(c.size());
467 }
468 
469 
470 
472 {
473  assert(!frozen[v]);
474  assert(!isEliminated(v));
475  assert(value(v) == l_Undef);
476  int i;
477 
478  // Split the occurrences into positive and negative:
479  //
480  const vec<CRef>& cls = occurs.lookup(v);
481  vec<CRef> pos, neg;
482  for (i = 0; i < cls.size(); i++)
483  (find(ca[cls[i]], mkLit(v)) ? pos : neg).push(cls[i]);
484 
485  // Check wether the increase in number of clauses stays within the allowed ('grow'). Moreover, no
486  // clause must exceed the limit on the maximal clause size (if it is set):
487  //
488  int cnt = 0;
489  int clause_size = 0;
490 
491  for (i = 0; i < pos.size(); i++)
492  for (int j = 0; j < neg.size(); j++)
493  if (merge(ca[pos[i]], ca[neg[j]], v, clause_size) &&
494  (++cnt > cls.size() + grow || (clause_lim != -1 && clause_size > clause_lim)))
495  return true;
496 
497  // Delete and store old clauses:
498  eliminated[v] = true;
499  setDecisionVar(v, false);
500  eliminated_vars++;
501 
502  if (pos.size() > neg.size()){
503  for (int i = 0; i < neg.size(); i++)
504  mkElimClause(elimclauses, v, ca[neg[i]]);
506  }else{
507  for (int i = 0; i < pos.size(); i++)
508  mkElimClause(elimclauses, v, ca[pos[i]]);
510  }
511 
512  for (i = 0; i < cls.size(); i++)
513  removeClause(cls[i]);
514 
515  // Produce clauses in cross product:
516  vec<Lit>& resolvent = add_tmp;
517  for (i = 0; i < pos.size(); i++)
518  for (int j = 0; j < neg.size(); j++)
519  if (merge(ca[pos[i]], ca[neg[j]], v, resolvent) && !addClause_(resolvent))
520  return false;
521 
522  // Free occurs list for this variable:
523  occurs[v].clear(true);
524 
525  // Free watchers lists for this variable, if possible:
526  if (watches[ mkLit(v)].size() == 0) watches[ mkLit(v)].clear(true);
527  if (watches[~mkLit(v)].size() == 0) watches[~mkLit(v)].clear(true);
528 
529  return backwardSubsumptionCheck();
530 }
531 
532 
534 {
535  assert(!frozen[v]);
536  assert(!isEliminated(v));
537  assert(value(v) == l_Undef);
538 
539  if (!ok) return false;
540 
541  eliminated[v] = true;
542  setDecisionVar(v, false);
543  const vec<CRef>& cls = occurs.lookup(v);
544 
545  vec<Lit>& subst_clause = add_tmp;
546  for (int i = 0; i < cls.size(); i++){
547  Clause& c = ca[cls[i]];
548 
549  subst_clause.clear();
550  for (int j = 0; j < c.size(); j++){
551  Lit p = c[j];
552  subst_clause.push(var(p) == v ? x ^ sign(p) : p);
553  }
554 
555  removeClause(cls[i]);
556 
557  if (!addClause_(subst_clause))
558  return ok = false;
559  }
560 
561  return true;
562 }
563 
564 
566 {
567  int i, j;
568  Lit x;
569 
570  for (i = elimclauses.size()-1; i > 0; i -= j){
571  for (j = elimclauses[i--]; j > 1; j--, i--)
572  if (modelValue(toLit(elimclauses[i])) != l_False)
573  goto next;
574 
575  x = toLit(elimclauses[i]);
576  model[var(x)] = lbool(!sign(x));
577  next:;
578  }
579 }
580 
581 
582 bool SimpSolver::eliminate(bool turn_off_elim)
583 {
584  if (!simplify())
585  return false;
586  else if (!use_simplification)
587  return true;
588 
589  // Main simplification loop:
590  //
591  while (n_touched > 0 || bwdsub_assigns < trail.size() || elim_heap.size() > 0){
592 
594  // printf(" ## (time = %6.2f s) BWD-SUB: queue = %d, trail = %d\n", cpuTime(), subsumption_queue.size(), trail.size() - bwdsub_assigns);
595  if ((subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()) &&
596  !backwardSubsumptionCheck(true)){
597  ok = false; goto cleanup; }
598 
599  // Empty elim_heap and return immediately on user-interrupt:
600  if (asynch_interrupt){
601  assert(bwdsub_assigns == trail.size());
602  assert(subsumption_queue.size() == 0);
603  assert(n_touched == 0);
604  elim_heap.clear();
605  goto cleanup; }
606 
607  // printf(" ## (time = %6.2f s) ELIM: vars = %d\n", cpuTime(), elim_heap.size());
608  for (int cnt = 0; !elim_heap.empty(); cnt++){
609  Var elim = elim_heap.removeMin();
610 
611  if (asynch_interrupt) break;
612 
613  if (isEliminated(elim) || value(elim) != l_Undef) continue;
614 
615  if (verbosity >= 2 && cnt % 100 == 0)
616  printf("elimination left: %10d\r", elim_heap.size());
617 
618  if (use_asymm){
619  // Temporarily freeze variable. Otherwise, it would immediately end up on the queue again:
620  bool was_frozen = frozen[elim];
621  frozen[elim] = true;
622  if (!asymmVar(elim)){
623  ok = false; goto cleanup; }
624  frozen[elim] = was_frozen; }
625 
626  // At this point, the variable may have been set by assymetric branching, so check it
627  // again. Also, don't eliminate frozen variables:
628  if (use_elim && value(elim) == l_Undef && !frozen[elim] && !eliminateVar(elim)){
629  ok = false; goto cleanup; }
630 
632  }
633 
634  assert(subsumption_queue.size() == 0);
635  }
636  cleanup:
637 
638  // If no more simplification is needed, free all simplification-related data structures:
639  if (turn_off_elim){
640  touched .clear(true);
641  occurs .clear(true);
642  n_occ .clear(true);
643  elim_heap.clear(true);
644  subsumption_queue.clear(true);
645 
646  use_simplification = false;
647  remove_satisfied = true;
648  ca.extra_clause_field = false;
649 
650  // Force full cleanup (this is safe and desirable since it only happens once):
652  garbageCollect();
653  }else{
654  // Cheaper cleanup:
655  cleanUpClauses(); // TODO: can we make 'cleanUpClauses()' not be linear in the problem size somehow?
656  checkGarbage();
657  }
658 
659  if (verbosity >= 1 && elimclauses.size() > 0)
660  printf("| Eliminated clauses: %10.2f Mb |\n",
661  double(elimclauses.size() * sizeof(uint32_t)) / (1024*1024));
662 
663  return ok;
664 }
665 
666 
668 {
669  occurs.cleanAll();
670  int i,j;
671  for (i = j = 0; i < clauses.size(); i++)
672  if (ca[clauses[i]].mark() == 0)
673  clauses[j++] = clauses[i];
674  clauses.shrink(i - j);
675 }
676 
677 
678 //=================================================================================================
679 // Garbage Collection methods:
680 
681 
683 {
684  if (!use_simplification) return;
685 
686  // All occurs lists:
687  //
688  int i;
689  for (i = 0; i < nVars(); i++){
690  vec<CRef>& cs = occurs[i];
691  for (int j = 0; j < cs.size(); j++)
692  ca.reloc(cs[j], to);
693  }
694 
695  // Subsumption queue:
696  //
697  for (i = 0; i < subsumption_queue.size(); i++)
698  ca.reloc(subsumption_queue[i], to);
699 
700  // Temporary clause:
701  //
702  ca.reloc(bwdsub_tmpunit, to);
703 }
704 
705 
707 {
708  // Initialize the next region to a size corresponding to the estimated utilization degree. This
709  // is not precise but should avoid some unnecessary reallocations for the new region:
710  ClauseAllocator to(ca.size() - ca.wasted());
711 
712  cleanUpClauses();
713  to.extra_clause_field = ca.extra_clause_field; // NOTE: this is important to keep (or lose) the extra fields.
714  relocAll(to);
715  Solver::relocAll(to);
716  if (verbosity >= 2)
717  printf("| Garbage collection: %12d bytes => %12d bytes |\n",
719  to.moveTo(ca);
720 }
uint32_t size() const
Definition: Alloc.h:56
RegionAllocator< uint32_t >::Ref CRef
Definition: SolverTypes.h:120
#define INT32_MAX
Definition: pstdint.h:415
uint32_t wasted() const
Definition: Alloc.h:57
void removeClause(CRef cr)
Definition: SimpSolver.cpp:175
vec< int > n_occ
Definition: SimpSolver.h:132
ClauseAllocator ca
Definition: Solver.h:193
char lbool
Definition: satVec.h:133
bool simplify()
Definition: Solver.cpp:577
void relocAll(ClauseAllocator &to)
Definition: Solver.cpp:876
OccLists< Var, vec< CRef >, ClauseDeleted > occurs
Definition: SimpSolver.h:131
static Llb_Mgr_t * p
Definition: llb3Image.c:950
lbool modelValue(Var x) const
Definition: Solver.h:323
#define l_Undef
Definition: SolverTypes.h:86
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))
static BoolOption opt_use_elim(_cat,"elim","Perform variable elimination.", true)
int var(Lit p)
Definition: SolverTypes.h:62
void setFrozen(Var v, bool b)
Definition: SimpSolver.h:182
void strengthen(Lit p)
Definition: SolverTypes.h:398
bool pos
Definition: globals.c:30
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))
Queue< CRef > subsumption_queue
Definition: SimpSolver.h:134
int size() const
Definition: Queue.h:42
vec< uint32_t > elimclauses
Definition: SimpSolver.h:128
#define l_True
Definition: SolverTypes.h:84
CRef alloc(const Lits &ps, bool learnt=false)
Definition: SolverTypes.h:209
bool sign(Lit p)
Definition: SolverTypes.h:61
#define HUGE_VAL
Definition: util_old.h:295
void clear(bool dealloc=false)
Definition: Queue.h:41
void attachClause(CRef cr)
Definition: Solver.cpp:162
void pop()
Definition: Queue.h:48
Lit mkLit(Var var, bool sign)
Definition: SolverTypes.h:58
void setDecisionVar(Var v, bool b)
Definition: Solver.h:331
void cancelUntil(int level)
Definition: Solver.cpp:207
void insert(T elem)
Definition: Queue.h:49
void updateElimHeap(Var v)
Definition: SimpSolver.h:170
void detachClause(CRef cr, bool strict=false)
Definition: Solver.cpp:171
void push(void)
Definition: Vec.h:73
static BoolOption opt_use_rcheck(_cat,"rcheck","Check if a clause is already implied. (costly)", false)
vec< int > trail_lim
Definition: Solver.h:183
virtual void garbageCollect()
Definition: SimpSolver.cpp:706
int nVars() const
Definition: Solver.h:328
int size(void) const
Definition: Vec.h:63
static int clause_size(clause *c)
Definition: satClause.h:146
bool merge(const Clause &_ps, const Clause &_qs, Var v, vec< Lit > &out_clause)
Definition: SimpSolver.cpp:217
static const char * _cat
Definition: SimpSolver.cpp:31
bool eliminateVar(Var v)
Definition: SimpSolver.cpp:471
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))
const CRef CRef_Undef
Definition: SolverTypes.h:193
static BoolOption opt_use_asymm(_cat,"asymm","Shrink clauses by asymmetric branching.", false)
bool asymm(Var v, CRef cr)
Definition: SimpSolver.cpp:394
int decisionLevel() const
Definition: Solver.h:319
bool asynch_interrupt
Definition: Solver.h:211
bool implied(const vec< Lit > &c)
Definition: SimpSolver.cpp:306
vec< Lit > assumptions
Definition: Solver.h:188
void checkGarbage()
Definition: Solver.h:304
vec< CRef > clauses
Definition: Solver.h:172
void rebuildOrderHeap()
Definition: Solver.cpp:559
void shrink(int nelems)
Definition: Vec.h:64
vec< char > touched
Definition: SimpSolver.h:129
static int size
Definition: cuddSign.c:86
bool addClause_(vec< Lit > &ps)
Definition: Solver.cpp:132
bool strengthenClause(CRef cr, Lit l)
Definition: SimpSolver.cpp:190
void clear(bool dealloc=false)
Definition: Vec.h:121
bool asymmVar(Var v)
Definition: SimpSolver.cpp:421
void reloc(CRef &cr, ClauseAllocator &to)
Definition: SolverTypes.h:234
bool eliminate(bool turn_off_elim=false)
Definition: SimpSolver.cpp:582
T peek() const
Definition: Queue.h:47
void removeClause(CRef cr)
Definition: Solver.cpp:188
void relocAll(ClauseAllocator &to)
Definition: SimpSolver.cpp:682
Heap< ElimLt > elim_heap
Definition: SimpSolver.h:133
vec< lbool > model
Definition: Solver.h:110
bool backwardSubsumptionCheck(bool verbose=false)
Definition: SimpSolver.cpp:327
bool isEliminated(Var v) const
Definition: SimpSolver.h:169
OccLists< Lit, vec< Watcher >, WatcherDeleted > watches
Definition: Solver.h:178
static IntOption opt_grow(_cat,"grow","Allow a variable elimination step to grow by a number of clauses.", 0)
lbool value(Var x) const
Definition: Solver.h:321
lbool solve_()
Definition: Solver.cpp:751
Var newVar(bool polarity=true, bool dvar=true)
Definition: SimpSolver.cpp:76
vec< char > eliminated
Definition: SimpSolver.h:136
bool addClause_(vec< Lit > &ps)
Definition: SimpSolver.cpp:135
#define l_False
Definition: SolverTypes.h:85
int Var
Definition: SolverTypes.h:42
vec< Lit > add_tmp
Definition: Solver.h:201
Var newVar(bool polarity=true, bool dvar=true)
Definition: Solver.cpp:114
bool enqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.h:310
const Lit lit_Error
Definition: SolverTypes.h:73
Lit subsumes(const Clause &other) const
Definition: SolverTypes.h:367
static bool find(V &ts, const T &t)
Definition: Alg.h:47
void uncheckedEnqueue(Lit p, CRef from=CRef_Undef)
Definition: Solver.cpp:429
const Lit lit_Undef
Definition: SolverTypes.h:72
vec< Lit > trail
Definition: Solver.h:182
#define assert(ex)
Definition: util_old.h:213
static void mkElimClause(vec< uint32_t > &elimclauses, Lit x)
Definition: SimpSolver.cpp:438
bool substitute(Var v, Lit x)
Definition: SimpSolver.cpp:533
static int result
Definition: cuddGenetic.c:125
#define true
Definition: place_base.h:28
bool satisfied(const Clause &c) const
Definition: Solver.cpp:198
Lit toLit(int i)
Definition: SolverTypes.h:67
double simp_garbage_frac
Definition: SimpSolver.h:87
CRef propagate()
Definition: Solver.cpp:449
vec< char > frozen
Definition: SimpSolver.h:135
int toInt(Var v)
Definition: SolverTypes.h:65
const T & last(void) const
Definition: Vec.h:82
bool remove_satisfied
Definition: Solver.h:191