yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ezMiniSAT Class Reference

#include <ezminisat.h>

+ Inheritance diagram for ezMiniSAT:
+ Collaboration diagram for ezMiniSAT:

Public Types

enum  OpId {
  OpNot, OpAnd, OpOr, OpXor,
  OpIFF, OpITE
}
 

Public Member Functions

 ezMiniSAT ()
 
virtual ~ezMiniSAT ()
 
virtual void clear ()
 
virtual void freeze (int id)
 
virtual bool eliminated (int idx)
 
virtual bool solver (const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
 
void keep_cnf ()
 
void non_incremental ()
 
bool mode_keep_cnf () const
 
bool mode_non_incremental () const
 
int value (bool val)
 
int literal ()
 
int literal (const std::string &name)
 
int frozen_literal ()
 
int frozen_literal (const std::string &name)
 
int expression (OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
 
int expression (OpId op, const std::vector< int > &args)
 
void lookup_literal (int id, std::string &name) const
 
const std::string & lookup_literal (int id) const
 
void lookup_expression (int id, OpId &op, std::vector< int > &args) const
 
const std::vector< int > & lookup_expression (int id, OpId &op) const
 
int parse_string (const std::string &text)
 
std::string to_string (int id) const
 
int numLiterals () const
 
int numExpressions () const
 
int eval (int id, const std::vector< int > &values) const
 
bool solve (const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
 
bool solve (const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
 
bool solve (int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
 
void setSolverTimeout (int newTimeoutSeconds)
 
bool getSolverTimoutStatus ()
 
void assume (int id)
 
int bind (int id, bool auto_freeze=true)
 
int bound (int id) const
 
int numCnfVariables () const
 
int numCnfClauses () const
 
const std::vector< std::vector
< int > > & 
cnf () const
 
void consumeCnf ()
 
void consumeCnf (std::vector< std::vector< int >> &cnf)
 
void getFullCnf (std::vector< std::vector< int >> &full_cnf) const
 
std::string cnfLiteralInfo (int idx) const
 
int VAR (_V a)
 
int NOT (_V a)
 
int AND (_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
 
int OR (_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
 
int XOR (_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
 
int IFF (_V a, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
 
int ITE (_V a, _V b, _V c)
 
void SET (_V a, _V b)
 
std::vector< int > vec_const (const std::vector< bool > &bits)
 
std::vector< int > vec_const_signed (int64_t value, int numBits)
 
std::vector< int > vec_const_unsigned (uint64_t value, int numBits)
 
std::vector< int > vec_var (int numBits)
 
std::vector< int > vec_var (std::string name, int numBits)
 
std::vector< int > vec_cast (const std::vector< int > &vec1, int toBits, bool signExtend=false)
 
std::vector< int > vec_not (const std::vector< int > &vec1)
 
std::vector< int > vec_and (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_or (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_xor (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_iff (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_ite (const std::vector< int > &vec1, const std::vector< int > &vec2, const std::vector< int > &vec3)
 
std::vector< int > vec_ite (int sel, const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_count (const std::vector< int > &vec, int numBits, bool clip=true)
 
std::vector< int > vec_add (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_sub (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_neg (const std::vector< int > &vec)
 
void vec_cmp (const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
 
int vec_lt_signed (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_le_signed (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_ge_signed (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_gt_signed (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_lt_unsigned (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_le_unsigned (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_ge_unsigned (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_gt_unsigned (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_eq (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
int vec_ne (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
std::vector< int > vec_shl (const std::vector< int > &vec1, int shift, bool signExtend=false)
 
std::vector< int > vec_srl (const std::vector< int > &vec1, int shift)
 
std::vector< int > vec_shr (const std::vector< int > &vec1, int shift, bool signExtend=false)
 
std::vector< int > vec_srr (const std::vector< int > &vec1, int shift)
 
std::vector< int > vec_shift (const std::vector< int > &vec1, int shift, int extend_left, int extend_right)
 
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)
 
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 vec_append (std::vector< int > &vec, const std::vector< int > &vec1) const
 
void vec_append_signed (std::vector< int > &vec, const std::vector< int > &vec1, int64_t value)
 
void vec_append_unsigned (std::vector< int > &vec, const std::vector< int > &vec1, uint64_t value)
 
int64_t vec_model_get_signed (const std::vector< int > &modelExpressions, const std::vector< bool > &modelValues, const std::vector< int > &vec1) const
 
uint64_t vec_model_get_unsigned (const std::vector< int > &modelExpressions, const std::vector< bool > &modelValues, const std::vector< int > &vec1) const
 
int vec_reduce_and (const std::vector< int > &vec1)
 
int vec_reduce_or (const std::vector< int > &vec1)
 
void vec_set (const std::vector< int > &vec1, const std::vector< int > &vec2)
 
void vec_set_signed (const std::vector< int > &vec1, int64_t value)
 
void vec_set_unsigned (const std::vector< int > &vec1, uint64_t value)
 
struct ezSATbit bit (_V a)
 
struct ezSATvec vec (const std::vector< int > &vec)
 
void printDIMACS (FILE *f, bool verbose=false) const
 
void printInternalState (FILE *f) const
 
int onehot (const std::vector< int > &vec, bool max_only=false)
 
int manyhot (const std::vector< int > &vec, int min_hot, int max_hot=-1)
 
int ordered (const std::vector< int > &vec1, const std::vector< int > &vec2, bool allow_equal=true)
 

Data Fields

int solverTimeout
 
bool solverTimoutStatus
 

Static Public Attributes

static const int CONST_TRUE = 1
 
static const int CONST_FALSE = 2
 

Protected Member Functions

void preSolverCallback ()
 

Private Types

typedef Minisat::SimpSolver Solver
 

Static Private Member Functions

static void alarmHandler (int)
 

Private Attributes

SolverminisatSolver
 
std::vector< int > minisatVars
 
bool foundContradiction
 
std::set< int > cnfFrozenVars
 

Static Private Attributes

static ezMiniSATalarmHandlerThis = NULL
 
static clock_t alarmHandlerTimeout = 0
 

Detailed Description

Definition at line 38 of file ezminisat.h.

Member Typedef Documentation

Definition at line 42 of file ezminisat.h.

Member Enumeration Documentation

enum ezSAT::OpId
inherited
Enumerator
OpNot 
OpAnd 
OpOr 
OpXor 
OpIFF 
OpITE 

Definition at line 44 of file ezsat.h.

44  {
46  };

Constructor & Destructor Documentation

ezMiniSAT::ezMiniSAT ( )

Definition at line 38 of file ezminisat.cc.

39 {
41  foundContradiction = false;
42 
45 }
Solver * minisatSolver
Definition: ezminisat.h:46
static const int CONST_FALSE
Definition: ezsat.h:49
bool foundContradiction
Definition: ezminisat.h:48
static const int CONST_TRUE
Definition: ezsat.h:48
#define NULL
virtual void freeze(int id)

+ Here is the call graph for this function:

ezMiniSAT::~ezMiniSAT ( )
virtual

Definition at line 47 of file ezminisat.cc.

48 {
49  if (minisatSolver != NULL)
50  delete minisatSolver;
51 }
Solver * minisatSolver
Definition: ezminisat.h:46
#define NULL

Member Function Documentation

void ezMiniSAT::alarmHandler ( int  )
staticprivate

Definition at line 87 of file ezminisat.cc.

88 {
89  if (clock() > alarmHandlerTimeout) {
92  } else
93  alarm(1);
94 }
Solver * minisatSolver
Definition: ezminisat.h:46
void interrupt()
Definition: Solver.h:371
static ezMiniSAT * alarmHandlerThis
Definition: ezminisat.h:55
static clock_t alarmHandlerTimeout
Definition: ezminisat.h:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::AND ( _V  a = 0,
_V  b = 0,
_V  c = 0,
_V  d = 0,
_V  e = 0,
_V  f = 0 
)
inlineinherited

Definition at line 201 of file ezsat.h.

201  {
202  return expression(OpAnd, a.get(this), b.get(this), c.get(this), d.get(this), e.get(this), f.get(this));
203  }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::assume ( int  id)
inherited

Definition at line 388 of file ezsat.cc.

389 {
390  if (id < 0)
391  {
392  assert(0 < -id && -id <= int(expressions.size()));
393  cnfExpressionVariables.resize(expressions.size());
394 
395  if (cnfExpressionVariables[-id-1] == 0)
396  {
397  OpId op;
398  std::vector<int> args;
399  lookup_expression(id, op, args);
400 
401  if (op == OpNot) {
402  int idx = bind(args[0]);
403  cnfClauses.push_back(std::vector<int>(1, -idx));
404  cnfClausesCount++;
405  return;
406  }
407  if (op == OpOr) {
408  std::vector<int> clause;
409  for (int arg : args)
410  clause.push_back(bind(arg));
411  cnfClauses.push_back(clause);
412  cnfClausesCount++;
413  return;
414  }
415  if (op == OpAnd) {
416  for (int arg : args) {
417  cnfClauses.push_back(std::vector<int>(1, bind(arg)));
418  cnfClausesCount++;
419  }
420  return;
421  }
422  }
423  }
424 
425  int idx = bind(id);
426  cnfClauses.push_back(std::vector<int>(1, idx));
427  cnfClausesCount++;
428 }
void lookup_expression(int id, OpId &op, std::vector< int > &args) const
Definition: ezsat.cc:218
OpId
Definition: ezsat.h:44
int cnfClausesCount
Definition: ezsat.h:64
static std::string idx(std::string str)
Definition: test_autotb.cc:57
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66
std::vector< int > cnfExpressionVariables
Definition: ezsat.h:65
int bind(int id, bool auto_freeze=true)
Definition: ezsat.cc:520

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::bind ( int  id,
bool  auto_freeze = true 
)
inherited

Definition at line 520 of file ezsat.cc.

521 {
522  if (id >= 0) {
523  assert(0 < id && id <= int(literals.size()));
524  cnfLiteralVariables.resize(literals.size());
525  if (eliminated(cnfLiteralVariables[id-1])) {
526  fprintf(stderr, "ezSAT: Missing freeze on literal `%s'.\n", to_string(id).c_str());
527  abort();
528  }
529  if (cnfLiteralVariables[id-1] == 0) {
531  if (id == CONST_TRUE)
533  if (id == CONST_FALSE)
535  }
536  return cnfLiteralVariables[id-1];
537  }
538 
539  assert(0 < -id && -id <= int(expressions.size()));
540  cnfExpressionVariables.resize(expressions.size());
541 
543  {
544  cnfExpressionVariables[-id-1] = 0;
545 
546  // this will recursively call bind(id). within the recursion
547  // the cnf is pre-set to 0. an idx is allocated there, then it
548  // is frozen, then it returns here with the new idx already set.
549  if (auto_freeze)
550  freeze(id);
551  }
552 
553  if (cnfExpressionVariables[-id-1] == 0)
554  {
555  OpId op;
556  std::vector<int> args;
557  lookup_expression(id, op, args);
558  int idx = 0;
559 
560  if (op == OpXor) {
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]);
566  else
567  newArgs.push_back(OR(AND(args[i], NOT(args[i+1])), AND(NOT(args[i]), args[i+1])));
568  args.swap(newArgs);
569  }
570  idx = bind(args.at(0), false);
571  goto assign_idx;
572  }
573 
574  if (op == OpIFF) {
575  std::vector<int> invArgs;
576  for (auto arg : args)
577  invArgs.push_back(NOT(arg));
578  idx = bind(OR(expression(OpAnd, args), expression(OpAnd, invArgs)), false);
579  goto assign_idx;
580  }
581 
582  if (op == OpITE) {
583  idx = bind(OR(AND(args[0], args[1]), AND(NOT(args[0]), args[2])), false);
584  goto assign_idx;
585  }
586 
587  for (int i = 0; i < int(args.size()); i++)
588  args[i] = bind(args[i], false);
589 
590  switch (op)
591  {
592  case OpNot: idx = bind_cnf_not(args); break;
593  case OpAnd: idx = bind_cnf_and(args); break;
594  case OpOr: idx = bind_cnf_or(args); break;
595  default: abort();
596  }
597 
598  assign_idx:
599  assert(idx != 0);
600  cnfExpressionVariables[-id-1] = idx;
601  }
602 
603  return cnfExpressionVariables[-id-1];
604 }
void lookup_expression(int id, OpId &op, std::vector< int > &args) const
Definition: ezsat.cc:218
OpId
Definition: ezsat.h:44
virtual bool eliminated(int idx)
Definition: ezsat.cc:383
static const int CONST_FALSE
Definition: ezsat.h:49
static std::string idx(std::string str)
Definition: test_autotb.cc:57
void add_clause(const std::vector< int > &args)
Definition: ezsat.cc:430
int NOT(_V a)
Definition: ezsat.h:197
std::vector< std::string > literals
Definition: ezsat.h:58
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
std::vector< int > cnfLiteralVariables
Definition: ezsat.h:65
std::string to_string(int id) const
Definition: ezsat.cc:237
int bind_cnf_and(const std::vector< int > &args)
Definition: ezsat.cc:468
virtual void freeze(int id)
Definition: ezsat.cc:379
int bind_cnf_not(const std::vector< int > &args)
Definition: ezsat.cc:462
static const int CONST_TRUE
Definition: ezsat.h:48
int cnfVariableCount
Definition: ezsat.h:64
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205
int bind_cnf_or(const std::vector< int > &args)
Definition: ezsat.cc:481
std::vector< int > cnfExpressionVariables
Definition: ezsat.h:65
int bind(int id, bool auto_freeze=true)
Definition: ezsat.cc:520

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ezSATbit ezSAT::bit ( _V  a)
inherited

Definition at line 1178 of file ezsat.cc.

1179 {
1180  return ezSATbit(*this, a);
1181 }

+ Here is the caller graph for this function:

int ezSAT::bound ( int  id) const
inherited

Definition at line 494 of file ezsat.cc.

495 {
496  if (id > 0 && id <= int(cnfLiteralVariables.size()))
497  return cnfLiteralVariables[id-1];
498  if (-id > 0 && -id <= int(cnfExpressionVariables.size()))
499  return cnfExpressionVariables[-id-1];
500  return 0;
501 }
std::vector< int > cnfLiteralVariables
Definition: ezsat.h:65
std::vector< int > cnfExpressionVariables
Definition: ezsat.h:65

+ Here is the caller graph for this function:

void ezMiniSAT::clear ( )
virtual

Reimplemented from ezSAT.

Definition at line 53 of file ezminisat.cc.

54 {
55  if (minisatSolver != NULL) {
56  delete minisatSolver;
58  }
59  foundContradiction = false;
60  minisatVars.clear();
61 #if EZMINISAT_SIMPSOLVER && EZMINISAT_INCREMENTAL
62  cnfFrozenVars.clear();
63 #endif
64  ezSAT::clear();
65 }
Solver * minisatSolver
Definition: ezminisat.h:46
std::set< int > cnfFrozenVars
Definition: ezminisat.h:51
bool foundContradiction
Definition: ezminisat.h:48
std::vector< int > minisatVars
Definition: ezminisat.h:47
#define NULL
virtual void clear()
Definition: ezsat.cc:369

+ Here is the call graph for this function:

const std::vector<std::vector<int> >& ezSAT::cnf ( ) const
inlineinherited

Definition at line 168 of file ezsat.h.

168 { return cnfClauses; }
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66

+ Here is the caller graph for this function:

std::string ezSAT::cnfLiteralInfo ( int  idx) const
inherited

Definition at line 503 of file ezsat.cc.

504 {
505  for (int i = 0; i < int(cnfLiteralVariables.size()); i++) {
506  if (cnfLiteralVariables[i] == idx)
507  return to_string(i+1);
508  if (cnfLiteralVariables[i] == -idx)
509  return "NOT " + to_string(i+1);
510  }
511  for (int i = 0; i < int(cnfExpressionVariables.size()); i++) {
512  if (cnfExpressionVariables[i] == idx)
513  return to_string(-i-1);
514  if (cnfExpressionVariables[i] == -idx)
515  return "NOT " + to_string(-i-1);
516  }
517  return "<unnamed>";
518 }
static std::string idx(std::string str)
Definition: test_autotb.cc:57
std::vector< int > cnfLiteralVariables
Definition: ezsat.h:65
std::string to_string(int id) const
Definition: ezsat.cc:237
std::vector< int > cnfExpressionVariables
Definition: ezsat.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::consumeCnf ( )
inherited

Definition at line 606 of file ezsat.cc.

607 {
608  if (mode_keep_cnf())
609  cnfClausesBackup.insert(cnfClausesBackup.end(), cnfClauses.begin(), cnfClauses.end());
610  else
611  cnfConsumed = true;
612  cnfClauses.clear();
613 }
bool mode_keep_cnf() const
Definition: ezsat.h:89
bool cnfConsumed
Definition: ezsat.h:63
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66
std::vector< std::vector< int > > cnfClausesBackup
Definition: ezsat.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::consumeCnf ( std::vector< std::vector< int >> &  cnf)
inherited

Definition at line 615 of file ezsat.cc.

616 {
617  if (mode_keep_cnf())
618  cnfClausesBackup.insert(cnfClausesBackup.end(), cnfClauses.begin(), cnfClauses.end());
619  else
620  cnfConsumed = true;
621  cnf.swap(cnfClauses);
622  cnfClauses.clear();
623 }
const std::vector< std::vector< int > > & cnf() const
Definition: ezsat.h:168
bool mode_keep_cnf() const
Definition: ezsat.h:89
bool cnfConsumed
Definition: ezsat.h:63
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66
std::vector< std::vector< int > > cnfClausesBackup
Definition: ezsat.h:66

+ Here is the call graph for this function:

virtual bool ezMiniSAT::eliminated ( int  idx)
virtual

Reimplemented from ezSAT.

int ezSAT::eval ( int  id,
const std::vector< int > &  values 
) const
inherited

Definition at line 293 of file ezsat.cc.

294 {
295  if (id > 0) {
296  if (id <= int(values.size()) && (values[id-1] == CONST_TRUE || values[id-1] == CONST_FALSE || values[id-1] == 0))
297  return values[id-1];
298  return 0;
299  }
300 
301  OpId op;
302  const std::vector<int> &args = lookup_expression(id, op);
303  int a, b;
304 
305  switch (op)
306  {
307  case OpNot:
308  assert(args.size() == 1);
309  a = eval(args[0], values);
310  if (a == CONST_TRUE)
311  return CONST_FALSE;
312  if (a == CONST_FALSE)
313  return CONST_TRUE;
314  return 0;
315  case OpAnd:
316  a = CONST_TRUE;
317  for (auto arg : args) {
318  b = eval(arg, values);
319  if (b != CONST_TRUE && b != CONST_FALSE)
320  a = 0;
321  if (b == CONST_FALSE)
322  return CONST_FALSE;
323  }
324  return a;
325  case OpOr:
326  a = CONST_FALSE;
327  for (auto arg : args) {
328  b = eval(arg, values);
329  if (b != CONST_TRUE && b != CONST_FALSE)
330  a = 0;
331  if (b == CONST_TRUE)
332  return CONST_TRUE;
333  }
334  return a;
335  case OpXor:
336  a = CONST_FALSE;
337  for (auto arg : args) {
338  b = eval(arg, values);
339  if (b != CONST_TRUE && b != CONST_FALSE)
340  return 0;
341  if (b == CONST_TRUE)
342  a = a == CONST_TRUE ? CONST_FALSE : CONST_TRUE;
343  }
344  return a;
345  case OpIFF:
346  assert(args.size() > 0);
347  a = eval(args[0], values);
348  for (auto arg : args) {
349  b = eval(arg, values);
350  if (b != CONST_TRUE && b != CONST_FALSE)
351  return 0;
352  if (b != a)
353  return CONST_FALSE;
354  }
355  return CONST_TRUE;
356  case OpITE:
357  assert(args.size() == 3);
358  a = eval(args[0], values);
359  if (a == CONST_TRUE)
360  return eval(args[1], values);
361  if (a == CONST_FALSE)
362  return eval(args[2], values);
363  return 0;
364  default:
365  abort();
366  }
367 }
void lookup_expression(int id, OpId &op, std::vector< int > &args) const
Definition: ezsat.cc:218
OpId
Definition: ezsat.h:44
static const int CONST_FALSE
Definition: ezsat.h:49
int eval(int id, const std::vector< int > &values) const
Definition: ezsat.cc:293
static const int CONST_TRUE
Definition: ezsat.h:48

+ Here is the call graph for this function:

int ezSAT::expression ( OpId  op,
int  a = 0,
int  b = 0,
int  c = 0,
int  d = 0,
int  e = 0,
int  f = 0 
)
inherited

Definition at line 102 of file ezsat.cc.

103 {
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;
107  return expression(op, args);
108 }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the caller graph for this function:

int ezSAT::expression ( OpId  op,
const std::vector< int > &  args 
)
inherited

Definition at line 110 of file ezsat.cc.

111 {
112  std::vector<int> myArgs;
113  myArgs.reserve(args.size());
114  bool xorRemovedOddTrues = false;
115 
116  for (auto arg : args)
117  {
118  if (arg == 0)
119  continue;
120  if (op == OpAnd && arg == CONST_TRUE)
121  continue;
122  if ((op == OpOr || op == OpXor) && arg == CONST_FALSE)
123  continue;
124  if (op == OpXor && arg == CONST_TRUE) {
125  xorRemovedOddTrues = !xorRemovedOddTrues;
126  continue;
127  }
128  myArgs.push_back(arg);
129  }
130 
131  if (myArgs.size() > 0 && (op == OpAnd || op == OpOr || op == OpXor || op == OpIFF)) {
132  std::sort(myArgs.begin(), myArgs.end());
133  int j = 0;
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)
138  j--;
139  myArgs.resize(j+1);
140  }
141 
142  switch (op)
143  {
144  case OpNot:
145  assert(myArgs.size() == 1);
146  if (myArgs[0] == CONST_TRUE)
147  return CONST_FALSE;
148  if (myArgs[0] == CONST_FALSE)
149  return CONST_TRUE;
150  break;
151 
152  case OpAnd:
153  if (myArgs.size() == 0)
154  return CONST_TRUE;
155  if (myArgs.size() == 1)
156  return myArgs[0];
157  break;
158 
159  case OpOr:
160  if (myArgs.size() == 0)
161  return CONST_FALSE;
162  if (myArgs.size() == 1)
163  return myArgs[0];
164  break;
165 
166  case OpXor:
167  if (myArgs.size() == 0)
168  return xorRemovedOddTrues ? CONST_TRUE : CONST_FALSE;
169  if (myArgs.size() == 1)
170  return xorRemovedOddTrues ? NOT(myArgs[0]) : myArgs[0];
171  break;
172 
173  case OpIFF:
174  assert(myArgs.size() >= 1);
175  if (myArgs.size() == 1)
176  return CONST_TRUE;
177  // FIXME: Add proper const folding
178  break;
179 
180  case OpITE:
181  assert(myArgs.size() == 3);
182  if (myArgs[0] == CONST_TRUE)
183  return myArgs[1];
184  if (myArgs[0] == CONST_FALSE)
185  return myArgs[2];
186  break;
187 
188  default:
189  abort();
190  }
191 
192  std::pair<OpId, std::vector<int>> myExpr(op, myArgs);
193  int id = 0;
194 
195  if (expressionsCache.count(myExpr) > 0) {
196  id = expressionsCache.at(myExpr);
197  } else {
198  id = -(int(expressions.size()) + 1);
199  expressionsCache[myExpr] = id;
200  expressions.push_back(myExpr);
201  }
202 
203  return xorRemovedOddTrues ? NOT(id) : id;
204 }
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
static const int CONST_FALSE
Definition: ezsat.h:49
int NOT(_V a)
Definition: ezsat.h:197
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61
std::map< std::pair< OpId, std::vector< int > >, int > expressionsCache
Definition: ezsat.h:60
static const int CONST_TRUE
Definition: ezsat.h:48
std::string id(RTLIL::IdString internal_id, bool may_rename=true)

+ Here is the call graph for this function:

virtual void ezMiniSAT::freeze ( int  id)
virtual

Reimplemented from ezSAT.

+ Here is the caller graph for this function:

int ezSAT::frozen_literal ( )
inherited

Definition at line 88 of file ezsat.cc.

89 {
90  int id = literal();
91  freeze(id);
92  return id;
93 }
virtual void freeze(int id)
Definition: ezsat.cc:379
int literal()
Definition: ezsat.cc:73
std::string id(RTLIL::IdString internal_id, bool may_rename=true)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::frozen_literal ( const std::string &  name)
inherited

Definition at line 95 of file ezsat.cc.

96 {
97  int id = literal(name);
98  freeze(id);
99  return id;
100 }
virtual void freeze(int id)
Definition: ezsat.cc:379
int literal()
Definition: ezsat.cc:73
std::string id(RTLIL::IdString internal_id, bool may_rename=true)

+ Here is the call graph for this function:

void ezSAT::getFullCnf ( std::vector< std::vector< int >> &  full_cnf) const
inherited

Definition at line 625 of file ezsat.cc.

626 {
627  assert(full_cnf.empty());
628  full_cnf.insert(full_cnf.end(), cnfClausesBackup.begin(), cnfClausesBackup.end());
629  full_cnf.insert(full_cnf.end(), cnfClauses.begin(), cnfClauses.end());
630 }
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66
std::vector< std::vector< int > > cnfClausesBackup
Definition: ezsat.h:66

+ Here is the caller graph for this function:

bool ezSAT::getSolverTimoutStatus ( )
inlineinherited

Definition at line 153 of file ezsat.h.

153  {
154  return solverTimoutStatus;
155  }
bool solverTimoutStatus
Definition: ezsat.h:81
int ezSAT::IFF ( _V  a,
_V  b = 0,
_V  c = 0,
_V  d = 0,
_V  e = 0,
_V  f = 0 
)
inlineinherited

Definition at line 213 of file ezsat.h.

213  {
214  return expression(OpIFF, a.get(this), b.get(this), c.get(this), d.get(this), e.get(this), f.get(this));
215  }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::ITE ( _V  a,
_V  b,
_V  c 
)
inlineinherited

Definition at line 217 of file ezsat.h.

217  {
218  return expression(OpITE, a.get(this), b.get(this), c.get(this));
219  }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::keep_cnf ( )
inlineinherited

Definition at line 86 of file ezsat.h.

86 { flag_keep_cnf = true; }
bool flag_keep_cnf
Definition: ezsat.h:52

+ Here is the caller graph for this function:

int ezSAT::literal ( )
inherited

Definition at line 73 of file ezsat.cc.

74 {
75  literals.push_back(std::string());
76  return literals.size();
77 }
std::vector< std::string > literals
Definition: ezsat.h:58

+ Here is the caller graph for this function:

int ezSAT::literal ( const std::string &  name)
inherited

Definition at line 79 of file ezsat.cc.

80 {
81  if (literalsCache.count(name) == 0) {
82  literals.push_back(name);
83  literalsCache[name] = literals.size();
84  }
85  return literalsCache.at(name);
86 }
std::vector< std::string > literals
Definition: ezsat.h:58
std::map< std::string, int > literalsCache
Definition: ezsat.h:57
void ezSAT::lookup_expression ( int  id,
OpId op,
std::vector< int > &  args 
) const
inherited

Definition at line 218 of file ezsat.cc.

219 {
220  assert(0 < -id && -id <= int(expressions.size()));
221  op = expressions[-id - 1].first;
222  args = expressions[-id - 1].second;
223 }
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61

+ Here is the caller graph for this function:

const std::vector< int > & ezSAT::lookup_expression ( int  id,
OpId op 
) const
inherited

Definition at line 225 of file ezsat.cc.

226 {
227  assert(0 < -id && -id <= int(expressions.size()));
228  op = expressions[-id - 1].first;
229  return expressions[-id - 1].second;
230 }
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61
void ezSAT::lookup_literal ( int  id,
std::string &  name 
) const
inherited

Definition at line 206 of file ezsat.cc.

207 {
208  assert(0 < id && id <= int(literals.size()));
209  name = literals[id - 1];
210 }
std::vector< std::string > literals
Definition: ezsat.h:58

+ Here is the caller graph for this function:

const std::string & ezSAT::lookup_literal ( int  id) const
inherited

Definition at line 212 of file ezsat.cc.

213 {
214  assert(0 < id && id <= int(literals.size()));
215  return literals[id - 1];
216 }
std::vector< std::string > literals
Definition: ezsat.h:58
int ezSAT::manyhot ( const std::vector< int > &  vec,
int  min_hot,
int  max_hot = -1 
)
inherited

Definition at line 1333 of file ezsat.cc.

1334 {
1335  // many-hot encoding using a simple sorting network
1336 
1337  if (max_hot < 0)
1338  max_hot = min_hot;
1339 
1340  std::vector<int> formula;
1341  int M = max_hot+1, N = vec.size();
1342  std::map<std::pair<int,int>, int> x;
1343 
1344  for (int i = -1; i < N; i++)
1345  for (int j = -1; j < M; j++)
1346  x[std::pair<int,int>(i,j)] = j < 0 ? CONST_TRUE : i < 0 ? CONST_FALSE : literal();
1347 
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)]));
1354 #if 0
1355  // explicit resolution clauses -- in tests it was better to let the sat solver figure those out
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)])));
1358 #endif
1359  }
1360 
1361  for (int j = 0; j < M; j++) {
1362  if (j+1 <= min_hot)
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)]));
1366  }
1367 
1368  return expression(OpAnd, formula);
1369 }
static const int CONST_FALSE
Definition: ezsat.h:49
int NOT(_V a)
Definition: ezsat.h:197
static const int CONST_TRUE
Definition: ezsat.h:48
int literal()
Definition: ezsat.cc:73
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ezSAT::mode_keep_cnf ( ) const
inlineinherited

Definition at line 89 of file ezsat.h.

89 { return flag_keep_cnf; }
bool flag_keep_cnf
Definition: ezsat.h:52

+ Here is the caller graph for this function:

bool ezSAT::mode_non_incremental ( ) const
inlineinherited

Definition at line 90 of file ezsat.h.

90 { return flag_non_incremental; }
bool flag_non_incremental
Definition: ezsat.h:53

+ Here is the caller graph for this function:

void ezSAT::non_incremental ( )
inlineinherited

Definition at line 87 of file ezsat.h.

87 { flag_non_incremental = true; }
bool flag_non_incremental
Definition: ezsat.h:53

+ Here is the caller graph for this function:

int ezSAT::NOT ( _V  a)
inlineinherited

Definition at line 197 of file ezsat.h.

197  {
198  return expression(OpNot, a.get(this));
199  }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::numCnfClauses ( ) const
inlineinherited

Definition at line 167 of file ezsat.h.

167 { return cnfClausesCount; }
int cnfClausesCount
Definition: ezsat.h:64

+ Here is the caller graph for this function:

int ezSAT::numCnfVariables ( ) const
inlineinherited

Definition at line 166 of file ezsat.h.

166 { return cnfVariableCount; }
int cnfVariableCount
Definition: ezsat.h:64

+ Here is the caller graph for this function:

int ezSAT::numExpressions ( ) const
inlineinherited

Definition at line 112 of file ezsat.h.

112 { return expressions.size(); }
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61
int ezSAT::numLiterals ( ) const
inlineinherited

Definition at line 111 of file ezsat.h.

111 { return literals.size(); }
std::vector< std::string > literals
Definition: ezsat.h:58

+ Here is the caller graph for this function:

int ezSAT::onehot ( const std::vector< int > &  vec,
bool  max_only = false 
)
inherited

Definition at line 1303 of file ezsat.cc.

1304 {
1305  // Mixed one-hot/binary encoding as described by Claessen in Sec. 4.2 of
1306  // "Successful SAT Encoding Techniques. Magnus Bjiirk. 25th July 2009".
1307  // http://jsat.ewi.tudelft.nl/addendum/Bjork_encoding.pdf
1308 
1309  std::vector<int> formula;
1310 
1311  // add at-leat-one constraint
1312  if (max_only == false)
1313  formula.push_back(expression(OpOr, vec));
1314 
1315  // create binary vector
1316  int num_bits = ceil(log2(vec.size()));
1317  std::vector<int> bits;
1318  for (int k = 0; k < num_bits; k++)
1319  bits.push_back(literal());
1320 
1321  // add at-most-one clauses using binary encoding
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]));
1327  formula.push_back(expression(OpOr, clause));
1328  }
1329 
1330  return expression(OpAnd, formula);
1331 }
int NOT(_V a)
Definition: ezsat.h:197
int literal()
Definition: ezsat.cc:73
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::OR ( _V  a = 0,
_V  b = 0,
_V  c = 0,
_V  d = 0,
_V  e = 0,
_V  f = 0 
)
inlineinherited

Definition at line 205 of file ezsat.h.

205  {
206  return expression(OpOr, a.get(this), b.get(this), c.get(this), d.get(this), e.get(this), f.get(this));
207  }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::ordered ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2,
bool  allow_equal = true 
)
inherited

Definition at line 1371 of file ezsat.cc.

1372 {
1373  std::vector<int> formula;
1374  int last_x = CONST_FALSE;
1375 
1376  assert(vec1.size() == vec2.size());
1377  for (size_t i = 0; i < vec1.size(); i++)
1378  {
1379  int a = vec1[i], b = vec2[i];
1380  formula.push_back(OR(NOT(a), b, last_x));
1381 
1382  int next_x = i+1 < vec1.size() ? literal() : allow_equal ? CONST_FALSE : CONST_TRUE;
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)));
1385  last_x = next_x;
1386  }
1387 
1388  return expression(OpAnd, formula);
1389 }
static const int CONST_FALSE
Definition: ezsat.h:49
int NOT(_V a)
Definition: ezsat.h:197
static const int CONST_TRUE
Definition: ezsat.h:48
int literal()
Definition: ezsat.cc:73
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::parse_string ( const std::string &  text)
inherited

