Beispiel #1
0
/**Function*************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_NtkMfsNode( Mfs_Man_t * p, Abc_Obj_t * pNode )
{
    Hop_Obj_t * pObj;
    int RetValue;
    float dProb;
    extern Hop_Obj_t * Abc_NodeIfNodeResyn( Bdc_Man_t * p, Hop_Man_t * pHop, Hop_Obj_t * pRoot, int nVars, Vec_Int_t * vTruth, unsigned * puCare, float dProb );

    int nGain;
    abctime clk;
    p->nNodesTried++;
    // prepare data structure for this node
    Mfs_ManClean( p );
    // compute window roots, window support, and window nodes
clk = Abc_Clock();
    p->vRoots = Abc_MfsComputeRoots( pNode, p->pPars->nWinTfoLevs, p->pPars->nFanoutsMax );
    p->vSupp  = Abc_NtkNodeSupport( p->pNtk, (Abc_Obj_t **)Vec_PtrArray(p->vRoots), Vec_PtrSize(p->vRoots) );
    p->vNodes = Abc_NtkDfsNodes( p->pNtk, (Abc_Obj_t **)Vec_PtrArray(p->vRoots), Vec_PtrSize(p->vRoots) );
p->timeWin += Abc_Clock() - clk;
    // count the number of patterns
//    p->dTotalRatios += Abc_NtkConstraintRatio( p, pNode );
    // construct AIG for the window
clk = Abc_Clock();
    p->pAigWin = Abc_NtkConstructAig( p, pNode );
p->timeAig += Abc_Clock() - clk;
    // translate it into CNF
clk = Abc_Clock();
    p->pCnf = Cnf_DeriveSimple( p->pAigWin, Abc_ObjFaninNum(pNode) );
p->timeCnf += Abc_Clock() - clk;
    // create the SAT problem
clk = Abc_Clock();
    p->pSat = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
    if ( p->pSat && p->pPars->fOneHotness )
        Abc_NtkAddOneHotness( p );
    if ( p->pSat == NULL )
        return 0;
    // solve the SAT problem
    RetValue = Abc_NtkMfsSolveSat( p, pNode );
    p->nTotConfLevel += p->pSat->stats.conflicts;
p->timeSat += Abc_Clock() - clk;
    if ( RetValue == 0 )
    {
        p->nTimeOutsLevel++;
        p->nTimeOuts++;
        return 0;
    }
    // minimize the local function of the node using bi-decomposition
    assert( p->nFanins == Abc_ObjFaninNum(pNode) );
    dProb = p->pPars->fPower? ((float *)p->vProbs->pArray)[pNode->Id] : -1.0;
    pObj = Abc_NodeIfNodeResyn( p->pManDec, (Hop_Man_t *)pNode->pNtk->pManFunc, (Hop_Obj_t *)pNode->pData, p->nFanins, p->vTruth, p->uCare, dProb );
    nGain = Hop_DagSize((Hop_Obj_t *)pNode->pData) - Hop_DagSize(pObj);
    if ( nGain >= 0 )
    {
        p->nNodesDec++;
        p->nNodesGained += nGain;
        p->nNodesGainedLevel += nGain;
        pNode->pData = pObj;
    }
    return 1;
}
Beispiel #2
0
/**Function*************************************************************

  Synopsis    []

  Description []

  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_NtkMfsResub( Mfs_Man_t * p, Abc_Obj_t * pNode )
{
    abctime clk;
    p->nNodesTried++;
    // prepare data structure for this node
    Mfs_ManClean( p );
    // compute window roots, window support, and window nodes
clk = Abc_Clock();
    p->vRoots = Abc_MfsComputeRoots( pNode, p->pPars->nWinTfoLevs, p->pPars->nFanoutsMax );
    p->vSupp  = Abc_NtkNodeSupport( p->pNtk, (Abc_Obj_t **)Vec_PtrArray(p->vRoots), Vec_PtrSize(p->vRoots) );
    p->vNodes = Abc_NtkDfsNodes( p->pNtk, (Abc_Obj_t **)Vec_PtrArray(p->vRoots), Vec_PtrSize(p->vRoots) );
p->timeWin += Abc_Clock() - clk;
    if ( p->pPars->nWinMax && Vec_PtrSize(p->vNodes) > p->pPars->nWinMax )
    {
        p->nMaxDivs++;
        return 1;
    }
    // compute the divisors of the window
clk = Abc_Clock();
    p->vDivs  = Abc_MfsComputeDivisors( p, pNode, Abc_ObjRequiredLevel(pNode) - 1 );
    p->nTotalDivs += Vec_PtrSize(p->vDivs) - Abc_ObjFaninNum(pNode);
p->timeDiv += Abc_Clock() - clk;
    // construct AIG for the window
clk = Abc_Clock();
    p->pAigWin = Abc_NtkConstructAig( p, pNode );
p->timeAig += Abc_Clock() - clk;
    // translate it into CNF
clk = Abc_Clock();
    p->pCnf = Cnf_DeriveSimple( p->pAigWin, 1 + Vec_PtrSize(p->vDivs) );
p->timeCnf += Abc_Clock() - clk;
    // create the SAT problem
clk = Abc_Clock();
    p->pSat = Abc_MfsCreateSolverResub( p, NULL, 0, 0 );
    if ( p->pSat == NULL )
    {
        p->nNodesBad++;
        return 1;
    }
//clk = Abc_Clock();
//    if ( p->pPars->fGiaSat )
//        Abc_NtkMfsConstructGia( p );
//p->timeGia += Abc_Clock() - clk;
    // solve the SAT problem
    if ( p->pPars->fPower )
        Abc_NtkMfsEdgePower( p, pNode );
    else if ( p->pPars->fSwapEdge )
        Abc_NtkMfsEdgeSwapEval( p, pNode );
    else
    {
        Abc_NtkMfsResubNode( p, pNode );
        if ( p->pPars->fMoreEffort )
            Abc_NtkMfsResubNode2( p, pNode );
    }
p->timeSat += Abc_Clock() - clk;
//    if ( p->pPars->fGiaSat )
//        Abc_NtkMfsDeconstructGia( p );
    return 1;
}
Beispiel #3
0
/**Function*************************************************************

  Synopsis    [Takes the AIG with the single output to be checked.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Cla_Man_t * Fra_ClauStart( Aig_Man_t * pMan )
{
    Cla_Man_t * p;
    Cnf_Dat_t * pCnfMain;
    Cnf_Dat_t * pCnfTest;
    Cnf_Dat_t * pCnfBmc;
    Aig_Man_t * pFramesMain;
    Aig_Man_t * pFramesTest;
    Aig_Man_t * pFramesBmc;
    assert( Aig_ManCoNum(pMan) - Aig_ManRegNum(pMan) == 1 );

    // start the manager
    p = ABC_ALLOC( Cla_Man_t, 1 );
    memset( p, 0, sizeof(Cla_Man_t) );
    p->vCexMain0 = Vec_IntAlloc( Aig_ManRegNum(pMan) );
    p->vCexMain  = Vec_IntAlloc( Aig_ManRegNum(pMan) );
    p->vCexTest  = Vec_IntAlloc( Aig_ManRegNum(pMan) );
    p->vCexBase  = Vec_IntAlloc( Aig_ManRegNum(pMan) );
    p->vCexAssm  = Vec_IntAlloc( Aig_ManRegNum(pMan) );
    p->vCexBmc   = Vec_IntAlloc( Aig_ManRegNum(pMan) );

    // derive two timeframes to be checked
    pFramesMain = Aig_ManFrames( pMan, 2, 0, 1, 0, 0, NULL ); // nFrames, fInit, fOuts, fRegs
//Aig_ManShow( pFramesMain, 0, NULL );
    assert( Aig_ManCoNum(pFramesMain) == 2 );
    Aig_ObjChild0Flip( Aig_ManCo(pFramesMain, 0) ); // complement the first output
    pCnfMain = Cnf_DeriveSimple( pFramesMain, 0 );
//Cnf_DataWriteIntoFile( pCnfMain, "temp.cnf", 1 );
    p->pSatMain = (sat_solver *)Cnf_DataWriteIntoSolver( pCnfMain, 1, 0 );
/*
    {
        int i;
        Aig_Obj_t * pObj;
        Aig_ManForEachObj( pFramesMain, pObj, i )
            printf( "%d -> %d  \n", pObj->Id, pCnfMain->pVarNums[pObj->Id] );
        printf( "\n" );
    }
*/

    // derive one timeframe to be checked
    pFramesTest = Aig_ManFrames( pMan, 1, 0, 0, 1, 0, NULL );
    assert( Aig_ManCoNum(pFramesTest) == Aig_ManRegNum(pMan) );
    pCnfTest = Cnf_DeriveSimple( pFramesTest, Aig_ManRegNum(pMan) );
    p->pSatTest = (sat_solver *)Cnf_DataWriteIntoSolver( pCnfTest, 1, 0 );
    p->nSatVarsTestBeg = p->nSatVarsTestCur = sat_solver_nvars( p->pSatTest );

    // derive one timeframe to be checked for BMC
    pFramesBmc = Aig_ManFrames( pMan, 1, 1, 0, 1, 0, NULL );
