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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Inter_ManCheckUniqueness (Aig_Man_t *p, sat_solver *pSat, Cnf_Dat_t *pCnf, int nFrames)
 DECLARATIONS ///. More...
 
int Inter_ManCheckContainment (Aig_Man_t *pNew, Aig_Man_t *pOld)
 FUNCTION DEFINITIONS ///. More...
 
int Inter_ManCheckEquivalence (Aig_Man_t *pNew, Aig_Man_t *pOld)
 
Aig_Man_tInter_ManFramesLatches (Aig_Man_t *pAig, int nFrames, Vec_Ptr_t **pvMapReg)
 
void Inter_ManAppendCone (Aig_Man_t *pOld, Aig_Man_t *pNew, Aig_Obj_t **ppNewPis, int fCompl)
 
int Inter_ManCheckInductiveContainment (Aig_Man_t *pTrans, Aig_Man_t *pInter, int nSteps, int fBackward)
 

Function Documentation

void Inter_ManAppendCone ( Aig_Man_t pOld,
Aig_Man_t pNew,
Aig_Obj_t **  ppNewPis,
int  fCompl 
)

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

Synopsis [Duplicates AIG while mapping PIs into the given array.]

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file intContain.c.

161 {
162  Aig_Obj_t * pObj;
163  int i;
164  assert( Aig_ManCoNum(pOld) == 1 );
165  // create the PIs
166  Aig_ManCleanData( pOld );
167  Aig_ManConst1(pOld)->pData = Aig_ManConst1(pNew);
168  Aig_ManForEachCi( pOld, pObj, i )
169  pObj->pData = ppNewPis[i];
170  // duplicate internal nodes
171  Aig_ManForEachNode( pOld, pObj, i )
172  pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
173  // add one PO to new
174  pObj = Aig_ManCo( pOld, 0 );
175  Aig_ObjCreateCo( pNew, Aig_NotCond( Aig_ObjChild0Copy(pObj), fCompl ) );
176 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
void * pData
Definition: aig.h:87
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
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
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
int Inter_ManCheckContainment ( Aig_Man_t pNew,
Aig_Man_t pOld 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Checks constainment of two interpolants.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file intContain.c.

48 {
49  Aig_Man_t * pMiter, * pAigTemp;
50  int RetValue;
51  pMiter = Aig_ManCreateMiter( pNew, pOld, 1 );
52 // pMiter = Dar_ManRwsat( pAigTemp = pMiter, 1, 0 );
53 // Aig_ManStop( pAigTemp );
54  RetValue = Fra_FraigMiterStatus( pMiter );
55  if ( RetValue == -1 )
56  {
57  pAigTemp = Fra_FraigEquivence( pMiter, 1000000, 1 );
58  RetValue = Fra_FraigMiterStatus( pAigTemp );
59  Aig_ManStop( pAigTemp );
60 // RetValue = Fra_FraigSat( pMiter, 1000000, 0, 0, 0, 0, 0, 0 );
61  }
62  assert( RetValue != -1 );
63  Aig_ManStop( pMiter );
64  return RetValue;
65 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Man_t * Aig_ManCreateMiter(Aig_Man_t *p1, Aig_Man_t *p2, int fImpl)
Definition: aigDup.c:1049
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
#define assert(ex)
Definition: util_old.h:213
int Fra_FraigMiterStatus(Aig_Man_t *p)
DECLARATIONS ///.
Definition: fraCore.c:62
int Inter_ManCheckEquivalence ( Aig_Man_t pNew,
Aig_Man_t pOld 
)

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

Synopsis [Checks constainment of two interpolants.]

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file intContain.c.

79 {
80  Aig_Man_t * pMiter, * pAigTemp;
81  int RetValue;
82  pMiter = Aig_ManCreateMiter( pNew, pOld, 0 );
83 // pMiter = Dar_ManRwsat( pAigTemp = pMiter, 1, 0 );
84 // Aig_ManStop( pAigTemp );
85  RetValue = Fra_FraigMiterStatus( pMiter );
86  if ( RetValue == -1 )
87  {
88  pAigTemp = Fra_FraigEquivence( pMiter, 1000000, 1 );
89  RetValue = Fra_FraigMiterStatus( pAigTemp );
90  Aig_ManStop( pAigTemp );
91 // RetValue = Fra_FraigSat( pMiter, 1000000, 0, 0, 0, 0, 0, 0 );
92  }
93  assert( RetValue != -1 );
94  Aig_ManStop( pMiter );
95  return RetValue;
96 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Man_t * Aig_ManCreateMiter(Aig_Man_t *p1, Aig_Man_t *p2, int fImpl)
Definition: aigDup.c:1049
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
#define assert(ex)
Definition: util_old.h:213
int Fra_FraigMiterStatus(Aig_Man_t *p)
DECLARATIONS ///.
Definition: fraCore.c:62
int Inter_ManCheckInductiveContainment ( Aig_Man_t pTrans,
Aig_Man_t pInter,
int  nSteps,
int  fBackward 
)

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

Synopsis [Checks constainment of two interpolants inductively.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file intContain.c.

191 {
192  Aig_Man_t * pFrames;
193  Aig_Obj_t ** ppNodes;
194  Vec_Ptr_t * vMapRegs;
195  Cnf_Dat_t * pCnf;
196  sat_solver * pSat;
197  int f, nRegs, status;
198  nRegs = Saig_ManRegNum(pTrans);
199  assert( nRegs > 0 );
200  // generate the timeframes
201  pFrames = Inter_ManFramesLatches( pTrans, nSteps, &vMapRegs );
202  assert( Vec_PtrSize(vMapRegs) == (nSteps + 1) * nRegs );
203  // add main constraints to the timeframes
204  ppNodes = (Aig_Obj_t **)Vec_PtrArray(vMapRegs);
205  if ( !fBackward )
206  {
207  // forward inductive check: p -> p -> ... -> !p
208  for ( f = 0; f < nSteps; f++ )
209  Inter_ManAppendCone( pInter, pFrames, ppNodes + f * nRegs, 0 );
210  Inter_ManAppendCone( pInter, pFrames, ppNodes + f * nRegs, 1 );
211  }
212  else
213  {
214  // backward inductive check: p -> !p -> ... -> !p
215  Inter_ManAppendCone( pInter, pFrames, ppNodes + 0 * nRegs, 1 );
216  for ( f = 1; f <= nSteps; f++ )
217  Inter_ManAppendCone( pInter, pFrames, ppNodes + f * nRegs, 0 );
218  }
219  Vec_PtrFree( vMapRegs );
220  Aig_ManCleanup( pFrames );
221 
222  // convert to CNF
223  pCnf = Cnf_Derive( pFrames, 0 );
224  pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
225 // Cnf_DataFree( pCnf );
226 // Aig_ManStop( pFrames );
227 
228  if ( pSat == NULL )
229  {
230  Cnf_DataFree( pCnf );
231  Aig_ManStop( pFrames );
232  return 1;
233  }
234 
235  // solve the problem
236  status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
237 
238 // Inter_ManCheckUniqueness( pTrans, pSat, pCnf, nSteps );
239 
240  Cnf_DataFree( pCnf );
241  Aig_ManStop( pFrames );
242 
243  sat_solver_delete( pSat );
244  return status == l_False;
245 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
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
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
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
Aig_Man_t * Inter_ManFramesLatches(Aig_Man_t *pAig, int nFrames, Vec_Ptr_t **pvMapReg)
Definition: intContain.c:111
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: cnf.h:56
void Inter_ManAppendCone(Aig_Man_t *pOld, Aig_Man_t *pNew, Aig_Obj_t **ppNewPis, int fCompl)
Definition: intContain.c:160
Definition: aig.h:69
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition: cnfMan.c:463
#define l_False
Definition: SolverTypes.h:85
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
#define assert(ex)
Definition: util_old.h:213
static void ** Vec_PtrArray(Vec_Ptr_t *p)
Definition: vecPtr.h:279
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START int Inter_ManCheckUniqueness ( Aig_Man_t p,
sat_solver pSat,
Cnf_Dat_t pCnf,
int  nFrames 
)

DECLARATIONS ///.

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

FileName [intContain.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Interpolation engine.]

Synopsis [Interpolant containment checking.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Check if cex satisfies uniqueness constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file intContain.c.

265 {
266  extern int Fra_SmlNodesCompareInFrame( Fra_Sml_t * p, Aig_Obj_t * pObj0, Aig_Obj_t * pObj1, int iFrame0, int iFrame1 );
267  extern void Fra_SmlAssignConst( Fra_Sml_t * p, Aig_Obj_t * pObj, int fConst1, int iFrame );
268  extern void Fra_SmlSimulateOne( Fra_Sml_t * p );
269 
270  Fra_Sml_t * pSml;
271  Vec_Int_t * vPis;
272  Aig_Obj_t * pObj, * pObj0;
273  int i, k, v, iBit, * pCounterEx;
274  int Counter;
275  if ( nFrames == 1 )
276  return 1;
277 // if ( pSat->model.size == 0 )
278 
279  // possible consequences here!!!
280  assert( 0 );
281 
282  if ( sat_solver_nvars(pSat) == 0 )
283  return 1;
284 // assert( Saig_ManPoNum(p) == 1 );
285  assert( Aig_ManRegNum(p) > 0 );
287 
288  // get the counter-example
289  vPis = Vec_IntAlloc( 100 );
290  Aig_ManForEachCi( pCnf->pMan, pObj, k )
291  Vec_IntPush( vPis, pCnf->pVarNums[Aig_ObjId(pObj)] );
292  assert( Vec_IntSize(vPis) == Aig_ManRegNum(p) + nFrames * Saig_ManPiNum(p) );
293  pCounterEx = Sat_SolverGetModel( pSat, vPis->pArray, vPis->nSize );
294  Vec_IntFree( vPis );
295 
296  // start a new sequential simulator
297  pSml = Fra_SmlStart( p, 0, nFrames, 1 );
298  // assign simulation info for the registers
299  iBit = 0;
300  Aig_ManForEachLoSeq( p, pObj, i )
301  Fra_SmlAssignConst( pSml, pObj, pCounterEx[iBit++], 0 );
302  // assign simulation info for the primary inputs
303  for ( i = 0; i < nFrames; i++ )
304  Aig_ManForEachPiSeq( p, pObj, k )
305  Fra_SmlAssignConst( pSml, pObj, pCounterEx[iBit++], i );
306  assert( iBit == Aig_ManCiNum(pCnf->pMan) );
307  // run simulation
308  Fra_SmlSimulateOne( pSml );
309 
310  // check if the given output has failed
311 // RetValue = !Fra_SmlNodeIsZero( pSml, Aig_ManCo(pAig, 0) );
312 // assert( RetValue );
313 
314  // check values at the internal nodes
315  Counter = 0;
316  for ( i = 0; i < nFrames; i++ )
317  for ( k = i+1; k < nFrames; k++ )
318  {
319  for ( v = 0; v < Aig_ManRegNum(p); v++ )
320  {
321  pObj0 = Aig_ManLo(p, v);
322  if ( !Fra_SmlNodesCompareInFrame( pSml, pObj0, pObj0, i, k ) )
323  break;
324  }
325  if ( v == Aig_ManRegNum(p) )
326  Counter++;
327  }
328  printf( "Uniquness does not hold in %d frames.\n", Counter );
329 
330  Fra_SmlStop( pSml );
331  ABC_FREE( pCounterEx );
332  return 1;
333 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Fra_SmlAssignConst(Fra_Sml_t *p, Aig_Obj_t *pObj, int fConst1, int iFrame)
Definition: fraSim.c:379
int Fra_SmlNodesCompareInFrame(Fra_Sml_t *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1, int iFrame0, int iFrame1)
Definition: fraSim.c:550
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Man_t * pMan
Definition: cnf.h:58
void Fra_SmlSimulateOne(Fra_Sml_t *p)
Definition: fraSim.c:663
for(p=first;p->value< newval;p=p->next)
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: fraSim.c:813
static Aig_Obj_t * Aig_ManLo(Aig_Man_t *p, int i)
Definition: aig.h:268
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
int sat_solver_nvars(sat_solver *s)
Definition: satSolver.c:1896
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
Definition: satUtil.c:266
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
Aig_Man_t* Inter_ManFramesLatches ( Aig_Man_t pAig,
int  nFrames,
Vec_Ptr_t **  pvMapReg 
)

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

Synopsis [Create timeframes of the manager for interpolation.]

Description [The resulting manager is combinational. The primary inputs corresponding to register outputs are ordered first.]

SideEffects []

SeeAlso []

Definition at line 111 of file intContain.c.

112 {
113  Aig_Man_t * pFrames;
114  Aig_Obj_t * pObj, * pObjLi, * pObjLo;
115  int i, f;
116  assert( Saig_ManRegNum(pAig) > 0 );
117  pFrames = Aig_ManStart( Aig_ManNodeNum(pAig) * nFrames );
118  // map the constant node
119  Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
120  // create variables for register outputs
121  *pvMapReg = Vec_PtrAlloc( (nFrames+1) * Saig_ManRegNum(pAig) );
122  Saig_ManForEachLo( pAig, pObj, i )
123  {
124  pObj->pData = Aig_ObjCreateCi( pFrames );
125  Vec_PtrPush( *pvMapReg, pObj->pData );
126  }
127  // add timeframes
128  for ( f = 0; f < nFrames; f++ )
129  {
130  // create PI nodes for this frame
131  Saig_ManForEachPi( pAig, pObj, i )
132  pObj->pData = Aig_ObjCreateCi( pFrames );
133  // add internal nodes of this frame
134  Aig_ManForEachNode( pAig, pObj, i )
135  pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
136  // save register inputs
137  Saig_ManForEachLi( pAig, pObj, i )
138  pObj->pData = Aig_ObjChild0Copy(pObj);
139  // transfer to register outputs
140  Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
141  {
142  pObjLo->pData = pObjLi->pData;
143  Vec_PtrPush( *pvMapReg, pObjLo->pData );
144  }
145  }
146  return pFrames;
147 }
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 void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
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
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
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 Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91