Commit b910cba3 by Alan Mishchenko

Initial new interpolation code.

parent d9bbcb5d
/**CFile****************************************************************
FileName [int2.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Interpolation engine.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - Dec 1, 2013.]
Revision [$Id: int2.h,v 1.00 2013/12/01 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef ABC__aig__int2__int_h
#define ABC__aig__int2__int_h
/*
The interpolation algorithm implemented here was introduced in the papers:
K. L. McMillan. Interpolation and SAT-based model checking. CAV’03, pp. 1-13.
C.-Y. Wu et al. A CEX-Guided Interpolant Generation Algorithm for
SAT-based Model Checking. DAC'13.
*/
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
// simulation manager
typedef struct Int2_ManPars_t_ Int2_ManPars_t;
struct Int2_ManPars_t_
{
int nBTLimit; // limit on the number of conflicts
int nFramesS; // the starting number timeframes
int nFramesMax; // the max number timeframes to unroll
int nSecLimit; // time limit in seconds
int nFramesK; // the number of timeframes to use in induction
int fRewrite; // use additional rewriting to simplify timeframes
int fTransLoop; // add transition into the init state under new PI var
int fDropInvar; // dump inductive invariant into file
int fVerbose; // print verbose statistics
int iFrameMax; // the time frame reached
char * pFileName; // file name to dump interpolant
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== intCore.c ==========================================================*/
extern void Int2_ManSetDefaultParams( Int2_ManPars_t * p );
extern int Int2_ManPerformInterpolation( Gia_Man_t * p, Int2_ManPars_t * pPars );
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [int2Int.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Interpolation engine.]
Synopsis [Internal declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - Dec 1, 2013.]
Revision [$Id: int2Int.h,v 1.00 2013/12/01 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef ABC__Gia__int2__intInt_h
#define ABC__Gia__int2__intInt_h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "aig/gia/gia.h"
#include "sat/bsat/satSolver.h"
#include "sat/cnf/cnf.h"
#include "int2.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
// interpolation manager
typedef struct Int2_Man_t_ Int2_Man_t;
struct Int2_Man_t_
{
// parameters
Int2_ManPars_t * pPars; // parameters
// GIA managers
Gia_Man_t * pGia; // original manager
Gia_Man_t * pGiaPref; // prefix manager
Gia_Man_t * pGiaSuff; // suffix manager
// subset of the manager
Vec_Int_t * vSuffCis; // suffix CIs
Vec_Int_t * vSuffCos; // suffix COs
Vec_Int_t * vPrefCos; // suffix POs
Vec_Int_t * vStack; // temporary stack
// preimages
Vec_Int_t * vImageOne; // latest preimage
Vec_Int_t * vImagesAll; // cumulative preimage
// variable maps
Vec_Ptr_t * vMapFrames; // mapping of GIA IDs into frame IDs
Vec_Int_t * vMapPref; // mapping of flop inputs into SAT variables
Vec_Int_t * vMapSuff; // mapping of flop outputs into SAT variables
// initial minimization
Vec_Int_t * vAssign; // assignment of PIs in pGiaSuff
Vec_Int_t * vPrio; // priority of PIs in pGiaSuff
// SAT solving
sat_solver * pSatPref; // prefix solver
sat_solver * pSatSuff; // suffix solver
// runtime
abctime timeSatPref;
abctime timeSatSuff;
abctime timeOther;
abctime timeTotal;
};
static inline Int2_Man_t * Int2_ManCreate( Gia_Man_t * pGia, Int2_ManPars_t * pPars )
{
Int2_Man_t * p;
p = ABC_CALLOC( Int2_Man_t, 1 );
p->pPars = pPars;
p->pGia = pGia;
p->pGiaPref = Gia_ManStart( 10000 );
// perform structural hashing
Gia_ManHashAlloc( pFrames );
// subset of the manager
p->vSuffCis = Vec_IntAlloc( Gia_ManCiNum(pGia) );
p->vSuffCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
p->vPrefCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
p->vStack = Vec_IntAlloc( 10000 );
// preimages
p->vImageOne = Vec_IntAlloc( 1000 );
p->vImagesAll = Vec_IntAlloc( 1000 );
// variable maps
p->vMapFrames = Vec_PtrAlloc( 100 );
p->vMapPref = Vec_IntAlloc( Gia_ManRegNum(pGia) );
p->vMapSuff = Vec_IntAlloc( Gia_ManRegNum(pGia) );
// initial minimization
p->vAssign = Vec_IntAlloc( Gia_ManCiNum(pGia) );
p->vPrio = Vec_IntAlloc( Gia_ManCiNum(pGia) );
return p;
}
static inline void Int2_ManStop( Int2_Man_t * p )
{
// GIA managers
Gia_ManStopP( &p->pGiaPref );
Gia_ManStopP( &p->pGiaSuff );
// subset of the manager
Vec_IntFreeP( &p->vSuffCis );
Vec_IntFreeP( &p->vSuffCos );
Vec_IntFreeP( &p->vPrefCos );
Vec_IntFreeP( &p->vStack );
// preimages
Vec_IntFreeP( &p->vImageOne );
Vec_IntFreeP( &p->vImagesAll );
// variable maps
Vec_VecFree( (Vec_Vec_t *)p->vMapFrames );
Vec_IntFreeP( &p->vMapPref );
Vec_IntFreeP( &p->vMapSuff );
// initial minimization
Vec_IntFreeP( &p->vAssign );
Vec_IntFreeP( &p->vPrio );
// SAT solving
if ( p->pSatPref )
sat_solver_delete( p->pSatPref );
if ( p->timeSatSuff )
sat_solver_delete( p->pSatSuff );
ABC_FREE( p );
}
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== int2Bmc.c =============================================================*/
extern int Int2_ManCheckInit( Gia_Man_t * p );
extern Gia_Man_t * Int2_ManDupInit( Gia_Man_t * p, int fVerbose );
extern sat_solver * Int2_ManSetupBmcSolver( Gia_Man_t * p, int nFrames );
extern void Int2_ManCreateFrames( Int2_Man_t * p, int iFrame, Vec_Int_t * vPrefCos );
extern int Int2_ManCheckBmc( Int2_Man_t * p, Vec_Int_t * vCube );
/*=== int2Refine.c =============================================================*/
extern Vec_Int_t * Int2_ManRefineCube( Gia_Man_t * p, Vec_Int_t * vAssign, Vec_Int_t * vPrio );
/*=== int2Util.c ============================================================*/
extern Gia_Man_t * Int2_ManProbToGia( Gia_Man_t * p, Vec_Int_t * vSop );
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [int2Refine.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Interpolation engine.]
Synopsis [Various utilities.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - Dec 1, 2013.]
Revision [$Id: int2Refine.c,v 1.00 2013/12/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "int2Int.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Int2_ManJustify_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSelect )
{
if ( pObj->fMark1 )
return;
pObj->fMark1 = 1;
if ( Gia_ObjIsPi(p, pObj) )
return;
if ( Gia_ObjIsCo(pObj) )
{
Vec_IntPush( vSelect, Gia_ObjCioId(pObj) );
return;
}
assert( Gia_ObjIsAnd(pObj) );
if ( pObj->Value == 1 )
{
if ( Gia_ObjFanin0(pObj)->Value < ABC_INFINITY )
Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSelect );
if ( Gia_ObjFanin1(pObj)->Value < ABC_INFINITY )
Int2_ManJustify_rec( p, Gia_ObjFanin1(pObj), vSelect );
return;
}
if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 && (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj)) == 0 )
{
if ( Gia_ObjFanin0(pObj)->fMark0 <= Gia_ObjFanin1(pObj)->fMark0 ) // choice
{
if ( Gia_ObjFanin0(pObj)->Value < ABC_INFINITY )
Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSelect );
}
else
{
if ( Gia_ObjFanin1(pObj)->Value < ABC_INFINITY )
Int2_ManJustify_rec( p, Gia_ObjFanin1(pObj), vSelect );
}
}
else if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 )
{
if ( Gia_ObjFanin0(pObj)->Value < ABC_INFINITY )
Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSelect );
}
else if ( (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj)) == 0 )
{
if ( Gia_ObjFanin1(pObj)->Value < ABC_INFINITY )
Int2_ManJustify_rec( p, Gia_ObjFanin1(pObj), vSelect );
}
else assert( 0 );
}
/**Function*************************************************************
Synopsis [Computes the reduced set of flop variables.]
Description [Given is a single-output seq AIG manager and an assignment
of its CIs. Returned is a subset of flops that justifies the output.]
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Int2_ManRefineCube( Gia_Man_t * p, Vec_Int_t * vAssign, Vec_Int_t * vPrio )
{
Vec_Int_t * vSubset;
Gia_Obj_t * pObj;
int i;
// set values and prios
assert( Gia_ManRegNum(p) > 0 );
assert( Vec_IntSize(vAssign) == Vec_IntSize(vPrio) );
Gia_ManConst0(p)->fMark0 = 0;
Gia_ManConst0(p)->fMark1 = 0;
Gia_ManConst0(p)->Value = ABC_INFINITY;
Gia_ManForEachCi( p, pObj, i )
{
pObj->fMark0 = Vec_IntEntry(vAssign, i);
pObj->fMark1 = 0;
pObj->Value = Vec_IntEntry(vPrio, i);
}
Gia_ManForEachAnd( p, pObj, i )
{
pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
pObj->fMark1 = 0;
if ( pObj->fMark0 == 1 )
pObj->Value = Abc_MaxInt( Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
else if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 && (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj)) == 0 )
pObj->Value = Abc_MinInt( Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value ); // choice
else if ( (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) == 0 )
pObj->Value = Gia_ObjFanin0(pObj)->Value;
else
pObj->Value = Gia_ObjFanin1(pObj)->Value;
}
pObj = Gia_ManPo( p, 0 );
pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj));
pObj->fMark1 = 0;
pObj->Value = Gia_ObjFanin0(pObj)->Value;
assert( pObj->fMark0 == 1 );
assert( pObj->Value < ABC_INFINITY );
// select subset
vSubset = Vec_IntAlloc( 100 );
Int2_ManJustify_rec( p, Gia_ObjFanin0(pObj), vSubset );
return vSubset;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [int2Util.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Interpolation engine.]
Synopsis [Various utilities.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - Dec 1, 2013.]
Revision [$Id: int2Util.c,v 1.00 2013/12/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "int2Int.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Int2_ManComputeCoPres( Vec_Int_t * vSop, int nRegs )
{
Vec_Int_t * vCoPres, * vMap;
vCoPres = Vec_IntAlloc( 100 );
if ( vSop == NULL )
Vec_IntPush( vCoPres, 0 );
else
{
int i, k, Limit;
vMap = Vec_IntStart( nRegs );
Vec_IntForEachEntryStart( vSop, Limit, i, 1 )
{
for ( k = 0; k < Limit; k++ )
{
i++;
assert( Vec_IntEntry(vSop, i + k) < 2 * nRegs );
Vec_IntWriteEntry( vMap, Abc_Lit2Var(Vec_IntEntry(vSop, i + k)), 1 );
}
}
Vec_IntForEachEntry( vMap, Limit, i )
if ( Limit )
Vec_IntPush( vCoPres, i+1 );
Vec_IntFree( vMap );
}
return vCoPres;
}
void Int2_ManCollectInternal_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
{
if ( Gia_ObjIsTravIdCurrent(p, pObj) )
return;
Gia_ObjSetTravIdCurrent(p, pObj);
if ( Gia_ObjIsCi(pObj) )
return;
assert( Gia_ObjIsAnd(pObj) );
Int2_ManCollectInternal_rec( p, Gia_ObjFanin0(pObj), vNodes );
Int2_ManCollectInternal_rec( p, Gia_ObjFanin1(pObj), vNodes );
Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
}
Vec_Int_t * Int2_ManCollectInternal( Gia_Man_t * p, Vec_Int_t * vCoPres )
{
Vec_Int_t * vNodes;
Gia_Obj_t * pObj;
int i, Entry;
Gia_ManIncrementTravId( p );
Gia_ObjSetTravIdCurrent(p, Gia_ManConst0(p));
Gia_ManForEachCi( p, pObj, i )
Gia_ObjSetTravIdCurrent(p, pObj);
vNodes = Vec_IntAlloc( 1000 );
Vec_IntForEachEntry( vCoPres, Entry, i )
Int2_ManCollectInternal_rec( p, Gia_ObjFanin0(Gia_ManCo(p, Entry)), vNodes );
return vNodes;
}
Gia_Man_t * Int2_ManProbToGia( Gia_Man_t * p, Vec_Int_t * vSop )
{
Vec_Int_t * vCoPres, * vNodes;
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj;
int i, k, Entry, Limit;
int Lit, Cube, Sop;
assert( Gia_ManPoNum(p) == 1 );
// collect COs and ANDs
vCoPres = Int2_ManComputeCoPres( vSop, Gia_ManRegNum(p) );
vNodes = Int2_ManCollectInternal( p, vCoPres );
// create new manager
pNew = Gia_ManStart( Gia_ManObjNum(p) );
pNew->pName = Abc_UtilStrsav( p->pName );
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
Gia_ManConst0(p)->Value = 0;
Gia_ManForEachCi( p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
Gia_ManHashAlloc( pNew );
Gia_ManForEachObjVec( vNodes, p, pObj, i )
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
Vec_IntForEachEntry( vCoPres, Entry, i )
{
pObj = Gia_ManCo(p, Entry);
pObj->Value = Gia_ObjFanin0Copy( pObj );
}
// create additional cubes
Sop = 0;
Vec_IntForEachEntryStart( vSop, Limit, i, 1 )
{
Cube = 1;
for ( k = 0; k < Limit; k++ )
{
i++;
Lit = Vec_IntEntry( vSop, i + k );
pObj = Gia_ManRi( p, Abc_Lit2Var(Lit) );
Cube = Gia_ManHashAnd( pNew, Cube, Abc_LitNotCond(pObj->Value, Abc_LitIsCompl(Lit)) );
}
Sop = Gia_ManHashOr( pNew, Sop, Cube );
}
Gia_ManAppendCo( pNew, Sop );
Gia_ManHashStop( pNew );
// cleanup
pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManStop( pTemp );
return pNew;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
SRC += src/proof/int2/int2Bmc.c \
src/proof/int2/int2Core.c \
src/proof/int2/int2Refine.c \
src/proof/int2/int2Util.c
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment