ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cadical_constrain.cpp
Go to the documentation of this file.
1#include "global.h"
2
3#include "internal.hpp"
4
6
7namespace CaDiCaL {
8
10 if (lit)
11 constraint.push_back (lit);
12 else {
13 if (level)
14 backtrack ();
15 LOG (constraint, "shrinking constraint");
16 bool satisfied_constraint = false;
17 const vector<int>::const_iterator end = constraint.end ();
19 for (vector<int>::const_iterator j = i; j != end; j++) {
20 int tmp = marked (*j);
21 if (tmp > 0) {
22 LOG ("removing duplicated literal %d from constraint", *j);
23 } else if (tmp < 0) {
24 LOG ("tautological since both %d and %d occur in constraint", -*j,
25 *j);
26 satisfied_constraint = true;
27 break;
28 } else {
29 tmp = val (*j);
30 if (tmp < 0) {
31 LOG ("removing falsified literal %d from constraint clause", *j);
32 } else if (tmp > 0) {
33 LOG ("satisfied constraint with literal %d", *j);
34 satisfied_constraint = true;
35 break;
36 } else {
37 *i++ = *j;
38 mark (*j);
39 }
40 }
41 }
42 constraint.resize (i - constraint.begin ());
43 for (const auto &lit : constraint)
44 unmark (lit);
45 if (satisfied_constraint)
46 constraint.clear ();
47 else if (constraint.empty ()) {
48 unsat_constraint = true;
49 if (!conflict_id)
50 marked_failed = false; // allow to trigger failing ()
51 } else
52 for (const auto lit : constraint)
53 freeze (lit);
54 }
55}
56
58
60 for (auto lit : constraint)
61 melt (lit);
62 LOG ("cleared %zd constraint literals", constraint.size ());
63 constraint.clear ();
64 unsat_constraint = false;
65 marked_failed = true;
66}
67
68} // namespace CaDiCaL
69
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define LOG(...)
int lit
Definition satVec.h:130
vector< int > constraint
Definition internal.hpp:262
void unmark(int lit)
Definition internal.hpp:490
signed char val(int lit) const
signed char marked(int lit) const
Definition internal.hpp:478
void backtrack(int target_level=0)
void melt(int lit)
void freeze(int lit)
signed char mark
Definition value.h:8