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

Go to the source code of this file.

Classes

struct  Inta_Man_t_
 

Functions

Inta_Man_tInta_ManAlloc ()
 FUNCTION DEFINITIONS ///.
 
int Inta_ManGlobalVars (Inta_Man_t *p)
 
void Inta_ManResize (Inta_Man_t *p)
 
void Inta_ManFree (Inta_Man_t *p)
 
void Inta_ManPrintClause (Inta_Man_t *p, Sto_Cls_t *pClause)
 
void Inta_ManPrintResolvent (Vec_Int_t *vResLits)
 
void Inta_ManPrintInterOne (Inta_Man_t *p, Sto_Cls_t *pClause)
 
Sto_Cls_tInta_ManPropagate (Inta_Man_t *p, int Start)
 
void Inta_ManProofWriteOne (Inta_Man_t *p, Sto_Cls_t *pClause)
 
int Inta_ManProofTraceOne (Inta_Man_t *p, Sto_Cls_t *pConflict, Sto_Cls_t *pFinal)
 
int Inta_ManProofRecordOne (Inta_Man_t *p, Sto_Cls_t *pClause)
 
int Inta_ManProcessRoots (Inta_Man_t *p)
 
void Inta_ManPrepareInter (Inta_Man_t *p)
 
void * Inta_ManInterpolate (Inta_Man_t *p, Sto_Man_t *pCnf, abctime TimeToStop, void *vVarsAB, int fVerbose)
 
Aig_Man_tInta_ManDeriveClauses (Inta_Man_t *pMan, Sto_Man_t *pCnf, int fClausesA)
 

Function Documentation

◆ Inta_ManAlloc()

Inta_Man_t * Inta_ManAlloc ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file satInterA.c.

107{
108 Inta_Man_t * p;
109 // allocate the manager
110 p = (Inta_Man_t *)ABC_ALLOC( char, sizeof(Inta_Man_t) );
111 memset( p, 0, sizeof(Inta_Man_t) );
112 // verification
113 p->vResLits = Vec_IntAlloc( 1000 );
114 // parameters
115 p->fProofWrite = 0;
116 p->fProofVerif = 1;
117 return p;
118}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Cube * p
Definition exorList.c:222
struct Inta_Man_t_ Inta_Man_t
Definition satStore.h:130
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManDeriveClauses()

Aig_Man_t * Inta_ManDeriveClauses ( Inta_Man_t * pMan,
Sto_Man_t * pCnf,
int fClausesA )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1051 of file satInterA.c.

1052{
1053 Aig_Man_t * p;
1054 Aig_Obj_t * pMiter, * pSum, * pLit;
1055 Sto_Cls_t * pClause;
1056 int Var, VarAB, v;
1057 p = Aig_ManStart( 10000 );
1058 pMiter = Aig_ManConst1(p);
1059 Sto_ManForEachClauseRoot( pCnf, pClause )
1060 {
1061 if ( fClausesA ^ pClause->fA ) // clause of B
1062 continue;
1063 // clause of A
1064 pSum = Aig_ManConst0(p);
1065 for ( v = 0; v < (int)pClause->nLits; v++ )
1066 {
1067 Var = lit_var(pClause->pLits[v]);
1068 if ( pMan->pVarTypes[Var] < 0 ) // global var
1069 {
1070 VarAB = -pMan->pVarTypes[Var]-1;
1071 assert( VarAB >= 0 && VarAB < Vec_IntSize(pMan->vVarsAB) );
1072 pLit = Aig_NotCond( Aig_IthVar(p, VarAB), lit_sign(pClause->pLits[v]) );
1073 }
1074 else
1075 pLit = Aig_NotCond( Aig_IthVar(p, Vec_IntSize(pMan->vVarsAB)+1+Var), lit_sign(pClause->pLits[v]) );
1076 pSum = Aig_Or( p, pSum, pLit );
1077 }
1078 pMiter = Aig_And( p, pMiter, pSum );
1079 }
1080 Aig_ObjCreateCo( p, pMiter );
1081 return p;
1082}
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition aigOper.c:63
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:259
int Var
Definition exorList.c:228
struct Sto_Cls_t_ Sto_Cls_t
BASIC TYPES ///.
Definition satStore.h:67
#define Sto_ManForEachClauseRoot(p, pCls)
Definition satStore.h:100
int * pVarTypes
Definition satInterA.c:61
Vec_Int_t * vVarsAB
Definition satInterA.c:44
lit pLits[0]
Definition satStore.h:78
unsigned fA
Definition satStore.h:74
unsigned nLits
Definition satStore.h:77
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManFree()

void Inta_ManFree ( Inta_Man_t * p)

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

Synopsis [Deallocate proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file satInterA.c.

251{
252/*
253 printf( "Runtime stats:\n" );
254ABC_PRT( "BCP ", p->timeBcp );
255ABC_PRT( "Trace ", p->timeTrace );
256ABC_PRT( "TOTAL ", p->timeTotal );
257*/
258 ABC_FREE( p->pInters );
259 ABC_FREE( p->pProofNums );
260 ABC_FREE( p->pTrail );
261 ABC_FREE( p->pAssigns );
262 ABC_FREE( p->pSeens );
263 ABC_FREE( p->pVarTypes );
264 ABC_FREE( p->pReasons );
265 ABC_FREE( p->pWatches );
266 Vec_IntFree( p->vResLits );
267 ABC_FREE( p );
268}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Inta_ManGlobalVars()

int Inta_ManGlobalVars ( Inta_Man_t * p)

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

Synopsis [Count common variables in the clauses of A and B.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file satInterA.c.

132{
133 Sto_Cls_t * pClause;
134 int LargeNum = -100000000;
135 int Var, nVarsAB, v;
136
137 // mark the variable encountered in the clauses of A
138 Sto_ManForEachClauseRoot( p->pCnf, pClause )
139 {
140 if ( !pClause->fA )
141 break;
142 for ( v = 0; v < (int)pClause->nLits; v++ )
143 p->pVarTypes[lit_var(pClause->pLits[v])] = 1;
144 }
145
146 // check variables that appear in clauses of B
147 nVarsAB = 0;
148 Sto_ManForEachClauseRoot( p->pCnf, pClause )
149 {
150 if ( pClause->fA )
151 continue;
152 for ( v = 0; v < (int)pClause->nLits; v++ )
153 {
154 Var = lit_var(pClause->pLits[v]);
155 if ( p->pVarTypes[Var] == 1 ) // var of A
156 {
157 // change it into a global variable
158 nVarsAB++;
159 p->pVarTypes[Var] = LargeNum;
160 }
161 }
162 }
163 assert( nVarsAB <= Vec_IntSize(p->vVarsAB) );
164
165 // order global variables
166 nVarsAB = 0;
167 Vec_IntForEachEntry( p->vVarsAB, Var, v )
168 p->pVarTypes[Var] = -(1+nVarsAB++);
169
170 // check that there is no extra global variables
171 for ( v = 0; v < p->pCnf->nVars; v++ )
172 assert( p->pVarTypes[v] != LargeNum );
173 return nVarsAB;
174}
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ Inta_ManInterpolate()

void * Inta_ManInterpolate ( Inta_Man_t * p,
Sto_Man_t * pCnf,
abctime TimeToStop,
void * vVarsAB,
int fVerbose )

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

Synopsis [Computes interpolant for the given CNF.]

Description [Takes the interpolation manager, the CNF deriving by the SAT solver, which includes ClausesA, ClausesB, and learned clauses. Additional arguments are the vector of variables common to AB and the verbosiness flag. Returns the AIG manager with a single output, containing the interpolant.]

SideEffects []

SeeAlso []

Definition at line 944 of file satInterA.c.

945{
946 Aig_Man_t * pRes;
947 Aig_Obj_t * pObj;
948 Sto_Cls_t * pClause;
949 int RetValue = 1;
950 abctime clkTotal = Abc_Clock();
951
952 if ( TimeToStop && Abc_Clock() > TimeToStop )
953 return NULL;
954
955 // check that the CNF makes sense
956 assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
957 p->pCnf = pCnf;
958 p->fVerbose = fVerbose;
959 p->vVarsAB = (Vec_Int_t *)vVarsAB;
960 p->pAig = pRes = Aig_ManStart( 10000 );
961 Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
962
963 // adjust the manager
964 Inta_ManResize( p );
965
966 // prepare the interpolant computation
968
969 // construct proof for each clause
970 // start the proof
971 if ( p->fProofWrite )
972 {
973 p->pFile = fopen( "proof.cnf_", "w" );
974 p->Counter = 0;
975 }
976
977 // write the root clauses
978 Sto_ManForEachClauseRoot( p->pCnf, pClause )
979 {
980 Inta_ManProofWriteOne( p, pClause );
981 if ( TimeToStop && Abc_Clock() > TimeToStop )
982 {
983 Aig_ManStop( pRes );
984 p->pAig = NULL;
985 return NULL;
986 }
987 }
988
989 // propagate root level assignments
990 if ( Inta_ManProcessRoots( p ) )
991 {
992 // if there is no conflict, consider learned clauses
993 Sto_ManForEachClause( p->pCnf, pClause )
994 {
995 if ( pClause->fRoot )
996 continue;
997 if ( !Inta_ManProofRecordOne( p, pClause ) )
998 {
999 RetValue = 0;
1000 break;
1001 }
1002 if ( TimeToStop && Abc_Clock() > TimeToStop )
1003 {
1004 Aig_ManStop( pRes );
1005 p->pAig = NULL;
1006 return NULL;
1007 }
1008 }
1009 }
1010
1011 // stop the proof
1012 if ( p->fProofWrite )
1013 {
1014 fclose( p->pFile );
1015// Sat_ProofChecker( "proof.cnf_" );
1016 p->pFile = NULL;
1017 }
1018
1019 if ( fVerbose )
1020 {
1021// ABC_PRT( "Interpo", Abc_Clock() - clkTotal );
1022 printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f MB ",
1023 p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
1024 1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
1025 1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
1026 Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
1027p->timeTotal += Abc_Clock() - clkTotal;
1028 }
1029
1030 pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
1031 Aig_ObjCreateCo( pRes, pObj );
1032 Aig_ManCleanup( pRes );
1033
1034 p->pAig = NULL;
1035 return pRes;
1036
1037}
ABC_INT64_T abctime
Definition abc_global.h:332
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Inta_ManPrepareInter(Inta_Man_t *p)
Definition satInterA.c:897
int Inta_ManProofRecordOne(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition satInterA.c:719
void Inta_ManResize(Inta_Man_t *p)
Definition satInterA.c:187
int Inta_ManProcessRoots(Inta_Man_t *p)
Definition satInterA.c:824
void Inta_ManProofWriteOne(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition satInterA.c:517
int Sto_ManMemoryReport(Sto_Man_t *p)
Definition satStore.c:97
#define Sto_ManForEachClause(p, pCls)
Definition satStore.h:99
unsigned fRoot
Definition satStore.h:75
int nVars
Definition satStore.h:85
int nClauses
Definition satStore.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManPrepareInter()

void Inta_ManPrepareInter ( Inta_Man_t * p)

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

Synopsis [Records the proof.]

Description []

SideEffects []

SeeAlso []

Definition at line 897 of file satInterA.c.

898{
899 Sto_Cls_t * pClause;
900 int Var, VarAB, v;
901
902 // set interpolants for root clauses
903 Sto_ManForEachClauseRoot( p->pCnf, pClause )
904 {
905 if ( !pClause->fA ) // clause of B
906 {
907 Inta_ManAigFill( p, Inta_ManAigRead(p, pClause) );
908// Inta_ManPrintInterOne( p, pClause );
909 continue;
910 }
911 // clause of A
912 Inta_ManAigClear( p, Inta_ManAigRead(p, pClause) );
913 for ( v = 0; v < (int)pClause->nLits; v++ )
914 {
915 Var = lit_var(pClause->pLits[v]);
916 if ( p->pVarTypes[Var] < 0 ) // global var
917 {
918 VarAB = -p->pVarTypes[Var]-1;
919 assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
920 if ( lit_sign(pClause->pLits[v]) ) // negative var
921 Inta_ManAigOrNotVar( p, Inta_ManAigRead(p, pClause), VarAB );
922 else
923 Inta_ManAigOrVar( p, Inta_ManAigRead(p, pClause), VarAB );
924 }
925 }
926// Inta_ManPrintInterOne( p, pClause );
927 }
928}
Here is the caller graph for this function:

◆ Inta_ManPrintClause()

void Inta_ManPrintClause ( Inta_Man_t * p,
Sto_Cls_t * pClause )

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

Synopsis [Prints the clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 284 of file satInterA.c.

285{
286 int i;
287 printf( "Clause ID = %d. Proof = %d. {", pClause->Id, Inta_ManProofGet(p, pClause) );
288 for ( i = 0; i < (int)pClause->nLits; i++ )
289 printf( " %d", pClause->pLits[i] );
290 printf( " }\n" );
291}
Here is the caller graph for this function:

◆ Inta_ManPrintInterOne()

void Inta_ManPrintInterOne ( Inta_Man_t * p,
Sto_Cls_t * pClause )

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

Synopsis [Prints the interpolant for one clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 324 of file satInterA.c.

325{
326 printf( "Clause %2d : ", pClause->Id );
327// Extra_PrintBinary___( stdout, Inta_ManAigRead(p, pClause), (1 << p->nVarsAB) );
328 printf( "\n" );
329}

◆ Inta_ManPrintResolvent()

void Inta_ManPrintResolvent ( Vec_Int_t * vResLits)

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

Synopsis [Prints the resolvent.]

Description []

SideEffects []

SeeAlso []

Definition at line 304 of file satInterA.c.

305{
306 int i, Entry;
307 printf( "Resolvent: {" );
308 Vec_IntForEachEntry( vResLits, Entry, i )
309 printf( " %d", Entry );
310 printf( " }\n" );
311}
Here is the caller graph for this function:

◆ Inta_ManProcessRoots()

int Inta_ManProcessRoots ( Inta_Man_t * p)

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

Synopsis [Propagate the root clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 824 of file satInterA.c.

825{
826 Sto_Cls_t * pClause;
827 int Counter;
828
829 // make sure the root clauses are preceeding the learnt clauses
830 Counter = 0;
831 Sto_ManForEachClause( p->pCnf, pClause )
832 {
833 assert( (int)pClause->fA == (Counter < (int)p->pCnf->nClausesA) );
834 assert( (int)pClause->fRoot == (Counter < (int)p->pCnf->nRoots) );
835 Counter++;
836 }
837 assert( p->pCnf->nClauses == Counter );
838
839 // make sure the last clause if empty
840 assert( p->pCnf->pTail->nLits == 0 );
841
842 // go through the root unit clauses
843 p->nTrailSize = 0;
844 Sto_ManForEachClauseRoot( p->pCnf, pClause )
845 {
846 // create watcher lists for the root clauses
847 if ( pClause->nLits > 1 )
848 {
849 Inta_ManWatchClause( p, pClause, pClause->pLits[0] );
850 Inta_ManWatchClause( p, pClause, pClause->pLits[1] );
851 }
852 // empty clause and large clauses
853 if ( pClause->nLits != 1 )
854 continue;
855 // unit clause
856 assert( lit_check(pClause->pLits[0], p->pCnf->nVars) );
857 if ( !Inta_ManEnqueue( p, pClause->pLits[0], pClause ) )
858 {
859 // detected root level conflict
860// printf( "Error in Inta_ManProcessRoots(): Detected a root-level conflict too early!\n" );
861// assert( 0 );
862 // detected root level conflict
863 Inta_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
864 if ( p->fVerbose )
865 printf( "Found root level conflict!\n" );
866 return 0;
867 }
868 }
869
870 // propagate the root unit clauses
871 pClause = Inta_ManPropagate( p, 0 );
872 if ( pClause )
873 {
874 // detected root level conflict
875 Inta_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
876 if ( p->fVerbose )
877 printf( "Found root level conflict!\n" );
878 return 0;
879 }
880
881 // set the root level
882 p->nRootSize = p->nTrailSize;
883 return 1;
884}
Sto_Cls_t * Inta_ManPropagate(Inta_Man_t *p, int Start)
Definition satInterA.c:487
int Inta_ManProofTraceOne(Inta_Man_t *p, Sto_Cls_t *pConflict, Sto_Cls_t *pFinal)
Definition satInterA.c:542
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManProofRecordOne()

int Inta_ManProofRecordOne ( Inta_Man_t * p,
Sto_Cls_t * pClause )

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

Synopsis [Records the proof for one clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 719 of file satInterA.c.

720{
721 Sto_Cls_t * pConflict;
722 int i;
723
724 // empty clause never ends up there
725 assert( pClause->nLits > 0 );
726 if ( pClause->nLits == 0 )
727 printf( "Error: Empty clause is attempted.\n" );
728
729 assert( !pClause->fRoot );
730 assert( p->nTrailSize == p->nRootSize );
731
732 // if any of the clause literals are already assumed
733 // it means that the clause is redundant and can be skipped
734 for ( i = 0; i < (int)pClause->nLits; i++ )
735 if ( p->pAssigns[lit_var(pClause->pLits[i])] == pClause->pLits[i] )
736 return 1;
737
738 // add assumptions to the trail
739 for ( i = 0; i < (int)pClause->nLits; i++ )
740 if ( !Inta_ManEnqueue( p, lit_neg(pClause->pLits[i]), NULL ) )
741 {
742 assert( 0 ); // impossible
743 return 0;
744 }
745
746 // propagate the assumptions
747 pConflict = Inta_ManPropagate( p, p->nRootSize );
748 if ( pConflict == NULL )
749 {
750 assert( 0 ); // cannot prove
751 return 0;
752 }
753
754 // skip the clause if it is weaker or the same as the conflict clause
755 if ( pClause->nLits >= pConflict->nLits )
756 {
757 // check if every literal of conflict clause can be found in the given clause
758 int j;
759 for ( i = 0; i < (int)pConflict->nLits; i++ )
760 {
761 for ( j = 0; j < (int)pClause->nLits; j++ )
762 if ( pConflict->pLits[i] == pClause->pLits[j] )
763 break;
764 if ( j == (int)pClause->nLits ) // literal pConflict->pLits[i] is not found
765 break;
766 }
767 if ( i == (int)pConflict->nLits ) // all lits are found
768 {
769 // undo to the root level
770 Inta_ManCancelUntil( p, p->nRootSize );
771 return 1;
772 }
773 }
774
775 // construct the proof
776 Inta_ManProofTraceOne( p, pConflict, pClause );
777
778 // undo to the root level
779 Inta_ManCancelUntil( p, p->nRootSize );
780
781 // add large clauses to the watched lists
782 if ( pClause->nLits > 1 )
783 {
784 Inta_ManWatchClause( p, pClause, pClause->pLits[0] );
785 Inta_ManWatchClause( p, pClause, pClause->pLits[1] );
786 return 1;
787 }
788 assert( pClause->nLits == 1 );
789
790 // if the clause proved is unit, add it and propagate
791 if ( !Inta_ManEnqueue( p, pClause->pLits[0], pClause ) )
792 {
793 assert( 0 ); // impossible
794 return 0;
795 }
796
797 // propagate the assumption
798 pConflict = Inta_ManPropagate( p, p->nRootSize );
799 if ( pConflict )
800 {
801 // construct the proof
802 Inta_ManProofTraceOne( p, pConflict, p->pCnf->pEmpty );
803// if ( p->fVerbose )
804// printf( "Found last conflict after adding unit clause number %d!\n", pClause->Id );
805 return 0;
806 }
807
808 // update the root level
809 p->nRootSize = p->nTrailSize;
810 return 1;
811}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManProofTraceOne()

int Inta_ManProofTraceOne ( Inta_Man_t * p,
Sto_Cls_t * pConflict,
Sto_Cls_t * pFinal )

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

Synopsis [Traces the proof for one clause.]

Description []

SideEffects []

SeeAlso []

Definition at line 542 of file satInterA.c.

543{
544 Sto_Cls_t * pReason;
545 int i, v, Var, PrevId;
546 int fPrint = 0;
547 abctime clk = Abc_Clock();
548
549 // collect resolvent literals
550 if ( p->fProofVerif )
551 {
552 Vec_IntClear( p->vResLits );
553 for ( i = 0; i < (int)pConflict->nLits; i++ )
554 Vec_IntPush( p->vResLits, pConflict->pLits[i] );
555 }
556
557 // mark all the variables in the conflict as seen
558 for ( v = 0; v < (int)pConflict->nLits; v++ )
559 p->pSeens[lit_var(pConflict->pLits[v])] = 1;
560
561 // start the anticedents
562// pFinal->pAntis = Vec_PtrAlloc( 32 );
563// Vec_PtrPush( pFinal->pAntis, pConflict );
564
565 if ( p->pCnf->nClausesA )
566 Inta_ManAigCopy( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pConflict) );
567
568 // follow the trail backwards
569 PrevId = Inta_ManProofGet(p, pConflict);
570 for ( i = p->nTrailSize - 1; i >= 0; i-- )
571 {
572 // skip literals that are not involved
573 Var = lit_var(p->pTrail[i]);
574 if ( !p->pSeens[Var] )
575 continue;
576 p->pSeens[Var] = 0;
577
578 // skip literals of the resulting clause
579 pReason = p->pReasons[Var];
580 if ( pReason == NULL )
581 continue;
582 assert( p->pTrail[i] == pReason->pLits[0] );
583
584 // add the variables to seen
585 for ( v = 1; v < (int)pReason->nLits; v++ )
586 p->pSeens[lit_var(pReason->pLits[v])] = 1;
587
588 // record the reason clause
589 assert( Inta_ManProofGet(p, pReason) > 0 );
590 p->Counter++;
591 if ( p->fProofWrite )
592 fprintf( p->pFile, "%d * %d %d 0\n", p->Counter, PrevId, Inta_ManProofGet(p, pReason) );
593 PrevId = p->Counter;
594
595 if ( p->pCnf->nClausesA )
596 {
597 if ( p->pVarTypes[Var] == 1 ) // var of A
598 Inta_ManAigOr( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pReason) );
599 else
600 Inta_ManAigAnd( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pReason) );
601 }
602
603 // resolve the temporary resolvent with the reason clause
604 if ( p->fProofVerif )
605 {
606 int v1, v2, Entry = -1;
607 if ( fPrint )
608 Inta_ManPrintResolvent( p->vResLits );
609 // check that the var is present in the resolvent
610 Vec_IntForEachEntry( p->vResLits, Entry, v1 )
611 if ( lit_var(Entry) == Var )
612 break;
613 if ( v1 == Vec_IntSize(p->vResLits) )
614 printf( "Recording clause %d: Cannot find variable %d in the temporary resolvent.\n", pFinal->Id, Var );
615 if ( Entry != lit_neg(pReason->pLits[0]) )
616 printf( "Recording clause %d: The resolved variable %d is in the wrong polarity.\n", pFinal->Id, Var );
617 // remove variable v1 from the resolvent
618 assert( lit_var(Entry) == Var );
619 Vec_IntRemove( p->vResLits, Entry );
620 // add variables of the reason clause
621 for ( v2 = 1; v2 < (int)pReason->nLits; v2++ )
622 {
623 Vec_IntForEachEntry( p->vResLits, Entry, v1 )
624 if ( lit_var(Entry) == lit_var(pReason->pLits[v2]) )
625 break;
626 // if it is a new variable, add it to the resolvent
627 if ( v1 == Vec_IntSize(p->vResLits) )
628 {
629 Vec_IntPush( p->vResLits, pReason->pLits[v2] );
630 continue;
631 }
632 // if the variable is the same, the literal should be the same too
633 if ( Entry == pReason->pLits[v2] )
634 continue;
635 // the literal is different
636 printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id );
637 }
638 }
639// Vec_PtrPush( pFinal->pAntis, pReason );
640 }
641
642 // unmark all seen variables
643// for ( i = p->nTrailSize - 1; i >= 0; i-- )
644// p->pSeens[lit_var(p->pTrail[i])] = 0;
645 // check that the literals are unmarked
646// for ( i = p->nTrailSize - 1; i >= 0; i-- )
647// assert( p->pSeens[lit_var(p->pTrail[i])] == 0 );
648
649 // use the resulting clause to check the correctness of resolution
650 if ( p->fProofVerif )
651 {
652 int v1, v2, Entry = -1;
653 if ( fPrint )
654 Inta_ManPrintResolvent( p->vResLits );
655 Vec_IntForEachEntry( p->vResLits, Entry, v1 )
656 {
657 for ( v2 = 0; v2 < (int)pFinal->nLits; v2++ )
658 if ( pFinal->pLits[v2] == Entry )
659 break;
660 if ( v2 < (int)pFinal->nLits )
661 continue;
662 break;
663 }
664 if ( v1 < Vec_IntSize(p->vResLits) )
665 {
666 printf( "Recording clause %d: The final resolvent is wrong.\n", pFinal->Id );
667 Inta_ManPrintClause( p, pConflict );
668 Inta_ManPrintResolvent( p->vResLits );
669 Inta_ManPrintClause( p, pFinal );
670 }
671
672 // if there are literals in the clause that are not in the resolvent
673 // it means that the derived resolvent is stronger than the clause
674 // we can replace the clause with the resolvent by removing these literals
675 if ( Vec_IntSize(p->vResLits) != (int)pFinal->nLits )
676 {
677 for ( v1 = 0; v1 < (int)pFinal->nLits; v1++ )
678 {
679 Vec_IntForEachEntry( p->vResLits, Entry, v2 )
680 if ( pFinal->pLits[v1] == Entry )
681 break;
682 if ( v2 < Vec_IntSize(p->vResLits) )
683 continue;
684 // remove literal v1 from the final clause
685 pFinal->nLits--;
686 for ( v2 = v1; v2 < (int)pFinal->nLits; v2++ )
687 pFinal->pLits[v2] = pFinal->pLits[v2+1];
688 v1--;
689 }
690 assert( Vec_IntSize(p->vResLits) == (int)pFinal->nLits );
691 }
692 }
693p->timeTrace += Abc_Clock() - clk;
694
695 // return the proof pointer
696 if ( p->pCnf->nClausesA )
697 {
698// Inta_ManPrintInterOne( p, pFinal );
699 }
700 Inta_ManProofSet( p, pFinal, p->Counter );
701 // make sure the same proof ID is not asssigned to two consecutive clauses
702 assert( p->pProofNums[pFinal->Id-1] != p->Counter );
703// if ( p->pProofNums[pFinal->Id] == p->pProofNums[pFinal->Id-1] )
704// p->pProofNums[pFinal->Id] = p->pProofNums[pConflict->Id];
705 return p->Counter;
706}
void Inta_ManPrintResolvent(Vec_Int_t *vResLits)
Definition satInterA.c:304
void Inta_ManPrintClause(Inta_Man_t *p, Sto_Cls_t *pClause)
Definition satInterA.c:284
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inta_ManProofWriteOne()

void Inta_ManProofWriteOne ( Inta_Man_t * p,
Sto_Cls_t * pClause )

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

Synopsis [Writes one root clause into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 517 of file satInterA.c.

518{
519 Inta_ManProofSet( p, pClause, ++p->Counter );
520
521 if ( p->fProofWrite )
522 {
523 int v;
524 fprintf( p->pFile, "%d", Inta_ManProofGet(p, pClause) );
525 for ( v = 0; v < (int)pClause->nLits; v++ )
526 fprintf( p->pFile, " %d", lit_print(pClause->pLits[v]) );
527 fprintf( p->pFile, " 0 0\n" );
528 }
529}
Here is the caller graph for this function:

◆ Inta_ManPropagate()

Sto_Cls_t * Inta_ManPropagate ( Inta_Man_t * p,
int Start )

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

Synopsis [Propagate the current assignments.]

Description []

SideEffects []

SeeAlso []

Definition at line 487 of file satInterA.c.

488{
489 Sto_Cls_t * pClause;
490 int i;
491 abctime clk = Abc_Clock();
492 for ( i = Start; i < p->nTrailSize; i++ )
493 {
494 pClause = Inta_ManPropagateOne( p, p->pTrail[i] );
495 if ( pClause )
496 {
497p->timeBcp += Abc_Clock() - clk;
498 return pClause;
499 }
500 }
501p->timeBcp += Abc_Clock() - clk;
502 return NULL;
503}
Here is the caller graph for this function:

◆ Inta_ManResize()

void Inta_ManResize ( Inta_Man_t * p)

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

Synopsis [Resize proof manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file satInterA.c.

188{
189 p->Counter = 0;
190 // check if resizing is needed
191 if ( p->nVarsAlloc < p->pCnf->nVars )
192 {
193 // find the new size
194 if ( p->nVarsAlloc == 0 )
195 p->nVarsAlloc = 1;
196 while ( p->nVarsAlloc < p->pCnf->nVars )
197 p->nVarsAlloc *= 2;
198 // resize the arrays
199 p->pTrail = ABC_REALLOC(lit, p->pTrail, p->nVarsAlloc );
200 p->pAssigns = ABC_REALLOC(lit, p->pAssigns, p->nVarsAlloc );
201 p->pSeens = ABC_REALLOC(char, p->pSeens, p->nVarsAlloc );
202 p->pVarTypes = ABC_REALLOC(int, p->pVarTypes, p->nVarsAlloc );
203 p->pReasons = ABC_REALLOC(Sto_Cls_t *, p->pReasons, p->nVarsAlloc );
204 p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
205 }
206
207 // clean the free space
208 memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
209 memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
210 memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
211 memset( p->pReasons , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars );
212 memset( p->pWatches , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars*2 );
213
214 // compute the number of common variables
216
217 // check if resizing of clauses is needed
218 if ( p->nClosAlloc < p->pCnf->nClauses )
219 {
220 // find the new size
221 if ( p->nClosAlloc == 0 )
222 p->nClosAlloc = 1;
223 while ( p->nClosAlloc < p->pCnf->nClauses )
224 p->nClosAlloc *= 2;
225 // resize the arrays
226 p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc );
227 }
228 memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses );
229
230 // check if resizing of truth tables is needed
231 if ( p->nIntersAlloc < p->pCnf->nClauses )
232 {
233 p->nIntersAlloc = p->pCnf->nClauses;
234 p->pInters = ABC_REALLOC( Aig_Obj_t *, p->pInters, p->nIntersAlloc );
235 }
236 memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses );
237}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
int Inta_ManGlobalVars(Inta_Man_t *p)
Definition satInterA.c:131
int lit
Definition satVec.h:130
Here is the call graph for this function:
Here is the caller graph for this function: