Commit 07405ca1 by Alan Mishchenko

Integrated new proof-logging into proof-based gate-level abstraction.

parent b5c3992b
......@@ -606,7 +606,7 @@ int Gia_ManCexAbstractionRefine( Gia_Man_t * pGia, Abc_Ce
extern int Gia_ManPbaPerform( Gia_Man_t * pGia, int nStart, int nFrames, int nConfLimit, int nTimeLimit, int fVerbose, int * piFrame );
extern int Gia_ManCbaPerform( Gia_Man_t * pGia, void * pPars );
extern int Gia_ManGlaCbaPerform( Gia_Man_t * pGia, void * pPars, int fNaiveCnf );
extern int Gia_ManGlaPbaPerform( Gia_Man_t * pGia, void * pPars );
extern int Gia_ManGlaPbaPerform( Gia_Man_t * pGia, void * pPars, int fNewSolver );
/*=== giaAiger.c ===========================================================*/
extern int Gia_FileSize( char * pFileName );
extern Gia_Man_t * Gia_ReadAigerFromMemory( char * pContents, int nFileSize, int fCheck );
......
......@@ -424,9 +424,10 @@ int Gia_ManGlaCbaPerform( Gia_Man_t * pGia, void * pPars, int fNaiveCnf )
SeeAlso []
***********************************************************************/
int Gia_ManGlaPbaPerform( Gia_Man_t * pGia, void * pPars )
int Gia_ManGlaPbaPerform( Gia_Man_t * pGia, void * pPars, int fNewSolver )
{
extern Vec_Int_t * Aig_Gla2ManPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nConfLimit, int TimeLimit, int fSkipRand, int fVerbose );
extern Vec_Int_t * Aig_Gla3ManPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nConfLimit, int TimeLimit, int fSkipRand, int fVerbose );
Saig_ParBmc_t * p = (Saig_ParBmc_t *)pPars;
Vec_Int_t * vGateClasses;
Gia_Man_t * pGiaAbs;
......@@ -447,7 +448,10 @@ int Gia_ManGlaPbaPerform( Gia_Man_t * pGia, void * pPars )
}
// perform abstraction
vGateClasses = Aig_Gla2ManPerform( pAig, p->nStart, p->nFramesMax, p->nConfLimit, p->nTimeOut, p->fSkipRand, p->fVerbose );
if ( fNewSolver )
vGateClasses = Aig_Gla3ManPerform( pAig, p->nStart, p->nFramesMax, p->nConfLimit, p->nTimeOut, p->fSkipRand, p->fVerbose );
else
vGateClasses = Aig_Gla2ManPerform( pAig, p->nStart, p->nFramesMax, p->nConfLimit, p->nTimeOut, p->fSkipRand, p->fVerbose );
Aig_ManStop( pAig );
// update the BMC depth
......
......@@ -13,6 +13,7 @@ SRC += src/aig/saig/saigAbs.c \
src/aig/saig/saigDup.c \
src/aig/saig/saigGlaCba.c \
src/aig/saig/saigGlaPba.c \
src/aig/saig/saigGlaPba2.c \
src/aig/saig/saigHaig.c \
src/aig/saig/saigInd.c \
src/aig/saig/saigIoa.c \
......
......@@ -432,11 +432,10 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo
Vec_Int_t * vCore;
void * pSatCnf;
Intp_Man_t * pManProof;
int RetValue;
int RetValue, clk = clock();
if ( piRetValue )
*piRetValue = -1;
// solve the problem
Abc_Clock(2,1);
RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue == l_Undef )
{
......@@ -453,19 +452,19 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo
if ( fVerbose )
{
printf( "SAT solver returned UNSAT after %7d conflicts. ", pSat->stats.conflicts );
ABC_PRT( "Time", (Abc_Clock(2,0)/ABC_CPS)*CLOCKS_PER_SEC );
Abc_PrintTime( 1, "Time", clock() - clk );
}
assert( RetValue == l_False );
pSatCnf = sat_solver_store_release( pSat );
// derive the UNSAT core
Abc_Clock(2,1);
clk = clock();
pManProof = Intp_ManAlloc();
vCore = (Vec_Int_t *)Intp_ManUnsatCore( pManProof, (Sto_Man_t *)pSatCnf, 0 );
Intp_ManFree( pManProof );
if ( fVerbose )
{
printf( "SAT core contains %8d clauses (out of %8d). ", Vec_IntSize(vCore), ((Sto_Man_t *)pSatCnf)->nRoots );
ABC_PRT( "Time", (Abc_Clock(2,0)/ABC_CPS)*CLOCKS_PER_SEC );
printf( "SAT core contains %8d clauses (out of %8d). ", Vec_IntSize(vCore), sat_solver_nclauses(pSat) );
Abc_PrintTime( 1, "Time", clock() - clk );
}
Sto_ManFree( (Sto_Man_t *)pSatCnf );
return vCore;
......@@ -561,7 +560,6 @@ Vec_Int_t * Aig_Gla2ManPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, in
int clk, clk2 = clock();
assert( Saig_ManPoNum(pAig) == 1 );
Abc_Clock(0,1);
if ( fVerbose )
{
if ( TimeLimit )
......@@ -572,7 +570,6 @@ Vec_Int_t * Aig_Gla2ManPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, in
// start the solver
clk = clock();
Abc_Clock(1,1);
p = Aig_Gla2ManStart( pAig, nStart, nFramesMax, fVerbose );
if ( !Aig_Gla2CreateSatSolver( p ) )
{
......@@ -581,7 +578,6 @@ Vec_Int_t * Aig_Gla2ManPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, in
return NULL;
}
sat_solver_set_random( p->pSat, fSkipRand );
// p->timePre += (Abc_Clock(1,0)/ABC_CPS)*CLOCKS_PER_SEC;
p->timePre += clock() - clk;
// set runtime limit
......@@ -590,15 +586,12 @@ Vec_Int_t * Aig_Gla2ManPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, in
// compute UNSAT core
clk = clock();
Abc_Clock(1,1);
vCore = Saig_AbsSolverUnsatCore( p->pSat, nConfLimit, fVerbose, NULL );
if ( vCore == NULL )
{
Aig_Gla2ManStop( p );
return NULL;
}
// p->timeSat += (Abc_Clock(1,0)/ABC_CPS)*CLOCKS_PER_SEC;
// p->timeTotal = (Abc_Clock(0,0)/ABC_CPS)*CLOCKS_PER_SEC;
p->timeSat += clock() - clk;
p->timeTotal += clock() - clk2;
......
......@@ -29093,13 +29093,14 @@ int Abc_CommandAbc9GlaPba( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Saig_ParBmc_t Pars, * pPars = &Pars;
int c;
int fNewSolver = 0;
Saig_ParBmcSetDefaultParams( pPars );
pPars->nStart = 0;
pPars->nFramesMax = (pAbc->nFrames >= 0) ? pAbc->nFrames : 10;
pPars->nConfLimit = 0;
pPars->fSkipRand = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "SFCTrvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "SFCTrnvh" ) ) != EOF )
{
switch ( c )
{
......@@ -29150,6 +29151,9 @@ int Abc_CommandAbc9GlaPba( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'r':
pPars->fSkipRand ^= 1;
break;
case 'n':
fNewSolver ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
break;
......@@ -29186,20 +29190,21 @@ int Abc_CommandAbc9GlaPba( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pPars->nStart )
Abc_Print( 0, "The starting frame is specified. The resulting abstraction may be unsound.\n" );
pAbc->Status = Gia_ManGlaPbaPerform( pAbc->pGia, pPars );
pAbc->Status = Gia_ManGlaPbaPerform( pAbc->pGia, pPars, fNewSolver );
// if ( pPars->nStart == 0 )
pAbc->nFrames = pPars->iFrame;
Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
return 0;
usage:
Abc_Print( -2, "usage: &gla_pba [-SFCT num] [-rvh]\n" );
Abc_Print( -2, "usage: &gla_pba [-SFCT num] [-rnvh]\n" );
Abc_Print( -2, "\t refines abstracted object map with proof-based abstraction\n" );
Abc_Print( -2, "\t-S num : the starting time frame (0=unused) [default = %d]\n", pPars->nStart );
Abc_Print( -2, "\t-F num : the max number of timeframes to unroll [default = %d]\n", pPars->nFramesMax );
Abc_Print( -2, "\t-C num : the max number of SAT solver conflicts (0=unused) [default = %d]\n", pPars->nConfLimit );
Abc_Print( -2, "\t-T num : an approximate timeout, in seconds [default = %d]\n", pPars->nTimeOut );
Abc_Print( -2, "\t-r : toggle using random decisiont during SAT solving [default = %s]\n", !pPars->fSkipRand? "yes": "no" );
Abc_Print( -2, "\t-n : toggle using on-the-fly proof-logging [default = %s]\n", fNewSolver? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
......
......@@ -28,7 +28,6 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
ABC_NAMESPACE_IMPL_START
#define SAT_USE_ANALYZE_FINAL
#define SAT_USE_PROOF_LOGGING
......@@ -369,7 +368,7 @@ static inline void act_clause_decay(sat_solver2* s) { s->cla_inc += (s->cla_inc
//=================================================================================================
// Clause functions:
static int clause_new(sat_solver2* s, lit* begin, lit* end, int learnt, int proof_id)
static int clause_create_new(sat_solver2* s, lit* begin, lit* end, int learnt, int proof_id)
{
satset* c;
int i, Cid, nLits = end - begin;
......@@ -516,7 +515,7 @@ static void solver2_record(sat_solver2* s, veci* cls, int proof_id)
{
lit* begin = veci_begin(cls);
lit* end = begin + veci_size(cls);
int Cid = clause_new(s,begin,end,1, proof_id);
int Cid = clause_create_new(s,begin,end,1, proof_id);
assert(veci_size(cls) > 0);
if ( veci_size(cls) == 1 )
{
......@@ -888,6 +887,7 @@ satset* solver2_propagate(sat_solver2* s)
veci* ws;
lit* lits, false_lit, p, * stop, * k;
cla* begin,* end, *i, *j;
int Lit;
while (confl == 0 && s->qtail - s->qhead > 0){
......@@ -926,9 +926,10 @@ satset* solver2_propagate(sat_solver2* s)
}
// Did not find watch -- clause is unit under assignment:
Lit = lits[0];
if (s->fProofLogging && solver2_dlevel(s) == 0){
int k, x, proof_id, Cid, Var = lit_var(lits[0]);
int fLitIsFalse = (var_value(s, Var) == !lit_sign(lits[0]));
int k, x, proof_id, Cid, Var = lit_var(Lit);
int fLitIsFalse = (var_value(s, Var) == !lit_sign(Lit));
// Log production of top-level unit clause:
proof_chain_start( s, c );
satset_foreach_var( c, x, k, 1 ){
......@@ -937,7 +938,7 @@ satset* solver2_propagate(sat_solver2* s)
}
proof_id = proof_chain_stop( s );
// get a new clause
Cid = clause_new( s, lits, lits + 1, 1, proof_id );
Cid = clause_create_new( s, &Lit, &Lit + 1, 1, proof_id );
assert( (var_unit_clause(s, Var) == NULL) != fLitIsFalse );
// if variable already has unit clause, it must be with the other polarity
// in this case, we should derive the empty clause here
......@@ -948,13 +949,13 @@ satset* solver2_propagate(sat_solver2* s)
proof_chain_start( s, clause_read(s,Cid) );
proof_chain_resolve( s, NULL, Var );
proof_id = proof_chain_stop( s );
clause_new( s, lits, lits, 1, proof_id );
clause_create_new( s, &Lit, &Lit, 1, proof_id );
}
}
*j++ = *i;
// Clause is unit under assignment:
if (!solver2_enqueue(s,lits[0], *i)){
if (!solver2_enqueue(s,Lit, *i)){
confl = clause_read(s,*i++);
// Copy the remaining watches:
while (i < end)
......@@ -1275,16 +1276,17 @@ void sat_solver2_setnvars(sat_solver2* s,int n)
void sat_solver2_delete(sat_solver2* s)
{
satset * c = clause_read(s, s->hLearntLast);
// veci * pCore;
// report statistics
printf( "Used %6.2f Mb for proof-logging. Unit clauses = %d.\n", 2.0 * veci_size(&s->proofs) / (1<<20), s->nUnits );
/*
pCore = Sat_ProofCore( s );
printf( "UNSAT core contains %d clauses (%6.2f %%).\n", veci_size(pCore), 100.0*veci_size(pCore)/veci_size(&s->clauses) );
veci_delete( pCore );
ABC_FREE( pCore );
Sat_ProofTest(
&s->clauses, // clauses
&s->proofs, // proof clauses
NULL, // proof roots
veci_begin(&s->claProofs)[c->Id] // one root
);
*/
// Sat_ProofCheck( s );
// delete vectors
veci_delete(&s->order);
......@@ -1308,10 +1310,7 @@ void sat_solver2_delete(sat_solver2* s)
int i;
if ( s->wlists )
for (i = 0; i < s->size*2; i++)
{
// printf( "%d ", s->wlists[i].size );
veci_delete(&s->wlists[i]);
}
ABC_FREE(s->wlists );
ABC_FREE(s->vi );
ABC_FREE(s->trail );
......@@ -1375,7 +1374,7 @@ int sat_solver2_addclause__(sat_solver2* s, lit* begin, lit* end)
return solver2_enqueue(s,*begin,0);
// create new clause
return clause_new(s,begin,j,0,0);
return clause_create_new(s,begin,j,0,0);
}
int sat_solver2_addclause(sat_solver2* s, lit* begin, lit* end)
......@@ -1404,21 +1403,17 @@ int sat_solver2_addclause(sat_solver2* s, lit* begin, lit* end)
sat_solver2_setnvars(s,maxvar+1);
// create a new clause
Cid = clause_new( s, begin, end, 0, 0 );
Cid = clause_create_new( s, begin, end, 0, 0 );
// handle unit clause
if ( begin + 1 == end )
{
printf( "Adding unit clause %d\n", begin[0] );
// printf( "Adding unit clause %d\n", begin[0] );
// solver2_canceluntil(s, 0);
if ( s->fProofLogging )
var_set_unit_clause( s, lit_var(begin[0]), Cid );
if ( !solver2_enqueue(s,begin[0],0) )
assert( 0 );
}
// count literals
s->stats.clauses++;
s->stats.clauses_literals += end - begin;
return Cid;
}
......@@ -1447,7 +1442,6 @@ void luby2_test()
// updates clauses, watches, units, and proof
void solver2_reducedb(sat_solver2* s)
{
extern void Sat_ProofReduce( veci * pProof, veci * pRoots );
satset * c;
cla h,* pArray,* pArray2;
int Counter = 0, CounterStart = s->stats.learnts * 3 / 4; // 2/3;
......@@ -1504,7 +1498,7 @@ void solver2_reducedb(sat_solver2* s)
s->stats.learnts = veci_size(&s->learnt_live);
// compact proof (compacts 'proofs' and update 'claProofs')
Sat_ProofReduce( &s->proofs, &s->claProofs );
Sat_ProofReduce( s );
TimeTotal += clock() - clk;
Abc_PrintTime( 1, "Time", TimeTotal );
......@@ -1658,7 +1652,7 @@ int sat_solver2_solve(sat_solver2* s, lit* begin, lit* end, ABC_INT64_T nConfLim
// reduce the set of learnt clauses:
if (nof_learnts > 0 && s->stats.learnts > nof_learnts)
{
solver2_reducedb(s);
// solver2_reducedb(s);
nof_learnts = nof_learnts * 11 / 10;
}
// perform next run
......
......@@ -59,14 +59,6 @@ extern void sat_solver2TraceStart( sat_solver2 * pSat, char * pName );
extern void sat_solver2TraceStop( sat_solver2 * pSat );
extern void sat_solver2TraceWrite( sat_solver2 * pSat, int * pBeg, int * pEnd, int fRoot );
// clause storage
extern void sat_solver2_store_alloc( sat_solver2 * s );
extern void sat_solver2_store_write( sat_solver2 * s, char * pFileName );
extern void sat_solver2_store_free( sat_solver2 * s );
extern void sat_solver2_store_mark_roots( sat_solver2 * s );
extern void sat_solver2_store_mark_clauses_a( sat_solver2 * s );
extern void * sat_solver2_store_release( sat_solver2 * s );
// global variables
extern int var_is_partA (sat_solver2* s, int v);
extern void var_set_partA(sat_solver2* s, int v, int partA);
......@@ -76,6 +68,11 @@ extern void clause_set_partA(sat_solver2* s, int handle, int partA);
// other clause functions
extern int clause_id(sat_solver2* s, int h);
// proof-based APIs
extern void * Sat_ProofCore( sat_solver2 * s );
extern void * Sat_ProofInterpolant( sat_solver2 * s, void * pGloVars );
extern void Sat_ProofReduce( sat_solver2 * s );
extern void Sat_ProofCheck( sat_solver2 * s );
//=================================================================================================
// Solver representation:
......@@ -247,8 +244,6 @@ static inline int sat_solver2_set_random(sat_solver2* s, int fNotUseRandom)
return fNotUseRandomOld;
}
extern void Sat_ProofTest( veci * pClauses, veci * pProof, veci * pRoots, int hRoot );
ABC_NAMESPACE_HEADER_END
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment