abc/src/sat/bsat/satInterA.c
void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, abctime TimeToStop, void * vVarsAB, int fVerbose )
{
    Aig_Man_t * pRes;
    Aig_Obj_t * pObj;
    Sto_Cls_t * pClause;
    int RetValue = 1;
    abctime clkTotal = Abc_Clock();

    if ( TimeToStop && Abc_Clock() > TimeToStop )
        return NULL;

    // check that the CNF makes sense
    assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
    p->pCnf = pCnf;
    p->fVerbose = fVerbose;
    p->vVarsAB = (Vec_Int_t *)vVarsAB;
    p->pAig = pRes = Aig_ManStart( 10000 );
    Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );

    // adjust the manager
    Inta_ManResize( p );

    // prepare the interpolant computation
    Inta_ManPrepareInter( p );

    // construct proof for each clause
    // start the proof
    if ( p->fProofWrite )
    {
        p->pFile = fopen( "proof.cnf_", "w" );
        p->Counter = 0;
    }

    // write the root clauses
    Sto_ManForEachClauseRoot( p->pCnf, pClause )
    {
        Inta_ManProofWriteOne( p, pClause );
        if ( TimeToStop && Abc_Clock() > TimeToStop )
        {
            Aig_ManStop( pRes );
            p->pAig = NULL;
            return NULL;
        }
    }

    // propagate root level assignments
    if ( Inta_ManProcessRoots( p ) )
    {
        // if there is no conflict, consider learned clauses
        Sto_ManForEachClause( p->pCnf, pClause )
        {
            if ( pClause->fRoot )
                continue;
            if ( !Inta_ManProofRecordOne( p, pClause ) )
            {
                RetValue = 0;
                break;
            }
            if ( TimeToStop && Abc_Clock() > TimeToStop )
            {
                Aig_ManStop( pRes );
                p->pAig = NULL;
                return NULL;
            }
        }
    }

    // stop the proof
    if ( p->fProofWrite )
    { 
        fclose( p->pFile );
//        Sat_ProofChecker( "proof.cnf_" );
        p->pFile = NULL;    
    }

    if ( fVerbose )
    {
//        ABC_PRT( "Interpo", Abc_Clock() - clkTotal );
    printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d.  Ave = %.2f.  Mem = %.2f MB  ", 
        p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,  
        1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots), 
        1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
    Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
