00001
00021 #ifndef __PR_H__
00022 #define __PR_H__
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034
00035 #ifdef _WIN32
00036 #define inline __inline // compatible with MS VS 6.0
00037 #endif
00038
00039 #ifndef PRT
00040 #define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
00041 #endif
00042
00043 #define STO_MAX(a,b) ((a) > (b) ? (a) : (b))
00044
00048
00052
00056
00057 typedef unsigned lit;
00058
00059 typedef struct Sto_Cls_t_ Sto_Cls_t;
00060 struct Sto_Cls_t_
00061 {
00062 Sto_Cls_t * pNext;
00063 Sto_Cls_t * pNext0;
00064 Sto_Cls_t * pNext1;
00065 int Id;
00066 unsigned fA : 1;
00067 unsigned fRoot : 1;
00068 unsigned fVisit : 1;
00069 unsigned nLits : 24;
00070 lit pLits[0];
00071 };
00072
00073 typedef struct Sto_Man_t_ Sto_Man_t;
00074 struct Sto_Man_t_
00075 {
00076
00077 int nVars;
00078 int nRoots;
00079 int nClauses;
00080 int nClausesA;
00081 Sto_Cls_t * pHead;
00082 Sto_Cls_t * pTail;
00083 Sto_Cls_t * pEmpty;
00084
00085 int nChunkSize;
00086 int nChunkUsed;
00087 char * pChunkLast;
00088 };
00089
00090
00091 static inline lit toLit (int v) { return v + v; }
00092 static inline lit toLitCond(int v, int c) { return v + v + (c != 0); }
00093 static inline lit lit_neg (lit l) { return l ^ 1; }
00094 static inline int lit_var (lit l) { return l >> 1; }
00095 static inline int lit_sign (lit l) { return l & 1; }
00096 static inline int lit_print(lit l) { return lit_sign(l)? -lit_var(l)-1 : lit_var(l)+1; }
00097 static inline lit lit_read (int s) { return s > 0 ? toLit(s-1) : lit_neg(toLit(-s-1)); }
00098 static inline int lit_check(lit l, int n) { return l >= 0 && lit_var(l) < n; }
00099
00100
00101 #define Sto_ManForEachClause( p, pCls ) for( pCls = p->pHead; pCls; pCls = pCls->pNext )
00102 #define Sto_ManForEachClauseRoot( p, pCls ) for( pCls = p->pHead; pCls && pCls->fRoot; pCls = pCls->pNext )
00103
00107
00111
00112
00113 extern Sto_Man_t * Sto_ManAlloc();
00114 extern void Sto_ManFree( Sto_Man_t * p );
00115 extern int Sto_ManAddClause( Sto_Man_t * p, lit * pBeg, lit * pEnd );
00116 extern int Sto_ManMemoryReport( Sto_Man_t * p );
00117 extern void Sto_ManMarkRoots( Sto_Man_t * p );
00118 extern void Sto_ManMarkClausesA( Sto_Man_t * p );
00119 extern void Sto_ManDumpClauses( Sto_Man_t * p, char * pFileName );
00120 extern Sto_Man_t * Sto_ManLoadClauses( char * pFileName );
00121
00122
00123 typedef struct Int_Man_t_ Int_Man_t;
00124 extern Int_Man_t * Int_ManAlloc( int nVarsAlloc );
00125 extern void Int_ManFree( Int_Man_t * p );
00126 extern int Int_ManInterpolate( Int_Man_t * p, Sto_Man_t * pCnf, int fVerbose, unsigned ** ppResult );
00127
00128 #ifdef __cplusplus
00129 }
00130 #endif
00131
00132 #endif
00133
00137