abc/src/base/abci/abcExact.c
// returns 0, if current max depth and arrival times are not consistent
returns 0, if current max depth and arrival times are not consistent
returns 0 if current max depth and arrival times are not consistent
static int Ses_CheckDepthConsistency( Ses_Man_t * pSes )
{
    int l, i, fAdded, nLevel;
    int fMaxGatesLevel2 = 1;
    Vec_IntClear( pSes->vStairDecVars );
    pSes->fDecStructure = 0;
    for ( l = 0; l < pSes->nSpecVars; ++l )
    {
        if ( pSes->pArrTimeProfile[l] >= pSes->nMaxDepth )
        {
            if ( pSes->fReasonVerbose )
                printf( "give up due to impossible arrival time (depth = %d, input = %d, arrival time = %d)", pSes->nMaxDepth, l, pSes->pArrTimeProfile[l] );
            return 0;
        }
        else if ( pSes->nSpecFunc == 1 && pSes->pArrTimeProfile[l] + 1 == pSes->nMaxDepth )
        {
            if ( ( pSes->fDecStructure == 1 && pSes->nSpecVars > 2 ) || pSes->fDecStructure == 2 )
            {
                if ( pSes->fReasonVerbose )
                    printf( "give up due to impossible decomposition (depth = %d, input = %d, arrival time = %d)", pSes->nMaxDepth, l, pSes->pArrTimeProfile[l] );
                return 0;
            }
            pSes->fDecStructure++;
            if ( !( ( pSes->pDecVars >> l ) & 1 ) )
            {
                if ( pSes->fReasonVerbose )
                    printf( "give up due to impossible decomposition (depth = %d, input = %d, arrival time = %d)", pSes->nMaxDepth, l, pSes->pArrTimeProfile[l] );
                return 0;
            }
        }
    }
    if ( pSes->fDecStructure )
    {
        nLevel = 1;
        while ( 1 )
        {
            fAdded = 0;
            for ( l = 0; l < pSes->nSpecVars; ++l )
                if ( pSes->pArrTimeProfile[l] + nLevel == pSes->nMaxDepth )
                {
                    if ( fAdded )
                    {
                        assert( nLevel == Vec_IntSize( pSes->vStairDecVars ) );
                        if ( fAdded > 1 || ( nLevel + 1 < pSes->nSpecVars ) )
                        {
                            if ( pSes->fReasonVerbose )
                                printf( "give up due to impossible decomposition at level %d", nLevel );
                            return 0;
                        }
                    }
                    else
                    {
                        Vec_IntPush( pSes->vStairDecVars, l );
                    }
                    fAdded++;
                }
            if ( !fAdded ) break;
            ++nLevel;
        }
        if ( Vec_IntSize( pSes->vStairDecVars ) && !Abc_TtIsStairDecomposable( pSes->pSpec, pSes->nSpecWords, Vec_IntArray( pSes->vStairDecVars ), Vec_IntSize( pSes->vStairDecVars ), pSes->pStairDecFunc ) )
        {
            if ( pSes->fReasonVerbose )
            {
                printf( "give up due to impossible stair decomposition at level %d: ", nLevel );
                Vec_IntPrint( pSes->vStairDecVars );
            }
            return 0;
        }
    }
    if ( pSes->fDecStructure )
        fMaxGatesLevel2 = ( pSes->nSpecVars == 3 ) ? 2 : 1;
    else
        fMaxGatesLevel2 = ( pSes->nSpecVars == 4 ) ? 4 : 3;
    i = 0;
    for ( l = 0; l < pSes->nSpecVars; ++l )
        if ( pSes->pArrTimeProfile[l] + 2 == pSes->nMaxDepth )
            if ( ++i > fMaxGatesLevel2 )
            {
                if ( pSes->fReasonVerbose )
                    printf( "give up due to impossible decomposition at second level (depth = %d, input = %d, arrival time = %d)", pSes->nMaxDepth, l, pSes->pArrTimeProfile[l] );
                return 0;
            }
    if ( pSes->nSpecVars > 4 && pSes->fDecStructure && i == 1 ) 
    {
        i = 0;
        for ( l = 0; l < pSes->nSpecVars; ++l )
            if ( pSes->pArrTimeProfile[l] + 3 == pSes->nMaxDepth )
                if ( ++i > 1 )
                {
                    if ( pSes->fReasonVerbose )
                        printf( "give up due to impossible decomposition at third level (depth = %d, input = %d, arrival time = %d)", pSes->nMaxDepth, l, pSes->pArrTimeProfile[l] );
                    return 0;
                }
    }
    return 1;
}
static int Ses_CheckDepthConsistency ( Ses_Man_t * pSes ) { int l , i , fAdded , nLevel ; int fMaxGatesLevel2 = 1 ; Vec_IntClear ( pSes -> vStairDecVars ) ; pSes -> fDecStructure = 0 ; for ( l = 0 ; l < pSes -> nSpecVars ; ++ l ) { if ( pSes -> pArrTimeProfile [ l ] >= pSes -> nMaxDepth ) { if ( pSes -> fReasonVerbose ) printf ( " " , pSes -> nMaxDepth , l , pSes -> pArrTimeProfile [ l ] ) ; return 0 ; } else if ( pSes -> nSpecFunc == 1 && pSes -> pArrTimeProfile [ l ] + 1 == pSes -> nMaxDepth ) { if ( ( pSes -> fDecStructure == 1 && pSes -> nSpecVars > 2 ) || pSes -> fDecStructure == 2 ) { if ( pSes -> fReasonVerbose ) printf ( " " , pSes -> nMaxDepth , l , pSes -> pArrTimeProfile [ l ] ) ; return 0 ; } pSes -> fDecStructure ++ ; if ( ! ( ( pSes -> pDecVars >> l ) & 1 ) ) { if ( pSes -> fReasonVerbose ) printf ( " " , pSes -> nMaxDepth , l , pSes -> pArrTimeProfile [ l ] ) ; return 0 ; } } } if ( pSes -> fDecStructure ) { nLevel = 1 ; while ( 1 ) { fAdded = 0 ; for ( l = 0 ; l < pSes -> nSpecVars ; ++ l ) if ( pSes -> pArrTimeProfile [ l ] + nLevel == pSes -> nMaxDepth ) { if ( fAdded ) { assert ( nLevel == Vec_IntSize ( pSes -> vStairDecVars ) ) ; if ( fAdded > 1 || ( nLevel + 1 < pSes -> nSpecVars ) ) { if ( pSes -> fReasonVerbose ) printf ( " " , nLevel ) ; return 0 ; } } else { Vec_IntPush ( pSes -> vStairDecVars , l ) ; } fAdded ++ ; } if ( ! fAdded ) break ; ++ nLevel ; } if ( Vec_IntSize ( pSes -> vStairDecVars ) && ! Abc_TtIsStairDecomposable ( pSes -> pSpec , pSes -> nSpecWords , Vec_IntArray ( pSes -> vStairDecVars ) , Vec_IntSize ( pSes -> vStairDecVars ) , pSes -> pStairDecFunc ) ) { if ( pSes -> fReasonVerbose ) { printf ( " " , nLevel ) ; Vec_IntPrint ( pSes -> vStairDecVars ) ; } return 0 ; } } if ( pSes -> fDecStructure ) fMaxGatesLevel2 = ( pSes -> nSpecVars == 3 ) ? 2 : 1 ; else fMaxGatesLevel2 = ( pSes -> nSpecVars == 4 ) ? 4 : 3 ; i = 0 ; for ( l = 0 ; l < pSes -> nSpecVars ; ++ l ) if ( pSes -> pArrTimeProfile [ l ] + 2 == pSes -> nMaxDepth ) if ( ++ i > fMaxGatesLevel2 ) { if ( pSes -> fReasonVerbose ) printf ( " " , pSes -> nMaxDepth , l , pSes -> pArrTimeProfile [ l ] ) ; return 0 ; } if ( pSes -> nSpecVars > 4 && pSes -> fDecStructure && i == 1 ) { i = 0 ; for ( l = 0 ; l < pSes -> nSpecVars ; ++ l ) if ( pSes -> pArrTimeProfile [ l ] + 3 == pSes -> nMaxDepth ) if ( ++ i > 1 ) { if ( pSes -> fReasonVerbose ) printf ( " " , pSes -> nMaxDepth , l , pSes -> pArrTimeProfile [ l ] ) ; return 0 ; } } return 1 ; }
returns 0, if current max depth and arrival times are not consistent
returns 0 if current max depth and arrival times are not consistent
/* A subset B <=> A and B = A */ /* more complicated decomposition */ /* check if depth's match with structure at second level from top */ /* check if depth's match with structure at third level from top */ /* we have f = AND(x_i, AND(x_j, g)) (x_i and x_j may be complemented) */