p->timeTotal += Abc_Clock() - clkTotal;
    }

    pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
    Aig_ObjCreateCo( pRes, pObj );
    Aig_ManCleanup( pRes );

    p->pAig = NULL;
    return pRes;
    
}
/**Function*************************************************************

  Synopsis    [Computes interpolant for the given CNF.]

  Description [Takes the interpolation manager, the CNF deriving by the SAT
  solver, which includes ClausesA, ClausesB, and learned clauses. Additional
  arguments are the vector of variables common to AB and the verbosiness flag.
  Returns the AIG manager with a single output, containing the interpolant.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Computes interpolant for the given CNF.]

Description [Takes the interpolation manager, the CNF deriving by the SAT
solver, which includes ClausesA, ClausesB, and learned clauses. Additional
arguments are the vector of variables common to AB and the verbosiness flag.
Returns the AIG manager with a single output, containing the interpolant.]




Function Synopsis [ Computes interpolant for the given CNF . ] Description [ Takes the interpolation manager the CNF deriving by the SAT solver which includes ClausesA ClausesB and learned clauses . Additional arguments are the vector of variables common to AB and the verbosiness flag . Returns the AIG manager with a single output containing the interpolant . ]
void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, abctime TimeToStop, void * vVarsAB, int fVerbose )
{
    Aig_Man_t * pRes;
    Aig_Obj_t * pObj;
    Sto_Cls_t * pClause;
    int RetValue = 1;
    abctime clkTotal = Abc_Clock();
    if ( TimeToStop && Abc_Clock() > TimeToStop )
        return NULL;
    assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
    p->pCnf = pCnf;
    p->fVerbose = fVerbose;
    p->vVarsAB = (Vec_Int_t *)vVarsAB;
    p->pAig = pRes = Aig_ManStart( 10000 );
    Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
    Inta_ManResize( p );
    Inta_ManPrepareInter( p );
    if ( p->fProofWrite )
    {
        p->pFile = fopen( "proof.cnf_", "w" );
        p->Counter = 0;
    }
    Sto_ManForEachClauseRoot( p->pCnf, pClause )
    {
        Inta_ManProofWriteOne( p, pClause );
        if ( TimeToStop && Abc_Clock() > TimeToStop )
        {
            Aig_ManStop( pRes );
            p->pAig = NULL;
            return NULL;
        }
    }
    if ( Inta_ManProcessRoots( p ) )
    {
        Sto_ManForEachClause( p->pCnf, pClause )
        {
            if ( pClause->fRoot )
                continue;
            if ( !Inta_ManProofRecordOne( p, pClause ) )
            {
                RetValue = 0;
                break;
            }
            if ( TimeToStop && Abc_Clock() > TimeToStop )
            {
                Aig_ManStop( pRes );
                p->pAig = NULL;
                return NULL;
            }
        }
    }
    if ( p->fProofWrite )
    { 
        fclose( p->pFile );
        p->pFile = NULL;    
    }
    if ( fVerbose )
    {
    printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d.  Ave = %.2f.  Mem = %.2f MB  ", 
        p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,  
        1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots), 
        1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
    Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
p->timeTotal += Abc_Clock() - clkTotal;
    }
    pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
    Aig_ObjCreateCo( pRes, pObj );
    Aig_ManCleanup( pRes );
    p->pAig = NULL;
    return pRes;
}
void * Inta_ManInterpolate ( Inta_Man_t * p , Sto_Man_t * pCnf , abctime TimeToStop , void * vVarsAB , int fVerbose ) { Aig_Man_t * pRes ; Aig_Obj_t * pObj ; Sto_Cls_t * pClause ; int RetValue = 1 ; abctime clkTotal = Abc_Clock ( ) ; if ( TimeToStop && Abc_Clock ( ) > TimeToStop ) return NULL ; assert ( pCnf -> nVars > 0 && pCnf -> nClauses > 0 ) ; p -> pCnf = pCnf ; p -> fVerbose = fVerbose ; p -> vVarsAB = ( Vec_Int_t * ) vVarsAB ; p -> pAig = pRes = Aig_ManStart ( 10000 ) ; Aig_IthVar ( p -> pAig , Vec_IntSize ( p -> vVarsAB ) - 1 ) ; Inta_ManResize ( p ) ; Inta_ManPrepareInter ( p ) ; if ( p -> fProofWrite ) { p -> pFile = fopen ( " " , " " ) ; p -> Counter = 0 ; } Sto_ManForEachClauseRoot ( p -> pCnf , pClause ) { Inta_ManProofWriteOne ( p , pClause ) ; if ( TimeToStop && Abc_Clock ( ) > TimeToStop ) { Aig_ManStop ( pRes ) ; p -> pAig = NULL ; return NULL ; } } if ( Inta_ManProcessRoots ( p ) ) { Sto_ManForEachClause ( p -> pCnf , pClause ) { if ( pClause -> fRoot ) continue ; if ( ! Inta_ManProofRecordOne ( p , pClause ) ) { RetValue = 0 ; break ; } if ( TimeToStop && Abc_Clock ( ) > TimeToStop ) { Aig_ManStop ( pRes ) ; p -> pAig = NULL ; return NULL ; } } } if ( p -> fProofWrite ) { fclose ( p -> pFile ) ; p -> pFile = NULL ; } if ( fVerbose ) { printf ( " " , p -> pCnf -> nVars , p -> pCnf -> nRoots , p -> pCnf -> nClauses - p -> pCnf -> nRoots , p -> Counter , 1.0 * ( p -> Counter - p -> pCnf -> nRoots ) / ( p -> pCnf -> nClauses - p -> pCnf -> nRoots ) , 1.0 * Sto_ManMemoryReport ( p -> pCnf ) / ( 1 << 20 ) ) ; Abc_PrintTime ( 1 , " " , Abc_Clock ( ) - clkTotal ) ; p -> timeTotal += Abc_Clock ( ) - clkTotal ; } pObj = * Inta_ManAigRead ( p , p -> pCnf -> pTail ) ; Aig_ObjCreateCo ( pRes , pObj ) ; Aig_ManCleanup ( pRes ) ; p -> pAig = NULL ; return pRes ; }
Function
Synopsis    [Computes interpolant for the given CNF.]
Function Synopsis [ Computes interpolant for the given CNF . ]
// check that the CNF makes sense // adjust the manager // prepare the interpolant computation // construct proof for each clause // start the proof // write the root clauses // propagate root level assignments // if there is no conflict, consider learned clauses // stop the proof //        Sat_ProofChecker( "proof.cnf_" ); //        ABC_PRT( "Interpo", Abc_Clock() - clkTotal );