53 int RetValue, iNode = -1, iFanin, i, k;
58 sat_solver_setnvars(
p->pSat, 1 + Vec_IntSize(
p->vOrder) + Vec_IntSize(
p->vTfo) + Vec_IntSize(
p->vRoots) + 10 );
60 Sfm_NtkCleanVars(
p );
63 Sfm_ObjSetSatVar(
p, iNode,
p->nSatVars++ );
65 Vec_IntClear(
p->vDivVars );
67 Vec_IntPush(
p->vDivVars, Sfm_ObjSatVar(
p, iNode) );
71 if ( Sfm_ObjIsPi(
p, iNode) )
74 Vec_IntClear(
p->vFaninMap );
76 Vec_IntPush(
p->vFaninMap, Sfm_ObjSatVar(
p, iFanin) );
77 Vec_IntPush(
p->vFaninMap, Sfm_ObjSatVar(
p, iNode) );
83 if ( Vec_IntSize(vClause) == 0 )
85 RetValue =
sat_solver_addclause(
p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
90 if ( Vec_IntSize(
p->vTfo) > 0 )
92 assert(
p->pPars->nTfoLevMax > 0 );
93 assert( Vec_IntSize(
p->vRoots) > 0 );
94 assert( Vec_IntEntry(
p->vTfo, 0) !=
p->iPivotNode );
96 Vec_IntClear(
p->vLits );
98 Vec_IntPush(
p->vLits, Sfm_ObjSatVar(
p, iNode) );
102 Sfm_ObjCleanSatVar(
p, Sfm_ObjSatVar(
p, iNode) );
103 Sfm_ObjSetSatVar(
p, iNode,
p->nSatVars++ );
108 assert( Sfm_ObjIsNode(
p, iNode) );
110 Vec_IntClear(
p->vFaninMap );
112 Vec_IntPush(
p->vFaninMap, Sfm_ObjSatVar(
p, iFanin) );
113 Vec_IntPush(
p->vFaninMap, Sfm_ObjSatVar(
p, iNode) );
119 if ( Vec_IntSize(vClause) == 0 )
121 RetValue =
sat_solver_addclause(
p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
130 Vec_IntWriteEntry(
p->vLits, i, Abc_Var2Lit(
p->nSatVars-1, 0) );
139 p->timeCnf += Abc_Clock() - clk;
157 int status, i, Div, iVar, nFinal, * pFinal, nIter = 0;
159 int nWords = Abc_Truth6WordNum( Vec_IntSize(
p->vDivIds) );
161 pLits[0] = Abc_Var2Lit( Sfm_ObjSatVar(
p,
p->iPivotNode), 0 );
162 pLits[1] = Abc_Var2Lit( nVars, 0 );
164 Abc_TtClear(
p->pTruth,
nWords );
176 Vec_IntClear(
p->vValues );
178 Vec_IntPush(
p->vValues, sat_solver_var_value(
p->pSat, iVar) );
180 Vec_IntClear(
p->vLits );
181 Vec_IntPush(
p->vLits, Abc_LitNot(pLits[0]) );
183 Vec_IntPush(
p->vLits, sat_solver_var_literal(
p->pSat, Div) );
186 status =
sat_solver_solve(
p->pSat, Vec_IntArray(
p->vLits), Vec_IntArray(
p->vLits) + Vec_IntSize(
p->vLits),
p->pPars->nBTLimit, 0, 0, 0 );
193 nFinal = sat_solver_final(
p->pSat, &pFinal );
194 Abc_TtFill(
p->pCube,
nWords );
195 Vec_IntClear(
p->vLits );
196 Vec_IntPush(
p->vLits, Abc_LitNot(pLits[1]) );
197 for ( i = 0; i < nFinal; i++ )
199 if ( pFinal[i] == pLits[0] )
201 Vec_IntPush(
p->vLits, pFinal[i] );
202 iVar = Vec_IntFind(
p->vDivIds, Abc_Lit2Var(pFinal[i]) );
assert( iVar >= 0 );
203 Abc_TtAndSharp(
p->pCube,
p->pCube,
p->pTtElems[iVar],
nWords, !Abc_LitIsCompl(pFinal[i]) );
205 Abc_TtOr(
p->pTruth,
p->pTruth,
p->pCube,
nWords );
213 if ( Vec_IntEntry(
p->vValues, i) ^ sat_solver_var_value(
p->pSat, iVar) )
215 pSign = Vec_WrdEntryP(
p->vDivCexes, i );
216 assert( !Abc_TtGetBit( pSign,
p->nCexes) );
217 Abc_TtXorBit( pSign,
p->nCexes );
237 int iVarPivot = Sfm_ObjSatVar(
p,
p->iPivotNode );
238 int status, iNewLit, i, Div, nIter = 0;
239 Truth[0] = Truth[1] = 0;
241 iNewLit = Abc_Var2Lit( nVars, 0 );
242 assert( Vec_IntSize(
p->vDivIds) <= 6 );
243 Vec_IntFill(
p->vValues, (1 << Vec_IntSize(
p->vDivIds)) * Vec_IntSize(
p->vDivVars), -1 );
247 p->nSatCalls++; nIter++;
248 status =
sat_solver_solve(
p->pSat, &iNewLit, &iNewLit + 1,
p->pPars->nBTLimit, 0, 0, 0 );
256 fOnSet = sat_solver_var_value(
p->pSat, iVarPivot);
257 Vec_IntClear(
p->vLits );
258 Vec_IntPush(
p->vLits, Abc_LitNot(iNewLit) );
259 Vec_IntPush(
p->vLits, Abc_LitNot(sat_solver_var_literal(
p->pSat, iVarPivot)) );
262 Vec_IntPush(
p->vLits, Abc_LitNot(sat_solver_var_literal(
p->pSat, Div)) );
263 if ( sat_solver_var_value(
p->pSat, Div) )
266 if ( Truth[!fOnSet] & ((
word)1 << iMint) )
268 assert( !(Truth[fOnSet] & ((
word)1 << iMint)) );
269 Truth[fOnSet] |= ((
word)1 << iMint);
272 Vec_IntWriteEntry(
p->vValues, iMint * Vec_IntSize(
p->vDivVars) + i, sat_solver_var_value(
p->pSat, iVar) );
279 assert( iMint < (1 << Vec_IntSize(
p->vDivIds)) );
282 int Value = Vec_IntEntry(
p->vValues, iMint * Vec_IntSize(
p->vDivVars) + i);
284 if ( Value ^ sat_solver_var_value(
p->pSat, iVar) )
286 word * pSign = Vec_WrdEntryP(
p->vDivCexes, i );
287 assert( !Abc_TtGetBit( pSign,
p->nCexes) );
288 Abc_TtXorBit( pSign,
p->nCexes );
296 word Res, ResP, ResN, Truth[2];
297 int nCubesP = 0, nCubesN = 0;
308 Truth[0] = Abc_Tt6Stretch( Truth[0], Vec_IntSize(
p->vDivIds) );
309 Truth[1] = Abc_Tt6Stretch( Truth[1], Vec_IntSize(
p->vDivIds) );
310 ResP = Abc_Tt6Isop( Truth[1], ~Truth[0], Vec_IntSize(
p->vDivIds), &nCubesP );
311 ResN = Abc_Tt6Isop( Truth[0], ~Truth[1], Vec_IntSize(
p->vDivIds), &nCubesN );
312 Res = nCubesP <= nCubesN ? ResP : ~ResN;
341 Vec_IntClear(
p->vDivIds );
342 Vec_IntPush(
p->vDivIds, Sfm_ObjSatVar(
p, iDiv0) );
343 Vec_IntPush(
p->vDivIds, Sfm_ObjSatVar(
p, iDiv1) );
348 printf(
"The problem is SAT.\n" );
350 printf(
"The problem is UNDEC.\n" );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
#define sat_solver_addclause
#define sat_solver_add_xor
unsigned __int64 word
DECLARATIONS ///.
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
int sat_solver_simplify(sat_solver *s)
void sat_solver_restart(sat_solver *s)
void sat_solver_setnvars(sat_solver *s, int n)
int sat_solver_nvars(sat_solver *s)
void Sfm_TranslateCnf(Vec_Wec_t *vRes, Vec_Str_t *vCnf, Vec_Int_t *vFaninMap, int iPivotVar)
int Sfm_NtkCreateWindow(Sfm_Ntk_t *p, int iNode, int fVerbose)
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
#define SFM_FANIN_MAX
INCLUDES ///.
void Sfm_ComputeInterpolantCheck(Sfm_Ntk_t *p)
ABC_NAMESPACE_IMPL_START int Sfm_NtkWindowToSolver(Sfm_Ntk_t *p)
DECLARATIONS ///.
word Sfm_ComputeInterpolant(Sfm_Ntk_t *p)
word Sfm_ComputeInterpolant2(Sfm_Ntk_t *p)
int Sfm_ComputeInterpolantInt(Sfm_Ntk_t *p, word Truth[2])
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.