ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
kissatSolver.h File Reference
#include "aig/gia/gia.h"
#include "sat/cnf/cnf.h"
Include dependency graph for kissatSolver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kissat_solver_
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct kissat_solver_ kissat_solver
 INCLUDES ///.
 

Functions

kissat_solverkissat_solver_new (void)
 MACRO DEFINITIONS ///.
 
void kissat_solver_delete (kissat_solver *s)
 
int kissat_solver_addclause (kissat_solver *s, int *begin, int *end)
 
int kissat_solver_solve (kissat_solver *s, int *begin, int *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
 
int kissat_solver_nvars (kissat_solver *s)
 
int kissat_solver_addvar (kissat_solver *s)
 
void kissat_solver_setnvars (kissat_solver *s, int n)
 
int kissat_solver_get_var_value (kissat_solver *s, int v)
 
Vec_Int_tkissat_solve_cnf (Cnf_Dat_t *pCnf, char *pArgs, int nConfs, int nTimeLimit, int fSat, int fUnsat, int fPrintCex, int fVerbose)
 

Typedef Documentation

◆ kissat_solver

typedef typedefABC_NAMESPACE_HEADER_START struct kissat_solver_ kissat_solver

INCLUDES ///.

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

FileName [kissatSolver.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT solver Kissat by Armin Biere, University of Freiburg]

Synopsis [https://github.com/arminbiere/kissat]

Author [Integrated into ABC by Yukio Miyasaka]

Affiliation [UC Berkeley]

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

Revision [

Id
kissatSolver.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS /// BASIC TYPES ///

Definition at line 41 of file kissatSolver.h.

Function Documentation

◆ kissat_solve_cnf()

Vec_Int_t * kissat_solve_cnf ( Cnf_Dat_t * pCnf,
char * pArgs,
int nConfs,
int nTimeLimit,
int fSat,
int fUnsat,
int fPrintCex,
int fVerbose )
extern

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

Synopsis [Solves the given CNF using kissat.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file kissatSolver.c.

207{
208 abctime clk = Abc_Clock();
209 Vec_Int_t * vRes = NULL;
210 int i, * pBeg, * pEnd, RetValue;
211 if ( fVerbose )
212 printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
214 kissat_solver_setnvars(pSat, pCnf->nVars);
215 assert(kissat_solver_nvars(pSat) == pCnf->nVars);
216 Cnf_CnfForClause( pCnf, pBeg, pEnd, i ) {
217 if ( !kissat_solver_addclause(pSat, pBeg, pEnd) )
218 {
219 assert( 0 ); // if it happens, can return 1 (unsatisfiable)
220 return NULL;
221 }
222 }
223 RetValue = kissat_solver_solve(pSat, NULL, NULL, 0, 0, 0, 0);
224 if ( RetValue == 1 )
225 printf( "Result: Satisfiable. " );
226 else if ( RetValue == -1 )
227 printf( "Result: Unsatisfiable. " );
228 else
229 printf( "Result: Undecided. " );
230 if ( RetValue == 1 ) {
231 vRes = Vec_IntAlloc( pCnf->nVars );
232 for ( i = 0; i < pCnf->nVars; i++ )
233 Vec_IntPush( vRes, kissat_solver_get_var_value(pSat, i) );
234 }
236 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
237 return vRes;
238}
ABC_INT64_T abctime
Definition abc_global.h:332
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Cnf_CnfForClause(p, pBeg, pEnd, i)
MACRO DEFINITIONS ///.
Definition cnf.h:117
int kissat_solver_solve(kissat_solver *s, int *begin, int *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
int kissat_solver_addclause(kissat_solver *s, int *begin, int *end)
int kissat_solver_get_var_value(kissat_solver *s, int v)
void kissat_solver_delete(kissat_solver *s)
ABC_NAMESPACE_IMPL_START kissat_solver * kissat_solver_new(void)
DECLARATIONS ///.
int kissat_solver_nvars(kissat_solver *s)
void kissat_solver_setnvars(kissat_solver *s, int n)
typedefABC_NAMESPACE_HEADER_START struct kissat_solver_ kissat_solver
INCLUDES ///.
int nVars
Definition cnf.h:59
int nLiterals
Definition cnf.h:60
int nClauses
Definition cnf.h:61
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ kissat_solver_addclause()

int kissat_solver_addclause ( kissat_solver * s,
int * begin,
int * end )
extern

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

Synopsis [add clause]

Description [kissat takes x and -x as a literal for a variable x > 0, where 0 is an indicator of the end of a clause. since variables start from 0 in abc, a variable v is translated into v + 1 in kissat.]

SideEffects []

SeeAlso []

Definition at line 82 of file kissatSolver.c.

82 {
83 for(;begin != end; begin++) {
84 if(*begin & 1) {
85 kissat_add((kissat*)s->p, -(1 + ((*begin) >> 1)));
86 } else {
87 kissat_add((kissat*)s->p, 1 + ((*begin) >> 1) );
88 }
89 }
90 kissat_add((kissat*)s->p, 0);
91 return !kissat_is_inconsistent((kissat*)s->p);
92}
void kissat_add(kissat *solver, int elit)
Definition internal.c:268
int kissat_is_inconsistent(kissat *solver)
Definition internal.c:524
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_solver_addvar()

int kissat_solver_addvar ( kissat_solver * s)
extern

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

Synopsis [add new variable]

Description [emulated using "nVars".]

SideEffects []

SeeAlso []

Definition at line 158 of file kissatSolver.c.

158 {
159 return s->nVars++;
160}
Here is the caller graph for this function:

◆ kissat_solver_delete()

void kissat_solver_delete ( kissat_solver * s)
extern

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

Synopsis [delete solver]

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file kissatSolver.c.

63 {
64 kissat_release((kissat*)s->p);
65 free(s);
66}
void kissat_release(kissat *solver)
Definition internal.c:81
VOID_HACK free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_solver_get_var_value()

int kissat_solver_get_var_value ( kissat_solver * s,
int v )
extern

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

Synopsis [get value of variable]

Description [kissat returns x (true) or -x (false) for a variable x. note a variable v was translated into v + 1 in kissat.]

SideEffects []

SeeAlso []

Definition at line 190 of file kissatSolver.c.

190 {
191 return kissat_value((kissat*)s->p, v + 1) > 0;
192}
int kissat_value(kissat *solver, int elit)
Definition internal.c:498
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_solver_new()

kissat_solver * kissat_solver_new ( void )
extern

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

MACRO DEFINITIONS ///.

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

FileName [kissatSolver.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT solver Kissat by Armin Biere, University of Freiburg]

Synopsis [https://github.com/arminbiere/kissat]

Author [Integrated into ABC by Yukio Miyasaka]

Affiliation [UC Berkeley]

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

Revision [

Id
kissatSolver.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [allocate solver]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file kissatSolver.c.

45 {
47 s->p = (void*)kissat_init();
48 s->nVars = 0;
49 return s;
50}
kissat * kissat_init(void)
Definition internal.c:27
char * malloc()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_solver_nvars()

int kissat_solver_nvars ( kissat_solver * s)
extern

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

Synopsis [get number of variables]

Description [emulated using "nVars".]

SideEffects []

SeeAlso []

Definition at line 143 of file kissatSolver.c.

143 {
144 return s->nVars;
145}
Here is the caller graph for this function:

◆ kissat_solver_setnvars()

void kissat_solver_setnvars ( kissat_solver * s,
int n )
extern

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

Synopsis [set number of variables]

Description [not only emulate with "nVars" but also reserve memory.]

SideEffects []

SeeAlso []

Definition at line 173 of file kissatSolver.c.

173 {
174 s->nVars = n;
175 kissat_reserve((kissat*)s->p, n);
176}
void kissat_reserve(kissat *solver, int max_var)
Definition internal.c:169
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_solver_solve()

int kissat_solver_solve ( kissat_solver * s,
int * begin,
int * end,
ABC_INT64_T nConfLimit,
ABC_INT64_T nInsLimit,
ABC_INT64_T nConfLimitGlobal,
ABC_INT64_T nInsLimitGlobal )
extern

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

Synopsis [solve with resource limits]

Description [assumptions and inspection limits are not supported.]

SideEffects []

SeeAlso []

Definition at line 105 of file kissatSolver.c.

105 {
106 // assumptions are not supported
107 assert(begin == end);
108 // inspection limits are not supported
109 assert(nInsLimit == 0);
110 assert(nInsLimitGlobal == 0);
111 // set conflict limits
112 if(nConfLimit)
113 kissat_set_conflict_limit((kissat*)s->p, nConfLimit);
114 if(nConfLimitGlobal && (nConfLimit == 0 || nConfLimit > nConfLimitGlobal))
115 kissat_set_conflict_limit((kissat*)s->p, nConfLimitGlobal);
116 // solve
117 int res = kissat_solve((kissat*)s->p);
118 // translate this kissat return value into a corresponding ABC status value
119 switch(res) {
120 case 0: // UNDETERMINED
121 return 0;
122 case 10: // SATISFIABLE
123 return 1;
124 case 20: // UNSATISFIABLE
125 return -1;
126 default:
127 assert(0);
128 }
129 return 0;
130}
int kissat_solve(kissat *solver)
Definition internal.c:477
void kissat_set_conflict_limit(kissat *solver, unsigned limit)
Definition internal.c:222
Here is the call graph for this function:
Here is the caller graph for this function: