/**Function************************************************************* Synopsis [Prepares the SAT solver to run on the two nodes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Fraig_PrepareCones( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNew ) { // Msat_IntVec_t * vAdjs; // int * pVars, nVars, i, k; int nVarsAlloc; assert( pOld != pNew ); assert( !Fraig_IsComplement(pOld) ); assert( !Fraig_IsComplement(pNew) ); // clean the variables nVarsAlloc = Msat_IntVecReadSize(pMan->vVarsUsed); Msat_IntVecFill( pMan->vVarsUsed, nVarsAlloc, 0 ); Msat_IntVecClear( pMan->vVarsInt ); pMan->nTravIds++; Fraig_PrepareCones_rec( pMan, pNew ); Fraig_PrepareCones_rec( pMan, pOld ); /* nVars = Msat_IntVecReadSize( pMan->vVarsInt ); pVars = Msat_IntVecReadArray( pMan->vVarsInt ); for ( i = 0; i < nVars; i++ ) { // process its connections vAdjs = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( pMan->vAdjacents, pVars[i] ); printf( "%d=%d { ", pVars[i], Msat_IntVecReadSize(vAdjs) ); for ( k = 0; k < Msat_IntVecReadSize(vAdjs); k++ ) printf( "%d ", Msat_IntVecReadEntry(vAdjs,k) ); printf( "}\n" ); } i = 0; */ }
/**Function************************************************************* Synopsis [Set up the adjacent variable information.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Fraig_SetupAdjacentMark( Fraig_Man_t * pMan, Msat_IntVec_t * vConeVars ) { Fraig_Node_t * pNode, * pFanin; Msat_IntVec_t * vAdjs; int * pVars, nVars, i, k; // clean the adjacents for the variables nVars = Msat_IntVecReadSize( vConeVars ); pVars = Msat_IntVecReadArray( vConeVars ); for ( i = 0; i < nVars; i++ ) { pNode = pMan->vNodes->pArray[pVars[i]]; if ( pNode->fMark2 == 0 ) continue; // pNode->fMark2 = 0; // process its connections // vAdjs = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( pMan->vAdjacents, pVars[i] ); // Msat_IntVecClear( vAdjs ); if ( !Fraig_NodeIsAnd(pNode) ) continue; // add fanins vAdjs = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( pMan->vAdjacents, pVars[i] ); for ( k = 0; k < pNode->vFanins->nSize; k++ ) // for ( k = pNode->vFanins->nSize - 1; k >= 0; k-- ) { pFanin = Fraig_Regular(pNode->vFanins->pArray[k]); Msat_IntVecPush( vAdjs, pFanin->Num ); // Msat_IntVecPushUniqueOrder( vAdjs, pFanin->Num ); } } // add the fanouts for ( i = 0; i < nVars; i++ ) { pNode = pMan->vNodes->pArray[pVars[i]]; if ( pNode->fMark2 == 0 ) continue; pNode->fMark2 = 0; if ( !Fraig_NodeIsAnd(pNode) ) continue; // add the edges for ( k = 0; k < pNode->vFanins->nSize; k++ ) // for ( k = pNode->vFanins->nSize - 1; k >= 0; k-- ) { pFanin = Fraig_Regular(pNode->vFanins->pArray[k]); vAdjs = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( pMan->vAdjacents, pFanin->Num ); Msat_IntVecPush( vAdjs, pNode->Num ); // Msat_IntVecPushUniqueOrder( vAdjs, pFanin->Num ); } } }
/**Function************************************************************* Synopsis [Count the number of PI variables.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Fraig_CountPis( Fraig_Man_t * p, Msat_IntVec_t * vVarNums ) { int * pVars, nVars, i, Counter; nVars = Msat_IntVecReadSize(vVarNums); pVars = Msat_IntVecReadArray(vVarNums); Counter = 0; for ( i = 0; i < nVars; i++ ) Counter += Fraig_NodeIsVar( p->vNodes->pArray[pVars[i]] ); return Counter; }
/**Function************************************************************* Synopsis [Collect variables using their proximity from the nodes.] Description [This procedure creates a variable order based on collecting first the nodes that are the closest to the given two target nodes.] SideEffects [] SeeAlso [] ***********************************************************************/ void Fraig_SetActivity( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNew ) { Fraig_Node_t * pNode; int i, Number, MaxLevel; float * pFactors = Msat_SolverReadFactors(pMan->pSat); if ( pFactors == NULL ) return; MaxLevel = FRAIG_MAX( pOld->Level, pNew->Level ); // create the variable order for ( i = 0; i < Msat_IntVecReadSize(pMan->vVarsInt); i++ ) { // get the new node on the frontier Number = Msat_IntVecReadEntry(pMan->vVarsInt, i); pNode = pMan->vNodes->pArray[Number]; pFactors[pNode->Num] = (float)pow( 0.97, MaxLevel - pNode->Level ); // if ( pNode->Num % 50 == 0 ) // printf( "(%d) %.2f ", MaxLevel - pNode->Level, pFactors[pNode->Num] ); } // printf( "\n" ); }
/**Function************************************************************* Synopsis [Top-level solve.] Description [If using assumptions (non-empty 'assumps' vector), you must call 'simplifyDB()' first to see that no top-level conflict is present (which would put the solver in an undefined state. If the last argument is given (vProj), the solver enumerates through the satisfying solutions, which are projected on the variables listed in this array. Note that the variables in the array may be complemented, in which case the derived assignment for the variable is complemented.] SideEffects [] SeeAlso [] ***********************************************************************/ int Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTrackLimit, int nTimeLimit ) { Msat_SearchParams_t Params = { 0.95, 0.999 }; double nConflictsLimit, nLearnedLimit; Msat_Type_t Status; int timeStart = clock(); // p->pFreq = ABC_ALLOC( int, p->nVarsAlloc ); // memset( p->pFreq, 0, sizeof(int) * p->nVarsAlloc ); if ( vAssumps ) { int * pAssumps, nAssumps, i; assert( Msat_IntVecReadSize(p->vTrailLim) == 0 ); nAssumps = Msat_IntVecReadSize( vAssumps ); pAssumps = Msat_IntVecReadArray( vAssumps ); for ( i = 0; i < nAssumps; i++ ) { if ( !Msat_SolverAssume(p, pAssumps[i]) || Msat_SolverPropagate(p) ) { Msat_QueueClear( p->pQueue ); Msat_SolverCancelUntil( p, 0 ); return MSAT_FALSE; } } } p->nLevelRoot = Msat_SolverReadDecisionLevel(p); p->nClausesInit = Msat_ClauseVecReadSize( p->vClauses ); nConflictsLimit = 100; nLearnedLimit = Msat_ClauseVecReadSize(p->vClauses) / 3; Status = MSAT_UNKNOWN; p->nBackTracks = (int)p->Stats.nConflicts; while ( Status == MSAT_UNKNOWN ) { if ( p->fVerbose ) printf("Solving -- conflicts=%d learnts=%d progress=%.4f %%\n", (int)nConflictsLimit, (int)nLearnedLimit, p->dProgress*100); Status = Msat_SolverSearch( p, (int)nConflictsLimit, (int)nLearnedLimit, nBackTrackLimit, &Params ); nConflictsLimit *= 1.5; nLearnedLimit *= 1.1; // if the limit on the number of backtracks is given, quit the restart loop if ( nBackTrackLimit > 0 && (int)p->Stats.nConflicts - p->nBackTracks > nBackTrackLimit ) break; // if the runtime limit is exceeded, quit the restart loop if ( nTimeLimit > 0 && clock() - timeStart >= nTimeLimit * CLOCKS_PER_SEC ) break; } Msat_SolverCancelUntil( p, 0 ); p->nBackTracks = (int)p->Stats.nConflicts - p->nBackTracks; /* ABC_PRT( "True solver runtime", clock() - timeStart ); // print the statistics { int i, Counter = 0; for ( i = 0; i < p->nVars; i++ ) if ( p->pFreq[i] > 0 ) { printf( "%d ", p->pFreq[i] ); Counter++; } if ( Counter ) printf( "\n" ); printf( "Total = %d. Used = %d. Decisions = %d. Imps = %d. Conflicts = %d. ", p->nVars, Counter, (int)p->Stats.nDecisions, (int)p->Stats.nPropagations, (int)p->Stats.nConflicts ); ABC_PRT( "Time", clock() - timeStart ); } */ return Status; }
/**Function************************************************************* Synopsis [Collect variables using their proximity from the nodes.] Description [This procedure creates a variable order based on collecting first the nodes that are the closest to the given two target nodes.] SideEffects [] SeeAlso [] ***********************************************************************/ void Fraig_OrderVariables( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNew ) { Fraig_Node_t * pNode, * pFanin; int i, k, Number, fUseMuxes = 1; int nVarsAlloc; assert( pOld != pNew ); assert( !Fraig_IsComplement(pOld) ); assert( !Fraig_IsComplement(pNew) ); pMan->nTravIds++; // clean the variables nVarsAlloc = Msat_IntVecReadSize(pMan->vVarsUsed); Msat_IntVecFill( pMan->vVarsUsed, nVarsAlloc, 0 ); Msat_IntVecClear( pMan->vVarsInt ); // add the first node Msat_IntVecPush( pMan->vVarsInt, pOld->Num ); Msat_IntVecWriteEntry( pMan->vVarsUsed, pOld->Num, 1 ); pOld->TravId = pMan->nTravIds; // add the second node Msat_IntVecPush( pMan->vVarsInt, pNew->Num ); Msat_IntVecWriteEntry( pMan->vVarsUsed, pNew->Num, 1 ); pNew->TravId = pMan->nTravIds; // create the variable order for ( i = 0; i < Msat_IntVecReadSize(pMan->vVarsInt); i++ ) { // get the new node on the frontier Number = Msat_IntVecReadEntry(pMan->vVarsInt, i); pNode = pMan->vNodes->pArray[Number]; if ( !Fraig_NodeIsAnd(pNode) ) continue; // if the node does not have fanins, create them if ( pNode->vFanins == NULL ) { // create the fanins of the supergate assert( pNode->fClauses == 0 ); // detecting a fanout-free cone (experiment only) // Fraig_DetectFanoutFreeCone( pMan, pNode ); if ( fUseMuxes && Fraig_NodeIsMuxType(pNode) ) { pNode->vFanins = Fraig_NodeVecAlloc( 4 ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p1)->p1) ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p1)->p2) ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p2)->p1) ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p2)->p2) ); Fraig_SupergateAddClausesMux( pMan, pNode ); // Fraig_DetectFanoutFreeConeMux( pMan, pNode ); nMuxes++; } else { pNode->vFanins = Fraig_CollectSupergate( pNode, fUseMuxes ); Fraig_SupergateAddClauses( pMan, pNode, pNode->vFanins ); } assert( pNode->vFanins->nSize > 1 ); pNode->fClauses = 1; pMan->nVarsClauses++; pNode->fMark2 = 1; // goes together with Fraig_SetupAdjacentMark() } // explore the implication fanins of pNode for ( k = 0; k < pNode->vFanins->nSize; k++ ) { pFanin = Fraig_Regular(pNode->vFanins->pArray[k]); if ( pFanin->TravId == pMan->nTravIds ) // already collected continue; // collect and mark Msat_IntVecPush( pMan->vVarsInt, pFanin->Num ); Msat_IntVecWriteEntry( pMan->vVarsUsed, pFanin->Num, 1 ); pFanin->TravId = pMan->nTravIds; } } // set up the adjacent variable information // Fraig_SetupAdjacent( pMan, pMan->vVarsInt ); Fraig_SetupAdjacentMark( pMan, pMan->vVarsInt ); }
/**Function************************************************************* Synopsis [Traverses the cone, collects the numbers and adds the clauses.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Fraig_PrepareCones_rec( Fraig_Man_t * pMan, Fraig_Node_t * pNode ) { Fraig_Node_t * pFanin; Msat_IntVec_t * vAdjs; int fUseMuxes = 1, i; int fItIsTime; // skip if the node is aleady visited assert( !Fraig_IsComplement(pNode) ); if ( pNode->TravId == pMan->nTravIds ) return; pNode->TravId = pMan->nTravIds; // collect the node's number (closer to reverse topological order) Msat_IntVecPush( pMan->vVarsInt, pNode->Num ); Msat_IntVecWriteEntry( pMan->vVarsUsed, pNode->Num, 1 ); if ( !Fraig_NodeIsAnd( pNode ) ) return; // if the node does not have fanins, create them fItIsTime = 0; if ( pNode->vFanins == NULL ) { fItIsTime = 1; // create the fanins of the supergate assert( pNode->fClauses == 0 ); if ( fUseMuxes && Fraig_NodeIsMuxType(pNode) ) { pNode->vFanins = Fraig_NodeVecAlloc( 4 ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p1)->p1) ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p1)->p2) ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p2)->p1) ); Fraig_NodeVecPushUnique( pNode->vFanins, Fraig_Regular(Fraig_Regular(pNode->p2)->p2) ); Fraig_SupergateAddClausesMux( pMan, pNode ); } else { pNode->vFanins = Fraig_CollectSupergate( pNode, fUseMuxes ); Fraig_SupergateAddClauses( pMan, pNode, pNode->vFanins ); } assert( pNode->vFanins->nSize > 1 ); pNode->fClauses = 1; pMan->nVarsClauses++; // add fanins vAdjs = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( pMan->vAdjacents, pNode->Num ); assert( Msat_IntVecReadSize( vAdjs ) == 0 ); for ( i = 0; i < pNode->vFanins->nSize; i++ ) { pFanin = Fraig_Regular(pNode->vFanins->pArray[i]); Msat_IntVecPush( vAdjs, pFanin->Num ); } } // recursively visit the fanins for ( i = 0; i < pNode->vFanins->nSize; i++ ) Fraig_PrepareCones_rec( pMan, Fraig_Regular(pNode->vFanins->pArray[i]) ); if ( fItIsTime ) { // recursively visit the fanins for ( i = 0; i < pNode->vFanins->nSize; i++ ) { pFanin = Fraig_Regular(pNode->vFanins->pArray[i]); vAdjs = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( pMan->vAdjacents, pFanin->Num ); Msat_IntVecPush( vAdjs, pNode->Num ); } } }
/**Function************************************************************* Synopsis [Checks whether pOld => pNew.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Fraig_NodeIsImplication( Fraig_Man_t * p, Fraig_Node_t * pOld, Fraig_Node_t * pNew, int nBTLimit ) { int RetValue, RetValue1, i, fComp, clk; int fVerbose = 0; // make sure the nodes are not complemented assert( !Fraig_IsComplement(pNew) ); assert( !Fraig_IsComplement(pOld) ); assert( pNew != pOld ); p->nSatCallsImp++; // make sure the solver is allocated and has enough variables if ( p->pSat == NULL ) Fraig_ManCreateSolver( p ); // make sure the SAT solver has enough variables for ( i = Msat_SolverReadVarNum(p->pSat); i < p->vNodes->nSize; i++ ) Msat_SolverAddVar( p->pSat, p->vNodes->pArray[i]->Level ); // get the logic cone clk = clock(); Fraig_OrderVariables( p, pOld, pNew ); // Fraig_PrepareCones( p, pOld, pNew ); p->timeTrav += clock() - clk; if ( fVerbose ) printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) ); // get the complemented attribute fComp = Fraig_NodeComparePhase( pOld, pNew ); //Msat_SolverPrintClauses( p->pSat ); //////////////////////////////////////////// // prepare the solver to run incrementally on these variables //clk = clock(); Msat_SolverPrepare( p->pSat, p->vVarsInt ); //p->time3 += clock() - clk; // solve under assumptions // A = 1; B = 0 OR A = 1; B = 1 Msat_IntVecClear( p->vProj ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) ); // run the solver clk = clock(); RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, 1000000 ); p->timeSat += clock() - clk; if ( RetValue1 == MSAT_FALSE ) { //p->time1 += clock() - clk; if ( fVerbose ) { printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); PRT( "time", clock() - clk ); } // add the clause Msat_IntVecClear( p->vProj ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) ); RetValue = Msat_SolverAddClause( p->pSat, p->vProj ); assert( RetValue ); // p->nSatProofImp++; return 1; } else if ( RetValue1 == MSAT_TRUE ) { //p->time2 += clock() - clk; if ( fVerbose ) { printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); PRT( "time", clock() - clk ); } // record the counter example Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew ); p->nSatCounterImp++; return 0; } else // if ( RetValue1 == MSAT_UNKNOWN ) { p->time3 += clock() - clk; p->nSatFailsImp++; return 0; } }
/**Function************************************************************* Synopsis [Checks whether two nodes are functinally equivalent.] Description [The flag (fComp) tells whether the nodes to be checked are in the opposite polarity. The second flag (fSkipZeros) tells whether the checking should be performed if the simulation vectors are zeros. Returns 1 if the nodes are equivalent; 0 othewise.] SideEffects [] SeeAlso [] ***********************************************************************/ int Fraig_NodeIsEquivalent( Fraig_Man_t * p, Fraig_Node_t * pOld, Fraig_Node_t * pNew, int nBTLimit, int nTimeLimit ) { int RetValue, RetValue1, i, fComp, clk; int fVerbose = 0; int fSwitch = 0; // make sure the nodes are not complemented assert( !Fraig_IsComplement(pNew) ); assert( !Fraig_IsComplement(pOld) ); assert( pNew != pOld ); // if at least one of the nodes is a failed node, perform adjustments: // if the backtrack limit is small, simply skip this node // if the backtrack limit is > 10, take the quare root of the limit if ( nBTLimit > 0 && (pOld->fFailTfo || pNew->fFailTfo) ) { p->nSatFails++; // return 0; // if ( nBTLimit > 10 ) // nBTLimit /= 10; if ( nBTLimit <= 10 ) return 0; nBTLimit = (int)sqrt(nBTLimit); // fSwitch = 1; } p->nSatCalls++; // make sure the solver is allocated and has enough variables if ( p->pSat == NULL ) Fraig_ManCreateSolver( p ); // make sure the SAT solver has enough variables for ( i = Msat_SolverReadVarNum(p->pSat); i < p->vNodes->nSize; i++ ) Msat_SolverAddVar( p->pSat, p->vNodes->pArray[i]->Level ); /* { Fraig_Node_t * ppNodes[2] = { pOld, pNew }; extern void Fraig_MappingShowNodes( Fraig_Man_t * pMan, Fraig_Node_t ** ppRoots, int nRoots, char * pFileName ); Fraig_MappingShowNodes( p, ppNodes, 2, "temp_aig" ); } */ nMuxes = 0; // get the logic cone clk = clock(); // Fraig_VarsStudy( p, pOld, pNew ); Fraig_OrderVariables( p, pOld, pNew ); // Fraig_PrepareCones( p, pOld, pNew ); p->timeTrav += clock() - clk; // printf( "The number of MUXes detected = %d (%5.2f %% of logic). ", nMuxes, 300.0*nMuxes/(p->vNodes->nSize - p->vInputs->nSize) ); // PRT( "Time", clock() - clk ); if ( fVerbose ) printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) ); // prepare variable activity Fraig_SetActivity( p, pOld, pNew ); // get the complemented attribute fComp = Fraig_NodeComparePhase( pOld, pNew ); //Msat_SolverPrintClauses( p->pSat ); //////////////////////////////////////////// // prepare the solver to run incrementally on these variables //clk = clock(); Msat_SolverPrepare( p->pSat, p->vVarsInt ); //p->time3 += clock() - clk; // solve under assumptions // A = 1; B = 0 OR A = 1; B = 1 Msat_IntVecClear( p->vProj ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) ); //Msat_SolverWriteDimacs( p->pSat, "temp_fraig.cnf" ); // run the solver clk = clock(); RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, nTimeLimit ); p->timeSat += clock() - clk; if ( RetValue1 == MSAT_FALSE ) { //p->time1 += clock() - clk; if ( fVerbose ) { printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); PRT( "time", clock() - clk ); } // add the clause Msat_IntVecClear( p->vProj ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) ); RetValue = Msat_SolverAddClause( p->pSat, p->vProj ); assert( RetValue ); // continue solving the other implication } else if ( RetValue1 == MSAT_TRUE ) { //p->time2 += clock() - clk; if ( fVerbose ) { printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); PRT( "time", clock() - clk ); } // record the counter example Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew ); // if ( pOld->fFailTfo || pNew->fFailTfo ) // printf( "*" ); // printf( "s(%d)", pNew->Level ); if ( fSwitch ) printf( "s(%d)", pNew->Level ); p->nSatCounter++; return 0; } else // if ( RetValue1 == MSAT_UNKNOWN ) { p->time3 += clock() - clk; // if ( pOld->fFailTfo || pNew->fFailTfo ) // printf( "*" ); // printf( "T(%d)", pNew->Level ); // mark the node as the failed node if ( pOld != p->pConst1 ) pOld->fFailTfo = 1; pNew->fFailTfo = 1; // p->nSatFails++; if ( fSwitch ) printf( "T(%d)", pNew->Level ); p->nSatFailsReal++; return 0; } // if the old node was constant 0, we already know the answer if ( pOld == p->pConst1 ) return 1; //////////////////////////////////////////// // prepare the solver to run incrementally //clk = clock(); Msat_SolverPrepare( p->pSat, p->vVarsInt ); //p->time3 += clock() - clk; // solve under assumptions // A = 0; B = 1 OR A = 0; B = 0 Msat_IntVecClear( p->vProj ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) ); // run the solver clk = clock(); RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, nTimeLimit ); p->timeSat += clock() - clk; if ( RetValue1 == MSAT_FALSE ) { //p->time1 += clock() - clk; if ( fVerbose ) { printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); PRT( "time", clock() - clk ); } // add the clause Msat_IntVecClear( p->vProj ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) ); Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) ); RetValue = Msat_SolverAddClause( p->pSat, p->vProj ); assert( RetValue ); // continue solving the other implication } else if ( RetValue1 == MSAT_TRUE ) { //p->time2 += clock() - clk; if ( fVerbose ) { printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); PRT( "time", clock() - clk ); } // record the counter example Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew ); p->nSatCounter++; // if ( pOld->fFailTfo || pNew->fFailTfo ) // printf( "*" ); // printf( "s(%d)", pNew->Level ); if ( fSwitch ) printf( "s(%d)", pNew->Level ); return 0; } else // if ( RetValue1 == MSAT_UNKNOWN ) { p->time3 += clock() - clk; // if ( pOld->fFailTfo || pNew->fFailTfo ) // printf( "*" ); // printf( "T(%d)", pNew->Level ); if ( fSwitch ) printf( "T(%d)", pNew->Level ); // mark the node as the failed node pOld->fFailTfo = 1; pNew->fFailTfo = 1; // p->nSatFails++; p->nSatFailsReal++; return 0; } // return SAT proof p->nSatProof++; // if ( pOld->fFailTfo || pNew->fFailTfo ) // printf( "*" ); // printf( "u(%d)", pNew->Level ); if ( fSwitch ) printf( "u(%d)", pNew->Level ); return 1; }