abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
satStore.h File Reference
#include "satSolver.h"

Go to the source code of this file.

Data Structures

struct  Sto_Cls_t_
 
struct  Sto_Man_t_
 

Macros

#define STO_MAX(a, b)   ((a) > (b) ? (a) : (b))
 INCLUDES ///. More...
 
#define Sto_ManForEachClause(p, pCls)   for( pCls = p->pHead; pCls; pCls = pCls->pNext )
 
#define Sto_ManForEachClauseRoot(p, pCls)   for( pCls = p->pHead; pCls && pCls->fRoot; pCls = pCls->pNext )
 

Typedefs

typedef struct Sto_Cls_t_ Sto_Cls_t
 BASIC TYPES ///. More...
 
typedef struct Sto_Man_t_ Sto_Man_t
 
typedef struct Int_Man_t_ Int_Man_t
 
typedef struct Inta_Man_t_ Inta_Man_t
 
typedef struct Intb_Man_t_ Intb_Man_t
 
typedef struct Intp_Man_t_ Intp_Man_t
 

Functions

Sto_Man_tSto_ManAlloc ()
 MACRO DEFINITIONS ///. More...
 
void Sto_ManFree (Sto_Man_t *p)
 
int Sto_ManAddClause (Sto_Man_t *p, lit *pBeg, lit *pEnd)
 
int Sto_ManMemoryReport (Sto_Man_t *p)
 
void Sto_ManMarkRoots (Sto_Man_t *p)
 
void Sto_ManMarkClausesA (Sto_Man_t *p)
 
void Sto_ManDumpClauses (Sto_Man_t *p, char *pFileName)
 
int Sto_ManChangeLastClause (Sto_Man_t *p)
 
Sto_Man_tSto_ManLoadClauses (char *pFileName)
 
Int_Man_tInt_ManAlloc ()
 FUNCTION DEFINITIONS ///. More...
 
int * Int_ManSetGlobalVars (Int_Man_t *p, int nGloVars)
 
void Int_ManFree (Int_Man_t *p)
 
int Int_ManInterpolate (Int_Man_t *p, Sto_Man_t *pCnf, int fVerbose, unsigned **ppResult)
 
Inta_Man_tInta_ManAlloc ()
 FUNCTION DEFINITIONS ///. More...
 
void Inta_ManFree (Inta_Man_t *p)
 
void * Inta_ManInterpolate (Inta_Man_t *p, Sto_Man_t *pCnf, abctime TimeToStop, void *vVarsAB, int fVerbose)
 
Intb_Man_tIntb_ManAlloc ()
 FUNCTION DEFINITIONS ///. More...
 
void Intb_ManFree (Intb_Man_t *p)
 
void * Intb_ManInterpolate (Intb_Man_t *p, Sto_Man_t *pCnf, void *vVarsAB, int fVerbose)
 
Intp_Man_tIntp_ManAlloc ()
 FUNCTION DEFINITIONS ///. More...
 
void Intp_ManFree (Intp_Man_t *p)
 
void * Intp_ManUnsatCore (Intp_Man_t *p, Sto_Man_t *pCnf, int fLearned, int fVerbose)
 
void Intp_ManUnsatCorePrintForBmc (FILE *pFile, Sto_Man_t *pCnf, void *vCore, void *vVarMap)
 

Macro Definition Documentation

#define Sto_ManForEachClause (   p,
  pCls 
)    for( pCls = p->pHead; pCls; pCls = pCls->pNext )

Definition at line 99 of file satStore.h.

#define Sto_ManForEachClauseRoot (   p,
  pCls 
)    for( pCls = p->pHead; pCls && pCls->fRoot; pCls = pCls->pNext )

Definition at line 100 of file satStore.h.

#define STO_MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

INCLUDES ///.

CFile****************************************************************

