#define LITCAPACITY 4
#define MERGESIZE 5
+VectorImpl(LitVector, LitVector *, 4)
+
static inline uint boundedSize(uint x) { return (x > MERGESIZE)?MERGESIZE:x; }
LitVector * allocLitVector() {
addLiteralLitVector(&This->singletons, l);
uint newsize=getSizeLitVector(&This->singletons);
if (newsize==0)
- clearCNF(This, false); //We found a conflict
+ clearCNFExpr(This, false); //We found a conflict
else
This->litSize+=getSizeLitVector(&This->singletons);
}
void conjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
if (expr->litSize==0) {
if (!This->isTrue) {
- clearCNF(This, false);
+ clearCNFExpr(This, false);
}
if (destroy) {
deleteCNFExpr(expr);
addLiteralLitVector(&This->singletons, l);
if (getSizeLitVector(&This->singletons)==0) {
//Found conflict...
- clearCNF(This, false);
+ clearCNFExpr(This, false);
if (destroy) {
deleteCNFExpr(expr);
}
/** Handle the special cases */
if (expr->litSize == 0) {
if (expr->isTrue) {
- clearCNF(This, true);
+ clearCNFExpr(This, true);
}
if (destroy) {
deleteCNFExpr(expr);
void clearCNFExpr(CNFExpr *This, bool isTrue);
void copyCNF(CNFExpr *This, CNFExpr *expr, bool destroy);
-bool alwaysTrueCNF(CNFExpr * This);
-bool alwaysFalseCNF(CNFExpr * This);
-uint getLitSizeCNF(CNFExpr * This);
-void clearCNF(CNFExpr *This, bool isTrue);
-uint getClauseSizeCNF(CNFExpr * This);
+static inline bool alwaysTrueCNF(CNFExpr * This) {return (This->litSize==0) && This->isTrue;}
+static inline bool alwaysFalseCNF(CNFExpr * This) {return (This->litSize==0) && !This->isTrue;}
+static inline uint getLitSizeCNF(CNFExpr * This) {return This->litSize;}
+static inline uint getClauseSizeCNF(CNFExpr * This) {return getSizeLitVector(&This->singletons) + getSizeVectorLitVector(&This->clauses);}
void conjoinCNFLit(CNFExpr *This, Literal l);
void disjoinCNFLit(CNFExpr *This, Literal l);
void disjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy);
uint hashNode(NodeType type, uint numEdges, Edge * edges) {
uint hashvalue=type ^ numEdges;
for(uint i=0;i<numEdges;i++) {
- hashvalue ^= (uint) edges[i].node_ptr;
+ hashvalue ^= (uint) ((uintptr_t) edges[i].node_ptr);
hashvalue = (hashvalue << 3) | (hashvalue >> 29); //rotate left by 3 bits
}
return (uint) hashvalue;
/// propagate(solver, expPos, snPos, false) || propagate(solver, expNeg, snNeg, false)
// propagate from positive to negative, negative to positive
- propagate(cnf, & expPos, expNeg, true) || propagate(cnf, & expNeg, expPos, true);
+ if (!propagate(cnf, & expPos, expNeg, true))
+ propagate(cnf, & expNeg, expPos, true);
// The polarity heuristic entails visiting the discovery polarity first
if (isPosEdge(e)) {
vector->size--; \
} \
type lastVector ## name(Vector ## name *vector) { \
- return vector->array[vector->size]; \
+ return vector->array[vector->size-1]; \
} \
void setSizeVector ## name(Vector ## name *vector, uint size) { \
if (size <= vector->size) { \