267 {
269 unsigned not_lit =
NOT (
lit);
270
271 bool update = false;
272 bool pure = false;
273 uint64_t limit;
274
275 {
276 unsigned pos_count = occurrences_literal (
solver,
lit, &update);
277 unsigned neg_count = occurrences_literal (
solver, not_lit, &update);
278
279 if (pos_count > neg_count) {
281 SWAP (
size_t, pos_count, neg_count);
282 }
283
284 const unsigned occlim =
GET_OPTION (eliminateocclim);
285 limit = pos_count + (uint64_t) neg_count;
286
287 if (pos_count && limit > occlim) {
288 LOG (
"no elimination of variable %u "
289 "since it has %" PRIu64 " > %u occurrences",
290 idx, limit, occlim);
291 return false;
292 }
293
294 if (pos_count) {
295 const uint64_t bound =
solver->bounds.eliminate.additional_clauses;
296 limit += bound;
297 LOG (
"trying to eliminate %s "
298 "limit %" PRIu64 " bound %" PRIu64,
299 LOGVAR (idx), limit, bound);
300 } else {
301 LOG (
"eliminating pure literal %s thus its variable %u",
LOGLIT (
lit),
302 idx);
303 pure = true;
304 }
305 }
306
308
309 INC (eliminate_attempted);
310 if (pure)
311 return true;
312
314
315 statches *
const gates0 = &
solver->gates[0];
316 statches *
const gates1 = &
solver->gates[1];
317
322 return false;
323 }
324
325 bool failed = false;
326 uint64_t resolved = 0;
327
329 statches *
const antecedents0 = &
solver->antecedents[0];
330 statches *
const antecedents1 = &
solver->antecedents[1];
331
332 if (gates) {
333 LOG (
"resolving gates[0] against antecedents[1] clauses");
334 if (!generate_resolvents (
solver,
lit, gates0, antecedents1, &resolved,
335 limit))
336 failed = true;
337 else {
338 LOG (
"resolving gates[1] against antecedents[0] clauses");
339 if (!generate_resolvents (
solver, not_lit, gates1, antecedents0,
340 &resolved, limit)) {
341 failed = true;
342 }
else if (
solver->resolve_gate) {
343 LOG (
"need to resolved gates[0] against gates[1] too");
344 if (!generate_resolvents (
solver,
lit, gates0, gates1, &resolved,
345 limit))
346 failed = true;
347 }
348 }
349 } else {
350 LOG (
"no gate extracted thus resolving all clauses");
351 if (!generate_resolvents (
solver,
lit, antecedents0, antecedents1,
352 &resolved, limit))
353 failed = true;
354 }
355
358
359 if (failed) {
360 LOG (
"elimination of %s failed", LOGVAR (
IDX (
lit)));
362 if (update)
364 }
365
366 LOG (
"resolved %" PRIu64
" resolvents", resolved);
367
370
371 return !failed;
372}
void kissat_update_variable_score(kissat *solver, unsigned idx)
bool kissat_find_gates(kissat *solver, unsigned lit)
void kissat_get_antecedents(kissat *solver, unsigned lit)
#define kissat_extremely_verbose(...)