@@ -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.
181185DLL_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
257258DLL_PUBLIC void Arjun::standalone_backbone (SimplifiedCNF& cnf) {
0 commit comments