ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
xsat.h File Reference
Include dependency graph for xsat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct xSAT_Solver_t_ xSAT_Solver_t
 

Functions

int xSAT_SolverParseDimacs (FILE *, xSAT_Solver_t **)
 FUNCTION DECLARATIONS ///.
 
xSAT_Solver_txSAT_SolverCreate ()
 
void xSAT_SolverDestroy (xSAT_Solver_t *)
 
int xSAT_SolverAddClause (xSAT_Solver_t *, Vec_Int_t *)
 
int xSAT_SolverSimplify (xSAT_Solver_t *)
 
int xSAT_SolverSolve (xSAT_Solver_t *)
 
void xSAT_SolverPrintStats (xSAT_Solver_t *)
 

Typedef Documentation

◆ xSAT_Solver_t

typedef struct xSAT_Solver_t_ xSAT_Solver_t

Definition at line 36 of file xsat.h.

Function Documentation

◆ xSAT_SolverAddClause()

int xSAT_SolverAddClause ( xSAT_Solver_t * s,
Vec_Int_t * vLits )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 251 of file xsatSolverAPI.c.

252{
253 int i, j;
254 int Lit, PrevLit;
255 int MaxVar;
256
257 Vec_IntSort( vLits, 0 );
258 MaxVar = xSAT_Lit2Var( Vec_IntEntryLast( vLits ) );
259 while ( MaxVar >= Vec_IntSize( s->vActivity ) )
261
262 j = 0;
263 PrevLit = LitUndef;
264 Vec_IntForEachEntry( vLits, Lit, i )
265 {
266 if ( Lit == xSAT_NegLit( PrevLit ) || Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( Lit ) ) == xSAT_LitSign( Lit ) )
267 return true;
268 else if ( Lit != PrevLit && Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( Lit ) ) == VarX )
269 {
270 PrevLit = Lit;
271 Vec_IntWriteEntry( vLits, j++, Lit );
272 }
273 }
274 Vec_IntShrink( vLits, j );
275
276 if ( Vec_IntSize( vLits ) == 0 )
277 return false;
278 if ( Vec_IntSize( vLits ) == 1 )
279 {
280 xSAT_SolverEnqueue( s, Vec_IntEntry( vLits, 0 ), CRefUndef );
281 return ( xSAT_SolverPropagate( s ) == CRefUndef );
282 }
283
284 xSAT_SolverClaNew( s, vLits, 0 );
285 return true;
286}
Vec_Int_t * vActivity
Definition xsatSolver.h:131
Vec_Str_t * vAssigns
Definition xsatSolver.h:135
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
void xSAT_SolverAddVariable(xSAT_Solver_t *s, int Sign)
int xSAT_SolverEnqueue(xSAT_Solver_t *s, int Lit, unsigned Reason)
Definition xsatSolver.c:333
unsigned xSAT_SolverPropagate(xSAT_Solver_t *s)
Definition xsatSolver.c:665
unsigned xSAT_SolverClaNew(xSAT_Solver_t *s, Vec_Int_t *vLits, int fLearnt)
FUNCTION DECLARATIONS ///.
Definition xsatSolver.c:269
@ VarX
Definition xsatSolver.h:57
#define CRefUndef
Definition xsatSolver.h:73
@ LitUndef
Definition xsatSolver.h:70
Here is the call graph for this function:

◆ xSAT_SolverCreate()

xSAT_Solver_t * xSAT_SolverCreate ( )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file xsatSolverAPI.c.

67{
68 xSAT_Solver_t * s = (xSAT_Solver_t *) ABC_CALLOC( char, sizeof( xSAT_Solver_t ) );
70
71 s->pMemory = xSAT_MemAlloc(0);
72 s->vClauses = Vec_IntAlloc(0);
73 s->vLearnts = Vec_IntAlloc(0);
74 s->vWatches = xSAT_VecWatchListAlloc( 0 );
75 s->vBinWatches = xSAT_VecWatchListAlloc( 0 );
76
77 s->vTrailLim = Vec_IntAlloc(0);
78 s->vTrail = Vec_IntAlloc( 0 );
79
80 s->vActivity = Vec_IntAlloc( 0 );
81 s->hOrder = xSAT_HeapAlloc( s->vActivity );
82
83 s->vPolarity = Vec_StrAlloc( 0 );
84 s->vTags = Vec_StrAlloc( 0 );
85 s->vAssigns = Vec_StrAlloc( 0 );
86 s->vLevels = Vec_IntAlloc( 0 );
87 s->vReasons = Vec_IntAlloc( 0 );
88 s->vStamp = Vec_IntAlloc( 0 );
89
90 s->vTagged = Vec_IntAlloc(0);
91 s->vStack = Vec_IntAlloc(0);
92
93 s->vSeen = Vec_StrAlloc( 0 );
94 s->vLearntClause = Vec_IntAlloc(0);
95 s->vLastDLevel = Vec_IntAlloc(0);
96
97
98 s->bqTrail = xSAT_BQueueNew( s->Config.nSizeTrailQueue );
99 s->bqLBD = xSAT_BQueueNew( s->Config.nSizeLBDQueue );
100
101 s->nVarActInc = (1 << 5);
102 s->nClaActInc = (1 << 11);
103
105 s->nRC1 = 1;
107 return s;
108}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Vec_Int_t * vLastDLevel
Definition xsatSolver.h:162
Vec_Str_t * vPolarity
Definition xsatSolver.h:136
Vec_Int_t * vStamp
Definition xsatSolver.h:166
Vec_Str_t * vTags
Definition xsatSolver.h:137
Vec_Str_t * vSeen
Definition xsatSolver.h:159
xSAT_Mem_t * pMemory
Definition xsatSolver.h:120
Vec_Int_t * vTagged
Definition xsatSolver.h:160
xSAT_SolverOptions_t Config
Definition xsatSolver.h:169
xSAT_VecWatchList_t * vWatches
Definition xsatSolver.h:123
Vec_Int_t * vReasons
Definition xsatSolver.h:134
Vec_Int_t * vLearntClause
Definition xsatSolver.h:158
Vec_Int_t * vTrail
Definition xsatSolver.h:140
xSAT_BQueue_t * bqLBD
Definition xsatSolver.h:151
Vec_Int_t * vLevels
Definition xsatSolver.h:133
Vec_Int_t * vTrailLim
Definition xsatSolver.h:141
Vec_Int_t * vClauses
Definition xsatSolver.h:122
Vec_Int_t * vLearnts
Definition xsatSolver.h:121
xSAT_BQueue_t * bqTrail
Definition xsatSolver.h:150
Vec_Int_t * vStack
Definition xsatSolver.h:161
xSAT_VecWatchList_t * vBinWatches
Definition xsatSolver.h:124
xSAT_Heap_t * hOrder
Definition xsatSolver.h:132
ABC_NAMESPACE_IMPL_START xSAT_SolverOptions_t DefaultConfig
INCLUDES ///.
struct xSAT_Solver_t_ xSAT_Solver_t
Definition xsat.h:36

◆ xSAT_SolverDestroy()

void xSAT_SolverDestroy ( xSAT_Solver_t * s)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file xsatSolverAPI.c.

122{
123 xSAT_MemFree( s->pMemory );
124 Vec_IntFree( s->vClauses );
125 Vec_IntFree( s->vLearnts );
126 xSAT_VecWatchListFree( s->vWatches );
127 xSAT_VecWatchListFree( s->vBinWatches );
128
129 xSAT_HeapFree(s->hOrder);
130 Vec_IntFree( s->vTrailLim );
131 Vec_IntFree( s->vTrail );
132 Vec_IntFree( s->vTagged );
133 Vec_IntFree( s->vStack );
134
135 Vec_StrFree( s->vSeen );
136 Vec_IntFree( s->vLearntClause );
137 Vec_IntFree( s->vLastDLevel );
138
139 Vec_IntFree( s->vActivity );
140 Vec_StrFree( s->vPolarity );
141 Vec_StrFree( s->vTags );
142 Vec_StrFree( s->vAssigns );
143 Vec_IntFree( s->vLevels );
144 Vec_IntFree( s->vReasons );
145 Vec_IntFree( s->vStamp );
146
147 xSAT_BQueueFree(s->bqLBD);
148 xSAT_BQueueFree(s->bqTrail);
149
150 ABC_FREE(s);
151}
#define ABC_FREE(obj)
Definition abc_global.h:267

◆ xSAT_SolverParseDimacs()

int xSAT_SolverParseDimacs ( FILE * pFile,
xSAT_Solver_t ** p )
extern

FUNCTION DECLARATIONS ///.

Function*************************************************************

Synopsis [Starts the solver and reads the DIMAC file.]

Description [Returns FALSE upon immediate conflict.]

SideEffects []

SeeAlso []

Definition at line 222 of file xsatCnfReader.c.

223{
224 char * pText;
225 int Value;
226 pText = xSAT_FileRead( pFile );
227 Value = xSAT_ParseDimacs( pText, p );
228 ABC_FREE( pText );
229 return Value;
230}
Cube * p
Definition exorList.c:222
ABC_NAMESPACE_IMPL_START char * xSAT_FileRead(FILE *pFile)
INCLUDES ///.
Here is the call graph for this function:

◆ xSAT_SolverPrintStats()

void xSAT_SolverPrintStats ( xSAT_Solver_t * s)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 338 of file xsatSolverAPI.c.

339{
340 printf( "starts : %10d\n", s->Stats.nStarts );
341 printf( "conflicts : %10ld\n", s->Stats.nConflicts );
342 printf( "decisions : %10ld\n", s->Stats.nDecisions );
343 printf( "propagations : %10ld\n", s->Stats.nPropagations );
344}
xSAT_Stats_t Stats
Definition xsatSolver.h:170
iword nPropagations
Definition xsatSolver.h:109
unsigned nStarts
Definition xsatSolver.h:105

◆ xSAT_SolverSimplify()

int xSAT_SolverSimplify ( xSAT_Solver_t * s)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file xsatSolverAPI.c.

165{
166 int i, j;
167 unsigned CRef;
168 assert( xSAT_SolverDecisionLevel(s) == 0 );
169
171 return false;
172
173 if ( s->nAssignSimplify == Vec_IntSize( s->vTrail ) || s->nPropSimplify > 0 )
174 return true;
175
176 j = 0;
177 Vec_IntForEachEntry( s->vClauses, CRef, i )
178 {
179 xSAT_Clause_t * pCla = xSAT_SolverReadClause( s, CRef );
180 if ( xSAT_SolverIsClauseSatisfied( s, pCla ) )
181 {
182 pCla->fMark = 1;
183 s->Stats.nClauseLits -= pCla->nSize;
184
185 if ( pCla->nSize == 2 )
186 {
187 xSAT_WatchListRemove( xSAT_VecWatchListEntry( s->vBinWatches, xSAT_NegLit(pCla->pData[0].Lit) ), CRef );
188 xSAT_WatchListRemove( xSAT_VecWatchListEntry( s->vBinWatches, xSAT_NegLit(pCla->pData[1].Lit) ), CRef );
189 }
190 else
191 {
192 xSAT_WatchListRemove( xSAT_VecWatchListEntry( s->vWatches, xSAT_NegLit(pCla->pData[0].Lit) ), CRef );
193 xSAT_WatchListRemove( xSAT_VecWatchListEntry( s->vWatches, xSAT_NegLit(pCla->pData[1].Lit) ), CRef );
194 }
195 }
196 else
197 Vec_IntWriteEntry( s->vClauses, j++, CRef );
198 }
199 Vec_IntShrink( s->vClauses, j );
201
202 s->nAssignSimplify = Vec_IntSize( s->vTrail );
204
205 return true;
206}
RegionAllocator< uint32_t >::Ref CRef
iword nPropSimplify
Definition xsatSolver.h:146
iword nLearntLits
Definition xsatSolver.h:114
iword nClauseLits
Definition xsatSolver.h:113
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct xSAT_Clause_t_ xSAT_Clause_t
INCLUDES ///.
Definition xsatClause.h:34
void xSAT_SolverRebuildOrderHeap(xSAT_Solver_t *s)
Definition xsatSolver.c:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xSAT_SolverSolve()

int xSAT_SolverSolve ( xSAT_Solver_t * s)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 299 of file xsatSolverAPI.c.

300{
301 char status = LBoolUndef;
302
303 assert(s);
304 if ( s->Config.fVerbose )
305 {
306 printf( "==========================================[ BLACK MAGIC ]================================================\n" );
307 printf( "| | | |\n" );
308 printf( "| - Restarts: | - Reduce Clause DB: | - Minimize Asserting: |\n" );
309 printf( "| * LBD Queue : %6d | * First : %6d | * size < %3d |\n", s->Config.nSizeLBDQueue, s->Config.nConfFirstReduce, 0 );
310 printf( "| * Trail Queue : %6d | * Inc : %6d | * lbd < %3d |\n", s->Config.nSizeTrailQueue, s->Config.nIncReduce, 0 );
311 printf( "| * K : %6.2f | * Special : %6d | |\n", s->Config.K, s->Config.nSpecialIncReduce );
312 printf( "| * R : %6.2f | * Protected : (lbd)< %2d | |\n", s->Config.R, s->Config.nLBDFrozenClause );
313 printf( "| | | |\n" );
314 printf( "=========================================================================================================\n" );
315 }
316
317 while ( status == LBoolUndef )
318 status = xSAT_SolverSearch( s );
319
320 if ( s->Config.fVerbose )
321 printf( "=========================================================================================================\n" );
322
324 return status;
325}
unsigned nLBDFrozenClause
Definition xsatSolver.h:99
void xSAT_SolverCancelUntil(xSAT_Solver_t *s, int Level)
Definition xsatSolver.c:375
char xSAT_SolverSearch(xSAT_Solver_t *s)
Definition xsatSolver.c:847
@ LBoolUndef
Definition xsatSolver.h:62
Here is the call graph for this function: