Skip to content

Commit a34f3fb

Browse files
committed
Some minor fixed and improvements
1 parent fc3b0fa commit a34f3fb

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

src/arjun.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ DLL_PUBLIC void SimplifiedCNF::get_bve_mapping(SimplifiedCNF& scnf, unique_ptr<C
322322
}
323323
bool sign = neg > pos;
324324

325-
auto overall = scnf.aig_mng.new_const(false);
325+
aig_ptr overall = nullptr;
326326
for(const auto& cl: orig_def) {
327327
auto current = scnf.aig_mng.new_const(true);
328328

@@ -341,9 +341,12 @@ DLL_PUBLIC void SimplifiedCNF::get_bve_mapping(SimplifiedCNF& scnf, unique_ptr<C
341341
auto aig = AIG::new_lit(~l);
342342
current = AIG::new_and(current, aig);
343343
}
344-
overall = AIG::new_or(overall, current);
344+
if (overall == nullptr) overall = current;
345+
else overall = AIG::new_or(overall, current);
345346
}
346-
if (sign ^ orig_target.sign()) overall = AIG::new_not(overall);
347+
if (overall == nullptr) overall = scnf.aig_mng.new_const(false);
348+
if (sign ^ orig_target.sign()) overall->flip();
349+
347350
scnf.defs[orig_target.var()] = overall;
348351
if (verb >= 5)
349352
cout << "c o [bve-aig] set aig for var: " << orig_target << " from bve elim: " << overall << endl;

src/arjun.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class AIG {
6262
AIG(const AIG&) = delete;
6363
AIG& operator=(const AIG&) = delete;
6464

65+
void flip() { neg = !neg; }
66+
6567
bool invariants() const {
6668
if (type == AIGT::t_lit) {
6769
if (l != nullptr || r != nullptr) std::cout << "ERROR: AIG literal has children!" << std::endl;

src/manthan.cpp

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ vector<int> lits_to_ints(const vector<Lit>& lits) {
8484
// LOTS of repairs, fast, but does not terminate: benchmarks-qdimacs/query01_query42_1344n.qdimacs.cnf
8585
// many repairs, does finish: benchmarks-qdimacs/stmt32_329_378.qdimacs.cnf
8686
// many-many repairs, does finish: benchmarks-qdimacs/sdlx-fixpoint-10.qdimacs.cnf
87+
// no repair, learning/mbve does it: rankfunc57_unsigned_64.qdimacs.cnf
8788

8889
template<typename S>
8990
void Manthan::inject_cnf(S& s, bool also_vars) const {
@@ -396,7 +397,7 @@ void Manthan::print_y_order_occur() const {
396397
for(const auto& y: y_order) {
397398
const uint32_t pos = occur_lit[Lit(y, false).toInt()];
398399
const uint32_t neg = occur_lit[Lit(y, true).toInt()];
399-
verb_print(2, "[y-order] var " << setw(4) << y+1
400+
verb_print(2, "[manthan] y-order var " << setw(4) << y+1
400401
<< " BW: " << backward_defined.count(y)
401402
<< " pos occur " << setw(6) << pos
402403
<< " -- neg occur " << setw(6) << neg);
@@ -578,22 +579,26 @@ void Manthan::bve_and_substitute() {
578579

579580
FHolder::Formula f;
580581
map<uint32_t, aig_ptr> transformed;
581-
auto overall = aig_mng.new_const(false);
582582

583583
// For optimizing which side of the BVE to take
584-
/* uint32_t num_pos = 0; */
585-
/* uint32_t num_neg = 0; */
586-
/* for(const auto& cl: cnf.get_clauses()) { */
587-
/* for(const auto& l: cl) { */
588-
/* if (l.var() == v) { */
589-
/* if (l.sign()) num_neg++; */
590-
/* else num_pos++; */
591-
/* break; */
592-
/* } */
593-
/* } */
594-
/* } */
595-
/* bool sign = (num_pos >= num_neg); */
596-
bool sign = false;
584+
uint32_t num_pos = 0;
585+
uint32_t num_neg = 0;
586+
for(const auto& cl: cnf.get_clauses()) {
587+
for(const auto& l: cl) {
588+
if (l.var() == v) {
589+
if (l.sign()) num_neg++;
590+
else num_pos++;
591+
break;
592+
}
593+
}
594+
}
595+
verb_print(2, "[manthan] bve var " << setw(5) << v+1
596+
<< " pos occur: " << setw(6) << num_pos
597+
<< " neg occur: " << setw(6) << num_neg);
598+
599+
const bool sign = (num_pos >= num_neg);
600+
/* const bool sign = false; */
601+
aig_ptr overall = nullptr;
597602
for(const auto& cl: cnf.get_clauses()) {
598603
bool todo = false;
599604
for(const auto& l: cl) {
@@ -622,9 +627,11 @@ void Manthan::bve_and_substitute() {
622627
}
623628
}
624629
}
625-
overall = AIG::new_or(overall, current);
626-
if (sign) overall = AIG::new_not(overall);
630+
if (overall == nullptr) overall = current;
631+
else overall = AIG::new_or(overall, current);
627632
}
633+
if (overall == nullptr) overall = aig_mng.new_const(true);
634+
if (sign) overall->flip();
628635

629636
f.aig = AIG::simplify(overall);
630637
var_to_formula[v] = f;

src/puura.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void Puura::synthesis_unate(SimplifiedCNF& cnf) {
144144
var_to_indic.clear();
145145
var_to_indic.resize(cnf.nVars(), var_Undef);
146146
for(uint32_t i = 0; i < orig_num_vars; i++) {
147-
if (input.count(i)) continue;
147+
if (sampl_set.count(i)) continue;
148148
s->new_var();
149149
const Lit ind_l = Lit(s->nVars()-1, false);
150150

0 commit comments

Comments
 (0)