ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
reduce.c File Reference
#include "reduce.h"
#include "allocate.h"
#include "collect.h"
#include "inline.h"
#include "print.h"
#include "rank.h"
#include "report.h"
#include "tiers.h"
#include "trail.h"
#include <inttypes.h>
#include <math.h>
Include dependency graph for reduce.c:

Go to the source code of this file.

Classes

struct  reducible
 

Macros

#define RANK_REDUCIBLE(RED)
 
#define USEFULNESS   RANK_REDUCIBLE
 

Typedefs

typedef struct reducible reducible
 

Functions

ABC_NAMESPACE_IMPL_START bool kissat_reducing (kissat *solver)
 
typedef STACK (reducible)
 
int kissat_reduce (kissat *solver)
 

Macro Definition Documentation

◆ RANK_REDUCIBLE

#define RANK_REDUCIBLE ( RED)
Value:
#define RED
Definition colors.h:19
unsigned rank
Definition vector.c:142

Definition at line 33 of file reduce.c.

◆ USEFULNESS

#define USEFULNESS   RANK_REDUCIBLE

Definition at line 98 of file reduce.c.

Typedef Documentation

◆ reducible

typedef struct reducible reducible

Definition at line 26 of file reduce.c.

Function Documentation

◆ kissat_reduce()

int kissat_reduce ( kissat * solver)

Definition at line 155 of file reduce.c.

155 {
156 START (reduce);
157 INC (reductions);
158 kissat_phase (solver, "reduce", GET (reductions),
159 "reduce limit %" PRIu64 " hit after %" PRIu64 " conflicts",
160 solver->limits.reduce.conflicts, CONFLICTS);
162 bool compact = kissat_compacting (solver);
163 reference start = compact ? 0 : solver->first_reducible;
164 if (start != INVALID_REF) {
165#ifndef KISSAT_QUIET
166 size_t arena_size = SIZE_STACK (solver->arena);
167 size_t words_to_sweep = arena_size - start;
168 size_t bytes_to_sweep = sizeof (word) * words_to_sweep;
169 kissat_phase (solver, "reduce", GET (reductions),
170 "reducing clauses after offset %" REFERENCE_FORMAT
171 " in arena",
172 start);
173 kissat_phase (solver, "reduce", GET (reductions),
174 "reducing %zu words %s %.0f%%", words_to_sweep,
175 FORMAT_BYTES (bytes_to_sweep),
176 kissat_percent (words_to_sweep, arena_size));
177#endif
179 reducibles reds;
180 INIT_STACK (reds);
181 if (collect_reducibles (solver, &reds, start)) {
182 sort_reducibles (solver, &reds);
183 mark_less_useful_clauses_as_garbage (solver, &reds);
184 RELEASE_STACK (reds);
185 kissat_sparse_collect (solver, compact, start);
186 } else if (compact)
187 kissat_sparse_collect (solver, compact, start);
188 else
190 } else
191 KISSAT_assert (solver->inconsistent);
192 } else
193 kissat_phase (solver, "reduce", GET (reductions), "nothing to reduce");
195 UPDATE_CONFLICT_LIMIT (reduce, reductions, SQRT, false);
196 solver->last.conflicts.reduce = CONFLICTS;
197 REPORT (0, '-');
198 STOP (reduce);
199 return solver->inconsistent ? 20 : 0;
200}
#define SIZE_STACK(S)
Definition stack.h:19
#define RELEASE_STACK(S)
Definition stack.h:71
#define INIT_STACK(S)
Definition stack.h:22
#define INC(NAME)
ABC_NAMESPACE_IMPL_START void kissat_classify(struct kissat *solver)
Definition classify.c:7
bool kissat_compacting(kissat *solver)
Definition collect.c:635
void kissat_sparse_collect(kissat *solver, bool compact, reference start)
Definition collect.c:610
pcover reduce()
#define FORMAT_BYTES(BYTES)
Definition format.h:31
#define SQRT(COUNT)
Definition kimits.h:113
#define UPDATE_CONFLICT_LIMIT(NAME, COUNT, SCALE_COUNT_FUNCTION, SCALE_DELTA)
Definition kimits.h:115
#define KISSAT_assert(ignore)
Definition global.h:13
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define solver
Definition kitten.c:211
#define kissat_phase(...)
Definition print.h:48
#define STOP(P)
Definition profile.hpp:158
#define START(P)
Definition profile.hpp:150
#define INVALID_REF
Definition reference.h:16
ABC_NAMESPACE_HEADER_START typedef unsigned reference
Definition reference.h:9
#define REFERENCE_FORMAT
Definition reference.h:11
#define REPORT(...)
Definition report.h:10
#define CONFLICTS
Definition statistics.h:335
#define GET(NAME)
Definition statistics.h:416
void kissat_compute_and_set_tier_limits(struct kissat *solver)
Definition tiers.c:53
void kissat_unmark_reason_clauses(kissat *solver, reference start)
Definition trail.c:66
bool kissat_flush_and_mark_reason_clauses(kissat *solver, reference start)
Definition trail.c:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_reducing()

ABC_NAMESPACE_IMPL_START bool kissat_reducing ( kissat * solver)

Definition at line 16 of file reduce.c.

16 {
17 if (!GET_OPTION (reduce))
18 return false;
19 if (!solver->statistics_.clauses_redundant)
20 return false;
22 return false;
23 return true;
24}
#define GET_OPTION(N)
Definition options.h:295
struct limits::@317277023072347355124305102271146250361353123031 reduce
uint64_t conflicts
Definition kimits.h:27
Here is the call graph for this function:
Here is the caller graph for this function:

◆ STACK()

typedef STACK ( reducible )

Definition at line 36 of file reduce.c.

40 {
41 KISSAT_assert (start_ref != INVALID_REF);
42 KISSAT_assert (start_ref <= SIZE_STACK (solver->arena));
43 ward *const arena = BEGIN_STACK (solver->arena);
44 clause *start = (clause *) (arena + start_ref);
45 const clause *const end = (clause *) END_STACK (solver->arena);
46 KISSAT_assert (start < end);
47 while (start != end && !start->redundant)
48 start = kissat_next_clause (start);
49 if (start == end) {
50 solver->first_reducible = INVALID_REF;
51 LOG ("no reducible clause candidate left");
52 return false;
53 }
54 const reference redundant = (ward *) start - arena;
55#ifdef LOGGING
56 if (redundant < solver->first_reducible)
57 LOG ("updating start of redundant clauses from %zu to %zu",
58 (size_t) solver->first_reducible, (size_t) redundant);
59 else
60 LOG ("no update to start of redundant clauses %zu",
61 (size_t) solver->first_reducible);
62#endif
63 solver->first_reducible = redundant;
64 const unsigned tier1 = TIER1;
65 const unsigned tier2 = MAX (tier1, TIER2);
66 KISSAT_assert (tier1 <= tier2);
67 for (clause *c = start; c != end; c = kissat_next_clause (c)) {
68 if (!c->redundant)
69 continue;
70 if (c->garbage)
71 continue;
72 const unsigned used = c->used;
73 if (used)
74 c->used = used - 1;
75 if (c->reason)
76 continue;
77 const unsigned glue = c->glue;
78 if (glue <= tier1 && used)
79 continue;
80 if (glue <= tier2 && used >= MAX_USED - 1)
81 continue;
82 KISSAT_assert (kissat_clause_in_arena (solver, c));
83 reducible red;
84 const uint64_t negative_size = ~c->size;
85 const uint64_t negative_glue = ~c->glue;
86 red.rank = negative_size | (negative_glue << 32);
87 red.ref = (ward *) c - arena;
88 PUSH_STACK (*reds, red);
89 }
90 if (EMPTY_STACK (*reds)) {
91 kissat_phase (solver, "reduce", GET (reductions),
92 "did not find any reducible redundant clause");
93 return false;
94 }
95 return true;
96}
ABC_NAMESPACE_HEADER_START typedef word ward
Definition arena.h:12
#define MAX(a, b)
Definition avl.h:23
#define BEGIN_STACK(S)
Definition stack.h:46
#define EMPTY_STACK(S)
Definition stack.h:18
#define PUSH_STACK(S, E)
Definition stack.h:39
#define END_STACK(S)
Definition stack.h:48
#define LOG(...)
#define TIER1
Definition internal.h:258
#define TIER2
Definition internal.h:259
#define MAX_USED
Definition clause.h:20
bool redundant
Definition clause.h:28
unsigned ref
Definition reduce.c:30
uint64_t rank
Definition reduce.c:29