Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
arminbiere committed Sep 12, 2024
2 parents faa674e + 21f1459 commit 43f02cf
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 50 deletions.
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 4.0.1
-------------

- updated README to point to the 2024 system description
- removed redundant line in congruence closure
- fixed proof chain generation for matching ITE
- fixed getting size of watches for `--compact`
- more precise completion in congruence
- writing DIMACS to `<stdout>` with `-o -`
- fixed reporting in congruence
- fixed DIMACS writing

Version 4.0.0
-------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
4.0.1
62 changes: 43 additions & 19 deletions src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,30 +809,54 @@ static int run_application (kissat *solver, int argc, char **argv,
close_proof (&application);
#endif
kissat_section (solver, "result");
if (res == 20) {
printf ("s UNSATISFIABLE\n");
fflush (stdout);
} else if (res == 10) {
#ifndef NDEBUG
if (GET_OPTION (check))
kissat_check_satisfying_assignment (solver);
#endif
printf ("s SATISFIABLE\n");
fflush (stdout);
if (application.witness)
kissat_print_witness (solver, application.max_var,
application.partial);
if (application.output_path && !strcmp (application.output_path, "-")) {
const char *status;
if (res == 20)
status = "UNSATISFIABLE";
else if (res == 10)
status = "SATISFIABLE";
else
status = "UNKNOWN";
kissat_message (solver,
"not printing 's %s' status line "
"when writing DIMACS to '<stdout>'",
status);
} else {
printf ("s UNKNOWN\n");
fflush (stdout);
if (res == 20) {
printf ("s UNSATISFIABLE\n");
fflush (stdout);
} else if (res == 10) {
#ifndef NDEBUG
if (GET_OPTION (check))
kissat_check_satisfying_assignment (solver);
#endif
printf ("s SATISFIABLE\n");
fflush (stdout);
if (application.witness)
kissat_print_witness (solver, application.max_var,
application.partial);
} else {
printf ("s UNKNOWN\n");
fflush (stdout);
}
}
if (application.output_path) {
// TODO want to use 'struct file' from 'file.h'?
FILE *file = fopen (application.output_path, "w");
if (!file)
ERROR ("could not write DIMACS file '%s'", application.output_path);
const char *path = application.output_path;
bool close_file;
FILE *file;
if (!strcmp (path, "-")) {
close_file = false;
file = stdout;
} else {
close_file = true;
file = fopen (path, "w");
if (!file)
ERROR ("could not write DIMACS file '%s'", path);
}
kissat_write_dimacs (solver, file);
fclose (file);
if (close_file)
fclose (file);
}
#ifndef QUIET
kissat_print_statistics (solver);
Expand Down
4 changes: 1 addition & 3 deletions src/congruence.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,6 @@ static void add_binary_clause (closure *closure, unsigned a, unsigned b) {
unit = b;
else if (!a_value && b_value < 0)
unit = a;
else if (a == b)
unit = a;
if (unit != INVALID_LIT) {
(void) !learn_congruence_unit (closure, unit);
return;
Expand Down Expand Up @@ -1259,7 +1257,7 @@ static void add_ite_matching_proof_chain (closure *closure, gate *g,
PUSH_STACK (*unsimplified, cond);
SIMPLIFY_AND_ADD_TO_PROOF_CHAIN ();
unsimplified->end--;
PUSH_STACK (*unsimplified, cond);
PUSH_STACK (*unsimplified, not_cond);
SIMPLIFY_AND_ADD_TO_PROOF_CHAIN ();
unsimplified->end--;
SIMPLIFY_AND_ADD_TO_PROOF_CHAIN ();
Expand Down
39 changes: 27 additions & 12 deletions src/factor.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static double distinct_paths (factoring *factoring, unsigned src_lit,
const unsigned signed_src_lit = src_lit ^ sign;
watches *const watches = &WATCHES (signed_src_lit);
uint64_t ticks =
1 + kissat_cache_lines (SIZE_STACK (*watches), sizeof (watch));
1 + kissat_cache_lines (SIZE_WATCHES (*watches), sizeof (watch));
for (all_binary_large_watches (watch, *watches)) {
if (watch.type.binary) {
const unsigned other = watch.binary.lit;
Expand Down Expand Up @@ -559,7 +559,7 @@ static void factorize_next (factoring *factoring, unsigned next,
assert (min_lit != INVALID_LIT);
watches *min_watches = all_watches + min_lit;
unsigned c_size = c->size;
ticks += 1 + kissat_cache_lines (SIZE_STACK (*min_watches),
ticks += 1 + kissat_cache_lines (SIZE_WATCHES (*min_watches),
sizeof (watch));
for (all_binary_large_watches (min_watch, *min_watches)) {
if (min_watch.type.binary)
Expand Down Expand Up @@ -893,7 +893,7 @@ adjust_scores_and_phases_of_fresh_varaibles (factoring *factoring) {
}
}

static void run_factorization (kissat *solver, uint64_t limit) {
static bool run_factorization (kissat *solver, uint64_t limit) {
factoring factoring;
init_factoring (solver, &factoring, limit);
schedule_factorization (&factoring);
Expand All @@ -903,7 +903,7 @@ static void run_factorization (kissat *solver, uint64_t limit) {
#endif
uint64_t *ticks = &solver->statistics.factor_ticks;
kissat_extremely_verbose (
solver, "factorization limit of %" PRIu64 " ticks", limit);
solver, "factorization limit of %" PRIu64 " ticks", limit - *ticks);
while (!done && !kissat_empty_heap (&factoring.schedule)) {
const unsigned first =
kissat_pop_max_heap (solver, &factoring.schedule);
Expand Down Expand Up @@ -946,9 +946,11 @@ static void run_factorization (kissat *solver, uint64_t limit) {
}
release_quotients (&factoring);
}
bool completed = kissat_empty_heap (&factoring.schedule);
adjust_scores_and_phases_of_fresh_varaibles (&factoring);
release_factoring (&factoring);
REPORT (!factored, 'f');
return completed;
}

static void connect_clauses_to_factor (kissat *solver) {
Expand Down Expand Up @@ -1069,8 +1071,14 @@ void kissat_factor (kissat *solver) {
if (!GET_OPTION (factor))
return;
statistics *s = &solver->statistics;
if (solver->limits.factor.marked >= s->literals_factor)
if (solver->limits.factor.marked >= s->literals_factor) {
kissat_extremely_verbose (
solver,
"factorization skipped as no literals have been marked to be added "
"(%" PRIu64 " < %" PRIu64,
solver->limits.factor.marked, s->literals_factor);
return;
}
START (factor);
INC (factorizations);
kissat_phase (solver, "factorization", GET (factorizations),
Expand All @@ -1089,33 +1097,40 @@ void kissat_factor (kissat *solver) {
}
#ifndef QUIET
struct {
int64_t variables, clauses, ticks;
int64_t variables, binary, clauses, ticks;
} before, after, delta;
before.variables = s->variables_extension + s->variables_original;
before.clauses = BINARY_CLAUSES;
before.binary = BINARY_CLAUSES;
before.clauses = IRREDUNDANT_CLAUSES;
before.ticks = s->factor_ticks;
#endif
kissat_enter_dense_mode (solver, 0);
connect_clauses_to_factor (solver);
run_factorization (solver, limit);
bool completed = run_factorization (solver, limit);
kissat_resume_sparse_mode (solver, false, 0);
#ifndef QUIET
after.variables = s->variables_extension + s->variables_original;
after.clauses = BINARY_CLAUSES;
after.binary = BINARY_CLAUSES;
after.clauses = IRREDUNDANT_CLAUSES;
after.ticks = s->factor_ticks;
delta.variables = after.variables - before.variables;
delta.binary = before.binary - after.binary;
delta.clauses = before.clauses - after.clauses;
delta.ticks = before.ticks - after.ticks;
delta.ticks = after.ticks - before.ticks;
kissat_very_verbose (solver, "used %f million factorization ticks",
delta.ticks * 1e-6);
kissat_phase (solver, "factorization", GET (factorizations),
"introduced %" PRId64 " extension variables %.0f%%",
delta.variables,
kissat_percent (delta.variables, before.variables));
kissat_phase (solver, "factorization", GET (factorizations),
"removed %" PRId64 " binary clauses %.0f%%", delta.clauses,
"removed %" PRId64 " binary clauses %.0f%%", delta.binary,
kissat_percent (delta.binary, before.binary));
kissat_phase (solver, "factorization", GET (factorizations),
"removed %" PRId64 " large clauses %.0f%%", delta.clauses,
kissat_percent (delta.clauses, before.clauses));
#endif
solver->limits.factor.marked = s->literals_factor;
if (completed)
solver->limits.factor.marked = s->literals_factor;
STOP (factor);
}
38 changes: 27 additions & 11 deletions src/krite.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,34 @@
#include <inttypes.h>

void kissat_write_dimacs (kissat *solver, FILE *file) {
fprintf (file, "p cnf %u %" PRIu64 "\n", VARS, BINIRR_CLAUSES);
size_t imported = SIZE_STACK (solver->import);
if (imported)
imported--;
fprintf (file, "p cnf %zu %" PRIu64 "\n", imported, BINIRR_CLAUSES);
assert (solver->watching);
for (all_literals (ilit))
for (all_binary_large_watches (watch, WATCHES (ilit)))
if (watch.type.binary) {
const unsigned iother = watch.binary.lit;
if (iother < ilit)
continue;
const int elit = kissat_export_literal (solver, ilit);
const int eother = kissat_export_literal (solver, iother);
fprintf (file, "%d %d 0\n", elit, eother);
}
if (solver->watching) {
for (all_literals (ilit))
for (all_binary_blocking_watches (watch, WATCHES (ilit)))
if (watch.type.binary) {
const unsigned iother = watch.binary.lit;
if (iother < ilit)
continue;
const int elit = kissat_export_literal (solver, ilit);
const int eother = kissat_export_literal (solver, iother);
fprintf (file, "%d %d 0\n", elit, eother);
}
} else {
for (all_literals (ilit))
for (all_binary_large_watches (watch, WATCHES (ilit)))
if (watch.type.binary) {
const unsigned iother = watch.binary.lit;
if (iother < ilit)
continue;
const int elit = kissat_export_literal (solver, ilit);
const int eother = kissat_export_literal (solver, iother);
fprintf (file, "%d %d 0\n", elit, eother);
}
}
for (all_clauses (c))
if (!c->garbage && !c->redundant) {
for (all_literals_in_clause (ilit, c)) {
Expand Down
9 changes: 5 additions & 4 deletions test/testsolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ static void schedule_solve_job_with_option (int expected, const char *opt,
tissat_warning ("Skipping unreadable '%s'", path);
return;
}
char cmd[256];
assert (strlen (path) + strlen (opt) + 32 < sizeof cmd);
sprintf (cmd, "%s%s", opt, path);
assert (strlen (cmd) < sizeof cmd);
size_t len = strlen (opt) + strlen (path) + 1;
char * cmd = malloc (len);
strcpy (cmd, opt);
strcat (cmd, path);
tissat_schedule_application (expected, cmd);
free (cmd);
scheduled++;
}

Expand Down

0 comments on commit 43f02cf

Please sign in to comment.