42 #define var_Undef (-1) 61 inline int var (
Lit p) {
return p.
x >> 1; }
73 const Lit lit_Undef = { -2 };
74 const Lit lit_Error = { -1 };
85 #define l_True (lbool((uint8_t)0)) // gcc does not do constant propagation if these are real constants. 86 #define l_False (lbool((uint8_t)1)) 87 #define l_Undef (lbool((uint8_t)2)) 88 #define l_Timeout (lbool((uint8_t)9)) // HEDTKE 94 explicit lbool(uint8_t v) : value(v) { }
97 explicit lbool(
bool x) : value(!x) { }
103 return (( (b.
value & 2) & (value & 2) ) | (((b.
value & 2) == 0) & (value == b.
value))) != 0;
110 uint8_t sel = (this->value << 1) | (b.
value << 3);
111 uint8_t v = (0xF7F755F4 >> sel) & 3;
115 uint8_t sel = (this->value << 1) | (b.
value << 3);
116 uint8_t v = (0xFCFCF400 >> sel) & 3;
132 #pragma warning ( push ) 133 #pragma warning ( disable : 4200 ) 143 union {
Lit lit;
float act; uint32_t abs;
CRef rel; } data[0];
149 Clause(
const V& ps,
bool use_extra,
bool learnt) {
151 header.learnt = learnt;
152 header.has_extra = use_extra;
154 header.size = ps.size();
156 for (
int i = 0; i < ps.size(); i++)
159 if (header.has_extra){
161 data[header.size].act = 0;
168 assert(header.has_extra);
169 uint32_t abstraction = 0;
170 for (
int i = 0; i < size(); i++)
171 abstraction |= 1 << (
var(data[i].lit) & 31);
172 data[header.size].abs = abstraction; }
175 int size ()
const {
return header.size; }
176 void shrink (
int i) { assert(i <= size());
if (header.has_extra) data[header.size-i] = data[header.size]; header.size -= i; }
177 void pop () { shrink(1); }
178 bool learnt ()
const {
return header.learnt; }
180 uint32_t
mark ()
const {
return header.mark; }
181 void mark (uint32_t m) { header.mark = m; }
182 const Lit&
last ()
const {
return data[header.size-1].lit; }
184 bool reloced ()
const {
return header.reloced; }
190 Lit& operator [] (
int i) {
return data[i].lit; }
191 Lit operator [] (
int i)
const {
return data[i].lit; }
192 operator const Lit* (void)
const {
return reinterpret_cast<const Lit*
>(data); }
194 float&
activity () { assert(header.has_extra);
return data[header.size].act; }
195 uint32_t
abstraction ()
const { assert(header.has_extra);
return data[header.size].abs; }
197 Lit subsumes (
const Clause& other)
const;
198 void strengthen (
Lit p);
202 #pragma warning ( pop ) 214 return (
sizeof(
Clause) + (
sizeof(
Lit) * (size + (
int)has_extra))) /
sizeof(uint32_t); }
228 assert(
sizeof(
Lit) ==
sizeof(uint32_t));
229 assert(
sizeof(
float) ==
sizeof(uint32_t));
230 bool use_extra = learnt | extra_clause_field;
233 new (lea(cid))
Clause(ps, use_extra, learnt);
247 Clause& c = operator[](cid);
253 Clause& c = operator[](cr);
262 to[cr].mark(c.
mark());
263 if (to[cr].learnt()) to[cr].activity() = c.
activity();
264 else if (to[cr].has_extra()) to[cr].calcAbstraction();
272 template<
class Idx,
class Vec,
class Deleted>
285 Vec& operator[](
const Idx& idx){
return occs[
toInt(idx)]; }
288 Vec&
lookup (
const Idx& idx){
if (dirty[
toInt(idx)]) clean(idx);
return occs[
toInt(idx)]; }
291 void clean (
const Idx& idx);
293 if (dirty[
toInt(idx)] == 0){
294 dirty[
toInt(idx)] = 1;
307 template<
class Idx,
class Vec,
class Deleted>
310 for (
int i = 0; i < dirties.size(); i++)
312 if (dirty[
toInt(dirties[i])])
318 template<
class Idx,
class Vec,
class Deleted>
323 for (i = j = 0; i < vec.size(); i++)
324 if (!deleted(vec[i]))
327 dirty[
toInt(idx)] = 0;
357 const T& operator [] (
CRef cr)
const {
return map[cr]; }
358 T& operator [] (
CRef cr) {
return map[cr]; }
369 printf(
" --- size = %d, bucket_count = %d\n", size(), map.
bucket_count()); }
389 if (other.
size() < size() || (extra.abst & ~other.extra.abst) != 0)
390 if (other.
size() < size() || (!learnt() && !other.
learnt() && (extra.abst & ~other.extra.abst) != 0))
398 const Lit* c =
static_cast<const Lit*
>(*this);
399 const Lit* d =
static_cast<const Lit*
>(other);
401 for (
unsigned i = 0; i < header.size; i++) {
403 for (
unsigned j = 0; j < other.
header.
size; j++)
406 else if (ret == lit_Undef && c[i] == ~d[j]){
uint32_t abstraction() const
const vec< typename HashTable::Pair > & bucket(int i) const
void reloc(CRef &cr, ClauseAllocator &to)
void moveTo(RegionAllocator &to)
const Clause * lea(Ref r) const
Lit operator^(Lit p, bool b)
ClauseAllocator(uint32_t start_cap)
void clean(const Idx &idx)
struct Minisat::Internal::Clause::@4 header
void insert(CRef cr, const T &t)
void smudge(const Idx &idx)
const vec< Pair > & bucket(int i) const
bool operator!=(Lit p) const
void moveTo(ClauseAllocator &to)
union Minisat::Internal::Clause::@5 data[0]
void init(const Idx &idx)
static int clauseWord32Size(int size, bool has_extra)
Clause & operator[](Ref r)
void growTo(CRef cr, const T &t)
uint32_t operator()(CRef cr) const
bool operator<(Lit p) const
Lit subsumes(const Clause &other) const
OccLists(const Deleted &d)
RegionAllocator< uint32_t >::Ref CRef
const Clause & operator[](Ref r) const
Vec & operator[](const Idx &idx)
friend Lit mkLit(Var var, bool sign)
Clause(const V &ps, bool use_extra, bool learnt)
void insert(const K &k, const D &d)
void clear(bool free=true)
bool peek(const K &k, D &d) const
bool operator==(Lit p) const
void clear(bool dealloc=false)
Vec & lookup(const Idx &idx)
CRef alloc(const Lits &ps, bool learnt=false)