Ejemplo n.º 1
0
inline int DPLL_add_compensation_resolvents( const int lit1, const int lit2 )
{
	int i, lit, *bImp = BIMP_START(lit2);

    	CHECK_NODE_STAMP( -lit1 );
	CHECK_BIMP_UPPERBOUND( -lit1, BinaryImp[ lit2 ][ 0 ] );

	for (i = BIMP_ELEMENTS; --i; )
	{
	    lit = *(bImp++); 
	    if( IS_FIXED(lit) ) continue;

	    if( bImp_stamps[ -lit ] == current_bImp_stamp )	
		return look_fix_binary_implications( lit1 );
#ifdef COMPENSATION_RESOLVENTS
	    if( bImp_stamps[ lit ] != current_bImp_stamp )
	    {
		CHECK_NODE_STAMP( -lit );
	      	CHECK_BIMP_BOUND  ( -lit );
		ADD_BINARY_IMPLICATIONS( lit, lit1 );
	    }
#endif
    	}
	return UNKNOWN;
}
Ejemplo n.º 2
0
inline void add_resolvents( const int nrval )
{
	int lit, stackSize;

        stackSize = (int) (look_resstackp - look_resstack);
#ifdef ADD_BOTH_IMPLICATIONS
        CHECK_NODE_STAMP(nrval);
        CHECK_BIMP_UPPERBOUND( nrval, stackSize );
#endif
        while( look_resstackp > look_resstack )
        {
            lit = *(--look_resstackp);

            CHECK_BIMP_BOUND( -lit );
	    CHECK_NODE_STAMP( -lit );
#ifdef ADD_BOTH_IMPLICATIONS
	    ADD_BINARY_IMPLICATION( -nrval, lit );
#endif
	    ADD_BINARY_IMPLICATION( lit, -nrval );
        }
}
Ejemplo n.º 3
0
void els_red()
{
	int i, j;
	int stamp = 0;
	int lit, *bImp;
	int *fle, nroffailed = 0;

	fle = (int*) malloc ( sizeof(int) * 2 * nrofvars );

	S = (int*) malloc ( sizeof(int) * 2 * nrofvars );
	rep = (int*) malloc( sizeof(int) * (2*nrofvars+1) );
	rep += nrofvars;

	for( i = -nrofvars; i <= nrofvars; i++ )
	{
	    dsc[ i ] = 0; fin[ i ] = 0; rep[ i ] = i;
	
            if( IS_FORCED( i ) ) 
	    {
		dsc[ i ] = 1; 
		fin[ i ] = 1; 
	    }
	}

	dsc[ 0 ] = 1;

	for( i = -nrofvars; i <= nrofvars; i++ )
	   if( dsc[ i ] == 0 ) 
		stamp = els_stamp_rec( i, stamp );

        for( i = -nrofvars; i <= nrofvars; i++ )
        {
	    if( rep[ i ] == i )
	    {
                bImp = BIMP_START(i);
                for( j = BIMP_ELEMENTS; --j; )
                {
                  lit = *bImp;
		  if( rep[ lit ] == -i )
		  {
			printf("c found failed literal %i\n", i );
			fle[ nroffailed++ ] = -i;
		  }
		  else if( rep[ lit ] != i && rep[lit] != lit )
		  {
//		    printf("c lit %i equal to lit %i (%i)\n", lit, rep[ lit ], i );
		    *bImp = rep[ lit ];
		  }
		  bImp++;
                }
	    }
	    else
	    {
		int flag = 1;

//		printf("c moving implications from %i to %i\n", i, rep[ i ] );

                bImp = BIMP_START(i);
		CHECK_BIMP_UPPERBOUND( rep[ i ], BIMP_ELEMENTS +1 );
                for( j = BIMP_ELEMENTS; --j; )
                {
                  lit = *bImp++;
		  if( rep[ lit ] == -rep[ i ] )
		  {
		     printf("c found failed literal %i\n", rep[ i ] );
		     fle[ nroffailed++ ] = -rep[ i];
		  }		
		  else if( rep[ lit ] != rep[ i ] )
		  {  ADD_BINARY_IMPLICATION( -rep[ i ], rep[ lit ] ); 
//		     printf("c adding %i to %i\n", rep[ lit ], rep[ i ] );
	  	  }
		  else if( lit == rep[ i ] ) 
		    flag = 0;
                }

		BinaryImp[ i ][ 0 ] = 3;
		BinaryImp[ i ][ 2 ] = rep[ i ];
		if( flag )
		    ADD_BINARY_IMPLICATION( -rep[ i ], i );
	    }
        }

	for( i = 0; i < nroffailed; i++ )
	    look_fix_forced_literal( fle[i] );

	free(fle);

	rep -= nrofvars;
	free(rep);
	free(S);
}