Definition at line 232 of file ezsat.cc.

233 {
234  abort();
235 }
void ezSAT::preSolverCallback ( )
protectedinherited

Definition at line 632 of file ezsat.cc.

633 {
635  if (mode_non_incremental())
637 }
bool mode_non_incremental() const
Definition: ezsat.h:90
bool non_incremental_solve_used_up
Definition: ezsat.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::printDIMACS ( FILE *  f,
bool  verbose = false 
) const
inherited

Definition at line 1188 of file ezsat.cc.

1189 {
1190  if (cnfConsumed) {
1191  fprintf(stderr, "Usage error: printDIMACS() must not be called after cnfConsumed()!");
1192  abort();
1193  }
1194 
1195  int digits = ceil(log10f(cnfVariableCount)) + 2;
1196 
1197  fprintf(f, "c generated by ezSAT\n");
1198 
1199  if (verbose)
1200  {
1201  fprintf(f, "c\n");
1202  fprintf(f, "c mapping of variables to literals:\n");
1203  for (int i = 0; i < int(cnfLiteralVariables.size()); i++)
1204  if (cnfLiteralVariables[i] != 0)
1205  fprintf(f, "c %*d: %s\n", digits, cnfLiteralVariables[i], literals[i].c_str());
1206 
1207  fprintf(f, "c\n");
1208  fprintf(f, "c mapping of variables to expressions:\n");
1209  for (int i = 0; i < int(cnfExpressionVariables.size()); i++)
1210  if (cnfExpressionVariables[i] != 0)
1211  fprintf(f, "c %*d: %d\n", digits, cnfExpressionVariables[i], -i-1);
1212 
1213  if (mode_keep_cnf()) {
1214  fprintf(f, "c\n");
1215  fprintf(f, "c %d clauses from backup, %d from current buffer\n",
1216  int(cnfClausesBackup.size()), int(cnfClauses.size()));
1217  }
1218 
1219  fprintf(f, "c\n");
1220  }
1221 
1222  std::vector<std::vector<int>> all_clauses;
1223  getFullCnf(all_clauses);
1224  assert(cnfClausesCount == int(all_clauses.size()));
1225 
1226  fprintf(f, "p cnf %d %d\n", cnfVariableCount, cnfClausesCount);
1227  int maxClauseLen = 0;
1228  for (auto &clause : all_clauses)
1229  maxClauseLen = std::max(int(clause.size()), maxClauseLen);
1230  if (!verbose)
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);
1237  else
1238  fprintf(f, " %*d\n", digits, 0);
1239  }
1240 }
int cnfClausesCount
Definition: ezsat.h:64
static std::string idx(std::string str)
Definition: test_autotb.cc:57
bool mode_keep_cnf() const
Definition: ezsat.h:89
std::vector< std::string > literals
Definition: ezsat.h:58
std::vector< int > cnfLiteralVariables
Definition: ezsat.h:65
bool cnfConsumed
Definition: ezsat.h:63
int cnfVariableCount
Definition: ezsat.h:64
void getFullCnf(std::vector< std::vector< int >> &full_cnf) const
Definition: ezsat.cc:625
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66
std::vector< std::vector< int > > cnfClausesBackup
Definition: ezsat.h:66
std::vector< int > cnfExpressionVariables
Definition: ezsat.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::printInternalState ( FILE *  f) const
inherited

