Commit b65ae734 by Alan Mishchenko

Enabling multi-output solving in 'pdr'.

parent 79aa1f00
...@@ -22321,10 +22321,11 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22321,10 +22321,11 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
int c; int c;
Pdr_ManSetDefaultParams( pPars ); Pdr_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "OMFCRTrmsdgvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "MFCRTarmsdgvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
/*
case 'O': case 'O':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
...@@ -22336,6 +22337,7 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22336,6 +22337,7 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->iOutput < 0 ) if ( pPars->iOutput < 0 )
goto usage; goto usage;
break; break;
*/
case 'M': case 'M':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
...@@ -22391,6 +22393,9 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22391,6 +22393,9 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nTimeOut < 0 ) if ( pPars->nTimeOut < 0 )
goto usage; goto usage;
break; break;
case 'a':
pPars->fSolveAll ^= 1;
break;
case 'r': case 'r':
pPars->fTwoRounds ^= 1; pPars->fTwoRounds ^= 1;
break; break;
...@@ -22432,12 +22437,15 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22432,12 +22437,15 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n"); Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n");
return 0; return 0;
} }
/*
if ( pPars->iOutput != -1 && (pPars->iOutput < 0 || pPars->iOutput >= Abc_NtkPoNum(pNtk)) ) if ( pPars->iOutput != -1 && (pPars->iOutput < 0 || pPars->iOutput >= Abc_NtkPoNum(pNtk)) )
{ {
Abc_Print( -2, "Output index (%d) is incorrect (can be 0 through %d).\n", Abc_Print( -2, "Output index (%d) is incorrect (can be 0 through %d).\n",
pPars->iOutput, Abc_NtkPoNum(pNtk)-1 ); pPars->iOutput, Abc_NtkPoNum(pNtk)-1 );
return 0; return 0;
} }
*/
/*
if ( Abc_NtkPoNum(pNtk) != 1 && pPars->fVerbose ) if ( Abc_NtkPoNum(pNtk) != 1 && pPars->fVerbose )
{ {
if ( pPars->iOutput == -1 ) if ( pPars->iOutput == -1 )
...@@ -22446,6 +22454,7 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22446,6 +22454,7 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -2, "Working on the primary output with zero-based number %d (out of %d).\n", Abc_Print( -2, "Working on the primary output with zero-based number %d (out of %d).\n",
pPars->iOutput, Abc_NtkPoNum(pNtk) ); pPars->iOutput, Abc_NtkPoNum(pNtk) );
} }
*/
// run the procedure // run the procedure
pAbc->Status = Abc_NtkDarPdr( pNtk, pPars, &pCex ); pAbc->Status = Abc_NtkDarPdr( pNtk, pPars, &pCex );
pAbc->nFrames = pPars->iFrame; pAbc->nFrames = pPars->iFrame;
...@@ -22453,16 +22462,17 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22453,16 +22462,17 @@ int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: pdr [-OMFCRT<num] [-rmsdgvwh]\n" ); Abc_Print( -2, "usage: pdr [-MFCRT<num] [-armsdgvwh]\n" );
Abc_Print( -2, "\t model checking using property directed reachability (aka IC3)\n" ); Abc_Print( -2, "\t model checking using property directed reachability (aka IC3)\n" );
Abc_Print( -2, "\t pioneered by Aaron Bradley (http://ecee.colorado.edu/~bradleya/ic3/)\n" ); Abc_Print( -2, "\t pioneered by Aaron Bradley (http://ecee.colorado.edu/~bradleya/ic3/)\n" );
Abc_Print( -2, "\t with improvements by Niklas Een (http://een.se/niklas/)\n" ); Abc_Print( -2, "\t with improvements by Niklas Een (http://een.se/niklas/)\n" );
Abc_Print( -2, "\t-O num : the zero-based number of the primary output to solve [default = all]\n" ); // Abc_Print( -2, "\t-O num : the zero-based number of the primary output to solve [default = all]\n" );
Abc_Print( -2, "\t-M num : limit on unused vars to trigger SAT solver recycling [default = %d]\n", pPars->nRecycle ); Abc_Print( -2, "\t-M num : limit on unused vars to trigger SAT solver recycling [default = %d]\n", pPars->nRecycle );
Abc_Print( -2, "\t-F num : limit on timeframes explored to stop computation [default = %d]\n", pPars->nFrameMax ); Abc_Print( -2, "\t-F num : limit on timeframes explored to stop computation [default = %d]\n", pPars->nFrameMax );
Abc_Print( -2, "\t-C num : limit on conflicts in one SAT call (0 = no limit) [default = %d]\n", pPars->nConfLimit ); Abc_Print( -2, "\t-C num : limit on conflicts in one SAT call (0 = no limit) [default = %d]\n", pPars->nConfLimit );
Abc_Print( -2, "\t-R num : limit on proof obligations before a restart (0 = no limit) [default = %d]\n", pPars->nRestLimit ); Abc_Print( -2, "\t-R num : limit on proof obligations before a restart (0 = no limit) [default = %d]\n", pPars->nRestLimit );
Abc_Print( -2, "\t-T num : approximate timeout in seconds (0 = no limit) [default = %d]\n", pPars->nTimeOut ); Abc_Print( -2, "\t-T num : approximate timeout in seconds (0 = no limit) [default = %d]\n", pPars->nTimeOut );
Abc_Print( -2, "\t-a : toggle solving all outputs even if one of them is SAT [default = %s]\n", pPars->fSolveAll? "yes": "no" );
Abc_Print( -2, "\t-r : toggle using more effort in generalization [default = %s]\n", pPars->fTwoRounds? "yes": "no" ); Abc_Print( -2, "\t-r : toggle using more effort in generalization [default = %s]\n", pPars->fTwoRounds? "yes": "no" );
Abc_Print( -2, "\t-m : toggle using monolythic CNF computation [default = %s]\n", pPars->fMonoCnf? "yes": "no" ); Abc_Print( -2, "\t-m : toggle using monolythic CNF computation [default = %s]\n", pPars->fMonoCnf? "yes": "no" );
Abc_Print( -2, "\t-s : toggle creating only shortest counter-examples [default = %s]\n", pPars->fShortest? "yes": "no" ); Abc_Print( -2, "\t-s : toggle creating only shortest counter-examples [default = %s]\n", pPars->fShortest? "yes": "no" );
......
...@@ -2717,6 +2717,7 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex ) ...@@ -2717,6 +2717,7 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
Abc_Print( 1, "Converting network into AIG has failed.\n" ); Abc_Print( 1, "Converting network into AIG has failed.\n" );
return -1; return -1;
} }
/*
// perform ORing the primary outputs // perform ORing the primary outputs
if ( pPars->iOutput == -1 ) if ( pPars->iOutput == -1 )
{ {
...@@ -2728,6 +2729,9 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex ) ...@@ -2728,6 +2729,9 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
} }
else else
RetValue = Pdr_ManSolve( pMan, pPars, ppCex ); RetValue = Pdr_ManSolve( pMan, pPars, ppCex );
*/
RetValue = Pdr_ManSolve( pMan, pPars, ppCex );
// output the result // output the result
if ( !pPars->fSilent ) if ( !pPars->fSilent )
{ {
...@@ -2739,7 +2743,7 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex ) ...@@ -2739,7 +2743,7 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
Abc_Print( 1, "Property UNDECIDED. " ); Abc_Print( 1, "Property UNDECIDED. " );
else else
assert( 0 ); assert( 0 );
ABC_PRT( "Time", clock() - clk ); ABC_PRT( "Time", clock() - clk );
} }
if ( *ppCex && !Saig_ManVerifyCex( pMan, *ppCex ) ) if ( *ppCex && !Saig_ManVerifyCex( pMan, *ppCex ) )
......
...@@ -40,7 +40,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -40,7 +40,7 @@ ABC_NAMESPACE_HEADER_START
typedef struct Pdr_Par_t_ Pdr_Par_t; typedef struct Pdr_Par_t_ Pdr_Par_t;
struct Pdr_Par_t_ struct Pdr_Par_t_
{ {
int iOutput; // zero-based number of primary output to solve // int iOutput; // zero-based number of primary output to solve
int nRecycle; // limit on vars for recycling int nRecycle; // limit on vars for recycling
int nFrameMax; // limit on frame count int nFrameMax; // limit on frame count
int nConfLimit; // limit on SAT solver conflicts int nConfLimit; // limit on SAT solver conflicts
...@@ -54,6 +54,8 @@ struct Pdr_Par_t_ ...@@ -54,6 +54,8 @@ struct Pdr_Par_t_
int fVerbose; // verbose output` int fVerbose; // verbose output`
int fVeryVerbose; // very verbose output int fVeryVerbose; // very verbose output
int fSilent; // totally silent execution int fSilent; // totally silent execution
int fSolveAll; // do not stop when found a SAT output
int nFailOuts; // the number of failed outputs
int iFrame; // explored up to this frame int iFrame; // explored up to this frame
int RunId; // PDR id in this run int RunId; // PDR id in this run
int(*pFuncStop)(int); // callback to terminate int(*pFuncStop)(int); // callback to terminate
......
...@@ -76,6 +76,8 @@ struct Pdr_Man_t_ ...@@ -76,6 +76,8 @@ struct Pdr_Man_t_
Vec_Int_t** pvId2Vars; // for each used ObjId, maps frame into SAT var Vec_Int_t** pvId2Vars; // for each used ObjId, maps frame into SAT var
Vec_Ptr_t * vVar2Ids; // for each used frame, maps SAT var into ObjId Vec_Ptr_t * vVar2Ids; // for each used frame, maps SAT var into ObjId
// data representation // data representation
int iOutCur; // current output
Vec_Ptr_t * vCexes; // counter-examples for each output
Vec_Ptr_t * vSolvers; // SAT solvers Vec_Ptr_t * vSolvers; // SAT solvers
Vec_Vec_t * vClauses; // clauses by timeframe Vec_Vec_t * vClauses; // clauses by timeframe
Pdr_Obl_t * pQueue; // proof obligations Pdr_Obl_t * pQueue; // proof obligations
......
...@@ -144,6 +144,8 @@ void Pdr_ManStop( Pdr_Man_t * p ) ...@@ -144,6 +144,8 @@ void Pdr_ManStop( Pdr_Man_t * p )
Vec_IntFree( p->vRes ); // final result Vec_IntFree( p->vRes ); // final result
Vec_IntFree( p->vSuppLits ); // support literals Vec_IntFree( p->vSuppLits ); // support literals
ABC_FREE( p->pCubeJust ); ABC_FREE( p->pCubeJust );
if ( p->vCexes )
Vec_PtrFreeFree( p->vCexes );
// additional AIG data-members // additional AIG data-members
if ( p->pAig->pFanData != NULL ) if ( p->pAig->pFanData != NULL )
Aig_ManFanoutStop( p->pAig ); Aig_ManFanoutStop( p->pAig );
...@@ -173,7 +175,8 @@ Abc_Cex_t * Pdr_ManDeriveCex( Pdr_Man_t * p ) ...@@ -173,7 +175,8 @@ Abc_Cex_t * Pdr_ManDeriveCex( Pdr_Man_t * p )
nFrames++; nFrames++;
// create the counter-example // create the counter-example
pCex = Abc_CexAlloc( Aig_ManRegNum(p->pAig), Saig_ManPiNum(p->pAig), nFrames ); pCex = Abc_CexAlloc( Aig_ManRegNum(p->pAig), Saig_ManPiNum(p->pAig), nFrames );
pCex->iPo = (p->pPars->iOutput==-1)? 0 : p->pPars->iOutput; // pCex->iPo = (p->pPars->iOutput==-1)? 0 : p->pPars->iOutput;
pCex->iPo = p->iOutCur;
pCex->iFrame = nFrames-1; pCex->iFrame = nFrames-1;
for ( pObl = p->pQueue, f = 0; pObl; pObl = pObl->pNext, f++ ) for ( pObl = p->pQueue, f = 0; pObl; pObl = pObl->pNext, f++ )
for ( i = pObl->pState->nLits; i < pObl->pState->nTotal; i++ ) for ( i = pObl->pState->nLits; i < pObl->pState->nTotal; i++ )
......
...@@ -45,6 +45,8 @@ ABC_NAMESPACE_IMPL_START ...@@ -45,6 +45,8 @@ ABC_NAMESPACE_IMPL_START
sat_solver * Pdr_ManCreateSolver( Pdr_Man_t * p, int k ) sat_solver * Pdr_ManCreateSolver( Pdr_Man_t * p, int k )
{ {
sat_solver * pSat; sat_solver * pSat;
Aig_Obj_t * pObj;
int i;
assert( Vec_PtrSize(p->vSolvers) == k ); assert( Vec_PtrSize(p->vSolvers) == k );
assert( Vec_VecSize(p->vClauses) == k ); assert( Vec_VecSize(p->vClauses) == k );
assert( Vec_IntSize(p->vActVars) == k ); assert( Vec_IntSize(p->vActVars) == k );
...@@ -55,7 +57,9 @@ sat_solver * Pdr_ManCreateSolver( Pdr_Man_t * p, int k ) ...@@ -55,7 +57,9 @@ sat_solver * Pdr_ManCreateSolver( Pdr_Man_t * p, int k )
Vec_VecExpand( p->vClauses, k ); Vec_VecExpand( p->vClauses, k );
Vec_IntPush( p->vActVars, 0 ); Vec_IntPush( p->vActVars, 0 );
// add property cone // add property cone
Pdr_ObjSatVar( p, k, Aig_ManCo(p->pAig, (p->pPars->iOutput==-1)?0:p->pPars->iOutput ) ); // Pdr_ObjSatVar( p, k, Aig_ManCo(p->pAig, (p->pPars->iOutput==-1)?0:p->pPars->iOutput ) );
Saig_ManForEachPo( p->pAig, pObj, i )
Pdr_ObjSatVar( p, k, pObj );
return pSat; return pSat;
} }
...@@ -173,11 +177,15 @@ Vec_Int_t * Pdr_ManCubeToLits( Pdr_Man_t * p, int k, Pdr_Set_t * pCube, int fCom ...@@ -173,11 +177,15 @@ Vec_Int_t * Pdr_ManCubeToLits( Pdr_Man_t * p, int k, Pdr_Set_t * pCube, int fCom
void Pdr_ManSetPropertyOutput( Pdr_Man_t * p, int k ) void Pdr_ManSetPropertyOutput( Pdr_Man_t * p, int k )
{ {
sat_solver * pSat; sat_solver * pSat;
int Lit, RetValue; Aig_Obj_t * pObj;
int Lit, RetValue, i;
pSat = Pdr_ManSolver(p, k); pSat = Pdr_ManSolver(p, k);
Lit = toLitCond( Pdr_ObjSatVar(p, k, Aig_ManCo(p->pAig, (p->pPars->iOutput==-1)?0:p->pPars->iOutput)), 1 ); // neg literal Saig_ManForEachPo( p->pAig, pObj, i )
RetValue = sat_solver_addclause( pSat, &Lit, &Lit + 1 ); {
assert( RetValue == 1 ); Lit = toLitCond( Pdr_ObjSatVar(p, k, pObj), 1 ); // neg literal
RetValue = sat_solver_addclause( pSat, &Lit, &Lit + 1 );
assert( RetValue == 1 );
}
sat_solver_compress( pSat ); sat_solver_compress( pSat );
} }
...@@ -279,7 +287,7 @@ int Pdr_ManCheckCube( Pdr_Man_t * p, int k, Pdr_Set_t * pCube, Pdr_Set_t ** ppPr ...@@ -279,7 +287,7 @@ int Pdr_ManCheckCube( Pdr_Man_t * p, int k, Pdr_Set_t * pCube, Pdr_Set_t ** ppPr
if ( pCube == NULL ) // solve the property if ( pCube == NULL ) // solve the property
{ {
clk = clock(); clk = clock();
Lit = toLit( Pdr_ObjSatVar(p, k, Aig_ManCo(p->pAig, (p->pPars->iOutput==-1)?0:p->pPars->iOutput)) ); // pos literal (property fails) Lit = toLit( Pdr_ObjSatVar(p, k, Aig_ManCo(p->pAig, p->iOutCur)) ); // pos literal (property fails)
RetValue = sat_solver_solve( pSat, &Lit, &Lit + 1, nConfLimit, 0, 0, 0 ); RetValue = sat_solver_solve( pSat, &Lit, &Lit + 1, nConfLimit, 0, 0, 0 );
if ( RetValue == l_Undef ) if ( RetValue == l_Undef )
return -1; return -1;
......
...@@ -368,7 +368,10 @@ Pdr_Set_t * Pdr_ManTernarySim( Pdr_Man_t * p, int k, Pdr_Set_t * pCube ) ...@@ -368,7 +368,10 @@ Pdr_Set_t * Pdr_ManTernarySim( Pdr_Man_t * p, int k, Pdr_Set_t * pCube )
// collect CO objects // collect CO objects
Vec_IntClear( vCoObjs ); Vec_IntClear( vCoObjs );
if ( pCube == NULL ) // the target is the property output if ( pCube == NULL ) // the target is the property output
Vec_IntPush( vCoObjs, Aig_ObjId(Aig_ManCo(p->pAig, (p->pPars->iOutput==-1)?0:p->pPars->iOutput)) ); {
// Vec_IntPush( vCoObjs, Aig_ObjId(Aig_ManCo(p->pAig, (p->pPars->iOutput==-1)?0:p->pPars->iOutput)) );
Vec_IntPush( vCoObjs, Aig_ObjId(Aig_ManCo(p->pAig, p->iOutCur)) );
}
else // the target is the cube else // the target is the cube
{ {
for ( i = 0; i < pCube->nLits; i++ ) for ( i = 0; i < pCube->nLits; i++ )
......
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