Skip to content

Commit c7c5e52

Browse files
committed
There is no safe way of doing BCE with redundant clauses. Disabling
1 parent 236a321 commit c7c5e52

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/arjun.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ DLL_PUBLIC void Arjun::standalone_sbva(SimplifiedCNF& orig,
178178
puura.run_sbva(orig, sbva_steps, sbva_cls_cutoff, sbva_lits_cutoff, sbva_tiebreak);
179179
}
180180

181+
// DELETES ALL REDUNDANT CLAUSES!!!
182+
// This is a must, because it's impossible to ascertain
183+
// which redundant clauses are actually deriveable from the irred clauses
184+
// after deletion. Sad.
181185
DLL_PUBLIC void Arjun::standalone_bce(SimplifiedCNF& cnf) {
186+
SLOW_DEBUG_DO(cnf.check_red_cls_deriveable());
187+
182188
// Unfortunately, with opt_sampling_set, we rely on a variables
183189
// being fully deterministic. So we can't block on them
184190
// otherwise we'd need to remove those variables from the opt_sampling set
@@ -192,32 +198,31 @@ DLL_PUBLIC void Arjun::standalone_bce(SimplifiedCNF& cnf) {
192198
vector<vector<uint32_t>> occs(cnf.nVars()*2);
193199
uint32_t at = 0;
194200
for(const auto& cl: cnf.get_clauses()) {
195-
// UNSAT CNF, just return the CNF
196-
if (cl.empty()) return;
201+
if (cl.empty()) {
202+
// Empty clause, CNF is unsat, skip BCE
203+
return;
204+
}
197205

198206
SimplifiedCNF::BCEClause c;
199207
c.lits = cl;
200208
c.at = at;
201-
c.red = false;
209+
assert(cls.size() == at);
202210
cls.push_back(c);
203211
for(const auto& l: cl) occs[l.toInt()].push_back(at);
204212
assert(cl.size() > 1 && "CNF must be simplified for BCE");
205213
at++;
206214
}
207215

208216
vector<uint8_t> seen;
209-
vector<uint64_t> also_must_remove;
210217
seen.resize(cnf.nVars()*2, 0);
211218

212219
uint32_t tot_removed = 0;
213220
bool removed_one;
214221
do {
215222
removed_one = false;
216223
for(auto& cl: cls) {
217-
if (cl.red) continue;
218224
if (cl.to_remove) continue;
219225

220-
also_must_remove.clear();
221226
bool can_remove = false;
222227
for(const auto& l: cl.lits) seen[l.toInt()] = true;
223228
for(const auto& l: cl.lits) {
@@ -226,10 +231,6 @@ DLL_PUBLIC void Arjun::standalone_bce(SimplifiedCNF& cnf) {
226231
for(const auto& cl2_at: occs[(~l).toInt()]) {
227232
const SimplifiedCNF::BCEClause& cl2 = cls[cl2_at];
228233
if (cl2.to_remove) continue;
229-
if (cl2.red) {
230-
also_must_remove.push_back(cl2_at);
231-
continue;
232-
}
233234
bool found_blocking_lit = false;
234235
for(const auto& l2: cl2.lits) {
235236
if (l2 == ~l) continue;
@@ -242,7 +243,6 @@ DLL_PUBLIC void Arjun::standalone_bce(SimplifiedCNF& cnf) {
242243
for(const auto& l: cl.lits) seen[l.toInt()] = 0;
243244
if (can_remove) {
244245
cl.to_remove = true;
245-
for(const auto& i: also_must_remove) cls[i].to_remove = true;
246246
removed_one = true;
247247
tot_removed++;
248248
}
@@ -252,6 +252,7 @@ DLL_PUBLIC void Arjun::standalone_bce(SimplifiedCNF& cnf) {
252252

253253
verb_print2(1, "[arjun] BCE removed " << tot_removed << " clauses"
254254
" T: " << (cpuTime() - start_time));
255+
SLOW_DEBUG_DO(cnf.check_red_cls_deriveable());
255256
}
256257

257258
DLL_PUBLIC void Arjun::standalone_backbone(SimplifiedCNF& cnf) {

src/arjun.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,18 +1241,18 @@ class SimplifiedCNF {
12411241
void replace_clauses_with(std::vector<int>& ret, uint32_t new_nvars, uint32_t new_nclauses);
12421242

12431243
// Used after BCE to replace clauses
1244+
// DELETES ALL REDUNDANT CLAUSES!!!
12441245
struct BCEClause {
12451246
uint32_t at = std::numeric_limits<uint32_t>::max();
12461247
std::vector<CMSat::Lit> lits;
1247-
bool red = false;
12481248
bool to_remove = false;
12491249
};
12501250
void replace_clauses_with(std::vector<BCEClause>& cls) {
12511251
clauses.clear();
1252+
red_clauses.clear(); // Yes, it's necessary
12521253
for(const auto& cl: cls) {
12531254
if (cl.to_remove) continue;
1254-
if (!cl.red) add_clause(cl.lits);
1255-
else add_red_clause(cl.lits);
1255+
add_clause(cl.lits);
12561256
}
12571257
}
12581258
void set_after_backward_round_synth() {

0 commit comments

Comments
 (0)