//Aig_ManShow( pFramesBmc, 0, NULL );
    assert( Aig_ManCoNum(pFramesBmc) == Aig_ManRegNum(pMan) );
    pCnfBmc = Cnf_DeriveSimple( pFramesBmc, Aig_ManRegNum(pMan) );
    p->pSatBmc = (sat_solver *)Cnf_DataWriteIntoSolver( pCnfBmc, 1, 0 );

    // create variable sets
    p->vSatVarsMainCs = Fra_ClauSaveInputVars( pFramesMain, pCnfMain, 2 * (Aig_ManCiNum(pMan)-Aig_ManRegNum(pMan)) );
    p->vSatVarsTestCs = Fra_ClauSaveLatchVars( pFramesTest, pCnfTest, 1 );
    p->vSatVarsTestNs = Fra_ClauSaveLatchVars( pFramesTest, pCnfTest, 0 );
    p->vSatVarsBmcNs  = Fra_ClauSaveOutputVars( pFramesBmc, pCnfBmc );
    assert( Vec_IntSize(p->vSatVarsTestCs) == Vec_IntSize(p->vSatVarsMainCs) );
    assert( Vec_IntSize(p->vSatVarsTestCs) == Vec_IntSize(p->vSatVarsBmcNs) );

    // create mapping of CS into NS vars
    p->pMapCsMainToCsTest = Fra_ClauCreateMapping( p->vSatVarsMainCs, p->vSatVarsTestCs, Aig_ManObjNumMax(pFramesMain) );
    p->pMapCsTestToCsMain = Fra_ClauCreateMapping( p->vSatVarsTestCs, p->vSatVarsMainCs, Aig_ManObjNumMax(pFramesTest) );
    p->pMapCsTestToNsTest = Fra_ClauCreateMapping( p->vSatVarsTestCs, p->vSatVarsTestNs, Aig_ManObjNumMax(pFramesTest) );
    p->pMapCsTestToNsBmc  = Fra_ClauCreateMapping( p->vSatVarsTestCs, p->vSatVarsBmcNs,  Aig_ManObjNumMax(pFramesTest) );

    // cleanup
    Cnf_DataFree( pCnfMain );
    Cnf_DataFree( pCnfTest );
    Cnf_DataFree( pCnfBmc );
    Aig_ManStop( pFramesMain );
    Aig_ManStop( pFramesTest );
    Aig_ManStop( pFramesBmc );
    if ( p->pSatMain == NULL || p->pSatTest == NULL || p->pSatBmc == NULL )
    {
        Fra_ClauStop( p );
        return NULL;
    }
    return p;
}
Beispiel #4
0
void ToCNFAIG::toCNF(const BBNodeAIG& top, Cnf_Dat_t*& cnfData,
		ToSATBase::ASTNodeToSATVar& nodeToVar,
		bool needAbsRef, BBNodeManagerAIG& mgr) {
	assert(cnfData == NULL);

	Aig_ObjCreatePo(mgr.aigMgr, top.n);
	if (!needAbsRef) {
		Aig_ManCleanup( mgr.aigMgr); // remove nodes not connected to the PO.
	}
	Aig_ManCheck( mgr.aigMgr); // check that AIG looks ok.

	assert(Aig_ManPoNum(mgr.aigMgr) == 1);

	// UseZeroes gives assertion errors.
	// Rewriting is sometimes very slow. Can it be configured to be faster?
	// What about refactoring???

	int nodeCount = mgr.aigMgr->nObjs[AIG_OBJ_AND];
	if (uf.stats_flag)
		cerr << "Nodes before AIG rewrite:" << nodeCount << endl;

	if (!needAbsRef && uf.isSet("aig-rewrite","0")) {
		Dar_LibStart();
		Aig_Man_t * pTemp;
		Dar_RwrPar_t Pars, *pPars = &Pars;
		Dar_ManDefaultRwrParams(pPars);

		// Assertion errors occur with this enabled.
		// pPars->fUseZeros = 1;

		// For mul63bit.smt2 with iterations =3 & nCutsMax = 8
		// CNF generation was taking 139 seconds, solving 10 seconds.

		// With nCutsMax =2, CNF generation takes 16 seconds, solving 10 seconds.
		// The rewriting doesn't remove as many nodes of course..
		int iterations = 3;

		for (int i = 0; i < iterations; i++) {
			mgr.aigMgr = Aig_ManDup(pTemp = mgr.aigMgr, 0);
			Aig_ManStop(pTemp);
			Dar_ManRewrite(mgr.aigMgr, pPars);

			mgr.aigMgr = Aig_ManDup(pTemp = mgr.aigMgr, 0);
			Aig_ManStop(pTemp);

			if (uf.stats_flag)
				cerr << "After rewrite [" << i << "]  nodes:"
						<< mgr.aigMgr->nObjs[AIG_OBJ_AND] << endl;

			if (nodeCount == mgr.aigMgr->nObjs[AIG_OBJ_AND])
				break;

		}
	}
	if (!uf.isSet("simple-cnf","0")) {
		cnfData = Cnf_Derive(mgr.aigMgr, 0);
		if (uf.stats_flag)
		  cerr << "advanced CNF" << endl;
	} else {
		cnfData = Cnf_DeriveSimple(mgr.aigMgr, 0);
                if (uf.stats_flag)
                	cerr << "simple CNF" << endl;

	}

	BBNodeManagerAIG::SymbolToBBNode::const_iterator it;

	assert(nodeToVar.size() == 0);

	//todo. cf. with addvariables above...
	// Each symbol maps to a vector of CNF variables.
	for (it = mgr.symbolToBBNode.begin(); it != mgr.symbolToBBNode.end(); it++) {
		const ASTNode& n = it->first;
		const vector<BBNodeAIG> &b = it->second;
		assert(nodeToVar.find(n) == nodeToVar.end());

		const int width = (n.GetType() == BOOLEAN_TYPE) ? 1 : n.GetValueWidth();

		// INT_MAX for parts of symbols that didn't get encoded.
		vector<unsigned> v(width, ~((unsigned) 0));

		for (unsigned i = 0; i < b.size(); i++) {
			if (!b[i].IsNull()) {
				Aig_Obj_t * pObj;
				pObj = (Aig_Obj_t*) Vec_PtrEntry(mgr.aigMgr->vPis,
						b[i].symbol_index);
				v[i] = cnfData->pVarNums[pObj->Id];
			}
		}

		nodeToVar.insert(make_pair(n, v));
	}
	assert(cnfData != NULL);
}
/**Function*************************************************************

  Synopsis    [Interplates while the number of conflicts is not exceeded.]

  Description [Returns 1 if proven. 0 if failed. -1 if undecided.]
               
  SideEffects [Does not check the property in 0-th frame.]

  SeeAlso     []

***********************************************************************/
int Inter_ManPerformInterpolation( Aig_Man_t * pAig, Inter_ManParams_t * pPars, int * piFrame )
{
    extern int Inter_ManCheckInductiveContainment( Aig_Man_t * pTrans, Aig_Man_t * pInter, int nSteps, int fBackward );
    Inter_Man_t * p;
    Inter_Check_t * pCheck = NULL;
    Aig_Man_t * pAigTemp;
    int s, i, RetValue, Status;
    abctime clk, clk2, clkTotal = Abc_Clock(), timeTemp = 0;
    abctime nTimeNewOut = pPars->nSecLimit ? pPars->nSecLimit * CLOCKS_PER_SEC + Abc_Clock() : 0;

    // enable ORing of the interpolants, if containment check is performed inductively with K > 1
    if ( pPars->nFramesK > 1 )
        pPars->fTransLoop = 1;

    // sanity checks
    assert( Saig_ManRegNum(pAig) > 0 );
    assert( Saig_ManPiNum(pAig) > 0 );
    assert( Saig_ManPoNum(pAig)-Saig_ManConstrNum(pAig) == 1 );
    if ( pPars->fVerbose && Saig_ManConstrNum(pAig) )
        printf( "Performing interpolation with %d constraints...\n", Saig_ManConstrNum(pAig) );

    if ( Inter_ManCheckInitialState(pAig) )
    {
        *piFrame = -1;
        printf( "Property trivially fails in the initial state.\n" );
        return 0;
    }
/*
    if ( Inter_ManCheckAllStates(pAig) )
    {
        printf( "Property trivially holds in all states.\n" );
        return 1;
    }
*/
    // create interpolation manager
    // can perform SAT sweeping and/or rewriting of this AIG...
    p = Inter_ManCreate( pAig, pPars );
    if ( pPars->fTransLoop )
        p->pAigTrans = Inter_ManStartOneOutput( pAig, 0 );
    else
        p->pAigTrans = Inter_ManStartDuplicated( pAig );
    // derive CNF for the transformed AIG
clk = Abc_Clock();
    p->pCnfAig = Cnf_Derive( p->pAigTrans, Aig_ManRegNum(p->pAigTrans) ); 
p->timeCnf += Abc_Clock() - clk;    
    if ( pPars->fVerbose )
    { 
        printf( "AIG: PI/PO/Reg = %d/%d/%d. And = %d. Lev = %d.  CNF: Var/Cla = %d/%d.\n",
            Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig), 
            Aig_ManAndNum(pAig), Aig_ManLevelNum(pAig),
            p->pCnfAig->nVars, p->pCnfAig->nClauses );
    }
 
    // derive interpolant
    *piFrame = -1;
    p->nFrames = 1;
    for ( s = 0; ; s++ )
    {
        Cnf_Dat_t * pCnfInter2;

clk2 = Abc_Clock();
        // initial state
        if ( pPars->fUseBackward )
            p->pInter = Inter_ManStartOneOutput( pAig, 1 );
        else
            p->pInter = Inter_ManStartInitState( Aig_ManRegNum(pAig) );
        assert( Aig_ManCoNum(p->pInter) == 1 );
clk = Abc_Clock();
        p->pCnfInter = Cnf_Derive( p->pInter, 0 );  
p->timeCnf += Abc_Clock() - clk;    
        // timeframes
        p->pFrames = Inter_ManFramesInter( pAig, p->nFrames, pPars->fUseBackward, pPars->fUseTwoFrames );
clk = Abc_Clock();
        if ( pPars->fRewrite )
        {
            p->pFrames = Dar_ManRwsat( pAigTemp = p->pFrames, 1, 0 );
            Aig_ManStop( pAigTemp );
//        p->pFrames = Fra_FraigEquivence( pAigTemp = p->pFrames, 100, 0 );
//        Aig_ManStop( pAigTemp );
        }
p->timeRwr += Abc_Clock() - clk;
        // can also do SAT sweeping on the timeframes...
clk = Abc_Clock();
        if ( pPars->fUseBackward )
            p->pCnfFrames = Cnf_Derive( p->pFrames, Aig_ManCoNum(p->pFrames) );  
        else
//            p->pCnfFrames = Cnf_Derive( p->pFrames, 0 );  
            p->pCnfFrames = Cnf_DeriveSimple( p->pFrames, 0 );  
p->timeCnf += Abc_Clock() - clk;    
        // report statistics
        if ( pPars->fVerbose )
        {
            printf( "Step = %2d. Frames = 1 + %d. And = %5d. Lev = %5d.  ", 
                s+1, p->nFrames, Aig_ManNodeNum(p->pFrames), Aig_ManLevelNum(p->pFrames) );
            ABC_PRT( "Time", Abc_Clock() - clk2 );
        }


        //////////////////////////////////////////
        // start containment checking
        if ( !(pPars->fTransLoop || pPars->fUseBackward || pPars->nFramesK > 1) )
        {
            pCheck = Inter_CheckStart( p->pAigTrans, pPars->nFramesK );
            // try new containment check for the initial state
clk = Abc_Clock();
            pCnfInter2 = Cnf_Derive( p->pInter, 1 );  
p->timeCnf += Abc_Clock() - clk;    
clk = Abc_Clock();
            RetValue = Inter_CheckPerform( pCheck, pCnfInter2, nTimeNewOut );
p->timeEqu += Abc_Clock() - clk;
//            assert( RetValue == 0 );
            Cnf_DataFree( pCnfInter2 );
            if ( p->vInters )
                Vec_PtrPush( p->vInters, Aig_ManDupSimple(p->pInter) );
        }
        //////////////////////////////////////////

        // iterate the interpolation procedure
        for ( i = 0; ; i++ )
        {
            if ( pPars->nFramesMax && p->nFrames + i >= pPars->nFramesMax )
            { 
                if ( pPars->fVerbose )
                    printf( "Reached limit (%d) on the number of timeframes.\n", pPars->nFramesMax );
                p->timeTotal = Abc_Clock() - clkTotal;
                Inter_ManStop( p, 0 );
                Inter_CheckStop( pCheck );
                return -1;
            }

            // perform interpolation
            clk = Abc_Clock();
#ifdef ABC_USE_LIBRARIES
            if ( pPars->fUseMiniSat )
            {
                assert( !pPars->fUseBackward );
                RetValue = Inter_ManPerformOneStepM114p( p, pPars->fUsePudlak, pPars->fUseOther );
            }
            else 
#endif
                RetValue = Inter_ManPerformOneStep( p, pPars->fUseBias, pPars->fUseBackward, nTimeNewOut );

            if ( pPars->fVerbose )
            {
                printf( "   I = %2d. Bmc =%3d. IntAnd =%6d. IntLev =%5d. Conf =%6d.  ", 
                    i+1, i + 1 + p->nFrames, Aig_ManNodeNum(p->pInter), Aig_ManLevelNum(p->pInter), p->nConfCur );
                ABC_PRT( "Time", Abc_Clock() - clk );
            }
            // remember the number of timeframes completed
            pPars->iFrameMax = i - 1 + p->nFrames;
            if ( RetValue == 0 ) // found a (spurious?) counter-example
            {
                if ( i == 0 ) // real counterexample
                {
                    if ( pPars->fVerbose )
                        printf( "Found a real counterexample in frame %d.\n", p->nFrames );
                    p->timeTotal = Abc_Clock() - clkTotal;
                    *piFrame = p->nFrames;
//                    pAig->pSeqModel = (Abc_Cex_t *)Inter_ManGetCounterExample( pAig, p->nFrames+1, pPars->fVerbose );
                    {
                        int RetValue;
                        Saig_ParBmc_t ParsBmc, * pParsBmc = &ParsBmc;
                        Saig_ParBmcSetDefaultParams( pParsBmc );
                        pParsBmc->nConfLimit = 100000000;
                        pParsBmc->nStart     = p->nFrames;
                        pParsBmc->fVerbose   = pPars->fVerbose;
                        RetValue = Saig_ManBmcScalable( pAig, pParsBmc );
                        if ( RetValue == 1 )
                            printf( "Error: The problem should be SAT but it is UNSAT.\n" );
                        else if ( RetValue == -1 )
                            printf( "Error: The problem timed out.\n" );
                    }
                    Inter_ManStop( p, 0 );
                    Inter_CheckStop( pCheck );
                    return 0;
                }
                // likely spurious counter-example
                p->nFrames += i;
                Inter_ManClean( p ); 
                break;
            }
            else if ( RetValue == -1 ) 
            {
                if ( pPars->nSecLimit && Abc_Clock() > nTimeNewOut ) // timed out
                {
                    if ( pPars->fVerbose )
                        printf( "Reached timeout (%d seconds).\n",  pPars->nSecLimit );
                }
                else
                {
                    assert( p->nConfCur >= p->nConfLimit );
                    if ( pPars->fVerbose )
                        printf( "Reached limit (%d) on the number of conflicts.\n", p->nConfLimit );
                }
                p->timeTotal = Abc_Clock() - clkTotal;
                Inter_ManStop( p, 0 );
                Inter_CheckStop( pCheck );
                return -1;
            }
            assert( RetValue == 1 ); // found new interpolant
            // compress the interpolant
clk = Abc_Clock();
            if ( p->pInterNew )
            {
                // save the timeout value
                p->pInterNew->Time2Quit = nTimeNewOut;
//                Ioa_WriteAiger( p->pInterNew, "interpol.aig", 0, 0 );
                p->pInterNew = Dar_ManRwsat( pAigTemp = p->pInterNew, 1, 0 );
//                p->pInterNew = Dar_ManRwsat( pAigTemp = p->pInterNew, 0, 0 );
                Aig_ManStop( pAigTemp );
                if ( p->pInterNew == NULL )
                {
                    printf( "Reached timeout (%d seconds) during rewriting.\n",  pPars->nSecLimit );
                    p->timeTotal = Abc_Clock() - clkTotal;
                    Inter_ManStop( p, 1 );
                    Inter_CheckStop( pCheck );
                    return -1;
                }
            }
p->timeRwr += Abc_Clock() - clk;

            // check if interpolant is trivial
            if ( p->pInterNew == NULL || Aig_ObjChild0(Aig_ManCo(p->pInterNew,0)) == Aig_ManConst0(p->pInterNew) )
            { 
//                printf( "interpolant is constant 0\n" );
                if ( pPars->fVerbose )
                    printf( "The problem is trivially true for all states.\n" );
                p->timeTotal = Abc_Clock() - clkTotal;
                Inter_ManStop( p, 1 );
                Inter_CheckStop( pCheck );
                return 1;
            }

            // check containment of interpolants
clk = Abc_Clock();
            if ( pPars->fCheckKstep ) // k-step unique-state induction
            {
                if ( Aig_ManCiNum(p->pInterNew) == Aig_ManCiNum(p->pInter) )
                {
                    if ( pPars->fTransLoop || pPars->fUseBackward || pPars->nFramesK > 1 )
                    {
clk2 = Abc_Clock();
                        Status = Inter_ManCheckInductiveContainment( p->pAigTrans, p->pInterNew, Abc_MinInt(i + 1, pPars->nFramesK), pPars->fUseBackward );
timeTemp = Abc_Clock() - clk2;
                    }
                    else
                    {   // new containment check
clk2 = Abc_Clock();
                        pCnfInter2 = Cnf_Derive( p->pInterNew, 1 );  
p->timeCnf += Abc_Clock() - clk2;
timeTemp = Abc_Clock() - clk2;
            
                        Status = Inter_CheckPerform( pCheck, pCnfInter2, nTimeNewOut );
                        Cnf_DataFree( pCnfInter2 );
                        if ( p->vInters )
                            Vec_PtrPush( p->vInters, Aig_ManDupSimple(p->pInterNew) );
                    }
                }
                else
                    Status = 0;
            }
            else // combinational containment
            {
                if ( Aig_ManCiNum(p->pInterNew) == Aig_ManCiNum(p->pInter) )
                    Status = Inter_ManCheckContainment( p->pInterNew, p->pInter );
                else
                    Status = 0;
            }
p->timeEqu += Abc_Clock() - clk - timeTemp;
            if ( Status ) // contained
            {
                if ( pPars->fVerbose )
                    printf( "Proved containment of interpolants.\n" );
                p->timeTotal = Abc_Clock() - clkTotal;
                Inter_ManStop( p, 1 );
                Inter_CheckStop( pCheck );
                return 1;
            }
            if ( pPars->nSecLimit && Abc_Clock() > nTimeNewOut )
            {
                printf( "Reached timeout (%d seconds).\n",  pPars->nSecLimit );
                p->timeTotal = Abc_Clock() - clkTotal;
                Inter_ManStop( p, 1 );
                Inter_CheckStop( pCheck );
                return -1;
            }
            // save interpolant and convert it into CNF
            if ( pPars->fTransLoop )
            {
                Aig_ManStop( p->pInter );
                p->pInter = p->pInterNew; 
            }
            else
            {
                if ( pPars->fUseBackward )
                {
                    p->pInter = Aig_ManCreateMiter( pAigTemp = p->pInter, p->pInterNew, 2 );
                    Aig_ManStop( pAigTemp );
                    Aig_ManStop( p->pInterNew );
                    // compress the interpolant
clk = Abc_Clock();
                    p->pInter = Dar_ManRwsat( pAigTemp = p->pInter, 1, 0 );
                    Aig_ManStop( pAigTemp );
p->timeRwr += Abc_Clock() - clk;
                }
                else // forward with the new containment checking (using only the frontier)
                {
                    Aig_ManStop( p->pInter );
                    p->pInter = p->pInterNew; 
                }
            }
            p->pInterNew = NULL;
            Cnf_DataFree( p->pCnfInter );
clk = Abc_Clock();
            p->pCnfInter = Cnf_Derive( p->pInter, 0 );  
p->timeCnf += Abc_Clock() - clk;
        }

        // start containment checking
        Inter_CheckStop( pCheck );
    }
    assert( 0 );
    return RetValue;
}