36 snprintf(buffer, 64,
"%d", i);
39 return std::to_string(i);
104 std::vector<int>
args(6);
105 args[0] = a, args[1] = b, args[2] = c;
106 args[3] = d, args[4] = e, args[5] = f;
112 std::vector<int> myArgs;
113 myArgs.reserve(args.size());
114 bool xorRemovedOddTrues =
false;
116 for (
auto arg : args)
125 xorRemovedOddTrues = !xorRemovedOddTrues;
128 myArgs.push_back(arg);
134 for (
int i = 1; i < int(myArgs.size()); i++)
135 if (j < 0 || myArgs[j] != myArgs[i])
136 myArgs[++j] = myArgs[i];
137 else if (op ==
OpXor)
145 assert(myArgs.size() == 1);
153 if (myArgs.size() == 0)
155 if (myArgs.size() == 1)
160 if (myArgs.size() == 0)
162 if (myArgs.size() == 1)
167 if (myArgs.size() == 0)
169 if (myArgs.size() == 1)
170 return xorRemovedOddTrues ?
NOT(myArgs[0]) : myArgs[0];
174 assert(myArgs.size() >= 1);
175 if (myArgs.size() == 1)
181 assert(myArgs.size() == 3);
192 std::pair<OpId, std::vector<int>> myExpr(op, myArgs);
203 return xorRemovedOddTrues ?
NOT(
id) :
id;
208 assert(0 <
id &&
id <=
int(
literals.size()));
214 assert(0 <
id &&
id <=
int(
literals.size()));
248 std::vector<int>
args;
281 for (
int i = 0; i < int(args.size()); i++) {
296 if (
id <=
int(values.size()) && (values[
id-1] ==
CONST_TRUE || values[
id-1] ==
CONST_FALSE || values[
id-1] == 0))
308 assert(args.size() == 1);
309 a =
eval(args[0], values);
317 for (
auto arg : args) {
318 b =
eval(arg, values);
327 for (
auto arg : args) {
328 b =
eval(arg, values);
337 for (
auto arg : args) {
338 b =
eval(arg, values);
346 assert(args.size() > 0);
347 a =
eval(args[0], values);
348 for (
auto arg : args) {
349 b =
eval(arg, values);
357 assert(args.size() == 3);
358 a =
eval(args[0], values);
360 return eval(args[1], values);
362 return eval(args[2], values);
398 std::vector<int>
args;
403 cnfClauses.push_back(std::vector<int>(1, -idx));
408 std::vector<int> clause;
410 clause.push_back(
bind(arg));
416 for (
int arg : args) {
426 cnfClauses.push_back(std::vector<int>(1, idx));
438 std::vector<int> clause;
439 for (
auto arg : args)
440 clause.push_back(argsPolarity ? +arg : -arg);
452 std::vector<int> clause;
464 assert(args.size() == 1);
470 assert(args.size() >= 2);
475 for (
auto arg : args)
483 assert(args.size() >= 2);
488 for (
auto arg : args)
523 assert(0 <
id &&
id <=
int(
literals.size()));
526 fprintf(stderr,
"ezSAT: Missing freeze on literal `%s'.\n",
to_string(
id).c_str());
556 std::vector<int>
args;
561 while (args.size() > 1) {
562 std::vector<int> newArgs;
563 for (
int i = 0; i < int(args.size()); i += 2)
564 if (i+1 ==
int(args.size()))
565 newArgs.push_back(args[i]);
567 newArgs.push_back(
OR(
AND(args[i],
NOT(args[i+1])),
AND(
NOT(args[i]), args[i+1])));
570 idx =
bind(args.at(0),
false);
575 std::vector<int> invArgs;
576 for (
auto arg : args)
577 invArgs.push_back(
NOT(arg));
583 idx =
bind(
OR(
AND(args[0], args[1]),
AND(
NOT(args[0]), args[2])),
false);
587 for (
int i = 0; i < int(args.size()); i++)
588 args[i] =
bind(args[i],
false);
627 assert(full_cnf.empty());
639 bool ezSAT::solver(
const std::vector<int>&, std::vector<bool>&,
const std::vector<int>&)
642 fprintf(stderr,
"************************************************************************\n");
643 fprintf(stderr,
"ERROR: You are trying to use the solve() method of the ezSAT base class!\n");
644 fprintf(stderr,
"Use a dervied class like ezMiniSAT instead.\n");
645 fprintf(stderr,
"************************************************************************\n");
651 std::vector<int>
vec;
652 for (
auto bit : bits)
659 std::vector<int>
vec;
660 for (
int i = 0; i < numBits; i++)
667 std::vector<int>
vec;
668 for (
int i = 0; i < numBits; i++)
675 std::vector<int>
vec;
676 for (
int i = 0; i < numBits; i++)
683 std::vector<int>
vec;
684 for (
int i = 0; i < numBits; i++) {
690 std::vector<int>
ezSAT::vec_cast(
const std::vector<int> &vec1,
int toBits,
bool signExtend)
692 std::vector<int>
vec;
693 for (
int i = 0; i < toBits; i++)
694 if (i >=
int(vec1.size()))
695 vec.push_back(signExtend ? vec1.back() :
CONST_FALSE);
697 vec.push_back(vec1[i]);
703 std::vector<int>
vec;
704 for (
auto bit : vec1)
709 std::vector<int>
ezSAT::vec_and(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
711 assert(vec1.size() == vec2.size());
712 std::vector<int>
vec(vec1.size());
713 for (
int i = 0; i < int(vec1.size()); i++)
714 vec[i] =
AND(vec1[i], vec2[i]);
718 std::vector<int>
ezSAT::vec_or(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
720 assert(vec1.size() == vec2.size());
721 std::vector<int>
vec(vec1.size());
722 for (
int i = 0; i < int(vec1.size()); i++)
723 vec[i] =
OR(vec1[i], vec2[i]);
727 std::vector<int>
ezSAT::vec_xor(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
729 assert(vec1.size() == vec2.size());
730 std::vector<int>
vec(vec1.size());
731 for (
int i = 0; i < int(vec1.size()); i++)
732 vec[i] =
XOR(vec1[i], vec2[i]);
736 std::vector<int>
ezSAT::vec_iff(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
738 assert(vec1.size() == vec2.size());
739 std::vector<int>
vec(vec1.size());
740 for (
int i = 0; i < int(vec1.size()); i++)
741 vec[i] =
IFF(vec1[i], vec2[i]);
745 std::vector<int>
ezSAT::vec_ite(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
const std::vector<int> &vec3)
747 assert(vec1.size() == vec2.size() && vec2.size() == vec3.size());
748 std::vector<int>
vec(vec1.size());
749 for (
int i = 0; i < int(vec1.size()); i++)
750 vec[i] =
ITE(vec1[i], vec2[i], vec3[i]);
755 std::vector<int>
ezSAT::vec_ite(
int sel,
const std::vector<int> &vec1,
const std::vector<int> &vec2)
757 assert(vec1.size() == vec2.size());
758 std::vector<int>
vec(vec1.size());
759 for (
int i = 0; i < int(vec1.size()); i++)
760 vec[i] =
ITE(sel, vec1[i], vec2[i]);
767 int tmp = that->
XOR(a, b);
768 int new_x = that->
XOR(tmp, c);
769 int new_y = that->
OR(that->
AND(a, b), that->
AND(c, tmp));
771 printf(
"FULLADD> a=%s, b=%s, c=%s, carry=%s, sum=%s\n", that->
to_string(a).c_str(), that->
to_string(b).c_str(),
774 x = new_x, y = new_y;
780 int new_x = that->
XOR(a, b);
781 int new_y = that->
AND(a, b);
783 printf(
"HALFADD> a=%s, b=%s, carry=%s, sum=%s\n", that->
to_string(a).c_str(), that->
to_string(b).c_str(),
786 x = new_x, y = new_y;
792 std::vector<int> carry_vector;
794 for (
auto bit : vec) {
796 for (
int i = 0; i < numBits; i++)
797 halfadder(
this, carry, sum[i], carry, sum[i]);
798 carry_vector.push_back(carry);
807 printf(
"COUNT> vec=[");
808 for (
int i =
int(vec.size())-1; i >= 0; i--)
809 printf(
"%s%s",
to_string(vec[i]).c_str(), i ?
", " :
"");
810 printf(
"], result=[");
811 for (
int i =
int(sum.size())-1; i >= 0; i--)
812 printf(
"%s%s",
to_string(sum[i]).c_str(), i ?
", " :
"");
819 std::vector<int>
ezSAT::vec_add(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
821 assert(vec1.size() == vec2.size());
822 std::vector<int>
vec(vec1.size());
824 for (
int i = 0; i < int(vec1.size()); i++)
825 fulladder(
this, vec1[i], vec2[i], carry, carry,
vec[i]);
828 printf(
"ADD> vec1=[");
829 for (
int i =
int(vec1.size())-1; i >= 0; i--)
830 printf(
"%s%s",
to_string(vec1[i]).c_str(), i ?
", " :
"");
832 for (
int i =
int(vec2.size())-1; i >= 0; i--)
833 printf(
"%s%s",
to_string(vec2[i]).c_str(), i ?
", " :
"");
834 printf(
"], result=[");
835 for (
int i =
int(
vec.size())-1; i >= 0; i--)
836 printf(
"%s%s",
to_string(
vec[i]).c_str(), i ?
", " :
"");
843 std::vector<int>
ezSAT::vec_sub(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
845 assert(vec1.size() == vec2.size());
846 std::vector<int>
vec(vec1.size());
848 for (
int i = 0; i < int(vec1.size()); i++)
852 printf(
"SUB> vec1=[");
853 for (
int i =
int(vec1.size())-1; i >= 0; i--)
854 printf(
"%s%s",
to_string(vec1[i]).c_str(), i ?
", " :
"");
856 for (
int i =
int(vec2.size())-1; i >= 0; i--)
857 printf(
"%s%s",
to_string(vec2[i]).c_str(), i ?
", " :
"");
858 printf(
"], result=[");
859 for (
int i =
int(
vec.size())-1; i >= 0; i--)
860 printf(
"%s%s",
to_string(
vec[i]).c_str(), i ?
", " :
"");
873 void ezSAT::vec_cmp(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
int &carry,
int &overflow,
int &
sign,
int &zero)
875 assert(vec1.size() == vec2.size());
878 for (
int i = 0; i < int(vec1.size()); i++) {
880 fulladder(
this, vec1[i],
NOT(vec2[i]), carry, carry, sign);
881 zero =
OR(zero, sign);
883 overflow =
XOR(overflow, carry);
888 printf(
"CMP> vec1=[");
889 for (
int i =
int(vec1.size())-1; i >= 0; i--)
890 printf(
"%s%s",
to_string(vec1[i]).c_str(), i ?
", " :
"");
892 for (
int i =
int(vec2.size())-1; i >= 0; i--)
893 printf(
"%s%s",
to_string(vec2[i]).c_str(), i ?
", " :
"");
900 int carry, overflow,
sign, zero;
901 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
907 int carry, overflow,
sign, zero;
908 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
909 return OR(
AND(
NOT(overflow), sign),
AND(overflow,
NOT(sign)), zero);
914 int carry, overflow,
sign, zero;
915 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
921 int carry, overflow,
sign, zero;
922 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
928 int carry, overflow,
sign, zero;
929 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
935 int carry, overflow,
sign, zero;
936 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
937 return OR(carry, zero);
942 int carry, overflow,
sign, zero;
943 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
949 int carry, overflow,
sign, zero;
950 vec_cmp(vec1, vec2, carry, overflow, sign, zero);
954 int ezSAT::vec_eq(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
959 int ezSAT::vec_ne(
const std::vector<int> &vec1,
const std::vector<int> &vec2)
964 std::vector<int>
ezSAT::vec_shl(
const std::vector<int> &vec1,
int shift,
bool signExtend)
966 std::vector<int>
vec;
967 for (
int i = 0; i < int(vec1.size()); i++) {
969 if (
int(vec1.size()) <= j)
970 vec.push_back(signExtend ? vec1.back() :
CONST_FALSE);
972 vec.push_back(vec1[j]);
981 std::vector<int>
vec;
982 for (
int i = 0; i < int(vec1.size()); i++) {
986 while (j >=
int(vec1.size()))
988 vec.push_back(vec1[j]);
993 std::vector<int>
ezSAT::vec_shift(
const std::vector<int> &vec1,
int shift,
int extend_left,
int extend_right)
995 std::vector<int>
vec;
996 for (
int i = 0; i < int(vec1.size()); i++) {
999 vec.push_back(extend_right);
1000 else if (j >=
int(vec1.size()))
1001 vec.push_back(extend_left);
1003 vec.push_back(vec1[j]);
1011 for (x--; x > 0; result++)
1016 std::vector<int>
ezSAT::vec_shift_right(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
bool vec2_signed,
int extend_left,
int extend_right)
1018 int vec2_bits = std::min(
my_clog2(vec1.size()) + (vec2_signed ? 1 : 0), int(vec2.size()));
1020 std::vector<int> overflow_bits(vec2.begin() + vec2_bits, vec2.end());
1025 for (
auto bit : overflow_bits)
1026 overflow =
OR(overflow,
XOR(
bit, vec2[vec2_bits-1]));
1027 overflow_left =
AND(overflow,
NOT(vec2.back()));
1028 overflow_right =
AND(overflow, vec2.back());
1032 std::vector<int> buffer = vec1;
1035 while (buffer.size() < vec1.size() + (1 << vec2_bits))
1036 buffer.push_back(extend_left);
1038 std::vector<int> overflow_pattern_left(buffer.size(), extend_left);
1039 std::vector<int> overflow_pattern_right(buffer.size(), extend_right);
1041 buffer =
vec_ite(overflow_left, overflow_pattern_left, buffer);
1044 buffer =
vec_ite(overflow_right, overflow_pattern_left, buffer);
1046 for (
int i = vec2_bits-1; i >= 0; i--) {
1047 std::vector<int> shifted_buffer;
1048 if (vec2_signed && i == vec2_bits-1)
1049 shifted_buffer =
vec_shift(buffer, -(1 << i), extend_left, extend_right);
1051 shifted_buffer =
vec_shift(buffer, 1 << i, extend_left, extend_right);
1052 buffer =
vec_ite(vec2[i], shifted_buffer, buffer);
1055 buffer.resize(vec1.size());
1059 std::vector<int>
ezSAT::vec_shift_left(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
bool vec2_signed,
int extend_left,
int extend_right)
1062 assert(vec2_signed ==
false);
1064 int vec2_bits = std::min(
my_clog2(vec1.size()),
int(vec2.size()));
1066 std::vector<int> overflow_bits(vec2.begin() + vec2_bits, vec2.end());
1069 std::vector<int> buffer = vec1;
1070 std::vector<int> overflow_pattern_right(buffer.size(), extend_right);
1071 buffer =
vec_ite(overflow, overflow_pattern_right, buffer);
1073 for (
int i = 0; i < vec2_bits; i++) {
1074 std::vector<int> shifted_buffer;
1075 shifted_buffer =
vec_shift(buffer, -(1 << i), extend_left, extend_right);
1076 buffer =
vec_ite(vec2[i], shifted_buffer, buffer);
1079 buffer.resize(vec1.size());
1085 for (
auto bit : vec1)
1091 assert(
int(vec1.size()) <= 64);
1092 for (
int i = 0; i < int(vec1.size()); i++) {
1093 if (((value >> i) & 1) != 0)
1094 vec.push_back(vec1[i]);
1096 vec.push_back(
NOT(vec1[i]));
1102 assert(
int(vec1.size()) <= 64);
1103 for (
int i = 0; i < int(vec1.size()); i++) {
1104 if (((value >> i) & 1) != 0)
1105 vec.push_back(vec1[i]);
1107 vec.push_back(
NOT(vec1[i]));
1111 int64_t
ezSAT::vec_model_get_signed(
const std::vector<int> &modelExpressions,
const std::vector<bool> &modelValues,
const std::vector<int> &vec1)
const
1114 std::map<int, bool> modelMap;
1115 assert(modelExpressions.size() == modelValues.size());
1116 for (
int i = 0; i < int(modelExpressions.size()); i++)
1117 modelMap[modelExpressions[i]] = modelValues[i];
1118 for (
int i = 0; i < 64; i++) {
1119 int j = i < int(vec1.size()) ? i : vec1.size()-1;
1120 if (modelMap.at(vec1[j]))
1121 value |= int64_t(1) << i;
1129 std::map<int, bool> modelMap;
1130 assert(modelExpressions.size() == modelValues.size());
1131 for (
int i = 0; i < int(modelExpressions.size()); i++)
1132 modelMap[modelExpressions[i]] = modelValues[i];
1133 for (
int i = 0; i < int(vec1.size()); i++)
1134 if (modelMap.at(vec1[i]))
1135 value |= uint64_t(1) << i;
1151 assert(vec1.size() == vec2.size());
1152 for (
int i = 0; i < int(vec1.size()); i++)
1153 SET(vec1[i], vec2[i]);
1158 assert(
int(vec1.size()) <= 64);
1159 for (
int i = 0; i < int(vec1.size()); i++) {
1160 if (((value >> i) & 1) != 0)
1169 assert(
int(vec1.size()) <= 64);
1170 for (
int i = 0; i < int(vec1.size()); i++) {
1171 if (((value >> i) & 1) != 0)
1191 fprintf(stderr,
"Usage error: printDIMACS() must not be called after cnfConsumed()!");
1197 fprintf(f,
"c generated by ezSAT\n");
1202 fprintf(f,
"c mapping of variables to literals:\n");
1208 fprintf(f,
"c mapping of variables to expressions:\n");
1215 fprintf(f,
"c %d clauses from backup, %d from current buffer\n",
1222 std::vector<std::vector<int>> all_clauses;
1227 int maxClauseLen = 0;
1228 for (
auto &clause : all_clauses)
1229 maxClauseLen = std::max(
int(clause.size()), maxClauseLen);
1231 maxClauseLen = std::min(maxClauseLen, 3);
1232 for (
auto &clause : all_clauses) {
1233 for (
auto idx : clause)
1234 fprintf(f,
" %*d", digits,
idx);
1235 if (maxClauseLen >=
int(clause.size()))
1236 fprintf(f,
" %*d\n", (digits + 1)*
int(maxClauseLen - clause.size()) + digits, 0);
1238 fprintf(f,
" %*d\n", digits, 0);
1245 switch (data.first) {
1246 #define X(op) case ezSAT::op: text += #op; break;
1258 for (
auto it : data.second)
1265 fprintf(f,
"--8<-- snip --8<--\n");
1267 fprintf(f,
"literalsCache:\n");
1269 fprintf(f,
" `%s' -> %d\n", it.first.c_str(), it.second);
1271 fprintf(f,
"literals:\n");
1272 for (
int i = 0; i < int(
literals.size()); i++)
1273 fprintf(f,
" %d: `%s'\n", i+1,
literals[i].c_str());
1275 fprintf(f,
"expressionsCache:\n");
1277 fprintf(f,
" `%s' -> %d\n",
expression2str(it.first).c_str(), it.second);
1279 fprintf(f,
"expressions:\n");
1291 fprintf(f,
"cnfClauses:\n");
1294 fprintf(f,
" %4d", i2);
1298 fprintf(f,
" *** more clauses consumed via cnfConsume() ***\n");
1300 fprintf(f,
"--8<-- snap --8<--\n");
1309 std::vector<int> formula;
1312 if (max_only ==
false)
1316 int num_bits = ceil(log2(vec.size()));
1317 std::vector<int> bits;
1318 for (
int k = 0; k < num_bits; k++)
1322 for (
size_t i = 0; i < vec.size(); i++)
1323 for (
int k = 0; k < num_bits; k++) {
1324 std::vector<int> clause;
1325 clause.push_back(
NOT(vec[i]));
1326 clause.push_back((i & (1 << k)) != 0 ? bits[k] :
NOT(bits[k]));
1340 std::vector<int> formula;
1341 int M = max_hot+1, N = vec.size();
1342 std::map<std::pair<int,int>,
int> x;
1344 for (
int i = -1; i < N; i++)
1345 for (
int j = -1; j < M; j++)
1348 for (
int i = 0; i < N; i++)
1349 for (
int j = 0; j < M; j++) {
1350 formula.push_back(
OR(
NOT(vec[i]), x[std::pair<int,int>(i-1,j-1)],
NOT(x[std::pair<int,int>(i,j)])));
1351 formula.push_back(
OR(
NOT(vec[i]),
NOT(x[std::pair<int,int>(i-1,j-1)]), x[std::pair<int,int>(i,j)]));
1352 formula.push_back(
OR(vec[i], x[std::pair<int,int>(i-1,j)],
NOT(x[std::pair<int,int>(i,j)])));
1353 formula.push_back(
OR(vec[i],
NOT(x[std::pair<int,int>(i-1,j)]), x[std::pair<int,int>(i,j)]));
1356 formula.push_back(
OR(
NOT(x[std::pair<int,int>(i-1,j-1)]),
NOT(x[std::pair<int,int>(i-1,j)]), x[std::pair<int,int>(i,j)]));
1357 formula.push_back(
OR(x[std::pair<int,int>(i-1,j-1)], x[std::pair<int,int>(i-1,j)],
NOT(x[std::pair<int,int>(i,j)])));
1361 for (
int j = 0; j < M; j++) {
1363 formula.push_back(x[std::pair<int,int>(N-1,j)]);
1364 else if (j+1 > max_hot)
1365 formula.push_back(
NOT(x[std::pair<int,int>(N-1,j)]));
1371 int ezSAT::ordered(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
bool allow_equal)
1373 std::vector<int> formula;
1376 assert(vec1.size() == vec2.size());
1377 for (
size_t i = 0; i < vec1.size(); i++)
1379 int a = vec1[i], b = vec2[i];
1380 formula.push_back(
OR(
NOT(a), b, last_x));
1383 formula.push_back(
OR(a, b, last_x,
NOT(next_x)));
1384 formula.push_back(
OR(
NOT(a),
NOT(b), last_x,
NOT(next_x)));
std::vector< int > vec_sub(const std::vector< int > &vec1, const std::vector< int > &vec2)
const std::vector< std::vector< int > > & cnf() const
std::vector< int > vec_const_signed(int64_t value, int numBits)
std::string cnfLiteralInfo(int idx) const
int vec_ge_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
void sort(T *array, int size, LessThan lt)
void lookup_expression(int id, OpId &op, std::vector< int > &args) const
int parse_string(const std::string &text)
std::vector< int > vec_var(int numBits)
virtual bool solver(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
virtual bool eliminated(int idx)
static const int CONST_FALSE
void vec_append_signed(std::vector< int > &vec, const std::vector< int > &vec1, int64_t value)
std::vector< int > vec_iff(const std::vector< int > &vec1, const std::vector< int > &vec2)
int eval(int id, const std::vector< int > &values) const
int vec_le_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
static std::string idx(std::string str)
void add_clause(const std::vector< int > &args)
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
int vec_lt_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
bool mode_keep_cnf() const
std::vector< int > vec_count(const std::vector< int > &vec, int numBits, bool clip=true)
std::vector< std::string > literals
static std::string my_int_to_string(int i)
void vec_set(const std::vector< int > &vec1, const std::vector< int > &vec2)
std::vector< int > vec_shift(const std::vector< int > &vec1, int shift, int extend_left, int extend_right)
int ITE(_V a, _V b, _V c)
std::vector< int > vec_shl(const std::vector< int > &vec1, int shift, bool signExtend=false)
std::vector< std::pair< OpId, std::vector< int > > > expressions
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
std::vector< int > vec_or(const std::vector< int > &vec1, const std::vector< int > &vec2)
int onehot(const std::vector< int > &vec, bool max_only=false)
void vec_set_unsigned(const std::vector< int > &vec1, uint64_t value)
std::vector< int > vec_srl(const std::vector< int > &vec1, int shift)
void lookup_literal(int id, std::string &name) const
std::vector< int > cnfLiteralVariables
std::string to_string(int id) const
std::map< std::pair< OpId, std::vector< int > >, int > expressionsCache
uint64_t vec_model_get_unsigned(const std::vector< int > &modelExpressions, const std::vector< bool > &modelValues, const std::vector< int > &vec1) const
int vec_gt_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
std::vector< int > vec_neg(const std::vector< int > &vec)
std::vector< int > vec_const_unsigned(uint64_t value, int numBits)
void vec_append_unsigned(std::vector< int > &vec, const std::vector< int > &vec1, uint64_t value)
int vec_ne(const std::vector< int > &vec1, const std::vector< int > &vec2)
std::vector< int > vec_shift_left(const std::vector< int > &vec1, const std::vector< int > &vec2, bool vec2_signed, int extend_left, int extend_right)
void printInternalState(FILE *f) const
void printDIMACS(FILE *f, bool verbose=false) const
static void halfadder(ezSAT *that, int a, int b, int &y, int &x)
static int my_clog2(int x)
int bind_cnf_and(const std::vector< int > &args)
int64_t vec_model_get_signed(const std::vector< int > &modelExpressions, const std::vector< bool > &modelValues, const std::vector< int > &vec1) const
std::vector< int > vec_shift_right(const std::vector< int > &vec1, const std::vector< int > &vec2, bool vec2_signed, int extend_left, int extend_right)
int ordered(const std::vector< int > &vec1, const std::vector< int > &vec2, bool allow_equal=true)
int vec_reduce_and(const std::vector< int > &vec1)
std::vector< int > vec_cast(const std::vector< int > &vec1, int toBits, bool signExtend=false)
std::vector< int > vec_xor(const std::vector< int > &vec1, const std::vector< int > &vec2)
int vec_reduce_or(const std::vector< int > &vec1)
int vec_gt_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
static std::string expression2str(const std::pair< ezSAT::OpId, std::vector< int >> &data)
virtual void freeze(int id)
int bind_cnf_not(const std::vector< int > &args)
static const int CONST_TRUE
std::vector< int > vec_add(const std::vector< int > &vec1, const std::vector< int > &vec2)
void getFullCnf(std::vector< std::vector< int >> &full_cnf) const
std::vector< int > vec_ite(const std::vector< int > &vec1, const std::vector< int > &vec2, const std::vector< int > &vec3)
int manyhot(const std::vector< int > &vec, int min_hot, int max_hot=-1)
int XOR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
int vec_eq(const std::vector< int > &vec1, const std::vector< int > &vec2)
int vec_lt_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
bool flag_non_incremental
std::vector< int > vec_const(const std::vector< bool > &bits)
int bind_cnf_or(const std::vector< int > &args)
std::vector< std::vector< int > > cnfClauses
std::string id(RTLIL::IdString internal_id, bool may_rename=true)
std::map< std::string, int > literalsCache
void vec_set_signed(const std::vector< int > &vec1, int64_t value)
int IFF(_V a, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
std::vector< std::vector< int > > cnfClausesBackup
bool mode_non_incremental() const
std::vector< int > vec_not(const std::vector< int > &vec1)
std::vector< int > cnfExpressionVariables
int vec_ge_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
struct ezSATbit bit(_V a)
bool non_incremental_solve_used_up
void vec_append(std::vector< int > &vec, const std::vector< int > &vec1) const
struct ezSATvec vec(const std::vector< int > &vec)
int vec_le_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
static void fulladder(ezSAT *that, int a, int b, int c, int &y, int &x)
int bind(int id, bool auto_freeze=true)
std::vector< int > vec_and(const std::vector< int > &vec1, const std::vector< int > &vec2)