abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
satStore.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [satStore.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Proof recording.]
8 
9  Synopsis [External declarations.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: pr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__sat__bsat__satStore_h
22 #define ABC__sat__bsat__satStore_h
23 
24 
25 /*
26  The trace of SAT solving contains the original clauses of the problem
27  along with the learned clauses derived during SAT solving.
28  The first line of the resulting file contains 3 numbers instead of 2:
29  c <num_vars> <num_all_clauses> <num_root_clauses>
30 */
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// INCLUDES ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 #include "satSolver.h"
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// PARAMETERS ///
40 ////////////////////////////////////////////////////////////////////////
41 
43 
44 #ifdef _WIN32
45 #define inline __inline // compatible with MS VS 6.0
46 #endif
47 
48 #define STO_MAX(a,b) ((a) > (b) ? (a) : (b))
49 
50 ////////////////////////////////////////////////////////////////////////
51 /// BASIC TYPES ///
52 ////////////////////////////////////////////////////////////////////////
53 
54 /*
55 typedef unsigned lit;
56 // variable/literal conversions (taken from MiniSat)
57 static inline lit toLit (int v) { return v + v; }
58 static inline lit toLitCond(int v, int c) { return v + v + (c != 0); }
59 static inline lit lit_neg (lit l) { return l ^ 1; }
60 static inline int lit_var (lit l) { return l >> 1; }
61 static inline int lit_sign (lit l) { return l & 1; }
62 static inline int lit_print(lit l) { return lit_sign(l)? -lit_var(l)-1 : lit_var(l)+1; }
63 static inline lit lit_read (int s) { return s > 0 ? toLit(s-1) : lit_neg(toLit(-s-1)); }
64 static inline int lit_check(lit l, int n) { return l >= 0 && lit_var(l) < n; }
65 */
66 
67 typedef struct Sto_Cls_t_ Sto_Cls_t;
68 struct Sto_Cls_t_
69 {
70  Sto_Cls_t * pNext; // the next clause
71  Sto_Cls_t * pNext0; // the next 0-watch
72  Sto_Cls_t * pNext1; // the next 1-watch
73  int Id; // the clause ID
74  unsigned fA : 1; // belongs to A
75  unsigned fRoot : 1; // original clause
76  unsigned fVisit : 1; // visited clause
77  unsigned nLits : 24; // the number of literals
78  lit pLits[0]; // literals of this clause
79 };
80 
81 typedef struct Sto_Man_t_ Sto_Man_t;
82 struct Sto_Man_t_
83 {
84  // general data
85  int nVars; // the number of variables
86  int nRoots; // the number of root clauses
87  int nClauses; // the number of all clauses
88  int nClausesA; // the number of clauses of A
89  Sto_Cls_t * pHead; // the head clause
90  Sto_Cls_t * pTail; // the tail clause
91  Sto_Cls_t * pEmpty; // the empty clause
92  // memory management
93  int nChunkSize; // the number of bytes in a chunk
94  int nChunkUsed; // the number of bytes used in the last chunk
95  char * pChunkLast; // the last memory chunk
96 };
97 
98 // iterators through the clauses
99 #define Sto_ManForEachClause( p, pCls ) for( pCls = p->pHead; pCls; pCls = pCls->pNext )
100 #define Sto_ManForEachClauseRoot( p, pCls ) for( pCls = p->pHead; pCls && pCls->fRoot; pCls = pCls->pNext )
101 
102 ////////////////////////////////////////////////////////////////////////
103 /// MACRO DEFINITIONS ///
104 ////////////////////////////////////////////////////////////////////////
105 
106 ////////////////////////////////////////////////////////////////////////
107 /// FUNCTION DECLARATIONS ///
108 ////////////////////////////////////////////////////////////////////////
109 
110 /*=== satStore.c ==========================================================*/
111 extern Sto_Man_t * Sto_ManAlloc();
112 extern void Sto_ManFree( Sto_Man_t * p );
113 extern int Sto_ManAddClause( Sto_Man_t * p, lit * pBeg, lit * pEnd );
114 extern int Sto_ManMemoryReport( Sto_Man_t * p );
115 extern void Sto_ManMarkRoots( Sto_Man_t * p );
116 extern void Sto_ManMarkClausesA( Sto_Man_t * p );
117 extern void Sto_ManDumpClauses( Sto_Man_t * p, char * pFileName );
118 extern int Sto_ManChangeLastClause( Sto_Man_t * p );
119 extern Sto_Man_t * Sto_ManLoadClauses( char * pFileName );
120 
121 
122 /*=== satInter.c ==========================================================*/
123 typedef struct Int_Man_t_ Int_Man_t;
124 extern Int_Man_t * Int_ManAlloc();
125 extern int * Int_ManSetGlobalVars( Int_Man_t * p, int nGloVars );
126 extern void Int_ManFree( Int_Man_t * p );
127 extern int Int_ManInterpolate( Int_Man_t * p, Sto_Man_t * pCnf, int fVerbose, unsigned ** ppResult );
128 
129 /*=== satInterA.c ==========================================================*/
130 typedef struct Inta_Man_t_ Inta_Man_t;
131 extern Inta_Man_t * Inta_ManAlloc();
132 extern void Inta_ManFree( Inta_Man_t * p );
133 extern void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, abctime TimeToStop, void * vVarsAB, int fVerbose );
134 
135 /*=== satInterB.c ==========================================================*/
136 typedef struct Intb_Man_t_ Intb_Man_t;
137 extern Intb_Man_t * Intb_ManAlloc();
138 extern void Intb_ManFree( Intb_Man_t * p );
139 extern void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose );
140 
141 /*=== satInterP.c ==========================================================*/
142 typedef struct Intp_Man_t_ Intp_Man_t;
143 extern Intp_Man_t * Intp_ManAlloc();
144 extern void Intp_ManFree( Intp_Man_t * p );
145 extern void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fLearned, int fVerbose );
146 extern void Intp_ManUnsatCorePrintForBmc( FILE * pFile, Sto_Man_t * pCnf, void * vCore, void * vVarMap );
147 
148 
150 
151 
152 
153 #endif
154 
155 ////////////////////////////////////////////////////////////////////////
156 /// END OF FILE ///
157 ////////////////////////////////////////////////////////////////////////
158 
void Intb_ManFree(Intb_Man_t *p)
Definition: satInterB.c:255
Intb_Man_t * Intb_ManAlloc()
FUNCTION DEFINITIONS ///.
Definition: satInterB.c:110
int * Int_ManSetGlobalVars(Int_Man_t *p, int nGloVars)
Definition: satInter.c:133
Vec_Int_t * vVarsAB
Definition: satInterB.c:44
int fVerbose
Definition: satInterA.c:46
Sto_Man_t * pCnf
Definition: satInter.c:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned fRoot
Definition: satStore.h:75
void Sto_ManMarkRoots(Sto_Man_t *p)
Definition: satStore.c:235
Inta_Man_t * Inta_ManAlloc()
FUNCTION DEFINITIONS ///.
Definition: satInterA.c:106
Sto_Cls_t * pEmpty
Definition: satStore.h:91
int nVars
Definition: satStore.h:85
void Intp_ManUnsatCorePrintForBmc(FILE *pFile, Sto_Man_t *pCnf, void *vCore, void *vVarMap)
Definition: satInterP.c:1059
Sto_Man_t * pCnf
Definition: satInterA.c:43
Sto_Man_t * Sto_ManLoadClauses(char *pFileName)
Definition: satStore.c:384
lit pLits[0]
Definition: satStore.h:78
Sto_Cls_t * pNext1
Definition: satStore.h:72
Sto_Man_t * pCnf
Definition: satInterP.c:43
int Sto_ManChangeLastClause(Sto_Man_t *p)
Definition: satStore.c:279
int nClausesA
Definition: satStore.h:88
Vec_Int_t * vVarsAB
Definition: satInterA.c:44
int Int_ManInterpolate(Int_Man_t *p, Sto_Man_t *pCnf, int fVerbose, unsigned **ppResult)
Definition: satInter.c:1005
int nChunkSize
Definition: satStore.h:93
void * Intb_ManInterpolate(Intb_Man_t *p, Sto_Man_t *pCnf, void *vVarsAB, int fVerbose)
Definition: satInterB.c:987
unsigned nLits
Definition: satStore.h:77
void * Intp_ManUnsatCore(Intp_Man_t *p, Sto_Man_t *pCnf, int fLearned, int fVerbose)
Definition: satInterP.c:963
int lit
Definition: satVec.h:130
int fVerbose
Definition: satInter.c:46
FILE * pFile
Definition: satInterP.c:66
Sto_Cls_t * pHead
Definition: satStore.h:89
Sto_Cls_t * pNext0
Definition: satStore.h:71
unsigned fVisit
Definition: satStore.h:76
char * pChunkLast
Definition: satStore.h:95
Int_Man_t * Int_ManAlloc()
FUNCTION DEFINITIONS ///.
Definition: satInter.c:107
void Sto_ManFree(Sto_Man_t *p)
Definition: satStore.c:143
int Sto_ManAddClause(Sto_Man_t *p, lit *pBeg, lit *pEnd)
Definition: satStore.c:160
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
int fVerbose
Definition: satInterP.c:45
int Id
Definition: satStore.h:73
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
void * Inta_ManInterpolate(Inta_Man_t *p, Sto_Man_t *pCnf, abctime TimeToStop, void *vVarsAB, int fVerbose)
Definition: satInterA.c:944
Sto_Cls_t * pTail
Definition: satStore.h:90
Sto_Cls_t * pNext
Definition: satStore.h:70
int nChunkUsed
Definition: satStore.h:94
Sto_Man_t * pCnf
Definition: satInterB.c:43
void Inta_ManFree(Inta_Man_t *p)
Definition: satInterA.c:250
int nClauses
Definition: satStore.h:87
void Sto_ManMarkClausesA(Sto_Man_t *p)
Definition: satStore.c:257
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition: satStore.c:97
Intp_Man_t * Intp_ManAlloc()
FUNCTION DEFINITIONS ///.
Definition: satInterP.c:96
void Intp_ManFree(Intp_Man_t *p)
Definition: satInterP.c:178
void Sto_ManDumpClauses(Sto_Man_t *p, char *pFileName)
Definition: satStore.c:305
Sto_Man_t * Sto_ManAlloc()
MACRO DEFINITIONS ///.
Definition: satStore.c:121
int nRoots
Definition: satStore.h:86
int nGloVars
Definition: satInter.c:44
ABC_INT64_T abctime
Definition: abc_global.h:278
unsigned fA
Definition: satStore.h:74
void Int_ManFree(Int_Man_t *p)
Definition: satInter.c:273
int fVerbose
Definition: satInterB.c:46