FileName [satStore.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Proof recording.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
pr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///

Definition at line 48 of file satStore.h.

Typedef Documentation

typedef struct Int_Man_t_ Int_Man_t

Definition at line 123 of file satStore.h.

typedef struct Inta_Man_t_ Inta_Man_t

Definition at line 130 of file satStore.h.

typedef struct Intb_Man_t_ Intb_Man_t

Definition at line 136 of file satStore.h.

typedef struct Intp_Man_t_ Intp_Man_t

Definition at line 142 of file satStore.h.

typedef struct Sto_Cls_t_ Sto_Cls_t

BASIC TYPES ///.

Definition at line 67 of file satStore.h.

typedef struct Sto_Man_t_ Sto_Man_t

Definition at line 81 of file satStore.h.

Function Documentation

Int_Man_t* Int_ManAlloc ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file satInter.c.

108 {
109  Int_Man_t * p;
110  // allocate the manager
111  p = (Int_Man_t *)ABC_ALLOC( char, sizeof(Int_Man_t) );
112  memset( p, 0, sizeof(Int_Man_t) );
113  // verification
114  p->nResLitsAlloc = (1<<16);
115  p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
116  // parameters
117  p->fProofWrite = 0;
118  p->fProofVerif = 1;
119  return p;
120 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nResLitsAlloc
Definition: satInter.c:72
int fProofWrite
Definition: satInter.c:48
int lit
Definition: satVec.h:130
int fProofVerif
Definition: satInter.c:47
lit * pResLits
Definition: satInter.c:70
void Int_ManFree ( Int_Man_t p)

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file satInter.c.

274 {
275 /*
276  printf( "Runtime stats:\n" );
277 ABC_PRT( "BCP ", p->timeBcp );
278 ABC_PRT( "Trace ", p->timeTrace );
279 ABC_PRT( "TOTAL ", p->timeTotal );
280 */
281  ABC_FREE( p->pInters );
282  ABC_FREE( p->pProofNums );
283  ABC_FREE( p->pTrail );
284  ABC_FREE( p->pAssigns );
285  ABC_FREE( p->pSeens );
286  ABC_FREE( p->pVarTypes );
287  ABC_FREE( p->pReasons );
288  ABC_FREE( p->pWatches );
289  ABC_FREE( p->pResLits );
290  ABC_FREE( p );
291 }
int * pVarTypes
Definition: satInter.c:61
char * pSeens
Definition: satInter.c:56
Sto_Cls_t ** pReasons
Definition: satInter.c:57
lit * pAssigns
Definition: satInter.c:55
lit * pTrail
Definition: satInter.c:54
int * pProofNums
Definition: satInter.c:67
#define ABC_FREE(obj)
Definition: abc_global.h:232
lit * pResLits
Definition: satInter.c:70
Sto_Cls_t ** pWatches
Definition: satInter.c:58
unsigned * pInters
Definition: satInter.c:62
int Int_ManInterpolate ( Int_Man_t p,
Sto_Man_t pCnf,
int  fVerbose,
unsigned **  ppResult 
)

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

Synopsis [Computes interpolant for the given CNF.]

Description [Returns the number of common variable found and interpolant. Returns 0, if something did not work.]

SideEffects []

SeeAlso []

Definition at line 1005 of file satInter.c.

1006 {
1007  Sto_Cls_t * pClause;
1008  int RetValue = 1;
1009  abctime clkTotal = Abc_Clock();
1010 
1011  // check that the CNF makes sense
1012  assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
1013  p->pCnf = pCnf;
1014  p->fVerbose = fVerbose;
1015  *ppResult = NULL;
1016 
1017  // adjust the manager
1018  Int_ManResize( p );
1019 
1020  // prepare the interpolant computation
1021  Int_ManPrepareInter( p );
1022 
1023  // construct proof for each clause
1024  // start the proof
1025  if ( p->fProofWrite )
1026  {
1027  p->pFile = fopen( "proof.cnf_", "w" );
1028  p->Counter = 0;
1029  }
1030 
1031  // write the root clauses
1032  Sto_ManForEachClauseRoot( p->pCnf, pClause )
1033  Int_ManProofWriteOne( p, pClause );
1034 
1035  // propagate root level assignments
1036  if ( Int_ManProcessRoots( p ) )
1037  {
1038  // if there is no conflict, consider learned clauses
1039  Sto_ManForEachClause( p->pCnf, pClause )
1040  {
1041  if ( pClause->fRoot )
1042  continue;
1043  if ( !Int_ManProofRecordOne( p, pClause ) )
1044  {
1045  RetValue = 0;
1046  break;
1047  }
1048  }
1049  }
1050 
1051  // stop the proof
1052  if ( p->fProofWrite )
1053  {
1054  fclose( p->pFile );
1055  p->pFile = NULL;
1056  }
1057 
1058  if ( fVerbose )
1059  {
1060  printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f MB\n",
1061  p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
1062  1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
1063  1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
1064 p->timeTotal += Abc_Clock() - clkTotal;
1065  }
1066 
1067  *ppResult = Int_ManTruthRead( p, p->pCnf->pTail );
1068  return p->nVarsAB;
1069 }
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition: satStore.c:97
Sto_Man_t * pCnf
Definition: satInter.c:42
int nVars
Definition: satStore.h:85
static abctime Abc_Clock()
Definition: abc_global.h:279
int fProofWrite
Definition: satInter.c:48
void Int_ManResize(Int_Man_t *p)
Definition: satInter.c:209
int fVerbose
Definition: satInter.c:46
void Int_ManPrepareInter(Int_Man_t *p)
Definition: satInter.c:948
static unsigned * Int_ManTruthRead(Int_Man_t *p, Sto_Cls_t *pCls)
Definition: satInter.c:80
int Int_ManProofRecordOne(Int_Man_t *p, Sto_Cls_t *pClause)
Definition: satInter.c:770
int Int_ManProcessRoots(Int_Man_t *p)
Definition: satInter.c:875
if(last==0)
Definition: sparse_int.h:34
int nClauses
Definition: satStore.h:87
FILE * pFile
Definition: satInter.c:68
int Counter
Definition: satInter.c:66
#define assert(ex)
Definition: util_old.h:213
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
#define Sto_ManForEachClauseRoot(p, pCls)
Definition: satStore.h:100
ABC_INT64_T abctime
Definition: abc_global.h:278
void Int_ManProofWriteOne(Int_Man_t *p, Sto_Cls_t *pClause)
Definition: satInter.c:564
int* Int_ManSetGlobalVars ( Int_Man_t p,
int  nGloVars 
)

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 133 of file satInter.c.

134 {
135  p->nGloVars = nGloVars;
136  return p->pGloVars;
137 }
int pGloVars[16]
Definition: satInter.c:43
int nGloVars
Definition: satInter.c:44
Inta_Man_t* Inta_ManAlloc ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file satInterA.c.

107 {
108  Inta_Man_t * p;
109  // allocate the manager
110  p = (Inta_Man_t *)ABC_ALLOC( char, sizeof(Inta_Man_t) );
111  memset( p, 0, sizeof(Inta_Man_t) );
112  // verification
113  p->vResLits = Vec_IntAlloc( 1000 );
114  // parameters
115  p->fProofWrite = 0;
116  p->fProofVerif = 1;
117  return p;
118 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Int_t * vResLits
Definition: satInterA.c:69
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int fProofWrite
Definition: satInterA.c:48
int fProofVerif
Definition: satInterA.c:47
void Inta_ManFree ( Inta_Man_t p)

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file satInterA.c.

251 {
252 /*
253  printf( "Runtime stats:\n" );
254 ABC_PRT( "BCP ", p->timeBcp );
255 ABC_PRT( "Trace ", p->timeTrace );
256 ABC_PRT( "TOTAL ", p->timeTotal );
257 */
258  ABC_FREE( p->pInters );
259  ABC_FREE( p->pProofNums );
260  ABC_FREE( p->pTrail );
261  ABC_FREE( p->pAssigns );
262  ABC_FREE( p->pSeens );
263  ABC_FREE( p->pVarTypes );
264  ABC_FREE( p->pReasons );
265  ABC_FREE( p->pWatches );
266  Vec_IntFree( p->vResLits );
267  ABC_FREE( p );
268 }
Aig_Obj_t ** pInters
Definition: satInterA.c:62
Vec_Int_t * vResLits
Definition: satInterA.c:69
char * pSeens
Definition: satInterA.c:56
int * pProofNums
Definition: satInterA.c:66
Sto_Cls_t ** pWatches
Definition: satInterA.c:58
lit * pAssigns
Definition: satInterA.c:55
lit * pTrail
Definition: satInterA.c:54
#define ABC_FREE(obj)
Definition: abc_global.h:232
Sto_Cls_t ** pReasons
Definition: satInterA.c:57
int * pVarTypes
Definition: satInterA.c:61
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void* Inta_ManInterpolate ( Inta_Man_t p,
Sto_Man_t pCnf,
abctime  TimeToStop,
void *  vVarsAB,
int  fVerbose 
)

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

Synopsis [Computes interpolant for the given CNF.]

Description [Takes the interpolation manager, the CNF deriving by the SAT solver, which includes ClausesA, ClausesB, and learned clauses. Additional arguments are the vector of variables common to AB and the verbosiness flag. Returns the AIG manager with a single output, containing the interpolant.]

SideEffects []

SeeAlso []

Definition at line 944 of file satInterA.c.

945 {
946  Aig_Man_t * pRes;
947  Aig_Obj_t * pObj;
948  Sto_Cls_t * pClause;
949  int RetValue = 1;
950  abctime clkTotal = Abc_Clock();
951 
952  if ( TimeToStop && Abc_Clock() > TimeToStop )
953  return NULL;
954 
955  // check that the CNF makes sense
956  assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
957  p->pCnf = pCnf;
958  p->fVerbose = fVerbose;
959  p->vVarsAB = (Vec_Int_t *)vVarsAB;
960  p->pAig = pRes = Aig_ManStart( 10000 );
961  Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
962 
963  // adjust the manager
964  Inta_ManResize( p );
965 
966  // prepare the interpolant computation
968 
969  // construct proof for each clause
970  // start the proof
971  if ( p->fProofWrite )
972  {
973  p->pFile = fopen( "proof.cnf_", "w" );
974  p->Counter = 0;
975  }
976 
977  // write the root clauses
978  Sto_ManForEachClauseRoot( p->pCnf, pClause )
979  {
980  Inta_ManProofWriteOne( p, pClause );
981  if ( TimeToStop && Abc_Clock() > TimeToStop )
982  {
983  Aig_ManStop( pRes );
984  p->pAig = NULL;
985  return NULL;
986  }
987  }
988 
989  // propagate root level assignments
990  if ( Inta_ManProcessRoots( p ) )
991  {
992  // if there is no conflict, consider learned clauses
993  Sto_ManForEachClause( p->pCnf, pClause )
994  {
995  if ( pClause->fRoot )
996  continue;
997  if ( !Inta_ManProofRecordOne( p, pClause ) )
998  {
999  RetValue = 0;
1000  break;
1001  }
1002  if ( TimeToStop && Abc_Clock() > TimeToStop )
1003  {
1004  Aig_ManStop( pRes );
1005  p->pAig = NULL;
1006  return NULL;
1007  }
1008  }
1009  }
1010 
1011  // stop the proof
1012  if ( p->fProofWrite )
1013  {
1014  fclose( p->pFile );
1015 // Sat_ProofChecker( "proof.cnf_" );
1016  p->pFile = NULL;
1017  }
1018 
1019  if ( fVerbose )
1020  {
1021 // ABC_PRT( "Interpo", Abc_Clock() - clkTotal );
1022  printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f MB\n",
1023  p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
1024  1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
1025  1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
1026 p->timeTotal += Abc_Clock() - clkTotal;
1027  }
1028 
1029  pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
1030  Aig_ObjCreateCo( pRes, pObj );
1031  Aig_ManCleanup( pRes );
1032 
1033  p->pAig = NULL;
1034  return pRes;
1035 
1036 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition: satStore.c:97
int Inta_ManProofRecordOne(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition: satInterA.c:719
void Inta_ManPrepareInter(Inta_Man_t *p)
Definition: satInterA.c:897
int fVerbose
Definition: satInterA.c:46
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
unsigned fRoot
Definition: satStore.h:75
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int nVars
Definition: satStore.h:85
Sto_Man_t * pCnf
Definition: satInterA.c:43
int Inta_ManProcessRoots(Inta_Man_t *p)
Definition: satInterA.c:824
static Aig_Obj_t ** Inta_ManAigRead(Inta_Man_t *pMan, Sto_Cls_t *pCls)
Definition: satInterA.c:77
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Vec_Int_t * vVarsAB
Definition: satInterA.c:44
static abctime Abc_Clock()
Definition: abc_global.h:279
abctime timeTotal
Definition: satInterA.c:73
void Inta_ManResize(Inta_Man_t *p)
Definition: satInterA.c:187
Aig_Man_t * pAig
Definition: satInterA.c:60
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: aigOper.c:63
Definition: aig.h:69
FILE * pFile
Definition: satInterA.c:67
int fProofWrite
Definition: satInterA.c:48
Sto_Cls_t * pTail
Definition: satStore.h:90
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nClauses
Definition: satStore.h:87
#define assert(ex)
Definition: util_old.h:213
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
int Counter
Definition: satInterA.c:65
#define Sto_ManForEachClauseRoot(p, pCls)
Definition: satStore.h:100
void Inta_ManProofWriteOne(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition: satInterA.c:517
int nRoots
Definition: satStore.h:86
ABC_INT64_T abctime
Definition: abc_global.h:278
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
Intb_Man_t* Intb_ManAlloc ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file satInterB.c.

111 {
112  Intb_Man_t * p;
113  // allocate the manager
114  p = (Intb_Man_t *)ABC_ALLOC( char, sizeof(Intb_Man_t) );
115  memset( p, 0, sizeof(Intb_Man_t) );
116  // verification
117  p->nResLitsAlloc = (1<<16);
118  p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
119  // parameters
120  p->fProofWrite = 0;
121  p->fProofVerif = 1;
122  return p;
123 }
char * memset()
int fProofVerif
Definition: satInterB.c:47
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int lit
Definition: satVec.h:130
int nResLitsAlloc
Definition: satInterB.c:71
lit * pResLits
Definition: satInterB.c:69
int fProofWrite
Definition: satInterB.c:48
void Intb_ManFree ( Intb_Man_t p)

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file satInterB.c.

256 {
257 /*
258  printf( "Runtime stats:\n" );
259 ABC_PRT( "BCP ", p->timeBcp );
260 ABC_PRT( "Trace ", p->timeTrace );
261 ABC_PRT( "TOTAL ", p->timeTotal );
262 */
263  ABC_FREE( p->pInters );
264  ABC_FREE( p->pProofNums );
265  ABC_FREE( p->pTrail );
266  ABC_FREE( p->pAssigns );
267  ABC_FREE( p->pSeens );
268  ABC_FREE( p->pVarTypes );
269  ABC_FREE( p->pReasons );
270  ABC_FREE( p->pWatches );
271  ABC_FREE( p->pResLits );
272  ABC_FREE( p );
273 }
lit * pAssigns
Definition: satInterB.c:55
Aig_Obj_t ** pInters
Definition: satInterB.c:62
Sto_Cls_t ** pWatches
Definition: satInterB.c:58
char * pSeens
Definition: satInterB.c:56
int * pProofNums
Definition: satInterB.c:66
lit * pResLits
Definition: satInterB.c:69
int * pVarTypes
Definition: satInterB.c:61
lit * pTrail
Definition: satInterB.c:54
#define ABC_FREE(obj)
Definition: abc_global.h:232
Sto_Cls_t ** pReasons
Definition: satInterB.c:57
void* Intb_ManInterpolate ( Intb_Man_t p,
Sto_Man_t pCnf,
void *  vVarsAB,
int  fVerbose 
)

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

Synopsis [Computes interpolant for the given CNF.]

Description [Takes the interpolation manager, the CNF deriving by the SAT solver, which includes ClausesA, ClausesB, and learned clauses. Additional arguments are the vector of variables common to AB and the verbosiness flag. Returns the AIG manager with a single output, containing the interpolant.]

SideEffects []

SeeAlso []

Definition at line 987 of file satInterB.c.

988 {
989  Aig_Man_t * pRes;
990  Aig_Obj_t * pObj;
991  Sto_Cls_t * pClause;
992  int RetValue = 1;
993  abctime clkTotal = Abc_Clock();
994 
995  // check that the CNF makes sense
996  assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
997  p->pCnf = pCnf;
998  p->fVerbose = fVerbose;
999  p->vVarsAB = (Vec_Int_t *)vVarsAB;
1000  p->pAig = pRes = Aig_ManStart( 10000 );
1001  Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
1002 
1003  // adjust the manager
1004  Intb_ManResize( p );
1005 
1006  // prepare the interpolant computation
1007  Intb_ManPrepareInter( p );
1008 
1009  // construct proof for each clause
1010  // start the proof
1011  if ( p->fProofWrite )
1012  {
1013  p->pFile = fopen( "proof.cnf_", "w" );
1014  p->Counter = 0;
1015  }
1016 
1017  // write the root clauses
1018  Sto_ManForEachClauseRoot( p->pCnf, pClause )
1019  Intb_ManProofWriteOne( p, pClause );
1020 
1021  // propagate root level assignments
1022  if ( Intb_ManProcessRoots( p ) )
1023  {
1024  // if there is no conflict, consider learned clauses
1025  Sto_ManForEachClause( p->pCnf, pClause )
1026  {
1027  if ( pClause->fRoot )
1028  continue;
1029  if ( !Intb_ManProofRecordOne( p, pClause ) )
1030  {
1031  RetValue = 0;
1032  break;
1033  }
1034  }
1035  }
1036 
1037  // stop the proof
1038  if ( p->fProofWrite )
1039  {
1040  fclose( p->pFile );
1041 // Sat_ProofChecker( "proof.cnf_" );
1042  p->pFile = NULL;
1043  }
1044 
1045  if ( fVerbose )
1046  {
1047 // ABC_PRT( "Interpo", Abc_Clock() - clkTotal );
1048  printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f MB\n",
1049  p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
1050  1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
1051  1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
1052 p->timeTotal += Abc_Clock() - clkTotal;
1053  }
1054 
1055  pObj = *Intb_ManAigRead( p, p->pCnf->pTail );
1056  Aig_ObjCreateCo( pRes, pObj );
1057  Aig_ManCleanup( pRes );
1058 
1059  p->pAig = NULL;
1060  return pRes;
1061 
1062 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition: satStore.c:97
void Intb_ManProofWriteOne(Intb_Man_t *p, Sto_Cls_t *pClause)
Definition: satInterB.c:522
Vec_Int_t * vVarsAB
Definition: satInterB.c:44
FILE * pFile
Definition: satInterB.c:67
Aig_Man_t * pAig
Definition: satInterB.c:60
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int nVars
Definition: satStore.h:85
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
static abctime Abc_Clock()
Definition: abc_global.h:279
int Intb_ManProofRecordOne(Intb_Man_t *p, Sto_Cls_t *pClause)
Definition: satInterB.c:762
void Intb_ManResize(Intb_Man_t *p)
Definition: satInterB.c:192
void Intb_ManPrepareInter(Intb_Man_t *p)
Definition: satInterB.c:940
int Intb_ManProcessRoots(Intb_Man_t *p)
Definition: satInterB.c:867
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: aigOper.c:63
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Aig_Obj_t ** Intb_ManAigRead(Intb_Man_t *pMan, Sto_Cls_t *pCls)
Definition: satInterB.c:79
Sto_Man_t * pCnf
Definition: satInterB.c:43
int fProofWrite
Definition: satInterB.c:48
int Counter
Definition: satInterB.c:65
int nClauses
Definition: satStore.h:87
#define assert(ex)
Definition: util_old.h:213
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
#define Sto_ManForEachClauseRoot(p, pCls)
Definition: satStore.h:100
ABC_INT64_T abctime
Definition: abc_global.h:278
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
int fVerbose
Definition: satInterB.c:46
Intp_Man_t* Intp_ManAlloc ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 96 of file satInterP.c.

97 {
98  Intp_Man_t * p;
99  // allocate the manager
100  p = (Intp_Man_t *)ABC_ALLOC( char, sizeof(Intp_Man_t) );
101  memset( p, 0, sizeof(Intp_Man_t) );
102  // verification
103  p->nResLitsAlloc = (1<<16);
104  p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
105  // proof recording
106 // p->vAnties = Vec_IntAlloc( 1000 );
107 // p->vBreaks = Vec_IntAlloc( 1000 );
108  p->vAntClas = Vec_PtrAlloc( 1000 );
109  p->nAntStart = 0;
110  // parameters
111  p->fProofWrite = 0;
112  p->fProofVerif = 1;
113  return p;
114 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nResLitsAlloc
Definition: satInterP.c:70
int fProofVerif
Definition: satInterP.c:46
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int lit
Definition: satVec.h:130
int nAntStart
Definition: satInterP.c:62
Vec_Ptr_t * vAntClas
Definition: satInterP.c:61
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
lit * pResLits
Definition: satInterP.c:68
int fProofWrite
Definition: satInterP.c:47
void Intp_ManFree ( Intp_Man_t p)

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file satInterP.c.

179 {
180 /*
181  printf( "Runtime stats:\n" );
182 ABC_PRT( "BCP ", p->timeBcp );
183 ABC_PRT( "Trace ", p->timeTrace );
184 ABC_PRT( "TOTAL ", p->timeTotal );
185 */
186 // Vec_IntFree( p->vAnties );
187 // Vec_IntFree( p->vBreaks );
188  Vec_VecFree( (Vec_Vec_t *)p->vAntClas );
189 // ABC_FREE( p->pInters );
190  ABC_FREE( p->pProofNums );
191  ABC_FREE( p->pTrail );
192  ABC_FREE( p->pAssigns );
193  ABC_FREE( p->pSeens );
194 // ABC_FREE( p->pVarTypes );
195  ABC_FREE( p->pReasons );
196  ABC_FREE( p->pWatches );
197  ABC_FREE( p->pResLits );
198  ABC_FREE( p );
199 }
int * pProofNums
Definition: satInterP.c:65
lit * pAssigns
Definition: satInterP.c:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
lit * pTrail
Definition: satInterP.c:53
Vec_Ptr_t * vAntClas
Definition: satInterP.c:61
Sto_Cls_t ** pReasons
Definition: satInterP.c:56
char * pSeens
Definition: satInterP.c:55
Sto_Cls_t ** pWatches
Definition: satInterP.c:57
#define ABC_FREE(obj)
Definition: abc_global.h:232
lit * pResLits
Definition: satInterP.c:68
void* Intp_ManUnsatCore ( Intp_Man_t p,
Sto_Man_t pCnf,
int  fLearned,
int  fVerbose 
)

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

Synopsis [Computes UNSAT core of the satisfiablity problem.]

Description [Takes the interpolation manager, the CNF derived by the SAT solver, which includes the root clauses and the learned clauses. Returns the array of integers representing the number of root clauses that are in the UNSAT core.]

SideEffects []

SeeAlso []

Definition at line 963 of file satInterP.c.

964 {
965  Vec_Int_t * vCore;
966  Vec_Str_t * vVisited;
967  Sto_Cls_t * pClause;
968  int RetValue = 1;
969  abctime clkTotal = Abc_Clock();
970 
971  // check that the CNF makes sense
972  assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
973  p->pCnf = pCnf;
974  p->fVerbose = fVerbose;
975 
976  // adjust the manager
977  Intp_ManResize( p );
978 
979  // construct proof for each clause
980  // start the proof
981  if ( p->fProofWrite )
982  {
983  p->pFile = fopen( "proof.cnf_", "w" );
984  p->Counter = 0;
985  }
986 
987  // write the root clauses
988 // Vec_IntClear( p->vAnties );
989 // Vec_IntFill( p->vBreaks, p->pCnf->nRoots, 0 );
990  Vec_PtrClear( p->vAntClas );
991  p->nAntStart = p->pCnf->nRoots;
992 
993  Sto_ManForEachClauseRoot( p->pCnf, pClause )
994  Intp_ManProofWriteOne( p, pClause );
995 
996  // propagate root level assignments
997  if ( Intp_ManProcessRoots( p ) )
998  {
999  // if there is no conflict, consider learned clauses
1000  Sto_ManForEachClause( p->pCnf, pClause )
1001  {
1002  if ( pClause->fRoot )
1003  continue;
1004  if ( !Intp_ManProofRecordOne( p, pClause ) )
1005  {
1006  RetValue = 0;
1007  break;
1008  }
1009  }
1010  }
1011 
1012  // add the last breaker
1013 // assert( p->pCnf->pEmpty->Id == Vec_IntSize(p->vBreaks) - 1 );
1014 // Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
1015  assert( p->pCnf->pEmpty->Id - p->nAntStart == Vec_PtrSize(p->vAntClas) - 1 );
1016  Vec_PtrPush( p->vAntClas, Vec_IntAlloc(0) );
1017 
1018  // stop the proof
1019  if ( p->fProofWrite )
1020  {
1021  fclose( p->pFile );
1022 // Sat_ProofChecker( "proof.cnf_" );
1023  p->pFile = NULL;
1024  }
1025 
1026  if ( fVerbose )
1027  {
1028 // ABC_PRT( "Core", Abc_Clock() - clkTotal );
1029  printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f MB\n",
1030  p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
1031  1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
1032  1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
1033 p->timeTotal += Abc_Clock() - clkTotal;
1034  }
1035 
1036  // derive the UNSAT core
1037  vCore = Vec_IntAlloc( 1000 );
1038  vVisited = Vec_StrStart( p->pCnf->pEmpty->Id+1 );
1039  Intp_ManUnsatCore_rec( p->vAntClas, p->pCnf->pEmpty->Id, vCore, p->pCnf->nRoots, vVisited, fLearned );
1040  Vec_StrFree( vVisited );
1041  if ( fVerbose )
1042  printf( "Root clauses = %d. Learned clauses = %d. UNSAT core size = %d.\n",
1043  p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, Vec_IntSize(vCore) );
1044 // Intp_ManUnsatCoreVerify( p->pCnf, vCore );
1045  return vCore;
1046 }
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition: satStore.c:97
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Counter
Definition: satInterP.c:64
int nVars
Definition: satStore.h:85
Sto_Man_t * pCnf
Definition: satInterP.c:43
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
FILE * pFile
Definition: satInterP.c:66
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
if(last==0)
Definition: sparse_int.h:34
int nAntStart
Definition: satInterP.c:62
static Vec_Str_t * Vec_StrStart(int nSize)
Definition: vecStr.h:95
Vec_Ptr_t * vAntClas
Definition: satInterP.c:61
int fVerbose
Definition: satInterP.c:45
int Intp_ManProofRecordOne(Intp_Man_t *p, Sto_Cls_t *pClause)
Definition: satInterP.c:668
void Intp_ManUnsatCore_rec(Vec_Ptr_t *vAntClas, int iThis, Vec_Int_t *vCore, int nRoots, Vec_Str_t *vVisited, int fLearned)
Definition: satInterP.c:919
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Intp_ManProofWriteOne(Intp_Man_t *p, Sto_Cls_t *pClause)
Definition: satInterP.c:448
int nClauses
Definition: satStore.h:87
int Intp_ManProcessRoots(Intp_Man_t *p)
Definition: satInterP.c:782
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
#define Sto_ManForEachClauseRoot(p, pCls)
Definition: satStore.h:100
int fProofWrite
Definition: satInterP.c:47
int nRoots
Definition: satStore.h:86
ABC_INT64_T abctime
Definition: abc_global.h:278
void Intp_ManResize(Intp_Man_t *p)
Definition: satInterP.c:127
void Intp_ManUnsatCorePrintForBmc ( FILE *  pFile,
Sto_Man_t pCnf,
void *  vCore0,
void *  vVarMap0 
)

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

Synopsis [Prints learned clauses in terms of original problem varibles.]

Description []

SideEffects []

SeeAlso []

Definition at line 1059 of file satInterP.c.

1060 {
1061  Vec_Int_t * vCore = (Vec_Int_t *)vCore0;
1062  Vec_Int_t * vVarMap = (Vec_Int_t *)vVarMap0;
1063  Vec_Ptr_t * vClaMap;
1064  Sto_Cls_t * pClause;
1065  int v, i, iClause, fCompl, iObj, iFrame;
1066  // create map of clause
1067  vClaMap = Vec_PtrAlloc( pCnf->nClauses );
1068  Sto_ManForEachClause( pCnf, pClause )
1069  Vec_PtrPush( vClaMap, pClause );
1070  // print clauses
1071  fprintf( pFile, "UNSAT contains %d learned clauses:\n", Vec_IntSize(vCore) );
1072  Vec_IntForEachEntry( vCore, iClause, i )
1073  {
1074  pClause = (Sto_Cls_t *)Vec_PtrEntry(vClaMap, iClause);
1075  fprintf( pFile, "%6d : %6d : ", i, iClause - pCnf->nRoots );
1076  for ( v = 0; v < (int)pClause->nLits; v++ )
1077  {
1078  fCompl = Abc_LitIsCompl(pClause->pLits[v]);
1079  iObj = Vec_IntEntry(vVarMap, 2*Abc_Lit2Var(pClause->pLits[v]));
1080  iFrame = Vec_IntEntry(vVarMap, 2*Abc_Lit2Var(pClause->pLits[v])+1);
1081  fprintf( pFile, "%s%d(%d) ", fCompl ? "!":"", iObj, iFrame );
1082  }
1083  if ( pClause->nLits == 0 )
1084  fprintf( pFile, "Empty" );
1085  fprintf( pFile, "\n" );
1086  }
1087  Vec_PtrFree( vClaMap );
1088 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int nClauses
Definition: satStore.h:87
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
int nRoots
Definition: satStore.h:86
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Sto_ManAddClause ( Sto_Man_t p,
lit pBeg,
lit pEnd 
)

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

Synopsis [Adds one clause to the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file satStore.c.

161 {
162  Sto_Cls_t * pClause;
163  lit Lit, * i, * j;
164  int nSize;
165 
166  // process the literals
167  if ( pBeg < pEnd )
168  {
169  // insertion sort
170  for ( i = pBeg + 1; i < pEnd; i++ )
171  {
172  Lit = *i;
173  for ( j = i; j > pBeg && *(j-1) > Lit; j-- )
174  *j = *(j-1);
175  *j = Lit;
176  }
177  // make sure there is no duplicated variables
178  for ( i = pBeg + 1; i < pEnd; i++ )
179  if ( lit_var(*(i-1)) == lit_var(*i) )
180  {
181  printf( "The clause contains two literals of the same variable: %d and %d.\n", *(i-1), *i );
182  return 0;
183  }
184  // check the largest var size
185  p->nVars = STO_MAX( p->nVars, lit_var(*(pEnd-1)) + 1 );
186  }
187 
188  // get memory for the clause
189  nSize = sizeof(Sto_Cls_t) + sizeof(lit) * (pEnd - pBeg);
190  nSize = (nSize / sizeof(char*) + ((nSize % sizeof(char*)) > 0)) * sizeof(char*); // added by Saurabh on Sep 3, 2009
191  pClause = (Sto_Cls_t *)Sto_ManMemoryFetch( p, nSize );
192  memset( pClause, 0, sizeof(Sto_Cls_t) );
193 
194  // assign the clause
195  pClause->Id = p->nClauses++;
196  pClause->nLits = pEnd - pBeg;
197  memcpy( pClause->pLits, pBeg, sizeof(lit) * (pEnd - pBeg) );
198 // assert( pClause->pLits[0] >= 0 );
199 
200  // add the clause to the list
201  if ( p->pHead == NULL )
202  p->pHead = pClause;
203  if ( p->pTail == NULL )
204  p->pTail = pClause;
205  else
206  {
207  p->pTail->pNext = pClause;
208  p->pTail = pClause;
209  }
210 
211  // add the empty clause
212  if ( pClause->nLits == 0 )
213  {
214  if ( p->pEmpty )
215  {
216  printf( "More than one empty clause!\n" );
217  return 0;
218  }
219  p->pEmpty = pClause;
220  }
221  return 1;
222 }
char * memset()
Sto_Cls_t * pEmpty
Definition: satStore.h:91
int nVars
Definition: satStore.h:85
static int lit_var(lit l)
Definition: satVec.h:145
lit pLits[0]
Definition: satStore.h:78
char * memcpy()
ABC_NAMESPACE_IMPL_START char * Sto_ManMemoryFetch(Sto_Man_t *p, int nBytes)
DECLARATIONS ///.
Definition: satStore.c:50
unsigned nLits
Definition: satStore.h:77
int lit
Definition: satVec.h:130
struct Sto_Cls_t_ Sto_Cls_t
BASIC TYPES ///.
Definition: satStore.h:67
Sto_Cls_t * pHead
Definition: satStore.h:89
int Id
Definition: satStore.h:73
Sto_Cls_t * pTail
Definition: satStore.h:90
Sto_Cls_t * pNext
Definition: satStore.h:70
#define STO_MAX(a, b)
INCLUDES ///.
Definition: satStore.h:48
int nClauses
Definition: satStore.h:87
Sto_Man_t* Sto_ManAlloc ( )

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file satStore.c.

122 {
123  Sto_Man_t * p;
124  // allocate the manager
125  p = (Sto_Man_t *)ABC_ALLOC( char, sizeof(Sto_Man_t) );
126  memset( p, 0, sizeof(Sto_Man_t) );
127  // memory management
128  p->nChunkSize = (1<<16); // use 64K chunks
129  return p;
130 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nChunkSize
Definition: satStore.h:93
int Sto_ManChangeLastClause ( Sto_Man_t p)

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

Synopsis [Returns the literal of the last clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file satStore.c.

280 {
281  Sto_Cls_t * pClause, * pPrev;
282  pPrev = NULL;
283  Sto_ManForEachClause( p, pClause )
284  pPrev = pClause;
285  assert( pPrev != NULL );
286  assert( pPrev->fA == 1 );
287  assert( pPrev->nLits == 1 );
288  p->nClausesA--;
289  pPrev->fA = 0;
290  return pPrev->pLits[0] >> 1;
291 }
#define assert(ex)
Definition: util_old.h:213
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
void Sto_ManDumpClauses ( Sto_Man_t p,
char *  pFileName 
)

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

Synopsis [Writes the stored clauses into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 305 of file satStore.c.

306 {
307  FILE * pFile;
308  Sto_Cls_t * pClause;
309  int i;
310  // start the file
311  pFile = fopen( pFileName, "w" );
312  if ( pFile == NULL )
313  {
314  printf( "Error: Cannot open output file (%s).\n", pFileName );
315  return;
316  }
317  // write the data
318  fprintf( pFile, "p %d %d %d %d\n", p->nVars, p->nClauses, p->nRoots, p->nClausesA );
319  Sto_ManForEachClause( p, pClause )
320  {
321  for ( i = 0; i < (int)pClause->nLits; i++ )
322  fprintf( pFile, " %d", lit_print(pClause->pLits[i]) );
323  fprintf( pFile, " 0\n" );
324  }
325 // fprintf( pFile, " 0\n" );
326  fclose( pFile );
327 }
int nVars
Definition: satStore.h:85
lit pLits[0]
Definition: satStore.h:78
int nClausesA
Definition: satStore.h:88
unsigned nLits
Definition: satStore.h:77
int nClauses
Definition: satStore.h:87
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
int nRoots
Definition: satStore.h:86
static int lit_print(lit l)
Definition: satVec.h:147
void Sto_ManFree ( Sto_Man_t p)

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file satStore.c.

144 {
145  Sto_ManMemoryStop( p );
146  ABC_FREE( p );
147 }
void Sto_ManMemoryStop(Sto_Man_t *p)
Definition: satStore.c:76
#define ABC_FREE(obj)
Definition: abc_global.h:232
Sto_Man_t* Sto_ManLoadClauses ( char *  pFileName)

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

Synopsis [Reads CNF from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 384 of file satStore.c.

385 {
386  FILE * pFile;
387  Sto_Man_t * p;
388  Sto_Cls_t * pClause;
389  char pBuffer[1024];
390  int nLits, nLitsAlloc, Counter, Number;
391  lit * pLits;
392 
393  // start the file
394  pFile = fopen( pFileName, "r" );
395  if ( pFile == NULL )
396  {
397  printf( "Error: Cannot open input file (%s).\n", pFileName );
398  return NULL;
399  }
400 
401  // create the manager
402  p = Sto_ManAlloc();
403 
404  // alloc the array of literals
405  nLitsAlloc = 1024;
406  pLits = (lit *)ABC_ALLOC( char, sizeof(lit) * nLitsAlloc );
407 
408  // read file header
409  p->nVars = p->nClauses = p->nRoots = p->nClausesA = 0;
410  while ( fgets( pBuffer, 1024, pFile ) )
411  {
412  if ( pBuffer[0] == 'c' )
413  continue;
414  if ( pBuffer[0] == 'p' )
415  {
416  sscanf( pBuffer + 1, "%d %d %d %d", &p->nVars, &p->nClauses, &p->nRoots, &p->nClausesA );
417  break;
418  }
419  printf( "Warning: Skipping line: \"%s\"\n", pBuffer );
420  }
421 
422  // read the clauses
423  nLits = 0;
424  while ( Sto_ManLoadNumber(pFile, &Number) )
425  {
426  if ( Number == 0 )
427  {
428  int RetValue;
429  RetValue = Sto_ManAddClause( p, pLits, pLits + nLits );
430  assert( RetValue );
431  nLits = 0;
432  continue;
433  }
434  if ( nLits == nLitsAlloc )
435  {
436  nLitsAlloc *= 2;
437  pLits = ABC_REALLOC( lit, pLits, nLitsAlloc );
438  }
439  pLits[ nLits++ ] = lit_read(Number);
440  }
441  if ( nLits > 0 )
442  printf( "Error: The last clause was not saved.\n" );
443 
444  // count clauses
445  Counter = 0;
446  Sto_ManForEachClause( p, pClause )
447  Counter++;
448 
449  // check the number of clauses
450  if ( p->nClauses != Counter )
451  {
452  printf( "Error: The actual number of clauses (%d) is different than declared (%d).\n", Counter, p->nClauses );
453  Sto_ManFree( p );
454  return NULL;
455  }
456 
457  ABC_FREE( pLits );
458  fclose( pFile );
459  return p;
460 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int nVars
Definition: satStore.h:85
int nClausesA
Definition: satStore.h:88
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int lit
Definition: satVec.h:130
static lit lit_read(int s)
Definition: satVec.h:148
Sto_Man_t * Sto_ManAlloc()
MACRO DEFINITIONS ///.
Definition: satStore.c:121
if(last==0)
Definition: sparse_int.h:34
static int Counter
void Sto_ManFree(Sto_Man_t *p)
Definition: satStore.c:143
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Sto_ManAddClause(Sto_Man_t *p, lit *pBeg, lit *pEnd)
Definition: satStore.c:160
int nClauses
Definition: satStore.h:87
int Sto_ManLoadNumber(FILE *pFile, int *pNumber)
Definition: satStore.c:340
#define assert(ex)
Definition: util_old.h:213
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
int nRoots
Definition: satStore.h:86
void Sto_ManMarkClausesA ( Sto_Man_t p)

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

Synopsis [Mark all clauses added so far as clause of A.]

Description []

SideEffects []

SeeAlso []

Definition at line 257 of file satStore.c.

258 {
259  Sto_Cls_t * pClause;
260  p->nClausesA = 0;
261  Sto_ManForEachClause( p, pClause )
262  {
263  pClause->fA = 1;
264  p->nClausesA++;
265  }
266 }
int nClausesA
Definition: satStore.h:88
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
unsigned fA
Definition: satStore.h:74
void Sto_ManMarkRoots ( Sto_Man_t p)

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

Synopsis [Mark all clauses added so far as root clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file satStore.c.

236 {
237  Sto_Cls_t * pClause;
238  p->nRoots = 0;
239  Sto_ManForEachClause( p, pClause )
240  {
241  pClause->fRoot = 1;
242  p->nRoots++;
243  }
244 }
unsigned fRoot
Definition: satStore.h:75
#define Sto_ManForEachClause(p, pCls)
Definition: satStore.h:99
int nRoots
Definition: satStore.h:86
int Sto_ManMemoryReport ( Sto_Man_t p)

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

Synopsis [Reports memory usage in bytes.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file satStore.c.

98 {
99  int Total;
100  char * pMem, * pNext;
101  if ( p->pChunkLast == NULL )
102  return 0;
103  Total = p->nChunkUsed;
104  for ( pMem = p->pChunkLast; (pNext = *(char **)pMem); pMem = pNext )
105  Total += p->nChunkSize;
106  return Total;
107 }
int nChunkSize
Definition: satStore.h:93
char * pChunkLast
Definition: satStore.h:95
int nChunkUsed
Definition: satStore.h:94