Definition at line 1263 of file ezsat.cc.

1264 {
1265  fprintf(f, "--8<-- snip --8<--\n");
1266 
1267  fprintf(f, "literalsCache:\n");
1268  for (auto &it : literalsCache)
1269  fprintf(f, " `%s' -> %d\n", it.first.c_str(), it.second);
1270 
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());
1274 
1275  fprintf(f, "expressionsCache:\n");
1276  for (auto &it : expressionsCache)
1277  fprintf(f, " `%s' -> %d\n", expression2str(it.first).c_str(), it.second);
1278 
1279  fprintf(f, "expressions:\n");
1280  for (int i = 0; i < int(expressions.size()); i++)
1281  fprintf(f, " %d: `%s'\n", -i-1, expression2str(expressions[i]).c_str());
1282 
1283  fprintf(f, "cnfVariables (count=%d):\n", cnfVariableCount);
1284  for (int i = 0; i < int(cnfLiteralVariables.size()); i++)
1285  if (cnfLiteralVariables[i] != 0)
1286  fprintf(f, " literal %d -> %d (%s)\n", i+1, cnfLiteralVariables[i], to_string(i+1).c_str());
1287  for (int i = 0; i < int(cnfExpressionVariables.size()); i++)
1288  if (cnfExpressionVariables[i] != 0)
1289  fprintf(f, " expression %d -> %d (%s)\n", -i-1, cnfExpressionVariables[i], to_string(-i-1).c_str());
1290 
1291  fprintf(f, "cnfClauses:\n");
1292  for (auto &i1 : cnfClauses) {
1293  for (auto &i2 : i1)
1294  fprintf(f, " %4d", i2);
1295  fprintf(f, "\n");
1296  }
1297  if (cnfConsumed)
1298  fprintf(f, " *** more clauses consumed via cnfConsume() ***\n");
1299 
1300  fprintf(f, "--8<-- snap --8<--\n");
1301 }
std::vector< std::string > literals
Definition: ezsat.h:58
std::vector< std::pair< OpId, std::vector< int > > > expressions
Definition: ezsat.h:61
std::vector< int > cnfLiteralVariables
Definition: ezsat.h:65
std::string to_string(int id) const
Definition: ezsat.cc:237
std::map< std::pair< OpId, std::vector< int > >, int > expressionsCache
Definition: ezsat.h:60
bool cnfConsumed
Definition: ezsat.h:63
static std::string expression2str(const std::pair< ezSAT::OpId, std::vector< int >> &data)
Definition: ezsat.cc:1242
int cnfVariableCount
Definition: ezsat.h:64
std::vector< std::vector< int > > cnfClauses
Definition: ezsat.h:66
std::map< std::string, int > literalsCache
Definition: ezsat.h:57
std::vector< int > cnfExpressionVariables
Definition: ezsat.h:65

+ Here is the call graph for this function:

void ezSAT::SET ( _V  a,
_V  b 
)
inlineinherited

Definition at line 221 of file ezsat.h.

221  {
222  assume(IFF(a.get(this), b.get(this)));
223  }
void assume(int id)
Definition: ezsat.cc:388
int IFF(_V a, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:213

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::setSolverTimeout ( int  newTimeoutSeconds)
inlineinherited

Definition at line 149 of file ezsat.h.

149  {
150  solverTimeout = newTimeoutSeconds;
151  }
int solverTimeout
Definition: ezsat.h:80
bool ezSAT::solve ( const std::vector< int > &  modelExpressions,
std::vector< bool > &  modelValues,
const std::vector< int > &  assumptions 
)
inlineinherited

Definition at line 122 of file ezsat.h.

122  {
123  return solver(modelExpressions, modelValues, assumptions);
124  }
virtual bool solver(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
Definition: ezsat.cc:639

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ezSAT::solve ( const std::vector< int > &  modelExpressions,
std::vector< bool > &  modelValues,
int  a = 0,
int  b = 0,
int  c = 0,
int  d = 0,
int  e = 0,
int  f = 0 
)
inlineinherited

Definition at line 126 of file ezsat.h.

126  {
127  std::vector<int> assumptions;
128  if (a != 0) assumptions.push_back(a);
129  if (b != 0) assumptions.push_back(b);
130  if (c != 0) assumptions.push_back(c);
131  if (d != 0) assumptions.push_back(d);
132  if (e != 0) assumptions.push_back(e);
133  if (f != 0) assumptions.push_back(f);
134  return solver(modelExpressions, modelValues, assumptions);
135  }
virtual bool solver(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
Definition: ezsat.cc:639

+ Here is the call graph for this function:

bool ezSAT::solve ( int  a = 0,
int  b = 0,
int  c = 0,
int  d = 0,
int  e = 0,
int  f = 0 
)
inlineinherited

Definition at line 137 of file ezsat.h.

137  {
138  std::vector<int> assumptions, modelExpressions;
139  std::vector<bool> modelValues;
140  if (a != 0) assumptions.push_back(a);
141  if (b != 0) assumptions.push_back(b);
142  if (c != 0) assumptions.push_back(c);
143  if (d != 0) assumptions.push_back(d);
144  if (e != 0) assumptions.push_back(e);
145  if (f != 0) assumptions.push_back(f);
146  return solver(modelExpressions, modelValues, assumptions);
147  }
virtual bool solver(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
Definition: ezsat.cc:639

+ Here is the call graph for this function:

bool ezMiniSAT::solver ( const std::vector< int > &  modelExpressions,
std::vector< bool > &  modelValues,
const std::vector< int > &  assumptions 
)
virtual

Reimplemented from ezSAT.

Definition at line 97 of file ezminisat.cc.

98 {
100 
101  solverTimoutStatus = false;
102 
103  if (0) {
104 contradiction:
105  delete minisatSolver;
107  minisatVars.clear();
108  foundContradiction = true;
109  return false;
110  }
111 
112  if (foundContradiction) {
113  consumeCnf();
114  return false;
115  }
116 
117  std::vector<int> extraClauses, modelIdx;
118 
119  for (auto id : assumptions)
120  extraClauses.push_back(bind(id));
121  for (auto id : modelExpressions)
122  modelIdx.push_back(bind(id));
123 
124  if (minisatSolver == NULL) {
125  minisatSolver = new Solver;
127  }
128 
129 #if EZMINISAT_INCREMENTAL
130  std::vector<std::vector<int>> cnf;
131  consumeCnf(cnf);
132 #else
133  const std::vector<std::vector<int>> &cnf = this->cnf();
134 #endif
135 
136  while (int(minisatVars.size()) < numCnfVariables())
137  minisatVars.push_back(minisatSolver->newVar());
138 
139 #if EZMINISAT_SIMPSOLVER && EZMINISAT_INCREMENTAL
140  for (auto idx : cnfFrozenVars)
141  minisatSolver->setFrozen(minisatVars.at(idx > 0 ? idx-1 : -idx-1), true);
142  cnfFrozenVars.clear();
143 #endif
144 
145  for (auto &clause : cnf) {
147  for (auto idx : clause) {
148  if (idx > 0)
149  ps.push(Minisat::mkLit(minisatVars.at(idx-1)));
150  else
151  ps.push(Minisat::mkLit(minisatVars.at(-idx-1), true));
152 #if EZMINISAT_SIMPSOLVER
153  if (minisatSolver->isEliminated(minisatVars.at(idx > 0 ? idx-1 : -idx-1))) {
154  fprintf(stderr, "Assert in %s:%d failed! Missing call to ezsat->freeze(): %s (lit=%d)\n",
155  __FILE__, __LINE__, cnfLiteralInfo(idx).c_str(), idx);
156  abort();
157  }
158 #endif
159  }
160  if (!minisatSolver->addClause(ps))
161  goto contradiction;
162  }
163 
164  if (cnf.size() > 0 && !minisatSolver->simplify())
165  goto contradiction;
166 
168 
169  for (auto idx : extraClauses) {
170  if (idx > 0)
171  assumps.push(Minisat::mkLit(minisatVars.at(idx-1)));
172  else
173  assumps.push(Minisat::mkLit(minisatVars.at(-idx-1), true));
174 #if EZMINISAT_SIMPSOLVER
175  if (minisatSolver->isEliminated(minisatVars.at(idx > 0 ? idx-1 : -idx-1))) {
176  fprintf(stderr, "Assert in %s:%d failed! Missing call to ezsat->freeze(): %s\n", __FILE__, __LINE__, cnfLiteralInfo(idx).c_str());
177  abort();
178  }
179 #endif
180  }
181 
182 #ifndef _WIN32
183  struct sigaction sig_action;
184  struct sigaction old_sig_action;
185  int old_alarm_timeout = 0;
186 
187  if (solverTimeout > 0) {
188  sig_action.sa_handler = alarmHandler;
189  sigemptyset(&sig_action.sa_mask);
190  sig_action.sa_flags = SA_RESTART;
191  alarmHandlerThis = this;
192  alarmHandlerTimeout = clock() + solverTimeout*CLOCKS_PER_SEC;
193  old_alarm_timeout = alarm(0);
194  sigaction(SIGALRM, &sig_action, &old_sig_action);
195  alarm(1);
196  }
197 #endif
198 
199  bool foundSolution = minisatSolver->solve(assumps);
200 
201 #ifndef _WIN32
202  if (solverTimeout > 0) {
203  if (alarmHandlerTimeout == 0)
204  solverTimoutStatus = true;
205  alarm(0);
206  sigaction(SIGALRM, &old_sig_action, NULL);
207  alarm(old_alarm_timeout);
208  }
209 #endif
210 
211  if (!foundSolution) {
212 #if !EZMINISAT_INCREMENTAL
213  delete minisatSolver;
215  minisatVars.clear();
216 #endif
217  return false;
218  }
219 
220  modelValues.clear();
221  modelValues.resize(modelIdx.size());
222 
223  for (size_t i = 0; i < modelIdx.size(); i++)
224  {
225  int idx = modelIdx[i];
226  bool refvalue = true;
227 
228  if (idx < 0)
229  idx = -idx, refvalue = false;
230 
231  using namespace Minisat;
233  modelValues[i] = (value == Minisat::lbool(refvalue));
234  }
235 
236 #if !EZMINISAT_INCREMENTAL
237  delete minisatSolver;
239  minisatVars.clear();
240 #endif
241  return true;
242 }
Solver * minisatSolver
Definition: ezminisat.h:46
const std::vector< std::vector< int > > & cnf() const
Definition: ezsat.h:168
std::string cnfLiteralInfo(int idx) const
Definition: ezsat.cc:503
#define EZMINISAT_VERBOSITY
Definition: ezminisat.h:24
bool simplify()
Definition: Solver.cc:643
Lit mkLit(Var var, bool sign=false)
Definition: SolverTypes.h:63
int solverTimeout
Definition: ezsat.h:80
lbool modelValue(Var x) const
Definition: Solver.h:352
Minisat::SimpSolver Solver
Definition: ezminisat.h:42
void setFrozen(Var v, bool b)
Definition: SimpSolver.h:192
static std::string idx(std::string str)
Definition: test_autotb.cc:57
static void alarmHandler(int)
Definition: ezminisat.cc:87
int value(bool val)
Definition: ezsat.cc:68
void consumeCnf()
Definition: ezsat.cc:606
void preSolverCallback()
Definition: ezsat.cc:632
std::set< int > cnfFrozenVars
Definition: ezminisat.h:51
int numCnfVariables() const
Definition: ezsat.h:166
static ezMiniSAT * alarmHandlerThis
Definition: ezminisat.h:55
Var newVar(lbool upol=l_Undef, bool dvar=true)
Definition: SimpSolver.cc:79
void push(void)
Definition: Vec.h:74
bool addClause(const vec< Lit > &ps)
Definition: SimpSolver.h:186
bool foundContradiction
Definition: ezminisat.h:48
bool solverTimoutStatus
Definition: ezsat.h:81
bool isEliminated(Var v) const
Definition: SimpSolver.h:178
std::vector< int > minisatVars
Definition: ezminisat.h:47
#define NULL
bool solve(const vec< Lit > &assumps, bool do_simp=true, bool turn_off_simp=false)
Definition: SimpSolver.h:213
static clock_t alarmHandlerTimeout
Definition: ezminisat.h:56
int bind(int id, bool auto_freeze=true)
Definition: ezsat.cc:520

+ Here is the call graph for this function:

std::string ezSAT::to_string ( int  id) const
inherited

Definition at line 237 of file ezsat.cc.

238 {
239  std::string text;
240 
241  if (id > 0)
242  {
243  lookup_literal(id, text);
244  }
245  else
246  {
247  OpId op;
248  std::vector<int> args;
249  lookup_expression(id, op, args);
250 
251  switch (op)
252  {
253  case OpNot:
254  text = "not(";
255  break;
256 
257  case OpAnd:
258  text = "and(";
259  break;
260 
261  case OpOr:
262  text = "or(";
263  break;
264 
265  case OpXor:
266  text = "xor(";
267  break;
268 
269  case OpIFF:
270  text = "iff(";
271  break;
272 
273  case OpITE:
274  text = "ite(";
275  break;
276 
277  default:
278  abort();
279  }
280 
281  for (int i = 0; i < int(args.size()); i++) {
282  if (i > 0)
283  text += ", ";
284  text += to_string(args[i]);
285  }
286 
287  text += ")";
288  }
289 
290  return text;
291 }
void lookup_expression(int id, OpId &op, std::vector< int > &args) const
Definition: ezsat.cc:218
OpId
Definition: ezsat.h:44
void lookup_literal(int id, std::string &name) const
Definition: ezsat.cc:206
std::string to_string(int id) const
Definition: ezsat.cc:237

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::value ( bool  val)
inherited

Definition at line 68 of file ezsat.cc.

69 {
70  return val ? CONST_TRUE : CONST_FALSE;
71 }
static const int CONST_FALSE
Definition: ezsat.h:49
static const int CONST_TRUE
Definition: ezsat.h:48

+ Here is the caller graph for this function:

int ezSAT::VAR ( _V  a)
inlineinherited

Definition at line 193 of file ezsat.h.

193  {
194  return a.get(this);
195  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ezSATvec ezSAT::vec ( const std::vector< int > &  vec)
inherited

Definition at line 1183 of file ezsat.cc.

1184 {
1185  return ezSATvec(*this, vec);
1186 }
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_add ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 819 of file ezsat.cc.

820 {
821  assert(vec1.size() == vec2.size());
822  std::vector<int> vec(vec1.size());
823  int carry = CONST_FALSE;
824  for (int i = 0; i < int(vec1.size()); i++)
825  fulladder(this, vec1[i], vec2[i], carry, carry, vec[i]);
826 
827 #if 0
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 ? ", " : "");
831  printf("], vec2=[");
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 ? ", " : "");
837  printf("]\n");
838 #endif
839 
840  return vec;
841 }
static const int CONST_FALSE
Definition: ezsat.h:49
std::string to_string(int id) const
Definition: ezsat.cc:237
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183
static void fulladder(ezSAT *that, int a, int b, int c, int &y, int &x)
Definition: ezsat.cc:765

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_and ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 709 of file ezsat.cc.

710 {
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]);
715  return vec;
716 }
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::vec_append ( std::vector< int > &  vec,
const std::vector< int > &  vec1 
) const
inherited

Definition at line 1083 of file ezsat.cc.

1084 {
1085  for (auto bit : vec1)
1086  vec.push_back(bit);
1087 }
struct ezSATbit bit(_V a)
Definition: ezsat.cc:1178
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::vec_append_signed ( std::vector< int > &  vec,
const std::vector< int > &  vec1,
int64_t  value 
)
inherited

Definition at line 1089 of file ezsat.cc.

1090 {
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]);
1095  else
1096  vec.push_back(NOT(vec1[i]));
1097  }
1098 }
int NOT(_V a)
Definition: ezsat.h:197
int value(bool val)
Definition: ezsat.cc:68
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

