mirror of https://github.com/YosysHQ/abc.git
patch
This commit is contained in:
parent
a7476c65d8
commit
664d285fcb
2
Makefile
2
Makefile
|
|
@ -28,7 +28,7 @@ MODULES := \
|
|||
src/opt/cut src/opt/fxu src/opt/fxch src/opt/rwr src/opt/mfs src/opt/sim \
|
||||
src/opt/ret src/opt/fret src/opt/res src/opt/lpk src/opt/nwk src/opt/rwt src/opt/rar \
|
||||
src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/dsc src/opt/sfm src/opt/sbd \
|
||||
src/sat/bsat src/sat/xsat src/sat/satoko src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc src/sat/glucose src/sat/glucose2 \
|
||||
src/sat/bsat src/sat/xsat src/sat/satoko src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc src/sat/glucose src/sat/glucose2 src/sat/kissat \
|
||||
src/bool/bdc src/bool/deco src/bool/dec src/bool/kit src/bool/lucky \
|
||||
src/bool/rsb src/bool/rpo \
|
||||
src/proof/pdr src/proof/abs src/proof/live src/proof/ssc src/proof/int \
|
||||
|
|
|
|||
368
abclib.dsp
368
abclib.dsp
|
|
@ -2518,6 +2518,374 @@ SOURCE=.\src\sat\glucose2\Vec.h
|
|||
SOURCE=.\src\sat\glucose2\XAlloc.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "kissat"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\allocate.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\analyze.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\ands.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\arena.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\assign.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\averages.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\backbone.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\backtrack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\build.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\bump.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\check.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\classify.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\clause.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\collect.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\colors.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\compact.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\config.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\congruence.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\decide.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\deduce.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\definition.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\dense.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\dump.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\eliminate.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\equivalences.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\error.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\extend.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\factor.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\fastel.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\file.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\flags.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\format.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\forward.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\gates.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\heap.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\ifthenelse.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\import.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\internal.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\kimits.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\kissatSolver.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\kissatTest.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\kitten.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\kptions.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\krite.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\kucky.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\learn.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\logging.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\minimize.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\mode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\phases.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\preprocess.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\print.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\probe.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\profile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\promote.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\proof.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\propbeyond.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\propdense.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\propinitially.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\proprobe.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\propsearch.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\queue.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\reduce.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\reluctant.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\reorder.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\rephase.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\report.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\resize.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\resolve.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\resources.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\restart.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\search.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\shrink.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\smooth.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\sort.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\stack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\statistics.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\strengthen.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\substitute.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\sweep.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\terminate.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\tiers.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\trail.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\transitive.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\utilities.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\vector.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\vivify.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\walk.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\warmup.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\watch.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\kissat\weaken.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "opt"
|
||||
|
||||
|
|
|
|||
|
|
@ -56001,6 +56001,11 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
extern void kissat_solver_test();
|
||||
kissat_solver_test();
|
||||
return 0;
|
||||
|
||||
if ( pAbc->pGia == NULL )
|
||||
{
|
||||
Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" );
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void inc_bytes (kissat *solver, size_t bytes) {
|
||||
#ifdef METRICS
|
||||
if (!solver)
|
||||
|
|
@ -62,16 +64,16 @@ void kissat_free (kissat *solver, void *ptr, size_t bytes) {
|
|||
dec_bytes (solver, bytes);
|
||||
free (ptr);
|
||||
} else
|
||||
assert (!bytes);
|
||||
KISSAT_assert (!bytes);
|
||||
}
|
||||
|
||||
char *kissat_strdup (kissat *solver, const char *str) {
|
||||
char *res = kissat_malloc (solver, strlen (str) + 1);
|
||||
char *res = (char*)kissat_malloc (solver, strlen (str) + 1);
|
||||
return strcpy (res, str);
|
||||
}
|
||||
|
||||
void kissat_freestr (struct kissat *solver, char *str) {
|
||||
assert (str);
|
||||
KISSAT_assert (str);
|
||||
kissat_free (solver, str, strlen (str) + 1);
|
||||
}
|
||||
|
||||
|
|
@ -149,8 +151,8 @@ void *kissat_realloc (kissat *solver, void *p, size_t old_bytes,
|
|||
void *kissat_nrealloc (kissat *solver, void *p, size_t o, size_t n,
|
||||
size_t size) {
|
||||
if (!size) {
|
||||
assert (!p);
|
||||
assert (!o);
|
||||
KISSAT_assert (!p);
|
||||
KISSAT_assert (!o);
|
||||
return 0;
|
||||
}
|
||||
const size_t max = MAX_SIZE_T / size;
|
||||
|
|
@ -159,3 +161,5 @@ void *kissat_nrealloc (kissat *solver, void *p, size_t o, size_t n,
|
|||
n, size);
|
||||
return kissat_realloc (solver, p, o * size, n * size);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
void *kissat_malloc (struct kissat *, size_t bytes);
|
||||
|
|
@ -18,14 +21,14 @@ void kissat_dealloc (struct kissat *, void *ptr, size_t n, size_t size);
|
|||
void *kissat_realloc (struct kissat *, void *, size_t old, size_t bytes);
|
||||
void *kissat_nrealloc (struct kissat *, void *, size_t o, size_t n, size_t);
|
||||
|
||||
#define NALLOC(P, N) \
|
||||
#define NALLOC(T, P, N) \
|
||||
do { \
|
||||
(P) = kissat_nalloc (solver, (N), sizeof *(P)); \
|
||||
(P) = (T*) kissat_nalloc (solver, (N), sizeof *(P)); \
|
||||
} while (0)
|
||||
|
||||
#define CALLOC(P, N) \
|
||||
#define CALLOC(T, P, N) \
|
||||
do { \
|
||||
(P) = kissat_calloc (solver, (N), sizeof *(P)); \
|
||||
(P) = (T*) kissat_calloc (solver, (N), sizeof *(P)); \
|
||||
} while (0)
|
||||
|
||||
#define DEALLOC(P, N) \
|
||||
|
|
@ -33,4 +36,6 @@ void *kissat_nrealloc (struct kissat *, void *, size_t o, size_t n, size_t);
|
|||
kissat_dealloc (solver, (P), (N), sizeof *(P)); \
|
||||
} while (0)
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static bool one_literal_on_conflict_level (kissat *solver, clause *conflict,
|
||||
unsigned *conflict_level_ptr) {
|
||||
assert (conflict);
|
||||
assert (conflict->size > 1);
|
||||
KISSAT_assert (conflict);
|
||||
KISSAT_assert (conflict->size > 1);
|
||||
|
||||
unsigned jump_level = INVALID_LEVEL;
|
||||
unsigned conflict_level = INVALID_LEVEL;
|
||||
|
|
@ -31,7 +33,7 @@ static bool one_literal_on_conflict_level (kissat *solver, clause *conflict,
|
|||
|
||||
for (const unsigned *p = lits; p != end_of_lits; p++) {
|
||||
const unsigned lit = *p;
|
||||
assert (VALUE (lit) < 0);
|
||||
KISSAT_assert (VALUE (lit) < 0);
|
||||
const unsigned idx = IDX (lit);
|
||||
const unsigned lit_level = all_assigned[idx].level;
|
||||
if (conflict_level == INVALID_LEVEL || conflict_level < lit_level) {
|
||||
|
|
@ -48,8 +50,8 @@ static bool one_literal_on_conflict_level (kissat *solver, clause *conflict,
|
|||
if (literals_on_conflict_level > 1 && conflict_level == solver->level)
|
||||
break;
|
||||
}
|
||||
assert (conflict_level != INVALID_LEVEL);
|
||||
assert (literals_on_conflict_level);
|
||||
KISSAT_assert (conflict_level != INVALID_LEVEL);
|
||||
KISSAT_assert (literals_on_conflict_level);
|
||||
|
||||
LOG ("found %u literals on conflict level %u", literals_on_conflict_level,
|
||||
conflict_level);
|
||||
|
|
@ -105,10 +107,10 @@ static bool one_literal_on_conflict_level (kissat *solver, clause *conflict,
|
|||
if (literals_on_conflict_level > 1)
|
||||
return false;
|
||||
|
||||
assert (literals_on_conflict_level == 1);
|
||||
assert (forced_lit != INVALID_LIT);
|
||||
assert (jump_level != INVALID_LEVEL);
|
||||
assert (jump_level < conflict_level);
|
||||
KISSAT_assert (literals_on_conflict_level == 1);
|
||||
KISSAT_assert (forced_lit != INVALID_LIT);
|
||||
KISSAT_assert (jump_level != INVALID_LEVEL);
|
||||
KISSAT_assert (jump_level < conflict_level);
|
||||
|
||||
LOG ("reusing conflict as driving clause of %s", LOGLIT (forced_lit));
|
||||
|
||||
|
|
@ -116,7 +118,7 @@ static bool one_literal_on_conflict_level (kissat *solver, clause *conflict,
|
|||
kissat_backtrack_after_conflict (solver, new_level);
|
||||
|
||||
if (conflict_size == 2) {
|
||||
assert (conflict == &solver->conflict);
|
||||
KISSAT_assert (conflict == &solver->conflict);
|
||||
const unsigned other = lits[0] ^ lits[1] ^ forced_lit;
|
||||
kissat_assign_binary (solver, forced_lit, other);
|
||||
} else {
|
||||
|
|
@ -142,9 +144,9 @@ static inline void analyze_reason_side_literal (kissat *solver,
|
|||
unsigned lit) {
|
||||
const unsigned idx = IDX (lit);
|
||||
const assigned *a = all_assigned + idx;
|
||||
assert (a->level);
|
||||
assert (a->analyzed);
|
||||
assert (a->reason != UNIT_REASON);
|
||||
KISSAT_assert (a->level);
|
||||
KISSAT_assert (a->analyzed);
|
||||
KISSAT_assert (a->reason != UNIT_REASON);
|
||||
if (a->reason == DECISION_REASON)
|
||||
return;
|
||||
if (a->binary) {
|
||||
|
|
@ -152,13 +154,13 @@ static inline void analyze_reason_side_literal (kissat *solver,
|
|||
mark_reason_side_literal (solver, all_assigned, other);
|
||||
} else {
|
||||
const reference ref = a->reason;
|
||||
assert (ref < SIZE_STACK (solver->arena));
|
||||
KISSAT_assert (ref < SIZE_STACK (solver->arena));
|
||||
clause *c = (clause *) (arena + ref);
|
||||
const unsigned not_lit = NOT (lit);
|
||||
INC (search_ticks);
|
||||
for (all_literals_in_clause (other, c))
|
||||
if (other != not_lit) {
|
||||
assert (other != lit);
|
||||
KISSAT_assert (other != lit);
|
||||
mark_reason_side_literal (solver, all_assigned, other);
|
||||
if (SIZE_STACK (solver->analyzed) > limit)
|
||||
break;
|
||||
|
|
@ -183,9 +185,9 @@ static void analyze_reason_side_literals (kissat *solver) {
|
|||
return;
|
||||
}
|
||||
assigned *all_assigned = solver->assigned;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
for (all_stack (unsigned, lit, solver->clause))
|
||||
assert (all_assigned[IDX (lit)].analyzed);
|
||||
KISSAT_assert (all_assigned[IDX (lit)].analyzed);
|
||||
#endif
|
||||
LOG ("trying to bump reason side literals too");
|
||||
const size_t saved = SIZE_STACK (solver->analyzed);
|
||||
|
|
@ -203,7 +205,7 @@ static void analyze_reason_side_literals (kissat *solver) {
|
|||
const unsigned idx = POP_STACK (solver->analyzed);
|
||||
struct assigned *a = all_assigned + idx;
|
||||
LOG ("marking %s as not analyzed", LOGVAR (idx));
|
||||
assert (a->analyzed);
|
||||
KISSAT_assert (a->analyzed);
|
||||
a->analyzed = false;
|
||||
}
|
||||
BUMP_DELAY (bumpreasons);
|
||||
|
|
@ -228,7 +230,7 @@ static void sort_levels (kissat *solver) {
|
|||
|
||||
static void sort_deduced_clause (kissat *solver) {
|
||||
sort_levels (solver);
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
const size_t size_frames = SIZE_STACK (solver->frames);
|
||||
#endif
|
||||
frame *frames = BEGIN_STACK (solver->frames);
|
||||
|
|
@ -238,25 +240,25 @@ static void sort_deduced_clause (kissat *solver) {
|
|||
unsigned const *p = end_levels;
|
||||
while (p != begin_levels) {
|
||||
const unsigned level = *--p;
|
||||
assert (level < size_frames);
|
||||
KISSAT_assert (level < size_frames);
|
||||
frame *f = frames + level;
|
||||
const unsigned used = f->used;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
f->saved = used;
|
||||
#endif
|
||||
assert (used > 0);
|
||||
assert (UINT_MAX - used >= pos);
|
||||
KISSAT_assert (used > 0);
|
||||
KISSAT_assert (UINT_MAX - used >= pos);
|
||||
f->used = pos;
|
||||
pos += used;
|
||||
}
|
||||
unsigneds *clause = &solver->clause;
|
||||
const size_t size_clause = SIZE_STACK (*clause);
|
||||
#ifndef NDEBUG
|
||||
assert (pos == size_clause);
|
||||
#ifndef KISSAT_NDEBUG
|
||||
KISSAT_assert (pos == size_clause);
|
||||
#endif
|
||||
unsigned const *begin_clause = BEGIN_STACK (*clause);
|
||||
const unsigned *const end_clause = END_STACK (*clause);
|
||||
assert (begin_clause < end_clause);
|
||||
KISSAT_assert (begin_clause < end_clause);
|
||||
|
||||
unsigneds *shadow = &solver->shadow;
|
||||
while (SIZE_STACK (*shadow) < size_clause)
|
||||
|
|
@ -272,37 +274,37 @@ static void sort_deduced_clause (kissat *solver) {
|
|||
const unsigned idx = IDX (lit);
|
||||
const struct assigned *a = assigned + idx;
|
||||
const unsigned level = a->level;
|
||||
assert (level < size_frames);
|
||||
KISSAT_assert (level < size_frames);
|
||||
frame *f = frames + level;
|
||||
const unsigned pos = f->used++;
|
||||
POKE_STACK (*shadow, pos, lit);
|
||||
}
|
||||
|
||||
assert (size_clause == SIZE_STACK (*shadow));
|
||||
KISSAT_assert (size_clause == SIZE_STACK (*shadow));
|
||||
SWAP (unsigneds, *clause, *shadow);
|
||||
|
||||
pos = 1;
|
||||
p = end_levels;
|
||||
while (p != begin_levels) {
|
||||
const unsigned level = *--p;
|
||||
assert (level < size_frames);
|
||||
KISSAT_assert (level < size_frames);
|
||||
frame *f = frames + level;
|
||||
const unsigned end = f->used;
|
||||
assert (pos < end);
|
||||
KISSAT_assert (pos < end);
|
||||
f->used = end - pos;
|
||||
assert (f->used == f->saved);
|
||||
KISSAT_assert (f->used == f->saved);
|
||||
pos = end;
|
||||
}
|
||||
|
||||
CLEAR_STACK (*shadow);
|
||||
LOGTMP ("level sorted deduced");
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
unsigned prev_level = solver->level;
|
||||
for (all_stack (unsigned, lit, solver->clause)) {
|
||||
const unsigned idx = IDX (lit);
|
||||
const unsigned lit_level = assigned[idx].level;
|
||||
assert (prev_level >= lit_level);
|
||||
KISSAT_assert (prev_level >= lit_level);
|
||||
prev_level = lit_level;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -311,13 +313,13 @@ static void sort_deduced_clause (kissat *solver) {
|
|||
static void reset_levels (kissat *solver) {
|
||||
LOG ("reset %zu marked levels", SIZE_STACK (solver->levels));
|
||||
frame *frames = BEGIN_STACK (solver->frames);
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
const size_t size_frames = SIZE_STACK (solver->frames);
|
||||
#endif
|
||||
for (all_stack (unsigned, level, solver->levels)) {
|
||||
assert (level < size_frames);
|
||||
KISSAT_assert (level < size_frames);
|
||||
frame *f = frames + level;
|
||||
assert (f->used > 0);
|
||||
KISSAT_assert (f->used > 0);
|
||||
f->used = 0;
|
||||
}
|
||||
CLEAR_STACK (solver->levels);
|
||||
|
|
@ -327,11 +329,11 @@ void kissat_reset_only_analyzed_literals (kissat *solver) {
|
|||
LOG ("reset %zu analyzed variables", SIZE_STACK (solver->analyzed));
|
||||
assigned *assigned = solver->assigned;
|
||||
for (all_stack (unsigned, idx, solver->analyzed)) {
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
assert (!a->poisoned);
|
||||
assert (!a->removable);
|
||||
assert (!a->shrinkable);
|
||||
KISSAT_assert (!a->poisoned);
|
||||
KISSAT_assert (!a->removable);
|
||||
KISSAT_assert (!a->shrinkable);
|
||||
a->analyzed = false;
|
||||
}
|
||||
CLEAR_STACK (solver->analyzed);
|
||||
|
|
@ -340,13 +342,13 @@ void kissat_reset_only_analyzed_literals (kissat *solver) {
|
|||
static void reset_removable (kissat *solver) {
|
||||
LOG ("reset %zu removable variables", SIZE_STACK (solver->removable));
|
||||
assigned *assigned = solver->assigned;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
unsigned not_removable = 0;
|
||||
#endif
|
||||
for (all_stack (unsigned, idx, solver->removable)) {
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
assert (a->removable || !not_removable++);
|
||||
KISSAT_assert (a->removable || !not_removable++);
|
||||
a->removable = false;
|
||||
}
|
||||
CLEAR_STACK (solver->removable);
|
||||
|
|
@ -360,8 +362,8 @@ static void reset_analysis_but_not_analyzed_literals (kissat *solver) {
|
|||
}
|
||||
|
||||
static void update_trail_average (kissat *solver) {
|
||||
assert (!solver->probing);
|
||||
#if defined(LOGGING) || !defined(QUIET)
|
||||
KISSAT_assert (!solver->probing);
|
||||
#if defined(LOGGING) || !defined(KISSAT_QUIET)
|
||||
const unsigned size = SIZE_ARRAY (solver->trail);
|
||||
const unsigned assigned = size - solver->unflushed;
|
||||
const unsigned active = solver->active;
|
||||
|
|
@ -371,36 +373,36 @@ static void update_trail_average (kissat *solver) {
|
|||
#endif
|
||||
LOG ("trail filled %.0f%% (size %u, unflushed %u, active %u)", filled,
|
||||
size, solver->unflushed, active);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
UPDATE_AVERAGE (trail, filled);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void update_decision_rate_average (kissat *solver) {
|
||||
assert (!solver->probing);
|
||||
KISSAT_assert (!solver->probing);
|
||||
const uint64_t current = DECISIONS;
|
||||
const uint64_t previous =
|
||||
solver->averages[solver->stable].saved_decisions;
|
||||
assert (previous <= current);
|
||||
KISSAT_assert (previous <= current);
|
||||
const uint64_t decisions = current - previous;
|
||||
solver->averages[solver->stable].saved_decisions = current;
|
||||
UPDATE_AVERAGE (decision_rate, decisions);
|
||||
}
|
||||
|
||||
static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
||||
assert (solver->level == 1);
|
||||
KISSAT_assert (solver->level == 1);
|
||||
const unsigned failed = FRAME (1).decision;
|
||||
|
||||
LOGCLS (conflict, "analyzing failed literal %s conflict",
|
||||
LOGLIT (failed));
|
||||
|
||||
unsigneds *units = &solver->clause;
|
||||
assert (EMPTY_STACK (*units));
|
||||
assert (EMPTY_STACK (solver->analyzed));
|
||||
KISSAT_assert (EMPTY_STACK (*units));
|
||||
KISSAT_assert (EMPTY_STACK (solver->analyzed));
|
||||
|
||||
const unsigned not_failed = NOT (failed);
|
||||
assigned *all_assigned = solver->assigned;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
const value *const values = solver->values;
|
||||
#endif
|
||||
unsigned const *t = END_ARRAY (solver->trail);
|
||||
|
|
@ -408,18 +410,18 @@ static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
|||
unsigned unit = INVALID_LIT;
|
||||
|
||||
for (all_literals_in_clause (lit, conflict)) {
|
||||
assert (lit != failed);
|
||||
KISSAT_assert (lit != failed);
|
||||
if (lit == not_failed) {
|
||||
LOG ("negation %s of failed literal %s occurs in conflict",
|
||||
LOGLIT (not_failed), LOGLIT (failed));
|
||||
goto DONE;
|
||||
}
|
||||
assert (values[lit] < 0);
|
||||
KISSAT_assert (values[lit] < 0);
|
||||
const unsigned idx = IDX (lit);
|
||||
assigned *a = all_assigned + idx;
|
||||
if (!a->level)
|
||||
continue;
|
||||
assert (a->level == 1);
|
||||
KISSAT_assert (a->level == 1);
|
||||
LOG ("analyzing conflict literal %s", LOGLIT (lit));
|
||||
kissat_push_analyzed (solver, all_assigned, idx);
|
||||
unresolved++;
|
||||
|
|
@ -429,9 +431,9 @@ static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
|||
unsigned lit;
|
||||
assigned *a;
|
||||
do {
|
||||
assert (t > BEGIN_ARRAY (solver->trail));
|
||||
KISSAT_assert (t > BEGIN_ARRAY (solver->trail));
|
||||
lit = *--t;
|
||||
assert (values[lit] > 0);
|
||||
KISSAT_assert (values[lit] > 0);
|
||||
const unsigned idx = IDX (lit);
|
||||
a = all_assigned + idx;
|
||||
} while (!a->analyzed);
|
||||
|
|
@ -443,9 +445,9 @@ static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
|||
if (a->binary) {
|
||||
const unsigned other = a->reason;
|
||||
LOGBINARY (lit, other, "resolving %s reason", LOGLIT (lit));
|
||||
assert (other != failed);
|
||||
assert (other != unit);
|
||||
assert (values[other] < 0);
|
||||
KISSAT_assert (other != failed);
|
||||
KISSAT_assert (other != unit);
|
||||
KISSAT_assert (values[other] < 0);
|
||||
if (other == not_failed) {
|
||||
LOG ("negation %s of failed literal %s in reason",
|
||||
LOGLIT (not_failed), LOGLIT (failed));
|
||||
|
|
@ -453,21 +455,21 @@ static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
|||
}
|
||||
const unsigned idx = IDX (other);
|
||||
assigned *b = all_assigned + idx;
|
||||
assert (b->level == 1);
|
||||
KISSAT_assert (b->level == 1);
|
||||
if (!b->analyzed) {
|
||||
LOG ("analyzing reason literal %s", LOGLIT (other));
|
||||
kissat_push_analyzed (solver, all_assigned, idx);
|
||||
unresolved++;
|
||||
}
|
||||
} else {
|
||||
assert (a->reason != UNIT_REASON);
|
||||
assert (a->reason != DECISION_REASON);
|
||||
KISSAT_assert (a->reason != UNIT_REASON);
|
||||
KISSAT_assert (a->reason != DECISION_REASON);
|
||||
const reference ref = a->reason;
|
||||
LOGREF (ref, "resolving %s reason", LOGLIT (lit));
|
||||
clause *reason = kissat_dereference_clause (solver, ref);
|
||||
for (all_literals_in_clause (other, reason)) {
|
||||
assert (other != NOT (lit));
|
||||
assert (other != failed);
|
||||
KISSAT_assert (other != NOT (lit));
|
||||
KISSAT_assert (other != failed);
|
||||
if (other == lit)
|
||||
continue;
|
||||
if (other == unit)
|
||||
|
|
@ -477,12 +479,12 @@ static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
|||
LOGLIT (not_failed), LOGLIT (failed));
|
||||
goto DONE;
|
||||
}
|
||||
assert (values[other] < 0);
|
||||
KISSAT_assert (values[other] < 0);
|
||||
const unsigned idx = IDX (other);
|
||||
assigned *b = all_assigned + idx;
|
||||
if (!b->level)
|
||||
continue;
|
||||
assert (b->level == 1);
|
||||
KISSAT_assert (b->level == 1);
|
||||
if (b->analyzed)
|
||||
continue;
|
||||
LOG ("analyzing reason literal %s", LOGLIT (other));
|
||||
|
|
@ -490,7 +492,7 @@ static void analyze_failed_literal (kissat *solver, clause *conflict) {
|
|||
unresolved++;
|
||||
}
|
||||
}
|
||||
assert (unresolved > 0);
|
||||
KISSAT_assert (unresolved > 0);
|
||||
unresolved--;
|
||||
LOG ("after resolving %s there are %u unresolved literals",
|
||||
LOGLIT (lit), unresolved);
|
||||
|
|
@ -526,7 +528,7 @@ static void update_tier_limits (kissat *solver) {
|
|||
|
||||
int kissat_analyze (kissat *solver, clause *conflict) {
|
||||
if (solver->inconsistent) {
|
||||
assert (!solver->level);
|
||||
KISSAT_assert (!solver->level);
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
|
@ -534,7 +536,7 @@ int kissat_analyze (kissat *solver, clause *conflict) {
|
|||
if (!solver->probing) {
|
||||
update_trail_average (solver);
|
||||
update_decision_rate_average (solver);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
UPDATE_AVERAGE (level, solver->level);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -577,3 +579,5 @@ int kissat_analyze (kissat *solver, clause *conflict) {
|
|||
STOP (analyze);
|
||||
return res > 0 ? 0 : 20;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct clause;
|
||||
struct kissat;
|
||||
|
||||
int kissat_analyze (struct kissat *, struct clause *);
|
||||
void kissat_reset_only_analyzed_literals (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include "gates.h"
|
||||
#include "inline.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
bool kissat_find_and_gate (kissat *solver, unsigned lit,
|
||||
unsigned negative) {
|
||||
if (!GET_OPTION (ands))
|
||||
|
|
@ -27,9 +29,9 @@ bool kissat_find_and_gate (kissat *solver, unsigned lit,
|
|||
if (watch.type.binary)
|
||||
continue;
|
||||
const reference ref = watch.large.ref;
|
||||
assert (ref < SIZE_STACK (solver->arena));
|
||||
KISSAT_assert (ref < SIZE_STACK (solver->arena));
|
||||
clause *c = (clause *) (arena + ref);
|
||||
assert (!c->garbage);
|
||||
KISSAT_assert (!c->garbage);
|
||||
base = c;
|
||||
for (all_literals_in_clause (other, c)) {
|
||||
if (other == not_lit)
|
||||
|
|
@ -63,7 +65,7 @@ bool kissat_find_and_gate (kissat *solver, unsigned lit,
|
|||
if (values[other])
|
||||
continue;
|
||||
const unsigned not_other = NOT (other);
|
||||
assert (marks[not_other]);
|
||||
KISSAT_assert (marks[not_other]);
|
||||
marks[not_other] = 0;
|
||||
}
|
||||
watch tmp = kissat_binary_watch (0);
|
||||
|
|
@ -72,7 +74,7 @@ bool kissat_find_and_gate (kissat *solver, unsigned lit,
|
|||
if (!watch.type.binary)
|
||||
continue;
|
||||
const unsigned other = watch.binary.lit;
|
||||
assert (!solver->values[other]);
|
||||
KISSAT_assert (!solver->values[other]);
|
||||
if (marks[other]) {
|
||||
marks[other] = 0;
|
||||
continue;
|
||||
|
|
@ -86,3 +88,5 @@ bool kissat_find_and_gate (kissat *solver, unsigned lit,
|
|||
INC (ands_extracted);
|
||||
return true;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,9 +3,14 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
bool kissat_find_and_gate (struct kissat *, unsigned lit,
|
||||
unsigned negative);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
#ifndef _application_h_INCLUDED
|
||||
#define _application_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
int kissat_application (struct kissat *, int argc, char **argv);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
#include "logging.h"
|
||||
#include "print.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void report_resized (kissat *solver, const char *mode,
|
||||
arena before) {
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
ward *const old_begin = BEGIN_STACK (before);
|
||||
ward *const new_begin = BEGIN_STACK (solver->arena);
|
||||
const bool moved = (new_begin != old_begin);
|
||||
|
|
@ -23,25 +25,25 @@ static void report_resized (kissat *solver, const char *mode,
|
|||
}
|
||||
|
||||
reference kissat_allocate_clause (kissat *solver, size_t size) {
|
||||
assert (size <= UINT_MAX);
|
||||
KISSAT_assert (size <= UINT_MAX);
|
||||
const size_t res = SIZE_STACK (solver->arena);
|
||||
assert (res <= MAX_REF);
|
||||
KISSAT_assert (res <= MAX_REF);
|
||||
const size_t bytes = kissat_bytes_of_clause (size);
|
||||
assert (kissat_aligned_word (bytes));
|
||||
KISSAT_assert (kissat_aligned_word (bytes));
|
||||
const size_t needed = bytes / sizeof (ward);
|
||||
assert (needed <= UINT_MAX);
|
||||
KISSAT_assert (needed <= UINT_MAX);
|
||||
size_t capacity = CAPACITY_STACK (solver->arena);
|
||||
assert (kissat_is_power_of_two (MAX_ARENA));
|
||||
assert (capacity <= MAX_ARENA);
|
||||
KISSAT_assert (kissat_is_power_of_two (MAX_ARENA));
|
||||
KISSAT_assert (capacity <= MAX_ARENA);
|
||||
size_t available = capacity - res;
|
||||
if (needed > available) {
|
||||
const arena before = solver->arena;
|
||||
do {
|
||||
assert (kissat_is_zero_or_power_of_two (capacity));
|
||||
KISSAT_assert (kissat_is_zero_or_power_of_two (capacity));
|
||||
if (capacity == MAX_ARENA)
|
||||
kissat_fatal ("maximum arena capacity "
|
||||
"of 2^%u %zu-byte-words %s exhausted"
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
" (consider a configuration without '--compact')"
|
||||
#endif
|
||||
,
|
||||
|
|
@ -55,7 +57,7 @@ reference kissat_allocate_clause (kissat *solver, size_t size) {
|
|||
INC (arena_resized);
|
||||
INC (arena_enlarged);
|
||||
report_resized (solver, "enlarged", before);
|
||||
assert (capacity <= MAX_ARENA);
|
||||
KISSAT_assert (capacity <= MAX_ARENA);
|
||||
}
|
||||
solver->arena.end += needed;
|
||||
LOG ("allocated clause[%zu] of size %zu bytes %s", res, size,
|
||||
|
|
@ -67,7 +69,7 @@ void kissat_shrink_arena (kissat *solver) {
|
|||
const arena before = solver->arena;
|
||||
const size_t capacity = CAPACITY_STACK (before);
|
||||
const size_t size = SIZE_STACK (before);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const size_t capacity_bytes = capacity * sizeof (ward);
|
||||
kissat_phase (solver, "arena", GET (arena_resized),
|
||||
"capacity of %s %d-byte-words %s", FORMAT_COUNT (capacity),
|
||||
|
|
@ -89,7 +91,7 @@ void kissat_shrink_arena (kissat *solver) {
|
|||
report_resized (solver, "shrunken", before);
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || defined(LOGGING)
|
||||
|
||||
bool kissat_clause_in_arena (const kissat *solver, const clause *c) {
|
||||
if (!kissat_aligned_pointer (c))
|
||||
|
|
@ -106,3 +108,5 @@ bool kissat_clause_in_arena (const kissat *solver, const clause *c) {
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@
|
|||
#include "stack.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#ifdef COMPACT
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#ifdef KISSAT_COMPACT
|
||||
typedef word ward;
|
||||
#else
|
||||
typedef w2rd ward;
|
||||
|
|
@ -29,18 +32,20 @@ struct kissat;
|
|||
reference kissat_allocate_clause (struct kissat *, size_t size);
|
||||
void kissat_shrink_arena (struct kissat *);
|
||||
|
||||
#if !defined(NDEBUG) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || defined(LOGGING)
|
||||
|
||||
bool kissat_clause_in_arena (const struct kissat *, const struct clause *);
|
||||
|
||||
#endif
|
||||
|
||||
static inline word kissat_align_ward (word w) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return kissat_align_word (w);
|
||||
#else
|
||||
return kissat_align_w2rd (w);
|
||||
#endif
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "allocate.h"
|
||||
#include "stack.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define ARRAY(TYPE) \
|
||||
struct { \
|
||||
TYPE *begin; \
|
||||
|
|
@ -25,11 +28,11 @@
|
|||
*(A).end++ = (E); \
|
||||
} while (0)
|
||||
|
||||
#define REALLOCATE_ARRAY(A, O, N) \
|
||||
#define REALLOCATE_ARRAY(T, A, O, N) \
|
||||
do { \
|
||||
const size_t SIZE = SIZE_ARRAY (A); \
|
||||
(A).begin = \
|
||||
kissat_nrealloc (solver, (A).begin, (O), (N), sizeof *(A).begin); \
|
||||
(T*) kissat_nrealloc (solver, (A).begin, (O), (N), sizeof *(A).begin); \
|
||||
(A).end = (A).begin + SIZE; \
|
||||
} while (0)
|
||||
|
||||
|
|
@ -55,4 +58,6 @@ typedef ARRAY (unsigned) unsigned_array;
|
|||
|
||||
// clang-format on
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
void kissat_assign_unit (kissat *solver, unsigned lit, const char *reason) {
|
||||
kissat_assign (solver, solver->probing, 0, false, lit, UNIT_REASON);
|
||||
LOGUNARY (lit, "assign %s %s", LOGLIT (lit), reason);
|
||||
|
|
@ -30,7 +32,7 @@ void kissat_assign_decision (kissat *solver, unsigned lit) {
|
|||
}
|
||||
|
||||
void kissat_assign_binary (kissat *solver, unsigned lit, unsigned other) {
|
||||
assert (VALUE (other) < 0);
|
||||
KISSAT_assert (VALUE (other) < 0);
|
||||
assigned *assigned = solver->assigned;
|
||||
const unsigned other_idx = IDX (other);
|
||||
struct assigned *a = assigned + other_idx;
|
||||
|
|
@ -46,14 +48,16 @@ void kissat_assign_binary (kissat *solver, unsigned lit, unsigned other) {
|
|||
|
||||
void kissat_assign_reference (kissat *solver, unsigned lit, reference ref,
|
||||
clause *reason) {
|
||||
assert (reason == kissat_dereference_clause (solver, ref));
|
||||
KISSAT_assert (reason == kissat_dereference_clause (solver, ref));
|
||||
assigned *assigned = solver->assigned;
|
||||
value *values = solver->values;
|
||||
const unsigned level =
|
||||
kissat_assignment_level (solver, values, assigned, lit, reason);
|
||||
assert (level <= solver->level);
|
||||
assert (ref != DECISION_REASON);
|
||||
assert (ref != UNIT_REASON);
|
||||
KISSAT_assert (level <= solver->level);
|
||||
KISSAT_assert (ref != DECISION_REASON);
|
||||
KISSAT_assert (ref != UNIT_REASON);
|
||||
kissat_assign (solver, solver->probing, level, false, lit, ref);
|
||||
LOGREF (ref, "assign %s reason", LOGLIT (lit));
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define DECISION_REASON UINT_MAX
|
||||
#define UNIT_REASON (DECISION_REASON - 1)
|
||||
|
||||
|
|
@ -26,7 +29,7 @@ struct assigned {
|
|||
};
|
||||
|
||||
#define ASSIGNED(LIT) \
|
||||
(assert (VALID_INTERNAL_LITERAL (LIT)), solver->assigned + IDX (LIT))
|
||||
(KISSAT_assert (VALID_INTERNAL_LITERAL (LIT)), solver->assigned + IDX (LIT))
|
||||
|
||||
#define LEVEL(LIT) (ASSIGNED (LIT)->level)
|
||||
#define TRAIL(LIT) (ASSIGNED (LIT)->trail)
|
||||
|
|
@ -34,8 +37,12 @@ struct assigned {
|
|||
|
||||
#ifndef FAST_ASSIGN
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#include "reference.h"
|
||||
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
struct clause;
|
||||
|
||||
|
|
@ -52,4 +59,6 @@ void kissat_assign_reference (struct kissat *, unsigned lit, reference,
|
|||
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
#ifndef _attribute_h_INCLUDED
|
||||
#define _attribute_h_INCLUDED
|
||||
|
||||
#define ATTRIBUTE_FORMAT(FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION) \
|
||||
__attribute__ (( \
|
||||
format (printf, FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION)))
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
|
||||
/* #define ATTRIBUTE_FORMAT(FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION) \ */
|
||||
/* __attribute__ (( \ */
|
||||
/* format (printf, FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION))) */
|
||||
|
||||
#define ATTRIBUTE_FORMAT(FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION)
|
||||
|
||||
/* #define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) */
|
||||
|
||||
#define ATTRIBUTE_ALWAYS_INLINE
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#include "internal.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
void kissat_init_averages (kissat *solver, averages *averages) {
|
||||
if (averages->initialized)
|
||||
return;
|
||||
#define INIT_EMA(EMA, WINDOW) \
|
||||
kissat_init_smooth (solver, &averages->EMA, WINDOW, #EMA)
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
INIT_EMA (level, GET_OPTION (emaslow));
|
||||
INIT_EMA (size, GET_OPTION (emaslow));
|
||||
INIT_EMA (trail, GET_OPTION (emaslow));
|
||||
|
|
@ -15,3 +17,5 @@ void kissat_init_averages (kissat *solver, averages *averages) {
|
|||
INIT_EMA (decision_rate, GET_OPTION (emaslow));
|
||||
averages->initialized = true;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct averages averages;
|
||||
|
||||
struct averages {
|
||||
bool initialized;
|
||||
smooth fast_glue, slow_glue;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
smooth level, size, trail;
|
||||
#endif
|
||||
smooth decision_rate;
|
||||
|
|
@ -30,4 +33,6 @@ void kissat_init_averages (struct kissat *, averages *);
|
|||
#define UPDATE_AVERAGE(NAME, VALUE) \
|
||||
kissat_update_smooth (solver, &EMA (NAME), VALUE)
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#include "trail.h"
|
||||
#include "utilities.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void schedule_backbone_candidates (kissat *solver,
|
||||
unsigneds *candidates) {
|
||||
flags *flags = solver->flags;
|
||||
|
|
@ -34,7 +36,7 @@ static void schedule_backbone_candidates (kissat *solver,
|
|||
} else
|
||||
not_rescheduled++;
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const size_t rescheduled = SIZE_STACK (*candidates);
|
||||
const unsigned active_literals = 2u * solver->active;
|
||||
kissat_very_verbose (
|
||||
|
|
@ -58,7 +60,7 @@ static void schedule_backbone_candidates (kissat *solver,
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const size_t total = SIZE_STACK (*candidates);
|
||||
kissat_very_verbose (solver,
|
||||
"scheduled %zu backbone candidate literals %.0f%%"
|
||||
|
|
@ -83,21 +85,21 @@ static void keep_backbone_candidates (kissat *solver,
|
|||
else
|
||||
prioritized += f->backbone0;
|
||||
}
|
||||
assert (prioritized <= remain);
|
||||
KISSAT_assert (prioritized <= remain);
|
||||
if (!remain) {
|
||||
kissat_very_verbose (solver, "no backbone candidates remain");
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
for (all_variables (idx)) {
|
||||
const struct flags *f = flags + idx;
|
||||
if (!f->active)
|
||||
continue;
|
||||
assert (!f->backbone0);
|
||||
assert (!f->backbone1);
|
||||
KISSAT_assert (!f->backbone0);
|
||||
KISSAT_assert (!f->backbone1);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const size_t active_literals = 2u * solver->active;
|
||||
#endif
|
||||
if (prioritized == remain)
|
||||
|
|
@ -112,10 +114,10 @@ static void keep_backbone_candidates (kissat *solver,
|
|||
if (!f->active)
|
||||
continue;
|
||||
if (NEGATED (lit)) {
|
||||
assert (!f->backbone1);
|
||||
KISSAT_assert (!f->backbone1);
|
||||
f->backbone1 = true;
|
||||
} else {
|
||||
assert (!f->backbone0);
|
||||
KISSAT_assert (!f->backbone0);
|
||||
f->backbone0 = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -137,8 +139,8 @@ static inline void backbone_assign (kissat *solver, unsigned_array *trail,
|
|||
value *values, assigned *assigned,
|
||||
unsigned lit, unsigned reason) {
|
||||
const unsigned not_lit = NOT (lit);
|
||||
assert (!values[lit]);
|
||||
assert (!values[not_lit]);
|
||||
KISSAT_assert (!values[lit]);
|
||||
KISSAT_assert (!values[not_lit]);
|
||||
values[lit] = 1;
|
||||
values[not_lit] = -1;
|
||||
PUSH_ARRAY (*trail, lit);
|
||||
|
|
@ -154,13 +156,13 @@ backbone_propagate_literal (kissat *solver, const bool stop_early,
|
|||
unsigned_array *trail, value *values,
|
||||
assigned *assigned, unsigned lit) {
|
||||
LOG ("backbone propagating %s", LOGLIT (lit));
|
||||
assert (VALID_INTERNAL_LITERAL (lit));
|
||||
assert (values[lit] > 0);
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (lit));
|
||||
KISSAT_assert (values[lit] > 0);
|
||||
|
||||
const unsigned not_lit = NOT (lit);
|
||||
assert (values[not_lit] < 0);
|
||||
KISSAT_assert (values[not_lit] < 0);
|
||||
|
||||
assert (not_lit < LITS);
|
||||
KISSAT_assert (not_lit < LITS);
|
||||
const watches *const watches = all_watches + not_lit;
|
||||
|
||||
const watch *const begin_watches = BEGIN_CONST_WATCHES (*watches);
|
||||
|
|
@ -171,22 +173,22 @@ backbone_propagate_literal (kissat *solver, const bool stop_early,
|
|||
const watch watch = *p++;
|
||||
if (watch.type.binary) {
|
||||
const unsigned other = watch.binary.lit;
|
||||
assert (VALID_INTERNAL_LITERAL (other));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (other));
|
||||
const value value = values[other];
|
||||
if (value > 0)
|
||||
continue;
|
||||
if (value < 0)
|
||||
return kissat_binary_conflict (solver, not_lit, other);
|
||||
assert (!value);
|
||||
KISSAT_assert (!value);
|
||||
backbone_assign (solver, trail, values, assigned, other, lit);
|
||||
LOG ("backbone assign %s reason binary clause %s %s", LOGLIT (other),
|
||||
LOGLIT (other), LOGLIT (not_lit));
|
||||
} else {
|
||||
if (stop_early) {
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
for (const union watch *q = p + 1; q != end_watches; q++) {
|
||||
const union watch watch = *q++;
|
||||
assert (!watch.type.binary);
|
||||
KISSAT_assert (!watch.type.binary);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
|
@ -219,7 +221,7 @@ static inline clause *backbone_propagate (kissat *solver,
|
|||
conflict = backbone_propagate_literal (
|
||||
solver, stop_early, watches, trail, values, assigned, *propagate++);
|
||||
|
||||
assert (solver->propagate <= propagate);
|
||||
KISSAT_assert (solver->propagate <= propagate);
|
||||
const unsigned propagated = propagate - solver->propagate;
|
||||
solver->propagate = propagate;
|
||||
|
||||
|
|
@ -240,17 +242,17 @@ static inline void backbone_backtrack (kissat *solver,
|
|||
unsigned_array *trail, value *values,
|
||||
unsigned *saved,
|
||||
unsigned decision_level) {
|
||||
assert (decision_level <= solver->level);
|
||||
KISSAT_assert (decision_level <= solver->level);
|
||||
unsigned *end_trail = END_ARRAY (*trail);
|
||||
assert (saved != end_trail);
|
||||
KISSAT_assert (saved != end_trail);
|
||||
LOG ("backbone backtracking to trail level %zu and decision level %u",
|
||||
(size_t) (saved - BEGIN_ARRAY (*trail)), decision_level);
|
||||
while (saved != end_trail) {
|
||||
const unsigned lit = *--end_trail;
|
||||
const unsigned not_lit = NOT (lit);
|
||||
LOG ("backbone unassign %s", LOGLIT (lit));
|
||||
assert (values[lit] > 0);
|
||||
assert (values[not_lit] < 0);
|
||||
KISSAT_assert (values[lit] > 0);
|
||||
KISSAT_assert (values[not_lit] < 0);
|
||||
values[lit] = values[not_lit] = 0;
|
||||
}
|
||||
SET_END_OF_ARRAY (solver->trail, saved);
|
||||
|
|
@ -259,9 +261,9 @@ static inline void backbone_backtrack (kissat *solver,
|
|||
}
|
||||
|
||||
static unsigned backbone_analyze (kissat *solver, clause *conflict) {
|
||||
assert (conflict);
|
||||
KISSAT_assert (conflict);
|
||||
LOGCLS (conflict, "backbone analyzing");
|
||||
assert (conflict->size == 2);
|
||||
KISSAT_assert (conflict->size == 2);
|
||||
|
||||
assigned *const assigned = solver->assigned;
|
||||
|
||||
|
|
@ -271,7 +273,7 @@ static unsigned backbone_analyze (kissat *solver, clause *conflict) {
|
|||
const unsigned *t = END_ARRAY (solver->trail);
|
||||
|
||||
for (;;) {
|
||||
assert (t > BEGIN_ARRAY (solver->trail));
|
||||
KISSAT_assert (t > BEGIN_ARRAY (solver->trail));
|
||||
|
||||
unsigned lit = *--t;
|
||||
|
||||
|
|
@ -282,8 +284,8 @@ static unsigned backbone_analyze (kissat *solver, clause *conflict) {
|
|||
|
||||
LOG ("backbone analyzing %s", LOGLIT (lit));
|
||||
const unsigned reason = a->reason;
|
||||
assert (reason != UNIT_REASON);
|
||||
assert (reason != DECISION_REASON);
|
||||
KISSAT_assert (reason != UNIT_REASON);
|
||||
KISSAT_assert (reason != DECISION_REASON);
|
||||
const unsigned reason_idx = IDX (reason);
|
||||
const struct assigned *b = assigned + reason_idx;
|
||||
if (!b->analyzed) {
|
||||
|
|
@ -298,7 +300,7 @@ static unsigned backbone_analyze (kissat *solver, clause *conflict) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|
||||
static void
|
||||
check_large_clauses_watched_after_binary_clauses (kissat *solver) {
|
||||
|
|
@ -306,7 +308,7 @@ check_large_clauses_watched_after_binary_clauses (kissat *solver) {
|
|||
bool large = false;
|
||||
for (all_binary_blocking_watches (watch, WATCHES (lit)))
|
||||
if (watch.type.binary)
|
||||
assert (!large);
|
||||
KISSAT_assert (!large);
|
||||
else
|
||||
large = true;
|
||||
}
|
||||
|
|
@ -315,7 +317,7 @@ check_large_clauses_watched_after_binary_clauses (kissat *solver) {
|
|||
#endif
|
||||
|
||||
static unsigned compute_backbone (kissat *solver) {
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
if (solver->large_clauses_watched_after_binary_clauses)
|
||||
check_large_clauses_watched_after_binary_clauses (solver);
|
||||
#endif
|
||||
|
|
@ -325,26 +327,26 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
INIT_STACK (candidates);
|
||||
INIT_STACK (units);
|
||||
schedule_backbone_candidates (solver, &candidates);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const size_t scheduled = SIZE_STACK (candidates);
|
||||
#endif
|
||||
#if defined(METRICS) && (!defined(QUIET) || !defined(NDEBUG))
|
||||
const uint64_t implied_before = solver->statistics.backbone_implied;
|
||||
#if defined(METRICS) && (!defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG))
|
||||
const uint64_t implied_before = solver->statistics_.backbone_implied;
|
||||
#endif
|
||||
unsigned_array *trail = &solver->trail;
|
||||
value *values = solver->values;
|
||||
flags *flags = solver->flags;
|
||||
assigned *assigned = solver->assigned;
|
||||
|
||||
assert (kissat_propagated (solver));
|
||||
assert (kissat_trail_flushed (solver));
|
||||
KISSAT_assert (kissat_propagated (solver));
|
||||
KISSAT_assert (kissat_trail_flushed (solver));
|
||||
|
||||
unsigned inconsistent = INVALID_LIT;
|
||||
|
||||
SET_EFFORT_LIMIT (ticks_limit, backbone, backbone_ticks);
|
||||
size_t round_limit = GET_OPTION (backbonerounds);
|
||||
assert (solver->statistics.backbone_computations);
|
||||
round_limit *= solver->statistics.backbone_computations;
|
||||
KISSAT_assert (solver->statistics_.backbone_computations);
|
||||
round_limit *= solver->statistics_.backbone_computations;
|
||||
const size_t max_rounds = GET_OPTION (backbonemaxrounds);
|
||||
if (round_limit > max_rounds)
|
||||
round_limit = max_rounds;
|
||||
|
|
@ -356,7 +358,7 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
kissat_very_verbose (solver, "backbone round limit %zu hit", round);
|
||||
break;
|
||||
}
|
||||
const uint64_t ticks = solver->statistics.backbone_ticks;
|
||||
const uint64_t ticks = solver->statistics_.backbone_ticks;
|
||||
if (ticks > ticks_limit) {
|
||||
kissat_very_verbose (solver,
|
||||
"backbone ticks limit %" PRIu64 " hit "
|
||||
|
|
@ -365,17 +367,17 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
break;
|
||||
}
|
||||
size_t previous = failed;
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
if (TERMINATED (backbone_terminated_1))
|
||||
break;
|
||||
round++;
|
||||
INC (backbone_rounds);
|
||||
LOG ("starting backbone round %zu", round);
|
||||
unsigned *const begin_candidates = BEGIN_STACK (candidates);
|
||||
assert (!solver->level);
|
||||
#if !defined(QUIET) && defined(METRICS)
|
||||
KISSAT_assert (!solver->level);
|
||||
#if !defined(KISSAT_QUIET) && defined(METRICS)
|
||||
size_t decisions = 0;
|
||||
uint64_t propagated = solver->statistics.backbone_propagations;
|
||||
uint64_t propagated = solver->statistics_.backbone_propagations;
|
||||
#endif
|
||||
unsigned active_before = solver->active;
|
||||
{
|
||||
|
|
@ -383,7 +385,7 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
const unsigned *p = begin_candidates;
|
||||
const unsigned *const end_candidates = END_STACK (candidates);
|
||||
while (p != end_candidates) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
const unsigned probe = *q++ = *p++;
|
||||
const value value = values[probe];
|
||||
if (value > 0) {
|
||||
|
|
@ -409,14 +411,14 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if (solver->statistics.backbone_ticks > ticks_limit)
|
||||
if (solver->statistics_.backbone_ticks > ticks_limit)
|
||||
break;
|
||||
if (TERMINATED (backbone_terminated_2))
|
||||
break;
|
||||
const unsigned level = solver->level;
|
||||
unsigned *const saved = END_ARRAY (*trail);
|
||||
assert (level != UINT_MAX);
|
||||
#if !defined(QUIET) && defined(METRICS)
|
||||
KISSAT_assert (level != UINT_MAX);
|
||||
#if !defined(KISSAT_QUIET) && defined(METRICS)
|
||||
decisions++;
|
||||
#endif
|
||||
solver->level = level + 1;
|
||||
|
|
@ -444,7 +446,7 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
backbone_assign (solver, trail, values, assigned, not_uip,
|
||||
UNIT_REASON);
|
||||
LOG ("backbone forced assign %s", LOGLIT (not_uip));
|
||||
assert (failed == SIZE_STACK (units));
|
||||
KISSAT_assert (failed == SIZE_STACK (units));
|
||||
|
||||
conflict = backbone_propagate (solver, trail, values, assigned);
|
||||
if (conflict) {
|
||||
|
|
@ -455,7 +457,7 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
|
||||
LOG ("propagating backbone forced %s successful", LOGLIT (not_uip));
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t remain = end_candidates - p;
|
||||
if (remain)
|
||||
kissat_extremely_verbose (solver,
|
||||
|
|
@ -497,7 +499,7 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
LOG ("keeping falsified probe %s", LOGLIT (probe));
|
||||
continue;
|
||||
}
|
||||
assert (!value);
|
||||
KISSAT_assert (!value);
|
||||
LOG ("keeping unassigned probe %s", LOGLIT (probe));
|
||||
}
|
||||
LOG ("flushed %zu probe candidates",
|
||||
|
|
@ -515,13 +517,13 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
if (kissat_probing_propagate (solver, 0, true))
|
||||
break;
|
||||
}
|
||||
assert (solver->active <= active_before);
|
||||
KISSAT_assert (solver->active <= active_before);
|
||||
unsigned implied = active_before - solver->active;
|
||||
assert (failed <= failed);
|
||||
KISSAT_assert (failed <= failed);
|
||||
ADD (backbone_implied, implied);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
#ifdef METRICS
|
||||
propagated = solver->statistics.backbone_propagations - propagated;
|
||||
propagated = solver->statistics_.backbone_propagations - propagated;
|
||||
kissat_very_verbose (solver,
|
||||
"backbone round %zu with %zu decisions "
|
||||
"(%.2f propagations per decision)",
|
||||
|
|
@ -545,7 +547,7 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
LOG ("assuming forced unit %s", LOGLIT (inconsistent));
|
||||
kissat_learned_unit (solver, inconsistent);
|
||||
(void) kissat_probing_propagate (solver, 0, true);
|
||||
assert (solver->inconsistent);
|
||||
KISSAT_assert (solver->inconsistent);
|
||||
}
|
||||
RELEASE_STACK (units);
|
||||
if (solver->inconsistent)
|
||||
|
|
@ -553,12 +555,12 @@ static unsigned compute_backbone (kissat *solver) {
|
|||
"inconsistent binary clauses");
|
||||
else {
|
||||
keep_backbone_candidates (solver, &candidates);
|
||||
#if defined(METRICS) && (!defined(QUIET) || !defined(NDEBUG))
|
||||
assert (implied_before <= solver->statistics.backbone_implied);
|
||||
#if defined(METRICS) && (!defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG))
|
||||
KISSAT_assert (implied_before <= solver->statistics_.backbone_implied);
|
||||
#endif
|
||||
#if defined(METRICS) && !defined(QUIET)
|
||||
#if defined(METRICS) && !defined(KISSAT_QUIET)
|
||||
const uint64_t total_implied =
|
||||
solver->statistics.backbone_implied - implied_before;
|
||||
solver->statistics_.backbone_implied - implied_before;
|
||||
kissat_phase (solver, "backbone", GET (backbone_computations),
|
||||
"found %zu backbone literals %" PRIu64
|
||||
" implied in %zu rounds",
|
||||
|
|
@ -576,23 +578,25 @@ void kissat_binary_clauses_backbone (kissat *solver) {
|
|||
return;
|
||||
if (TERMINATED (backbone_terminated_3))
|
||||
return;
|
||||
assert (solver->watching);
|
||||
assert (solver->probing);
|
||||
assert (!solver->level);
|
||||
KISSAT_assert (solver->watching);
|
||||
KISSAT_assert (solver->probing);
|
||||
KISSAT_assert (!solver->level);
|
||||
START (backbone);
|
||||
INC (backbone_computations);
|
||||
#if !defined(NDEBUG) || defined(METRICS)
|
||||
assert (!solver->backbone_computing);
|
||||
#if !defined(KISSAT_NDEBUG) || defined(METRICS)
|
||||
KISSAT_assert (!solver->backbone_computing);
|
||||
solver->backbone_computing = true;
|
||||
#endif
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const unsigned failed =
|
||||
#endif
|
||||
compute_backbone (solver);
|
||||
REPORT (!failed, 'b');
|
||||
#if !defined(NDEBUG) || defined(METRICS)
|
||||
assert (solver->backbone_computing);
|
||||
#if !defined(KISSAT_NDEBUG) || defined(METRICS)
|
||||
KISSAT_assert (solver->backbone_computing);
|
||||
solver->backbone_computing = false;
|
||||
#endif
|
||||
STOP (backbone);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
void kissat_binary_clauses_backbone (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,19 +8,21 @@
|
|||
#include "propsearch.h"
|
||||
#include "trail.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static inline void unassign (kissat *solver, value *values, unsigned lit) {
|
||||
LOG ("unassign %s", LOGLIT (lit));
|
||||
assert (values[lit] > 0);
|
||||
KISSAT_assert (values[lit] > 0);
|
||||
const unsigned not_lit = NOT (lit);
|
||||
values[lit] = values[not_lit] = 0;
|
||||
assert (solver->unassigned < VARS);
|
||||
KISSAT_assert (solver->unassigned < VARS);
|
||||
solver->unassigned++;
|
||||
}
|
||||
|
||||
static inline void add_unassigned_variable_back_to_queue (kissat *solver,
|
||||
links *links,
|
||||
unsigned lit) {
|
||||
assert (!solver->stable);
|
||||
KISSAT_assert (!solver->stable);
|
||||
const unsigned idx = IDX (lit);
|
||||
if (links[idx].stamp > solver->queue.search.stamp)
|
||||
kissat_update_queue (solver, links, idx);
|
||||
|
|
@ -29,7 +31,7 @@ static inline void add_unassigned_variable_back_to_queue (kissat *solver,
|
|||
static inline void add_unassigned_variable_back_to_heap (kissat *solver,
|
||||
heap *scores,
|
||||
unsigned lit) {
|
||||
assert (solver->stable);
|
||||
KISSAT_assert (solver->stable);
|
||||
const unsigned idx = IDX (lit);
|
||||
if (!kissat_heap_contains (scores, idx))
|
||||
kissat_push_heap (solver, scores, idx);
|
||||
|
|
@ -71,7 +73,7 @@ static void kissat_update_target_and_best_phases (kissat *solver) {
|
|||
|
||||
void kissat_backtrack_without_updating_phases (kissat *solver,
|
||||
unsigned new_level) {
|
||||
assert (solver->level >= new_level);
|
||||
KISSAT_assert (solver->level >= new_level);
|
||||
if (solver->level == new_level)
|
||||
return;
|
||||
|
||||
|
|
@ -94,12 +96,12 @@ void kissat_backtrack_without_updating_phases (kissat *solver,
|
|||
for (const unsigned *p = q; p != old_end; p++) {
|
||||
const unsigned lit = *p;
|
||||
const unsigned idx = IDX (lit);
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
const unsigned level = a->level;
|
||||
if (level <= new_level) {
|
||||
const unsigned new_trail = q - trail;
|
||||
assert (new_trail <= a->trail);
|
||||
KISSAT_assert (new_trail <= a->trail);
|
||||
a->trail = new_trail;
|
||||
*q++ = lit;
|
||||
LOG ("reassign %s", LOGLIT (lit));
|
||||
|
|
@ -115,12 +117,12 @@ void kissat_backtrack_without_updating_phases (kissat *solver,
|
|||
for (const unsigned *p = q; p != old_end; p++) {
|
||||
const unsigned lit = *p;
|
||||
const unsigned idx = IDX (lit);
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
const unsigned level = a->level;
|
||||
if (level <= new_level) {
|
||||
const unsigned new_trail = q - trail;
|
||||
assert (new_trail <= a->trail);
|
||||
KISSAT_assert (new_trail <= a->trail);
|
||||
a->trail = new_trail;
|
||||
*q++ = lit;
|
||||
LOG ("reassign %s", LOGLIT (lit));
|
||||
|
|
@ -139,12 +141,12 @@ void kissat_backtrack_without_updating_phases (kissat *solver,
|
|||
LOG ("reassigned %u literals", reassigned);
|
||||
(void) unassigned, (void) reassigned;
|
||||
|
||||
assert (new_end <= END_ARRAY (solver->trail));
|
||||
KISSAT_assert (new_end <= END_ARRAY (solver->trail));
|
||||
LOG ("propagation will resume at trail position %zu",
|
||||
(size_t) (new_end - trail));
|
||||
solver->propagate = new_end;
|
||||
|
||||
assert (!solver->extended);
|
||||
KISSAT_assert (!solver->extended);
|
||||
}
|
||||
|
||||
void kissat_backtrack_in_consistent_state (kissat *solver,
|
||||
|
|
@ -162,16 +164,18 @@ void kissat_backtrack_after_conflict (kissat *solver, unsigned new_level) {
|
|||
|
||||
void kissat_backtrack_propagate_and_flush_trail (kissat *solver) {
|
||||
if (solver->level) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
kissat_backtrack_in_consistent_state (solver, 0);
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
clause *conflict =
|
||||
#endif
|
||||
solver->probing ? kissat_probing_propagate (solver, 0, true)
|
||||
: kissat_search_propagate (solver);
|
||||
assert (!conflict);
|
||||
KISSAT_assert (!conflict);
|
||||
}
|
||||
|
||||
assert (kissat_propagated (solver));
|
||||
assert (kissat_trail_flushed (solver));
|
||||
KISSAT_assert (kissat_propagated (solver));
|
||||
KISSAT_assert (kissat_trail_flushed (solver));
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _backtrack_h_INCLUDED
|
||||
#define _backtrack_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
void kissat_backtrack_without_updating_phases (struct kissat *, unsigned);
|
||||
|
|
@ -8,4 +11,6 @@ void kissat_backtrack_in_consistent_state (struct kissat *, unsigned);
|
|||
void kissat_backtrack_after_conflict (struct kissat *, unsigned);
|
||||
void kissat_backtrack_propagate_and_flush_trail (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
const char *kissat_signature (void) { return "kissat-" VERSION; }
|
||||
|
||||
const char *kissat_id (void) { return ID; }
|
||||
|
|
@ -79,3 +81,5 @@ void kissat_banner (const char *prefix, const char *name) {
|
|||
|
||||
kissat_build (prefix);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define VERSION ""
|
||||
#define COMPILER ""
|
||||
#define ID ""
|
||||
#define BUILD ""
|
||||
#define DIR ""
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
#include "rank.h"
|
||||
#include "sort.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
#define RANK(A) ((A).rank)
|
||||
#define SMALLER(A, B) (RANK (A) < RANK (B))
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ void kissat_rescale_scores (kissat *solver) {
|
|||
kissat_phase (solver, "rescale", GET (rescaled),
|
||||
"maximum score %g increment %g", max_score, solver->scinc);
|
||||
const double rescale = MAX (max_score, solver->scinc);
|
||||
assert (rescale > 0);
|
||||
KISSAT_assert (rescale > 0);
|
||||
const double factor = 1.0 / rescale;
|
||||
kissat_rescale_heap (solver, scores, factor);
|
||||
solver->scinc *= factor;
|
||||
|
|
@ -43,7 +45,7 @@ void kissat_rescale_scores (kissat *solver) {
|
|||
void kissat_bump_score_increment (kissat *solver) {
|
||||
const double old_scinc = solver->scinc;
|
||||
const double decay = GET_OPTION (decay) * 1e-3;
|
||||
assert (0 <= decay), assert (decay <= 0.5);
|
||||
KISSAT_assert (0 <= decay), KISSAT_assert (decay <= 0.5);
|
||||
const double factor = 1.0 / (1.0 - decay);
|
||||
const double new_scinc = old_scinc * factor;
|
||||
LOG ("new score increment %g = %g * %g", new_scinc, factor, old_scinc);
|
||||
|
|
@ -79,7 +81,7 @@ static void bump_analyzed_variable_scores (kissat *solver) {
|
|||
}
|
||||
|
||||
static void move_analyzed_variables_to_front_of_queue (kissat *solver) {
|
||||
assert (EMPTY_STACK (solver->ranks));
|
||||
KISSAT_assert (EMPTY_STACK (solver->ranks));
|
||||
const links *const links = solver->links;
|
||||
for (all_stack (unsigned, idx, solver->analyzed)) {
|
||||
// clang-format off
|
||||
|
|
@ -112,9 +114,11 @@ void kissat_bump_analyzed (kissat *solver) {
|
|||
}
|
||||
|
||||
void kissat_update_scores (kissat *solver) {
|
||||
assert (solver->stable);
|
||||
KISSAT_assert (solver->stable);
|
||||
heap *scores = SCORES;
|
||||
for (all_variables (idx))
|
||||
if (ACTIVE (idx) && !kissat_heap_contains (scores, idx))
|
||||
kissat_push_heap (solver, scores, idx);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
void kissat_bump_analyzed (struct kissat *);
|
||||
|
|
@ -13,4 +16,6 @@ void kissat_bump_score_increment (struct kissat *);
|
|||
|
||||
#define MAX_SCORE 1e150
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef NDEBUG
|
||||
#include "global.h"
|
||||
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|
||||
#include "check.h"
|
||||
#include "error.h"
|
||||
|
|
@ -187,7 +189,7 @@ void kissat_release_checker (kissat *solver) {
|
|||
kissat_free (solver, checker, sizeof (struct checker));
|
||||
}
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
|
|
@ -234,18 +236,18 @@ void kissat_print_checker_statistics (kissat *solver, bool verbose) {
|
|||
static unsigned reduce_hash (unsigned hash, unsigned mod) {
|
||||
if (mod < 2)
|
||||
return 0;
|
||||
assert (mod);
|
||||
KISSAT_assert (mod);
|
||||
unsigned res = hash;
|
||||
for (unsigned shift = 16, mask = 0xffff; res >= mod;
|
||||
mask >>= (shift >>= 1))
|
||||
res = (res >> shift) & mask;
|
||||
assert (res < mod);
|
||||
KISSAT_assert (res < mod);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void resize_hash (kissat *solver, checker *checker) {
|
||||
const unsigned old_hashed = checker->hashed;
|
||||
assert (old_hashed < MAX_SIZE);
|
||||
KISSAT_assert (old_hashed < MAX_SIZE);
|
||||
const unsigned new_hashed = old_hashed ? 2 * old_hashed : 1;
|
||||
bucket **table = kissat_calloc (solver, new_hashed, sizeof (bucket *));
|
||||
bucket **old_table = checker->table;
|
||||
|
|
@ -264,7 +266,7 @@ static void resize_hash (kissat *solver, checker *checker) {
|
|||
|
||||
static bucket *new_line (kissat *solver, checker *checker, unsigned size,
|
||||
unsigned hash) {
|
||||
bucket *res = kissat_malloc (solver, bytes_line (size));
|
||||
bucket *res = (bucket*)kissat_malloc (solver, bytes_line (size));
|
||||
res->next = 0;
|
||||
res->size = size;
|
||||
res->hash = hash;
|
||||
|
|
@ -291,18 +293,18 @@ static void checker_assign (kissat *solver, checker *checker, unsigned lit,
|
|||
#else
|
||||
(void) bucket;
|
||||
#endif
|
||||
assert (VALID_CHECKER_LIT (lit));
|
||||
KISSAT_assert (VALID_CHECKER_LIT (lit));
|
||||
const unsigned not_lit = lit ^ 1;
|
||||
signed char *values = checker->values;
|
||||
assert (!values[lit]);
|
||||
assert (!values[not_lit]);
|
||||
KISSAT_assert (!values[lit]);
|
||||
KISSAT_assert (!values[not_lit]);
|
||||
values[lit] = 1;
|
||||
values[not_lit] = -1;
|
||||
PUSH_STACK (checker->trail, lit);
|
||||
}
|
||||
|
||||
static buckets *checker_watches (checker *checker, unsigned lit) {
|
||||
assert (VALID_CHECKER_LIT (lit));
|
||||
KISSAT_assert (VALID_CHECKER_LIT (lit));
|
||||
return checker->watches + lit;
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +327,7 @@ static void unwatch_checker_literal (kissat *solver, checker *checker,
|
|||
|
||||
static void unwatch_line (kissat *solver, checker *checker,
|
||||
bucket *bucket) {
|
||||
assert (bucket->size > 1);
|
||||
KISSAT_assert (bucket->size > 1);
|
||||
const unsigned *const lits = bucket->lits;
|
||||
unwatch_checker_literal (solver, checker, bucket, lits[0]);
|
||||
unwatch_checker_literal (solver, checker, bucket, lits[1]);
|
||||
|
|
@ -474,7 +476,7 @@ static void use_line (kissat *solver, checker *checker) {
|
|||
static void insert_imported (kissat *solver, checker *checker,
|
||||
unsigned hash) {
|
||||
size_t size = SIZE_STACK (checker->imported);
|
||||
assert (size <= UINT_MAX);
|
||||
KISSAT_assert (size <= UINT_MAX);
|
||||
if (checker->buckets == checker->hashed)
|
||||
resize_hash (solver, checker);
|
||||
bucket *bucket = new_line (solver, checker, size, hash);
|
||||
|
|
@ -485,8 +487,8 @@ static void insert_imported (kissat *solver, checker *checker,
|
|||
LOGLINE3 ("inserted checker");
|
||||
const unsigned *const lits = BEGIN_STACK (checker->imported);
|
||||
const signed char *values = checker->values;
|
||||
assert (!values[lits[0]]);
|
||||
assert (!values[lits[1]]);
|
||||
KISSAT_assert (!values[lits[0]]);
|
||||
KISSAT_assert (!values[lits[1]]);
|
||||
watch_checker_literal (solver, checker, bucket, lits[0]);
|
||||
watch_checker_literal (solver, checker, bucket, lits[1]);
|
||||
checker->buckets++;
|
||||
|
|
@ -525,11 +527,11 @@ static void resize_checker (kissat *solver, checker *checker,
|
|||
const unsigned vars = checker->vars;
|
||||
const unsigned size = checker->size;
|
||||
if (new_vars > size) {
|
||||
assert (new_vars <= MAX_SIZE);
|
||||
KISSAT_assert (new_vars <= MAX_SIZE);
|
||||
unsigned new_size = size ? 2 * size : 1;
|
||||
while (new_size < new_vars)
|
||||
new_size *= 2;
|
||||
assert (new_size <= MAX_SIZE);
|
||||
KISSAT_assert (new_size <= MAX_SIZE);
|
||||
LOG3 ("resizing checker form %u to %u", size, new_size);
|
||||
const unsigned size2 = 2 * size;
|
||||
const unsigned new_size2 = 2 * new_size;
|
||||
|
|
@ -555,7 +557,7 @@ static void resize_checker (kissat *solver, checker *checker,
|
|||
const unsigned vars2 = 2 * vars;
|
||||
const unsigned new_vars2 = 2 * new_vars;
|
||||
const unsigned delta2 = 2 * delta;
|
||||
assert (delta2 == new_vars2 - vars2);
|
||||
KISSAT_assert (delta2 == new_vars2 - vars2);
|
||||
memset (checker->watches + vars2, 0, delta2 * sizeof *checker->watches);
|
||||
memset (checker->marks + vars2, 0, delta2);
|
||||
memset (checker->used + vars2, 0, delta2);
|
||||
|
|
@ -566,11 +568,11 @@ static void resize_checker (kissat *solver, checker *checker,
|
|||
|
||||
static inline unsigned
|
||||
import_external_checker (kissat *solver, checker *checker, int elit) {
|
||||
assert (elit);
|
||||
KISSAT_assert (elit);
|
||||
const unsigned var = ABS (elit) - 1;
|
||||
if (var >= checker->vars)
|
||||
resize_checker (solver, checker, var + 1);
|
||||
assert (var < checker->vars);
|
||||
KISSAT_assert (var < checker->vars);
|
||||
return 2 * var + (elit < 0);
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +583,7 @@ import_internal_checker (kissat *solver, checker *checker, unsigned ilit) {
|
|||
}
|
||||
|
||||
static inline int export_checker (checker *checker, unsigned ilit) {
|
||||
assert (ilit <= 2 * checker->vars);
|
||||
KISSAT_assert (ilit <= 2 * checker->vars);
|
||||
return (1 + (ilit >> 1)) * ((ilit & 1) ? -1 : 1);
|
||||
}
|
||||
|
||||
|
|
@ -619,7 +621,7 @@ static void remove_line (kissat *solver, checker *checker, size_t size) {
|
|||
unwatch_line (solver, checker, bucket);
|
||||
LOGLINE3 ("removed checker");
|
||||
kissat_free (solver, bucket, bytes_line (size));
|
||||
assert (checker->buckets > 0);
|
||||
KISSAT_assert (checker->buckets > 0);
|
||||
checker->buckets--;
|
||||
checker->removed++;
|
||||
}
|
||||
|
|
@ -639,7 +641,7 @@ static void import_external_literals (kissat *solver, checker *checker,
|
|||
|
||||
static void import_internal_literals (kissat *solver, checker *checker,
|
||||
size_t size, const unsigned *ilits) {
|
||||
assert (size <= UINT_MAX);
|
||||
KISSAT_assert (size <= UINT_MAX);
|
||||
CLEAR_STACK (checker->imported);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
const unsigned ilit = ilits[i];
|
||||
|
|
@ -680,8 +682,8 @@ static bool checker_propagate (kissat *solver, checker *checker) {
|
|||
const unsigned lit = PEEK_STACK (checker->trail, propagated);
|
||||
const unsigned not_lit = lit ^ 1;
|
||||
LOG3 ("checker propagate %u", lit);
|
||||
assert (values[lit] > 0);
|
||||
assert (values[not_lit] < 0);
|
||||
KISSAT_assert (values[lit] > 0);
|
||||
KISSAT_assert (values[not_lit] < 0);
|
||||
propagated++;
|
||||
buckets *buckets = checker_watches (checker, not_lit);
|
||||
bucket **begin_of_lines = BEGIN_STACK (*buckets), **q = begin_of_lines;
|
||||
|
|
@ -774,10 +776,10 @@ static void checker_backtrack (checker *checker, unsigned saved) {
|
|||
signed char *values = checker->values;
|
||||
while (p != begin) {
|
||||
const unsigned lit = *--p;
|
||||
assert (VALID_CHECKER_LIT (lit));
|
||||
KISSAT_assert (VALID_CHECKER_LIT (lit));
|
||||
const unsigned not_lit = lit ^ 1;
|
||||
assert (values[lit] > 0);
|
||||
assert (values[not_lit] < 0);
|
||||
KISSAT_assert (values[lit] > 0);
|
||||
KISSAT_assert (values[not_lit] < 0);
|
||||
values[lit] = values[not_lit] = 0;
|
||||
}
|
||||
checker->propagated = saved;
|
||||
|
|
@ -787,7 +789,7 @@ static void checker_backtrack (checker *checker, unsigned saved) {
|
|||
static bool checker_blocked_literal (kissat *solver, checker *checker,
|
||||
unsigned lit) {
|
||||
signed char *values = checker->values;
|
||||
assert (values[lit] < 0);
|
||||
KISSAT_assert (values[lit] < 0);
|
||||
const unsigned not_lit = lit ^ 1;
|
||||
if (checker->large[not_lit])
|
||||
return false;
|
||||
|
|
@ -840,7 +842,7 @@ static void check_line (kissat *solver, checker *checker) {
|
|||
bool satisfied = false, pure = false;
|
||||
unsigned decisions = 0, prev = INVALID_LIT;
|
||||
for (all_stack (unsigned, lit, checker->imported)) {
|
||||
assert (prev != lit);
|
||||
KISSAT_assert (prev != lit);
|
||||
prev = lit;
|
||||
signed char lit_value = values[lit];
|
||||
if (lit_value < 0)
|
||||
|
|
@ -896,7 +898,7 @@ void kissat_add_unchecked_internal (kissat *solver, size_t size,
|
|||
LOGUNSIGNEDS3 (size, lits, "adding unchecked internal checker");
|
||||
checker *checker = solver->checker;
|
||||
checker->unchecked++;
|
||||
assert (size <= UINT_MAX);
|
||||
KISSAT_assert (size <= UINT_MAX);
|
||||
import_internal_literals (solver, checker, size, lits);
|
||||
insert_imported_if_not_simplified (solver, checker);
|
||||
}
|
||||
|
|
@ -904,8 +906,8 @@ void kissat_add_unchecked_internal (kissat *solver, size_t size,
|
|||
void kissat_check_and_add_binary (kissat *solver, unsigned a, unsigned b) {
|
||||
LOGBINARY3 (a, b, "checking and adding internal checker");
|
||||
checker *checker = solver->checker;
|
||||
assert (VALID_INTERNAL_LITERAL (a));
|
||||
assert (VALID_INTERNAL_LITERAL (b));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (a));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (b));
|
||||
import_binary (solver, checker, a, b);
|
||||
check_line (solver, checker);
|
||||
insert_imported_if_not_simplified (solver, checker);
|
||||
|
|
@ -939,7 +941,7 @@ void kissat_check_and_add_internal (kissat *solver, size_t size,
|
|||
void kissat_check_and_add_unit (kissat *solver, unsigned a) {
|
||||
LOG3 ("checking and adding internal checker internal unit %u", a);
|
||||
checker *checker = solver->checker;
|
||||
assert (VALID_INTERNAL_LITERAL (a));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (a));
|
||||
import_internal_unit (solver, checker, a);
|
||||
check_line (solver, checker);
|
||||
insert_imported_if_not_simplified (solver, checker);
|
||||
|
|
@ -969,8 +971,8 @@ void kissat_check_shrink_clause (kissat *solver, clause *c, unsigned remove,
|
|||
void kissat_remove_checker_binary (kissat *solver, unsigned a, unsigned b) {
|
||||
LOGBINARY3 (a, b, "removing internal checker");
|
||||
checker *checker = solver->checker;
|
||||
assert (VALID_INTERNAL_LITERAL (a));
|
||||
assert (VALID_INTERNAL_LITERAL (b));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (a));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (b));
|
||||
import_binary (solver, checker, a, b);
|
||||
remove_line_if_not_redundant (solver, checker);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#ifndef _check_h_INCLUDED
|
||||
#define _check_h_INCLUDED
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|
||||
struct kissat;
|
||||
|
||||
void kissat_check_satisfying_assignment (struct kissat *);
|
||||
|
|
@ -17,7 +20,7 @@ struct clause;
|
|||
void kissat_init_checker (struct kissat *);
|
||||
void kissat_release_checker (struct kissat *);
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
void kissat_print_checker_statistics (struct kissat *, bool verbose);
|
||||
#endif
|
||||
|
||||
|
|
@ -172,4 +175,7 @@ void kissat_remove_checker_internal (struct kissat *, size_t,
|
|||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@
|
|||
#include "internal.h"
|
||||
#include "print.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
void kissat_classify (struct kissat *solver) {
|
||||
statistics *s = &solver->statistics;
|
||||
statistics *s = &solver->statistics_;
|
||||
uint64_t clauses = s->clauses_binary + s->clauses_irredundant;
|
||||
unsigned small_clauses_limit = GET_OPTION (smallclauses);
|
||||
if (clauses <= small_clauses_limit) {
|
||||
|
|
@ -26,3 +28,5 @@ void kissat_classify (struct kissat *solver) {
|
|||
solver, "formula classified to have a %s binary clauses fraction",
|
||||
solver->classification.bigbig ? "large" : "small");
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
struct classification {
|
||||
|
|
@ -14,4 +17,6 @@ typedef struct classification classification;
|
|||
|
||||
void kissat_classify (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void inc_clause (kissat *solver, bool original, bool redundant,
|
||||
bool binary) {
|
||||
if (binary)
|
||||
|
|
@ -28,8 +30,8 @@ static void dec_clause (kissat *solver, bool redundant, bool binary) {
|
|||
|
||||
static void init_clause (clause *res, bool redundant, unsigned glue,
|
||||
unsigned size) {
|
||||
assert (size <= UINT_MAX);
|
||||
assert (redundant || !glue);
|
||||
KISSAT_assert (size <= UINT_MAX);
|
||||
KISSAT_assert (redundant || !glue);
|
||||
|
||||
glue = MIN (MAX_GLUE, glue);
|
||||
|
||||
|
|
@ -64,8 +66,8 @@ void kissat_connect_clause (kissat *solver, clause *c) {
|
|||
static reference new_binary_clause (kissat *solver, bool original,
|
||||
bool watch, unsigned first,
|
||||
unsigned second) {
|
||||
assert (first != second);
|
||||
assert (first != NOT (second));
|
||||
KISSAT_assert (first != second);
|
||||
KISSAT_assert (first != NOT (second));
|
||||
if (watch)
|
||||
kissat_watch_binary (solver, first, second);
|
||||
kissat_mark_added_literal (solver, first);
|
||||
|
|
@ -81,7 +83,7 @@ static reference new_binary_clause (kissat *solver, bool original,
|
|||
static reference new_large_clause (kissat *solver, bool original,
|
||||
bool redundant, unsigned glue,
|
||||
unsigned size, unsigned *lits) {
|
||||
assert (size > 2);
|
||||
KISSAT_assert (size > 2);
|
||||
reference res = kissat_allocate_clause (solver, size);
|
||||
clause *c = kissat_unchecked_dereference_clause (solver, res);
|
||||
init_clause (c, redundant, glue, size);
|
||||
|
|
@ -148,19 +150,19 @@ reference kissat_new_redundant_clause (kissat *solver, unsigned glue) {
|
|||
}
|
||||
|
||||
static void mark_clause_as_garbage (kissat *solver, clause *c) {
|
||||
assert (!c->garbage);
|
||||
KISSAT_assert (!c->garbage);
|
||||
LOGCLS (c, "garbage");
|
||||
if (!c->redundant)
|
||||
kissat_mark_removed_literals (solver, c->size, c->lits);
|
||||
REMOVE_CHECKER_CLAUSE (c);
|
||||
DELETE_CLAUSE_FROM_PROOF (c);
|
||||
assert (c->size > 2);
|
||||
KISSAT_assert (c->size > 2);
|
||||
dec_clause (solver, c->redundant, false);
|
||||
c->garbage = true;
|
||||
}
|
||||
|
||||
void kissat_mark_clause_as_garbage (kissat *solver, clause *c) {
|
||||
assert (!c->garbage);
|
||||
KISSAT_assert (!c->garbage);
|
||||
mark_clause_as_garbage (solver, c);
|
||||
size_t bytes = kissat_actual_bytes_of_clause (c);
|
||||
ADD (arena_garbage, bytes);
|
||||
|
|
@ -168,8 +170,8 @@ void kissat_mark_clause_as_garbage (kissat *solver, clause *c) {
|
|||
|
||||
clause *kissat_delete_clause (kissat *solver, clause *c) {
|
||||
LOGCLS (c, "delete");
|
||||
assert (c->size > 2);
|
||||
assert (c->garbage);
|
||||
KISSAT_assert (c->size > 2);
|
||||
KISSAT_assert (c->garbage);
|
||||
size_t bytes = kissat_actual_bytes_of_clause (c);
|
||||
SUB (arena_garbage, bytes);
|
||||
INC (clauses_deleted);
|
||||
|
|
@ -185,3 +187,5 @@ void kissat_delete_binary (kissat *solver, unsigned a, unsigned b) {
|
|||
dec_clause (solver, false, true);
|
||||
INC (clauses_deleted);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct clause clause;
|
||||
|
||||
#define LD_MAX_GLUE 19
|
||||
|
|
@ -87,4 +90,6 @@ void kissat_delete_binary (struct kissat *, unsigned, unsigned);
|
|||
|
||||
void kissat_mark_clause_as_garbage (struct kissat *, clause *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@
|
|||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void flush_watched_clauses_by_literal (kissat *solver, unsigned lit,
|
||||
bool compact,
|
||||
reference start) {
|
||||
assert (start != INVALID_REF);
|
||||
KISSAT_assert (start != INVALID_REF);
|
||||
|
||||
const value *const values = solver->values;
|
||||
const assigned *const all_assigned = solver->assigned;
|
||||
|
|
@ -44,8 +46,8 @@ static void flush_watched_clauses_by_literal (kissat *solver, unsigned lit,
|
|||
if (lit < other)
|
||||
kissat_delete_binary (solver, lit, other);
|
||||
} else {
|
||||
assert (!lit_fixed);
|
||||
assert (!other_fixed);
|
||||
KISSAT_assert (!lit_fixed);
|
||||
KISSAT_assert (!other_fixed);
|
||||
|
||||
{
|
||||
head.binary.lit = mother;
|
||||
|
|
@ -59,7 +61,7 @@ static void flush_watched_clauses_by_literal (kissat *solver, unsigned lit,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
const watch tail = *p++;
|
||||
if (!lit_fixed) {
|
||||
const reference ref = tail.large.ref;
|
||||
|
|
@ -71,7 +73,7 @@ static void flush_watched_clauses_by_literal (kissat *solver, unsigned lit,
|
|||
}
|
||||
}
|
||||
|
||||
assert (!lit_fixed || q == begin);
|
||||
KISSAT_assert (!lit_fixed || q == begin);
|
||||
SET_END_OF_WATCHES (*lit_watches, q);
|
||||
#ifdef LOGGING
|
||||
const size_t size_lit_watches = SIZE_WATCHES (*lit_watches);
|
||||
|
|
@ -84,25 +86,25 @@ static void flush_watched_clauses_by_literal (kissat *solver, unsigned lit,
|
|||
return;
|
||||
|
||||
watches *mlit_watches = &WATCHES (mlit);
|
||||
#if defined(LOGGING) || !defined(NDEBUG)
|
||||
#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
|
||||
const size_t size_mlit_watches = SIZE_WATCHES (*mlit_watches);
|
||||
#endif
|
||||
if (lit_fixed)
|
||||
assert (!size_mlit_watches);
|
||||
KISSAT_assert (!size_mlit_watches);
|
||||
else if (mlit < lit) {
|
||||
assert (mlit != INVALID_LIT);
|
||||
assert (mlit < lit);
|
||||
KISSAT_assert (mlit != INVALID_LIT);
|
||||
KISSAT_assert (mlit < lit);
|
||||
*mlit_watches = *lit_watches;
|
||||
LOG ("copied watches[%u] = watches[%u] (size %zu)", mlit, lit,
|
||||
size_mlit_watches);
|
||||
memset (lit_watches, 0, sizeof *lit_watches);
|
||||
} else
|
||||
assert (mlit == lit);
|
||||
KISSAT_assert (mlit == lit);
|
||||
}
|
||||
|
||||
static void flush_all_watched_clauses (kissat *solver, bool compact,
|
||||
reference start) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
LOG ("starting to flush watches at clause[%" REFERENCE_FORMAT "]", start);
|
||||
for (all_variables (idx)) {
|
||||
const unsigned lit = LIT (idx);
|
||||
|
|
@ -114,12 +116,12 @@ static void flush_all_watched_clauses (kissat *solver, bool compact,
|
|||
|
||||
static void update_large_reason (kissat *solver, assigned *assigned,
|
||||
unsigned forced, clause *dst) {
|
||||
assert (dst->reason);
|
||||
assert (forced != INVALID_LIT);
|
||||
KISSAT_assert (dst->reason);
|
||||
KISSAT_assert (forced != INVALID_LIT);
|
||||
reference dst_ref = kissat_reference_clause (solver, dst);
|
||||
const unsigned forced_idx = IDX (forced);
|
||||
struct assigned *a = assigned + forced_idx;
|
||||
assert (!a->binary);
|
||||
KISSAT_assert (!a->binary);
|
||||
if (a->reason != dst_ref) {
|
||||
LOG ("reason reference %u of %s updated to %u", a->reason,
|
||||
LOGLIT (forced), dst_ref);
|
||||
|
|
@ -129,7 +131,7 @@ static void update_large_reason (kissat *solver, assigned *assigned,
|
|||
}
|
||||
|
||||
static unsigned get_forced (const value *values, clause *dst) {
|
||||
assert (dst->reason);
|
||||
KISSAT_assert (dst->reason);
|
||||
unsigned forced = INVALID_LIT;
|
||||
for (all_literals_in_clause (lit, dst)) {
|
||||
const value value = values[lit];
|
||||
|
|
@ -138,7 +140,7 @@ static unsigned get_forced (const value *values, clause *dst) {
|
|||
forced = lit;
|
||||
break;
|
||||
}
|
||||
assert (forced != INVALID_LIT);
|
||||
KISSAT_assert (forced != INVALID_LIT);
|
||||
return forced;
|
||||
}
|
||||
|
||||
|
|
@ -181,9 +183,9 @@ static void update_last_irredundant (kissat *solver, const clause *end,
|
|||
}
|
||||
|
||||
void kissat_update_first_reducible (kissat *solver, clause *reducible) {
|
||||
assert (reducible);
|
||||
assert (!reducible->garbage);
|
||||
assert (reducible->redundant);
|
||||
KISSAT_assert (reducible);
|
||||
KISSAT_assert (!reducible->garbage);
|
||||
KISSAT_assert (reducible->redundant);
|
||||
if (solver->first_reducible != INVALID_REF) {
|
||||
reference ref = kissat_reference_clause (solver, reducible);
|
||||
if (ref >= solver->first_reducible) {
|
||||
|
|
@ -196,9 +198,9 @@ void kissat_update_first_reducible (kissat *solver, clause *reducible) {
|
|||
}
|
||||
|
||||
void kissat_update_last_irredundant (kissat *solver, clause *irredundant) {
|
||||
assert (irredundant);
|
||||
assert (!irredundant->garbage);
|
||||
assert (!irredundant->redundant);
|
||||
KISSAT_assert (irredundant);
|
||||
KISSAT_assert (!irredundant->garbage);
|
||||
KISSAT_assert (!irredundant->redundant);
|
||||
if (solver->last_irredundant != INVALID_REF) {
|
||||
reference ref = kissat_reference_clause (solver, irredundant);
|
||||
if (ref <= solver->last_irredundant) {
|
||||
|
|
@ -213,10 +215,10 @@ void kissat_update_last_irredundant (kissat *solver, clause *irredundant) {
|
|||
static void move_redundant_clauses_to_the_end (kissat *solver,
|
||||
reference ref) {
|
||||
INC (moved);
|
||||
assert (ref != INVALID_REF);
|
||||
#ifndef NDEBUG
|
||||
KISSAT_assert (ref != INVALID_REF);
|
||||
#ifndef KISSAT_NDEBUG
|
||||
const size_t size = SIZE_STACK (solver->arena);
|
||||
assert ((size_t) ref <= size);
|
||||
KISSAT_assert ((size_t) ref <= size);
|
||||
#endif
|
||||
clause *begin = (clause *) (BEGIN_STACK (solver->arena) + ref);
|
||||
clause *end = (clause *) END_STACK (solver->arena);
|
||||
|
|
@ -234,7 +236,7 @@ static void move_redundant_clauses_to_the_end (kissat *solver,
|
|||
clause *last_irredundant = kissat_last_irredundant_clause (solver);
|
||||
|
||||
while (p != end) {
|
||||
assert (!p->shrunken);
|
||||
KISSAT_assert (!p->shrunken);
|
||||
size_t bytes = kissat_bytes_of_clause (p->size);
|
||||
if (p->redundant) {
|
||||
memcpy (r, p, bytes);
|
||||
|
|
@ -258,16 +260,16 @@ static void move_redundant_clauses_to_the_end (kissat *solver,
|
|||
LOGCLS (q, "new DST");
|
||||
if (q->reason)
|
||||
get_forced_and_update_large_reason (solver, assigned, values, q);
|
||||
assert (q->redundant);
|
||||
KISSAT_assert (q->redundant);
|
||||
if (!first_reducible)
|
||||
first_reducible = q;
|
||||
r = (clause *) (bytes + (char *) r);
|
||||
q = (clause *) (bytes + (char *) q);
|
||||
}
|
||||
assert ((char *) r <= (char *) redundant + bytes_redundant);
|
||||
KISSAT_assert ((char *) r <= (char *) redundant + bytes_redundant);
|
||||
kissat_free (solver, redundant, bytes_redundant);
|
||||
|
||||
assert (!first_reducible || first_reducible < q);
|
||||
KISSAT_assert (!first_reducible || first_reducible < q);
|
||||
|
||||
update_first_reducible (solver, q, first_reducible);
|
||||
update_last_irredundant (solver, q, last_irredundant);
|
||||
|
|
@ -276,20 +278,20 @@ static void move_redundant_clauses_to_the_end (kissat *solver,
|
|||
|
||||
static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
||||
reference start) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
LOG ("sparse garbage collection starting at clause[%" REFERENCE_FORMAT
|
||||
"]",
|
||||
start);
|
||||
#ifdef CHECKING_OR_PROVING
|
||||
const bool checking_or_proving = kissat_checking_or_proving (solver);
|
||||
#endif
|
||||
assert (EMPTY_STACK (solver->added));
|
||||
assert (EMPTY_STACK (solver->removed));
|
||||
KISSAT_assert (EMPTY_STACK (solver->added));
|
||||
KISSAT_assert (EMPTY_STACK (solver->removed));
|
||||
|
||||
const value *const values = solver->values;
|
||||
assigned *assigned = solver->assigned;
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t flushed_garbage_clauses = 0;
|
||||
size_t flushed_satisfied_clauses = 0;
|
||||
#endif
|
||||
|
|
@ -319,7 +321,7 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
for (clause *next; src != end; src = next) {
|
||||
if (src->garbage) {
|
||||
next = kissat_delete_clause (solver, src);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
flushed_garbage_clauses++;
|
||||
#endif
|
||||
if (last_irredundant == src) {
|
||||
|
|
@ -331,13 +333,13 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
continue;
|
||||
}
|
||||
|
||||
assert (src->size > 1);
|
||||
KISSAT_assert (src->size > 1);
|
||||
LOGCLS (src, "SRC");
|
||||
next = kissat_next_clause (src);
|
||||
#if !defined(NDEBUG) || defined(CHECKING_OR_PROVING)
|
||||
#if !defined(KISSAT_NDEBUG) || defined(CHECKING_OR_PROVING)
|
||||
const unsigned old_size = src->size;
|
||||
#endif
|
||||
assert (SIZE_OF_CLAUSE_HEADER == sizeof (unsigned));
|
||||
KISSAT_assert (SIZE_OF_CLAUSE_HEADER == sizeof (unsigned));
|
||||
*(unsigned *) dst = *(unsigned *) src;
|
||||
|
||||
unsigned *q = dst->lits;
|
||||
|
|
@ -365,15 +367,15 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
if (tmp < 0 && !level)
|
||||
flushed++;
|
||||
else if (tmp > 0 && !level) {
|
||||
assert (!satisfied);
|
||||
assert (!dst->reason);
|
||||
KISSAT_assert (!satisfied);
|
||||
KISSAT_assert (!dst->reason);
|
||||
LOG ("SRC satisfied by %s", LOGLIT (lit));
|
||||
satisfied = true;
|
||||
} else {
|
||||
const unsigned mlit = kissat_map_literal (solver, lit, compact);
|
||||
|
||||
if (tmp > 0) {
|
||||
assert (level);
|
||||
KISSAT_assert (level);
|
||||
forced = non_false++ ? INVALID_LIT : lit;
|
||||
} else if (tmp < 0)
|
||||
other = lit;
|
||||
|
|
@ -397,7 +399,7 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
DEC (clauses_redundant);
|
||||
else
|
||||
DEC (clauses_irredundant);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
flushed_satisfied_clauses++;
|
||||
#endif
|
||||
#ifdef CHECKING_OR_PROVING
|
||||
|
|
@ -418,36 +420,36 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
}
|
||||
|
||||
const unsigned new_size = q - dst->lits;
|
||||
assert (new_size <= old_size);
|
||||
assert (1 < new_size);
|
||||
KISSAT_assert (new_size <= old_size);
|
||||
KISSAT_assert (1 < new_size);
|
||||
|
||||
if (new_size == 2) {
|
||||
assert (mfirst != INVALID_LIT);
|
||||
assert (msecond != INVALID_LIT);
|
||||
KISSAT_assert (mfirst != INVALID_LIT);
|
||||
KISSAT_assert (msecond != INVALID_LIT);
|
||||
|
||||
statistics *statistics = &solver->statistics;
|
||||
assert (statistics->clauses_binary < UINT64_MAX);
|
||||
statistics *statistics = &solver->statistics_;
|
||||
KISSAT_assert (statistics->clauses_binary < UINT64_MAX);
|
||||
statistics->clauses_binary++;
|
||||
bool redundant = dst->redundant;
|
||||
if (redundant) {
|
||||
assert (statistics->clauses_redundant > 0);
|
||||
KISSAT_assert (statistics->clauses_redundant > 0);
|
||||
statistics->clauses_redundant--;
|
||||
redundant = false;
|
||||
} else {
|
||||
assert (statistics->clauses_irredundant > 0);
|
||||
KISSAT_assert (statistics->clauses_irredundant > 0);
|
||||
statistics->clauses_irredundant--;
|
||||
}
|
||||
LOGBINARY (mfirst, msecond, "DST");
|
||||
kissat_watch_binary (solver, mfirst, msecond);
|
||||
|
||||
if (dst->reason) {
|
||||
assert (non_false == 1);
|
||||
assert (other != INVALID_LIT);
|
||||
assert (forced != INVALID_LIT);
|
||||
KISSAT_assert (non_false == 1);
|
||||
KISSAT_assert (other != INVALID_LIT);
|
||||
KISSAT_assert (forced != INVALID_LIT);
|
||||
|
||||
const unsigned forced_idx = IDX (forced);
|
||||
struct assigned *a = assigned + forced_idx;
|
||||
assert (!a->binary);
|
||||
KISSAT_assert (!a->binary);
|
||||
|
||||
LOGBINARY (mfirst, msecond,
|
||||
"reason clause[%u] of %s updated to binary reason",
|
||||
|
|
@ -464,7 +466,7 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
last_irredundant = first;
|
||||
}
|
||||
} else {
|
||||
assert (2 < new_size);
|
||||
KISSAT_assert (2 < new_size);
|
||||
|
||||
dst->size = new_size;
|
||||
dst->shrunken = false;
|
||||
|
|
@ -495,8 +497,8 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
continue;
|
||||
|
||||
if (new_size != old_size) {
|
||||
assert (1 < new_size);
|
||||
assert (new_size < old_size);
|
||||
KISSAT_assert (1 < new_size);
|
||||
KISSAT_assert (new_size < old_size);
|
||||
|
||||
CHECK_AND_ADD_STACK (solver->added);
|
||||
ADD_STACK_TO_PROOF (solver->added);
|
||||
|
|
@ -516,10 +518,10 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
if (first_redundant)
|
||||
LOGCLS (first_redundant, "determined first redundant clause as");
|
||||
|
||||
#if !defined(QUIET) || defined(METRICS)
|
||||
#if !defined(KISSAT_QUIET) || defined(METRICS)
|
||||
size_t bytes = (char *) END_STACK (solver->arena) - (char *) dst;
|
||||
#endif
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
if (flushed)
|
||||
kissat_phase (solver, "collect", GET (garbage_collections),
|
||||
"flushed %zu falsified literals in large clauses",
|
||||
|
|
@ -556,18 +558,18 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
kissat_percent (redundant_bytes, move_bytes),
|
||||
FORMAT_BYTES (move_bytes));
|
||||
#endif
|
||||
assert (first_redundant < dst);
|
||||
KISSAT_assert (first_redundant < dst);
|
||||
res = kissat_reference_clause (solver, first_redundant);
|
||||
assert (res != INVALID_REF);
|
||||
KISSAT_assert (res != INVALID_REF);
|
||||
}
|
||||
|
||||
SET_END_OF_STACK (solver->arena, (ward *) dst);
|
||||
kissat_shrink_arena (solver);
|
||||
|
||||
#ifdef METRICS
|
||||
if (solver->statistics.arena_garbage)
|
||||
if (solver->statistics_.arena_garbage)
|
||||
kissat_very_verbose (solver, "still %s garbage left in arena",
|
||||
FORMAT_BYTES (solver->statistics.arena_garbage));
|
||||
FORMAT_BYTES (solver->statistics_.arena_garbage));
|
||||
else
|
||||
kissat_very_verbose (solver, "all garbage clauses in arena collected");
|
||||
#endif
|
||||
|
|
@ -578,7 +580,7 @@ static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
|
|||
static void rewatch_clauses (kissat *solver, reference start) {
|
||||
LOG ("rewatching clause[%" REFERENCE_FORMAT "] and following clauses",
|
||||
start);
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
|
||||
const value *const values = solver->values;
|
||||
const assigned *const assigned = solver->assigned;
|
||||
|
|
@ -587,7 +589,7 @@ static void rewatch_clauses (kissat *solver, reference start) {
|
|||
|
||||
clause *end = (clause *) END_STACK (solver->arena);
|
||||
clause *c = (clause *) (BEGIN_STACK (solver->arena) + start);
|
||||
assert (c <= end);
|
||||
KISSAT_assert (c <= end);
|
||||
|
||||
for (clause *next; c != end; c = next) {
|
||||
next = kissat_next_clause (c);
|
||||
|
|
@ -606,7 +608,7 @@ static void rewatch_clauses (kissat *solver, reference start) {
|
|||
}
|
||||
|
||||
void kissat_sparse_collect (kissat *solver, bool compact, reference start) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
START (collect);
|
||||
INC (garbage_collections);
|
||||
INC (sparse_gcs);
|
||||
|
|
@ -643,11 +645,11 @@ bool kissat_compacting (kissat *solver) {
|
|||
}
|
||||
|
||||
void kissat_initial_sparse_collect (kissat *solver) {
|
||||
assert (!solver->level);
|
||||
assert (!solver->inconsistent);
|
||||
assert (solver->watching);
|
||||
assert (kissat_trail_flushed (solver));
|
||||
if (solver->statistics.units) {
|
||||
KISSAT_assert (!solver->level);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
KISSAT_assert (solver->watching);
|
||||
KISSAT_assert (kissat_trail_flushed (solver));
|
||||
if (solver->statistics_.units) {
|
||||
bool compact = GET_OPTION (compact);
|
||||
kissat_sparse_collect (solver, compact, 0);
|
||||
}
|
||||
|
|
@ -655,12 +657,12 @@ void kissat_initial_sparse_collect (kissat *solver) {
|
|||
}
|
||||
|
||||
static void dense_sweep_garbage_clauses (kissat *solver) {
|
||||
assert (!solver->level);
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->level);
|
||||
KISSAT_assert (!solver->watching);
|
||||
|
||||
LOG ("dense garbage collection");
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t flushed_garbage_clauses = 0;
|
||||
#endif
|
||||
clause *first_reducible = 0;
|
||||
|
|
@ -675,15 +677,15 @@ static void dense_sweep_garbage_clauses (kissat *solver) {
|
|||
for (clause *next; src != end; src = next) {
|
||||
if (src->garbage) {
|
||||
next = kissat_delete_clause (solver, src);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
flushed_garbage_clauses++;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
assert (src->size > 1);
|
||||
KISSAT_assert (src->size > 1);
|
||||
LOGCLS (src, "SRC");
|
||||
next = kissat_next_clause (src);
|
||||
assert (SIZE_OF_CLAUSE_HEADER == sizeof (unsigned));
|
||||
KISSAT_assert (SIZE_OF_CLAUSE_HEADER == sizeof (unsigned));
|
||||
*(unsigned *) dst = *(unsigned *) src;
|
||||
dst->searched = src->searched;
|
||||
dst->size = src->size;
|
||||
|
|
@ -701,7 +703,7 @@ static void dense_sweep_garbage_clauses (kissat *solver) {
|
|||
update_last_irredundant (solver, dst, last_irredundant);
|
||||
kissat_reset_last_learned (solver);
|
||||
|
||||
#if !defined(QUIET) || defined(METRICS)
|
||||
#if !defined(KISSAT_QUIET) || defined(METRICS)
|
||||
size_t bytes = (char *) END_STACK (solver->arena) - (char *) dst;
|
||||
#endif
|
||||
kissat_phase (solver, "collect", GET (garbage_collections),
|
||||
|
|
@ -717,17 +719,17 @@ static void dense_sweep_garbage_clauses (kissat *solver) {
|
|||
kissat_shrink_arena (solver);
|
||||
|
||||
#ifdef METRICS
|
||||
if (solver->statistics.arena_garbage)
|
||||
if (solver->statistics_.arena_garbage)
|
||||
kissat_very_verbose (solver, "still %s garbage left in arena",
|
||||
FORMAT_BYTES (solver->statistics.arena_garbage));
|
||||
FORMAT_BYTES (solver->statistics_.arena_garbage));
|
||||
else
|
||||
kissat_very_verbose (solver, "all garbage clauses in arena collected");
|
||||
#endif
|
||||
}
|
||||
|
||||
void kissat_dense_collect (kissat *solver) {
|
||||
assert (!solver->watching);
|
||||
assert (!solver->level);
|
||||
KISSAT_assert (!solver->watching);
|
||||
KISSAT_assert (!solver->level);
|
||||
START (collect);
|
||||
INC (garbage_collections);
|
||||
INC (dense_garbage_collections);
|
||||
|
|
@ -736,3 +738,5 @@ void kissat_dense_collect (kissat *solver) {
|
|||
REPORT (1, 'C');
|
||||
STOP (collect);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "internal.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
bool kissat_compacting (kissat *);
|
||||
void kissat_dense_collect (kissat *);
|
||||
void kissat_sparse_collect (kissat *, bool compact, reference start);
|
||||
|
|
@ -30,4 +33,6 @@ static inline void kissat_defrag_watches_if_needed (kissat *solver) {
|
|||
void kissat_update_last_irredundant (kissat *, clause *last_irredundant);
|
||||
void kissat_update_first_reducible (kissat *, clause *first_reducible);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
#include "colors.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define isatty _isatty
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
int kissat_is_terminal[3] = {0, -1, -1};
|
||||
|
||||
int kissat_initialize_terminal (int fd) {
|
||||
assert (fd == 1 || fd == 2);
|
||||
assert (kissat_is_terminal[fd] < 0);
|
||||
KISSAT_assert (fd == 1 || fd == 2);
|
||||
KISSAT_assert (kissat_is_terminal[fd] < 0);
|
||||
return kissat_is_terminal[fd] = isatty (fd);
|
||||
}
|
||||
|
||||
|
|
@ -17,3 +23,5 @@ void kissat_force_colors (void) {
|
|||
void kissat_force_no_colors (void) {
|
||||
kissat_is_terminal[1] = kissat_is_terminal[2] = 0;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
#include "keatures.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define BLUE "\033[34m"
|
||||
#define BOLD "\033[1m"
|
||||
#define CYAN "\033[36m"
|
||||
|
|
@ -21,17 +24,17 @@
|
|||
#define DARK_GRAY "\033[0;37m"
|
||||
|
||||
#ifdef KISSAT_HAS_FILENO
|
||||
#define assert_if_has_fileno assert
|
||||
#define KISSAT_assert_if_has_fileno KISSAT_assert
|
||||
#else
|
||||
#define assert_if_has_fileno(...) \
|
||||
#define KISSAT_assert_if_has_fileno(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define TERMINAL(F, I) \
|
||||
assert_if_has_fileno (fileno (F) == \
|
||||
KISSAT_assert_if_has_fileno (fileno (F) == \
|
||||
I); /* 'fileno' only in POSIX not C99 */ \
|
||||
assert ((I == 1 && F == stdout) || (I == 2 && F == stderr)); \
|
||||
KISSAT_assert ((I == 1 && F == stdout) || (I == 2 && F == stderr)); \
|
||||
bool connected_to_terminal = kissat_connected_to_terminal (I); \
|
||||
FILE *terminal_file = F
|
||||
|
||||
|
|
@ -49,11 +52,11 @@ void kissat_force_colors (void);
|
|||
void kissat_force_no_colors (void);
|
||||
|
||||
static inline bool kissat_connected_to_terminal (int fd) {
|
||||
assert (fd == 1 || fd == 2);
|
||||
KISSAT_assert (fd == 1 || fd == 2);
|
||||
int res = kissat_is_terminal[fd];
|
||||
if (res < 0)
|
||||
res = kissat_initialize_terminal (fd);
|
||||
assert (res == 0 || res == 1);
|
||||
KISSAT_assert (res == 0 || res == 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -65,4 +68,6 @@ static inline const char *kissat_normal_color_code (int fd) {
|
|||
return kissat_connected_to_terminal (fd) ? NORMAL : "";
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void reimport_literal (kissat *solver, unsigned eidx,
|
||||
unsigned mlit) {
|
||||
import *import = &PEEK_STACK (solver->import, eidx);
|
||||
assert (import->imported);
|
||||
assert (!import->eliminated);
|
||||
KISSAT_assert (import->imported);
|
||||
KISSAT_assert (!import->eliminated);
|
||||
LOG ("reimporting external variable %u as internal literal %u (was %u)",
|
||||
eidx, mlit, import->lit);
|
||||
import->lit = mlit;
|
||||
|
|
@ -18,9 +20,9 @@ static void reimport_literal (kissat *solver, unsigned eidx,
|
|||
|
||||
unsigned kissat_compact_literals (kissat *solver, unsigned *mfixed_ptr) {
|
||||
INC (compacted);
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
const unsigned active = solver->active;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const unsigned inactive = solver->vars - active;
|
||||
kissat_phase (solver, "compact", GET (compacted),
|
||||
"compacting garbage collection "
|
||||
|
|
@ -29,7 +31,7 @@ unsigned kissat_compact_literals (kissat *solver, unsigned *mfixed_ptr) {
|
|||
#endif
|
||||
#endif
|
||||
#ifdef LOGGING
|
||||
assert (!solver->compacting);
|
||||
KISSAT_assert (!solver->compacting);
|
||||
solver->compacting = true;
|
||||
#endif
|
||||
unsigned mfixed = INVALID_LIT;
|
||||
|
|
@ -42,7 +44,7 @@ unsigned kissat_compact_literals (kissat *solver, unsigned *mfixed_ptr) {
|
|||
unsigned mlit;
|
||||
if (flags->fixed) {
|
||||
const value value = kissat_fixed (solver, ilit);
|
||||
assert (value);
|
||||
KISSAT_assert (value);
|
||||
if (mfixed == INVALID_LIT) {
|
||||
mlit = mfixed = LIT (vars);
|
||||
LOG2 ("first fixed %u mapped to %u assigned to %d", ilit, mfixed,
|
||||
|
|
@ -59,29 +61,29 @@ unsigned kissat_compact_literals (kissat *solver, unsigned *mfixed_ptr) {
|
|||
LOG2 ("positively fixed %u mapped to %u", ilit, mlit);
|
||||
}
|
||||
} else if (flags->active) {
|
||||
assert (flags->active);
|
||||
KISSAT_assert (flags->active);
|
||||
mlit = LIT (vars);
|
||||
LOG2 ("remapping %u to %u", ilit, mlit);
|
||||
vars++;
|
||||
} else {
|
||||
const int elit = PEEK_STACK (solver->export, iidx);
|
||||
const int elit = PEEK_STACK (solver->export_, iidx);
|
||||
if (elit) {
|
||||
const unsigned eidx = ABS (elit);
|
||||
import *import = &PEEK_STACK (solver->import, eidx);
|
||||
assert (import->imported);
|
||||
assert (!import->eliminated);
|
||||
KISSAT_assert (import->imported);
|
||||
KISSAT_assert (!import->eliminated);
|
||||
import->imported = false;
|
||||
LOG2 ("external variable %d not imported anymore", eidx);
|
||||
POKE_STACK (solver->export, iidx, 0);
|
||||
POKE_STACK (solver->export_, iidx, 0);
|
||||
} else
|
||||
LOG2 ("skipping inactive %u", ilit);
|
||||
continue;
|
||||
}
|
||||
assert (mlit <= ilit);
|
||||
assert (mlit != NOT (ilit));
|
||||
KISSAT_assert (mlit <= ilit);
|
||||
KISSAT_assert (mlit != NOT (ilit));
|
||||
if (mlit == ilit)
|
||||
continue;
|
||||
const int elit = PEEK_STACK (solver->export, iidx);
|
||||
const int elit = PEEK_STACK (solver->export_, iidx);
|
||||
const unsigned eidx = ABS (elit);
|
||||
if (elit < 0)
|
||||
mlit = NOT (mlit);
|
||||
|
|
@ -90,17 +92,17 @@ unsigned kissat_compact_literals (kissat *solver, unsigned *mfixed_ptr) {
|
|||
*mfixed_ptr = mfixed;
|
||||
LOG ("compacting to %u variables %.2f%% from %u", vars,
|
||||
kissat_percent (vars, solver->vars), solver->vars);
|
||||
assert (vars == active || vars == active + 1);
|
||||
KISSAT_assert (vars == active || vars == active + 1);
|
||||
return vars;
|
||||
}
|
||||
|
||||
static void compact_literal (kissat *solver, unsigned dst_lit,
|
||||
unsigned src_lit) {
|
||||
assert (dst_lit < src_lit);
|
||||
assert (dst_lit != NOT (src_lit));
|
||||
KISSAT_assert (dst_lit < src_lit);
|
||||
KISSAT_assert (dst_lit != NOT (src_lit));
|
||||
const unsigned dst_idx = IDX (dst_lit);
|
||||
const unsigned src_idx = IDX (src_lit);
|
||||
assert (dst_idx != src_idx);
|
||||
KISSAT_assert (dst_idx != src_idx);
|
||||
LOG ("mapping old internal literal %u to %u", src_lit, dst_lit);
|
||||
solver->assigned[dst_idx] = solver->assigned[src_idx];
|
||||
solver->flags[dst_idx] = solver->flags[src_idx];
|
||||
|
|
@ -116,19 +118,19 @@ static void compact_literal (kissat *solver, unsigned dst_lit,
|
|||
}
|
||||
|
||||
static unsigned map_idx (kissat *solver, unsigned iidx) {
|
||||
int elit = PEEK_STACK (solver->export, iidx);
|
||||
int elit = PEEK_STACK (solver->export_, iidx);
|
||||
if (!elit)
|
||||
return INVALID_IDX;
|
||||
assert (elit);
|
||||
KISSAT_assert (elit);
|
||||
const unsigned eidx = ABS (elit);
|
||||
assert (eidx);
|
||||
KISSAT_assert (eidx);
|
||||
import *import = &PEEK_STACK (solver->import, eidx);
|
||||
assert (import->imported);
|
||||
KISSAT_assert (import->imported);
|
||||
if (import->eliminated)
|
||||
return INVALID_IDX;
|
||||
const unsigned mlit = import->lit;
|
||||
const unsigned midx = IDX (mlit);
|
||||
assert (midx <= iidx);
|
||||
KISSAT_assert (midx <= iidx);
|
||||
return midx;
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +141,7 @@ static void compact_queue (kissat *solver) {
|
|||
solver->queue.stamp = 0;
|
||||
for (unsigned idx; !DISCONNECTED (idx = *p); p = &l->next) {
|
||||
const unsigned midx = map_idx (solver, idx);
|
||||
assert (midx != INVALID_IDX);
|
||||
KISSAT_assert (midx != INVALID_IDX);
|
||||
l = links + idx;
|
||||
l->prev = prev;
|
||||
l->stamp = ++solver->queue.stamp;
|
||||
|
|
@ -211,16 +213,16 @@ static void compact_trail (kissat *solver) {
|
|||
for (size_t i = 0; i < size; i++) {
|
||||
const unsigned ilit = PEEK_ARRAY (solver->trail, i);
|
||||
const unsigned mlit = kissat_map_literal (solver, ilit, true);
|
||||
assert (mlit != INVALID_LIT);
|
||||
KISSAT_assert (mlit != INVALID_LIT);
|
||||
POKE_ARRAY (solver->trail, i, mlit);
|
||||
const unsigned idx = IDX (ilit);
|
||||
assigned *a = solver->assigned + idx;
|
||||
if (!a->binary)
|
||||
continue;
|
||||
const unsigned other = a->reason;
|
||||
assert (VALID_INTERNAL_LITERAL (other));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (other));
|
||||
const unsigned mother = kissat_map_literal (solver, other, true);
|
||||
assert (mother != INVALID_LIT);
|
||||
KISSAT_assert (mother != INVALID_LIT);
|
||||
a->reason = mother;
|
||||
}
|
||||
}
|
||||
|
|
@ -232,55 +234,55 @@ static void compact_frames (kissat *solver) {
|
|||
frame *frame = &FRAME (level);
|
||||
const unsigned ilit = frame->decision;
|
||||
const unsigned mlit = kissat_map_literal (solver, ilit, true);
|
||||
assert (mlit != INVALID_LIT);
|
||||
KISSAT_assert (mlit != INVALID_LIT);
|
||||
frame->decision = mlit;
|
||||
}
|
||||
}
|
||||
|
||||
static void compact_export (kissat *solver, unsigned vars) {
|
||||
LOG ("compacting export");
|
||||
const size_t size = SIZE_STACK (solver->export);
|
||||
assert (size <= UINT_MAX);
|
||||
assert (size == solver->vars);
|
||||
const size_t size = SIZE_STACK (solver->export_);
|
||||
KISSAT_assert (size <= UINT_MAX);
|
||||
KISSAT_assert (size == solver->vars);
|
||||
for (unsigned iidx = 0; iidx < size; iidx++) {
|
||||
const unsigned elit = PEEK_STACK (solver->export, iidx);
|
||||
const unsigned elit = PEEK_STACK (solver->export_, iidx);
|
||||
if (!elit)
|
||||
continue;
|
||||
const unsigned midx = map_idx (solver, iidx);
|
||||
if (midx == INVALID_IDX)
|
||||
continue;
|
||||
POKE_STACK (solver->export, midx, elit);
|
||||
POKE_STACK (solver->export_, midx, elit);
|
||||
}
|
||||
RESIZE_STACK (solver->export, vars);
|
||||
SHRINK_STACK (solver->export);
|
||||
#ifndef NDEBUG
|
||||
assert (SIZE_STACK (solver->export) == vars);
|
||||
RESIZE_STACK (solver->export_, vars);
|
||||
SHRINK_STACK (solver->export_);
|
||||
#ifndef KISSAT_NDEBUG
|
||||
KISSAT_assert (SIZE_STACK (solver->export_) == vars);
|
||||
for (unsigned iidx = 0; iidx < vars; iidx++) {
|
||||
const int elit = PEEK_STACK (solver->export, iidx);
|
||||
assert (VALID_EXTERNAL_LITERAL (elit));
|
||||
const int elit = PEEK_STACK (solver->export_, iidx);
|
||||
KISSAT_assert (VALID_EXTERNAL_LITERAL (elit));
|
||||
const unsigned eidx = ABS (elit);
|
||||
const import *const import = &PEEK_STACK (solver->import, eidx);
|
||||
assert (import->imported);
|
||||
KISSAT_assert (import->imported);
|
||||
if (import->eliminated)
|
||||
continue;
|
||||
unsigned mlit = import->lit;
|
||||
if (elit < 0)
|
||||
mlit = NOT (mlit);
|
||||
const unsigned ilit = LIT (iidx);
|
||||
assert (mlit == ilit);
|
||||
KISSAT_assert (mlit == ilit);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void compact_units (kissat *solver, unsigned mfixed) {
|
||||
LOG ("compacting units (first fixed %u)", mfixed);
|
||||
assert (kissat_fixed (solver, mfixed) > 0);
|
||||
KISSAT_assert (kissat_fixed (solver, mfixed) > 0);
|
||||
for (all_stack (int, elit, solver->units)) {
|
||||
const unsigned eidx = ABS (elit);
|
||||
const unsigned mlit = elit < 0 ? NOT (mfixed) : mfixed;
|
||||
const import *const import = &PEEK_STACK (solver->import, eidx);
|
||||
assert (import->imported);
|
||||
assert (!import->eliminated);
|
||||
KISSAT_assert (import->imported);
|
||||
KISSAT_assert (!import->eliminated);
|
||||
const unsigned ilit = import->lit;
|
||||
if (mlit != ilit)
|
||||
reimport_literal (solver, eidx, mlit);
|
||||
|
|
@ -320,9 +322,9 @@ static void compact_best_and_target_values (kissat *solver, unsigned vars) {
|
|||
void kissat_finalize_compacting (kissat *solver, unsigned vars,
|
||||
unsigned mfixed) {
|
||||
LOG ("finalizing compacting");
|
||||
assert (vars <= solver->vars);
|
||||
KISSAT_assert (vars <= solver->vars);
|
||||
#ifdef LOGGING
|
||||
assert (solver->compacting);
|
||||
KISSAT_assert (solver->compacting);
|
||||
#endif
|
||||
if (vars == solver->vars) {
|
||||
#ifdef LOGGING
|
||||
|
|
@ -341,7 +343,7 @@ void kissat_finalize_compacting (kissat *solver, unsigned vars,
|
|||
if (flags->fixed && first)
|
||||
first = false;
|
||||
else if (!flags->active)
|
||||
POKE_STACK (solver->export, iidx, 0);
|
||||
POKE_STACK (solver->export_, iidx, 0);
|
||||
}
|
||||
|
||||
compact_trail (solver);
|
||||
|
|
@ -374,3 +376,5 @@ void kissat_finalize_compacting (kissat *solver, unsigned vars,
|
|||
#endif
|
||||
kissat_decrease_size (solver);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
#ifndef _compact_h_INCLUDED
|
||||
#define _compact_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
unsigned kissat_compact_literals (struct kissat *, unsigned *mfixed_ptr);
|
||||
void kissat_finalize_compacting (struct kissat *, unsigned vars,
|
||||
unsigned mfixed);
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef NOPTIONS
|
||||
#include "global.h"
|
||||
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
|
||||
#include "config.h"
|
||||
#include "kissat.h"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
#ifndef NOPTIONS
|
||||
#ifndef _config_h_INCLUDED
|
||||
#define _config_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
|
||||
void kissat_configuration_usage (void);
|
||||
|
||||
#endif
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
bool kissat_congruence (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define COVER(COND) \
|
||||
((COND) ? \
|
||||
\
|
||||
|
|
@ -25,4 +28,6 @@
|
|||
} while (0)
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,15 +6,17 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static unsigned last_enqueued_unassigned_variable (kissat *solver) {
|
||||
assert (solver->unassigned);
|
||||
KISSAT_assert (solver->unassigned);
|
||||
const links *const links = solver->links;
|
||||
const value *const values = solver->values;
|
||||
unsigned res = solver->queue.search.idx;
|
||||
if (values[LIT (res)]) {
|
||||
do {
|
||||
res = links[res].prev;
|
||||
assert (!DISCONNECTED (res));
|
||||
KISSAT_assert (!DISCONNECTED (res));
|
||||
} while (values[LIT (res)]);
|
||||
kissat_update_queue (solver, links, res);
|
||||
}
|
||||
|
|
@ -24,7 +26,7 @@ static unsigned last_enqueued_unassigned_variable (kissat *solver) {
|
|||
#endif
|
||||
#ifdef CHECK_QUEUE
|
||||
for (unsigned i = links[res].next; !DISCONNECTED (i); i = links[i].next)
|
||||
assert (VALUE (LIT (i)));
|
||||
KISSAT_assert (VALUE (LIT (i)));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
|
@ -48,7 +50,7 @@ static unsigned largest_score_unassigned_variable (kissat *solver) {
|
|||
if (VALUE (LIT (idx)))
|
||||
continue;
|
||||
const double idx_score = kissat_get_heap_score (scores, idx);
|
||||
assert (score >= idx_score);
|
||||
KISSAT_assert (score >= idx_score);
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
|
|
@ -71,7 +73,7 @@ void kissat_start_random_sequence (kissat *solver) {
|
|||
FORMAT_COUNT (CONFLICTS));
|
||||
else {
|
||||
INC (random_sequences);
|
||||
const uint64_t count = solver->statistics.random_sequences;
|
||||
const uint64_t count = solver->statistics_.random_sequences;
|
||||
const unsigned length = GET_OPTION (randeclength) * LOGN (count);
|
||||
kissat_very_verbose (solver,
|
||||
"starting random decision sequence "
|
||||
|
|
@ -100,7 +102,7 @@ static unsigned next_random_decision (kissat *solver) {
|
|||
return INVALID_IDX;
|
||||
|
||||
if (!solver->randec) {
|
||||
assert (solver->level);
|
||||
KISSAT_assert (solver->level);
|
||||
if (solver->level > 1)
|
||||
return INVALID_IDX;
|
||||
|
||||
|
|
@ -176,7 +178,7 @@ int kissat_decide_phase (kissat *solver, unsigned idx) {
|
|||
value res = 0;
|
||||
|
||||
if (!solver->stable) {
|
||||
switch ((solver->statistics.switched >> 1) & 7) {
|
||||
switch ((solver->statistics_.switched >> 1) & 7) {
|
||||
case 1:
|
||||
res = INITIAL_PHASE;
|
||||
break;
|
||||
|
|
@ -201,14 +203,14 @@ int kissat_decide_phase (kissat *solver, unsigned idx) {
|
|||
LOG ("%s uses initial decision phase %d", LOGVAR (idx), (int) res);
|
||||
INC (initial_decisions);
|
||||
}
|
||||
assert (res);
|
||||
KISSAT_assert (res);
|
||||
|
||||
return res < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
void kissat_decide (kissat *solver) {
|
||||
START (decide);
|
||||
assert (solver->unassigned);
|
||||
KISSAT_assert (solver->unassigned);
|
||||
if (solver->warming)
|
||||
INC (warming_decisions);
|
||||
else {
|
||||
|
|
@ -219,26 +221,28 @@ void kissat_decide (kissat *solver) {
|
|||
INC (focused_decisions);
|
||||
}
|
||||
solver->level++;
|
||||
assert (solver->level != INVALID_LEVEL);
|
||||
KISSAT_assert (solver->level != INVALID_LEVEL);
|
||||
const unsigned idx = kissat_next_decision_variable (solver);
|
||||
const value value = kissat_decide_phase (solver, idx);
|
||||
unsigned lit = LIT (idx);
|
||||
if (value < 0)
|
||||
lit = NOT (lit);
|
||||
kissat_push_frame (solver, lit);
|
||||
assert (solver->level < SIZE_STACK (solver->frames));
|
||||
KISSAT_assert (solver->level < SIZE_STACK (solver->frames));
|
||||
LOG ("decide literal %s", LOGLIT (lit));
|
||||
kissat_assign_decision (solver, lit);
|
||||
STOP (decide);
|
||||
}
|
||||
|
||||
void kissat_internal_assume (kissat *solver, unsigned lit) {
|
||||
assert (solver->unassigned);
|
||||
assert (!VALUE (lit));
|
||||
KISSAT_assert (solver->unassigned);
|
||||
KISSAT_assert (!VALUE (lit));
|
||||
solver->level++;
|
||||
assert (solver->level != INVALID_LEVEL);
|
||||
KISSAT_assert (solver->level != INVALID_LEVEL);
|
||||
kissat_push_frame (solver, lit);
|
||||
assert (solver->level < SIZE_STACK (solver->frames));
|
||||
KISSAT_assert (solver->level < SIZE_STACK (solver->frames));
|
||||
LOG ("assuming literal %s", LOGLIT (lit));
|
||||
kissat_assign_decision (solver, lit);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _decide_h_INCLUDED
|
||||
#define _decide_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
void kissat_decide (struct kissat *);
|
||||
|
|
@ -11,4 +14,6 @@ int kissat_decide_phase (struct kissat *, unsigned idx);
|
|||
|
||||
#define INITIAL_PHASE (GET_OPTION (phase) ? 1 : -1)
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
#include "promote.h"
|
||||
#include "strengthen.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static inline void recompute_and_promote (kissat *solver, clause *c) {
|
||||
assert (c->redundant);
|
||||
KISSAT_assert (c->redundant);
|
||||
const unsigned old_glue = c->glue;
|
||||
const unsigned new_glue = kissat_recompute_glue (solver, c, old_glue);
|
||||
if (new_glue < old_glue)
|
||||
|
|
@ -19,7 +21,7 @@ static inline void mark_clause_as_used (kissat *solver, clause *c) {
|
|||
LOGCLS (c, "using");
|
||||
recompute_and_promote (solver, c);
|
||||
unsigned glue = MIN (c->glue, MAX_GLUE_USED);
|
||||
solver->statistics.used[solver->stable].glue[glue]++;
|
||||
solver->statistics_.used[solver->stable].glue[glue]++;
|
||||
if (solver->stable)
|
||||
INC (clauses_used_stable);
|
||||
else
|
||||
|
|
@ -27,7 +29,7 @@ static inline void mark_clause_as_used (kissat *solver, clause *c) {
|
|||
}
|
||||
|
||||
bool kissat_recompute_and_promote (kissat *solver, clause *c) {
|
||||
assert (c->redundant);
|
||||
KISSAT_assert (c->redundant);
|
||||
const unsigned old_glue = c->glue;
|
||||
const unsigned new_glue = kissat_recompute_glue (solver, c, old_glue);
|
||||
if (new_glue >= old_glue)
|
||||
|
|
@ -38,7 +40,7 @@ bool kissat_recompute_and_promote (kissat *solver, clause *c) {
|
|||
|
||||
static inline bool analyze_literal (kissat *solver, assigned *all_assigned,
|
||||
frame *frames, unsigned lit) {
|
||||
assert (VALUE (lit) < 0);
|
||||
KISSAT_assert (VALUE (lit) < 0);
|
||||
const unsigned idx = IDX (lit);
|
||||
assigned *a = all_assigned + idx;
|
||||
const unsigned level = a->level;
|
||||
|
|
@ -49,14 +51,14 @@ static inline bool analyze_literal (kissat *solver, assigned *all_assigned,
|
|||
return false;
|
||||
LOG ("analyzing literal %s", LOGLIT (lit));
|
||||
kissat_push_analyzed (solver, all_assigned, idx);
|
||||
assert (level <= solver->level);
|
||||
#if defined(LOGGING) || !defined(NDEBUG)
|
||||
KISSAT_assert (level <= solver->level);
|
||||
#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
|
||||
PUSH_STACK (solver->resolvent, lit);
|
||||
#endif
|
||||
solver->resolvent_size++;
|
||||
if (level == solver->level)
|
||||
return true;
|
||||
assert (a->analyzed);
|
||||
KISSAT_assert (a->analyzed);
|
||||
PUSH_STACK (solver->clause, lit);
|
||||
LOG ("learned literal %s", LOGLIT (lit));
|
||||
frame *f = frames + level;
|
||||
|
|
@ -69,10 +71,10 @@ static inline bool analyze_literal (kissat *solver, assigned *all_assigned,
|
|||
|
||||
clause *kissat_deduce_first_uip_clause (kissat *solver, clause *conflict) {
|
||||
START (deduce);
|
||||
assert (EMPTY_STACK (solver->analyzed));
|
||||
assert (EMPTY_STACK (solver->levels));
|
||||
assert (EMPTY_STACK (solver->clause));
|
||||
#if defined(LOGGING) || !defined(NDEBUG)
|
||||
KISSAT_assert (EMPTY_STACK (solver->analyzed));
|
||||
KISSAT_assert (EMPTY_STACK (solver->levels));
|
||||
KISSAT_assert (EMPTY_STACK (solver->clause));
|
||||
#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
|
||||
CLEAR_STACK (solver->resolvent);
|
||||
#endif
|
||||
if (conflict->size > 2)
|
||||
|
|
@ -84,16 +86,16 @@ clause *kissat_deduce_first_uip_clause (kissat *solver, clause *conflict) {
|
|||
assigned *all_assigned = solver->assigned;
|
||||
frame *frames = BEGIN_STACK (solver->frames);
|
||||
for (all_literals_in_clause (lit, conflict)) {
|
||||
assert (VALUE (lit) < 0);
|
||||
KISSAT_assert (VALUE (lit) < 0);
|
||||
if (LEVEL (lit))
|
||||
conflict_size++;
|
||||
if (analyze_literal (solver, all_assigned, frames, lit))
|
||||
unresolved_on_current_level++;
|
||||
}
|
||||
assert (unresolved_on_current_level > 1);
|
||||
KISSAT_assert (unresolved_on_current_level > 1);
|
||||
LOG ("starting with %u unresolved literals on current decision level",
|
||||
unresolved_on_current_level);
|
||||
assert (solver->antecedent_size == solver->resolvent_size);
|
||||
KISSAT_assert (solver->antecedent_size == solver->resolvent_size);
|
||||
LOGRES2 ("initial");
|
||||
const bool otfs = GET_OPTION (otfs);
|
||||
unsigned const *t = END_ARRAY (solver->trail);
|
||||
|
|
@ -102,14 +104,14 @@ clause *kissat_deduce_first_uip_clause (kissat *solver, clause *conflict) {
|
|||
assigned *a = 0;
|
||||
for (;;) {
|
||||
do {
|
||||
assert (t > BEGIN_ARRAY (solver->trail));
|
||||
KISSAT_assert (t > BEGIN_ARRAY (solver->trail));
|
||||
uip = *--t;
|
||||
a = ASSIGNED (uip);
|
||||
} while (!a->analyzed || a->level != solver->level);
|
||||
if (unresolved_on_current_level == 1)
|
||||
break;
|
||||
assert (a->reason != DECISION_REASON);
|
||||
assert (a->level == solver->level);
|
||||
KISSAT_assert (a->reason != DECISION_REASON);
|
||||
KISSAT_assert (a->level == solver->level);
|
||||
solver->antecedent_size = 1;
|
||||
resolved++;
|
||||
if (a->binary) {
|
||||
|
|
@ -127,38 +129,38 @@ clause *kissat_deduce_first_uip_clause (kissat *solver, clause *conflict) {
|
|||
unresolved_on_current_level++;
|
||||
mark_clause_as_used (solver, reason);
|
||||
}
|
||||
assert (unresolved_on_current_level > 0);
|
||||
KISSAT_assert (unresolved_on_current_level > 0);
|
||||
unresolved_on_current_level--;
|
||||
LOG ("after resolving %s there are %u literals left "
|
||||
"on current decision level",
|
||||
LOGLIT (uip), unresolved_on_current_level);
|
||||
assert (solver->resolvent_size > 0);
|
||||
KISSAT_assert (solver->resolvent_size > 0);
|
||||
solver->resolvent_size--;
|
||||
#if defined(LOGGING) || !defined(NDEBUG)
|
||||
#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
|
||||
LOG2 ("actual antecedent size %u", solver->antecedent_size);
|
||||
REMOVE_STACK (unsigned, solver->resolvent, NOT (uip));
|
||||
assert (SIZE_STACK (solver->resolvent) == solver->resolvent_size);
|
||||
KISSAT_assert (SIZE_STACK (solver->resolvent) == solver->resolvent_size);
|
||||
LOGRES2 ("new");
|
||||
#endif
|
||||
if (otfs && solver->antecedent_size > 2 &&
|
||||
solver->resolvent_size < solver->antecedent_size) {
|
||||
assert (!a->binary);
|
||||
assert (solver->antecedent_size && solver->resolvent_size + 1);
|
||||
KISSAT_assert (!a->binary);
|
||||
KISSAT_assert (solver->antecedent_size && solver->resolvent_size + 1);
|
||||
clause *reason = kissat_dereference_clause (solver, a->reason);
|
||||
assert (!reason->garbage);
|
||||
KISSAT_assert (!reason->garbage);
|
||||
clause *res = kissat_on_the_fly_strengthen (solver, reason, uip);
|
||||
if (resolved == 1 && solver->resolvent_size < conflict_size) {
|
||||
assert (!conflict->garbage);
|
||||
assert (conflict_size > 2);
|
||||
KISSAT_assert (!conflict->garbage);
|
||||
KISSAT_assert (conflict_size > 2);
|
||||
kissat_on_the_fly_subsume (solver, res, conflict);
|
||||
}
|
||||
STOP (deduce);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
assert (uip != INVALID_LIT);
|
||||
KISSAT_assert (uip != INVALID_LIT);
|
||||
LOG ("first unique implication point %s (1st UIP)", LOGLIT (uip));
|
||||
assert (PEEK_STACK (solver->clause, 0) == INVALID_LIT);
|
||||
KISSAT_assert (PEEK_STACK (solver->clause, 0) == INVALID_LIT);
|
||||
POKE_STACK (solver->clause, 0, NOT (uip));
|
||||
LOGTMP ("deduced not yet minimized 1st UIP");
|
||||
if (!solver->probing)
|
||||
|
|
@ -166,3 +168,5 @@ clause *kissat_deduce_first_uip_clause (kissat *solver, clause *conflict) {
|
|||
STOP (deduce);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct clause;
|
||||
struct kissat;
|
||||
|
||||
|
|
@ -11,4 +14,6 @@ struct clause *kissat_deduce_first_uip_clause (struct kissat *,
|
|||
|
||||
bool kissat_recompute_and_promote (struct kissat *, struct clause *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include "kitten.h"
|
||||
#include "print.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
typedef struct definition_extractor definition_extractor;
|
||||
|
||||
struct definition_extractor {
|
||||
|
|
@ -14,13 +16,13 @@ struct definition_extractor {
|
|||
};
|
||||
|
||||
static void traverse_definition_core (void *state, unsigned id) {
|
||||
definition_extractor *extractor = state;
|
||||
definition_extractor *extractor = (definition_extractor*)state;
|
||||
kissat *solver = extractor->solver;
|
||||
watch watch;
|
||||
watches *watches0 = extractor->watches[0];
|
||||
watches *watches1 = extractor->watches[1];
|
||||
const size_t size_watches0 = SIZE_WATCHES (*watches0);
|
||||
assert (size_watches0 <= UINT_MAX);
|
||||
KISSAT_assert (size_watches0 <= UINT_MAX);
|
||||
unsigned sign;
|
||||
if (id < size_watches0) {
|
||||
watch = BEGIN_WATCHES (*watches0)[id];
|
||||
|
|
@ -28,10 +30,10 @@ static void traverse_definition_core (void *state, unsigned id) {
|
|||
sign = 0;
|
||||
} else {
|
||||
unsigned tmp = id - size_watches0;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
const size_t size_watches1 = SIZE_WATCHES (*watches1);
|
||||
assert (size_watches1 <= UINT_MAX);
|
||||
assert (tmp < size_watches1);
|
||||
KISSAT_assert (size_watches1 <= UINT_MAX);
|
||||
KISSAT_assert (tmp < size_watches1);
|
||||
#endif
|
||||
watch = BEGIN_WATCHES (*watches1)[tmp];
|
||||
LOGWATCH (NOT (extractor->lit), watch, "gate[1]");
|
||||
|
|
@ -40,7 +42,7 @@ static void traverse_definition_core (void *state, unsigned id) {
|
|||
PUSH_STACK (solver->gates[sign], watch);
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS)
|
||||
|
||||
typedef struct lemma_extractor lemma_extractor;
|
||||
|
||||
|
|
@ -59,7 +61,7 @@ static void traverse_one_sided_core_lemma (void *state, bool learned,
|
|||
kissat *solver = extractor->solver;
|
||||
const unsigned unit = extractor->unit;
|
||||
unsigneds *added = &solver->added;
|
||||
assert (extractor->lemmas || EMPTY_STACK (*added));
|
||||
KISSAT_assert (extractor->lemmas || EMPTY_STACK (*added));
|
||||
if (size) {
|
||||
PUSH_STACK (*added, size + 1);
|
||||
const size_t offset = SIZE_STACK (*added);
|
||||
|
|
@ -68,7 +70,7 @@ static void traverse_one_sided_core_lemma (void *state, bool learned,
|
|||
for (const unsigned *p = lits; p != end; p++)
|
||||
PUSH_STACK (*added, *p);
|
||||
unsigned *extended = &PEEK_STACK (*added, offset);
|
||||
assert (offset + size + 1 == SIZE_STACK (*added));
|
||||
KISSAT_assert (offset + size + 1 == SIZE_STACK (*added));
|
||||
CHECK_AND_ADD_LITS (size + 1, extended);
|
||||
ADD_LITS_TO_PROOF (size + 1, extended);
|
||||
} else {
|
||||
|
|
@ -77,7 +79,7 @@ static void traverse_one_sided_core_lemma (void *state, bool learned,
|
|||
unsigned *begin = BEGIN_STACK (*added);
|
||||
for (unsigned *p = begin, size; p != end; p += size) {
|
||||
size = *p++;
|
||||
assert (p + size <= end);
|
||||
KISSAT_assert (p + size <= end);
|
||||
REMOVE_CHECKER_LITS (size, p);
|
||||
DELETE_LITS_FROM_PROOF (size, p);
|
||||
}
|
||||
|
|
@ -93,7 +95,7 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
return false;
|
||||
START (definition);
|
||||
struct kitten *kitten = solver->kitten;
|
||||
assert (kitten);
|
||||
KISSAT_assert (kitten);
|
||||
kitten_clear (kitten);
|
||||
const unsigned not_lit = NOT (lit);
|
||||
definition_extractor extractor;
|
||||
|
|
@ -103,7 +105,7 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
extractor.watches[1] = &WATCHES (not_lit);
|
||||
kitten_track_antecedents (kitten);
|
||||
unsigned exported = 0;
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
size_t occs[2] = {0, 0};
|
||||
#endif
|
||||
for (unsigned sign = 0; sign < 2; sign++) {
|
||||
|
|
@ -119,7 +121,7 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
kitten_clause_with_id_and_exception (kitten, exported, c->size,
|
||||
c->lits, except);
|
||||
}
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
occs[sign]++;
|
||||
#endif
|
||||
exported++;
|
||||
|
|
@ -143,19 +145,19 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
kitten_shuffle_clauses (kitten);
|
||||
kitten_set_ticks_limit (kitten, 10 * limit);
|
||||
int tmp = kitten_solve (kitten);
|
||||
assert (!tmp || tmp == 20);
|
||||
KISSAT_assert (!tmp || tmp == 20);
|
||||
if (!tmp) {
|
||||
LOG ("aborting core extraction");
|
||||
goto ABORT;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
unsigned previous = reduced;
|
||||
#endif
|
||||
reduced = kitten_compute_clausal_core (kitten, &learned);
|
||||
LOG ("%s sub-solver core of size %u original clauses out of %u",
|
||||
FORMAT_ORDINAL (i), reduced, exported);
|
||||
assert (reduced <= previous);
|
||||
#if defined(QUIET) && defined(NDEBUG)
|
||||
KISSAT_assert (reduced <= previous);
|
||||
#if defined(KISSAT_QUIET) && defined(KISSAT_NDEBUG)
|
||||
(void) reduced;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -164,8 +166,8 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
size_t size[2];
|
||||
size[0] = SIZE_STACK (solver->gates[0]);
|
||||
size[1] = SIZE_STACK (solver->gates[1]);
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
assert (reduced == size[0] + size[1]);
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
KISSAT_assert (reduced == size[0] + size[1]);
|
||||
#ifdef METRICS
|
||||
kissat_extremely_verbose (
|
||||
solver,
|
||||
|
|
@ -188,7 +190,7 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
unsigned unit = INVALID_LIT;
|
||||
if (!size[0]) {
|
||||
unit = not_lit;
|
||||
assert (size[1]);
|
||||
KISSAT_assert (size[1]);
|
||||
} else if (!size[1])
|
||||
unit = lit;
|
||||
|
||||
|
|
@ -198,12 +200,12 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
kissat_extremely_verbose (solver, "one sided core "
|
||||
"definition extraction yields "
|
||||
"failed literal");
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS)
|
||||
if (false
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|| GET_OPTION (check) > 1
|
||||
#endif
|
||||
#ifndef NPROOFS
|
||||
#ifndef KISSAT_NPROOFS
|
||||
|| solver->proof
|
||||
#endif
|
||||
) {
|
||||
|
|
@ -228,3 +230,5 @@ bool kissat_find_definition (kissat *solver, unsigned lit) {
|
|||
STOP (definition);
|
||||
return res;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,8 +3,13 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
bool kissat_find_definition (struct kissat *, unsigned lit);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void flush_large_watches (kissat *solver, litpairs *irredundant) {
|
||||
assert (!solver->level);
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (!solver->level);
|
||||
KISSAT_assert (solver->watching);
|
||||
#ifndef LOGGING
|
||||
LOG ("flushing large watches");
|
||||
if (irredundant)
|
||||
|
|
@ -22,9 +24,9 @@ static void flush_large_watches (kissat *solver, litpairs *irredundant) {
|
|||
#endif
|
||||
const value *const values = solver->values;
|
||||
mark *const marks = solver->marks;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
for (all_literals (lit))
|
||||
assert (!marks[lit]);
|
||||
KISSAT_assert (!marks[lit]);
|
||||
#endif
|
||||
size_t flushed = 0, collected = 0;
|
||||
#ifdef LOGGING
|
||||
|
|
@ -37,7 +39,7 @@ static void flush_large_watches (kissat *solver, litpairs *irredundant) {
|
|||
watches *watches = all_watches + lit;
|
||||
watch *begin = BEGIN_WATCHES (*watches), *q = begin;
|
||||
const watch *const end_watches = END_WATCHES (*watches), *p = q;
|
||||
assert (EMPTY_STACK (*marked));
|
||||
KISSAT_assert (EMPTY_STACK (*marked));
|
||||
while (p != end_watches) {
|
||||
const watch watch = *p++;
|
||||
if (watch.type.binary) {
|
||||
|
|
@ -65,7 +67,7 @@ static void flush_large_watches (kissat *solver, litpairs *irredundant) {
|
|||
*q++ = watch;
|
||||
}
|
||||
} else {
|
||||
assert (lit_value > 0 || other_value > 0);
|
||||
KISSAT_assert (lit_value > 0 || other_value > 0);
|
||||
if (lit < other) {
|
||||
kissat_delete_binary (solver, lit, other);
|
||||
collected++;
|
||||
|
|
@ -84,7 +86,7 @@ static void flush_large_watches (kissat *solver, litpairs *irredundant) {
|
|||
marks[other] = 0;
|
||||
CLEAR_ARRAY (*marked);
|
||||
}
|
||||
assert (EMPTY_STACK (*marked));
|
||||
KISSAT_assert (EMPTY_STACK (*marked));
|
||||
LOG ("flushed %zu large watches", flushed);
|
||||
LOG ("removed %zu duplicated binary clauses", deduplicated);
|
||||
LOG ("collected %zu satisfied binary clauses", collected);
|
||||
|
|
@ -97,9 +99,9 @@ static void flush_large_watches (kissat *solver, litpairs *irredundant) {
|
|||
}
|
||||
|
||||
void kissat_enter_dense_mode (kissat *solver, litpairs *irredundant) {
|
||||
assert (!solver->level);
|
||||
assert (solver->watching);
|
||||
assert (kissat_propagated (solver));
|
||||
KISSAT_assert (!solver->level);
|
||||
KISSAT_assert (solver->watching);
|
||||
KISSAT_assert (kissat_propagated (solver));
|
||||
LOG ("entering dense mode with full occurrence lists");
|
||||
if (irredundant)
|
||||
flush_large_watches (solver, irredundant);
|
||||
|
|
@ -111,7 +113,7 @@ void kissat_enter_dense_mode (kissat *solver, litpairs *irredundant) {
|
|||
|
||||
static void resume_watching_irredundant_binaries (kissat *solver,
|
||||
litpairs *binaries) {
|
||||
assert (binaries);
|
||||
KISSAT_assert (binaries);
|
||||
#ifdef LOGGING
|
||||
size_t resumed_watching = 0;
|
||||
#endif
|
||||
|
|
@ -120,8 +122,8 @@ static void resume_watching_irredundant_binaries (kissat *solver,
|
|||
const unsigned first = litpair.lits[0];
|
||||
const unsigned second = litpair.lits[1];
|
||||
|
||||
assert (!ELIMINATED (IDX (first)));
|
||||
assert (!ELIMINATED (IDX (second)));
|
||||
KISSAT_assert (!ELIMINATED (IDX (first)));
|
||||
KISSAT_assert (!ELIMINATED (IDX (second)));
|
||||
|
||||
watches *first_watches = all_watches + first;
|
||||
watch first_watch = kissat_binary_watch (second);
|
||||
|
|
@ -172,7 +174,7 @@ resume_watching_large_clauses_after_elimination (kissat *solver) {
|
|||
continue;
|
||||
}
|
||||
|
||||
assert (c->size > 2);
|
||||
KISSAT_assert (c->size > 2);
|
||||
|
||||
unsigned *lits = c->lits;
|
||||
kissat_sort_literals (solver, values, assigned, c->size, lits);
|
||||
|
|
@ -198,8 +200,8 @@ resume_watching_large_clauses_after_elimination (kissat *solver) {
|
|||
|
||||
void kissat_resume_sparse_mode (kissat *solver, bool flush_eliminated,
|
||||
litpairs *irredundant) {
|
||||
assert (!solver->level);
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->level);
|
||||
KISSAT_assert (!solver->watching);
|
||||
if (solver->inconsistent)
|
||||
return;
|
||||
LOG ("resuming sparse mode watching clauses");
|
||||
|
|
@ -224,12 +226,14 @@ void kissat_resume_sparse_mode (kissat *solver, bool flush_eliminated,
|
|||
else
|
||||
conflict = kissat_search_propagate (solver);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
if (conflict)
|
||||
assert (solver->inconsistent);
|
||||
KISSAT_assert (solver->inconsistent);
|
||||
else
|
||||
assert (kissat_trail_flushed (solver));
|
||||
KISSAT_assert (kissat_trail_flushed (solver));
|
||||
#else
|
||||
(void) conflict;
|
||||
#endif
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@
|
|||
|
||||
#include "watch.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
void kissat_enter_dense_mode (struct kissat *,
|
||||
litpairs *saved_irredundant_binary_clauses);
|
||||
|
||||
void kissat_resume_sparse_mode (struct kissat *, bool flush_eliminated,
|
||||
litpairs *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#ifndef NDEBUG
|
||||
#include "global.h"
|
||||
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|
||||
#include "inline.h"
|
||||
|
||||
|
|
@ -64,14 +66,14 @@ static void dump_trail (kissat *solver) {
|
|||
const unsigned lit = PEEK_ARRAY (solver->trail, i);
|
||||
dump_literal (solver, lit);
|
||||
const unsigned lit_level = LEVEL (lit);
|
||||
assert (lit_level <= level);
|
||||
KISSAT_assert (lit_level <= level);
|
||||
if (lit_level < level)
|
||||
printf (" out-of-order");
|
||||
assigned *a = ASSIGNED (lit);
|
||||
if (!lit_level) {
|
||||
printf (" UNIT\n");
|
||||
assert (!a->binary);
|
||||
assert (a->reason == UNIT_REASON);
|
||||
KISSAT_assert (!a->binary);
|
||||
KISSAT_assert (a->reason == UNIT_REASON);
|
||||
} else {
|
||||
fputc (' ', stdout);
|
||||
if (a->binary) {
|
||||
|
|
@ -80,7 +82,7 @@ static void dump_trail (kissat *solver) {
|
|||
} else if (a->reason == DECISION_REASON)
|
||||
printf ("DECISION\n");
|
||||
else {
|
||||
assert (a->reason != UNIT_REASON);
|
||||
KISSAT_assert (a->reason != UNIT_REASON);
|
||||
const reference ref = a->reason;
|
||||
dump_ref (solver, ref);
|
||||
}
|
||||
|
|
@ -129,18 +131,18 @@ static void dump_scores (kissat *solver) {
|
|||
}
|
||||
|
||||
static void dump_export (kissat *solver) {
|
||||
const unsigned size = SIZE_STACK (solver->export);
|
||||
const unsigned size = SIZE_STACK (solver->export_);
|
||||
for (unsigned idx = 0; idx < size; idx++)
|
||||
printf ("export[%u] = %u\n", LIT (idx),
|
||||
PEEK_STACK (solver->export, idx));
|
||||
PEEK_STACK (solver->export_, idx));
|
||||
}
|
||||
|
||||
void dump_map (kissat *solver) {
|
||||
const unsigned size = SIZE_STACK (solver->export);
|
||||
const unsigned size = SIZE_STACK (solver->export_);
|
||||
unsigned first = INVALID_LIT;
|
||||
for (unsigned idx = 0; idx < size; idx++) {
|
||||
const unsigned ilit = LIT (idx);
|
||||
const int elit = PEEK_STACK (solver->export, idx);
|
||||
const int elit = PEEK_STACK (solver->export_, idx);
|
||||
printf ("map[%u] -> %d", ilit, elit);
|
||||
if (elit) {
|
||||
const unsigned eidx = ABS (elit);
|
||||
|
|
@ -195,7 +197,7 @@ static void dump_extend (kissat *solver) {
|
|||
const extension *const begin = BEGIN_STACK (solver->extend);
|
||||
const extension *const end = END_STACK (solver->extend);
|
||||
for (const extension *p = begin, *q; p != end; p = q) {
|
||||
assert (p->blocking);
|
||||
KISSAT_assert (p->blocking);
|
||||
printf ("extend[%zu] %d", (size_t) (p - begin), p->lit);
|
||||
if (!p[1].blocking)
|
||||
fputs (" :", stdout);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@
|
|||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
bool kissat_eliminating (kissat *solver) {
|
||||
if (!solver->enabled.eliminate)
|
||||
return false;
|
||||
statistics *statistics = &solver->statistics;
|
||||
statistics *statistics = &solver->statistics_;
|
||||
if (!statistics->clauses_irredundant)
|
||||
return false;
|
||||
const uint64_t conflicts = statistics->conflicts;
|
||||
|
|
@ -51,9 +53,9 @@ static inline double variable_score (kissat *solver, unsigned idx) {
|
|||
double prod = pos * neg;
|
||||
double sum = pos + neg;
|
||||
double occlim2 = occlim * (double) occlim;
|
||||
assert (prod <= occlim2);
|
||||
KISSAT_assert (prod <= occlim2);
|
||||
double score = prod - sum;
|
||||
assert (score <= occlim2);
|
||||
KISSAT_assert (score <= occlim2);
|
||||
double relevancy;
|
||||
if (solver->stable)
|
||||
relevancy = kissat_get_heap_score (&solver->scores, idx);
|
||||
|
|
@ -70,8 +72,8 @@ static inline double variable_score (kissat *solver, unsigned idx) {
|
|||
|
||||
static inline void update_variable_score (kissat *solver, heap *schedule,
|
||||
unsigned idx) {
|
||||
assert (schedule->size);
|
||||
assert (schedule == &solver->schedule);
|
||||
KISSAT_assert (schedule->size);
|
||||
KISSAT_assert (schedule == &solver->schedule);
|
||||
double new_score = variable_score (solver, idx);
|
||||
LOG ("new score %g for variable %s", new_score, LOGVAR (idx));
|
||||
kissat_update_heap (solver, schedule, idx, -new_score);
|
||||
|
|
@ -83,7 +85,7 @@ void kissat_update_variable_score (kissat *solver, unsigned idx) {
|
|||
|
||||
static inline void update_after_adding_stack (kissat *solver,
|
||||
unsigneds *stack) {
|
||||
assert (!solver->probing);
|
||||
KISSAT_assert (!solver->probing);
|
||||
heap *schedule = &solver->schedule;
|
||||
if (!schedule->size)
|
||||
return;
|
||||
|
|
@ -96,11 +98,11 @@ static inline void update_after_removing_variable (kissat *solver,
|
|||
heap *schedule = &solver->schedule;
|
||||
if (!schedule->size)
|
||||
return;
|
||||
assert (!solver->probing);
|
||||
KISSAT_assert (!solver->probing);
|
||||
flags *f = solver->flags + idx;
|
||||
if (f->fixed)
|
||||
return;
|
||||
assert (!f->eliminated);
|
||||
KISSAT_assert (!f->eliminated);
|
||||
update_variable_score (solver, schedule, idx);
|
||||
if (!kissat_heap_contains (schedule, idx))
|
||||
kissat_push_heap (solver, schedule, idx);
|
||||
|
|
@ -110,7 +112,7 @@ static inline void update_after_removing_clause (kissat *solver, clause *c,
|
|||
unsigned except) {
|
||||
if (!solver->schedule.size)
|
||||
return;
|
||||
assert (c->garbage);
|
||||
KISSAT_assert (c->garbage);
|
||||
for (all_literals_in_clause (lit, c))
|
||||
if (lit != except)
|
||||
update_after_removing_variable (solver, IDX (lit));
|
||||
|
|
@ -130,7 +132,7 @@ void kissat_eliminate_clause (kissat *solver, clause *c, unsigned lit) {
|
|||
|
||||
static unsigned schedule_variables (kissat *solver) {
|
||||
LOG ("initializing variable schedule");
|
||||
assert (!solver->schedule.size);
|
||||
KISSAT_assert (!solver->schedule.size);
|
||||
|
||||
kissat_resize_heap (solver, &solver->schedule, solver->vars);
|
||||
|
||||
|
|
@ -147,8 +149,8 @@ static unsigned schedule_variables (kissat *solver) {
|
|||
scheduled++;
|
||||
update_after_removing_variable (solver, idx);
|
||||
}
|
||||
assert (scheduled == kissat_size_heap (&solver->schedule));
|
||||
#ifndef QUIET
|
||||
KISSAT_assert (scheduled == kissat_size_heap (&solver->schedule));
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t active = solver->active;
|
||||
kissat_phase (solver, "eliminate", GET (eliminations),
|
||||
"scheduled %zu variables %.0f%%", scheduled,
|
||||
|
|
@ -160,7 +162,7 @@ static unsigned schedule_variables (kissat *solver) {
|
|||
void kissat_flush_units_while_connected (kissat *solver) {
|
||||
const unsigned *propagate = solver->propagate;
|
||||
const unsigned *end_trail = END_ARRAY (solver->trail);
|
||||
assert (propagate <= end_trail);
|
||||
KISSAT_assert (propagate <= end_trail);
|
||||
const size_t units = end_trail - propagate;
|
||||
if (!units)
|
||||
return;
|
||||
|
|
@ -191,11 +193,11 @@ void kissat_flush_units_while_connected (kissat *solver) {
|
|||
clause *c = kissat_dereference_clause (solver, ref);
|
||||
if (!c->garbage)
|
||||
kissat_eliminate_clause (solver, c, unit);
|
||||
assert (c->garbage);
|
||||
KISSAT_assert (c->garbage);
|
||||
q--;
|
||||
}
|
||||
}
|
||||
assert (q <= end);
|
||||
KISSAT_assert (q <= end);
|
||||
size_t flushed = end - q;
|
||||
if (!flushed)
|
||||
continue;
|
||||
|
|
@ -206,7 +208,7 @@ void kissat_flush_units_while_connected (kissat *solver) {
|
|||
|
||||
static void connect_resolvents (kissat *solver) {
|
||||
const value *const values = solver->values;
|
||||
assert (EMPTY_STACK (solver->clause));
|
||||
KISSAT_assert (EMPTY_STACK (solver->clause));
|
||||
bool satisfied = false;
|
||||
#ifdef LOGGING
|
||||
uint64_t added = 0;
|
||||
|
|
@ -219,7 +221,7 @@ static void connect_resolvents (kissat *solver) {
|
|||
LOGTMP ("temporary resolvent");
|
||||
const size_t size = SIZE_STACK (solver->clause);
|
||||
if (!size) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
ADD_EMPTY_TO_PROOF ();
|
||||
|
|
@ -230,7 +232,7 @@ static void connect_resolvents (kissat *solver) {
|
|||
LOG ("resolved unit clause %s", LOGLIT (unit));
|
||||
kissat_learned_unit (solver, unit);
|
||||
} else {
|
||||
assert (size > 1);
|
||||
KISSAT_assert (size > 1);
|
||||
(void) kissat_new_irredundant_clause (solver);
|
||||
update_after_adding_stack (solver, &solver->clause);
|
||||
#ifdef LOGGING
|
||||
|
|
@ -258,7 +260,7 @@ static void weaken_clauses (kissat *solver, unsigned lit) {
|
|||
const unsigned not_lit = NOT (lit);
|
||||
|
||||
const value *const values = solver->values;
|
||||
assert (!values[lit]);
|
||||
KISSAT_assert (!values[lit]);
|
||||
|
||||
watches *pos_watches = &WATCHES (lit);
|
||||
|
||||
|
|
@ -340,7 +342,7 @@ static void set_next_elimination_bound (kissat *solver, bool complete) {
|
|||
const unsigned max_bound = GET_OPTION (eliminatebound);
|
||||
const unsigned current_bound =
|
||||
solver->bounds.eliminate.additional_clauses;
|
||||
assert (current_bound <= max_bound);
|
||||
KISSAT_assert (current_bound <= max_bound);
|
||||
|
||||
if (complete) {
|
||||
if (current_bound == max_bound) {
|
||||
|
|
@ -348,11 +350,11 @@ static void set_next_elimination_bound (kissat *solver, bool complete) {
|
|||
"completed maximum elimination bound %u",
|
||||
current_bound);
|
||||
limits *limits = &solver->limits;
|
||||
statistics *statistics = &solver->statistics;
|
||||
statistics *statistics = &solver->statistics_;
|
||||
limits->eliminate.variables.eliminate =
|
||||
statistics->variables_eliminate;
|
||||
limits->eliminate.variables.subsume = statistics->variables_subsume;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
bool first = !solver->bounds.eliminate.max_bound_completed++;
|
||||
REPORT (!first, first ? '!' : ':');
|
||||
#endif
|
||||
|
|
@ -389,8 +391,8 @@ static bool eliminate_variable (kissat *solver, unsigned idx) {
|
|||
(void) variable_score (solver, idx);
|
||||
#endif
|
||||
|
||||
assert (!solver->inconsistent);
|
||||
assert (can_eliminate_variable (solver, idx));
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
KISSAT_assert (can_eliminate_variable (solver, idx));
|
||||
|
||||
LOG ("marking %s as not removed", LOGVAR (idx));
|
||||
FLAGS (idx)->eliminate = false;
|
||||
|
|
@ -406,7 +408,7 @@ static bool eliminate_variable (kissat *solver, unsigned idx) {
|
|||
if (solver->gate_eliminated) {
|
||||
INC (gates_eliminated);
|
||||
#ifdef METRICS
|
||||
assert (*solver->gate_eliminated < UINT64_MAX);
|
||||
KISSAT_assert (*solver->gate_eliminated < UINT64_MAX);
|
||||
*solver->gate_eliminated += 1;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -417,8 +419,8 @@ static void eliminate_variables (kissat *solver) {
|
|||
kissat_very_verbose (solver,
|
||||
"trying to eliminate variables with bound %u",
|
||||
solver->bounds.eliminate.additional_clauses);
|
||||
assert (!solver->inconsistent);
|
||||
#ifndef QUIET
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
#ifndef KISSAT_QUIET
|
||||
unsigned before = solver->active;
|
||||
unsigned eliminated = 0;
|
||||
uint64_t tried = 0;
|
||||
|
|
@ -452,7 +454,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
complete = true;
|
||||
}
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const unsigned last_round_scheduled =
|
||||
#endif
|
||||
schedule_variables (solver);
|
||||
|
|
@ -474,7 +476,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
unsigned idx = kissat_pop_max_heap (solver, &solver->schedule);
|
||||
if (!can_eliminate_variable (solver, idx))
|
||||
continue;
|
||||
statistics *s = &solver->statistics;
|
||||
statistics *s = &solver->statistics_;
|
||||
if (s->eliminate_resolutions > resolution_limit) {
|
||||
kissat_extremely_verbose (
|
||||
solver,
|
||||
|
|
@ -484,7 +486,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
complete = false;
|
||||
break;
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
tried++;
|
||||
#endif
|
||||
if (eliminate_variable (solver, idx))
|
||||
|
|
@ -496,7 +498,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
|
||||
if (last_round_eliminated) {
|
||||
complete = false;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
eliminated += last_round_eliminated;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -520,7 +522,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
break;
|
||||
if (round == GET_OPTION (eliminaterounds))
|
||||
break;
|
||||
if (solver->statistics.eliminate_resolutions > resolution_limit)
|
||||
if (solver->statistics_.eliminate_resolutions > resolution_limit)
|
||||
break;
|
||||
if (TERMINATED (eliminate_terminated_2))
|
||||
break;
|
||||
|
|
@ -528,7 +530,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
|
||||
const unsigned remain = kissat_size_heap (&solver->schedule);
|
||||
kissat_release_heap (solver, &solver->schedule);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
kissat_very_verbose (solver,
|
||||
"eliminated %u variables %.0f%% of %" PRIu64 " tried"
|
||||
" (%u remain %.0f%%)",
|
||||
|
|
@ -545,13 +547,13 @@ static void eliminate_variables (kissat *solver) {
|
|||
set_next_elimination_bound (solver, complete);
|
||||
if (!complete) {
|
||||
const flags *end = solver->flags + VARS;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
unsigned dropped = 0;
|
||||
#endif
|
||||
for (struct flags *f = solver->flags; f != end; f++)
|
||||
if (f->eliminate) {
|
||||
f->eliminate = false;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
dropped++;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -565,7 +567,7 @@ static void eliminate_variables (kissat *solver) {
|
|||
static void init_map_and_kitten (kissat *solver) {
|
||||
if (!GET_OPTION (definitions))
|
||||
return;
|
||||
assert (!solver->kitten);
|
||||
KISSAT_assert (!solver->kitten);
|
||||
solver->kitten = kitten_embedded (solver);
|
||||
}
|
||||
|
||||
|
|
@ -578,7 +580,7 @@ static void reset_map_and_kitten (kissat *solver) {
|
|||
|
||||
static void eliminate (kissat *solver) {
|
||||
kissat_backtrack_propagate_and_flush_trail (solver);
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
STOP_SEARCH_AND_START_SIMPLIFIER (eliminate);
|
||||
kissat_phase (solver, "eliminate", GET (eliminations),
|
||||
"elimination limit of %" PRIu64 " conflicts hit",
|
||||
|
|
@ -593,11 +595,13 @@ static void eliminate (kissat *solver) {
|
|||
}
|
||||
|
||||
int kissat_eliminate (kissat *solver) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
INC (eliminations);
|
||||
eliminate (solver);
|
||||
kissat_classify (solver);
|
||||
UPDATE_CONFLICT_LIMIT (eliminate, eliminations, NLOG2N, true);
|
||||
solver->last.ticks.eliminate = solver->statistics.search_ticks;
|
||||
solver->last.ticks.eliminate = solver->statistics_.search_ticks;
|
||||
return solver->inconsistent ? 20 : 0;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
struct clause;
|
||||
struct heap;
|
||||
|
|
@ -16,4 +19,6 @@ void kissat_eliminate_binary (struct kissat *, unsigned, unsigned);
|
|||
void kissat_eliminate_clause (struct kissat *, struct clause *, unsigned);
|
||||
void kissat_update_variable_score (struct kissat *, unsigned idx);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "inlinevector.h"
|
||||
#include "logging.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
bool kissat_find_equivalence_gate (kissat *solver, unsigned lit) {
|
||||
if (!GET_OPTION (equivalences))
|
||||
return false;
|
||||
|
|
@ -35,3 +37,5 @@ bool kissat_find_equivalence_gate (kissat *solver, unsigned lit) {
|
|||
INC (equivalences_extracted);
|
||||
return true;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,8 +3,13 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
bool kissat_find_equivalence_gate (struct kissat *, unsigned lit);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void (*kissat_abort_function) (void);
|
||||
|
||||
void kissat_call_function_instead_of_abort (void (*f) (void)) {
|
||||
|
|
@ -60,3 +62,5 @@ void kissat_fatal (const char *fmt, ...) {
|
|||
va_end (ap);
|
||||
kissat_abort ();
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "attribute.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
// clang-format off
|
||||
|
||||
void kissat_error (const char *fmt, ...) ATTRIBUTE_FORMAT (1, 2);
|
||||
|
|
@ -15,4 +18,6 @@ void kissat_abort (void);
|
|||
|
||||
// clang-format on
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "colors.h"
|
||||
#include "inline.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void undo_eliminated_assignment (kissat *solver) {
|
||||
size_t size_etrail = SIZE_STACK (solver->etrail);
|
||||
#ifdef LOGGING
|
||||
|
|
@ -18,32 +20,32 @@ static void undo_eliminated_assignment (kissat *solver) {
|
|||
|
||||
while (!EMPTY_STACK (solver->etrail)) {
|
||||
const unsigned pos = POP_STACK (solver->etrail);
|
||||
assert (pos < SIZE_STACK (solver->eliminated));
|
||||
assert (values[pos]);
|
||||
KISSAT_assert (pos < SIZE_STACK (solver->eliminated));
|
||||
KISSAT_assert (values[pos]);
|
||||
LOG2 ("unassigned eliminated[%u] external variable", pos);
|
||||
values[pos] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void extend_assign (kissat *solver, value *values, int lit) {
|
||||
assert (lit);
|
||||
assert (lit != INT_MIN);
|
||||
KISSAT_assert (lit);
|
||||
KISSAT_assert (lit != INT_MIN);
|
||||
const unsigned idx = ABS (lit);
|
||||
import *import = &PEEK_STACK (solver->import, idx);
|
||||
assert (import->eliminated);
|
||||
assert (import->imported);
|
||||
KISSAT_assert (import->eliminated);
|
||||
KISSAT_assert (import->imported);
|
||||
const unsigned pos = import->lit;
|
||||
assert (pos < SIZE_STACK (solver->eliminated));
|
||||
KISSAT_assert (pos < SIZE_STACK (solver->eliminated));
|
||||
const value value = lit < 0 ? -1 : 1;
|
||||
values[pos] = value;
|
||||
assert (kissat_value (solver, lit) == lit);
|
||||
KISSAT_assert (kissat_value (solver, lit) == lit);
|
||||
LOG ("assigned eliminated[%u] external literal %d", pos, value * idx);
|
||||
PUSH_STACK (solver->etrail, pos);
|
||||
}
|
||||
|
||||
void kissat_extend (kissat *solver) {
|
||||
assert (!EMPTY_STACK (solver->extend));
|
||||
assert (!solver->extended);
|
||||
KISSAT_assert (!EMPTY_STACK (solver->extend));
|
||||
KISSAT_assert (!solver->extended);
|
||||
|
||||
START (extend);
|
||||
solver->extended = true;
|
||||
|
|
@ -79,7 +81,7 @@ void kissat_extend (kissat *solver) {
|
|||
#endif
|
||||
do {
|
||||
size++;
|
||||
assert (begin < p);
|
||||
KISSAT_assert (begin < p);
|
||||
const extension ext = *--p;
|
||||
const int elit = ext.lit;
|
||||
if (ext.blocking)
|
||||
|
|
@ -88,15 +90,15 @@ void kissat_extend (kissat *solver) {
|
|||
if (satisfied)
|
||||
continue;
|
||||
|
||||
assert (elit != INT_MIN);
|
||||
KISSAT_assert (elit != INT_MIN);
|
||||
const unsigned eidx = ABS (elit);
|
||||
assert (eidx < SIZE_STACK (solver->import));
|
||||
KISSAT_assert (eidx < SIZE_STACK (solver->import));
|
||||
const import *const import = imports + eidx;
|
||||
assert (import->imported);
|
||||
KISSAT_assert (import->imported);
|
||||
|
||||
if (import->eliminated) {
|
||||
const unsigned tmp = import->lit;
|
||||
assert (tmp < SIZE_STACK (solver->eliminated));
|
||||
KISSAT_assert (tmp < SIZE_STACK (solver->eliminated));
|
||||
value value = evalues[tmp];
|
||||
|
||||
if (elit < 0)
|
||||
|
|
@ -120,7 +122,7 @@ void kissat_extend (kissat *solver) {
|
|||
} else {
|
||||
const unsigned ilit = import->lit;
|
||||
value value = ivalues[ilit];
|
||||
assert (value);
|
||||
KISSAT_assert (value);
|
||||
|
||||
if (elit < 0)
|
||||
value = -value;
|
||||
|
|
@ -151,10 +153,10 @@ void kissat_extend (kissat *solver) {
|
|||
|
||||
#ifdef LOGGING
|
||||
const unsigned blocking_idx = ABS (blocking);
|
||||
assert (blocking_idx < SIZE_STACK (solver->import));
|
||||
assert (imports[blocking_idx].eliminated);
|
||||
KISSAT_assert (blocking_idx < SIZE_STACK (solver->import));
|
||||
KISSAT_assert (imports[blocking_idx].eliminated);
|
||||
const unsigned blocking_pos = imports[blocking_idx].lit;
|
||||
assert (blocking_pos < SIZE_STACK (solver->eliminated));
|
||||
KISSAT_assert (blocking_pos < SIZE_STACK (solver->eliminated));
|
||||
const value blocking_value = evalues[blocking_pos];
|
||||
LOGEXT2 (size, p,
|
||||
"%s blocking external literal %d "
|
||||
|
|
@ -179,3 +181,5 @@ void kissat_extend (kissat *solver) {
|
|||
|
||||
STOP (extend);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "stack.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct extension extension;
|
||||
|
||||
struct extension {
|
||||
|
|
@ -16,7 +19,7 @@ typedef STACK (extension) extensions;
|
|||
// clang-format on
|
||||
|
||||
static inline extension kissat_extension (bool blocking, int lit) {
|
||||
assert (ABS (lit) < (1 << 30));
|
||||
KISSAT_assert (ABS (lit) < (1 << 30));
|
||||
extension res;
|
||||
res.blocking = blocking;
|
||||
res.lit = lit;
|
||||
|
|
@ -27,4 +30,6 @@ struct kissat;
|
|||
|
||||
void kissat_extend (struct kissat *solver);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
#define FACTOR 1
|
||||
#define QUOTIENT 2
|
||||
#define NOUNTED 4
|
||||
|
|
@ -73,19 +75,19 @@ static void init_factoring (kissat *solver, factoring *factoring,
|
|||
factoring->hops = GET_OPTION (factorhops);
|
||||
const unsigned hops = factoring->hops;
|
||||
if (hops) {
|
||||
CALLOC (factoring->scores, hops);
|
||||
CALLOC (scores, factoring->scores, hops);
|
||||
for (unsigned i = 0; i != hops; i++) {
|
||||
scores *scores = factoring->scores + i;
|
||||
NALLOC (scores->score, VARS);
|
||||
NALLOC (double, scores->score, VARS);
|
||||
double *score = scores->score;
|
||||
for (all_variables (idx))
|
||||
score[idx] = -1;
|
||||
}
|
||||
}
|
||||
CALLOC (factoring->count, factoring->allocated);
|
||||
#ifndef NDEBUG
|
||||
CALLOC (unsigned, factoring->count, factoring->allocated);
|
||||
#ifndef KISSAT_NDEBUG
|
||||
for (all_literals (lit))
|
||||
assert (!solver->marks[lit]);
|
||||
KISSAT_assert (!solver->marks[lit]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +97,7 @@ static void release_quotients (factoring *factoring) {
|
|||
for (quotient *q = factoring->quotients.first, *next; q; q = next) {
|
||||
next = q->next;
|
||||
unsigned factor = q->factor;
|
||||
assert (marks[factor] == FACTOR);
|
||||
KISSAT_assert (marks[factor] == FACTOR);
|
||||
marks[factor] = 0;
|
||||
RELEASE_STACK (q->clauses);
|
||||
RELEASE_STACK (q->matches);
|
||||
|
|
@ -118,10 +120,10 @@ static void release_quotients (factoring *factoring) {
|
|||
|
||||
static void release_factoring (factoring *factoring) {
|
||||
kissat *const solver = factoring->solver;
|
||||
assert (EMPTY_STACK (solver->analyzed));
|
||||
assert (EMPTY_STACK (factoring->counted));
|
||||
assert (EMPTY_STACK (factoring->nounted));
|
||||
assert (EMPTY_STACK (factoring->qlauses));
|
||||
KISSAT_assert (EMPTY_STACK (solver->analyzed));
|
||||
KISSAT_assert (EMPTY_STACK (factoring->counted));
|
||||
KISSAT_assert (EMPTY_STACK (factoring->nounted));
|
||||
KISSAT_assert (EMPTY_STACK (factoring->qlauses));
|
||||
DEALLOC (factoring->count, factoring->allocated);
|
||||
RELEASE_STACK (factoring->counted);
|
||||
RELEASE_STACK (factoring->nounted);
|
||||
|
|
@ -129,7 +131,7 @@ static void release_factoring (factoring *factoring) {
|
|||
RELEASE_STACK (factoring->qlauses);
|
||||
release_quotients (factoring);
|
||||
kissat_release_heap (solver, &factoring->schedule);
|
||||
assert (!(factoring->allocated & 1));
|
||||
KISSAT_assert (!(factoring->allocated & 1));
|
||||
const size_t allocated_score = factoring->allocated / 2;
|
||||
const unsigned hops = factoring->hops;
|
||||
if (hops) {
|
||||
|
|
@ -141,9 +143,9 @@ static void release_factoring (factoring *factoring) {
|
|||
}
|
||||
DEALLOC (factoring->scores, hops);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
for (all_literals (lit))
|
||||
assert (!solver->marks[lit]);
|
||||
KISSAT_assert (!solver->marks[lit]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +176,7 @@ static void schedule_factorization (factoring *factoring) {
|
|||
update_candidate (factoring, not_lit);
|
||||
}
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
heap *cands = &factoring->schedule;
|
||||
size_t size_cands = kissat_size_heap (cands);
|
||||
kissat_very_verbose (
|
||||
|
|
@ -186,19 +188,19 @@ static void schedule_factorization (factoring *factoring) {
|
|||
static quotient *new_quotient (factoring *factoring, unsigned factor) {
|
||||
kissat *const solver = factoring->solver;
|
||||
mark *marks = solver->marks;
|
||||
assert (!marks[factor]);
|
||||
KISSAT_assert (!marks[factor]);
|
||||
marks[factor] = FACTOR;
|
||||
quotient *res = kissat_malloc (solver, sizeof *res);
|
||||
quotient *res = (quotient*)kissat_malloc (solver, sizeof *res);
|
||||
memset (res, 0, sizeof *res);
|
||||
res->factor = factor;
|
||||
quotient *last = factoring->quotients.last;
|
||||
if (last) {
|
||||
assert (factoring->quotients.first);
|
||||
assert (!last->next);
|
||||
KISSAT_assert (factoring->quotients.first);
|
||||
KISSAT_assert (!last->next);
|
||||
last->next = res;
|
||||
res->id = last->id + 1;
|
||||
} else {
|
||||
assert (!factoring->quotients.first);
|
||||
KISSAT_assert (!factoring->quotients.first);
|
||||
factoring->quotients.first = res;
|
||||
}
|
||||
factoring->quotients.last = res;
|
||||
|
|
@ -211,24 +213,24 @@ static size_t first_factor (factoring *factoring, unsigned factor) {
|
|||
kissat *const solver = factoring->solver;
|
||||
watches *all_watches = solver->watches;
|
||||
watches *factor_watches = all_watches + factor;
|
||||
assert (!factoring->quotients.first);
|
||||
KISSAT_assert (!factoring->quotients.first);
|
||||
quotient *quotient = new_quotient (factoring, factor);
|
||||
statches *clauses = "ient->clauses;
|
||||
uint64_t ticks = 0;
|
||||
for (all_binary_large_watches (watch, *factor_watches)) {
|
||||
PUSH_STACK (*clauses, watch);
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
if (watch.type.binary)
|
||||
continue;
|
||||
const reference ref = watch.large.ref;
|
||||
clause *const c = kissat_dereference_clause (solver, ref);
|
||||
assert (!c->quotient);
|
||||
KISSAT_assert (!c->quotient);
|
||||
#endif
|
||||
ticks++;
|
||||
}
|
||||
size_t res = SIZE_STACK (*clauses);
|
||||
LOG ("quotient[0] factor %s size %zu", LOGLIT (factor), res);
|
||||
assert (res > 1);
|
||||
KISSAT_assert (res > 1);
|
||||
ADD (factor_ticks, ticks);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -236,7 +238,7 @@ static size_t first_factor (factoring *factoring, unsigned factor) {
|
|||
static void clear_nounted (kissat *solver, unsigneds *nounted) {
|
||||
mark *marks = solver->marks;
|
||||
for (all_stack (unsigned, lit, *nounted)) {
|
||||
assert (marks[lit] & NOUNTED);
|
||||
KISSAT_assert (marks[lit] & NOUNTED);
|
||||
marks[lit] &= ~NOUNTED;
|
||||
}
|
||||
CLEAR_STACK (*nounted);
|
||||
|
|
@ -246,7 +248,7 @@ static void clear_qlauses (kissat *solver, references *qlauses) {
|
|||
ward *const arena = BEGIN_STACK (solver->arena);
|
||||
for (all_stack (reference, ref, *qlauses)) {
|
||||
clause *const c = (clause *) (arena + ref);
|
||||
assert (c->quotient);
|
||||
KISSAT_assert (c->quotient);
|
||||
c->quotient = false;
|
||||
}
|
||||
CLEAR_STACK (*qlauses);
|
||||
|
|
@ -286,7 +288,7 @@ static double distinct_paths (factoring *factoring, unsigned src_lit,
|
|||
}
|
||||
ADD (factor_ticks, ticks);
|
||||
}
|
||||
assert (res >= 0);
|
||||
KISSAT_assert (res >= 0);
|
||||
score[src_idx] = res;
|
||||
unsigneds *scored = &scores->scored;
|
||||
PUSH_STACK (*scored, src_idx);
|
||||
|
|
@ -297,9 +299,9 @@ static double distinct_paths (factoring *factoring, unsigned src_lit,
|
|||
|
||||
static double structural_score (factoring *factoring, unsigned lit) {
|
||||
const quotient *first_quotient = factoring->quotients.first;
|
||||
assert (first_quotient);
|
||||
KISSAT_assert (first_quotient);
|
||||
const unsigned first_factor = first_quotient->factor;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
kissat *const solver = factoring->solver;
|
||||
#endif
|
||||
const unsigned first_factor_idx = IDX (first_factor);
|
||||
|
|
@ -324,15 +326,15 @@ static double tied_next_factor_score (factoring *factoring, unsigned lit) {
|
|||
static unsigned next_factor (factoring *factoring,
|
||||
unsigned *next_count_ptr) {
|
||||
quotient *last_quotient = factoring->quotients.last;
|
||||
assert (last_quotient);
|
||||
KISSAT_assert (last_quotient);
|
||||
statches *last_clauses = &last_quotient->clauses;
|
||||
kissat *const solver = factoring->solver;
|
||||
watches *all_watches = solver->watches;
|
||||
unsigned *count = factoring->count;
|
||||
unsigneds *counted = &factoring->counted;
|
||||
references *qlauses = &factoring->qlauses;
|
||||
assert (EMPTY_STACK (*counted));
|
||||
assert (EMPTY_STACK (*qlauses));
|
||||
KISSAT_assert (EMPTY_STACK (*counted));
|
||||
KISSAT_assert (EMPTY_STACK (*qlauses));
|
||||
ward *const arena = BEGIN_STACK (solver->arena);
|
||||
mark *marks = solver->marks;
|
||||
const unsigned initial = factoring->initial;
|
||||
|
|
@ -362,7 +364,7 @@ static unsigned next_factor (factoring *factoring,
|
|||
} else {
|
||||
const reference c_ref = quotient_watch.large.ref;
|
||||
clause *const c = (clause *) (arena + c_ref);
|
||||
assert (!c->quotient);
|
||||
KISSAT_assert (!c->quotient);
|
||||
unsigned min_lit = INVALID_LIT, factors = 0;
|
||||
size_t min_size = 0;
|
||||
ticks++;
|
||||
|
|
@ -371,7 +373,7 @@ static unsigned next_factor (factoring *factoring,
|
|||
if (factors++)
|
||||
break;
|
||||
} else {
|
||||
assert (!(marks[other] & QUOTIENT));
|
||||
KISSAT_assert (!(marks[other] & QUOTIENT));
|
||||
marks[other] |= QUOTIENT;
|
||||
watches *other_watches = all_watches + other;
|
||||
const size_t other_size = SIZE_WATCHES (*other_watches);
|
||||
|
|
@ -381,13 +383,13 @@ static unsigned next_factor (factoring *factoring,
|
|||
min_size = other_size;
|
||||
}
|
||||
}
|
||||
assert (factors);
|
||||
KISSAT_assert (factors);
|
||||
if (factors == 1) {
|
||||
assert (min_lit != INVALID_LIT);
|
||||
KISSAT_assert (min_lit != INVALID_LIT);
|
||||
watches *min_watches = all_watches + min_lit;
|
||||
unsigned c_size = c->size;
|
||||
unsigneds *nounted = &factoring->nounted;
|
||||
assert (EMPTY_STACK (*nounted));
|
||||
KISSAT_assert (EMPTY_STACK (*nounted));
|
||||
ticks += 1 + kissat_cache_lines (SIZE_WATCHES (*min_watches),
|
||||
sizeof (watch));
|
||||
for (all_binary_large_watches (min_watch, *min_watches)) {
|
||||
|
|
@ -403,25 +405,35 @@ static unsigned next_factor (factoring *factoring,
|
|||
if (d->size != c_size)
|
||||
continue;
|
||||
unsigned next = INVALID_LIT;
|
||||
int continue_with_next_min_watch = 0;
|
||||
for (all_literals_in_clause (other, d)) {
|
||||
const mark mark = marks[other];
|
||||
if (mark & QUOTIENT)
|
||||
continue;
|
||||
if (mark & FACTOR)
|
||||
goto CONTINUE_WITH_NEXT_MIN_WATCH;
|
||||
if (mark & NOUNTED)
|
||||
goto CONTINUE_WITH_NEXT_MIN_WATCH;
|
||||
if (next != INVALID_LIT)
|
||||
goto CONTINUE_WITH_NEXT_MIN_WATCH;
|
||||
if (mark & FACTOR) {
|
||||
continue_with_next_min_watch = 1;
|
||||
break;
|
||||
}
|
||||
if (mark & NOUNTED) {
|
||||
continue_with_next_min_watch = 1;
|
||||
break;
|
||||
}
|
||||
if (next != INVALID_LIT) {
|
||||
continue_with_next_min_watch = 1;
|
||||
break;
|
||||
}
|
||||
next = other;
|
||||
}
|
||||
assert (next != INVALID_LIT);
|
||||
if(continue_with_next_min_watch) {
|
||||
continue;
|
||||
}
|
||||
KISSAT_assert (next != INVALID_LIT);
|
||||
if (next > initial)
|
||||
continue;
|
||||
const unsigned next_idx = IDX (next);
|
||||
if (!ACTIVE (next_idx))
|
||||
continue;
|
||||
assert (!(marks[next] & (FACTOR | NOUNTED)));
|
||||
KISSAT_assert (!(marks[next] & (FACTOR | NOUNTED)));
|
||||
marks[next] |= NOUNTED;
|
||||
PUSH_STACK (*nounted, next);
|
||||
d->quotient = true;
|
||||
|
|
@ -429,7 +441,6 @@ static unsigned next_factor (factoring *factoring,
|
|||
if (!count[next])
|
||||
PUSH_STACK (*counted, next);
|
||||
count[next]++;
|
||||
CONTINUE_WITH_NEXT_MIN_WATCH:;
|
||||
}
|
||||
clear_nounted (solver, nounted);
|
||||
}
|
||||
|
|
@ -438,22 +449,22 @@ static unsigned next_factor (factoring *factoring,
|
|||
}
|
||||
ADD (factor_ticks, ticks);
|
||||
ticks = 0;
|
||||
if (solver->statistics.factor_ticks > factoring->limit)
|
||||
if (solver->statistics_.factor_ticks > factoring->limit)
|
||||
break;
|
||||
}
|
||||
clear_qlauses (solver, qlauses);
|
||||
unsigned next_count = 0, next = INVALID_LIT;
|
||||
if (solver->statistics.factor_ticks <= factoring->limit) {
|
||||
if (solver->statistics_.factor_ticks <= factoring->limit) {
|
||||
unsigned ties = 0;
|
||||
for (all_stack (unsigned, lit, *counted)) {
|
||||
const unsigned lit_count = count[lit];
|
||||
if (lit_count < next_count)
|
||||
continue;
|
||||
if (lit_count == next_count) {
|
||||
assert (lit_count);
|
||||
KISSAT_assert (lit_count);
|
||||
ties++;
|
||||
} else {
|
||||
assert (lit_count > next_count);
|
||||
KISSAT_assert (lit_count > next_count);
|
||||
next_count = lit_count;
|
||||
next = lit;
|
||||
ties = 1;
|
||||
|
|
@ -471,7 +482,7 @@ static unsigned next_factor (factoring *factoring,
|
|||
if (lit_count != next_count)
|
||||
continue;
|
||||
double lit_score = tied_next_factor_score (factoring, lit);
|
||||
assert (lit_score >= 0);
|
||||
KISSAT_assert (lit_score >= 0);
|
||||
LOG ("score %g of next factor candidate %s", lit_score,
|
||||
LOGLIT (lit));
|
||||
if (lit_score <= next_score)
|
||||
|
|
@ -479,11 +490,11 @@ static unsigned next_factor (factoring *factoring,
|
|||
next_score = lit_score;
|
||||
next = lit;
|
||||
}
|
||||
assert (next_score >= 0);
|
||||
assert (next != INVALID_LIT);
|
||||
KISSAT_assert (next_score >= 0);
|
||||
KISSAT_assert (next != INVALID_LIT);
|
||||
LOG ("best score %g of next factor %s", next_score, LOGLIT (next));
|
||||
} else {
|
||||
assert (ties == 1);
|
||||
KISSAT_assert (ties == 1);
|
||||
LOG ("single next factor %s with count %u", LOGLIT (next),
|
||||
next_count);
|
||||
}
|
||||
|
|
@ -491,7 +502,7 @@ static unsigned next_factor (factoring *factoring,
|
|||
for (all_stack (unsigned, lit, *counted))
|
||||
count[lit] = 0;
|
||||
CLEAR_STACK (*counted);
|
||||
assert (next == INVALID_LIT || next_count > 1);
|
||||
KISSAT_assert (next == INVALID_LIT || next_count > 1);
|
||||
*next_count_ptr = next_count;
|
||||
return next;
|
||||
}
|
||||
|
|
@ -506,12 +517,12 @@ static void factorize_next (factoring *factoring, unsigned next,
|
|||
ward *const arena = BEGIN_STACK (solver->arena);
|
||||
mark *marks = solver->marks;
|
||||
|
||||
assert (last_quotient);
|
||||
KISSAT_assert (last_quotient);
|
||||
statches *last_clauses = &last_quotient->clauses;
|
||||
statches *next_clauses = &next_quotient->clauses;
|
||||
sizes *matches = &next_quotient->matches;
|
||||
references *qlauses = &factoring->qlauses;
|
||||
assert (EMPTY_STACK (*qlauses));
|
||||
KISSAT_assert (EMPTY_STACK (*qlauses));
|
||||
|
||||
uint64_t ticks =
|
||||
1 + kissat_cache_lines (SIZE_STACK (*last_clauses), sizeof (watch));
|
||||
|
|
@ -535,7 +546,7 @@ static void factorize_next (factoring *factoring, unsigned next,
|
|||
} else {
|
||||
const reference c_ref = last_watch.large.ref;
|
||||
clause *const c = (clause *) (arena + c_ref);
|
||||
assert (!c->quotient);
|
||||
KISSAT_assert (!c->quotient);
|
||||
unsigned min_lit = INVALID_LIT, factors = 0;
|
||||
size_t min_size = 0;
|
||||
ticks++;
|
||||
|
|
@ -544,7 +555,7 @@ static void factorize_next (factoring *factoring, unsigned next,
|
|||
if (factors++)
|
||||
break;
|
||||
} else {
|
||||
assert (!(marks[other] & QUOTIENT));
|
||||
KISSAT_assert (!(marks[other] & QUOTIENT));
|
||||
marks[other] |= QUOTIENT;
|
||||
watches *other_watches = all_watches + other;
|
||||
const size_t other_size = SIZE_WATCHES (*other_watches);
|
||||
|
|
@ -554,9 +565,9 @@ static void factorize_next (factoring *factoring, unsigned next,
|
|||
min_size = other_size;
|
||||
}
|
||||
}
|
||||
assert (factors);
|
||||
KISSAT_assert (factors);
|
||||
if (factors == 1) {
|
||||
assert (min_lit != INVALID_LIT);
|
||||
KISSAT_assert (min_lit != INVALID_LIT);
|
||||
watches *min_watches = all_watches + min_lit;
|
||||
unsigned c_size = c->size;
|
||||
ticks += 1 + kissat_cache_lines (SIZE_WATCHES (*min_watches),
|
||||
|
|
@ -599,7 +610,7 @@ static void factorize_next (factoring *factoring, unsigned next,
|
|||
clear_qlauses (solver, qlauses);
|
||||
ADD (factor_ticks, ticks);
|
||||
|
||||
assert (expected_next_count <= SIZE_STACK (*next_clauses));
|
||||
KISSAT_assert (expected_next_count <= SIZE_STACK (*next_clauses));
|
||||
(void) expected_next_count;
|
||||
}
|
||||
|
||||
|
|
@ -643,9 +654,9 @@ static quotient *best_quotient (factoring *factoring,
|
|||
|
||||
static void resize_factoring (factoring *factoring, unsigned lit) {
|
||||
kissat *const solver = factoring->solver;
|
||||
assert (lit > NOT (lit));
|
||||
KISSAT_assert (lit > NOT (lit));
|
||||
const size_t old_size = factoring->size;
|
||||
assert (lit > old_size);
|
||||
KISSAT_assert (lit > old_size);
|
||||
const size_t old_allocated = factoring->allocated;
|
||||
size_t new_size = lit + 1;
|
||||
if (new_size > old_allocated) {
|
||||
|
|
@ -653,20 +664,20 @@ static void resize_factoring (factoring *factoring, unsigned lit) {
|
|||
while (new_size > new_allocated)
|
||||
new_allocated *= 2;
|
||||
unsigned *count = factoring->count;
|
||||
count = kissat_nrealloc (solver, count, old_allocated, new_allocated,
|
||||
count = (unsigned*)kissat_nrealloc (solver, count, old_allocated, new_allocated,
|
||||
sizeof *count);
|
||||
const size_t delta_allocated = new_allocated - old_allocated;
|
||||
const size_t delta_bytes = delta_allocated * sizeof *count;
|
||||
memset (count + old_size, 0, delta_bytes);
|
||||
factoring->count = count;
|
||||
assert (!(old_allocated & 1));
|
||||
assert (!(new_allocated & 1));
|
||||
KISSAT_assert (!(old_allocated & 1));
|
||||
KISSAT_assert (!(new_allocated & 1));
|
||||
const size_t old_allocated_score = old_allocated / 2;
|
||||
const size_t new_allocated_score = new_allocated / 2;
|
||||
for (unsigned i = 0; i != factoring->hops; i++) {
|
||||
scores *scores = factoring->scores + i;
|
||||
double *score = scores->score;
|
||||
score = kissat_nrealloc (solver, score, old_allocated_score,
|
||||
score = (double*)kissat_nrealloc (solver, score, old_allocated_score,
|
||||
new_allocated_score, sizeof *score);
|
||||
for (size_t i = old_allocated_score; i != new_allocated_score; i++)
|
||||
score[i] = -1;
|
||||
|
|
@ -682,12 +693,12 @@ static void flush_unmatched_clauses (kissat *solver, quotient *q) {
|
|||
sizes *q_matches = &q->matches, *prev_matches = &prev->matches;
|
||||
statches *q_clauses = &q->clauses, *prev_clauses = &prev->clauses;
|
||||
const size_t n = SIZE_STACK (*q_clauses);
|
||||
assert (n == SIZE_STACK (*q_matches));
|
||||
KISSAT_assert (n == SIZE_STACK (*q_matches));
|
||||
bool prev_is_first = !prev->id;
|
||||
size_t i = 0;
|
||||
while (i != n) {
|
||||
size_t j = PEEK_STACK (*q_matches, i);
|
||||
assert (i <= j);
|
||||
KISSAT_assert (i <= j);
|
||||
if (!prev_is_first) {
|
||||
size_t matches = PEEK_STACK (*prev_matches, j);
|
||||
POKE_STACK (*prev_matches, i, matches);
|
||||
|
|
@ -728,22 +739,22 @@ static void add_factored_quotient (factoring *factoring, quotient *q,
|
|||
const reference c_ref = watch.large.ref;
|
||||
clause *const c = kissat_dereference_clause (solver, c_ref);
|
||||
unsigneds *clause = &solver->clause;
|
||||
assert (EMPTY_STACK (*clause));
|
||||
KISSAT_assert (EMPTY_STACK (*clause));
|
||||
const unsigned factor = q->factor;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
bool found = false;
|
||||
#endif
|
||||
PUSH_STACK (*clause, not_fresh);
|
||||
for (all_literals_in_clause (other, c)) {
|
||||
if (other == factor) {
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
found = true;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
PUSH_STACK (*clause, other);
|
||||
}
|
||||
assert (found);
|
||||
KISSAT_assert (found);
|
||||
ADD (literals_factored, c->size);
|
||||
kissat_new_irredundant_clause (solver);
|
||||
CLEAR_STACK (*clause);
|
||||
|
|
@ -756,10 +767,10 @@ static void eagerly_remove_watch (kissat *solver, watches *watches,
|
|||
watch needle) {
|
||||
watch *p = BEGIN_WATCHES (*watches);
|
||||
watch *end = END_WATCHES (*watches);
|
||||
assert (p != end);
|
||||
KISSAT_assert (p != end);
|
||||
watch *last = end - 1;
|
||||
while (p->raw != needle.raw)
|
||||
p++, assert (p != end);
|
||||
p++, KISSAT_assert (p != end);
|
||||
if (p != last)
|
||||
memmove (p, p + 1, (last - p) * sizeof *p);
|
||||
SET_END_OF_WATCHES (*watches, last);
|
||||
|
|
@ -833,7 +844,7 @@ static bool apply_factoring (factoring *factoring, quotient *q) {
|
|||
delete_unfactored (factoring, p);
|
||||
for (quotient *p = q; p; p = p->prev)
|
||||
update_factored (factoring, p);
|
||||
assert (fresh < not_fresh);
|
||||
KISSAT_assert (fresh < not_fresh);
|
||||
resize_factoring (factoring, not_fresh);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -871,16 +882,16 @@ adjust_scores_and_phases_of_fresh_varaibles (factoring *factoring) {
|
|||
const unsigned idx = IDX (lit);
|
||||
struct links *l = links + idx;
|
||||
if (DISCONNECTED (queue->first)) {
|
||||
assert (DISCONNECTED (queue->last));
|
||||
KISSAT_assert (DISCONNECTED (queue->last));
|
||||
queue->last = idx;
|
||||
} else {
|
||||
struct links *first = links + queue->first;
|
||||
assert (DISCONNECTED (first->prev));
|
||||
KISSAT_assert (DISCONNECTED (first->prev));
|
||||
first->prev = idx;
|
||||
}
|
||||
l->next = queue->first;
|
||||
queue->first = idx;
|
||||
assert (DISCONNECTED (l->prev));
|
||||
KISSAT_assert (DISCONNECTED (l->prev));
|
||||
l->stamp = ++queue->stamp;
|
||||
}
|
||||
while (!DISCONNECTED (rest)) {
|
||||
|
|
@ -898,10 +909,10 @@ static bool run_factorization (kissat *solver, uint64_t limit) {
|
|||
init_factoring (solver, &factoring, limit);
|
||||
schedule_factorization (&factoring);
|
||||
bool done = false;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
unsigned factored = 0;
|
||||
#endif
|
||||
uint64_t *ticks = &solver->statistics.factor_ticks;
|
||||
uint64_t *ticks = &solver->statistics_.factor_ticks;
|
||||
kissat_extremely_verbose (
|
||||
solver, "factorization limit of %" PRIu64 " ticks", limit - *ticks);
|
||||
while (!done && !kissat_empty_heap (&factoring.schedule)) {
|
||||
|
|
@ -928,7 +939,7 @@ static bool run_factorization (kissat *solver, uint64_t limit) {
|
|||
const unsigned next = next_factor (&factoring, &next_count);
|
||||
if (next == INVALID_LIT)
|
||||
break;
|
||||
assert (next_count > 1);
|
||||
KISSAT_assert (next_count > 1);
|
||||
if (next_count < 2)
|
||||
break;
|
||||
factorize_next (&factoring, next, next_count);
|
||||
|
|
@ -937,7 +948,7 @@ static bool run_factorization (kissat *solver, uint64_t limit) {
|
|||
quotient *q = best_quotient (&factoring, &reduction);
|
||||
if (q && reduction > factoring.bound) {
|
||||
if (apply_factoring (&factoring, q)) {
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
factored++;
|
||||
#endif
|
||||
} else
|
||||
|
|
@ -965,12 +976,12 @@ static void connect_clauses_to_factor (kissat *solver) {
|
|||
ward *const arena = BEGIN_STACK (solver->arena);
|
||||
watches *all_watches = solver->watches;
|
||||
unsigned *bincount, *largecount;
|
||||
CALLOC (bincount, LITS);
|
||||
CALLOC (unsigned, bincount, LITS);
|
||||
for (all_literals (lit)) {
|
||||
if (!ACTIVE (IDX (lit)))
|
||||
continue;
|
||||
for (all_binary_large_watches (watch, WATCHES (lit))) {
|
||||
assert (watch.type.binary);
|
||||
KISSAT_assert (watch.type.binary);
|
||||
const unsigned other = watch.type.lit;
|
||||
if (lit > other)
|
||||
continue;
|
||||
|
|
@ -978,7 +989,7 @@ static void connect_clauses_to_factor (kissat *solver) {
|
|||
bincount[other]++;
|
||||
}
|
||||
}
|
||||
CALLOC (largecount, LITS);
|
||||
CALLOC (unsigned, largecount, LITS);
|
||||
size_t initial_candidates = 0;
|
||||
for (all_clauses (c)) {
|
||||
if (c->garbage)
|
||||
|
|
@ -1001,7 +1012,7 @@ static void connect_clauses_to_factor (kissat *solver) {
|
|||
for (unsigned round = 1; round <= rounds; round++) {
|
||||
size_t new_candidates = 0;
|
||||
unsigned *newlargecount;
|
||||
CALLOC (newlargecount, LITS);
|
||||
CALLOC (unsigned, newlargecount, LITS);
|
||||
for (all_clauses (c)) {
|
||||
if (c->garbage)
|
||||
continue;
|
||||
|
|
@ -1035,7 +1046,7 @@ static void connect_clauses_to_factor (kissat *solver) {
|
|||
"round %u",
|
||||
candidates, kissat_percent (candidates, initial_candidates), round);
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t connected = 0;
|
||||
#endif
|
||||
for (all_clauses (c)) {
|
||||
|
|
@ -1047,15 +1058,20 @@ static void connect_clauses_to_factor (kissat *solver) {
|
|||
continue;
|
||||
if (c->size > size_limit)
|
||||
continue;
|
||||
int continue_with_next_clause2 = 0;
|
||||
for (all_literals_in_clause (lit, c))
|
||||
if (bincount[lit] + largecount[lit] < 2)
|
||||
goto CONTINUE_WITH_NEXT_CLAUSE2;
|
||||
if (bincount[lit] + largecount[lit] < 2) {
|
||||
continue_with_next_clause2 = 1;
|
||||
break;
|
||||
}
|
||||
if(continue_with_next_clause2) {
|
||||
continue;
|
||||
}
|
||||
const reference ref = (ward *) c - arena;
|
||||
kissat_inlined_connect_clause (solver, all_watches, c, ref);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
connected++;
|
||||
#endif
|
||||
CONTINUE_WITH_NEXT_CLAUSE2:;
|
||||
}
|
||||
DEALLOC (largecount, LITS);
|
||||
DEALLOC (bincount, LITS);
|
||||
|
|
@ -1065,12 +1081,12 @@ static void connect_clauses_to_factor (kissat *solver) {
|
|||
}
|
||||
|
||||
void kissat_factor (kissat *solver) {
|
||||
assert (!solver->level);
|
||||
KISSAT_assert (!solver->level);
|
||||
if (solver->inconsistent)
|
||||
return;
|
||||
if (!GET_OPTION (factor))
|
||||
return;
|
||||
statistics *s = &solver->statistics;
|
||||
statistics *s = &solver->statistics_;
|
||||
if (solver->limits.factor.marked >= s->literals_factor) {
|
||||
kissat_extremely_verbose (
|
||||
solver,
|
||||
|
|
@ -1095,7 +1111,7 @@ void kissat_factor (kissat *solver) {
|
|||
limit *= 1e6;
|
||||
limit += s->factor_ticks;
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
struct {
|
||||
int64_t variables, binary, clauses, ticks;
|
||||
} before, after, delta;
|
||||
|
|
@ -1108,7 +1124,7 @@ void kissat_factor (kissat *solver) {
|
|||
connect_clauses_to_factor (solver);
|
||||
bool completed = run_factorization (solver, limit);
|
||||
kissat_resume_sparse_mode (solver, false, 0);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
after.variables = s->variables_extension + s->variables_original;
|
||||
after.binary = BINARY_CLAUSES;
|
||||
after.clauses = IRREDUNDANT_CLAUSES;
|
||||
|
|
@ -1134,3 +1150,5 @@ void kissat_factor (kissat *solver) {
|
|||
solver->limits.factor.marked = s->literals_factor;
|
||||
STOP (factor);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
void kissat_factor (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
#include "inline.h"
|
||||
#include "inlineassign.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
static inline void kissat_fast_binary_assign (
|
||||
kissat *solver, const bool probing, const unsigned level, value *values,
|
||||
assigned *assigned, unsigned lit, unsigned other) {
|
||||
|
|
@ -27,15 +30,17 @@ static inline void
|
|||
kissat_fast_assign_reference (kissat *solver, value *values,
|
||||
assigned *assigned, unsigned lit,
|
||||
reference ref, clause *reason) {
|
||||
assert (reason == kissat_dereference_clause (solver, ref));
|
||||
KISSAT_assert (reason == kissat_dereference_clause (solver, ref));
|
||||
const unsigned level =
|
||||
kissat_assignment_level (solver, values, assigned, lit, reason);
|
||||
assert (level <= solver->level);
|
||||
assert (ref != DECISION_REASON);
|
||||
assert (ref != UNIT_REASON);
|
||||
KISSAT_assert (level <= solver->level);
|
||||
KISSAT_assert (ref != DECISION_REASON);
|
||||
KISSAT_assert (ref != UNIT_REASON);
|
||||
kissat_fast_assign (solver, solver->probing, level, values, assigned,
|
||||
false, lit, ref);
|
||||
LOGREF (ref, "assign %s reason", LOGLIT (lit));
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
#include "terminate.h"
|
||||
#include "weaken.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static bool fast_forward_subsumed (kissat *solver, clause *c) {
|
||||
assert (!c->garbage);
|
||||
assert (!c->redundant);
|
||||
KISSAT_assert (!c->garbage);
|
||||
KISSAT_assert (!c->redundant);
|
||||
unsigned max_occurring = INVALID_LIT;
|
||||
size_t max_occurrence = 0;
|
||||
watches *all_watches = solver->watches;
|
||||
|
|
@ -58,7 +60,7 @@ static bool fast_forward_subsumed (kissat *solver, clause *c) {
|
|||
continue;
|
||||
if (d->size > c->size)
|
||||
continue;
|
||||
assert (!d->redundant);
|
||||
KISSAT_assert (!d->redundant);
|
||||
subsumed = true;
|
||||
for (all_literals_in_clause (other2, d)) {
|
||||
if (values[other2] < 0)
|
||||
|
|
@ -147,8 +149,8 @@ static size_t flush_occurrences (kissat *solver, unsigned lit) {
|
|||
|
||||
static void do_fast_resolve_binary_binary (kissat *solver, unsigned pivot,
|
||||
unsigned clit, unsigned dlit) {
|
||||
assert (!FLAGS (IDX (clit))->eliminated);
|
||||
assert (!FLAGS (IDX (dlit))->eliminated);
|
||||
KISSAT_assert (!FLAGS (IDX (clit))->eliminated);
|
||||
KISSAT_assert (!FLAGS (IDX (dlit))->eliminated);
|
||||
if (clit == NOT (dlit)) {
|
||||
LOG ("resolvent tautological");
|
||||
return;
|
||||
|
|
@ -165,7 +167,7 @@ static void do_fast_resolve_binary_binary (kissat *solver, unsigned pivot,
|
|||
return;
|
||||
}
|
||||
if (cval < 0 && dval < 0) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
solver->inconsistent = true;
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
|
|
@ -190,10 +192,10 @@ static void do_fast_resolve_binary_binary (kissat *solver, unsigned pivot,
|
|||
kissat_learned_unit (solver, clit);
|
||||
return;
|
||||
}
|
||||
assert (!cval);
|
||||
assert (!dval);
|
||||
KISSAT_assert (!cval);
|
||||
KISSAT_assert (!dval);
|
||||
unsigneds *clause = &solver->clause;
|
||||
assert (EMPTY_STACK (*clause));
|
||||
KISSAT_assert (EMPTY_STACK (*clause));
|
||||
PUSH_STACK (*clause, clit);
|
||||
PUSH_STACK (*clause, dlit);
|
||||
LOGTMP ("%s resolvent", LOGVAR (pivot));
|
||||
|
|
@ -206,10 +208,10 @@ static void do_fast_resolve_binary_binary (kissat *solver, unsigned pivot,
|
|||
|
||||
static void do_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
||||
unsigned lit, clause *c) {
|
||||
assert (!FLAGS (IDX (lit))->eliminated);
|
||||
KISSAT_assert (!FLAGS (IDX (lit))->eliminated);
|
||||
if (c->garbage)
|
||||
return;
|
||||
assert (!c->redundant);
|
||||
KISSAT_assert (!c->redundant);
|
||||
value *values = solver->values;
|
||||
value lit_val = values[lit];
|
||||
if (lit_val > 0) {
|
||||
|
|
@ -217,7 +219,7 @@ static void do_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
|||
return;
|
||||
}
|
||||
unsigneds *clause = &solver->clause;
|
||||
assert (EMPTY_STACK (*clause));
|
||||
KISSAT_assert (EMPTY_STACK (*clause));
|
||||
if (!lit_val)
|
||||
PUSH_STACK (*clause, lit);
|
||||
bool satisfied = false, tautological = false;
|
||||
|
|
@ -250,7 +252,7 @@ static void do_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
|||
}
|
||||
size_t size = SIZE_STACK (*clause);
|
||||
if (!size) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
solver->inconsistent = true;
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
|
|
@ -276,12 +278,12 @@ static void do_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
return;
|
||||
if (d->garbage)
|
||||
return;
|
||||
assert (!c->redundant);
|
||||
assert (!d->redundant);
|
||||
KISSAT_assert (!c->redundant);
|
||||
KISSAT_assert (!d->redundant);
|
||||
value *values = solver->values;
|
||||
mark *marks = solver->marks;
|
||||
unsigneds *clause = &solver->clause;
|
||||
assert (EMPTY_STACK (*clause));
|
||||
KISSAT_assert (EMPTY_STACK (*clause));
|
||||
bool satisfied = false, tautological = false;
|
||||
for (all_literals_in_clause (other, c)) {
|
||||
const unsigned idx_other = IDX (other);
|
||||
|
|
@ -337,7 +339,7 @@ static void do_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
}
|
||||
size_t size = SIZE_STACK (*clause);
|
||||
if (!size) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
solver->inconsistent = true;
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
|
|
@ -363,7 +365,7 @@ static void do_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
|
||||
static void do_fast_resolve (kissat *solver, unsigned pivot, watch cwatch,
|
||||
watch dwatch) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
LOGWATCH (LIT (pivot), cwatch, "1st fast %s elimination antecedent",
|
||||
LOGVAR (pivot));
|
||||
LOGWATCH (NOT (LIT (pivot)), dwatch, "1st fast %s elimination antecedent",
|
||||
|
|
@ -383,7 +385,7 @@ static void do_fast_resolve (kissat *solver, unsigned pivot, watch cwatch,
|
|||
else if (!cbin && dbin)
|
||||
do_fast_resolve_binary_large (solver, pivot, dlit, c);
|
||||
else {
|
||||
assert (!cbin), assert (!dbin);
|
||||
KISSAT_assert (!cbin), KISSAT_assert (!dbin);
|
||||
do_fast_resolve_large_large (solver, pivot, c, d);
|
||||
}
|
||||
}
|
||||
|
|
@ -449,7 +451,7 @@ static void do_fast_eliminate (kissat *solver, unsigned pivot) {
|
|||
p = begin_lit_watches + i;
|
||||
q = begin_not_lit_watches + j;
|
||||
}
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
INC (eliminated);
|
||||
INC (fast_eliminated);
|
||||
kissat_mark_eliminated_variable (solver, pivot);
|
||||
|
|
@ -459,8 +461,8 @@ static void do_fast_eliminate (kissat *solver, unsigned pivot) {
|
|||
|
||||
static bool can_fast_resolve_binary_binary (kissat *solver, unsigned clit,
|
||||
unsigned dlit) {
|
||||
assert (!FLAGS (IDX (clit))->eliminated);
|
||||
assert (!FLAGS (IDX (dlit))->eliminated);
|
||||
KISSAT_assert (!FLAGS (IDX (clit))->eliminated);
|
||||
KISSAT_assert (!FLAGS (IDX (dlit))->eliminated);
|
||||
if (clit == NOT (dlit))
|
||||
return false;
|
||||
value *values = solver->values;
|
||||
|
|
@ -471,7 +473,7 @@ static bool can_fast_resolve_binary_binary (kissat *solver, unsigned clit,
|
|||
if (dval > 0)
|
||||
return false;
|
||||
if (cval < 0 && dval < 0) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
solver->inconsistent = true;
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
|
|
@ -496,17 +498,17 @@ static bool can_fast_resolve_binary_binary (kissat *solver, unsigned clit,
|
|||
kissat_learned_unit (solver, clit);
|
||||
return false;
|
||||
}
|
||||
assert (!cval);
|
||||
assert (!dval);
|
||||
KISSAT_assert (!cval);
|
||||
KISSAT_assert (!dval);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool can_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
||||
unsigned lit, clause *c) {
|
||||
assert (!FLAGS (IDX (lit))->eliminated);
|
||||
KISSAT_assert (!FLAGS (IDX (lit))->eliminated);
|
||||
if (c->garbage)
|
||||
return false;
|
||||
assert (!c->redundant);
|
||||
KISSAT_assert (!c->redundant);
|
||||
value *values = solver->values;
|
||||
value lit_val = values[lit];
|
||||
if (lit_val > 0)
|
||||
|
|
@ -527,7 +529,7 @@ static bool can_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
|||
}
|
||||
if (found_lit) {
|
||||
unsigneds *clause = &solver->clause;
|
||||
assert (EMPTY_STACK (*clause));
|
||||
KISSAT_assert (EMPTY_STACK (*clause));
|
||||
for (all_literals_in_clause (other, c)) {
|
||||
const unsigned idx = IDX (other);
|
||||
if (idx == pivot)
|
||||
|
|
@ -535,7 +537,7 @@ static bool can_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
|||
value value = values[other];
|
||||
if (value < 0)
|
||||
continue;
|
||||
assert (!value);
|
||||
KISSAT_assert (!value);
|
||||
PUSH_STACK (*clause, other);
|
||||
}
|
||||
LOGTMP ("self-subsuming resolvent");
|
||||
|
|
@ -544,7 +546,7 @@ static bool can_fast_resolve_binary_large (kissat *solver, unsigned pivot,
|
|||
const size_t size = SIZE_STACK (*clause);
|
||||
const reference ref = kissat_reference_clause (solver, c);
|
||||
if (!size) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
solver->inconsistent = true;
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
|
|
@ -571,13 +573,13 @@ static bool can_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
return false;
|
||||
if (d->garbage)
|
||||
return false;
|
||||
assert (!c->redundant);
|
||||
assert (!d->redundant);
|
||||
KISSAT_assert (!c->redundant);
|
||||
KISSAT_assert (!d->redundant);
|
||||
value *values = solver->values;
|
||||
mark *marks = solver->marks;
|
||||
bool satisfied = false;
|
||||
unsigneds *clause = &solver->clause;
|
||||
assert (EMPTY_STACK (*clause));
|
||||
KISSAT_assert (EMPTY_STACK (*clause));
|
||||
for (all_literals_in_clause (other, c)) {
|
||||
const unsigned idx_other = IDX (other);
|
||||
if (idx_other == pivot)
|
||||
|
|
@ -591,7 +593,7 @@ static bool can_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
kissat_mark_clause_as_garbage (solver, c);
|
||||
break;
|
||||
}
|
||||
assert (!marks[other]);
|
||||
KISSAT_assert (!marks[other]);
|
||||
marks[other] = 1;
|
||||
PUSH_STACK (*clause, other);
|
||||
}
|
||||
|
|
@ -628,7 +630,7 @@ static bool can_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
if (!satisfied && !tautological) {
|
||||
const size_t size = SIZE_STACK (*clause);
|
||||
if (!size) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
solver->inconsistent = true;
|
||||
LOG ("resolved empty clause");
|
||||
CHECK_AND_ADD_EMPTY ();
|
||||
|
|
@ -698,7 +700,7 @@ static bool can_fast_resolve_large_large (kissat *solver, unsigned pivot,
|
|||
|
||||
static bool can_fast_resolve (kissat *solver, unsigned pivot, watch cwatch,
|
||||
watch dwatch) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
const unsigned clit = cwatch.binary.lit;
|
||||
const unsigned dlit = dwatch.binary.lit;
|
||||
const reference cref = cwatch.large.ref;
|
||||
|
|
@ -713,7 +715,7 @@ static bool can_fast_resolve (kissat *solver, unsigned pivot, watch cwatch,
|
|||
return can_fast_resolve_binary_large (solver, pivot, clit, d);
|
||||
if (!cbin && dbin)
|
||||
return can_fast_resolve_binary_large (solver, pivot, dlit, c);
|
||||
assert (!cbin), assert (!dbin);
|
||||
KISSAT_assert (!cbin), KISSAT_assert (!dbin);
|
||||
return can_fast_resolve_large_large (solver, pivot, c, d);
|
||||
}
|
||||
|
||||
|
|
@ -752,7 +754,7 @@ static bool resolvents_limited (kissat *solver, unsigned pivot,
|
|||
}
|
||||
|
||||
static bool try_to_fast_eliminate (kissat *solver, unsigned pivot) {
|
||||
assert (!solver->inconsistent);
|
||||
KISSAT_assert (!solver->inconsistent);
|
||||
if (!ACTIVE (pivot))
|
||||
return false;
|
||||
const unsigned lit = LIT (pivot);
|
||||
|
|
@ -824,16 +826,16 @@ void kissat_fast_variable_elimination (kissat *solver) {
|
|||
return;
|
||||
if (!GET_OPTION (fastel))
|
||||
return;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const unsigned variables_before = solver->active;
|
||||
#endif
|
||||
assert (!solver->level);
|
||||
KISSAT_assert (!solver->level);
|
||||
START (fastel);
|
||||
kissat_enter_dense_mode (solver, 0);
|
||||
kissat_connect_irredundant_large_clauses (solver);
|
||||
const unsigned fastelrounds = GET_OPTION (fastelrounds);
|
||||
const size_t fasteloccs = GET_OPTION (fasteloccs);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
unsigned eliminated = 0;
|
||||
#endif
|
||||
unsigned round = 0;
|
||||
|
|
@ -846,7 +848,7 @@ void kissat_fast_variable_elimination (kissat *solver) {
|
|||
kissat_extremely_verbose (
|
||||
solver, "gathering candidates for fast elimination round %u",
|
||||
round);
|
||||
assert (EMPTY_STACK (candidates));
|
||||
KISSAT_assert (EMPTY_STACK (candidates));
|
||||
flags *all_flags = solver->flags;
|
||||
for (all_variables (pivot)) {
|
||||
flags *pivot_flags = all_flags + pivot;
|
||||
|
|
@ -868,7 +870,7 @@ void kissat_fast_variable_elimination (kissat *solver) {
|
|||
candidate candidate = {pivot, score};
|
||||
PUSH_STACK (candidates, candidate);
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const size_t size_candidates = SIZE_STACK (candidates);
|
||||
const size_t active_variables = solver->active;
|
||||
kissat_extremely_verbose (
|
||||
|
|
@ -903,7 +905,7 @@ void kissat_fast_variable_elimination (kissat *solver) {
|
|||
}
|
||||
}
|
||||
CLEAR_STACK (candidates);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
eliminated += eliminated_this_round;
|
||||
kissat_very_verbose (
|
||||
solver, "fast eliminated %u of %zu candidates %.0f%% in round %u",
|
||||
|
|
@ -918,7 +920,7 @@ void kissat_fast_variable_elimination (kissat *solver) {
|
|||
FLAGS (idx)->eliminate = true;
|
||||
flush_eliminated_binary_clauses (solver);
|
||||
kissat_resume_sparse_mode (solver, true, 0);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
const unsigned original_variables = solver->statistics.variables_original;
|
||||
const unsigned variables_after = solver->active;
|
||||
kissat_verbose (
|
||||
|
|
@ -932,3 +934,5 @@ void kissat_fast_variable_elimination (kissat *solver) {
|
|||
STOP (fastel);
|
||||
REPORT (!eliminated, 'e');
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
#ifndef _fastel_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
void kissat_fast_variable_elimination (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define FIFO(TYPE) \
|
||||
struct { \
|
||||
TYPE *begin; \
|
||||
|
|
@ -29,7 +32,7 @@
|
|||
#define MOVABLE_FIFO(F) (BEGIN_FIFO (F) == LIMIT_FIFO (F))
|
||||
#define CAPACITY_FIFO(F) (ALLOCATED_FIFO (F) - START_FIFO (F))
|
||||
|
||||
#define ENLARGE_FIFO(F) \
|
||||
#define ENLARGE_FIFO(T, F) \
|
||||
do { \
|
||||
size_t OLD_BEGIN_OFFSET = BEGIN_FIFO (F) - START_FIFO (F); \
|
||||
size_t OLD_END_OFFSET = END_FIFO (F) - START_FIFO (F); \
|
||||
|
|
@ -38,12 +41,12 @@
|
|||
size_t OLD_BYTES = OLD_CAPACITY * sizeof *BEGIN_FIFO (F); \
|
||||
size_t NEW_BYTES = NEW_CAPACITY * sizeof *BEGIN_FIFO (F); \
|
||||
START_FIFO (F) = \
|
||||
kissat_realloc (solver, START_FIFO (F), OLD_BYTES, NEW_BYTES); \
|
||||
(T*) kissat_realloc (solver, START_FIFO (F), OLD_BYTES, NEW_BYTES); \
|
||||
ALLOCATED_FIFO (F) = START_FIFO (F) + NEW_CAPACITY; \
|
||||
LIMIT_FIFO (F) = START_FIFO (F) + NEW_CAPACITY / 2; \
|
||||
BEGIN_FIFO (F) = START_FIFO (F) + OLD_BEGIN_OFFSET; \
|
||||
END_FIFO (F) = START_FIFO (F) + OLD_END_OFFSET; \
|
||||
assert (BEGIN_FIFO (F) < LIMIT_FIFO (F)); \
|
||||
KISSAT_assert (BEGIN_FIFO (F) < LIMIT_FIFO (F)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVE_FIFO(F) \
|
||||
|
|
@ -55,22 +58,22 @@
|
|||
END_FIFO (F) = BEGIN_FIFO (F) + SIZE; \
|
||||
} while (0)
|
||||
|
||||
#define ENQUEUE_FIFO(F, E) \
|
||||
#define ENQUEUE_FIFO(T, F, E) \
|
||||
do { \
|
||||
if (FULL_FIFO (F)) \
|
||||
ENLARGE_FIFO (F); \
|
||||
ENLARGE_FIFO (T, F); \
|
||||
*END_FIFO (F)++ = (E); \
|
||||
} while (0)
|
||||
|
||||
#define DEQUEUE_FIFO(F, E) \
|
||||
do { \
|
||||
assert (!EMPTY_FIFO (F)); \
|
||||
KISSAT_assert (!EMPTY_FIFO (F)); \
|
||||
(E) = *BEGIN_FIFO (F)++; \
|
||||
if (MOVABLE_FIFO (F)) \
|
||||
MOVE_FIFO (F); \
|
||||
} while (0)
|
||||
|
||||
#define POP_FIFO(F) (assert (!EMPTY_FIFO (F)), *--END_FIFO (F))
|
||||
#define POP_FIFO(F) (KISSAT_assert (!EMPTY_FIFO (F)), *--END_FIFO (F))
|
||||
|
||||
#define RELEASE_FIFO(F) \
|
||||
do { \
|
||||
|
|
@ -94,4 +97,6 @@ typedef struct unsigned_fifo unsigned_fifo;
|
|||
|
||||
#define all_fifo all_stack
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,7 +7,17 @@
|
|||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define unlink _unlink
|
||||
#define access _access
|
||||
#define R_OK 4
|
||||
#define W_OK 2
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
bool kissat_file_exists (const char *path) {
|
||||
if (!path)
|
||||
|
|
@ -57,7 +67,7 @@ bool kissat_file_writable (const char *path) {
|
|||
res = 5;
|
||||
else {
|
||||
const size_t len = p - path;
|
||||
char *dirname = malloc (len + 1);
|
||||
char *dirname = (char*)malloc (len + 1);
|
||||
if (dirname) {
|
||||
strncpy (dirname, path, len);
|
||||
dirname[len] = 0;
|
||||
|
|
@ -98,7 +108,7 @@ bool kissat_find_executable (const char *name) {
|
|||
if (!environment)
|
||||
return false;
|
||||
const size_t dirs_len = strlen (environment);
|
||||
char *dirs = malloc (dirs_len + 1);
|
||||
char *dirs = (char*)malloc (dirs_len + 1);
|
||||
if (!dirs)
|
||||
return false;
|
||||
strcpy (dirs, environment);
|
||||
|
|
@ -106,16 +116,16 @@ bool kissat_find_executable (const char *name) {
|
|||
const char *end = dirs + dirs_len + 1;
|
||||
for (char *dir = dirs, *q; !res && dir != end; dir = q) {
|
||||
for (q = dir; *q && *q != ':'; q++)
|
||||
assert (q + 1 < end);
|
||||
KISSAT_assert (q + 1 < end);
|
||||
*q++ = 0;
|
||||
const size_t path_len = (q - dir) + name_len;
|
||||
char *path = malloc (path_len + 1);
|
||||
char *path = (char*)malloc (path_len + 1);
|
||||
if (!path) {
|
||||
free (dirs);
|
||||
return false;
|
||||
}
|
||||
sprintf (path, "%s/%s", dir, name);
|
||||
assert (strlen (path) == path_len);
|
||||
KISSAT_assert (strlen (path) == path_len);
|
||||
res = kissat_file_readable (path);
|
||||
free (path);
|
||||
}
|
||||
|
|
@ -131,7 +141,7 @@ static int xzsig[] = {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00, 0x00, EOF};
|
|||
static int Zsig[] = {0x1F, 0x9D, 0x90, EOF};
|
||||
|
||||
static bool match_signature (const char *path, const int *sig) {
|
||||
assert (path);
|
||||
KISSAT_assert (path);
|
||||
FILE *tmp = fopen (path, "r");
|
||||
if (!tmp)
|
||||
return false;
|
||||
|
|
@ -149,7 +159,7 @@ static FILE *open_pipe (const char *fmt, const char *path,
|
|||
size_t name_len = 0;
|
||||
while (fmt[name_len] && fmt[name_len] != ' ')
|
||||
name_len++;
|
||||
char *name = malloc (name_len + 1);
|
||||
char *name = (char*)malloc (name_len + 1);
|
||||
if (!name)
|
||||
return 0;
|
||||
strncpy (name, fmt, name_len);
|
||||
|
|
@ -158,7 +168,7 @@ static FILE *open_pipe (const char *fmt, const char *path,
|
|||
free (name);
|
||||
if (!found)
|
||||
return 0;
|
||||
char *cmd = malloc (strlen (fmt) + strlen (path));
|
||||
char *cmd = (char*)malloc (strlen (fmt) + strlen (path));
|
||||
if (!cmd)
|
||||
return 0;
|
||||
sprintf (cmd, fmt, path);
|
||||
|
|
@ -296,15 +306,17 @@ bool kissat_open_to_write_file (file *file, const char *path) {
|
|||
}
|
||||
|
||||
void kissat_close_file (file *file) {
|
||||
assert (file);
|
||||
assert (file->file);
|
||||
KISSAT_assert (file);
|
||||
KISSAT_assert (file->file);
|
||||
#ifdef KISSAT_HAS_COMPRESSION
|
||||
if (file->close && file->compressed)
|
||||
pclose (file->file);
|
||||
#else
|
||||
assert (!file->compressed);
|
||||
KISSAT_assert (!file->compressed);
|
||||
#endif
|
||||
if (file->close && !file->compressed)
|
||||
fclose (file->file);
|
||||
file->file = 0;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
#include "attribute.h"
|
||||
#include "keatures.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
bool kissat_file_exists (const char *path);
|
||||
bool kissat_file_readable (const char *path);
|
||||
bool kissat_file_writable (const char *path);
|
||||
|
|
@ -57,9 +60,9 @@ static inline void kissat_flush (file *) ATTRIBUTE_ALWAYS_INLINE;
|
|||
// clang-format on
|
||||
|
||||
static inline size_t kissat_read (file *file, void *ptr, size_t bytes) {
|
||||
assert (file);
|
||||
assert (file->file);
|
||||
assert (file->reading);
|
||||
KISSAT_assert (file);
|
||||
KISSAT_assert (file->file);
|
||||
KISSAT_assert (file->reading);
|
||||
#ifdef KISSAT_HAS_UNLOCKEDIO
|
||||
size_t res = fread_unlocked (ptr, 1, bytes, file->file);
|
||||
#else
|
||||
|
|
@ -70,9 +73,9 @@ static inline size_t kissat_read (file *file, void *ptr, size_t bytes) {
|
|||
}
|
||||
|
||||
static inline size_t kissat_write (file *file, void *ptr, size_t bytes) {
|
||||
assert (file);
|
||||
assert (file->file);
|
||||
assert (!file->reading);
|
||||
KISSAT_assert (file);
|
||||
KISSAT_assert (file->file);
|
||||
KISSAT_assert (!file->reading);
|
||||
#ifdef KISSAT_HAS_UNLOCKEDIO
|
||||
size_t res = fwrite_unlocked (ptr, 1, bytes, file->file);
|
||||
#else
|
||||
|
|
@ -83,9 +86,9 @@ static inline size_t kissat_write (file *file, void *ptr, size_t bytes) {
|
|||
}
|
||||
|
||||
static inline int kissat_getc (file *file) {
|
||||
assert (file);
|
||||
assert (file->file);
|
||||
assert (file->reading);
|
||||
KISSAT_assert (file);
|
||||
KISSAT_assert (file->file);
|
||||
KISSAT_assert (file->reading);
|
||||
#ifdef KISSAT_HAS_UNLOCKEDIO
|
||||
int res = getc_unlocked (file->file);
|
||||
#else
|
||||
|
|
@ -97,9 +100,9 @@ static inline int kissat_getc (file *file) {
|
|||
}
|
||||
|
||||
static inline int kissat_putc (file *file, int ch) {
|
||||
assert (file);
|
||||
assert (file->file);
|
||||
assert (!file->reading);
|
||||
KISSAT_assert (file);
|
||||
KISSAT_assert (file->file);
|
||||
KISSAT_assert (!file->reading);
|
||||
#ifdef KISSAT_HAS_UNLOCKEDIO
|
||||
int res = putc_unlocked (ch, file->file);
|
||||
#else
|
||||
|
|
@ -111,9 +114,9 @@ static inline int kissat_putc (file *file, int ch) {
|
|||
}
|
||||
|
||||
static inline void kissat_flush (file *file) {
|
||||
assert (file);
|
||||
assert (file->file);
|
||||
assert (!file->reading);
|
||||
KISSAT_assert (file);
|
||||
KISSAT_assert (file->file);
|
||||
KISSAT_assert (!file->reading);
|
||||
#ifdef KISSAT_HAS_UNLOCKEDIO
|
||||
fflush_unlocked (file->file);
|
||||
#else
|
||||
|
|
@ -121,4 +124,6 @@ static inline void kissat_flush (file *file) {
|
|||
#endif
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "inlineheap.h"
|
||||
#include "inlinequeue.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static inline void activate_literal (kissat *solver, unsigned lit) {
|
||||
const unsigned idx = IDX (lit);
|
||||
flags *f = FLAGS (idx);
|
||||
|
|
@ -10,37 +12,37 @@ static inline void activate_literal (kissat *solver, unsigned lit) {
|
|||
lit = STRIP (lit);
|
||||
LOG ("activating %s", LOGVAR (idx));
|
||||
f->active = true;
|
||||
assert (!f->fixed);
|
||||
assert (!f->eliminated);
|
||||
KISSAT_assert (!f->fixed);
|
||||
KISSAT_assert (!f->eliminated);
|
||||
solver->active++;
|
||||
INC (variables_activated);
|
||||
kissat_enqueue (solver, idx);
|
||||
const double score = 1.0 - 1.0 / solver->statistics.variables_activated;
|
||||
const double score = 1.0 - 1.0 / solver->statistics_.variables_activated;
|
||||
kissat_update_heap (solver, &solver->scores, idx, score);
|
||||
if (solver->stable) {
|
||||
const unsigned lit = LIT (idx);
|
||||
if (!VALUE (lit))
|
||||
kissat_push_heap (solver, &solver->scores, idx);
|
||||
}
|
||||
assert (solver->unassigned < UINT_MAX);
|
||||
KISSAT_assert (solver->unassigned < UINT_MAX);
|
||||
solver->unassigned++;
|
||||
kissat_mark_removed_literal (solver, lit);
|
||||
kissat_mark_added_literal (solver, lit);
|
||||
assert (!VALUE (lit));
|
||||
assert (!VALUE (NOT (lit)));
|
||||
assert (!SAVED (idx));
|
||||
assert (!TARGET (idx));
|
||||
assert (!BEST (idx));
|
||||
KISSAT_assert (!VALUE (lit));
|
||||
KISSAT_assert (!VALUE (NOT (lit)));
|
||||
KISSAT_assert (!SAVED (idx));
|
||||
KISSAT_assert (!TARGET (idx));
|
||||
KISSAT_assert (!BEST (idx));
|
||||
}
|
||||
|
||||
static inline void deactivate_variable (kissat *solver, flags *f,
|
||||
unsigned idx) {
|
||||
assert (solver->flags + idx == f);
|
||||
KISSAT_assert (solver->flags + idx == f);
|
||||
LOG ("deactivating %s", LOGVAR (idx));
|
||||
assert (f->active);
|
||||
assert (f->eliminated || f->fixed);
|
||||
KISSAT_assert (f->active);
|
||||
KISSAT_assert (f->eliminated || f->fixed);
|
||||
f->active = false;
|
||||
assert (solver->active > 0);
|
||||
KISSAT_assert (solver->active > 0);
|
||||
solver->active--;
|
||||
kissat_dequeue (solver, idx);
|
||||
if (kissat_heap_contains (SCORES, idx))
|
||||
|
|
@ -58,47 +60,47 @@ void kissat_activate_literals (kissat *solver, unsigned size,
|
|||
}
|
||||
|
||||
void kissat_mark_fixed_literal (kissat *solver, unsigned lit) {
|
||||
assert (VALUE (lit) > 0);
|
||||
KISSAT_assert (VALUE (lit) > 0);
|
||||
const unsigned idx = IDX (lit);
|
||||
LOG ("marking internal %s as fixed", LOGVAR (idx));
|
||||
flags *f = FLAGS (idx);
|
||||
assert (f->active);
|
||||
assert (!f->eliminated);
|
||||
assert (!f->fixed);
|
||||
KISSAT_assert (f->active);
|
||||
KISSAT_assert (!f->eliminated);
|
||||
KISSAT_assert (!f->fixed);
|
||||
f->fixed = true;
|
||||
deactivate_variable (solver, f, idx);
|
||||
INC (units);
|
||||
int elit = kissat_export_literal (solver, lit);
|
||||
assert (elit);
|
||||
KISSAT_assert (elit);
|
||||
PUSH_STACK (solver->units, elit);
|
||||
LOG ("pushed external unit literal %d (internal %u)", elit, lit);
|
||||
}
|
||||
|
||||
void kissat_mark_eliminated_variable (kissat *solver, unsigned idx) {
|
||||
const unsigned lit = LIT (idx);
|
||||
assert (!VALUE (lit));
|
||||
KISSAT_assert (!VALUE (lit));
|
||||
LOG ("marking internal %s as eliminated", LOGVAR (idx));
|
||||
flags *f = FLAGS (idx);
|
||||
assert (f->active);
|
||||
assert (!f->eliminated);
|
||||
assert (!f->fixed);
|
||||
KISSAT_assert (f->active);
|
||||
KISSAT_assert (!f->eliminated);
|
||||
KISSAT_assert (!f->fixed);
|
||||
f->eliminated = true;
|
||||
deactivate_variable (solver, f, idx);
|
||||
int elit = kissat_export_literal (solver, lit);
|
||||
assert (elit);
|
||||
assert (elit != INT_MIN);
|
||||
KISSAT_assert (elit);
|
||||
KISSAT_assert (elit != INT_MIN);
|
||||
unsigned eidx = ABS (elit);
|
||||
import *import = &PEEK_STACK (solver->import, eidx);
|
||||
assert (!import->eliminated);
|
||||
assert (import->imported);
|
||||
assert (STRIP (import->lit) == STRIP (lit));
|
||||
KISSAT_assert (!import->eliminated);
|
||||
KISSAT_assert (import->imported);
|
||||
KISSAT_assert (STRIP (import->lit) == STRIP (lit));
|
||||
size_t pos = SIZE_STACK (solver->eliminated);
|
||||
assert (pos < (1u << 30));
|
||||
KISSAT_assert (pos < (1u << 30));
|
||||
import->lit = pos;
|
||||
import->eliminated = true;
|
||||
PUSH_STACK (solver->eliminated, (value) 0);
|
||||
LOG ("marked external variable %u as eliminated", eidx);
|
||||
assert (solver->unassigned > 0);
|
||||
KISSAT_assert (solver->unassigned > 0);
|
||||
solver->unassigned--;
|
||||
}
|
||||
|
||||
|
|
@ -113,3 +115,5 @@ void kissat_mark_added_literals (kissat *solver, unsigned size,
|
|||
for (unsigned i = 0; i < size; i++)
|
||||
kissat_mark_added_literal (solver, lits[i]);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct flags flags;
|
||||
|
||||
struct flags {
|
||||
|
|
@ -18,7 +21,7 @@ struct flags {
|
|||
bool transitive : 1;
|
||||
};
|
||||
|
||||
#define FLAGS(IDX) (assert ((IDX) < VARS), (solver->flags + (IDX)))
|
||||
#define FLAGS(IDX) (KISSAT_assert ((IDX) < VARS), (solver->flags + (IDX)))
|
||||
|
||||
#define ACTIVE(IDX) (FLAGS (IDX)->active)
|
||||
#define ELIMINATED(IDX) (FLAGS (IDX)->eliminated)
|
||||
|
|
@ -34,4 +37,6 @@ void kissat_mark_fixed_literal (struct kissat *, unsigned lit);
|
|||
void kissat_mark_added_literals (struct kissat *, unsigned, unsigned *);
|
||||
void kissat_mark_removed_literals (struct kissat *, unsigned, unsigned *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char *kissat_next_format_string (format *format) {
|
||||
assert (format->pos < NUM_FORMAT_STRINGS);
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
char *kissat_next_format_string (kormat *format) {
|
||||
KISSAT_assert (format->pos < NUM_FORMAT_STRINGS);
|
||||
char *res = format->str[format->pos++];
|
||||
if (format->pos == NUM_FORMAT_STRINGS)
|
||||
format->pos = 0;
|
||||
|
|
@ -19,7 +21,7 @@ static void format_count (char *res, uint64_t w) {
|
|||
if (w >= 128 && kissat_is_power_of_two (w)) {
|
||||
unsigned l;
|
||||
for (l = 0; ((uint64_t) 1 << l) != w; l++)
|
||||
assert (l + 1 < 8 * sizeof (word));
|
||||
KISSAT_assert (l + 1 < 8 * sizeof (word));
|
||||
sprintf (res, "2^%u", l);
|
||||
} else if (w >= 1000 && !(w % 1000)) {
|
||||
unsigned l;
|
||||
|
|
@ -30,13 +32,13 @@ static void format_count (char *res, uint64_t w) {
|
|||
sprintf (res, "%" PRIu64, w);
|
||||
}
|
||||
|
||||
const char *kissat_format_count (format *format, uint64_t w) {
|
||||
const char *kissat_format_count (kormat *format, uint64_t w) {
|
||||
char *res = kissat_next_format_string (format);
|
||||
format_count (res, w);
|
||||
return res;
|
||||
}
|
||||
|
||||
const char *kissat_format_value (format *format, bool boolean, int value) {
|
||||
const char *kissat_format_value (kormat *format, bool boolean, int value) {
|
||||
if (boolean && value)
|
||||
return "true";
|
||||
if (boolean && !value)
|
||||
|
|
@ -54,7 +56,7 @@ const char *kissat_format_value (format *format, bool boolean, int value) {
|
|||
return res;
|
||||
}
|
||||
|
||||
const char *kissat_format_bytes (format *format, uint64_t bytes) {
|
||||
const char *kissat_format_bytes (kormat *format, uint64_t bytes) {
|
||||
char *res = kissat_next_format_string (format);
|
||||
if (bytes < (1u << 10))
|
||||
sprintf (res, "%" PRIu64 " bytes", bytes);
|
||||
|
|
@ -70,7 +72,7 @@ const char *kissat_format_bytes (format *format, uint64_t bytes) {
|
|||
return res;
|
||||
}
|
||||
|
||||
const char *kissat_format_time (format *format, double seconds) {
|
||||
const char *kissat_format_time (kormat *format, double seconds) {
|
||||
if (!seconds)
|
||||
return "0s";
|
||||
char *res = kissat_next_format_string (format);
|
||||
|
|
@ -106,10 +108,10 @@ const char *kissat_format_time (format *format, double seconds) {
|
|||
return res;
|
||||
}
|
||||
|
||||
const char *kissat_format_signs (format *format, unsigned size,
|
||||
const char *kissat_format_signs (kormat *format, unsigned size,
|
||||
word signs) {
|
||||
char *res = kissat_next_format_string (format);
|
||||
assert (size + 1 < FORMAT_STRING_SIZE);
|
||||
KISSAT_assert (size + 1 < FORMAT_STRING_SIZE);
|
||||
char *p = res;
|
||||
word bit = 1;
|
||||
for (unsigned i = 0; i < size; i++, bit <<= 1)
|
||||
|
|
@ -118,7 +120,7 @@ const char *kissat_format_signs (format *format, unsigned size,
|
|||
return res;
|
||||
}
|
||||
|
||||
const char *kissat_format_ordinal (format *format, uint64_t ordinal) {
|
||||
const char *kissat_format_ordinal (kormat *format, uint64_t ordinal) {
|
||||
char const *suffix;
|
||||
unsigned mod100 = ordinal % 100;
|
||||
if (10 <= mod100 && mod100 <= 19)
|
||||
|
|
@ -143,3 +145,5 @@ const char *kissat_format_ordinal (format *format, uint64_t ordinal) {
|
|||
sprintf (res, "%" PRIu64 "%s", ordinal, suffix);
|
||||
return res;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -6,24 +6,27 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define NUM_FORMAT_STRINGS 16
|
||||
#define FORMAT_STRING_SIZE 128
|
||||
|
||||
typedef struct format format;
|
||||
typedef struct kormat kormat;
|
||||
|
||||
struct format {
|
||||
struct kormat {
|
||||
unsigned pos;
|
||||
char str[NUM_FORMAT_STRINGS][FORMAT_STRING_SIZE];
|
||||
};
|
||||
|
||||
char *kissat_next_format_string (format *);
|
||||
char *kissat_next_format_string (kormat *);
|
||||
|
||||
char const *kissat_format_bytes (format *, uint64_t bytes);
|
||||
char const *kissat_format_count (format *, uint64_t);
|
||||
char const *kissat_format_ordinal (format *, uint64_t);
|
||||
char const *kissat_format_signs (format *, unsigned size, word);
|
||||
char const *kissat_format_time (format *, double seconds);
|
||||
char const *kissat_format_value (format *, bool boolean, int value);
|
||||
char const *kissat_format_bytes (kormat *, uint64_t bytes);
|
||||
char const *kissat_format_count (kormat *, uint64_t);
|
||||
char const *kissat_format_ordinal (kormat *, uint64_t);
|
||||
char const *kissat_format_signs (kormat *, unsigned size, word);
|
||||
char const *kissat_format_time (kormat *, double seconds);
|
||||
char const *kissat_format_value (kormat *, bool boolean, int value);
|
||||
|
||||
#define FORMAT_BYTES(BYTES) kissat_format_bytes (&solver->format, BYTES)
|
||||
|
||||
|
|
@ -39,4 +42,6 @@ char const *kissat_format_value (format *, bool boolean, int value);
|
|||
#define FORMAT_VALUE(BOOLEAN, VALUE) \
|
||||
kissat_format_value (&solver->format, BOOLEAN, VALUE)
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static size_t remove_duplicated_binaries_with_literal (kissat *solver,
|
||||
unsigned lit) {
|
||||
watches *watches = &WATCHES (lit);
|
||||
|
|
@ -21,7 +23,7 @@ static size_t remove_duplicated_binaries_with_literal (kissat *solver,
|
|||
|
||||
while (p != end) {
|
||||
const watch watch = *q++ = *p++;
|
||||
assert (watch.type.binary);
|
||||
KISSAT_assert (watch.type.binary);
|
||||
const unsigned other = watch.binary.lit;
|
||||
struct flags *f = flags + IDX (other);
|
||||
if (!f->active)
|
||||
|
|
@ -67,10 +69,10 @@ static size_t remove_duplicated_binaries_with_literal (kissat *solver,
|
|||
|
||||
static void remove_all_duplicated_binary_clauses (kissat *solver) {
|
||||
LOG ("removing all duplicated irredundant binary clauses");
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
size_t removed = 0;
|
||||
#endif
|
||||
assert (EMPTY_STACK (solver->delayed));
|
||||
KISSAT_assert (EMPTY_STACK (solver->delayed));
|
||||
|
||||
const flags *const all_flags = solver->flags;
|
||||
|
||||
|
|
@ -82,16 +84,16 @@ static void remove_all_duplicated_binary_clauses (kissat *solver) {
|
|||
continue;
|
||||
const unsigned int lit = LIT (idx);
|
||||
const unsigned int not_lit = NOT (lit);
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
removed +=
|
||||
#endif
|
||||
remove_duplicated_binaries_with_literal (solver, lit);
|
||||
#if !defined(QUIET) || !defined(NDEBUG)
|
||||
#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
|
||||
removed +=
|
||||
#endif
|
||||
remove_duplicated_binaries_with_literal (solver, not_lit);
|
||||
}
|
||||
assert (!(removed & 1));
|
||||
KISSAT_assert (!(removed & 1));
|
||||
|
||||
size_t units = SIZE_STACK (solver->delayed);
|
||||
if (units) {
|
||||
|
|
@ -141,7 +143,7 @@ static void find_forward_subsumption_candidates (kissat *solver,
|
|||
continue;
|
||||
if (c->size > clslim)
|
||||
continue;
|
||||
assert (c->size > 2);
|
||||
KISSAT_assert (c->size > 2);
|
||||
unsigned subsume = 0;
|
||||
for (all_literals_in_clause (lit, c)) {
|
||||
const unsigned idx = IDX (lit);
|
||||
|
|
@ -151,7 +153,7 @@ static void find_forward_subsumption_candidates (kissat *solver,
|
|||
if (values[lit] > 0) {
|
||||
LOGCLS (c, "satisfied by %s", LOGLIT (lit));
|
||||
kissat_mark_clause_as_garbage (solver, c);
|
||||
assert (c->garbage);
|
||||
KISSAT_assert (c->garbage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -166,7 +168,7 @@ static void find_forward_subsumption_candidates (kissat *solver,
|
|||
|
||||
static inline unsigned
|
||||
get_size_of_reference (kissat *solver, ward *const arena, reference ref) {
|
||||
assert (ref < SIZE_STACK (solver->arena));
|
||||
KISSAT_assert (ref < SIZE_STACK (solver->arena));
|
||||
const clause *const c = (clause *) (arena + ref);
|
||||
(void) solver;
|
||||
return c->size;
|
||||
|
|
@ -223,14 +225,14 @@ static inline bool forward_literal (kissat *solver, unsigned lit,
|
|||
const unsigned not_other = NOT (other);
|
||||
if (marks[not_other]) {
|
||||
LOGBINARY (lit, other, "forward %s strengthener", LOGLIT (other));
|
||||
assert (!subsume);
|
||||
KISSAT_assert (!subsume);
|
||||
*remove = not_other;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const reference ref = watch.large.ref;
|
||||
assert (ref < SIZE_STACK (solver->arena));
|
||||
KISSAT_assert (ref < SIZE_STACK (solver->arena));
|
||||
clause *d = (clause *) (arena + ref);
|
||||
steps++;
|
||||
|
||||
|
|
@ -253,34 +255,34 @@ static inline bool forward_literal (kissat *solver, unsigned lit,
|
|||
if (value > 0) {
|
||||
LOGCLS (d, "satisfied by %s", LOGLIT (other));
|
||||
kissat_mark_clause_as_garbage (solver, d);
|
||||
assert (d->garbage);
|
||||
KISSAT_assert (d->garbage);
|
||||
candidate = INVALID_LIT;
|
||||
subsume = false;
|
||||
break;
|
||||
}
|
||||
if (!subsume) {
|
||||
assert (candidate != INVALID_LIT);
|
||||
KISSAT_assert (candidate != INVALID_LIT);
|
||||
candidate = INVALID_LIT;
|
||||
break;
|
||||
}
|
||||
subsume = false;
|
||||
const unsigned not_other = NOT (other);
|
||||
if (!marks[not_other]) {
|
||||
assert (candidate == INVALID_LIT);
|
||||
KISSAT_assert (candidate == INVALID_LIT);
|
||||
break;
|
||||
}
|
||||
candidate = not_other;
|
||||
}
|
||||
|
||||
if (d->garbage) {
|
||||
assert (!subsume);
|
||||
KISSAT_assert (!subsume);
|
||||
q--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (subsume) {
|
||||
LOGCLS (d, "forward subsuming");
|
||||
assert (subsume);
|
||||
KISSAT_assert (subsume);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -316,7 +318,7 @@ static inline bool forward_marked_clause (kissat *solver, clause *c,
|
|||
if (!flags[idx].active)
|
||||
continue;
|
||||
|
||||
assert (!VALUE (lit));
|
||||
KISSAT_assert (!VALUE (lit));
|
||||
|
||||
if (forward_literal (solver, lit, true, remove, limit))
|
||||
return true;
|
||||
|
|
@ -330,7 +332,7 @@ static inline bool forward_marked_clause (kissat *solver, clause *c,
|
|||
static bool forward_subsumed_clause (kissat *solver, clause *c,
|
||||
bool *strengthened,
|
||||
unsigneds *new_binaries) {
|
||||
assert (!c->garbage);
|
||||
KISSAT_assert (!c->garbage);
|
||||
LOGCLS2 (c, "trying to forward subsume");
|
||||
|
||||
value *marks = solver->marks;
|
||||
|
|
@ -344,7 +346,7 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
if (value > 0) {
|
||||
LOGCLS (c, "satisfied by %s", LOGLIT (lit));
|
||||
kissat_mark_clause_as_garbage (solver, c);
|
||||
assert (c->garbage);
|
||||
KISSAT_assert (c->garbage);
|
||||
break;
|
||||
}
|
||||
marks[lit] = 1;
|
||||
|
|
@ -370,7 +372,7 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
}
|
||||
|
||||
if (non_false == 1) {
|
||||
assert (VALID_INTERNAL_LITERAL (unit));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (unit));
|
||||
LOG ("new remaining non-false literal unit clause %s", LOGLIT (unit));
|
||||
kissat_learned_unit (solver, unit);
|
||||
kissat_mark_clause_as_garbage (solver, c);
|
||||
|
|
@ -396,7 +398,7 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
LOGCLS (c, "forward strengthening by removing %s in", LOGLIT (remove));
|
||||
if (non_false == 2) {
|
||||
unit ^= remove;
|
||||
assert (VALID_INTERNAL_LITERAL (unit));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (unit));
|
||||
LOG ("forward strengthened unit clause %s", LOGLIT (unit));
|
||||
kissat_learned_unit (solver, unit);
|
||||
kissat_mark_clause_as_garbage (solver, c);
|
||||
|
|
@ -416,12 +418,12 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
const value value = values[lit];
|
||||
if (value < 0)
|
||||
continue;
|
||||
assert (!value);
|
||||
KISSAT_assert (!value);
|
||||
lits[new_size++] = lit;
|
||||
kissat_mark_added_literal (solver, lit);
|
||||
}
|
||||
assert (new_size == non_false - 1);
|
||||
assert (new_size > 2);
|
||||
KISSAT_assert (new_size == non_false - 1);
|
||||
KISSAT_assert (new_size > 2);
|
||||
if (!c->shrunken) {
|
||||
c->shrunken = true;
|
||||
lits[c->size - 1] = INVALID_LIT;
|
||||
|
|
@ -431,9 +433,9 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
c->subsume = true;
|
||||
LOGCLS (c, "forward strengthened");
|
||||
} else {
|
||||
assert (non_false == 3);
|
||||
KISSAT_assert (non_false == 3);
|
||||
LOGCLS (c, "garbage");
|
||||
assert (!c->garbage);
|
||||
KISSAT_assert (!c->garbage);
|
||||
const size_t bytes = kissat_actual_bytes_of_clause (c);
|
||||
ADD (arena_garbage, bytes);
|
||||
c->garbage = true;
|
||||
|
|
@ -444,25 +446,25 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
const value value = values[lit];
|
||||
if (value < 0)
|
||||
continue;
|
||||
assert (!value);
|
||||
KISSAT_assert (!value);
|
||||
if (first == INVALID_LIT)
|
||||
first = lit;
|
||||
else {
|
||||
assert (second == INVALID_LIT);
|
||||
KISSAT_assert (second == INVALID_LIT);
|
||||
second = lit;
|
||||
}
|
||||
kissat_mark_added_literal (solver, lit);
|
||||
}
|
||||
assert (first != INVALID_LIT);
|
||||
assert (second != INVALID_LIT);
|
||||
KISSAT_assert (first != INVALID_LIT);
|
||||
KISSAT_assert (second != INVALID_LIT);
|
||||
LOGBINARY (first, second, "forward strengthened");
|
||||
kissat_watch_other (solver, first, second);
|
||||
kissat_watch_other (solver, second, first);
|
||||
assert (new_binaries);
|
||||
assert (solver->statistics.clauses_irredundant);
|
||||
solver->statistics.clauses_irredundant--;
|
||||
assert (solver->statistics.clauses_binary < UINT64_MAX);
|
||||
solver->statistics.clauses_binary++;
|
||||
KISSAT_assert (new_binaries);
|
||||
KISSAT_assert (solver->statistics_.clauses_irredundant);
|
||||
solver->statistics_.clauses_irredundant--;
|
||||
KISSAT_assert (solver->statistics_.clauses_binary < UINT64_MAX);
|
||||
solver->statistics_.clauses_binary++;
|
||||
PUSH_STACK (*new_binaries, first);
|
||||
PUSH_STACK (*new_binaries, second);
|
||||
}
|
||||
|
|
@ -473,7 +475,7 @@ static bool forward_subsumed_clause (kissat *solver, clause *c,
|
|||
}
|
||||
|
||||
static void connect_subsuming (kissat *solver, unsigned occlim, clause *c) {
|
||||
assert (!c->garbage);
|
||||
KISSAT_assert (!c->garbage);
|
||||
|
||||
unsigned min_lit = INVALID_LIT;
|
||||
size_t min_occs = MAX_SIZE_T;
|
||||
|
|
@ -513,19 +515,19 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
INIT_STACK (candidates);
|
||||
|
||||
find_forward_subsumption_candidates (solver, &candidates);
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t scheduled = SIZE_STACK (candidates);
|
||||
kissat_phase (
|
||||
solver, "forward", GET (forward_subsumptions),
|
||||
"scheduled %zu irredundant clauses %.0f%%", scheduled,
|
||||
kissat_percent (scheduled, solver->statistics.clauses_irredundant));
|
||||
kissat_percent (scheduled, solver->statistics_.clauses_irredundant));
|
||||
#endif
|
||||
sort_forward_subsumption_candidates (solver, &candidates);
|
||||
|
||||
const reference *const end_of_candidates = END_STACK (candidates);
|
||||
reference *p = BEGIN_STACK (candidates);
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t subsumed = 0;
|
||||
size_t strengthened = 0;
|
||||
size_t checked = 0;
|
||||
|
|
@ -541,25 +543,25 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
ward *arena = BEGIN_STACK (solver->arena);
|
||||
|
||||
while (p != end_of_candidates) {
|
||||
if (solver->statistics.forward_steps > steps_limit)
|
||||
if (solver->statistics_.forward_steps > steps_limit)
|
||||
break;
|
||||
if (TERMINATED (forward_terminated_1))
|
||||
break;
|
||||
reference ref = *p++;
|
||||
clause *c = (clause *) (arena + ref);
|
||||
assert (kissat_clause_in_arena (solver, c));
|
||||
assert (!c->garbage);
|
||||
#ifndef QUIET
|
||||
KISSAT_assert (kissat_clause_in_arena (solver, c));
|
||||
KISSAT_assert (!c->garbage);
|
||||
#ifndef KISSAT_QUIET
|
||||
checked++;
|
||||
#endif
|
||||
bool not_subsumed_but_strengthened = false;
|
||||
if (forward_subsumed_clause (
|
||||
solver, c, ¬_subsumed_but_strengthened, &new_binaries)) {
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
subsumed++;
|
||||
#endif
|
||||
} else if (not_subsumed_but_strengthened) {
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
strengthened++;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -569,7 +571,7 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
connect_subsuming (solver, occlim, c);
|
||||
}
|
||||
}
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
if (subsumed)
|
||||
kissat_phase (solver, "forward", GET (forward_subsumptions),
|
||||
"subsumed %zu clauses %.2f%% of %zu checked %.0f%%",
|
||||
|
|
@ -593,19 +595,19 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
|
||||
ward *arena = BEGIN_STACK (solver->arena);
|
||||
unsigned reactivated = 0;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
size_t remain = 0;
|
||||
#endif
|
||||
for (reference *q = BEGIN_STACK (candidates); q != end_of_candidates;
|
||||
q++) {
|
||||
const reference ref = *q;
|
||||
clause *c = (clause *) (arena + ref);
|
||||
assert (kissat_clause_in_arena (solver, c));
|
||||
KISSAT_assert (kissat_clause_in_arena (solver, c));
|
||||
if (c->garbage)
|
||||
continue;
|
||||
if (q < p && !c->subsume)
|
||||
continue;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
remain++;
|
||||
#endif
|
||||
for (all_literals_in_clause (lit, c)) {
|
||||
|
|
@ -618,7 +620,7 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
"in remaining or strengthened",
|
||||
LOGVAR (idx));
|
||||
f->subsume = true;
|
||||
assert (reactivated < UINT_MAX);
|
||||
KISSAT_assert (reactivated < UINT_MAX);
|
||||
reactivated++;
|
||||
}
|
||||
}
|
||||
|
|
@ -638,7 +640,7 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
"in strengthened binary clause",
|
||||
LOGVAR (idx));
|
||||
f->subsume = true;
|
||||
assert (reactivated < UINT_MAX);
|
||||
KISSAT_assert (reactivated < UINT_MAX);
|
||||
reactivated++;
|
||||
}
|
||||
}
|
||||
|
|
@ -649,7 +651,7 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
"in next forward subsumption",
|
||||
reactivated,
|
||||
kissat_percent (reactivated, solver->active));
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
if (remain)
|
||||
kissat_phase (solver, "forward", GET (forward_subsumptions),
|
||||
"%zu unchecked clauses remain %.0f%%", remain,
|
||||
|
|
@ -668,7 +670,7 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
completed = false;
|
||||
else
|
||||
completed = true;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
kissat_very_verbose (solver, "forward subsumption considered %scomplete",
|
||||
completed ? "" : "in");
|
||||
#endif
|
||||
|
|
@ -678,9 +680,9 @@ static bool forward_subsume_all_clauses (kissat *solver) {
|
|||
bool kissat_forward_subsume_during_elimination (kissat *solver) {
|
||||
START (subsume);
|
||||
START (forward);
|
||||
assert (GET_OPTION (forward));
|
||||
KISSAT_assert (GET_OPTION (forward));
|
||||
INC (forward_subsumptions);
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->watching);
|
||||
remove_all_duplicated_binary_clauses (solver);
|
||||
bool complete = true;
|
||||
if (!solver->inconsistent)
|
||||
|
|
@ -689,3 +691,5 @@ bool kissat_forward_subsume_during_elimination (kissat *solver) {
|
|||
STOP (subsume);
|
||||
return complete;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,8 +3,13 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
bool kissat_forward_subsume_during_elimination (struct kissat *);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct frame frame;
|
||||
typedef struct slice slice;
|
||||
|
||||
|
|
@ -14,7 +17,7 @@ struct frame {
|
|||
unsigned decision;
|
||||
unsigned trail;
|
||||
unsigned used;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
unsigned saved;
|
||||
#endif
|
||||
};
|
||||
|
|
@ -29,4 +32,6 @@ struct kissat;
|
|||
|
||||
#define FRAME(LEVEL) (PEEK_STACK (solver->frames, (LEVEL)))
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include "ifthenelse.h"
|
||||
#include "inline.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
size_t kissat_mark_binaries (kissat *solver, unsigned lit) {
|
||||
value *marks = solver->marks;
|
||||
size_t res = 0;
|
||||
|
|
@ -14,7 +16,7 @@ size_t kissat_mark_binaries (kissat *solver, unsigned lit) {
|
|||
if (!watch.type.binary)
|
||||
continue;
|
||||
const unsigned other = watch.binary.lit;
|
||||
assert (!solver->values[other]);
|
||||
KISSAT_assert (!solver->values[other]);
|
||||
if (marks[other])
|
||||
continue;
|
||||
marks[other] = 1;
|
||||
|
|
@ -60,14 +62,14 @@ bool kissat_find_gates (kissat *solver, unsigned lit) {
|
|||
|
||||
static void get_antecedents (kissat *solver, unsigned lit,
|
||||
unsigned negative) {
|
||||
assert (!solver->watching);
|
||||
assert (!negative || negative == 1);
|
||||
KISSAT_assert (!solver->watching);
|
||||
KISSAT_assert (!negative || negative == 1);
|
||||
|
||||
statches *gates = solver->gates + negative;
|
||||
watches *watches = &WATCHES (lit);
|
||||
|
||||
statches *antecedents = solver->antecedents + negative;
|
||||
assert (EMPTY_STACK (*antecedents));
|
||||
KISSAT_assert (EMPTY_STACK (*antecedents));
|
||||
|
||||
const watch *const begin_gates = BEGIN_STACK (*gates);
|
||||
const watch *const end_gates = END_STACK (*gates);
|
||||
|
|
@ -85,7 +87,7 @@ static void get_antecedents (kissat *solver, unsigned lit,
|
|||
PUSH_STACK (*antecedents, watch);
|
||||
}
|
||||
|
||||
assert (g == end_gates);
|
||||
KISSAT_assert (g == end_gates);
|
||||
#ifdef LOGGING
|
||||
size_t size_gates = SIZE_STACK (*gates);
|
||||
size_t size_antecedents = SIZE_STACK (*antecedents);
|
||||
|
|
@ -102,3 +104,5 @@ void kissat_get_antecedents (kissat *solver, unsigned lit) {
|
|||
get_antecedents (solver, lit, 0);
|
||||
get_antecedents (solver, NOT (lit), 1);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
struct clause;
|
||||
|
||||
|
|
@ -19,4 +22,6 @@ void kissat_unmark_binaries (struct kissat *, unsigned lit);
|
|||
#define GATE_ELIMINATED(NAME) (&solver->statistics.NAME##_eliminated)
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef ABC_SAT_KISSAT_GLOBAL_H_
|
||||
#define ABC_SAT_KISSAT_GLOBAL_H_
|
||||
|
||||
#define KISSAT_COMPACT
|
||||
#define KISSAT_NDEBUG
|
||||
#define KISSAT_NOPTIONS
|
||||
#define KISSAT_NPROOFS
|
||||
#define KISSAT_QUIET
|
||||
|
||||
#define KISSAT_assert(ignore) ((void)0)
|
||||
|
||||
#include "misc/util/abc_global.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <signal.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
void kissat_init_signal_handler (void (*handler) (int));
|
||||
void kissat_reset_signal_handler (void);
|
||||
|
||||
|
|
@ -40,4 +43,6 @@ kissat_signal_name (int sig)
|
|||
|
||||
// clang-format on
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
void kissat_release_heap (kissat *solver, heap *heap) {
|
||||
RELEASE_STACK (heap->stack);
|
||||
DEALLOC (heap->pos, heap->size);
|
||||
|
|
@ -12,7 +14,7 @@ void kissat_release_heap (kissat *solver, heap *heap) {
|
|||
memset (heap, 0, sizeof *heap);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|
||||
void kissat_check_heap (heap *heap) {
|
||||
const unsigned *const stack = BEGIN_STACK (heap->stack);
|
||||
|
|
@ -22,18 +24,18 @@ void kissat_check_heap (heap *heap) {
|
|||
for (unsigned i = 0; i < end; i++) {
|
||||
const unsigned idx = stack[i];
|
||||
const unsigned idx_pos = pos[idx];
|
||||
assert (idx_pos == i);
|
||||
KISSAT_assert (idx_pos == i);
|
||||
unsigned child_pos = HEAP_CHILD (idx_pos);
|
||||
unsigned parent_pos = HEAP_PARENT (child_pos);
|
||||
assert (parent_pos == idx_pos);
|
||||
KISSAT_assert (parent_pos == idx_pos);
|
||||
if (child_pos < end) {
|
||||
unsigned child = stack[child_pos];
|
||||
assert (score[idx] >= score[child]);
|
||||
KISSAT_assert (score[idx] >= score[child]);
|
||||
if (++child_pos < end) {
|
||||
parent_pos = HEAP_PARENT (child_pos);
|
||||
assert (parent_pos == idx_pos);
|
||||
KISSAT_assert (parent_pos == idx_pos);
|
||||
child = stack[child_pos];
|
||||
assert (score[idx] >= score[child]);
|
||||
KISSAT_assert (score[idx] >= score[child]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,15 +50,15 @@ void kissat_resize_heap (kissat *solver, heap *heap, unsigned new_size) {
|
|||
LOG ("resizing %s heap from %u to %u",
|
||||
(heap->tainted ? "tainted" : "untainted"), old_size, new_size);
|
||||
|
||||
heap->pos = kissat_nrealloc (solver, heap->pos, old_size, new_size,
|
||||
heap->pos = (unsigned*)kissat_nrealloc (solver, heap->pos, old_size, new_size,
|
||||
sizeof (unsigned));
|
||||
if (heap->tainted) {
|
||||
heap->score = kissat_nrealloc (solver, heap->score, old_size, new_size,
|
||||
heap->score = (double*)kissat_nrealloc (solver, heap->score, old_size, new_size,
|
||||
sizeof (double));
|
||||
} else {
|
||||
if (old_size)
|
||||
DEALLOC (heap->score, old_size);
|
||||
heap->score = kissat_calloc (solver, new_size, sizeof (double));
|
||||
heap->score = (double*)kissat_calloc (solver, new_size, sizeof (double));
|
||||
}
|
||||
heap->size = new_size;
|
||||
#ifdef CHECK_HEAP
|
||||
|
|
@ -69,7 +71,7 @@ void kissat_rescale_heap (kissat *solver, heap *heap, double factor) {
|
|||
double *score = heap->score;
|
||||
for (unsigned i = 0; i < heap->vars; i++)
|
||||
score[i] *= factor;
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
kissat_check_heap (heap);
|
||||
#endif
|
||||
#ifndef LOGGING
|
||||
|
|
@ -79,8 +81,8 @@ void kissat_rescale_heap (kissat *solver, heap *heap, double factor) {
|
|||
|
||||
void kissat_enlarge_heap (kissat *solver, heap *heap, unsigned new_vars) {
|
||||
const unsigned old_vars = heap->vars;
|
||||
assert (old_vars < new_vars);
|
||||
assert (new_vars <= heap->size);
|
||||
KISSAT_assert (old_vars < new_vars);
|
||||
KISSAT_assert (new_vars <= heap->size);
|
||||
const size_t delta = new_vars - heap->vars;
|
||||
memset (heap->pos + old_vars, 0xff, delta * sizeof (unsigned));
|
||||
heap->vars = new_vars;
|
||||
|
|
@ -92,7 +94,7 @@ void kissat_enlarge_heap (kissat *solver, heap *heap, unsigned new_vars) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
|
||||
static void dump_heap (heap *heap) {
|
||||
for (unsigned i = 0; i < SIZE_STACK (heap->stack); i++)
|
||||
|
|
@ -106,3 +108,5 @@ static void dump_heap (heap *heap) {
|
|||
void kissat_dump_heap (heap *heap) { dump_heap (heap); }
|
||||
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define DISCONTAIN UINT_MAX
|
||||
#define DISCONTAINED(IDX) ((int) (IDX) < 0)
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ static inline size_t kissat_size_heap (heap *heap) {
|
|||
}
|
||||
|
||||
static inline unsigned kissat_max_heap (heap *heap) {
|
||||
assert (!kissat_empty_heap (heap));
|
||||
KISSAT_assert (!kissat_empty_heap (heap));
|
||||
return PEEK_STACK (heap->stack, 0);
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +64,7 @@ void kissat_enlarge_heap (struct kissat *, heap *, unsigned new_vars);
|
|||
static inline double kissat_max_score_on_heap (heap *heap) {
|
||||
if (!heap->tainted)
|
||||
return 0;
|
||||
assert (heap->vars);
|
||||
KISSAT_assert (heap->vars);
|
||||
const double *const score = heap->score;
|
||||
const double *const end = score + heap->vars;
|
||||
double res = score[0];
|
||||
|
|
@ -70,11 +73,11 @@ static inline double kissat_max_score_on_heap (heap *heap) {
|
|||
return res;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
void kissat_dump_heap (heap *);
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
void kissat_check_heap (heap *);
|
||||
#else
|
||||
#define kissat_check_heap(...) \
|
||||
|
|
@ -82,4 +85,6 @@ void kissat_check_heap (heap *);
|
|||
} while (0)
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include "gates.h"
|
||||
#include "inline.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static bool get_ternary_clause (kissat *solver, reference ref, unsigned *p,
|
||||
unsigned *q, unsigned *r) {
|
||||
clause *clause = kissat_dereference_clause (solver, ref);
|
||||
|
|
@ -30,9 +32,9 @@ static bool get_ternary_clause (kissat *solver, reference ref, unsigned *p,
|
|||
}
|
||||
if (found != 3)
|
||||
return false;
|
||||
assert (a != INVALID_LIT);
|
||||
assert (b != INVALID_LIT);
|
||||
assert (c != INVALID_LIT);
|
||||
KISSAT_assert (a != INVALID_LIT);
|
||||
KISSAT_assert (b != INVALID_LIT);
|
||||
KISSAT_assert (c != INVALID_LIT);
|
||||
*p = a;
|
||||
*q = b;
|
||||
*r = c;
|
||||
|
|
@ -121,7 +123,7 @@ bool kissat_find_if_then_else_gate (kissat *solver, unsigned lit,
|
|||
SWAP (unsigned, a1, b1);
|
||||
if (c1 == lit)
|
||||
SWAP (unsigned, a1, c1);
|
||||
assert (a1 == lit);
|
||||
KISSAT_assert (a1 == lit);
|
||||
for (const watch *p2 = p1 + 1; steps < limit && p2 != end; p2++) {
|
||||
watch w2 = *p2;
|
||||
if (w2.type.binary)
|
||||
|
|
@ -133,7 +135,7 @@ bool kissat_find_if_then_else_gate (kissat *solver, unsigned lit,
|
|||
SWAP (unsigned, a2, b2);
|
||||
if (c2 == lit)
|
||||
SWAP (unsigned, a2, c2);
|
||||
assert (a2 == lit);
|
||||
KISSAT_assert (a2 == lit);
|
||||
if (STRIP (b1) == STRIP (c2))
|
||||
SWAP (unsigned, b2, c2);
|
||||
if (STRIP (c1) == STRIP (c2))
|
||||
|
|
@ -172,3 +174,5 @@ bool kissat_find_if_then_else_gate (kissat *solver, unsigned lit,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -3,9 +3,14 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
bool kissat_find_if_then_else_gate (struct kissat *, unsigned lit,
|
||||
unsigned negative);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "logging.h"
|
||||
#include "resize.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
static void adjust_imports_for_external_literal (kissat *solver,
|
||||
unsigned eidx) {
|
||||
while (eidx >= SIZE_STACK (solver->import)) {
|
||||
|
|
@ -27,13 +29,13 @@ static void adjust_exports_for_external_literal (kissat *solver,
|
|||
INC (variables_extension);
|
||||
else
|
||||
INC (variables_original);
|
||||
assert (!import->eliminated);
|
||||
KISSAT_assert (!import->eliminated);
|
||||
import->lit = ilit;
|
||||
LOG ("importing %s external variable %u as internal literal %u",
|
||||
extension ? "extension" : "original", eidx, ilit);
|
||||
while (iidx >= SIZE_STACK (solver->export))
|
||||
PUSH_STACK (solver->export, 0);
|
||||
POKE_STACK (solver->export, iidx, (int) eidx);
|
||||
while (iidx >= SIZE_STACK (solver->export_))
|
||||
PUSH_STACK (solver->export_, 0);
|
||||
POKE_STACK (solver->export_, iidx, (int) eidx);
|
||||
LOG ("exporting internal variable %u as external literal %u", iidx, eidx);
|
||||
}
|
||||
|
||||
|
|
@ -47,20 +49,20 @@ static inline unsigned import_literal (kissat *solver, int elit,
|
|||
unsigned ilit;
|
||||
if (!import->imported)
|
||||
adjust_exports_for_external_literal (solver, eidx, extension);
|
||||
assert (import->imported);
|
||||
KISSAT_assert (import->imported);
|
||||
ilit = import->lit;
|
||||
if (elit < 0)
|
||||
ilit = NOT (ilit);
|
||||
assert (VALID_INTERNAL_LITERAL (ilit));
|
||||
KISSAT_assert (VALID_INTERNAL_LITERAL (ilit));
|
||||
return ilit;
|
||||
}
|
||||
|
||||
unsigned kissat_import_literal (kissat *solver, int elit) {
|
||||
assert (VALID_EXTERNAL_LITERAL (elit));
|
||||
KISSAT_assert (VALID_EXTERNAL_LITERAL (elit));
|
||||
if (GET_OPTION (tumble))
|
||||
return import_literal (solver, elit, false);
|
||||
const unsigned eidx = ABS (elit);
|
||||
assert (SIZE_STACK (solver->import) <= UINT_MAX);
|
||||
KISSAT_assert (SIZE_STACK (solver->import) <= UINT_MAX);
|
||||
unsigned other = SIZE_STACK (solver->import);
|
||||
if (eidx < other)
|
||||
return import_literal (solver, elit, false);
|
||||
|
|
@ -69,7 +71,7 @@ unsigned kissat_import_literal (kissat *solver, int elit) {
|
|||
|
||||
unsigned ilit = 0;
|
||||
do {
|
||||
assert (VALID_EXTERNAL_LITERAL ((int) other));
|
||||
KISSAT_assert (VALID_EXTERNAL_LITERAL ((int) other));
|
||||
ilit = import_literal (solver, other, false);
|
||||
} while (other++ < eidx);
|
||||
|
||||
|
|
@ -81,20 +83,22 @@ unsigned kissat_import_literal (kissat *solver, int elit) {
|
|||
|
||||
unsigned kissat_fresh_literal (kissat *solver) {
|
||||
size_t imported = SIZE_STACK (solver->import);
|
||||
assert (imported <= EXTERNAL_MAX_VAR);
|
||||
KISSAT_assert (imported <= EXTERNAL_MAX_VAR);
|
||||
if (imported == EXTERNAL_MAX_VAR) {
|
||||
LOG ("can not get another external variable");
|
||||
return INVALID_LIT;
|
||||
}
|
||||
assert (imported <= (unsigned) INT_MAX);
|
||||
KISSAT_assert (imported <= (unsigned) INT_MAX);
|
||||
int eidx = (int) imported;
|
||||
unsigned res = import_literal (solver, eidx, true);
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
struct import *import = &PEEK_STACK (solver->import, imported);
|
||||
assert (import->imported);
|
||||
assert (import->extension);
|
||||
KISSAT_assert (import->imported);
|
||||
KISSAT_assert (import->extension);
|
||||
#endif
|
||||
INC (fresh);
|
||||
kissat_activate_literal (solver, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
#ifndef _import_h_INLCUDED
|
||||
#define _import_h_INLCUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
struct kissat;
|
||||
|
||||
unsigned kissat_import_literal (struct kissat *solver, int lit);
|
||||
unsigned kissat_fresh_literal (struct kissat *solver);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "inlinevector.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#ifdef METRICS
|
||||
|
||||
static inline size_t kissat_allocated (kissat *solver) {
|
||||
|
|
@ -13,8 +16,8 @@ static inline size_t kissat_allocated (kissat *solver) {
|
|||
#endif
|
||||
|
||||
static inline bool kissat_propagated (kissat *solver) {
|
||||
assert (BEGIN_ARRAY (solver->trail) <= solver->propagate);
|
||||
assert (solver->propagate <= END_ARRAY (solver->trail));
|
||||
KISSAT_assert (BEGIN_ARRAY (solver->trail) <= solver->propagate);
|
||||
KISSAT_assert (solver->propagate <= END_ARRAY (solver->trail));
|
||||
return solver->propagate == END_ARRAY (solver->trail);
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +30,7 @@ static inline void kissat_reset_propagate (kissat *solver) {
|
|||
}
|
||||
|
||||
static inline value kissat_fixed (kissat *solver, unsigned lit) {
|
||||
assert (lit < LITS);
|
||||
KISSAT_assert (lit < LITS);
|
||||
const value res = solver->values[lit];
|
||||
if (!res)
|
||||
return 0;
|
||||
|
|
@ -83,7 +86,7 @@ static inline void kissat_push_blocking_watch (kissat *solver,
|
|||
watches *watches,
|
||||
unsigned blocking,
|
||||
reference ref) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
const watch head = kissat_blocking_watch (blocking);
|
||||
PUSH_WATCHES (*watches, head);
|
||||
const watch tail = kissat_large_watch (ref);
|
||||
|
|
@ -107,7 +110,7 @@ static inline void kissat_watch_binary (kissat *solver, unsigned a,
|
|||
static inline void kissat_watch_blocking (kissat *solver, unsigned lit,
|
||||
unsigned blocking,
|
||||
reference ref) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
LOGREF3 (ref, "watching %s blocking %s in", LOGLIT (lit),
|
||||
LOGLIT (blocking));
|
||||
watches *watches = &WATCHES (lit);
|
||||
|
|
@ -116,7 +119,7 @@ static inline void kissat_watch_blocking (kissat *solver, unsigned lit,
|
|||
|
||||
static inline void kissat_unwatch_blocking (kissat *solver, unsigned lit,
|
||||
reference ref) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
LOGREF3 (ref, "unwatching %s in", LOGLIT (lit));
|
||||
watches *watches = &WATCHES (lit);
|
||||
kissat_remove_blocking_watch (solver, watches, ref);
|
||||
|
|
@ -124,7 +127,7 @@ static inline void kissat_unwatch_blocking (kissat *solver, unsigned lit,
|
|||
|
||||
static inline void kissat_disconnect_binary (kissat *solver, unsigned lit,
|
||||
unsigned other) {
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->watching);
|
||||
watches *watches = &WATCHES (lit);
|
||||
const watch watch = kissat_binary_watch (other);
|
||||
REMOVE_WATCHES (*watches, watch);
|
||||
|
|
@ -132,7 +135,7 @@ static inline void kissat_disconnect_binary (kissat *solver, unsigned lit,
|
|||
|
||||
static inline void
|
||||
kissat_disconnect_reference (kissat *solver, unsigned lit, reference ref) {
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->watching);
|
||||
LOGREF3 (ref, "disconnecting %s in", LOGLIT (lit));
|
||||
const watch watch = kissat_large_watch (ref);
|
||||
watches *watches = &WATCHES (lit);
|
||||
|
|
@ -141,14 +144,14 @@ kissat_disconnect_reference (kissat *solver, unsigned lit, reference ref) {
|
|||
|
||||
static inline void kissat_watch_reference (kissat *solver, unsigned a,
|
||||
unsigned b, reference ref) {
|
||||
assert (solver->watching);
|
||||
KISSAT_assert (solver->watching);
|
||||
kissat_watch_blocking (solver, a, b, ref);
|
||||
kissat_watch_blocking (solver, b, a, ref);
|
||||
}
|
||||
|
||||
static inline void kissat_connect_literal (kissat *solver, unsigned lit,
|
||||
reference ref) {
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->watching);
|
||||
LOGREF3 (ref, "connecting %s in", LOGLIT (lit));
|
||||
watches *watches = &WATCHES (lit);
|
||||
kissat_push_large_watch (solver, watches, ref);
|
||||
|
|
@ -162,13 +165,13 @@ static inline clause *kissat_unchecked_dereference_clause (kissat *solver,
|
|||
static inline clause *kissat_dereference_clause (kissat *solver,
|
||||
reference ref) {
|
||||
clause *res = kissat_unchecked_dereference_clause (solver, ref);
|
||||
assert (kissat_clause_in_arena (solver, res));
|
||||
KISSAT_assert (kissat_clause_in_arena (solver, res));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline reference kissat_reference_clause (kissat *solver,
|
||||
const clause *c) {
|
||||
assert (kissat_clause_in_arena (solver, c));
|
||||
KISSAT_assert (kissat_clause_in_arena (solver, c));
|
||||
return (ward *) c - BEGIN_STACK (solver->arena);
|
||||
}
|
||||
|
||||
|
|
@ -176,33 +179,33 @@ static inline void kissat_inlined_connect_clause (kissat *solver,
|
|||
watches *all_watches,
|
||||
clause *c,
|
||||
reference ref) {
|
||||
assert (!solver->watching);
|
||||
assert (ref == kissat_reference_clause (solver, c));
|
||||
assert (c == kissat_dereference_clause (solver, ref));
|
||||
KISSAT_assert (!solver->watching);
|
||||
KISSAT_assert (ref == kissat_reference_clause (solver, c));
|
||||
KISSAT_assert (c == kissat_dereference_clause (solver, ref));
|
||||
for (all_literals_in_clause (lit, c)) {
|
||||
assert (!solver->watching);
|
||||
KISSAT_assert (!solver->watching);
|
||||
LOGREF3 (ref, "connecting %s in", LOGLIT (lit));
|
||||
assert (lit < LITS);
|
||||
KISSAT_assert (lit < LITS);
|
||||
watches *lit_watches = all_watches + lit;
|
||||
kissat_push_large_watch (solver, lit_watches, ref);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void kissat_watch_clause (kissat *solver, clause *c) {
|
||||
assert (c->searched < c->size);
|
||||
KISSAT_assert (c->searched < c->size);
|
||||
const reference ref = kissat_reference_clause (solver, c);
|
||||
kissat_watch_reference (solver, c->lits[0], c->lits[1], ref);
|
||||
}
|
||||
|
||||
static inline int kissat_export_literal (kissat *solver, unsigned ilit) {
|
||||
const unsigned iidx = IDX (ilit);
|
||||
assert (iidx < (unsigned) INT_MAX);
|
||||
int elit = PEEK_STACK (solver->export, iidx);
|
||||
KISSAT_assert (iidx < (unsigned) INT_MAX);
|
||||
int elit = PEEK_STACK (solver->export_, iidx);
|
||||
if (!elit)
|
||||
return 0;
|
||||
if (NEGATED (ilit))
|
||||
elit = -elit;
|
||||
assert (VALID_EXTERNAL_LITERAL (elit));
|
||||
KISSAT_assert (VALID_EXTERNAL_LITERAL (elit));
|
||||
return elit;
|
||||
}
|
||||
|
||||
|
|
@ -242,9 +245,9 @@ static inline clause *kissat_binary_conflict (kissat *solver, unsigned a,
|
|||
|
||||
static inline void kissat_push_analyzed (kissat *solver, assigned *assigned,
|
||||
unsigned idx) {
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
assert (!a->analyzed);
|
||||
KISSAT_assert (!a->analyzed);
|
||||
a->analyzed = true;
|
||||
PUSH_STACK (solver->analyzed, idx);
|
||||
LOG2 ("%s analyzed", LOGVAR (idx));
|
||||
|
|
@ -256,9 +259,9 @@ static inline bool kissat_analyzed (kissat *solver) {
|
|||
|
||||
static inline void
|
||||
kissat_push_removable (kissat *solver, assigned *assigned, unsigned idx) {
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
assert (!a->removable);
|
||||
KISSAT_assert (!a->removable);
|
||||
a->removable = true;
|
||||
PUSH_STACK (solver->removable, idx);
|
||||
LOG2 ("%s removable", LOGVAR (idx));
|
||||
|
|
@ -266,9 +269,9 @@ kissat_push_removable (kissat *solver, assigned *assigned, unsigned idx) {
|
|||
|
||||
static inline void kissat_push_poisoned (kissat *solver, assigned *assigned,
|
||||
unsigned idx) {
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
assert (!a->poisoned);
|
||||
KISSAT_assert (!a->poisoned);
|
||||
a->poisoned = true;
|
||||
PUSH_STACK (solver->poisoned, idx);
|
||||
LOG2 ("%s poisoned", LOGVAR (idx));
|
||||
|
|
@ -276,17 +279,17 @@ static inline void kissat_push_poisoned (kissat *solver, assigned *assigned,
|
|||
|
||||
static inline void
|
||||
kissat_push_shrinkable (kissat *solver, assigned *assigned, unsigned idx) {
|
||||
assert (idx < VARS);
|
||||
KISSAT_assert (idx < VARS);
|
||||
struct assigned *a = assigned + idx;
|
||||
assert (!a->shrinkable);
|
||||
KISSAT_assert (!a->shrinkable);
|
||||
a->shrinkable = true;
|
||||
PUSH_STACK (solver->shrinkable, idx);
|
||||
LOG2 ("%s shrinkable", LOGVAR (idx));
|
||||
}
|
||||
|
||||
static inline int kissat_checking (kissat *solver) {
|
||||
#ifndef NDEBUG
|
||||
#ifdef NOPTIONS
|
||||
#ifndef KISSAT_NDEBUG
|
||||
#ifdef KISSAT_NOPTIONS
|
||||
(void) solver;
|
||||
#endif
|
||||
return GET_OPTION (check);
|
||||
|
|
@ -298,7 +301,7 @@ static inline int kissat_checking (kissat *solver) {
|
|||
|
||||
static inline bool kissat_logging (kissat *solver) {
|
||||
#ifdef LOGGING
|
||||
#ifdef NOPTIONS
|
||||
#ifdef KISSAT_NOPTIONS
|
||||
(void) solver;
|
||||
#endif
|
||||
return GET_OPTION (log) > 0;
|
||||
|
|
@ -309,7 +312,7 @@ static inline bool kissat_logging (kissat *solver) {
|
|||
}
|
||||
|
||||
static inline bool kissat_proving (kissat *solver) {
|
||||
#ifdef NPROOFS
|
||||
#ifdef KISSAT_NPROOFS
|
||||
(void) solver;
|
||||
return false;
|
||||
#else
|
||||
|
|
@ -321,8 +324,10 @@ static inline bool kissat_checking_or_proving (kissat *solver) {
|
|||
return kissat_checking (solver) || kissat_proving (solver);
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS)
|
||||
#define CHECKING_OR_PROVING
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _inlineassign_h_INLCUDED
|
||||
#define _inlineassign_h_INLCUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#ifdef FAST_ASSIGN
|
||||
#define kissat_assign kissat_fast_assign
|
||||
#endif
|
||||
|
|
@ -17,24 +20,26 @@ static inline void kissat_assign (kissat *solver, const bool probing,
|
|||
watches watches = WATCHES (not_lit);
|
||||
if (!kissat_empty_vector (&watches)) {
|
||||
watch *w = BEGIN_WATCHES (watches);
|
||||
#ifndef WIN32
|
||||
__builtin_prefetch (w, 0, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef FAST_ASSIGN
|
||||
value *values = solver->values;
|
||||
#endif
|
||||
assert (!values[lit]);
|
||||
assert (!values[not_lit]);
|
||||
KISSAT_assert (!values[lit]);
|
||||
KISSAT_assert (!values[not_lit]);
|
||||
|
||||
values[lit] = 1;
|
||||
values[not_lit] = -1;
|
||||
|
||||
assert (solver->unassigned > 0);
|
||||
KISSAT_assert (solver->unassigned > 0);
|
||||
solver->unassigned--;
|
||||
|
||||
if (!level) {
|
||||
kissat_mark_fixed_literal (solver, lit);
|
||||
assert (solver->unflushed < UINT_MAX);
|
||||
KISSAT_assert (solver->unflushed < UINT_MAX);
|
||||
solver->unflushed++;
|
||||
if (reason != UNIT_REASON) {
|
||||
CHECK_AND_ADD_UNIT (lit);
|
||||
|
|
@ -84,17 +89,19 @@ kissat_assignment_level (kissat *solver, value *values, assigned *assigned,
|
|||
for (all_literals_in_clause (other, reason)) {
|
||||
if (other == lit)
|
||||
continue;
|
||||
assert (values[other] < 0), (void) values;
|
||||
KISSAT_assert (values[other] < 0), (void) values;
|
||||
const unsigned other_idx = IDX (other);
|
||||
struct assigned *a = assigned + other_idx;
|
||||
const unsigned level = a->level;
|
||||
if (res < level)
|
||||
res = level;
|
||||
}
|
||||
#ifdef NDEBUG
|
||||
#ifdef KISSAT_NDEBUG
|
||||
(void) solver;
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@
|
|||
#include "allocate.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
static inline void kissat_push_frame (kissat *solver, unsigned decision) {
|
||||
assert (!solver->level || decision != UINT_MAX);
|
||||
KISSAT_assert (!solver->level || decision != UINT_MAX);
|
||||
const size_t trail = SIZE_ARRAY (solver->trail);
|
||||
frame frame;
|
||||
frame.decision = decision;
|
||||
|
|
@ -15,4 +18,6 @@ static inline void kissat_push_frame (kissat *solver, unsigned decision) {
|
|||
PUSH_STACK (solver->frames, frame);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
#include "internal.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define HEAP_CHILD(POS) (assert ((POS) < (1u << 31)), (2 * (POS) + 1))
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#define HEAP_PARENT(POS) (assert ((POS) > 0), (((POS) - 1) / 2))
|
||||
#define HEAP_CHILD(POS) (KISSAT_assert ((POS) < (1u << 31)), (2 * (POS) + 1))
|
||||
|
||||
#define HEAP_PARENT(POS) (KISSAT_assert ((POS) > 0), (((POS) - 1) / 2))
|
||||
|
||||
static inline void kissat_bubble_up (kissat *solver, heap *heap,
|
||||
unsigned idx) {
|
||||
|
|
@ -75,7 +78,7 @@ static inline void kissat_bubble_down (kissat *solver, heap *heap,
|
|||
|
||||
#define HEAP_IMPORT(IDX) \
|
||||
do { \
|
||||
assert ((IDX) < UINT_MAX - 1); \
|
||||
KISSAT_assert ((IDX) < UINT_MAX - 1); \
|
||||
if (heap->vars <= (IDX)) \
|
||||
kissat_enlarge_heap (solver, heap, (IDX) + 1); \
|
||||
} while (0)
|
||||
|
|
@ -85,7 +88,7 @@ static inline void kissat_bubble_down (kissat *solver, heap *heap,
|
|||
static inline void kissat_push_heap (kissat *solver, heap *heap,
|
||||
unsigned idx) {
|
||||
LOG ("push heap %u", idx);
|
||||
assert (!kissat_heap_contains (heap, idx));
|
||||
KISSAT_assert (!kissat_heap_contains (heap, idx));
|
||||
HEAP_IMPORT (idx);
|
||||
heap->pos[idx] = SIZE_STACK (heap->stack);
|
||||
PUSH_STACK (heap->stack, idx);
|
||||
|
|
@ -95,7 +98,7 @@ static inline void kissat_push_heap (kissat *solver, heap *heap,
|
|||
static inline void kissat_pop_heap (kissat *solver, heap *heap,
|
||||
unsigned idx) {
|
||||
LOG ("pop heap %u", idx);
|
||||
assert (kissat_heap_contains (heap, idx));
|
||||
KISSAT_assert (kissat_heap_contains (heap, idx));
|
||||
const unsigned last = POP_STACK (heap->stack);
|
||||
heap->pos[last] = DISCONTAIN;
|
||||
if (last == idx)
|
||||
|
|
@ -112,11 +115,11 @@ static inline void kissat_pop_heap (kissat *solver, heap *heap,
|
|||
}
|
||||
|
||||
static inline unsigned kissat_pop_max_heap (kissat *solver, heap *heap) {
|
||||
assert (!EMPTY_STACK (heap->stack));
|
||||
KISSAT_assert (!EMPTY_STACK (heap->stack));
|
||||
unsigneds *stack = &heap->stack;
|
||||
unsigned *const begin = BEGIN_STACK (*stack);
|
||||
const unsigned idx = *begin;
|
||||
assert (!heap->pos[idx]);
|
||||
KISSAT_assert (!heap->pos[idx]);
|
||||
LOG ("pop max heap %u", idx);
|
||||
const unsigned last = POP_STACK (*stack);
|
||||
unsigned *const pos = heap->pos;
|
||||
|
|
@ -144,7 +147,7 @@ static inline void kissat_adjust_heap (kissat *solver, heap *heap,
|
|||
size_t new_size = old_size ? 2 * old_size : 1;
|
||||
while (idx >= new_size)
|
||||
new_size *= 2;
|
||||
assert (new_size < DISCONTAIN);
|
||||
KISSAT_assert (new_size < DISCONTAIN);
|
||||
kissat_resize_heap (solver, heap, new_size);
|
||||
}
|
||||
kissat_enlarge_heap (solver, heap, idx + 1);
|
||||
|
|
@ -173,4 +176,6 @@ static inline void kissat_update_heap (kissat *solver, heap *heap,
|
|||
#endif
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@
|
|||
#include "internal.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
static inline void kissat_update_queue (kissat *solver, const links *links,
|
||||
unsigned idx) {
|
||||
assert (!DISCONNECTED (idx));
|
||||
KISSAT_assert (!DISCONNECTED (idx));
|
||||
const unsigned stamp = links[idx].stamp;
|
||||
LOG ("queue updated to %s stamped %u", LOGVAR (idx), stamp);
|
||||
solver->queue.search.idx = idx;
|
||||
|
|
@ -16,20 +19,20 @@ static inline void kissat_update_queue (kissat *solver, const links *links,
|
|||
static inline void kissat_enqueue_links (kissat *solver, unsigned i,
|
||||
links *links, queue *queue) {
|
||||
struct links *p = links + i;
|
||||
assert (DISCONNECTED (p->prev));
|
||||
assert (DISCONNECTED (p->next));
|
||||
KISSAT_assert (DISCONNECTED (p->prev));
|
||||
KISSAT_assert (DISCONNECTED (p->next));
|
||||
const unsigned j = p->prev = queue->last;
|
||||
queue->last = i;
|
||||
if (DISCONNECTED (j))
|
||||
queue->first = i;
|
||||
else {
|
||||
struct links *l = links + j;
|
||||
assert (DISCONNECTED (l->next));
|
||||
KISSAT_assert (DISCONNECTED (l->next));
|
||||
l->next = i;
|
||||
}
|
||||
if (queue->stamp == UINT_MAX) {
|
||||
kissat_reassign_queue_stamps (solver);
|
||||
assert (p->stamp == queue->stamp);
|
||||
KISSAT_assert (p->stamp == queue->stamp);
|
||||
} else
|
||||
p->stamp = ++queue->stamp;
|
||||
}
|
||||
|
|
@ -40,25 +43,25 @@ static inline void kissat_dequeue_links (unsigned i, links *links,
|
|||
const unsigned j = l->prev, k = l->next;
|
||||
l->prev = l->next = DISCONNECT;
|
||||
if (DISCONNECTED (j)) {
|
||||
assert (queue->first == i);
|
||||
KISSAT_assert (queue->first == i);
|
||||
queue->first = k;
|
||||
} else {
|
||||
struct links *p = links + j;
|
||||
assert (p->next == i);
|
||||
KISSAT_assert (p->next == i);
|
||||
p->next = k;
|
||||
}
|
||||
if (DISCONNECTED (k)) {
|
||||
assert (queue->last == i);
|
||||
KISSAT_assert (queue->last == i);
|
||||
queue->last = j;
|
||||
} else {
|
||||
struct links *n = links + k;
|
||||
assert (n->prev == i);
|
||||
KISSAT_assert (n->prev == i);
|
||||
n->prev = j;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void kissat_enqueue (kissat *solver, unsigned idx) {
|
||||
assert (idx < solver->vars);
|
||||
KISSAT_assert (idx < solver->vars);
|
||||
links *links = solver->links, *l = links + idx;
|
||||
l->prev = l->next = DISCONNECT;
|
||||
kissat_enqueue_links (solver, idx, links, &solver->queue);
|
||||
|
|
@ -69,7 +72,7 @@ static inline void kissat_enqueue (kissat *solver, unsigned idx) {
|
|||
}
|
||||
|
||||
static inline void kissat_dequeue (kissat *solver, unsigned idx) {
|
||||
assert (idx < solver->vars);
|
||||
KISSAT_assert (idx < solver->vars);
|
||||
LOG ("dequeued %s", LOGVAR (idx));
|
||||
links *links = solver->links;
|
||||
if (solver->queue.search.idx == idx) {
|
||||
|
|
@ -91,10 +94,10 @@ static inline void kissat_move_to_front (kissat *solver, unsigned idx) {
|
|||
queue *queue = &solver->queue;
|
||||
links *links = solver->links;
|
||||
if (idx == queue->last) {
|
||||
assert (DISCONNECTED (links[idx].next));
|
||||
KISSAT_assert (DISCONNECTED (links[idx].next));
|
||||
return;
|
||||
}
|
||||
assert (idx < solver->vars);
|
||||
KISSAT_assert (idx < solver->vars);
|
||||
const value tmp = VALUE (LIT (idx));
|
||||
if (tmp && queue->search.idx == idx) {
|
||||
unsigned prev = links[idx].prev;
|
||||
|
|
@ -102,7 +105,7 @@ static inline void kissat_move_to_front (kissat *solver, unsigned idx) {
|
|||
kissat_update_queue (solver, links, prev);
|
||||
else {
|
||||
unsigned next = links[idx].next;
|
||||
assert (!DISCONNECTED (next));
|
||||
KISSAT_assert (!DISCONNECTED (next));
|
||||
kissat_update_queue (solver, links, next);
|
||||
}
|
||||
}
|
||||
|
|
@ -114,4 +117,6 @@ static inline void kissat_move_to_front (kissat *solver, unsigned idx) {
|
|||
kissat_check_queue (solver);
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@
|
|||
|
||||
#include "internal.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
static inline unsigned *kissat_begin_vector (kissat *solver,
|
||||
vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return BEGIN_STACK (solver->vectors.stack) + vector->offset;
|
||||
#else
|
||||
(void) solver;
|
||||
|
|
@ -14,7 +17,7 @@ static inline unsigned *kissat_begin_vector (kissat *solver,
|
|||
}
|
||||
|
||||
static inline unsigned *kissat_end_vector (kissat *solver, vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return kissat_begin_vector (solver, vector) + vector->size;
|
||||
#else
|
||||
(void) solver;
|
||||
|
|
@ -24,7 +27,7 @@ static inline unsigned *kissat_end_vector (kissat *solver, vector *vector) {
|
|||
|
||||
static inline const unsigned *
|
||||
kissat_begin_const_vector (kissat *solver, const vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return BEGIN_STACK (solver->vectors.stack) + vector->offset;
|
||||
#else
|
||||
(void) solver;
|
||||
|
|
@ -34,7 +37,7 @@ kissat_begin_const_vector (kissat *solver, const vector *vector) {
|
|||
|
||||
static inline const unsigned *
|
||||
kissat_end_const_vector (kissat *solver, const vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return kissat_begin_const_vector (solver, vector) + vector->size;
|
||||
#else
|
||||
(void) solver;
|
||||
|
|
@ -45,7 +48,7 @@ kissat_end_const_vector (kissat *solver, const vector *vector) {
|
|||
#if defined(LOGGING) || defined(TEST_VECTOR)
|
||||
|
||||
static inline size_t kissat_offset_vector (kissat *solver, vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
(void) solver;
|
||||
return vector->offset;
|
||||
#else
|
||||
|
|
@ -58,7 +61,7 @@ static inline size_t kissat_offset_vector (kissat *solver, vector *vector) {
|
|||
#endif
|
||||
|
||||
static inline size_t kissat_size_vector (const vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return vector->size;
|
||||
#else
|
||||
return vector->end - vector->begin;
|
||||
|
|
@ -66,7 +69,7 @@ static inline size_t kissat_size_vector (const vector *vector) {
|
|||
}
|
||||
|
||||
static inline bool kissat_empty_vector (vector *vector) {
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
return !vector->size;
|
||||
#else
|
||||
return vector->end == vector->begin;
|
||||
|
|
@ -74,20 +77,20 @@ static inline bool kissat_empty_vector (vector *vector) {
|
|||
}
|
||||
|
||||
static inline void kissat_inc_usable (kissat *solver) {
|
||||
assert (MAX_SECTOR > solver->vectors.usable);
|
||||
KISSAT_assert (MAX_SECTOR > solver->vectors.usable);
|
||||
solver->vectors.usable++;
|
||||
}
|
||||
|
||||
static inline void kissat_add_usable (kissat *solver, size_t inc) {
|
||||
assert (MAX_SECTOR - inc >= solver->vectors.usable);
|
||||
KISSAT_assert (MAX_SECTOR - inc >= solver->vectors.usable);
|
||||
solver->vectors.usable += inc;
|
||||
}
|
||||
|
||||
static inline unsigned *kissat_last_vector_pointer (kissat *solver,
|
||||
vector *vector) {
|
||||
assert (!kissat_empty_vector (vector));
|
||||
#ifdef COMPACT
|
||||
assert (vector->size);
|
||||
KISSAT_assert (!kissat_empty_vector (vector));
|
||||
#ifdef KISSAT_COMPACT
|
||||
KISSAT_assert (vector->size);
|
||||
unsigned *begin = kissat_begin_vector (solver, vector);
|
||||
return begin + vector->size - 1;
|
||||
#else
|
||||
|
|
@ -99,8 +102,8 @@ static inline unsigned *kissat_last_vector_pointer (kissat *solver,
|
|||
#ifdef TEST_VECTOR
|
||||
|
||||
static inline void kissat_pop_vector (kissat *solver, vector *vector) {
|
||||
assert (!kissat_empty_vector (vector));
|
||||
#ifdef COMPACT
|
||||
KISSAT_assert (!kissat_empty_vector (vector));
|
||||
#ifdef KISSAT_COMPACT
|
||||
unsigned *p = kissat_last_vector_pointer (solver, vector);
|
||||
vector->size--;
|
||||
*p = INVALID_VECTOR_ELEMENT;
|
||||
|
|
@ -118,16 +121,16 @@ static inline void kissat_release_vector (kissat *solver, vector *vector) {
|
|||
}
|
||||
|
||||
static inline void kissat_dec_usable (kissat *solver) {
|
||||
assert (solver->vectors.usable > 0);
|
||||
KISSAT_assert (solver->vectors.usable > 0);
|
||||
solver->vectors.usable--;
|
||||
}
|
||||
|
||||
static inline void kissat_push_vectors (kissat *solver, vector *vector,
|
||||
unsigned e) {
|
||||
unsigneds *stack = &solver->vectors.stack;
|
||||
assert (e != INVALID_VECTOR_ELEMENT);
|
||||
KISSAT_assert (e != INVALID_VECTOR_ELEMENT);
|
||||
if (
|
||||
#ifdef COMPACT
|
||||
#ifdef KISSAT_COMPACT
|
||||
!vector->size && !vector->offset
|
||||
#else
|
||||
!vector->begin
|
||||
|
|
@ -137,21 +140,21 @@ static inline void kissat_push_vectors (kissat *solver, vector *vector,
|
|||
PUSH_STACK (*stack, 0);
|
||||
if (FULL_STACK (*stack)) {
|
||||
unsigned *end = kissat_enlarge_vector (solver, vector);
|
||||
assert (*end == INVALID_VECTOR_ELEMENT);
|
||||
KISSAT_assert (*end == INVALID_VECTOR_ELEMENT);
|
||||
*end = e;
|
||||
kissat_dec_usable (solver);
|
||||
} else {
|
||||
#ifdef COMPACT
|
||||
assert ((uint64_t) SIZE_STACK (*stack) < MAX_VECTORS);
|
||||
#ifdef KISSAT_COMPACT
|
||||
KISSAT_assert ((uint64_t) SIZE_STACK (*stack) < MAX_VECTORS);
|
||||
vector->offset = SIZE_STACK (*stack);
|
||||
assert (vector->offset);
|
||||
KISSAT_assert (vector->offset);
|
||||
*stack->end++ = e;
|
||||
#else
|
||||
assert (stack->end < stack->allocated);
|
||||
KISSAT_assert (stack->end < stack->allocated);
|
||||
*(vector->begin = stack->end++) = e;
|
||||
#endif
|
||||
}
|
||||
#if !defined(COMPACT)
|
||||
#if !defined(KISSAT_COMPACT)
|
||||
vector->end = vector->begin;
|
||||
#endif
|
||||
} else {
|
||||
|
|
@ -159,7 +162,7 @@ static inline void kissat_push_vectors (kissat *solver, vector *vector,
|
|||
if (end == END_STACK (*stack)) {
|
||||
if (FULL_STACK (*stack)) {
|
||||
end = kissat_enlarge_vector (solver, vector);
|
||||
assert (*end == INVALID_VECTOR_ELEMENT);
|
||||
KISSAT_assert (*end == INVALID_VECTOR_ELEMENT);
|
||||
*end = e;
|
||||
kissat_dec_usable (solver);
|
||||
} else
|
||||
|
|
@ -167,12 +170,12 @@ static inline void kissat_push_vectors (kissat *solver, vector *vector,
|
|||
} else {
|
||||
if (*end != INVALID_VECTOR_ELEMENT)
|
||||
end = kissat_enlarge_vector (solver, vector);
|
||||
assert (*end == INVALID_VECTOR_ELEMENT);
|
||||
KISSAT_assert (*end == INVALID_VECTOR_ELEMENT);
|
||||
*end = e;
|
||||
kissat_dec_usable (solver);
|
||||
}
|
||||
}
|
||||
#ifndef COMPACT
|
||||
#ifndef KISSAT_COMPACT
|
||||
vector->end++;
|
||||
#else
|
||||
vector->size++;
|
||||
|
|
@ -190,4 +193,6 @@ static inline void kissat_push_vectors (kissat *solver, vector *vector,
|
|||
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,24 +17,26 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
void kissat_reset_last_learned (kissat *solver) {
|
||||
for (really_all_last_learned (p))
|
||||
*p = INVALID_REF;
|
||||
}
|
||||
|
||||
kissat *kissat_init (void) {
|
||||
kissat *solver = kissat_calloc (0, 1, sizeof *solver);
|
||||
#ifndef NOPTIONS
|
||||
kissat *solver = (kissat*)kissat_calloc (0, 1, sizeof *solver);
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
kissat_init_options (&solver->options);
|
||||
#else
|
||||
kissat_init_options ();
|
||||
#endif
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
kissat_init_profiles (&solver->profiles);
|
||||
#endif
|
||||
START (total);
|
||||
kissat_init_queue (solver);
|
||||
assert (INTERNAL_MAX_LIT < UINT_MAX);
|
||||
KISSAT_assert (INTERNAL_MAX_LIT < UINT_MAX);
|
||||
kissat_push_frame (solver, UINT_MAX);
|
||||
solver->watching = true;
|
||||
solver->conflict.size = 2;
|
||||
|
|
@ -42,7 +44,7 @@ kissat *kissat_init (void) {
|
|||
solver->first_reducible = INVALID_REF;
|
||||
solver->last_irredundant = INVALID_REF;
|
||||
kissat_reset_last_learned (solver);
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
kissat_init_checker (solver);
|
||||
#endif
|
||||
solver->prefix = kissat_strdup (solver, "c ");
|
||||
|
|
@ -83,7 +85,7 @@ void kissat_release (kissat *solver) {
|
|||
kissat_release_vectors (solver);
|
||||
kissat_release_phases (solver);
|
||||
|
||||
RELEASE_STACK (solver->export);
|
||||
RELEASE_STACK (solver->export_);
|
||||
RELEASE_STACK (solver->import);
|
||||
|
||||
DEALLOC_VARIABLE_INDEXED (assigned);
|
||||
|
|
@ -104,7 +106,7 @@ void kissat_release (kissat *solver) {
|
|||
|
||||
RELEASE_STACK (solver->clause);
|
||||
RELEASE_STACK (solver->shadow);
|
||||
#if defined(LOGGING) || !defined(NDEBUG)
|
||||
#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
|
||||
RELEASE_STACK (solver->resolvent);
|
||||
#endif
|
||||
|
||||
|
|
@ -136,26 +138,26 @@ void kissat_release (kissat *solver) {
|
|||
RELEASE_STACK (solver->gates[1]);
|
||||
RELEASE_STACK (solver->resolvents);
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS)
|
||||
RELEASE_STACK (solver->added);
|
||||
RELEASE_STACK (solver->removed);
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS) || defined(LOGGING)
|
||||
RELEASE_STACK (solver->original);
|
||||
#endif
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
RELEASE_STACK (solver->profiles.stack);
|
||||
#endif
|
||||
|
||||
kissat_freestr (solver, solver->prefix);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
kissat_release_checker (solver);
|
||||
#endif
|
||||
#if !defined(NDEBUG) && defined(METRICS)
|
||||
uint64_t leaked = solver->statistics.allocated_current;
|
||||
#if !defined(KISSAT_NDEBUG) && defined(METRICS)
|
||||
uint64_t leaked = solver->statistics_.allocated_current;
|
||||
if (leaked)
|
||||
if (!getenv ("LEAK"))
|
||||
kissat_fatal ("internally leaking %" PRIu64 " bytes", leaked);
|
||||
|
|
@ -182,7 +184,7 @@ void kissat_reserve (kissat *solver, int max_var) {
|
|||
int kissat_get_option (kissat *solver, const char *name) {
|
||||
kissat_require_initialized (solver);
|
||||
kissat_require (name, "name zero pointer");
|
||||
#ifndef NOPTIONS
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
return kissat_options_get (&solver->options, name);
|
||||
#else
|
||||
(void) solver;
|
||||
|
|
@ -191,10 +193,10 @@ int kissat_get_option (kissat *solver, const char *name) {
|
|||
}
|
||||
|
||||
int kissat_set_option (kissat *solver, const char *name, int new_value) {
|
||||
#ifndef NOPTIONS
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
kissat_require_initialized (solver);
|
||||
kissat_require (name, "name zero pointer");
|
||||
#ifndef NOPTIONS
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
return kissat_options_set (&solver->options, name, new_value);
|
||||
#else
|
||||
return kissat_options_set (name, new_value);
|
||||
|
|
@ -209,9 +211,9 @@ void kissat_set_decision_limit (kissat *solver, unsigned limit) {
|
|||
kissat_require_initialized (solver);
|
||||
limits *limits = &solver->limits;
|
||||
limited *limited = &solver->limited;
|
||||
statistics *statistics = &solver->statistics;
|
||||
statistics *statistics = &solver->statistics_;
|
||||
limited->decisions = true;
|
||||
assert (UINT64_MAX - limit >= statistics->decisions);
|
||||
KISSAT_assert (UINT64_MAX - limit >= statistics->decisions);
|
||||
limits->decisions = statistics->decisions + limit;
|
||||
LOG ("set decision limit to %" PRIu64 " after %u decisions",
|
||||
limits->decisions, limit);
|
||||
|
|
@ -221,16 +223,16 @@ void kissat_set_conflict_limit (kissat *solver, unsigned limit) {
|
|||
kissat_require_initialized (solver);
|
||||
limits *limits = &solver->limits;
|
||||
limited *limited = &solver->limited;
|
||||
statistics *statistics = &solver->statistics;
|
||||
statistics *statistics = &solver->statistics_;
|
||||
limited->conflicts = true;
|
||||
assert (UINT64_MAX - limit >= statistics->conflicts);
|
||||
KISSAT_assert (UINT64_MAX - limit >= statistics->conflicts);
|
||||
limits->conflicts = statistics->conflicts + limit;
|
||||
LOG ("set conflict limit to %" PRIu64 " after %u conflicts",
|
||||
limits->conflicts, limit);
|
||||
}
|
||||
|
||||
void kissat_print_statistics (kissat *solver) {
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
kissat_require_initialized (solver);
|
||||
const int verbosity = kissat_verbosity (solver);
|
||||
if (verbosity < 0)
|
||||
|
|
@ -243,13 +245,13 @@ void kissat_print_statistics (kissat *solver) {
|
|||
kissat_section (solver, "statistics");
|
||||
const bool verbose = (complete || verbosity > 0);
|
||||
kissat_statistics_print (solver, verbose);
|
||||
#ifndef NPROOFS
|
||||
#ifndef KISSAT_NPROOFS
|
||||
if (solver->proof) {
|
||||
kissat_section (solver, "proof");
|
||||
kissat_print_proof_statistics (solver, verbose);
|
||||
}
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
if (GET_OPTION (check) > 1) {
|
||||
kissat_section (solver, "checker");
|
||||
kissat_print_checker_statistics (solver, verbose);
|
||||
|
|
@ -266,14 +268,14 @@ void kissat_print_statistics (kissat *solver) {
|
|||
void kissat_add (kissat *solver, int elit) {
|
||||
kissat_require_initialized (solver);
|
||||
kissat_require (!GET (searches), "incremental solving not supported");
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS) || defined(LOGGING)
|
||||
const int checking = kissat_checking (solver);
|
||||
const bool logging = kissat_logging (solver);
|
||||
const bool proving = kissat_proving (solver);
|
||||
#endif
|
||||
if (elit) {
|
||||
kissat_require_valid_external_internal (elit);
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS) || defined(LOGGING)
|
||||
if (checking || logging || proving)
|
||||
PUSH_STACK (solver->original, elit);
|
||||
#endif
|
||||
|
|
@ -297,18 +299,18 @@ void kissat_add (kissat *solver, int elit) {
|
|||
} else {
|
||||
MARK (ilit) = 1;
|
||||
MARK (NOT (ilit)) = -1;
|
||||
assert (SIZE_STACK (solver->clause) < UINT_MAX);
|
||||
KISSAT_assert (SIZE_STACK (solver->clause) < UINT_MAX);
|
||||
PUSH_STACK (solver->clause, ilit);
|
||||
}
|
||||
} else if (mark < 0) {
|
||||
assert (mark < 0);
|
||||
KISSAT_assert (mark < 0);
|
||||
if (!solver->clause_trivial) {
|
||||
LOG ("adding dual literal %u(%d) and %u(%d)", NOT (ilit), -elit,
|
||||
ilit, elit);
|
||||
solver->clause_trivial = true;
|
||||
}
|
||||
} else {
|
||||
assert (mark > 0);
|
||||
KISSAT_assert (mark > 0);
|
||||
LOG ("adding duplicated literal %u(%d)", ilit, elit);
|
||||
if (!solver->clause_shrink) {
|
||||
solver->clause_shrink = true;
|
||||
|
|
@ -316,16 +318,16 @@ void kissat_add (kissat *solver, int elit) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS) || defined(LOGGING)
|
||||
const size_t offset = solver->offset_of_last_original_clause;
|
||||
size_t esize = SIZE_STACK (solver->original) - offset;
|
||||
int *elits = BEGIN_STACK (solver->original) + offset;
|
||||
assert (esize <= UINT_MAX);
|
||||
KISSAT_assert (esize <= UINT_MAX);
|
||||
#endif
|
||||
ADD_UNCHECKED_EXTERNAL (esize, elits);
|
||||
const size_t isize = SIZE_STACK (solver->clause);
|
||||
unsigned *ilits = BEGIN_STACK (solver->clause);
|
||||
assert (isize < (unsigned) INT_MAX);
|
||||
KISSAT_assert (isize < (unsigned) INT_MAX);
|
||||
|
||||
if (solver->inconsistent)
|
||||
LOG ("inconsistent thus skipping original clause");
|
||||
|
|
@ -380,38 +382,38 @@ void kissat_add (kissat *solver, int elit) {
|
|||
assign = true;
|
||||
} else if (u < 0 && k == l) {
|
||||
LOG ("both watches falsified at level @%u", k);
|
||||
assert (v < 0);
|
||||
assert (k > 0);
|
||||
KISSAT_assert (v < 0);
|
||||
KISSAT_assert (k > 0);
|
||||
kissat_backtrack_without_updating_phases (solver, k - 1);
|
||||
} else if (u < 0) {
|
||||
LOG ("watches falsified at levels @%u and @%u", k, l);
|
||||
assert (v < 0);
|
||||
assert (k > l);
|
||||
assert (l > 0);
|
||||
KISSAT_assert (v < 0);
|
||||
KISSAT_assert (k > l);
|
||||
KISSAT_assert (l > 0);
|
||||
assign = true;
|
||||
} else if (u > 0 && v < 0) {
|
||||
LOG ("first watch satisfied at level @%u "
|
||||
"second falsified at level @%u",
|
||||
k, l);
|
||||
assert (k <= l);
|
||||
KISSAT_assert (k <= l);
|
||||
} else if (!u && v > 0) {
|
||||
LOG ("first watch unassigned "
|
||||
"second falsified at level @%u",
|
||||
l);
|
||||
assign = true;
|
||||
} else {
|
||||
assert (!u);
|
||||
assert (!v);
|
||||
KISSAT_assert (!u);
|
||||
KISSAT_assert (!v);
|
||||
}
|
||||
|
||||
if (assign) {
|
||||
assert (solver->level > 0);
|
||||
KISSAT_assert (solver->level > 0);
|
||||
|
||||
if (isize == 2) {
|
||||
assert (res == INVALID_REF);
|
||||
KISSAT_assert (res == INVALID_REF);
|
||||
kissat_assign_binary (solver, a, b);
|
||||
} else {
|
||||
assert (res != INVALID_REF);
|
||||
KISSAT_assert (res != INVALID_REF);
|
||||
clause *c = kissat_dereference_clause (solver, res);
|
||||
kissat_assign_reference (solver, a, res, c);
|
||||
}
|
||||
|
|
@ -419,13 +421,13 @@ void kissat_add (kissat *solver, int elit) {
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS)
|
||||
if (solver->clause_satisfied || solver->clause_trivial) {
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
if (checking > 1)
|
||||
kissat_remove_checker_external (solver, esize, elits);
|
||||
#endif
|
||||
#ifndef NPROOFS
|
||||
#ifndef KISSAT_NPROOFS
|
||||
if (proving) {
|
||||
if (esize == 1)
|
||||
LOG ("skipping deleting unit from proof");
|
||||
|
|
@ -434,13 +436,13 @@ void kissat_add (kissat *solver, int elit) {
|
|||
}
|
||||
#endif
|
||||
} else if (!solver->inconsistent && solver->clause_shrink) {
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
if (checking > 1) {
|
||||
kissat_check_and_add_internal (solver, isize, ilits);
|
||||
kissat_remove_checker_external (solver, esize, elits);
|
||||
}
|
||||
#endif
|
||||
#ifndef NPROOFS
|
||||
#ifndef KISSAT_NPROOFS
|
||||
if (proving) {
|
||||
kissat_add_lits_to_proof (solver, isize, ilits);
|
||||
kissat_delete_external_from_proof (solver, esize, elits);
|
||||
|
|
@ -449,7 +451,7 @@ void kissat_add (kissat *solver, int elit) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS) || defined(LOGGING)
|
||||
if (checking) {
|
||||
LOGINTS (esize, elits, "saved original");
|
||||
PUSH_STACK (solver->original, 0);
|
||||
|
|
@ -483,7 +485,7 @@ int kissat_solve (kissat *solver) {
|
|||
void kissat_terminate (kissat *solver) {
|
||||
kissat_require_initialized (solver);
|
||||
solver->termination.flagged = ~(unsigned) 0;
|
||||
assert (solver->termination.flagged);
|
||||
KISSAT_assert (solver->termination.flagged);
|
||||
}
|
||||
|
||||
void kissat_set_terminate (kissat *solver, void *state,
|
||||
|
|
@ -518,3 +520,9 @@ int kissat_value (kissat *solver, int elit) {
|
|||
tmp = -tmp;
|
||||
return tmp < 0 ? -elit : elit;
|
||||
}
|
||||
|
||||
int kissat_is_inconsistent(kissat *solver) {
|
||||
return solver->inconsistent;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
#include "vector.h"
|
||||
#include "watch.h"
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct datarank datarank;
|
||||
|
||||
struct datarank {
|
||||
|
|
@ -74,7 +77,7 @@ typedef STACK (watch *) patches;
|
|||
struct kitten;
|
||||
|
||||
struct kissat {
|
||||
#if !defined(NDEBUG) || defined(METRICS)
|
||||
#if !defined(KISSAT_NDEBUG) || defined(METRICS)
|
||||
bool backbone_computing;
|
||||
#endif
|
||||
#ifdef LOGGING
|
||||
|
|
@ -85,11 +88,11 @@ struct kissat {
|
|||
bool iterating;
|
||||
bool preprocessing;
|
||||
bool probing;
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
bool sectioned;
|
||||
#endif
|
||||
bool stable;
|
||||
#if !defined(NDEBUG) || defined(METRICS)
|
||||
#if !defined(KISSAT_NDEBUG) || defined(METRICS)
|
||||
bool transitive_reducing;
|
||||
bool vivifying;
|
||||
#endif
|
||||
|
|
@ -105,7 +108,7 @@ struct kissat {
|
|||
unsigned active;
|
||||
unsigned randec;
|
||||
|
||||
ints export;
|
||||
ints export_;
|
||||
ints units;
|
||||
imports import;
|
||||
extensions extend;
|
||||
|
|
@ -144,7 +147,7 @@ struct kissat {
|
|||
|
||||
unsigneds delayed;
|
||||
|
||||
#if defined(LOGGING) || !defined(NDEBUG)
|
||||
#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
|
||||
unsigneds resolvent;
|
||||
#endif
|
||||
unsigned resolvent_size;
|
||||
|
|
@ -197,7 +200,7 @@ struct kissat {
|
|||
|
||||
uint64_t ticks;
|
||||
|
||||
format format;
|
||||
kormat format;
|
||||
char *prefix;
|
||||
|
||||
statches antecedents[2];
|
||||
|
|
@ -215,33 +218,33 @@ struct kissat {
|
|||
bool sweep_incomplete;
|
||||
unsigneds sweep_schedule;
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS)
|
||||
unsigneds added;
|
||||
unsigneds removed;
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG) || !defined(NPROOFS) || defined(LOGGING)
|
||||
#if !defined(KISSAT_NDEBUG) || !defined(KISSAT_NPROOFS) || defined(LOGGING)
|
||||
ints original;
|
||||
size_t offset_of_last_original_clause;
|
||||
#endif
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
profiles profiles;
|
||||
#endif
|
||||
|
||||
#ifndef NOPTIONS
|
||||
#ifndef KISSAT_NOPTIONS
|
||||
options options;
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef KISSAT_NDEBUG
|
||||
checker *checker;
|
||||
#endif
|
||||
|
||||
#ifndef NPROOFS
|
||||
#ifndef KISSAT_NPROOFS
|
||||
proof *proof;
|
||||
#endif
|
||||
|
||||
statistics statistics;
|
||||
statistics statistics_;
|
||||
};
|
||||
|
||||
#define VARS (solver->vars)
|
||||
|
|
@ -259,7 +262,7 @@ struct kissat {
|
|||
#define SCORES (&solver->scores)
|
||||
|
||||
static inline unsigned kissat_assigned (kissat *solver) {
|
||||
assert (VARS >= solver->unassigned);
|
||||
KISSAT_assert (VARS >= solver->unassigned);
|
||||
return VARS - solver->unassigned;
|
||||
}
|
||||
|
||||
|
|
@ -292,4 +295,6 @@ static inline unsigned kissat_assigned (kissat *solver) {
|
|||
|
||||
void kissat_reset_last_learned (kissat *solver);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _keatures_h_INCLUDED
|
||||
#define _keatures_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define KISSAT_IS_BIG_ENDIAN
|
||||
#endif
|
||||
|
|
@ -15,4 +18,6 @@
|
|||
#define KISSAT_HAS_UNLOCKEDIO
|
||||
#endif
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,29 +10,31 @@
|
|||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
double kissat_logn (uint64_t count) {
|
||||
assert (count > 0);
|
||||
KISSAT_assert (count > 0);
|
||||
const double res = log10 (count + 9);
|
||||
assert (res >= 1);
|
||||
KISSAT_assert (res >= 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
double kissat_sqrt (uint64_t count) {
|
||||
assert (count > 0);
|
||||
KISSAT_assert (count > 0);
|
||||
const double res = sqrt (count);
|
||||
assert (res >= 1);
|
||||
KISSAT_assert (res >= 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
double kissat_nlogpown (uint64_t count, unsigned exponent) {
|
||||
assert (count > 0);
|
||||
KISSAT_assert (count > 0);
|
||||
const double tmp = log10 (count + 9);
|
||||
double factor = 1;
|
||||
while (exponent--)
|
||||
factor *= tmp;
|
||||
assert (factor >= 1);
|
||||
KISSAT_assert (factor >= 1);
|
||||
const double res = count * factor;
|
||||
assert (res >= 1);
|
||||
KISSAT_assert (res >= 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -41,10 +43,10 @@ uint64_t kissat_scale_delta (kissat *solver, const char *pretty,
|
|||
const uint64_t C = BINIRR_CLAUSES;
|
||||
double f = kissat_logn (C + 1) - 5;
|
||||
const double ff = f * f;
|
||||
assert (ff >= 0);
|
||||
KISSAT_assert (ff >= 0);
|
||||
const double fff = 4.5 * ff + 25;
|
||||
uint64_t scaled = fff * delta;
|
||||
assert (delta <= scaled);
|
||||
KISSAT_assert (delta <= scaled);
|
||||
// clang-format off
|
||||
kissat_very_verbose (solver,
|
||||
"scaled %s delta %" PRIu64
|
||||
|
|
@ -97,7 +99,7 @@ static void init_enabled (kissat *solver) {
|
|||
} while (0)
|
||||
|
||||
void kissat_init_limits (kissat *solver) {
|
||||
assert (solver->statistics.searches == 1);
|
||||
KISSAT_assert (solver->statistics.searches == 1);
|
||||
|
||||
init_enabled (solver);
|
||||
|
||||
|
|
@ -131,7 +133,7 @@ void kissat_init_limits (kissat *solver) {
|
|||
INIT_CONFLICT_LIMIT (probe, true);
|
||||
}
|
||||
|
||||
#ifndef QUIET
|
||||
#ifndef KISSAT_QUIET
|
||||
|
||||
static const char *delay_description (kissat *solver, delay *delay) {
|
||||
delays *delays = &solver->delays;
|
||||
|
|
@ -142,7 +144,7 @@ static const char *delay_description (kissat *solver, delay *delay) {
|
|||
else if (delay == &delays->sweep)
|
||||
return "sweeping";
|
||||
else {
|
||||
assert (delay == &delays->vivifyirr);
|
||||
KISSAT_assert (delay == &delays->vivifyirr);
|
||||
return "vivifying irredundant clauses";
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +162,7 @@ void kissat_reduce_delay (kissat *solver, delay *delay) {
|
|||
solver, "%s delay interval decreased to %u",
|
||||
delay_description (solver, delay), delay->current);
|
||||
delay->count = delay->current;
|
||||
#ifdef QUIET
|
||||
#ifdef KISSAT_QUIET
|
||||
(void) solver;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -171,7 +173,7 @@ void kissat_bump_delay (kissat *solver, delay *delay) {
|
|||
solver, "%s delay interval increased to %u",
|
||||
delay_description (solver, delay), delay->current);
|
||||
delay->count = delay->current;
|
||||
#ifdef QUIET
|
||||
#ifdef KISSAT_QUIET
|
||||
(void) solver;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -188,7 +190,9 @@ bool kissat_delaying (kissat *solver, delay *delay) {
|
|||
delay_description (solver, delay));
|
||||
return false;
|
||||
}
|
||||
#ifdef QUIET
|
||||
#ifdef KISSAT_QUIET
|
||||
(void) solver;
|
||||
#endif
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct bounds bounds;
|
||||
typedef struct changes changes;
|
||||
typedef struct delays delays;
|
||||
|
|
@ -114,12 +117,12 @@ double kissat_logn (uint64_t);
|
|||
do { \
|
||||
if (solver->inconsistent) \
|
||||
break; \
|
||||
const struct statistics *statistics = &solver->statistics; \
|
||||
assert (statistics->COUNT > 0); \
|
||||
const struct statistics *statistics = &solver->statistics_; \
|
||||
KISSAT_assert (statistics->COUNT > 0); \
|
||||
struct limits *limits = &solver->limits; \
|
||||
uint64_t DELTA = GET_OPTION (NAME##int); \
|
||||
const double SCALING = SCALE_COUNT_FUNCTION (statistics->COUNT); \
|
||||
assert (SCALING >= 1); \
|
||||
KISSAT_assert (SCALING >= 1); \
|
||||
DELTA *= SCALING; \
|
||||
const uint64_t SCALED = \
|
||||
!(SCALE_DELTA) ? DELTA \
|
||||
|
|
@ -135,8 +138,8 @@ double kissat_logn (uint64_t);
|
|||
#define SET_EFFORT_LIMIT(LIMIT, NAME, START) \
|
||||
uint64_t LIMIT; \
|
||||
do { \
|
||||
const uint64_t OLD_LIMIT = solver->statistics.START; \
|
||||
const uint64_t TICKS = solver->statistics.search_ticks; \
|
||||
const uint64_t OLD_LIMIT = solver->statistics_.START; \
|
||||
const uint64_t TICKS = solver->statistics_.search_ticks; \
|
||||
const uint64_t LAST = solver->probing ? solver->last.ticks.probe \
|
||||
: solver->last.ticks.eliminate; \
|
||||
uint64_t REFERENCE = TICKS - LAST; \
|
||||
|
|
@ -182,4 +185,6 @@ void kissat_reduce_delay (struct kissat *, delay *);
|
|||
#define REDUCE_DELAY(NAME) \
|
||||
kissat_reduce_delay (solver, &solver->delays.NAME)
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _kissat_h_INCLUDED
|
||||
#define _kissat_h_INCLUDED
|
||||
|
||||
#include "global.h"
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct kissat kissat;
|
||||
|
||||
// Default (partial) IPASIR interface.
|
||||
|
|
@ -41,4 +44,9 @@ void kissat_set_decision_limit (kissat *solver, unsigned);
|
|||
|
||||
void kissat_print_statistics (kissat *solver);
|
||||
|
||||
// Extra API functions.
|
||||
int kissat_is_inconsistent(kissat *solver);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,198 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [kissatSolver.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName []
|
||||
|
||||
Synopsis []
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
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 $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "kissat.h"
|
||||
#include "kissatSolver.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [allocate solver]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
kissat_solver* kissat_solver_new(void) {
|
||||
kissat_solver* s = (kissat_solver*)malloc(sizeof(kissat_solver));
|
||||
s->p = (void*)kissat_init();
|
||||
s->nVars = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [delete solver]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void kissat_solver_delete(kissat_solver* s) {
|
||||
kissat_release((kissat*)s->p);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/**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 []
|
||||
|
||||
***********************************************************************/
|
||||
int kissat_solver_addclause(kissat_solver* s, int* begin, int* end) {
|
||||
for(;begin != end; begin++) {
|
||||
if(*begin & 1) {
|
||||
kissat_add((kissat*)s->p, -(1 + ((*begin) >> 1)));
|
||||
} else {
|
||||
kissat_add((kissat*)s->p, 1 + ((*begin) >> 1) );
|
||||
}
|
||||
}
|
||||
kissat_add((kissat*)s->p, 0);
|
||||
return !kissat_is_inconsistent((kissat*)s->p);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [solve with resource limits]
|
||||
|
||||
Description [assumptions and inspection limits are not supported.]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
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) {
|
||||
// assumptions are not supported
|
||||
assert(begin == end);
|
||||
// inspection limits are not supported
|
||||
assert(nInsLimit == 0);
|
||||
assert(nInsLimitGlobal == 0);
|
||||
// set conflict limits
|
||||
if(nConfLimit)
|
||||
kissat_set_conflict_limit((kissat*)s->p, nConfLimit);
|
||||
if(nConfLimitGlobal && (nConfLimit == 0 || nConfLimit > nConfLimitGlobal))
|
||||
kissat_set_conflict_limit((kissat*)s->p, nConfLimitGlobal);
|
||||
// solve
|
||||
int res = kissat_solve((kissat*)s->p);
|
||||
// translate this kissat return value into a corresponding ABC status value
|
||||
switch(res) {
|
||||
case 0: // UNDETERMINED
|
||||
return 0;
|
||||
case 10: // SATISFIABLE
|
||||
return 1;
|
||||
case 20: // UNSATISFIABLE
|
||||
return -1;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [get number of variables]
|
||||
|
||||
Description [emulated using "nVars".]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int kissat_solver_nvars(kissat_solver* s) {
|
||||
return s->nVars;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [add new variable]
|
||||
|
||||
Description [emulated using "nVars".]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int kissat_solver_addvar(kissat_solver* s) {
|
||||
return s->nVars++;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [set number of variables]
|
||||
|
||||
Description [not only emulate with "nVars" but also reserve memory.]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void kissat_solver_setnvars(kissat_solver* s,int n) {
|
||||
s->nVars = n;
|
||||
kissat_reserve((kissat*)s->p, n);
|
||||
}
|
||||
|
||||
/**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 []
|
||||
|
||||
***********************************************************************/
|
||||
int kissat_solver_get_var_value(kissat_solver* s, int v) {
|
||||
return kissat_value((kissat*)s->p, v + 1) > 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [kissatSolver.h]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName []
|
||||
|
||||
Synopsis []
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
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 $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef ABC_SAT_KISSAT_SOLVER_H_
|
||||
#define ABC_SAT_KISSAT_SOLVER_H_
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// INCLUDES ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "aig/gia/gia.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// PARAMETERS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// BASIC TYPES ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct kissat_solver_ kissat_solver;
|
||||
struct kissat_solver_
|
||||
{
|
||||
void* p;
|
||||
int nVars;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// MACRO DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern kissat_solver* kissat_solver_new(void);
|
||||
extern void kissat_solver_delete(kissat_solver* s);
|
||||
extern int kissat_solver_addclause(kissat_solver* s, int* begin, int* end);
|
||||
extern 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 int kissat_solver_nvars(kissat_solver* s);
|
||||
extern int kissat_solver_addvar(kissat_solver* s);
|
||||
extern void kissat_solver_setnvars(kissat_solver* s,int n);
|
||||
extern int kissat_solver_get_var_value(kissat_solver* s, int v);
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [kissatTest.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName []
|
||||
|
||||
Synopsis []
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: kissatTest.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "kissatSolver.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void kissat_solver_test() {
|
||||
int RetValue;
|
||||
int Lits[3];
|
||||
// test 1
|
||||
{
|
||||
kissat_solver *pSat = kissat_solver_new();
|
||||
int a = kissat_solver_addvar(pSat);
|
||||
int b = kissat_solver_addvar(pSat);
|
||||
int c = kissat_solver_addvar(pSat);
|
||||
assert(kissat_solver_nvars(pSat) == 3);
|
||||
Lits[0] = Abc_Var2Lit(a, 0);
|
||||
Lits[1] = Abc_Var2Lit(b, 0);
|
||||
Lits[2] = Abc_Var2Lit(c, 0);
|
||||
printf("adding (a, b, c)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 3);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(a, 0);
|
||||
Lits[1] = Abc_Var2Lit(b, 1);
|
||||
printf("adding (a, !b)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 2);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(a, 1);
|
||||
printf("adding (!a)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 1);
|
||||
assert(RetValue);
|
||||
RetValue = kissat_solver_solve(pSat, NULL, NULL, 0, 0, 0, 0);
|
||||
printf("solved: %d\n", RetValue);
|
||||
assert(RetValue == 1);
|
||||
int a_val = kissat_solver_get_var_value(pSat, a);
|
||||
int b_val = kissat_solver_get_var_value(pSat, b);
|
||||
int c_val = kissat_solver_get_var_value(pSat, c);
|
||||
printf("a = %d, b = %d, c = %d\n", a_val, b_val, c_val);
|
||||
assert(a_val == 0);
|
||||
assert(b_val == 0);
|
||||
assert(c_val == 1);
|
||||
kissat_solver_delete(pSat);
|
||||
printf("test 1 passed\n");
|
||||
}
|
||||
// test 2
|
||||
{
|
||||
kissat_solver *pSat = kissat_solver_new();
|
||||
kissat_solver_setnvars(pSat, 2);
|
||||
assert(kissat_solver_nvars(pSat) == 2);
|
||||
Lits[0] = Abc_Var2Lit(0, 0);
|
||||
Lits[1] = Abc_Var2Lit(1, 0);
|
||||
printf("adding (x0, x1)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 2);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(0, 0);
|
||||
Lits[1] = Abc_Var2Lit(1, 1);
|
||||
printf("adding (x0, !x1)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 2);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(0, 1);
|
||||
Lits[1] = Abc_Var2Lit(1, 1);
|
||||
printf("adding (!x0, !x1)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 2);
|
||||
assert(RetValue);
|
||||
RetValue = kissat_solver_solve(pSat, NULL, NULL, 0, 0, 0, 0);
|
||||
printf("solved: %d\n", RetValue);
|
||||
assert(RetValue == 1);
|
||||
printf("x0 = %d, x1 = %d\n", kissat_solver_get_var_value(pSat, 0), kissat_solver_get_var_value(pSat, 1));
|
||||
assert(kissat_solver_get_var_value(pSat, 0) == 1);
|
||||
assert(kissat_solver_get_var_value(pSat, 1) == 0);
|
||||
kissat_solver_delete(pSat);
|
||||
printf("test 2 passed\n");
|
||||
}
|
||||
// test 3
|
||||
{
|
||||
kissat_solver *pSat = kissat_solver_new();
|
||||
kissat_solver_setnvars(pSat, 3);
|
||||
assert(kissat_solver_nvars(pSat) == 3);
|
||||
Lits[0] = Abc_Var2Lit(0, 1);
|
||||
Lits[1] = Abc_Var2Lit(1, 0);
|
||||
Lits[2] = Abc_Var2Lit(2, 1);
|
||||
printf("adding (!x0, x1, !x2)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 3);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(0, 0);
|
||||
printf("adding (x0)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 1);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(1, 1);
|
||||
printf("adding (!x1)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 1);
|
||||
assert(RetValue);
|
||||
Lits[0] = Abc_Var2Lit(2, 0);
|
||||
printf("adding (x2)\n");
|
||||
RetValue = kissat_solver_addclause(pSat, Lits, Lits + 1);
|
||||
RetValue = kissat_solver_solve(pSat, NULL, NULL, 0, 0, 0, 0);
|
||||
printf("solved: %d\n", RetValue);
|
||||
assert(RetValue == -1);
|
||||
kissat_solver_delete(pSat);
|
||||
printf("test 3 passed\n");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue