59static inline int Proof_NodeWordNum (
int nEnts ) {
assert( nEnts > 0 );
return 1 + ((nEnts + 1) >> 1); }
64#define Proof_ForeachClauseVec( pVec, p, pNode, i ) \
65 for ( i = 0; (i < Vec_IntSize(pVec)) && ((pNode) = Proof_ClauseRead(p, Vec_IntEntry(pVec,i))); i++ )
66#define Proof_ForeachNodeVec( pVec, p, pNode, i ) \
67 for ( i = 0; (i < Vec_IntSize(pVec)) && ((pNode) = Proof_NodeRead(p, Vec_IntEntry(pVec,i))); i++ )
68#define Proof_ForeachNodeVec1( pVec, p, pNode, i ) \
69 for ( i = 1; (i < Vec_IntSize(pVec)) && ((pNode) = Proof_NodeRead(p, Vec_IntEntry(pVec,i))); i++ )
72#define Proof_NodeForeachFanin( pProof, pNode, pFanin, i ) \
73 for ( i = 0; (i < (int)pNode->nEnts) && (((pFanin) = (pNode->pEnts[i] & 1) ? NULL : Proof_NodeRead(pProof, pNode->pEnts[i] >> 2)), 1); i++ )
117 satset * pNext, * pNode = Proof_NodeRead( vProof, hNode );
123 Vec_IntPush( vStack, hNode << 1 );
125 while ( Vec_IntSize(vStack) )
127 hNode = Vec_IntPop( vStack );
130 Vec_IntPush( vUsed, hNode >> 1 );
134 Vec_IntPush( vStack, hNode ^ 1 );
136 pNode = Proof_NodeRead( vProof, hNode >> 1 );
138 if ( pNext && !pNext->Id )
141 Vec_IntPush( vStack, (pNode->pEnts[i] >> 2) << 1 );
150 int i, Entry, iPrev = 0;
151 vUsed = Vec_IntAlloc( 1000 );
152 vStack = Vec_IntAlloc( 1000 );
156 Vec_IntFree( vStack );
167 if ( iPrev >= Entry )
168 printf(
"Out of topological order!!!\n" );
189 satset * pNext, * pNode = Proof_NodeRead( vProof, hNode );
195 if ( pNext && !pNext->Id )
197 Vec_IntPush( vUsed, hNode );
203 vUsed = Vec_IntAlloc( 1000 );
223 satset * pNext, * pNode = Proof_NodeRead( vProof, hNode );
229 if ( pNext && !pNext->Id )
235 int i, Entry, Counter = 0;
377 nSize = Vec_SetWordNum( 2 + pNode->nEnts );
379 assert( (pNode->pEnts[k] >> 2) );
391 satset * pNode, * pFanin, * pPivot;
392 int i, j, k, hTemp, nSize;
400 vUsed = Vec_PtrAlloc( nSize );
404 Vec_SetShrinkS( vProof, 2 );
407 nSize = Vec_SetWordNum( 2 + pNode->nEnts );
408 if ( pNode->Id == 0 )
410 pNode->Id = Vec_SetAppendS( vProof, 2 + pNode->nEnts );
412 Vec_PtrPush( vUsed, pNode );
415 if ( (pNode->pEnts[k] & 1) == 0 )
418 pNode->pEnts[k] = (pFanin->Id << 2) | (pNode->pEnts[k] & 2);
425 Vec_IntWriteEntry( vRoots, i, pNode->Id );
427 assert( hProofPivot >= 1 && hProofPivot <= Vec_SetHandCurrent(vProof) );
428 pPivot = Proof_NodeRead( vProof, hProofPivot );
429 RetValue = Vec_SetHandCurrentS(vProof);
433 hTemp = pNode->Id; pNode->Id = 0;
434 memmove( Vec_SetEntry(vProof, hTemp), pNode,
sizeof(
word)*Proof_NodeWordNum(pNode->nEnts) );
435 if ( pPivot && pPivot <= pNode )
441 Vec_SetWriteEntryNum( vProof, Vec_PtrSize(vUsed) );
442 Vec_PtrFree( vUsed );
448 printf(
"The proof was reduced from %6.2f MB to %6.2f MB (by %6.2f %%) ",
449 1.0 * Vec_SetMemory(vProof) / (1<<20), 1.0 * Vec_SetMemoryS(vProof) / (1<<20),
450 100.0 * (Vec_SetMemory(vProof) - Vec_SetMemoryS(vProof)) / Vec_SetMemory(vProof) );
451 TimeTotal += Abc_Clock() - clk;
452 Abc_PrintTime( 1,
"Time", TimeTotal );
454 Vec_SetShrink( vProof, Vec_SetHandCurrentS(vProof) );
455 Vec_SetShrinkLimits( vProof );
478 int h, i, k,
Var = -1, Count = 0;
480 for ( i = 0; i < (int)c1->nEnts; i++ )
481 for ( k = 0; k < (int)c2->nEnts; k++ )
482 if ( (c1->pEnts[i] ^ c2->pEnts[k]) == 1 )
484 Var = (c1->pEnts[i] >> 1);
489 printf(
"Cannot find resolution variable\n" );
494 printf(
"Found more than 1 resolution variables\n" );
498 Vec_IntClear( vTemp );
499 Vec_IntPush( vTemp, 0 );
500 Vec_IntPush( vTemp, 0 );
501 for ( i = 0; i < (int)c1->nEnts; i++ )
502 if ( (c1->pEnts[i] >> 1) !=
Var )
503 Vec_IntPush( vTemp, c1->pEnts[i] );
504 for ( i = 0; i < (int)c2->nEnts; i++ )
505 if ( (c2->pEnts[i] >> 1) !=
Var )
506 Vec_IntPushUnique( vTemp, c2->pEnts[i] );
508 h = Vec_SetAppend(
p, Vec_IntArray(vTemp), Vec_IntSize(vTemp) );
510 c = Proof_NodeRead(
p, h );
511 c->nEnts = Vec_IntSize(vTemp)-2;
530 return Proof_ClauseRead( vClauses, iAnt >> 2 );
532 pAnt = Proof_NodeRead( vProof, iAnt >> 2 );
534 return Proof_NodeRead( vResolves, pAnt->Id );
552 Vec_Int_t Roots = { 1, 1, &s->hProofLast }, * vRoots = &Roots;
555 satset * pSet, * pSet0 = NULL, * pSet1;
556 int i, k, hRoot, Handle, Counter = 0;
558 hRoot = s->hProofLast;
565 vTemp = Vec_IntAlloc( 1000 );
566 vResolves = Vec_SetAlloc( 20 );
570 pSet0 = Sat_ProofCheckReadOne( vClauses, vProof, vResolves, pSet->pEnts[0] );
571 for ( k = 1; k < (int)pSet->nEnts; k++ )
573 pSet1 = Sat_ProofCheckReadOne( vClauses, vProof, vResolves, pSet->pEnts[k] );
574 Handle = Sat_ProofCheckResolveOne( vResolves, pSet0, pSet1, vTemp );
575 pSet0 = Proof_NodeRead( vResolves, Handle );
580 Vec_IntFree( vTemp );
584 printf(
"Used %6.2f MB for resolvents.\n", 1.0 * Vec_SetMemory(vResolves) / (1<<20) );
585 if ( pSet0->nEnts > 0 )
586 printf(
"Derived clause with %d lits instead of the empty clause. ", pSet0->nEnts );
588 printf(
"Proof verification successful. " );
589 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
591 Vec_SetFree( vResolves );
592 Vec_IntFree( vUsed );
612 int i, k, MaxCla = 0;
616 if ( pFanin == NULL )
617 MaxCla = Abc_MaxInt( MaxCla, pNode->pEnts[k] >> 2 );
619 pBitMap =
ABC_CALLOC(
unsigned, Abc_BitWordNum(MaxCla) + 1 );
621 vCore = Vec_IntAlloc( 1000 );
624 if ( pFanin == NULL )
626 int Entry = (pNode->pEnts[k] >> 2);
627 if ( Abc_InfoHasBit(pBitMap, Entry) )
629 Abc_InfoSetBit(pBitMap, Entry);
630 Vec_IntPush( vCore, Entry );
654 int i, k, Entry, * pMask;
657 vVarMap = Vec_IntStart( s->
size );
658 sat_solver_foreach_clause( s, c, i )
659 for ( k = 0; k < (int)c->nEnts; k++ )
660 *Vec_IntEntryP(vVarMap, lit_var(c->pEnts[k])) |= 2 - c->partA;
664 pMask = Vec_IntEntryP(vVarMap, Entry);
665 assert( *pMask >= 0 && *pMask <= 3 );
666 Counts[(*pMask & 3)]++;
673 Vec_IntFree( vVarMap );
676 printf(
"Warning: %6d variables listed as global do not appear in clauses (this is normal)\n", Counts[0] );
678 printf(
"Warning: %6d variables listed as global appear only in A-clauses (this is a BUG)\n", Counts[1] );
680 printf(
"Warning: %6d variables listed as global appear only in B-clauses (this is a BUG)\n", Counts[2] );
682 printf(
"Warning: %6d (out of %d) variables listed as global appear in both A- and B-clauses (this is normal)\n", Counts[3], Vec_IntSize(vGloVars) );
684 printf(
"Warning: %6d variables not listed as global appear in both A- and B-clauses (this is a BUG)\n", Counts[4] );
704 Vec_Int_t * vUsed, * vCore, * vCoreNums, * vVarMap;
708 int i, k, iVar, Lit, Entry, hRoot;
716 Sat_ProofInterpolantCheckVars( s, vGlobVars );
725 vVarMap = Vec_IntStartFull( s->
size );
727 Vec_IntWriteEntry( vVarMap, Entry, i );
731 pAig->pName = Abc_UtilStrsav(
"interpol" );
732 for ( i = 0; i < Vec_IntSize(vGlobVars); i++ )
736 vCoreNums = Vec_IntAlloc( Vec_IntSize(vCore) );
741 pObj = Aig_ManConst0( pAig );
742 satset_foreach_lit( pNode, Lit, k, 0 )
743 if ( (iVar = Vec_IntEntry(vVarMap, lit_var(Lit))) >= 0 )
744 pObj =
Aig_Or( pAig, pObj, Aig_NotCond(
Aig_IthVar(pAig, iVar), lit_sign(Lit)) );
747 pObj = Aig_ManConst1( pAig );
749 Vec_IntPush( vCoreNums, pNode->Id );
750 pNode->Id = Aig_ObjToLit(pObj);
752 Vec_IntFree( vVarMap );
758 assert( pNode->nEnts > 1 );
759 Proof_NodeForeachFaninLeaf( vProof, vClauses, pNode, pFanin, k )
761 assert( pFanin->Id < 2*Aig_ManObjNumMax(pAig) );
763 pObj = Aig_ObjFromLit( pAig, pFanin->Id );
764 else if ( pNode->pEnts[k] & 2 )
765 pObj =
Aig_Or( pAig, pObj, Aig_ObjFromLit(pAig, pFanin->Id) );
767 pObj =
Aig_And( pAig, pObj, Aig_ObjFromLit(pAig, pFanin->Id) );
770 pNode->Id = Aig_ObjToLit(pObj);
779 pNode->Id = Vec_IntEntry( vCoreNums, i );
783 Vec_IntFree( vCore );
784 Vec_IntFree( vUsed );
785 Vec_IntFree( vCoreNums );
807 Vec_Int_t * vUsed, * vCore, * vCoreNums, * vVarMap;
810 int nVars = Vec_IntSize(vGlobVars);
811 int nWords = (nVars < 6) ? 1 : (1 << (nVars-6));
813 int i, k, iVar, Lit, Entry, hRoot;
814 assert( nVars > 0 && nVars <= 16 );
819 Sat_ProofInterpolantCheckVars( s, vGlobVars );
828 vVarMap = Vec_IntStartFull( s->
size );
830 Vec_IntWriteEntry( vVarMap, Entry, i );
836 vCoreNums = Vec_IntAlloc( Vec_IntSize(vCore) );
842 Tru_ManClear( pRes,
nWords );
843 satset_foreach_lit( pNode, Lit, k, 0 )
844 if ( (iVar = Vec_IntEntry(vVarMap, lit_var(Lit))) >= 0 )
846 pRes = Tru_ManOrNotCond( pRes,
Tru_ManVar(pTru, iVar),
nWords, lit_sign(Lit) );
850 Tru_ManFill( pRes,
nWords );
852 Vec_IntPush( vCoreNums, pNode->Id );
856 Vec_IntFree( vVarMap );
862 assert( pNode->nEnts > 1 );
863 Proof_NodeForeachFaninLeaf( vProof, vClauses, pNode, pFanin, k )
869 pRes = Tru_ManCopyNotCond( pRes,
Tru_ManFunc(pTru, pFanin->Id & ~1),
nWords, pFanin->Id & 1 );
870 else if ( pNode->pEnts[k] & 2 )
872 pRes = Tru_ManOrNotCond( pRes,
Tru_ManFunc(pTru, pFanin->Id & ~1),
nWords, pFanin->Id & 1 );
875 pRes = Tru_ManAndNotCond( pRes,
Tru_ManFunc(pTru, pFanin->Id & ~1),
nWords, pFanin->Id & 1 );
888 pNode->Id = Vec_IntEntry( vCoreNums, i );
892 Vec_IntFree( vCore );
893 Vec_IntFree( vUsed );
894 Vec_IntFree( vCoreNums );
915 Vec_Int_t Roots = { 1, 1, &hRoot }, * vRoots = &Roots;
923 Vec_IntFree( vUsed );
924 Vec_IntSort( vCore, 1 );
void Abc_MergeSort(int *pInput, int nSize)
#define ABC_ALLOC(type, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
struct Aig_Obj_t_ Aig_Obj_t
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
int Aig_ManCleanup(Aig_Man_t *p)
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
unsigned __int64 word
DECLARATIONS ///.
void Proof_CollectUsed_iter(Vec_Set_t *vProof, int hNode, Vec_Int_t *vUsed, Vec_Int_t *vStack)
int Sat_ProofReduce(Vec_Set_t *vProof, void *pRoots, int hProofPivot)
void Proof_CollectUsed_rec(Vec_Set_t *vProof, int hNode, Vec_Int_t *vUsed)
#define Proof_ForeachNodeVec1(pVec, p, pNode, i)
Vec_Int_t * Proof_CollectUsedRec(Vec_Set_t *vProof, Vec_Int_t *vRoots)
Vec_Int_t * Proof_CollectUsedIter(Vec_Set_t *vProof, Vec_Int_t *vRoots, int fSort)
int Proof_MarkUsed_rec(Vec_Set_t *vProof, int hNode)
void Proof_ClauseSetEnts(Vec_Set_t *p, int h, int nEnts)
void Proof_CleanCollected(Vec_Set_t *vProof, Vec_Int_t *vUsed)
FUNCTION DEFINITIONS ///.
int Proof_MarkUsedRec(Vec_Set_t *vProof, Vec_Int_t *vRoots)
void * Proof_DeriveCore(Vec_Set_t *vProof, int hRoot)
#define Proof_ForeachClauseVec(pVec, p, pNode, i)
#define Proof_NodeForeachFanin(pProof, pNode, pFanin, i)
typedefABC_NAMESPACE_IMPL_START struct satset_t satset
#define Proof_ForeachNodeVec(pVec, p, pNode, i)
Vec_Int_t * Sat_ProofCollectCore(Vec_Set_t *vProof, Vec_Int_t *vUsed)
void Sat_ProofCheck0(Vec_Set_t *vProof)
word * Sat_ProofInterpolantTruth(sat_solver2 *s, void *pGloVars)
struct sat_solver2_t sat_solver2
void Sat_ProofCheck(sat_solver2 *s)
void * Sat_ProofInterpolant(sat_solver2 *s, void *pGloVars)
Tru_Man_t * Tru_ManAlloc(int nVars)
FUNCTION DECLARATIONS ///.
word * Tru_ManVar(Tru_Man_t *p, int v)
int Tru_ManInsert(Tru_Man_t *p, word *pTruth)
word * Tru_ManFunc(Tru_Man_t *p, int h)
void Tru_ManFree(Tru_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Tru_Man_t_ Tru_Man_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Set_t_ Vec_Set_t
INCLUDES ///.
#define Vec_SetForEachEntry(Type, pVec, nSize, pSet, p, s)