ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
satProof.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "misc/vec/vecSet.h"
#include "aig/aig/aig.h"
#include "satTruth.h"
Include dependency graph for satProof.c:

Go to the source code of this file.

Classes

struct  satset_t
 

Macros

#define Proof_ForeachClauseVec(pVec, p, pNode, i)
 
#define Proof_ForeachNodeVec(pVec, p, pNode, i)
 
#define Proof_ForeachNodeVec1(pVec, p, pNode, i)
 
#define Proof_NodeForeachFanin(pProof, pNode, pFanin, i)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct satset_t satset
 

Functions

void Proof_ClauseSetEnts (Vec_Set_t *p, int h, int nEnts)
 
void Proof_CleanCollected (Vec_Set_t *vProof, Vec_Int_t *vUsed)
 FUNCTION DEFINITIONS ///.
 
void Proof_CollectUsed_iter (Vec_Set_t *vProof, int hNode, Vec_Int_t *vUsed, Vec_Int_t *vStack)
 
Vec_Int_tProof_CollectUsedIter (Vec_Set_t *vProof, Vec_Int_t *vRoots, int fSort)
 
void Proof_CollectUsed_rec (Vec_Set_t *vProof, int hNode, Vec_Int_t *vUsed)
 
Vec_Int_tProof_CollectUsedRec (Vec_Set_t *vProof, Vec_Int_t *vRoots)
 
int Proof_MarkUsed_rec (Vec_Set_t *vProof, int hNode)
 
int Proof_MarkUsedRec (Vec_Set_t *vProof, Vec_Int_t *vRoots)
 
void Sat_ProofCheck0 (Vec_Set_t *vProof)
 
int Sat_ProofReduce (Vec_Set_t *vProof, void *pRoots, int hProofPivot)
 
Vec_Int_tSat_ProofCollectCore (Vec_Set_t *vProof, Vec_Int_t *vUsed)
 
void * Proof_DeriveCore (Vec_Set_t *vProof, int hRoot)
 

Macro Definition Documentation

◆ Proof_ForeachClauseVec

#define Proof_ForeachClauseVec ( pVec,
p,
pNode,
i )
Value:
for ( i = 0; (i < Vec_IntSize(pVec)) && ((pNode) = Proof_ClauseRead(p, Vec_IntEntry(pVec,i))); i++ )
Cube * p
Definition exorList.c:222

Definition at line 64 of file satProof.c.

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++ )

◆ Proof_ForeachNodeVec

#define Proof_ForeachNodeVec ( pVec,
p,
pNode,
i )
Value:
for ( i = 0; (i < Vec_IntSize(pVec)) && ((pNode) = Proof_NodeRead(p, Vec_IntEntry(pVec,i))); i++ )

Definition at line 66 of file satProof.c.

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++ )

◆ Proof_ForeachNodeVec1

#define Proof_ForeachNodeVec1 ( pVec,
p,
pNode,
i )
Value:
for ( i = 1; (i < Vec_IntSize(pVec)) && ((pNode) = Proof_NodeRead(p, Vec_IntEntry(pVec,i))); i++ )

Definition at line 68 of file satProof.c.

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++ )

◆ Proof_NodeForeachFanin

#define Proof_NodeForeachFanin ( pProof,
pNode,
pFanin,
i )
Value:
for ( i = 0; (i < (int)pNode->nEnts) && (((pFanin) = (pNode->pEnts[i] & 1) ? NULL : Proof_NodeRead(pProof, pNode->pEnts[i] >> 2)), 1); i++ )

Definition at line 72 of file satProof.c.

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++ )

Typedef Documentation

◆ satset

typedef typedefABC_NAMESPACE_IMPL_START struct satset_t satset

CFile****************************************************************

FileName [satProof.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT solver.]

Synopsis [Proof manipulation procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
satProof.c,v 1.4 2005/09/16 22:55:03 casem Exp

]

Definition at line 41 of file satProof.c.

Function Documentation

◆ Proof_ClauseSetEnts()

void Proof_ClauseSetEnts ( Vec_Set_t * p,
int h,
int nEnts )

Definition at line 61 of file satProof.c.

61{ Proof_NodeRead(p, h)->nEnts = nEnts; }

◆ Proof_CleanCollected()

void Proof_CleanCollected ( Vec_Set_t * vProof,
Vec_Int_t * vUsed )

FUNCTION DEFINITIONS ///.

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

Synopsis [Cleans collected resultion nodes belonging to the proof.]

Description []

SideEffects []

SeeAlso []

Definition at line 96 of file satProof.c.

