Commit 220a83f1 by Alan Mishchenko

Bug fix in 'int'.

parent 51714ef6
...@@ -66,9 +66,7 @@ struct Inta_Man_t_ ...@@ -66,9 +66,7 @@ struct Inta_Man_t_
int * pProofNums; // the proof numbers for each clause (size nClauses) int * pProofNums; // the proof numbers for each clause (size nClauses)
FILE * pFile; // the file for proof recording FILE * pFile; // the file for proof recording
// internal verification // internal verification
lit * pResLits; // the literals of the resolvent Vec_Int_t * vResLits;
int nResLits; // the number of literals of the resolvent
int nResLitsAlloc;// the number of literals of the resolvent
// runtime stats // runtime stats
abctime timeBcp; // the runtime for BCP abctime timeBcp; // the runtime for BCP
abctime timeTrace; // the runtime of trace construction abctime timeTrace; // the runtime of trace construction
...@@ -112,8 +110,7 @@ Inta_Man_t * Inta_ManAlloc() ...@@ -112,8 +110,7 @@ Inta_Man_t * Inta_ManAlloc()
p = (Inta_Man_t *)ABC_ALLOC( char, sizeof(Inta_Man_t) ); p = (Inta_Man_t *)ABC_ALLOC( char, sizeof(Inta_Man_t) );
memset( p, 0, sizeof(Inta_Man_t) ); memset( p, 0, sizeof(Inta_Man_t) );
// verification // verification
p->nResLitsAlloc = (1<<16); p->vResLits = Vec_IntAlloc( 1000 );
p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
// parameters // parameters
p->fProofWrite = 0; p->fProofWrite = 0;
p->fProofVerif = 1; p->fProofVerif = 1;
...@@ -266,7 +263,7 @@ ABC_PRT( "TOTAL ", p->timeTotal ); ...@@ -266,7 +263,7 @@ ABC_PRT( "TOTAL ", p->timeTotal );
ABC_FREE( p->pVarTypes ); ABC_FREE( p->pVarTypes );
ABC_FREE( p->pReasons ); ABC_FREE( p->pReasons );
ABC_FREE( p->pWatches ); ABC_FREE( p->pWatches );
ABC_FREE( p->pResLits ); Vec_IntFree( p->vResLits );
ABC_FREE( p ); ABC_FREE( p );
} }
...@@ -304,12 +301,12 @@ void Inta_ManPrintClause( Inta_Man_t * p, Sto_Cls_t * pClause ) ...@@ -304,12 +301,12 @@ void Inta_ManPrintClause( Inta_Man_t * p, Sto_Cls_t * pClause )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Inta_ManPrintResolvent( lit * pResLits, int nResLits ) void Inta_ManPrintResolvent( Vec_Int_t * vResLits )
{ {
int i; int i, Entry;
printf( "Resolvent: {" ); printf( "Resolvent: {" );
for ( i = 0; i < nResLits; i++ ) Vec_IntForEachEntry( vResLits, Entry, i )
printf( " %d", pResLits[i] ); printf( " %d", Entry );
printf( " }\n" ); printf( " }\n" );
} }
...@@ -552,9 +549,9 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF ...@@ -552,9 +549,9 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
// collect resolvent literals // collect resolvent literals
if ( p->fProofVerif ) if ( p->fProofVerif )
{ {
assert( (int)pConflict->nLits <= p->nResLitsAlloc ); Vec_IntClear( p->vResLits );
memcpy( p->pResLits, pConflict->pLits, sizeof(lit) * pConflict->nLits ); for ( i = 0; i < (int)pConflict->nLits; i++ )
p->nResLits = pConflict->nLits; Vec_IntPush( p->vResLits, pConflict->pLits[i] );
} }
// mark all the variables in the conflict as seen // mark all the variables in the conflict as seen
...@@ -606,38 +603,34 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF ...@@ -606,38 +603,34 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
// resolve the temporary resolvent with the reason clause // resolve the temporary resolvent with the reason clause
if ( p->fProofVerif ) if ( p->fProofVerif )
{ {
int v1, v2; int v1, v2, Entry;
if ( fPrint ) if ( fPrint )
Inta_ManPrintResolvent( p->pResLits, p->nResLits ); Inta_ManPrintResolvent( p->vResLits );
// check that the var is present in the resolvent // check that the var is present in the resolvent
for ( v1 = 0; v1 < p->nResLits; v1++ ) Vec_IntForEachEntry( p->vResLits, Entry, v1 )
if ( lit_var(p->pResLits[v1]) == Var ) if ( lit_var(Entry) == Var )
break; break;
if ( v1 == p->nResLits ) if ( v1 == Vec_IntSize(p->vResLits) )
printf( "Recording clause %d: Cannot find variable %d in the temporary resolvent.\n", pFinal->Id, Var ); printf( "Recording clause %d: Cannot find variable %d in the temporary resolvent.\n", pFinal->Id, Var );
if ( p->pResLits[v1] != lit_neg(pReason->pLits[0]) ) if ( Entry != lit_neg(pReason->pLits[0]) )
printf( "Recording clause %d: The resolved variable %d is in the wrong polarity.\n", pFinal->Id, Var ); printf( "Recording clause %d: The resolved variable %d is in the wrong polarity.\n", pFinal->Id, Var );
// remove this variable from the resolvent // remove variable v1 from the resolvent
assert( lit_var(p->pResLits[v1]) == Var ); assert( lit_var(Entry) == Var );
p->nResLits--; Vec_IntRemove( p->vResLits, Entry );
for ( ; v1 < p->nResLits; v1++ )
p->pResLits[v1] = p->pResLits[v1+1];
// add variables of the reason clause // add variables of the reason clause
for ( v2 = 1; v2 < (int)pReason->nLits; v2++ ) for ( v2 = 1; v2 < (int)pReason->nLits; v2++ )
{ {
for ( v1 = 0; v1 < p->nResLits; v1++ ) Vec_IntForEachEntry( p->vResLits, Entry, v1 )
if ( lit_var(p->pResLits[v1]) == lit_var(pReason->pLits[v2]) ) if ( lit_var(Entry) == lit_var(pReason->pLits[v2]) )
break; break;
// if it is a new variable, add it to the resolvent // if it is a new variable, add it to the resolvent
if ( v1 == p->nResLits ) if ( v1 == Vec_IntSize(p->vResLits) )
{ {
if ( p->nResLits == p->nResLitsAlloc ) Vec_IntPush( p->vResLits, pReason->pLits[v2] );
printf( "Recording clause %d: Ran out of space for intermediate resolvent.\n", pFinal->Id );
p->pResLits[ p->nResLits++ ] = pReason->pLits[v2];
continue; continue;
} }
// if the variable is the same, the literal should be the same too // if the variable is the same, the literal should be the same too
if ( p->pResLits[v1] == pReason->pLits[v2] ) if ( Entry == pReason->pLits[v2] )
continue; continue;
// the literal is different // the literal is different
printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id ); printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id );
...@@ -656,37 +649,37 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF ...@@ -656,37 +649,37 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
// use the resulting clause to check the correctness of resolution // use the resulting clause to check the correctness of resolution
if ( p->fProofVerif ) if ( p->fProofVerif )
{ {
int v1, v2; int v1, v2, Entry;
if ( fPrint ) if ( fPrint )
Inta_ManPrintResolvent( p->pResLits, p->nResLits ); Inta_ManPrintResolvent( p->vResLits );
for ( v1 = 0; v1 < p->nResLits; v1++ ) Vec_IntForEachEntry( p->vResLits, Entry, v1 )
{ {
for ( v2 = 0; v2 < (int)pFinal->nLits; v2++ ) for ( v2 = 0; v2 < (int)pFinal->nLits; v2++ )
if ( pFinal->pLits[v2] == p->pResLits[v1] ) if ( pFinal->pLits[v2] == Entry )
break; break;
if ( v2 < (int)pFinal->nLits ) if ( v2 < (int)pFinal->nLits )
continue; continue;
break; break;
} }
if ( v1 < p->nResLits ) if ( v1 < Vec_IntSize(p->vResLits) )
{ {
printf( "Recording clause %d: The final resolvent is wrong.\n", pFinal->Id ); printf( "Recording clause %d: The final resolvent is wrong.\n", pFinal->Id );
Inta_ManPrintClause( p, pConflict ); Inta_ManPrintClause( p, pConflict );
Inta_ManPrintResolvent( p->pResLits, p->nResLits ); Inta_ManPrintResolvent( p->vResLits );
Inta_ManPrintClause( p, pFinal ); Inta_ManPrintClause( p, pFinal );
} }
// if there are literals in the clause that are not in the resolvent // if there are literals in the clause that are not in the resolvent
// it means that the derived resolvent is stronger than the clause // it means that the derived resolvent is stronger than the clause
// we can replace the clause with the resolvent by removing these literals // we can replace the clause with the resolvent by removing these literals
if ( p->nResLits != (int)pFinal->nLits ) if ( Vec_IntSize(p->vResLits) != (int)pFinal->nLits )
{ {
for ( v1 = 0; v1 < (int)pFinal->nLits; v1++ ) for ( v1 = 0; v1 < (int)pFinal->nLits; v1++ )
{ {
for ( v2 = 0; v2 < p->nResLits; v2++ ) Vec_IntForEachEntry( p->vResLits, Entry, v2 )
if ( pFinal->pLits[v1] == p->pResLits[v2] ) if ( pFinal->pLits[v1] == Entry )
break; break;
if ( v2 < p->nResLits ) if ( v2 < Vec_IntSize(p->vResLits) )
continue; continue;
// remove literal v1 from the final clause // remove literal v1 from the final clause
pFinal->nLits--; pFinal->nLits--;
...@@ -694,7 +687,7 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF ...@@ -694,7 +687,7 @@ int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
pFinal->pLits[v2] = pFinal->pLits[v2+1]; pFinal->pLits[v2] = pFinal->pLits[v2+1];
v1--; v1--;
} }
assert( p->nResLits == (int)pFinal->nLits ); assert( Vec_IntSize(p->vResLits) == (int)pFinal->nLits );
} }
} }
p->timeTrace += Abc_Clock() - clk; p->timeTrace += Abc_Clock() - clk;
......
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