abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
intCtrex.c File Reference
#include "intInt.h"
#include "proof/ssw/ssw.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Aig_Man_t
Inter_ManFramesBmc (Aig_Man_t *pAig, int nFrames)
 DECLARATIONS ///. More...
 
void * Inter_ManGetCounterExample (Aig_Man_t *pAig, int nFrames, int fVerbose)
 

Function Documentation

ABC_NAMESPACE_IMPL_START Aig_Man_t* Inter_ManFramesBmc ( Aig_Man_t pAig,
int  nFrames 
)

DECLARATIONS ///.

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

FileName [intCtrex.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Interpolation engine.]

Synopsis [Counter-example generation after disproving the property.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 24, 2008.]

Revision [

Id:
intCtrex.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Unroll the circuit the given number of timeframes.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file intCtrex.c.

47 {
48  Aig_Man_t * pFrames;
49  Aig_Obj_t * pObj, * pObjLi, * pObjLo;
50  int i, f;
51  assert( Saig_ManRegNum(pAig) > 0 );
52  assert( Saig_ManPoNum(pAig) == 1 );
53  pFrames = Aig_ManStart( Aig_ManNodeNum(pAig) * nFrames );
54  // map the constant node
55  Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
56  // create variables for register outputs
57  Saig_ManForEachLo( pAig, pObj, i )
58  pObj->pData = Aig_ManConst0( pFrames );
59  // add timeframes
60  for ( f = 0; f < nFrames; f++ )
61  {
62  // create PI nodes for this frame
63  Saig_ManForEachPi( pAig, pObj, i )
64  pObj->pData = Aig_ObjCreateCi( pFrames );
65  // add internal nodes of this frame
66  Aig_ManForEachNode( pAig, pObj, i )
67  pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
68  if ( f == nFrames - 1 )
69  break;
70  // transfer to register outputs
71  Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
72  pObjLi->pData = Aig_ObjChild0Copy(pObjLi);
73  // transfer to register outputs
74  Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
75  pObjLo->pData = pObjLi->pData;
76  }
77  // create POs for the output of the last frame
78  pObj = Aig_ManCo( pAig, 0 );
79  Aig_ObjCreateCo( pFrames, Aig_ObjChild0Copy(pObj) );
80  Aig_ManCleanup( pFrames );
81  return pFrames;
82 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
void * pData
Definition: aig.h:87
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
for(p=first;p->value< newval;p=p->next)
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
if(last==0)
Definition: sparse_int.h:34
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define assert(ex)
Definition: util_old.h:213
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91
void* Inter_ManGetCounterExample ( Aig_Man_t pAig,
int  nFrames,
int  fVerbose 
)

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

Synopsis [Run the SAT solver on the unrolled instance.]

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file intCtrex.c.

96 {
97  int nConfLimit = 1000000;
98  Abc_Cex_t * pCtrex = NULL;
99  Aig_Man_t * pFrames;
100  sat_solver * pSat;
101  Cnf_Dat_t * pCnf;
102  int status;
103  abctime clk = Abc_Clock();
104  Vec_Int_t * vCiIds;
105  // create timeframes
106  assert( Saig_ManPoNum(pAig) == 1 );
107  pFrames = Inter_ManFramesBmc( pAig, nFrames );
108  // derive CNF
109  pCnf = Cnf_Derive( pFrames, 0 );
110  Cnf_DataTranformPolarity( pCnf, 0 );
111  vCiIds = Cnf_DataCollectPiSatNums( pCnf, pFrames );
112  Aig_ManStop( pFrames );
113  // convert into SAT solver
114  pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
115  Cnf_DataFree( pCnf );
116  if ( pSat == NULL )
117  {
118  printf( "Counter-example generation in command \"int\" has failed.\n" );
119  printf( "Use command \"bmc2\" to produce a valid counter-example.\n" );
120  Vec_IntFree( vCiIds );
121  return NULL;
122  }
123  // simplify the problem
124  status = sat_solver_simplify(pSat);
125  if ( status == 0 )
126  {
127  Vec_IntFree( vCiIds );
128  sat_solver_delete( pSat );
129  return NULL;
130  }
131  // solve the miter
132  status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
133  // if the problem is SAT, get the counterexample
134  if ( status == l_True )
135  {
136  int i, * pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
137  pCtrex = Abc_CexAlloc( Saig_ManRegNum(pAig), Saig_ManPiNum(pAig), nFrames );
138  pCtrex->iFrame = nFrames - 1;
139  pCtrex->iPo = 0;
140  for ( i = 0; i < Vec_IntSize(vCiIds); i++ )
141  if ( pModel[i] )
142  Abc_InfoSetBit( pCtrex->pData, Saig_ManRegNum(pAig) + i );
143  ABC_FREE( pModel );
144  }
145  // free the sat_solver
146  sat_solver_delete( pSat );
147  Vec_IntFree( vCiIds );
148  // verify counter-example
149  status = Saig_ManVerifyCex( pAig, pCtrex );
150  if ( status == 0 )
151  printf( "Inter_ManGetCounterExample(): Counter-example verification has FAILED.\n" );
152  // report the results
153  if ( fVerbose )
154  {
155  ABC_PRT( "Total ctrex generation time", Abc_Clock() - clk );
156  }
157  return pCtrex;
158 
159 }
ABC_NAMESPACE_IMPL_START Aig_Man_t * Inter_ManFramesBmc(Aig_Man_t *pAig, int nFrames)
DECLARATIONS ///.
Definition: intCtrex.c:46
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition: cnfCore.c:165
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
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition: utilCex.c:51
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition: saigDup.c:279
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
void Cnf_DataTranformPolarity(Cnf_Dat_t *pCnf, int fTransformPos)
Definition: cnfMan.c:652
#define l_True
Definition: SolverTypes.h:84
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: cnf.h:56
Vec_Int_t * Cnf_DataCollectPiSatNums(Cnf_Dat_t *pCnf, Aig_Man_t *p)
Definition: cnfMan.c:104
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition: cnfMan.c:463
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
Definition: satUtil.c:266