97{
98 satset * pNode;
99 int hNode;
100 Proof_ForeachNodeVec( vUsed, vProof, pNode, hNode )
101 pNode->Id = 0;
102}
typedefABC_NAMESPACE_IMPL_START struct satset_t satset
Definition satProof.c:41
#define Proof_ForeachNodeVec(pVec, p, pNode, i)
Definition satProof.c:66

◆ Proof_CollectUsed_iter()

void Proof_CollectUsed_iter ( Vec_Set_t * vProof,
int hNode,
Vec_Int_t * vUsed,
Vec_Int_t * vStack )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file satProof.c.

116{
117 satset * pNext, * pNode = Proof_NodeRead( vProof, hNode );
118 int i;
119 if ( pNode->Id )
120 return;
121 // start with node
122 pNode->Id = 1;
123 Vec_IntPush( vStack, hNode << 1 );
124 // perform DFS search
125 while ( Vec_IntSize(vStack) )
126 {
127 hNode = Vec_IntPop( vStack );
128 if ( hNode & 1 ) // extracted second time
129 {
130 Vec_IntPush( vUsed, hNode >> 1 );
131 continue;
132 }
133 // extracted first time
134 Vec_IntPush( vStack, hNode ^ 1 ); // add second time
135 // add its anticedents ;
136 pNode = Proof_NodeRead( vProof, hNode >> 1 );
137 Proof_NodeForeachFanin( vProof, pNode, pNext, i )
138 if ( pNext && !pNext->Id )
139 {
140 pNext->Id = 1;
141 Vec_IntPush( vStack, (pNode->pEnts[i] >> 2) << 1 ); // add first time
142 }
143 }
144}
#define Proof_NodeForeachFanin(pProof, pNode, pFanin, i)
Definition satProof.c:72
Here is the caller graph for this function:

◆ Proof_CollectUsed_rec()

void Proof_CollectUsed_rec ( Vec_Set_t * vProof,
int hNode,
Vec_Int_t * vUsed )

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

Synopsis [Recursively collects useful proof nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file satProof.c.

188{
189 satset * pNext, * pNode = Proof_NodeRead( vProof, hNode );
190 int i;
191 if ( pNode->Id )
192 return;
193 pNode->Id = 1;
194 Proof_NodeForeachFanin( vProof, pNode, pNext, i )
195 if ( pNext && !pNext->Id )
196 Proof_CollectUsed_rec( vProof, pNode->pEnts[i] >> 2, vUsed );
197 Vec_IntPush( vUsed, hNode );
198}
void Proof_CollectUsed_rec(Vec_Set_t *vProof, int hNode, Vec_Int_t *vUsed)
Definition satProof.c:187
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Proof_CollectUsedIter()

Vec_Int_t * Proof_CollectUsedIter ( Vec_Set_t * vProof,
Vec_Int_t * vRoots,
int fSort )

Definition at line 145 of file satProof.c.

146{
147 int fVerify = 0;
148 Vec_Int_t * vUsed, * vStack;
149 abctime clk = Abc_Clock();
150 int i, Entry, iPrev = 0;
151 vUsed = Vec_IntAlloc( 1000 );
152 vStack = Vec_IntAlloc( 1000 );
153 Vec_IntForEachEntry( vRoots, Entry, i )
154 if ( Entry >= 0 )
155 Proof_CollectUsed_iter( vProof, Entry, vUsed, vStack );
156 Vec_IntFree( vStack );
157// Abc_PrintTime( 1, "Iterative clause collection time", Abc_Clock() - clk );
158 clk = Abc_Clock();
159 Abc_MergeSort( Vec_IntArray(vUsed), Vec_IntSize(vUsed) );
160// Abc_PrintTime( 1, "Postprocessing with sorting time", Abc_Clock() - clk );
161 // verify topological order
162 if ( fVerify )
163 {
164 iPrev = 0;
165 Vec_IntForEachEntry( vUsed, Entry, i )
166 {
167 if ( iPrev >= Entry )
168 printf( "Out of topological order!!!\n" );
169 assert( iPrev < Entry );
170 iPrev = Entry;
171 }
172 }
173 return vUsed;
174}
ABC_INT64_T abctime
Definition abc_global.h:332
void Abc_MergeSort(int *pInput, int nSize)
Definition utilSort.c:129
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Proof_CollectUsed_iter(Vec_Set_t *vProof, int hNode, Vec_Int_t *vUsed, Vec_Int_t *vStack)
Definition satProof.c:115
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Proof_CollectUsedRec()

Vec_Int_t * Proof_CollectUsedRec ( Vec_Set_t * vProof,
Vec_Int_t * vRoots )

Definition at line 199 of file satProof.c.

200{
201 Vec_Int_t * vUsed;
202 int i, Entry;
203 vUsed = Vec_IntAlloc( 1000 );
204 Vec_IntForEachEntry( vRoots, Entry, i )
205 if ( Entry >= 0 )
206 Proof_CollectUsed_rec( vProof, Entry, vUsed );
207 return vUsed;
208}
Here is the call graph for this function:

◆ Proof_DeriveCore()

void * Proof_DeriveCore ( Vec_Set_t * vProof,
int hRoot )

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

Synopsis [Computes UNSAT core.]

Description [The result is the array of root clause indexes.]

SideEffects []

SeeAlso []

Definition at line 913 of file satProof.c.

914{
915 Vec_Int_t Roots = { 1, 1, &hRoot }, * vRoots = &Roots;
916 Vec_Int_t * vCore, * vUsed;
917 if ( hRoot == -1 )
918 return NULL;
919 // collect visited clauses
920 vUsed = Proof_CollectUsedIter( vProof, vRoots, 0 );
921 // collect core clauses
922 vCore = Sat_ProofCollectCore( vProof, vUsed );
923 Vec_IntFree( vUsed );
924 Vec_IntSort( vCore, 1 );
925 return vCore;
926}
Vec_Int_t * Proof_CollectUsedIter(Vec_Set_t *vProof, Vec_Int_t *vRoots, int fSort)
Definition satProof.c:145
Vec_Int_t * Sat_ProofCollectCore(Vec_Set_t *vProof, Vec_Int_t *vUsed)
Definition satProof.c:607
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Proof_MarkUsed_rec()

int Proof_MarkUsed_rec ( Vec_Set_t * vProof,
int hNode )

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

Synopsis [Recursively visits useful proof nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file satProof.c.

222{
223 satset * pNext, * pNode = Proof_NodeRead( vProof, hNode );
224 int i, Counter = 1;
225 if ( pNode->Id )
226 return 0;
227 pNode->Id = 1;
228 Proof_NodeForeachFanin( vProof, pNode, pNext, i )
229 if ( pNext && !pNext->Id )
230 Counter += Proof_MarkUsed_rec( vProof, pNode->pEnts[i] >> 2 );
231 return Counter;
232}
int Proof_MarkUsed_rec(Vec_Set_t *vProof, int hNode)
Definition satProof.c:221
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Proof_MarkUsedRec()

int Proof_MarkUsedRec ( Vec_Set_t * vProof,
Vec_Int_t * vRoots )

Definition at line 233 of file satProof.c.

234{
235 int i, Entry, Counter = 0;
236 Vec_IntForEachEntry( vRoots, Entry, i )
237 if ( Entry >= 0 )
238 Counter += Proof_MarkUsed_rec( vProof, Entry );
239 return Counter;
240}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sat_ProofCheck0()

void Sat_ProofCheck0 ( Vec_Set_t * vProof)

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

Synopsis [Checks the validity of the check point.]

Description []

SideEffects []

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

Synopsis [Reduces the proof to contain only roots and their children.]

Description [The result is updated proof and updated roots.]

SideEffects []

SeeAlso []

Definition at line 371 of file satProof.c.

372{
373 satset * pNode, * pFanin;
374 int i, j, k, nSize;
375 Vec_SetForEachEntry( satset *, vProof, nSize, pNode, i, j )
376 {
377 nSize = Vec_SetWordNum( 2 + pNode->nEnts );
378 Proof_NodeForeachFanin( vProof, pNode, pFanin, k )
379 assert( (pNode->pEnts[k] >> 2) );
380 }
381}
#define Vec_SetForEachEntry(Type, pVec, nSize, pSet, p, s)
Definition vecSet.h:96

◆ Sat_ProofCollectCore()

Vec_Int_t * Sat_ProofCollectCore ( Vec_Set_t * vProof,
Vec_Int_t * vUsed )

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

Synopsis [Collects nodes belonging to the UNSAT core.]

Description [The resulting array contains 1-based IDs of root clauses.]

SideEffects []

SeeAlso []

Definition at line 607 of file satProof.c.

608{
609 Vec_Int_t * vCore;
610 satset * pNode, * pFanin;
611 unsigned * pBitMap;
612 int i, k, MaxCla = 0;
613 // find the largest number
614 Proof_ForeachNodeVec( vUsed, vProof, pNode, i )
615 Proof_NodeForeachFanin( vProof, pNode, pFanin, k )
616 if ( pFanin == NULL )
617 MaxCla = Abc_MaxInt( MaxCla, pNode->pEnts[k] >> 2 );
618 // allocate bitmap
619 pBitMap = ABC_CALLOC( unsigned, Abc_BitWordNum(MaxCla) + 1 );
620 // collect leaves
621 vCore = Vec_IntAlloc( 1000 );
622 Proof_ForeachNodeVec( vUsed, vProof, pNode, i )
623 Proof_NodeForeachFanin( vProof, pNode, pFanin, k )
624 if ( pFanin == NULL )
625 {
626 int Entry = (pNode->pEnts[k] >> 2);
627 if ( Abc_InfoHasBit(pBitMap, Entry) )
628 continue;
629 Abc_InfoSetBit(pBitMap, Entry);
630 Vec_IntPush( vCore, Entry );
631 }
632 ABC_FREE( pBitMap );
633// Vec_IntUniqify( vCore );
634 return vCore;
635}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Sat_ProofReduce()

int Sat_ProofReduce ( Vec_Set_t * vProof,
void * pRoots,
int hProofPivot )

Definition at line 383 of file satProof.c.

384{
385// Vec_Set_t * vProof = (Vec_Set_t *)&s->Proofs;
386// Vec_Int_t * vRoots = (Vec_Int_t *)&s->claProofs;
387 Vec_Int_t * vRoots = (Vec_Int_t *)pRoots;
388// Vec_Int_t * vClauses = (Vec_Int_t *)&s->clauses;
389 int fVerbose = 0;
390 Vec_Ptr_t * vUsed;
391 satset * pNode, * pFanin, * pPivot;
392 int i, j, k, hTemp, nSize;
393 abctime clk = Abc_Clock();
394 static abctime TimeTotal = 0;
395 int RetValue;
396//Sat_ProofCheck0( vProof );
397
398 // collect visited nodes
399 nSize = Proof_MarkUsedRec( vProof, vRoots );
400 vUsed = Vec_PtrAlloc( nSize );
401//Sat_ProofCheck0( vProof );
402
403 // relabel nodes to use smaller space
404 Vec_SetShrinkS( vProof, 2 );
405 Vec_SetForEachEntry( satset *, vProof, nSize, pNode, i, j )
406 {
407 nSize = Vec_SetWordNum( 2 + pNode->nEnts );
408 if ( pNode->Id == 0 )
409 continue;
410 pNode->Id = Vec_SetAppendS( vProof, 2 + pNode->nEnts );
411 assert( pNode->Id > 0 );
412 Vec_PtrPush( vUsed, pNode );
413 // update fanins
414 Proof_NodeForeachFanin( vProof, pNode, pFanin, k )
415 if ( (pNode->pEnts[k] & 1) == 0 ) // proof node
416 {
417 assert( pFanin->Id > 0 );
418 pNode->pEnts[k] = (pFanin->Id << 2) | (pNode->pEnts[k] & 2);
419 }
420// else // problem clause
421// assert( (int*)pFanin >= Vec_IntArray(vClauses) && (int*)pFanin < Vec_IntArray(vClauses)+Vec_IntSize(vClauses) );
422 }
423 // update roots
424 Proof_ForeachNodeVec1( vRoots, vProof, pNode, i )
425 Vec_IntWriteEntry( vRoots, i, pNode->Id );
426 // determine new pivot
427 assert( hProofPivot >= 1 && hProofPivot <= Vec_SetHandCurrent(vProof) );
428 pPivot = Proof_NodeRead( vProof, hProofPivot );
429 RetValue = Vec_SetHandCurrentS(vProof);
430 // compact the nodes
431 Vec_PtrForEachEntry( satset *, vUsed, pNode, i )
432 {
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 )
436 {
437 RetValue = hTemp;
438 pPivot = NULL;
439 }
440 }
441 Vec_SetWriteEntryNum( vProof, Vec_PtrSize(vUsed) );
442 Vec_PtrFree( vUsed );
443
444 // report the result
445 if ( fVerbose )
446 {
447 printf( "\n" );
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 );
453 }
454 Vec_SetShrink( vProof, Vec_SetHandCurrentS(vProof) );
455 Vec_SetShrinkLimits( vProof );
456// Sat_ProofReduceCheck( s );
457//Sat_ProofCheck0( vProof );
458
459 return RetValue;
460}
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define Proof_ForeachNodeVec1(pVec, p, pNode, i)
Definition satProof.c:68
int Proof_MarkUsedRec(Vec_Set_t *vProof, Vec_Int_t *vRoots)
Definition satProof.c:233
char * memmove()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function: