Skip to content

Commit e220830

Browse files
committed
Fix unate query construction
1 parent fa4e987 commit e220830

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/main.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -494,40 +494,40 @@ void add_fixed_clauses()
494494
//it is now a pointer to a intvec
495495
solver->new_var();
496496
this_indic=solver-> nVars()-1;
497-
tmp.clear();
498-
tmp.push_back(Lit(this_indic,false));
499497
zvariables.push_back(this_indic);
500498
for(intvec::iterator jt = it->begin(); jt != it->end(); ++jt)
501499
{
502500

503-
504501
// jt is now a pointer to an integer.
505502

506503
var=std::abs(*jt)-1;
504+
Lit lit_prime;
507505
if (Yvar_to_Ypvar.count(var)>0) {
508506
if (*jt>0){
509-
tmp.push_back(Lit(Yvar_to_Ypvar[var],false));}
510-
else {
511-
tmp.push_back(Lit(Yvar_to_Ypvar[var],true));} }
512-
else {
513-
find_var = find(x_vars.begin(), x_vars.end(), var);
514-
if(find_var!=x_vars.end())
515-
{
516-
if (*jt>0){
517-
tmp.push_back(Lit(var,false));}
518-
else {
519-
tmp.push_back(Lit(var,true));}
507+
lit_prime = Lit(Yvar_to_Ypvar[var], false);
508+
} else {
509+
lit_prime = Lit(Yvar_to_Ypvar[var], true);
510+
}
511+
} else {
512+
// Keep all non-Y literals (treat them as X) in the ~F(X,Y') copy
513+
if (*jt>0){
514+
lit_prime = Lit(var,false);
515+
} else {
516+
lit_prime = Lit(var,true);
520517
}
521-
522-
523-
}}
524-
solver->add_clause(tmp);
525-
if (conf.verb){cout<<"adding clause : "<<tmp <<endl;}
518+
}
519+
// Encode: z -> ~lit_prime === (¬z ∨ ¬lit_prime)
520+
tmp.clear();
521+
tmp.push_back(Lit(this_indic, true)); // ¬z
522+
tmp.push_back(~lit_prime);
523+
solver->add_clause(tmp);
524+
if (conf.verb){cout<<"adding clause : "<<tmp <<endl;}
525+
}
526526
}
527527
tmp.clear();
528528
for(uint32_t i = 0; i < zvariables.size() ; i++) {
529-
tmp.push_back(Lit(zvariables[i],true));
530-
529+
// At least one clause must be falsified: z1 ∨ z2 ∨ ...
530+
tmp.push_back(Lit(zvariables[i], false));
531531
}
532532
solver->add_clause(tmp);
533533
if (conf.verb){cout<<"adding clause : "<<tmp <<endl;}

0 commit comments

Comments
 (0)