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

Go to the source code of this file.

Classes

struct  Sto_Cls_t_
 
struct  Sto_Man_t_
 

Macros

#define STO_MAX(a, b)
 INCLUDES ///.
 
#define Sto_ManForEachClause(p, pCls)
 
#define Sto_ManForEachClauseRoot(p, pCls)
 

Typedefs

typedef struct Sto_Cls_t_ Sto_Cls_t
 BASIC TYPES ///.
 
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 ///.
 
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 ///.
 
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 ///.
 
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 ///.
 
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 ///.
 
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

◆ Sto_ManForEachClause

#define Sto_ManForEachClause ( p,
pCls )
Value:
for( pCls = p->pHead; pCls; pCls = pCls->pNext )
Cube * p
Definition exorList.c:222

Definition at line 99 of file satStore.h.

◆ Sto_ManForEachClauseRoot

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

Definition at line 100 of file satStore.h.

◆ STO_MAX

#define STO_MAX ( a,
b )
Value:
((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

◆ Int_Man_t

typedef struct Int_Man_t_ Int_Man_t

Definition at line 123 of file satStore.h.

◆ Inta_Man_t

typedef struct Inta_Man_t_ Inta_Man_t

Definition at line 130 of file satStore.h.

◆ Intb_Man_t

typedef struct Intb_Man_t_ Intb_Man_t

Definition at line 136 of file satStore.h.

◆ Intp_Man_t

typedef struct Intp_Man_t_ Intp_Man_t

Definition at line 142 of file satStore.h.

◆ Sto_Cls_t

typedef struct Sto_Cls_t_ Sto_Cls_t

BASIC TYPES ///.

Definition at line 67 of file satStore.h.

◆ Sto_Man_t

typedef struct Sto_Man_t_ Sto_Man_t

Definition at line 81 of file satStore.h.

Function Documentation

◆ Int_ManAlloc()

Int_Man_t * Int_ManAlloc ( )
extern

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}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
struct Int_Man_t_ Int_Man_t
Definition satStore.h:123
int lit
Definition satVec.h:130
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Int_ManFree()

void Int_ManFree ( Int_Man_t * p)
extern

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file satInter.c.

274{
275/*
276 printf( "Runtime stats:\n" );
277ABC_PRT( "BCP ", p->timeBcp );
278ABC_PRT( "Trace ", p->timeTrace );
279ABC_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}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Int_ManInterpolate()

int Int_ManInterpolate ( Int_Man_t * p,
Sto_Man_t * pCnf,
int fVerbose,
unsigned ** ppResult )
extern

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
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) );
1064p->timeTotal += Abc_Clock() - clkTotal;
1065 }
1066
1067 *ppResult = Int_ManTruthRead( p, p->pCnf->pTail );
1068 return p->nVarsAB;
1069}
ABC_INT64_T abctime
Definition abc_global.h:332
void Int_ManPrepareInter(Int_Man_t *p)
Definition satInter.c:948
void Int_ManResize(Int_Man_t *p)
Definition satInter.c:209
int Int_ManProcessRoots(Int_Man_t *p)
Definition satInter.c:875
int Int_ManProofRecordOne(Int_Man_t *p, Sto_Cls_t *pClause)
Definition satInter.c:770
void Int_ManProofWriteOne(Int_Man_t *p, Sto_Cls_t *pClause)
Definition satInter.c:564
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition satStore.c:97
#define Sto_ManForEachClause(p, pCls)
Definition satStore.h:99
struct Sto_Cls_t_ Sto_Cls_t
BASIC TYPES ///.
Definition satStore.h:67
#define Sto_ManForEachClauseRoot(p, pCls)
Definition satStore.h:100
unsigned fRoot
Definition satStore.h:75
int nVars
Definition satStore.h:85
int nClauses
Definition satStore.h:87
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Int_ManSetGlobalVars()

int * Int_ManSetGlobalVars ( Int_Man_t * p,
int nGloVars )
extern

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}
Here is the caller graph for this function:

◆ Inta_ManAlloc()

Inta_Man_t * Inta_ManAlloc ( )
extern

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}
struct Inta_Man_t_ Inta_Man_t
Definition satStore.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManFree()

void Inta_ManFree ( Inta_Man_t * p)
extern

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file satInterA.c.

251{
252/*
253 printf( "Runtime stats:\n" );
254ABC_PRT( "BCP ", p->timeBcp );
255ABC_PRT( "Trace ", p->timeTrace );
256ABC_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}
Here is the caller graph for this function:

◆ Inta_ManInterpolate()

void * Inta_ManInterpolate ( Inta_Man_t * p,
Sto_Man_t * pCnf,
abctime TimeToStop,
void * vVarsAB,
int fVerbose )
extern

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 ",
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 Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
1027p->timeTotal += Abc_Clock() - clkTotal;
1028 }
1029
1030 pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
1031 Aig_ObjCreateCo( pRes, pObj );
1032 Aig_ManCleanup( pRes );
1033
1034 p->pAig = NULL;
1035 return pRes;
1036
1037}
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition aigOper.c:63
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Inta_ManPrepareInter(Inta_Man_t *p)
Definition satInterA.c:897
int Inta_ManProofRecordOne(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition satInterA.c:719
void Inta_ManResize(Inta_Man_t *p)
Definition satInterA.c:187
int Inta_ManProcessRoots(Inta_Man_t *p)
Definition satInterA.c:824
void Inta_ManProofWriteOne(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition satInterA.c:517
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Intb_ManAlloc()

Intb_Man_t * Intb_ManAlloc ( )
extern

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}
struct Intb_Man_t_ Intb_Man_t
Definition satStore.h:136
Here is the call graph for this function:

◆ Intb_ManFree()

void Intb_ManFree ( Intb_Man_t * p)
extern

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file satInterB.c.

256{
257/*
258 printf( "Runtime stats:\n" );
259ABC_PRT( "BCP ", p->timeBcp );
260ABC_PRT( "Trace ", p->timeTrace );
261ABC_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}

◆ Intb_ManInterpolate()

void * Intb_ManInterpolate ( Intb_Man_t * p,
Sto_Man_t * pCnf,
void * vVarsAB,
int fVerbose )
extern

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
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) );
1052p->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}
void Intb_ManProofWriteOne(Intb_Man_t *p, Sto_Cls_t *pClause)
Definition satInterB.c:522
int Intb_ManProcessRoots(Intb_Man_t *p)
Definition satInterB.c:867
void Intb_ManResize(Intb_Man_t *p)
Definition satInterB.c:192
int Intb_ManProofRecordOne(Intb_Man_t *p, Sto_Cls_t *pClause)
Definition satInterB.c:762
void Intb_ManPrepareInter(Intb_Man_t *p)
Definition satInterB.c:940
Here is the call graph for this function:

◆ Intp_ManAlloc()

Intp_Man_t * Intp_ManAlloc ( )
extern

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}
struct Intp_Man_t_ Intp_Man_t
Definition satStore.h:142
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Intp_ManFree()

void Intp_ManFree ( Intp_Man_t * p)
extern

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file satInterP.c.

179{
180/*
181 printf( "Runtime stats:\n" );
182ABC_PRT( "BCP ", p->timeBcp );
183ABC_PRT( "Trace ", p->timeTrace );
184ABC_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}
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the caller graph for this function:

◆ Intp_ManUnsatCore()

void * Intp_ManUnsatCore ( Intp_Man_t * p,
Sto_Man_t * pCnf,
int fLearned,
int fVerbose )
extern

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) );
1033p->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}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
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
void Intp_ManResize(Intp_Man_t *p)
Definition satInterP.c:127
void Intp_ManProofWriteOne(Intp_Man_t *p, Sto_Cls_t *pClause)
Definition satInterP.c:448
int Intp_ManProofRecordOne(Intp_Man_t *p, Sto_Cls_t *pClause)
Definition satInterP.c:668
int Intp_ManProcessRoots(Intp_Man_t *p)
Definition satInterP.c:782
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Intp_ManUnsatCorePrintForBmc()

void Intp_ManUnsatCorePrintForBmc ( FILE * pFile,
Sto_Man_t * pCnf,
void * vCore0,
void * vVarMap0 )
extern

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}
lit pLits[0]
Definition satStore.h:78
unsigned nLits
Definition satStore.h:77
int nRoots
Definition satStore.h:86
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the caller graph for this function:

◆ Sto_ManAddClause()

int Sto_ManAddClause ( Sto_Man_t * p,
lit * pBeg,
lit * pEnd )
extern

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}
ABC_NAMESPACE_IMPL_START char * Sto_ManMemoryFetch(Sto_Man_t *p, int nBytes)
DECLARATIONS ///.
Definition satStore.c:50
#define STO_MAX(a, b)
INCLUDES ///.
Definition satStore.h:48
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sto_ManAlloc()

Sto_Man_t * Sto_ManAlloc ( )
extern

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}
struct Sto_Man_t_ Sto_Man_t
Definition satStore.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sto_ManChangeLastClause()

int Sto_ManChangeLastClause ( Sto_Man_t * p)
extern

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}
unsigned fA
Definition satStore.h:74
Here is the caller graph for this function:

◆ Sto_ManDumpClauses()

void Sto_ManDumpClauses ( Sto_Man_t * p,
char * pFileName )
extern

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}
Here is the caller graph for this function:

◆ Sto_ManFree()

void Sto_ManFree ( Sto_Man_t * p)
extern

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file satStore.c.

144{
146 ABC_FREE( p );
147}
void Sto_ManMemoryStop(Sto_Man_t *p)
Definition satStore.c:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sto_ManLoadClauses()

Sto_Man_t * Sto_ManLoadClauses ( char * pFileName)
extern

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}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
int Sto_ManLoadNumber(FILE *pFile, int *pNumber)
Definition satStore.c:340
Sto_Man_t * Sto_ManAlloc()
MACRO DEFINITIONS ///.
Definition satStore.c:121
int Sto_ManAddClause(Sto_Man_t *p, lit *pBeg, lit *pEnd)
Definition satStore.c:160
void Sto_ManFree(Sto_Man_t *p)
Definition satStore.c:143
Here is the call graph for this function:

◆ Sto_ManMarkClausesA()

void Sto_ManMarkClausesA ( Sto_Man_t * p)
extern

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}
Here is the caller graph for this function:

◆ Sto_ManMarkRoots()

void Sto_ManMarkRoots ( Sto_Man_t * p)
extern

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}
Here is the caller graph for this function:

◆ Sto_ManMemoryReport()

int Sto_ManMemoryReport ( Sto_Man_t * p)
extern

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}
Here is the caller graph for this function: