ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraigSat.c File Reference
#include <math.h>
#include "fraigInt.h"
#include "sat/msat/msatInt.h"
Include dependency graph for fraigSat.c:

Go to the source code of this file.

Functions

int Fraig_NodesAreEqual (Fraig_Man_t *p, Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int nBTLimit, int nTimeLimit)
 FUNCTION DEFINITIONS ///.
 
void Fraig_ManProveMiter (Fraig_Man_t *p)
 
int Fraig_ManCheckMiter (Fraig_Man_t *p)
 
int Fraig_MarkTfi_rec (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_MarkTfi2_rec (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
int Fraig_MarkTfi3_rec (Fraig_Man_t *pMan, Fraig_Node_t *pNode)
 
void Fraig_VarsStudy (Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
 
int Fraig_NodeIsEquivalent (Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit, int nTimeLimit)
 
int Fraig_NodeIsImplification (Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit)
 
int Fraig_ManCheckClauseUsingSat (Fraig_Man_t *p, Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int nBTLimit)
 
void Fraig_DetectFanoutFreeCone_rec (Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, Fraig_NodeVec_t *vInside, int fFirst)
 
void Fraig_DetectFanoutFreeConeMux_rec (Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, Fraig_NodeVec_t *vInside, int fFirst)
 

Function Documentation

◆ Fraig_DetectFanoutFreeCone_rec()

void Fraig_DetectFanoutFreeCone_rec ( Fraig_Node_t * pNode,
Fraig_NodeVec_t * vSuper,
Fraig_NodeVec_t * vInside,
int fFirst )

Function*************************************************************

Synopsis [Returns the array of nodes to be combined into one multi-input AND-gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 1308 of file fraigSat.c.

1309{
1310 // make the pointer regular
1311 pNode = Fraig_Regular(pNode);
1312 // if the new node is complemented or a PI, another gate begins
1313 if ( (!fFirst && pNode->nRefs > 1) || Fraig_NodeIsVar(pNode) )
1314 {
1315 Fraig_NodeVecPushUnique( vSuper, pNode );
1316 return;
1317 }
1318 // go through the branches
1319 Fraig_DetectFanoutFreeCone_rec( pNode->p1, vSuper, vInside, 0 );
1320 Fraig_DetectFanoutFreeCone_rec( pNode->p2, vSuper, vInside, 0 );
1321 // add the node
1322 Fraig_NodeVecPushUnique( vInside, pNode );
1323}
void Fraig_DetectFanoutFreeCone_rec(Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, Fraig_NodeVec_t *vInside, int fFirst)
Definition fraigSat.c:1308
#define Fraig_Regular(p)
Definition fraig.h:108
int Fraig_NodeVecPushUnique(Fraig_NodeVec_t *p, Fraig_Node_t *Entry)
Definition fraigVec.c:212
int Fraig_NodeIsVar(Fraig_Node_t *p)
Definition fraigApi.c:152
Fraig_Node_t * p2
Definition fraigInt.h:233
Fraig_Node_t * p1
Definition fraigInt.h:232
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_DetectFanoutFreeConeMux_rec()

void Fraig_DetectFanoutFreeConeMux_rec ( Fraig_Node_t * pNode,
Fraig_NodeVec_t * vSuper,
Fraig_NodeVec_t * vInside,
int fFirst )

Function*************************************************************

Synopsis [Returns the array of nodes to be combined into one multi-input AND-gate.]

Description []

SideEffects []

SeeAlso [] Function*************************************************************

Synopsis [Returns the array of nodes to be combined into one multi-input AND-gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 1371 of file fraigSat.c.

1372{
1373 // make the pointer regular
1374 pNode = Fraig_Regular(pNode);
1375 // if the new node is complemented or a PI, another gate begins
1376 if ( (!fFirst && pNode->nRefs > 1) || Fraig_NodeIsVar(pNode) || !Fraig_NodeIsMuxType(pNode) )
1377 {
1378 Fraig_NodeVecPushUnique( vSuper, pNode );
1379 return;
1380 }
1381 // go through the branches
1382 Fraig_DetectFanoutFreeConeMux_rec( Fraig_Regular(pNode->p1)->p1, vSuper, vInside, 0 );
1383 Fraig_DetectFanoutFreeConeMux_rec( Fraig_Regular(pNode->p1)->p2, vSuper, vInside, 0 );
1384 Fraig_DetectFanoutFreeConeMux_rec( Fraig_Regular(pNode->p2)->p1, vSuper, vInside, 0 );
1385 Fraig_DetectFanoutFreeConeMux_rec( Fraig_Regular(pNode->p2)->p2, vSuper, vInside, 0 );
1386 // add the node
1387 Fraig_NodeVecPushUnique( vInside, pNode );
1388}
int Fraig_NodeIsMuxType(Fraig_Node_t *pNode)
Definition fraigUtil.c:591
void Fraig_DetectFanoutFreeConeMux_rec(Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, Fraig_NodeVec_t *vInside, int fFirst)
Definition fraigSat.c:1371
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManCheckClauseUsingSat()

int Fraig_ManCheckClauseUsingSat ( Fraig_Man_t * p,
Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2,
int nBTLimit )

Function*************************************************************

Synopsis [Prepares the SAT solver to run on the two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 653 of file fraigSat.c.

654{
655 Fraig_Node_t * pNode1R, * pNode2R;
656 int RetValue, RetValue1, i;
657 abctime clk;
658 int fVerbose = 0;
659
660 pNode1R = Fraig_Regular(pNode1);
661 pNode2R = Fraig_Regular(pNode2);
662 assert( pNode1R != pNode2R );
663
664 // make sure the solver is allocated and has enough variables
665 if ( p->pSat == NULL )
667 // make sure the SAT solver has enough variables
668 for ( i = Msat_SolverReadVarNum(p->pSat); i < p->vNodes->nSize; i++ )
669 Msat_SolverAddVar( p->pSat, p->vNodes->pArray[i]->Level );
670
671 // get the logic cone
672clk = Abc_Clock();
673 Fraig_OrderVariables( p, pNode1R, pNode2R );
674// Fraig_PrepareCones( p, pNode1R, pNode2R );
675p->timeTrav += Abc_Clock() - clk;
676
678 // prepare the solver to run incrementally on these variables
679//clk = Abc_Clock();
680 Msat_SolverPrepare( p->pSat, p->vVarsInt );
681//p->time3 += Abc_Clock() - clk;
682
683 // solve under assumptions
684 // A = 1; B = 0 OR A = 1; B = 1
685 Msat_IntVecClear( p->vProj );
686 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNode1R->Num, !Fraig_IsComplement(pNode1)) );
687 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNode2R->Num, !Fraig_IsComplement(pNode2)) );
688 // run the solver
689clk = Abc_Clock();
690 RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, 1000000 );
691p->timeSat += Abc_Clock() - clk;
692
693 if ( RetValue1 == MSAT_FALSE )
694 {
695//p->time1 += Abc_Clock() - clk;
696
697if ( fVerbose )
698{
699// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) );
700//ABC_PRT( "time", Abc_Clock() - clk );
701}
702
703 // add the clause
704 Msat_IntVecClear( p->vProj );
705 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNode1R->Num, Fraig_IsComplement(pNode1)) );
706 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNode2R->Num, Fraig_IsComplement(pNode2)) );
707 RetValue = Msat_SolverAddClause( p->pSat, p->vProj );
708 assert( RetValue );
709// p->nSatProofImp++;
710 return 1;
711 }
712 else if ( RetValue1 == MSAT_TRUE )
713 {
714//p->time2 += Abc_Clock() - clk;
715
716if ( fVerbose )
717{
718// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) );
719//ABC_PRT( "time", Abc_Clock() - clk );
720}
721 // record the counter example
722// Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pNode1R, pNode2R );
723 p->nSatCounterImp++;
724 return 0;
725 }
726 else // if ( RetValue1 == MSAT_UNKNOWN )
727 {
728p->time3 += Abc_Clock() - clk;
729 p->nSatFailsImp++;
730 return 0;
731 }
732}
ABC_INT64_T abctime
Definition abc_global.h:332
Cube * p
Definition exorList.c:222
void Fraig_ManCreateSolver(Fraig_Man_t *p)
Definition fraigMan.c:325
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition fraig.h:107
struct Fraig_NodeStruct_t_ Fraig_Node_t
Definition fraig.h:41
int Msat_SolverAddClause(Msat_Solver_t *p, Msat_IntVec_t *pLits)
int Msat_SolverSolve(Msat_Solver_t *p, Msat_IntVec_t *pVecAssumps, int nBackTrackLimit, int nTimeLimit)
#define MSAT_VAR2LIT(v, s)
Definition msat.h:56
int Msat_SolverReadVarNum(Msat_Solver_t *p)
FUNCTION DEFINITIONS ///.
@ MSAT_TRUE
Definition msat.h:50
@ MSAT_FALSE
Definition msat.h:50
void Msat_IntVecClear(Msat_IntVec_t *p)
Definition msatVec.c:335
void Msat_SolverPrepare(Msat_Solver_t *pSat, Msat_IntVec_t *vVars)
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition msatVec.c:351
int Msat_SolverAddVar(Msat_Solver_t *p, int Level)
DECLARATIONS ///.
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Fraig_ManCheckMiter()

int Fraig_ManCheckMiter ( Fraig_Man_t * p)

Function*************************************************************

Synopsis [Returns 1 if the miter is unsat; 0 if sat; -1 if undecided.]

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file fraigSat.c.

131{
132 Fraig_Node_t * pNode;
133 int i;
134 ABC_FREE( p->pModel );
135 for ( i = 0; i < p->vOutputs->nSize; i++ )
136 {
137 // get the output node (it can be complemented!)
138 pNode = p->vOutputs->pArray[i];
139 // if the miter is constant 0, the problem is UNSAT
140 if ( pNode == Fraig_Not(p->pConst1) )
141 continue;
142 // consider the special case when the miter is constant 1
143 if ( pNode == p->pConst1 )
144 {
145 // in this case, any counter example will do to distinquish it from constant 0
146 // here we pick the counter example composed of all zeros
147 p->pModel = Fraig_ManAllocCounterExample( p );
148 return 0;
149 }
150 // save the counter example
151 p->pModel = Fraig_ManSaveCounterExample( p, pNode );
152 // if the model is not found, return undecided
153 if ( p->pModel == NULL )
154 return -1;
155 else
156 return 0;
157 }
158 return 1;
159}
#define ABC_FREE(obj)
Definition abc_global.h:267
int * Fraig_ManAllocCounterExample(Fraig_Man_t *p)
Definition fraigFeed.c:787
int * Fraig_ManSaveCounterExample(Fraig_Man_t *p, Fraig_Node_t *pNode)
Definition fraigFeed.c:860
#define Fraig_Not(p)
Definition fraig.h:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_ManProveMiter()

void Fraig_ManProveMiter ( Fraig_Man_t * p)

Function*************************************************************

Synopsis [Tries to prove the final miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file fraigSat.c.

86{
87 Fraig_Node_t * pNode;
88 int i;
89 abctime clk;
90
91 if ( !p->fTryProve )
92 return;
93
94 clk = Abc_Clock();
95 // consider all outputs of the multi-output miter
96 for ( i = 0; i < p->vOutputs->nSize; i++ )
97 {
98 pNode = Fraig_Regular(p->vOutputs->pArray[i]);
99 // skip already constant nodes
100 if ( pNode == p->pConst1 )
101 continue;
102 // skip nodes that are different according to simulation
103 if ( !Fraig_CompareSimInfo( pNode, p->pConst1, p->nWordsRand, 1 ) )
104 continue;
105 if ( Fraig_NodeIsEquivalent( p, p->pConst1, pNode, -1, p->nSeconds ) )
106 {
107 if ( Fraig_IsComplement(p->vOutputs->pArray[i]) ^ Fraig_NodeComparePhase(p->pConst1, pNode) )
108 p->vOutputs->pArray[i] = Fraig_Not(p->pConst1);
109 else
110 p->vOutputs->pArray[i] = p->pConst1;
111 }
112 }
113 if ( p->fVerboseP )
114 {
115// ABC_PRT( "Final miter proof time", Abc_Clock() - clk );
116 }
117}
int Fraig_CompareSimInfo(Fraig_Node_t *pNode1, Fraig_Node_t *pNode2, int iWordLast, int fUseRand)
Definition fraigTable.c:351
int Fraig_NodeIsEquivalent(Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit, int nTimeLimit)
Definition fraigSat.c:302
int Fraig_NodeComparePhase(Fraig_Node_t *p1, Fraig_Node_t *p2)
Definition fraigApi.c:154
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_MarkTfi2_rec()

int Fraig_MarkTfi2_rec ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )

Function*************************************************************

Synopsis [Returns 1 if pOld is in the TFI of pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 198 of file fraigSat.c.

199{
200 // skip the visited node
201 if ( pNode->TravId == pMan->nTravIds )
202 return 0;
203 // skip the boundary node
204 if ( pNode->TravId == pMan->nTravIds-1 )
205 {
206 pNode->TravId = pMan->nTravIds;
207 return 1;
208 }
209 pNode->TravId = pMan->nTravIds;
210 // skip the PI node
211 if ( pNode->NumPi >= 0 )
212 return 1;
213 // check the children
214 return Fraig_MarkTfi2_rec( pMan, Fraig_Regular(pNode->p1) ) +
215 Fraig_MarkTfi2_rec( pMan, Fraig_Regular(pNode->p2) );
216}
int Fraig_MarkTfi2_rec(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigSat.c:198
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_MarkTfi3_rec()

int Fraig_MarkTfi3_rec ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )

Function*************************************************************

Synopsis [Returns 1 if pOld is in the TFI of pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file fraigSat.c.

230{
231 // skip the visited node
232 if ( pNode->TravId == pMan->nTravIds )
233 return 1;
234 // skip the boundary node
235 if ( pNode->TravId == pMan->nTravIds-1 )
236 {
237 pNode->TravId = pMan->nTravIds;
238 return 1;
239 }
240 pNode->TravId = pMan->nTravIds;
241 // skip the PI node
242 if ( pNode->NumPi >= 0 )
243 return 0;
244 // check the children
245 return Fraig_MarkTfi3_rec( pMan, Fraig_Regular(pNode->p1) ) *
246 Fraig_MarkTfi3_rec( pMan, Fraig_Regular(pNode->p2) );
247}
int Fraig_MarkTfi3_rec(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigSat.c:229
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_MarkTfi_rec()

int Fraig_MarkTfi_rec ( Fraig_Man_t * pMan,
Fraig_Node_t * pNode )

Function*************************************************************

Synopsis [Returns 1 if pOld is in the TFI of pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file fraigSat.c.

174{
175 // skip the visited node
176 if ( pNode->TravId == pMan->nTravIds )
177 return 0;
178 pNode->TravId = pMan->nTravIds;
179 // skip the PI node
180 if ( pNode->NumPi >= 0 )
181 return 1;
182 // check the children
183 return Fraig_MarkTfi_rec( pMan, Fraig_Regular(pNode->p1) ) +
184 Fraig_MarkTfi_rec( pMan, Fraig_Regular(pNode->p2) );
185}
int Fraig_MarkTfi_rec(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigSat.c:173
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsEquivalent()

int Fraig_NodeIsEquivalent ( Fraig_Man_t * p,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew,
int nBTLimit,
int nTimeLimit )

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 []

Definition at line 302 of file fraigSat.c.

303{
304 int RetValue, RetValue1, i, fComp;
305 abctime clk;
306 int fVerbose = 0;
307 int fSwitch = 0;
308
309 // make sure the nodes are not complemented
310 assert( !Fraig_IsComplement(pNew) );
311 assert( !Fraig_IsComplement(pOld) );
312 assert( pNew != pOld );
313
314 // if at least one of the nodes is a failed node, perform adjustments:
315 // if the backtrack limit is small, simply skip this node
316 // if the backtrack limit is > 10, take the quare root of the limit
317 if ( nBTLimit > 0 && (pOld->fFailTfo || pNew->fFailTfo) )
318 {
319 p->nSatFails++;
320// return 0;
321// if ( nBTLimit > 10 )
322// nBTLimit /= 10;
323 if ( nBTLimit <= 10 )
324 return 0;
325 nBTLimit = (int)sqrt((double)nBTLimit);
326// fSwitch = 1;
327 }
328
329 p->nSatCalls++;
330
331 // make sure the solver is allocated and has enough variables
332 if ( p->pSat == NULL )
334 // make sure the SAT solver has enough variables
335 for ( i = Msat_SolverReadVarNum(p->pSat); i < p->vNodes->nSize; i++ )
336 Msat_SolverAddVar( p->pSat, p->vNodes->pArray[i]->Level );
337
338
339
340/*
341 {
342 Fraig_Node_t * ppNodes[2] = { pOld, pNew };
343 extern void Fraig_MappingShowNodes( Fraig_Man_t * pMan, Fraig_Node_t ** ppRoots, int nRoots, char * pFileName );
344 Fraig_MappingShowNodes( p, ppNodes, 2, "temp_aig" );
345 }
346*/
347
348 nMuxes = 0;
349
350
351 // get the logic cone
352clk = Abc_Clock();
353// Fraig_VarsStudy( p, pOld, pNew );
354 Fraig_OrderVariables( p, pOld, pNew );
355// Fraig_PrepareCones( p, pOld, pNew );
356p->timeTrav += Abc_Clock() - clk;
357
358// printf( "The number of MUXes detected = %d (%5.2f %% of logic). ", nMuxes, 300.0*nMuxes/(p->vNodes->nSize - p->vInputs->nSize) );
359// ABC_PRT( "Time", Abc_Clock() - clk );
360
361 if ( fVerbose )
362 printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) );
363
364
365 // prepare variable activity
366 Fraig_SetActivity( p, pOld, pNew );
367
368 // get the complemented attribute
369 fComp = Fraig_NodeComparePhase( pOld, pNew );
370//Msat_SolverPrintClauses( p->pSat );
371
373 // prepare the solver to run incrementally on these variables
374//clk = Abc_Clock();
375 Msat_SolverPrepare( p->pSat, p->vVarsInt );
376//p->time3 += Abc_Clock() - clk;
377
378
379 // solve under assumptions
380 // A = 1; B = 0 OR A = 1; B = 1
381 Msat_IntVecClear( p->vProj );
382 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) );
383 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) );
384
385//Msat_SolverWriteDimacs( p->pSat, "temp_fraig.cnf" );
386
387 // run the solver
388clk = Abc_Clock();
389 RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, nTimeLimit );
390p->timeSat += Abc_Clock() - clk;
391
392 if ( RetValue1 == MSAT_FALSE )
393 {
394//p->time1 += Abc_Clock() - clk;
395
396if ( fVerbose )
397{
398// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) );
399//ABC_PRT( "time", Abc_Clock() - clk );
400}
401
402 // add the clause
403 Msat_IntVecClear( p->vProj );
404 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) );
405 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) );
406 RetValue = Msat_SolverAddClause( p->pSat, p->vProj );
407 assert( RetValue );
408 // continue solving the other implication
409 }
410 else if ( RetValue1 == MSAT_TRUE )
411 {
412//p->time2 += Abc_Clock() - clk;
413
414if ( fVerbose )
415{
416// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) );
417//ABC_PRT( "time", Abc_Clock() - clk );
418}
419
420 // record the counter example
421 Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew );
422
423// if ( pOld->fFailTfo || pNew->fFailTfo )
424// printf( "*" );
425// printf( "s(%d)", pNew->Level );
426 if ( fSwitch )
427 printf( "s(%d)", pNew->Level );
428 p->nSatCounter++;
429 return 0;
430 }
431 else // if ( RetValue1 == MSAT_UNKNOWN )
432 {
433p->time3 += Abc_Clock() - clk;
434
435// if ( pOld->fFailTfo || pNew->fFailTfo )
436// printf( "*" );
437// printf( "T(%d)", pNew->Level );
438
439 // mark the node as the failed node
440 if ( pOld != p->pConst1 )
441 pOld->fFailTfo = 1;
442 pNew->fFailTfo = 1;
443// p->nSatFails++;
444 if ( fSwitch )
445 printf( "T(%d)", pNew->Level );
446 p->nSatFailsReal++;
447 return 0;
448 }
449
450 // if the old node was constant 0, we already know the answer
451 if ( pOld == p->pConst1 )
452 return 1;
453
455 // prepare the solver to run incrementally
456//clk = Abc_Clock();
457 Msat_SolverPrepare( p->pSat, p->vVarsInt );
458//p->time3 += Abc_Clock() - clk;
459 // solve under assumptions
460 // A = 0; B = 1 OR A = 0; B = 0
461 Msat_IntVecClear( p->vProj );
462 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) );
463 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) );
464 // run the solver
465clk = Abc_Clock();
466 RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, nTimeLimit );
467p->timeSat += Abc_Clock() - clk;
468
469 if ( RetValue1 == MSAT_FALSE )
470 {
471//p->time1 += Abc_Clock() - clk;
472
473if ( fVerbose )
474{
475// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) );
476//ABC_PRT( "time", Abc_Clock() - clk );
477}
478
479 // add the clause
480 Msat_IntVecClear( p->vProj );
481 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) );
482 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) );
483 RetValue = Msat_SolverAddClause( p->pSat, p->vProj );
484 assert( RetValue );
485 // continue solving the other implication
486 }
487 else if ( RetValue1 == MSAT_TRUE )
488 {
489//p->time2 += Abc_Clock() - clk;
490
491if ( fVerbose )
492{
493// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) );
494//ABC_PRT( "time", Abc_Clock() - clk );
495}
496
497 // record the counter example
498 Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew );
499 p->nSatCounter++;
500
501// if ( pOld->fFailTfo || pNew->fFailTfo )
502// printf( "*" );
503// printf( "s(%d)", pNew->Level );
504 if ( fSwitch )
505 printf( "s(%d)", pNew->Level );
506 return 0;
507 }
508 else // if ( RetValue1 == MSAT_UNKNOWN )
509 {
510p->time3 += Abc_Clock() - clk;
511
512// if ( pOld->fFailTfo || pNew->fFailTfo )
513// printf( "*" );
514// printf( "T(%d)", pNew->Level );
515 if ( fSwitch )
516 printf( "T(%d)", pNew->Level );
517
518 // mark the node as the failed node
519 pOld->fFailTfo = 1;
520 pNew->fFailTfo = 1;
521// p->nSatFails++;
522 p->nSatFailsReal++;
523 return 0;
524 }
525
526 // return SAT proof
527 p->nSatProof++;
528
529// if ( pOld->fFailTfo || pNew->fFailTfo )
530// printf( "*" );
531// printf( "u(%d)", pNew->Level );
532
533 if ( fSwitch )
534 printf( "u(%d)", pNew->Level );
535
536 return 1;
537}
void Fraig_FeedBack(Fraig_Man_t *p, int *pModel, Msat_IntVec_t *vVars, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigFeed.c:80
int Fraig_CountPis(Fraig_Man_t *p, Msat_IntVec_t *vVarNums)
Definition fraigUtil.c:817
int * Msat_SolverReadModelArray(Msat_Solver_t *p)
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodeIsImplification()

int Fraig_NodeIsImplification ( Fraig_Man_t * p,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew,
int nBTLimit )

Function*************************************************************

Synopsis [Checks whether pOld => pNew.]

Description []

SideEffects []

SeeAlso []

Definition at line 551 of file fraigSat.c.

552{
553 int RetValue, RetValue1, i, fComp;
554 abctime clk;
555 int fVerbose = 0;
556
557 // make sure the nodes are not complemented
558 assert( !Fraig_IsComplement(pNew) );
559 assert( !Fraig_IsComplement(pOld) );
560 assert( pNew != pOld );
561
562 p->nSatCallsImp++;
563
564 // make sure the solver is allocated and has enough variables
565 if ( p->pSat == NULL )
567 // make sure the SAT solver has enough variables
568 for ( i = Msat_SolverReadVarNum(p->pSat); i < p->vNodes->nSize; i++ )
569 Msat_SolverAddVar( p->pSat, p->vNodes->pArray[i]->Level );
570
571 // get the logic cone
572clk = Abc_Clock();
573 Fraig_OrderVariables( p, pOld, pNew );
574// Fraig_PrepareCones( p, pOld, pNew );
575p->timeTrav += Abc_Clock() - clk;
576
577 if ( fVerbose )
578 printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) );
579
580
581 // get the complemented attribute
582 fComp = Fraig_NodeComparePhase( pOld, pNew );
583//Msat_SolverPrintClauses( p->pSat );
584
586 // prepare the solver to run incrementally on these variables
587//clk = Abc_Clock();
588 Msat_SolverPrepare( p->pSat, p->vVarsInt );
589//p->time3 += Abc_Clock() - clk;
590
591 // solve under assumptions
592 // A = 1; B = 0 OR A = 1; B = 1
593 Msat_IntVecClear( p->vProj );
594 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 0) );
595 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, !fComp) );
596 // run the solver
597clk = Abc_Clock();
598 RetValue1 = Msat_SolverSolve( p->pSat, p->vProj, nBTLimit, 1000000 );
599p->timeSat += Abc_Clock() - clk;
600
601 if ( RetValue1 == MSAT_FALSE )
602 {
603//p->time1 += Abc_Clock() - clk;
604
605if ( fVerbose )
606{
607// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) );
608//ABC_PRT( "time", Abc_Clock() - clk );
609}
610
611 // add the clause
612 Msat_IntVecClear( p->vProj );
613 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pOld->Num, 1) );
614 Msat_IntVecPush( p->vProj, MSAT_VAR2LIT(pNew->Num, fComp) );
615 RetValue = Msat_SolverAddClause( p->pSat, p->vProj );
616 assert( RetValue );
617// p->nSatProofImp++;
618 return 1;
619 }
620 else if ( RetValue1 == MSAT_TRUE )
621 {
622//p->time2 += Abc_Clock() - clk;
623
624if ( fVerbose )
625{
626// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) );
627//ABC_PRT( "time", Abc_Clock() - clk );
628}
629 // record the counter example
630 Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew );
631 p->nSatCounterImp++;
632 return 0;
633 }
634 else // if ( RetValue1 == MSAT_UNKNOWN )
635 {
636p->time3 += Abc_Clock() - clk;
637 p->nSatFailsImp++;
638 return 0;
639 }
640}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fraig_NodesAreEqual()

int Fraig_NodesAreEqual ( Fraig_Man_t * p,
Fraig_Node_t * pNode1,
Fraig_Node_t * pNode2,
int nBTLimit,
int nTimeLimit )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Checks equivalence of two nodes.]

Description [Returns 1 iff the nodes are equivalent.]

SideEffects []

SeeAlso []

Definition at line 65 of file fraigSat.c.

66{
67 if ( pNode1 == pNode2 )
68 return 1;
69 if ( pNode1 == Fraig_Not(pNode2) )
70 return 0;
71 return Fraig_NodeIsEquivalent( p, Fraig_Regular(pNode1), Fraig_Regular(pNode2), nBTLimit, nTimeLimit );
72}
Here is the call graph for this function:

◆ Fraig_VarsStudy()

void Fraig_VarsStudy ( Fraig_Man_t * p,
Fraig_Node_t * pOld,
Fraig_Node_t * pNew )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 260 of file fraigSat.c.

261{
262 int NumPis, NumCut, fContain;
263
264 // mark the TFI of pNew
265 p->nTravIds++;
266 NumPis = Fraig_MarkTfi_rec( p, pNew );
267 printf( "(%d)(%d,%d):", NumPis, pOld->Level, pNew->Level );
268
269 // check if the old is in the TFI
270 if ( pOld->TravId == p->nTravIds )
271 {
272 printf( "* " );
273 return;
274 }
275
276 // count the boundary of nodes in pOld
277 p->nTravIds++;
278 NumCut = Fraig_MarkTfi2_rec( p, pOld );
279 printf( "%d", NumCut );
280
281 // check if the new is contained in the old's support
282 p->nTravIds++;
283 fContain = Fraig_MarkTfi3_rec( p, pNew );
284 printf( "%c ", fContain? '+':'-' );
285}
Here is the call graph for this function: