47static inline void Aig_ManInterAddBuffer(
sat_solver2 * pSat,
int iVarA,
int iVarB,
int fCompl,
int fMark )
51 assert( iVarA >= 0 && iVarB >= 0 );
53 Lits[0] = toLitCond( iVarA, 0 );
54 Lits[1] = toLitCond( iVarB, !fCompl );
57 clause2_set_partA( pSat, Cid, 1 );
59 Lits[0] = toLitCond( iVarA, 1 );
60 Lits[1] = toLitCond( iVarB, fCompl );
63 clause2_set_partA( pSat, Cid, 1 );
77static inline void Aig_ManInterAddXor(
sat_solver2 * pSat,
int iVarA,
int iVarB,
int iVarC,
int fCompl,
int fMark )
81 assert( iVarA >= 0 && iVarB >= 0 && iVarC >= 0 );
83 Lits[0] = toLitCond( iVarA, !fCompl );
84 Lits[1] = toLitCond( iVarB, 1 );
85 Lits[2] = toLitCond( iVarC, 1 );
88 clause2_set_partA( pSat, Cid, 1 );
90 Lits[0] = toLitCond( iVarA, !fCompl );
91 Lits[1] = toLitCond( iVarB, 0 );
92 Lits[2] = toLitCond( iVarC, 0 );
95 clause2_set_partA( pSat, Cid, 1 );
97 Lits[0] = toLitCond( iVarA, fCompl );
98 Lits[1] = toLitCond( iVarB, 1 );
99 Lits[2] = toLitCond( iVarC, 0 );
102 clause2_set_partA( pSat, Cid, 1 );
104 Lits[0] = toLitCond( iVarA, fCompl );
105 Lits[1] = toLitCond( iVarB, 0 );
106 Lits[2] = toLitCond( iVarC, 1 );
109 clause2_set_partA( pSat, Cid, 1 );
131 int Lit, Cid,
Var, status, i;
132 clock_t clk = clock();
133 assert( Aig_ManRegNum(pMan) == 0 );
134 assert( Aig_ManCoNum(pMan) == 1 );
147 if ( !Aig_ObjIsCi(pObj) && !Aig_ObjIsCo(pObj) )
152 for ( i = 0; i < pCnf->
nClauses; i++ )
155 clause2_set_partA( pSat, Cid, 1 );
160 for ( i = 0; i < pCnf->
nClauses; i++ )
165 vVars = Vec_IntAlloc( Aig_ManCoNum(pMan)+1 );
168 if ( Aig_ObjRefs(pObj) == 0 )
171 Aig_ManInterAddBuffer( pSat,
Var, pCnf->
nVars +
Var, 0, 0 );
172 Vec_IntPush( vVars,
Var );
178 Vec_IntPush( vVars,
Var );
181 Lit = toLitCond( 2*pCnf->
nVars, 0 );
198 Vec_IntFree( vVars );
201 ABC_PRT(
"Total interpolation time", clock() - clk );
219 assert( Aig_ManCoNum(pNew) == 1 );
220 assert( Aig_ManCiNum(pNew) == Aig_ManCiNum(pBase) );
223 Aig_ManConst1(pNew)->pData = Aig_ManConst1(pBase);
228 pObj->
pData =
Aig_And( pBase, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
230 pObj = Aig_ManCo( pNew, 0 );
247 Aig_Man_t * pAigTemp, * pInter, * pBase = NULL;
252 int nOuts = Aig_ManCoNum(pMan);
253 int ShiftP[2], ShiftCnf[2], ShiftOr[2], ShiftAssume;
254 int Cid, Lit, status, i, k, c;
255 clock_t clk = clock();
256 assert( Aig_ManRegNum(pMan) == 0 );
266 ShiftP[1] = 2*pCnf->
nVars + 3*nOuts;
267 ShiftCnf[0] = ShiftP[0] + nOuts;
268 ShiftCnf[1] = ShiftP[1] + nOuts;
269 ShiftOr[0] = ShiftCnf[0] + 2*pCnf->
nVars;
270 ShiftOr[1] = ShiftCnf[1] + 2*pCnf->
nVars;
271 ShiftAssume = ShiftOr[1] + nOuts;
275 for ( i = ShiftCnf[0]; i < ShiftP[1]; i++ )
279 vVars = Vec_IntAlloc( 2*nOuts );
280 for ( k = 0; k < 2; k++ )
284 for ( i = 0; i < pCnf->
nClauses; i++ )
287 clause2_set_partA( pSat, Cid, k==0 );
291 Aig_ManInterAddBuffer( pSat, ShiftP[k] + i, pCnf->
pVarNums[pObj->
Id], k==1, k==0 );
294 for ( i = 0; i < pCnf->
nClauses; i++ )
297 clause2_set_partA( pSat, Cid, k==0 );
300 Vec_IntClear( vVars );
303 Aig_ManInterAddXor( pSat, ShiftP[k] + i, pCnf->
pVarNums[pObj->
Id], ShiftOr[k] + i, k==1, k==0 );
304 Vec_IntPush( vVars, toLitCond(ShiftOr[k] + i, 1) );
306 Cid =
sat_solver2_addclause( pSat, Vec_IntArray(vVars), Vec_IntArray(vVars) + Vec_IntSize(vVars), 0 );
307 clause2_set_partA( pSat, Cid, k==0 );
312 for ( k = 0; k < nOuts; k++ )
313 Aig_ManInterAddXor( pSat, ShiftP[0] + k, ShiftP[1] + k, ShiftAssume + k, 0, 0 );
317 pBase->pName = Abc_UtilStrsav(
"repar" );
318 for ( k = 0; k < 2*nOuts; k++ )
322 Vec_IntClear( vVars );
323 for ( k = 0; k < 2*nOuts; k++ )
324 Vec_IntPush( vVars, k );
328 for ( k = 0; k < nOuts; k++ )
331 int Temp = Vec_IntEntry( vVars, k );
332 Vec_IntWriteEntry( vVars, k, Vec_IntEntry(vVars, nOuts+k) );
333 Vec_IntWriteEntry( vVars, nOuts+k, Temp );
336 Lit = toLitCond( ShiftAssume + k, 1 );
346 assert( i <= k || Aig_ObjRefs(pObj) == 0 );
356 for ( i = 0; i < pCnfInter->
nVars; i++ )
358 for ( c = 0; c < 2; c++ )
363 for ( i = 0; i < pCnfInter->
nClauses; i++ )
366 clause2_set_partA( pSat, Cid, c==0 );
371 Aig_ManInterAddBuffer( pSat, i, pCnf->
pVarNums[pObj->
Id], 0, c==0 );
373 pObj = Aig_ManCo(pInter, 0);
374 Aig_ManInterAddBuffer( pSat, ShiftP[c] + k, pCnf->
pVarNums[pObj->
Id], 0, c==0 );
385 Temp = Vec_IntEntry( vVars, k );
386 Vec_IntWriteEntry( vVars, k, Vec_IntEntry(vVars, nOuts+k) );
387 Vec_IntWriteEntry( vVars, nOuts+k, Temp );
390 Vec_IntFree( vVars );
393 ABC_PRT(
"Reparameterization time", clock() - clk );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
void Aig_ManInterTest(Aig_Man_t *pMan, int fVerbose)
void Aig_ManAppend(Aig_Man_t *pBase, Aig_Man_t *pNew)
Aig_Man_t * Aig_ManInterRepar(Aig_Man_t *pMan, int fVerbose)
#define Aig_ManForEachObj(p, pObj, i)
void Aig_ManStop(Aig_Man_t *p)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
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 ///.
void Aig_ManPrintStats(Aig_Man_t *p)
#define Aig_ManForEachNode(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
#define Aig_ManForEachCo(p, pObj, i)
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
void Aig_ManCleanData(Aig_Man_t *p)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Cnf_DataLift(Cnf_Dat_t *p, int nVarsPlus)
unsigned __int64 word
DECLARATIONS ///.
void sat_solver2_delete(sat_solver2 *s)
sat_solver2 * sat_solver2_new(void)
int sat_solver2_solve(sat_solver2 *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
void sat_solver2_setnvars(sat_solver2 *s, int n)
void var_set_partA(sat_solver2 *s, int v, int partA)
int sat_solver2_addclause(sat_solver2 *s, lit *begin, lit *end, int Id)
void Sat_Solver2PrintStats(FILE *pFile, sat_solver2 *p)
struct sat_solver2_t sat_solver2
void * Sat_ProofInterpolant(sat_solver2 *s, void *pGloVars)