void ezSAT::vec_append_unsigned ( std::vector< int > &  vec,
const std::vector< int > &  vec1,
uint64_t  value 
)
inherited

Definition at line 1100 of file ezsat.cc.

1101 {
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]);
1106  else
1107  vec.push_back(NOT(vec1[i]));
1108  }
1109 }
int NOT(_V a)
Definition: ezsat.h:197
int value(bool val)
Definition: ezsat.cc:68
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_cast ( const std::vector< int > &  vec1,
int  toBits,
bool  signExtend = false 
)
inherited

Definition at line 690 of file ezsat.cc.

691 {
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);
696  else
697  vec.push_back(vec1[i]);
698  return vec;
699 }
static const int CONST_FALSE
Definition: ezsat.h:49
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

void ezSAT::vec_cmp ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2,
int &  carry,
int &  overflow,
int &  sign,
int &  zero 
)
inherited

Definition at line 873 of file ezsat.cc.

874 {
875  assert(vec1.size() == vec2.size());
876  carry = CONST_TRUE;
877  zero = CONST_FALSE;
878  for (int i = 0; i < int(vec1.size()); i++) {
879  overflow = carry;
880  fulladder(this, vec1[i], NOT(vec2[i]), carry, carry, sign);
881  zero = OR(zero, sign);
882  }
883  overflow = XOR(overflow, carry);
884  carry = NOT(carry);
885  zero = NOT(zero);
886 
887 #if 0
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 ? ", " : "");
891  printf("], vec2=[");
892  for (int i = int(vec2.size())-1; i >= 0; i--)
893  printf("%s%s", to_string(vec2[i]).c_str(), i ? ", " : "");
894  printf("], carry=%s, overflow=%s, sign=%s, zero=%s\n", to_string(carry).c_str(), to_string(overflow).c_str(), to_string(sign).c_str(), to_string(zero).c_str());
895 #endif
896 }
static const int CONST_FALSE
Definition: ezsat.h:49
int NOT(_V a)
Definition: ezsat.h:197
bool sign(Lit p)
Definition: SolverTypes.h:66
std::string to_string(int id) const
Definition: ezsat.cc:237
static const int CONST_TRUE
Definition: ezsat.h:48
int XOR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:209
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205
static void fulladder(ezSAT *that, int a, int b, int c, int &y, int &x)
Definition: ezsat.cc:765

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_const ( const std::vector< bool > &  bits)
inherited

Definition at line 649 of file ezsat.cc.

650 {
651  std::vector<int> vec;
652  for (auto bit : bits)
653  vec.push_back(bit ? CONST_TRUE : CONST_FALSE);
654  return vec;
655 }
static const int CONST_FALSE
Definition: ezsat.h:49
static const int CONST_TRUE
Definition: ezsat.h:48
struct ezSATbit bit(_V a)
Definition: ezsat.cc:1178
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

std::vector< int > ezSAT::vec_const_signed ( int64_t  value,
int  numBits 
)
inherited

Definition at line 657 of file ezsat.cc.

658 {
659  std::vector<int> vec;
660  for (int i = 0; i < numBits; i++)
661  vec.push_back(((value >> i) & 1) != 0 ? CONST_TRUE : CONST_FALSE);
662  return vec;
663 }
static const int CONST_FALSE
Definition: ezsat.h:49
int value(bool val)
Definition: ezsat.cc:68
static const int CONST_TRUE
Definition: ezsat.h:48
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_const_unsigned ( uint64_t  value,
int  numBits 
)
inherited

Definition at line 665 of file ezsat.cc.

666 {
667  std::vector<int> vec;
668  for (int i = 0; i < numBits; i++)
669  vec.push_back(((value >> i) & 1) != 0 ? CONST_TRUE : CONST_FALSE);
670  return vec;
671 }
static const int CONST_FALSE
Definition: ezsat.h:49
int value(bool val)
Definition: ezsat.cc:68
static const int CONST_TRUE
Definition: ezsat.h:48
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_count ( const std::vector< int > &  vec,
int  numBits,
bool  clip = true 
)
inherited

Definition at line 789 of file ezsat.cc.

790 {
791  std::vector<int> sum = vec_const_unsigned(0, numBits);
792  std::vector<int> carry_vector;
793 
794  for (auto bit : vec) {
795  int carry = bit;
796  for (int i = 0; i < numBits; i++)
797  halfadder(this, carry, sum[i], carry, sum[i]);
798  carry_vector.push_back(carry);
799  }
800 
801  if (clip) {
802  int overflow = vec_reduce_or(carry_vector);
803  sum = vec_ite(overflow, vec_const_unsigned(~0, numBits), sum);
804  }
805 
806 #if 0
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 ? ", " : "");
813  printf("]\n");
814 #endif
815 
816  return sum;
817 }
std::string to_string(int id) const
Definition: ezsat.cc:237
std::vector< int > vec_const_unsigned(uint64_t value, int numBits)
Definition: ezsat.cc:665
static void halfadder(ezSAT *that, int a, int b, int &y, int &x)
Definition: ezsat.cc:778
int vec_reduce_or(const std::vector< int > &vec1)
Definition: ezsat.cc:1144
std::vector< int > vec_ite(const std::vector< int > &vec1, const std::vector< int > &vec2, const std::vector< int > &vec3)
Definition: ezsat.cc:745
struct ezSATbit bit(_V a)
Definition: ezsat.cc:1178
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_eq ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 954 of file ezsat.cc.

955 {
956  return vec_reduce_and(vec_iff(vec1, vec2));
957 }
std::vector< int > vec_iff(const std::vector< int > &vec1, const std::vector< int > &vec2)
Definition: ezsat.cc:736
int vec_reduce_and(const std::vector< int > &vec1)
Definition: ezsat.cc:1139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_ge_signed ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 912 of file ezsat.cc.

913 {
914  int carry, overflow, sign, zero;
915  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
916  return OR(AND(NOT(overflow), NOT(sign)), AND(overflow, sign));
917 }
int NOT(_V a)
Definition: ezsat.h:197
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
bool sign(Lit p)
Definition: SolverTypes.h:66
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_ge_unsigned ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 940 of file ezsat.cc.

941 {
942  int carry, overflow, sign, zero;
943  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
944  return NOT(carry);
945 }
int NOT(_V a)
Definition: ezsat.h:197
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
bool sign(Lit p)
Definition: SolverTypes.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_gt_signed ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 919 of file ezsat.cc.

920 {
921  int carry, overflow, sign, zero;
922  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
923  return AND(OR(AND(NOT(overflow), NOT(sign)), AND(overflow, sign)), NOT(zero));
924 }
int NOT(_V a)
Definition: ezsat.h:197
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
bool sign(Lit p)
Definition: SolverTypes.h:66
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_gt_unsigned ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 947 of file ezsat.cc.

948 {
949  int carry, overflow, sign, zero;
950  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
951  return AND(NOT(carry), NOT(zero));
952 }
int NOT(_V a)
Definition: ezsat.h:197
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
bool sign(Lit p)
Definition: SolverTypes.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_iff ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 736 of file ezsat.cc.

737 {
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]);
742  return vec;
743 }
int IFF(_V a, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:213
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_ite ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2,
const std::vector< int > &  vec3 
)
inherited

Definition at line 745 of file ezsat.cc.

746 {
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]);
751  return vec;
752 }
int ITE(_V a, _V b, _V c)
Definition: ezsat.h:217
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_ite ( int  sel,
const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 755 of file ezsat.cc.

756 {
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]);
761  return vec;
762 }
int ITE(_V a, _V b, _V c)
Definition: ezsat.h:217
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

int ezSAT::vec_le_signed ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 905 of file ezsat.cc.

906 {
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);
910 }
int NOT(_V a)
Definition: ezsat.h:197
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
bool sign(Lit p)
Definition: SolverTypes.h:66
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_le_unsigned ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 933 of file ezsat.cc.

934 {
935  int carry, overflow, sign, zero;
936  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
937  return OR(carry, zero);
938 }
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
bool sign(Lit p)
Definition: SolverTypes.h:66
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_lt_signed ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 898 of file ezsat.cc.

899 {
900  int carry, overflow, sign, zero;
901  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
902  return OR(AND(NOT(overflow), sign), AND(overflow, NOT(sign)));
903 }
int NOT(_V a)
Definition: ezsat.h:197
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
bool sign(Lit p)
Definition: SolverTypes.h:66
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_lt_unsigned ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 926 of file ezsat.cc.

927 {
928  int carry, overflow, sign, zero;
929  vec_cmp(vec1, vec2, carry, overflow, sign, zero);
930  return carry;
931 }
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
Definition: ezsat.cc:873
bool sign(Lit p)
Definition: SolverTypes.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t ezSAT::vec_model_get_signed ( const std::vector< int > &  modelExpressions,
const std::vector< bool > &  modelValues,
const std::vector< int > &  vec1 
) const
inherited

Definition at line 1111 of file ezsat.cc.

1112 {
1113  int64_t value = 0;
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;
1122  }
1123  return value;
1124 }
int value(bool val)
Definition: ezsat.cc:68

+ Here is the call graph for this function:

uint64_t ezSAT::vec_model_get_unsigned ( const std::vector< int > &  modelExpressions,
const std::vector< bool > &  modelValues,
const std::vector< int > &  vec1 
) const
inherited

Definition at line 1126 of file ezsat.cc.

1127 {
1128  uint64_t value = 0;
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;
1136  return value;
1137 }
int value(bool val)
Definition: ezsat.cc:68

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_ne ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 959 of file ezsat.cc.

960 {
961  return NOT(vec_reduce_and(vec_iff(vec1, vec2)));
962 }
std::vector< int > vec_iff(const std::vector< int > &vec1, const std::vector< int > &vec2)
Definition: ezsat.cc:736
int NOT(_V a)
Definition: ezsat.h:197
int vec_reduce_and(const std::vector< int > &vec1)
Definition: ezsat.cc:1139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_neg ( const std::vector< int > &  vec)
inherited

Definition at line 867 of file ezsat.cc.

868 {
869  std::vector<int> zero(vec.size(), CONST_FALSE);
870  return vec_sub(zero, vec);
871 }
std::vector< int > vec_sub(const std::vector< int > &vec1, const std::vector< int > &vec2)
Definition: ezsat.cc:843
static const int CONST_FALSE
Definition: ezsat.h:49
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_not ( const std::vector< int > &  vec1)
inherited

Definition at line 701 of file ezsat.cc.

702 {
703  std::vector<int> vec;
704  for (auto bit : vec1)
705  vec.push_back(NOT(bit));
706  return vec;
707 }
int NOT(_V a)
Definition: ezsat.h:197
struct ezSATbit bit(_V a)
Definition: ezsat.cc:1178
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_or ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 718 of file ezsat.cc.

719 {
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]);
724  return vec;
725 }
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_reduce_and ( const std::vector< int > &  vec1)
inherited

Definition at line 1139 of file ezsat.cc.

1140 {
1141  return expression(OpAnd, vec1);
1142 }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::vec_reduce_or ( const std::vector< int > &  vec1)
inherited

Definition at line 1144 of file ezsat.cc.

1145 {
1146  return expression(OpOr, vec1);
1147 }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::vec_set ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 1149 of file ezsat.cc.

1150 {
1151  assert(vec1.size() == vec2.size());
1152  for (int i = 0; i < int(vec1.size()); i++)
1153  SET(vec1[i], vec2[i]);
1154 }
void SET(_V a, _V b)
Definition: ezsat.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ezSAT::vec_set_signed ( const std::vector< int > &  vec1,
int64_t  value 
)
inherited

Definition at line 1156 of file ezsat.cc.

1157 {
1158  assert(int(vec1.size()) <= 64);
1159  for (int i = 0; i < int(vec1.size()); i++) {
1160  if (((value >> i) & 1) != 0)
1161  assume(vec1[i]);
1162  else
1163  assume(NOT(vec1[i]));
1164  }
1165 }
int NOT(_V a)
Definition: ezsat.h:197
int value(bool val)
Definition: ezsat.cc:68
void assume(int id)
Definition: ezsat.cc:388

+ Here is the call graph for this function:

void ezSAT::vec_set_unsigned ( const std::vector< int > &  vec1,
uint64_t  value 
)
inherited

Definition at line 1167 of file ezsat.cc.

1168 {
1169  assert(int(vec1.size()) <= 64);
1170  for (int i = 0; i < int(vec1.size()); i++) {
1171  if (((value >> i) & 1) != 0)
1172  assume(vec1[i]);
1173  else
1174  assume(NOT(vec1[i]));
1175  }
1176 }
int NOT(_V a)
Definition: ezsat.h:197
int value(bool val)
Definition: ezsat.cc:68
void assume(int id)
Definition: ezsat.cc:388

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_shift ( const std::vector< int > &  vec1,
int  shift,
int  extend_left,
int  extend_right 
)
inherited

Definition at line 993 of file ezsat.cc.

994 {
995  std::vector<int> vec;
996  for (int i = 0; i < int(vec1.size()); i++) {
997  int j = i+shift;
998  if (j < 0)
999  vec.push_back(extend_right);
1000  else if (j >= int(vec1.size()))
1001  vec.push_back(extend_left);
1002  else
1003  vec.push_back(vec1[j]);
1004  }
1005  return vec;
1006 }
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)
inherited

Definition at line 1059 of file ezsat.cc.

1060 {
1061  // vec2_signed is not implemented in vec_shift_left() yet
1062  assert(vec2_signed == false);
1063 
1064  int vec2_bits = std::min(my_clog2(vec1.size()), int(vec2.size()));
1065 
1066  std::vector<int> overflow_bits(vec2.begin() + vec2_bits, vec2.end());
1067  int overflow = vec_reduce_or(overflow_bits);
1068 
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);
1072 
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);
1077  }
1078 
1079  buffer.resize(vec1.size());
1080  return buffer;
1081 }
std::vector< int > vec_shift(const std::vector< int > &vec1, int shift, int extend_left, int extend_right)
Definition: ezsat.cc:993
static int my_clog2(int x)
Definition: ezsat.cc:1008
int vec_reduce_or(const std::vector< int > &vec1)
Definition: ezsat.cc:1144
std::vector< int > vec_ite(const std::vector< int > &vec1, const std::vector< int > &vec2, const std::vector< int > &vec3)
Definition: ezsat.cc:745

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)
inherited

Definition at line 1016 of file ezsat.cc.

1017 {
1018  int vec2_bits = std::min(my_clog2(vec1.size()) + (vec2_signed ? 1 : 0), int(vec2.size()));
1019 
1020  std::vector<int> overflow_bits(vec2.begin() + vec2_bits, vec2.end());
1021  int overflow_left = CONST_FALSE, overflow_right = CONST_FALSE;
1022 
1023  if (vec2_signed) {
1024  int overflow = CONST_FALSE;
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());
1029  } else
1030  overflow_left = vec_reduce_or(overflow_bits);
1031 
1032  std::vector<int> buffer = vec1;
1033 
1034  if (vec2_signed)
1035  while (buffer.size() < vec1.size() + (1 << vec2_bits))
1036  buffer.push_back(extend_left);
1037 
1038  std::vector<int> overflow_pattern_left(buffer.size(), extend_left);
1039  std::vector<int> overflow_pattern_right(buffer.size(), extend_right);
1040 
1041  buffer = vec_ite(overflow_left, overflow_pattern_left, buffer);
1042 
1043  if (vec2_signed)
1044  buffer = vec_ite(overflow_right, overflow_pattern_left, buffer);
1045 
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);
1050  else
1051  shifted_buffer = vec_shift(buffer, 1 << i, extend_left, extend_right);
1052  buffer = vec_ite(vec2[i], shifted_buffer, buffer);
1053  }
1054 
1055  buffer.resize(vec1.size());
1056  return buffer;
1057 }
static const int CONST_FALSE
Definition: ezsat.h:49
int NOT(_V a)
Definition: ezsat.h:197
std::vector< int > vec_shift(const std::vector< int > &vec1, int shift, int extend_left, int extend_right)
Definition: ezsat.cc:993
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:201
static int my_clog2(int x)
Definition: ezsat.cc:1008
int vec_reduce_or(const std::vector< int > &vec1)
Definition: ezsat.cc:1144
std::vector< int > vec_ite(const std::vector< int > &vec1, const std::vector< int > &vec2, const std::vector< int > &vec3)
Definition: ezsat.cc:745
int XOR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:209
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:205
struct ezSATbit bit(_V a)
Definition: ezsat.cc:1178

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_shl ( const std::vector< int > &  vec1,
int  shift,
bool  signExtend = false 
)
inherited

Definition at line 964 of file ezsat.cc.

965 {
966  std::vector<int> vec;
967  for (int i = 0; i < int(vec1.size()); i++) {
968  int j = i-shift;
969  if (int(vec1.size()) <= j)
970  vec.push_back(signExtend ? vec1.back() : CONST_FALSE);
971  else if (0 <= j)
972  vec.push_back(vec1[j]);
973  else
974  vec.push_back(CONST_FALSE);
975  }
976  return vec;
977 }
static const int CONST_FALSE
Definition: ezsat.h:49
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<int> ezSAT::vec_shr ( const std::vector< int > &  vec1,
int  shift,
bool  signExtend = false 
)
inlineinherited

Definition at line 266 of file ezsat.h.

266 { return vec_shl(vec1, -shift, signExtend); }
std::vector< int > vec_shl(const std::vector< int > &vec1, int shift, bool signExtend=false)
Definition: ezsat.cc:964

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_srl ( const std::vector< int > &  vec1,
int  shift 
)
inherited

Definition at line 979 of file ezsat.cc.

980 {
981  std::vector<int> vec;
982  for (int i = 0; i < int(vec1.size()); i++) {
983  int j = i-shift;
984  while (j < 0)
985  j += vec1.size();
986  while (j >= int(vec1.size()))
987  j -= vec1.size();
988  vec.push_back(vec1[j]);
989  }
990  return vec;
991 }
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<int> ezSAT::vec_srr ( const std::vector< int > &  vec1,
int  shift 
)
inlineinherited

Definition at line 267 of file ezsat.h.

267 { return vec_srl(vec1, -shift); }
std::vector< int > vec_srl(const std::vector< int > &vec1, int shift)
Definition: ezsat.cc:979

+ Here is the call graph for this function:

std::vector< int > ezSAT::vec_sub ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 843 of file ezsat.cc.

844 {
845  assert(vec1.size() == vec2.size());
846  std::vector<int> vec(vec1.size());
847  int carry = CONST_TRUE;
848  for (int i = 0; i < int(vec1.size()); i++)
849  fulladder(this, vec1[i], NOT(vec2[i]), carry, carry, vec[i]);
850 
851 #if 0
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 ? ", " : "");
855  printf("], vec2=[");
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 ? ", " : "");
861  printf("]\n");
862 #endif
863 
864  return vec;
865 }
int NOT(_V a)
Definition: ezsat.h:197
std::string to_string(int id) const
Definition: ezsat.cc:237
static const int CONST_TRUE
Definition: ezsat.h:48
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183
static void fulladder(ezSAT *that, int a, int b, int c, int &y, int &x)
Definition: ezsat.cc:765

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_var ( int  numBits)
inherited

Definition at line 673 of file ezsat.cc.

674 {
675  std::vector<int> vec;
676  for (int i = 0; i < numBits; i++)
677  vec.push_back(literal());
678  return vec;
679 }
int literal()
Definition: ezsat.cc:73
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< int > ezSAT::vec_var ( std::string  name,
int  numBits 
)
inherited

Definition at line 681 of file ezsat.cc.

682 {
683  std::vector<int> vec;
684  for (int i = 0; i < numBits; i++) {
685  vec.push_back(VAR(name + my_int_to_string(i)));
686  }
687  return vec;
688 }
static std::string my_int_to_string(int i)
Definition: ezsat.cc:32
int VAR(_V a)
Definition: ezsat.h:193
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

std::vector< int > ezSAT::vec_xor ( const std::vector< int > &  vec1,
const std::vector< int > &  vec2 
)
inherited

Definition at line 727 of file ezsat.cc.

728 {
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]);
733  return vec;
734 }
int XOR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
Definition: ezsat.h:209
struct ezSATvec vec(const std::vector< int > &vec)
Definition: ezsat.cc:1183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ezSAT::XOR ( _V  a = 0,
_V  b = 0,
_V  c = 0,
_V  d = 0,
_V  e = 0,
_V  f = 0 
)
inlineinherited

Definition at line 209 of file ezsat.h.

209  {
210  return expression(OpXor, a.get(this), b.get(this), c.get(this), d.get(this), e.get(this), f.get(this));
211  }
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
Definition: ezsat.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ezMiniSAT * ezMiniSAT::alarmHandlerThis = NULL
staticprivate

Definition at line 55 of file ezminisat.h.

clock_t ezMiniSAT::alarmHandlerTimeout = 0
staticprivate

Definition at line 56 of file ezminisat.h.

std::set<int> ezMiniSAT::cnfFrozenVars
private

Definition at line 51 of file ezminisat.h.

const int ezSAT::CONST_FALSE = 2
staticinherited

Definition at line 49 of file ezsat.h.

const int ezSAT::CONST_TRUE = 1
staticinherited

Definition at line 48 of file ezsat.h.

bool ezMiniSAT::foundContradiction
private

Definition at line 48 of file ezminisat.h.

Solver* ezMiniSAT::minisatSolver
private

Definition at line 46 of file ezminisat.h.

std::vector<int> ezMiniSAT::minisatVars
private

Definition at line 47 of file ezminisat.h.

int ezSAT::solverTimeout
inherited

Definition at line 80 of file ezsat.h.

bool ezSAT::solverTimoutStatus
inherited

Definition at line 81 of file ezsat.h.


The documentation for this class was generated from the following files: