8 SATEncoder *satEncoder;
11 /** This is a vector of constraints that must be satisfied. */
12 HashSetBoolean *constraints;
14 /** This is a vector of all boolean structs that we have allocated. */
15 VectorBoolean *allBooleans;
17 /** This is a vector of all set structs that we have allocated. */
20 /** This is a vector of all element structs that we have allocated. */
21 VectorElement *allElements;
23 /** This is a vector of all predicate structs that we have allocated. */
24 VectorPredicate *allPredicates;
26 /** This is a vector of all table structs that we have allocated. */
27 VectorTable *allTables;
29 /** This is a vector of all order structs that we have allocated. */
30 VectorOrder *allOrders;
32 /** This is a vector of all function structs that we have allocated. */
33 VectorFunction *allFunctions;
36 /** Create a new solver instance. */
38 CSolver *allocCSolver();
40 /** Delete solver instance. */
42 void deleteSolver(CSolver *This);
44 /** This function creates a set containing the elements passed in the array. */
46 Set *createSet(CSolver *, VarType type, uint64_t *elements, uint num);
48 /** This function creates a set from lowrange to highrange (inclusive). */
50 Set *createRangeSet(CSolver *, VarType type, uint64_t lowrange, uint64_t highrange);
52 /** This function creates a mutable set. */
54 MutableSet *createMutableSet(CSolver *, VarType type);
56 /** This function adds a new item to a set. */
58 void addItem(CSolver *, MutableSet *set, uint64_t element);
60 /** This function adds a new unique item to the set and returns it.
61 This function cannot be used in conjunction with manually adding
64 uint64_t createUniqueItem(CSolver *, MutableSet *set);
66 /** This function creates an element variable over a set. */
68 Element *getElementVar(CSolver *, Set *set);
70 /** This function creates an element constrant. */
71 Element *getElementConst(CSolver *, VarType type, uint64_t value);
73 /** This function creates a boolean variable. */
75 Boolean *getBooleanVar(CSolver *, VarType type);
77 /** This function creates a function operator. */
79 Function *createFunctionOperator(CSolver *solver, ArithOp op, Set **domain, uint numDomain, Set *range,
80 OverFlowBehavior overflowbehavior);
82 /** This function creates a predicate operator. */
84 Predicate *createPredicateOperator(CSolver *solver, CompOp op, Set **domain, uint numDomain);
86 Predicate *createPredicateTable(CSolver *solver, Table *table, UndefinedBehavior behavior);
88 /** This function creates an empty instance table.*/
90 Table *createTable(CSolver *solver, Set **domains, uint numDomain, Set *range);
92 Table *createTableForPredicate(CSolver *solver, Set **domains, uint numDomain);
93 /** This function adds an input output relation to a table. */
95 void addTableEntry(CSolver *solver, Table *table, uint64_t *inputs, uint inputSize, uint64_t result);
97 /** This function converts a completed table into a function. */
99 Function *completeTable(CSolver *, Table *, UndefinedBehavior behavior);
101 /** This function applies a function to the Elements in its input. */
103 Element *applyFunction(CSolver *, Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
105 /** This function applies a predicate to the Elements in its input. */
107 Boolean *applyPredicateTable(CSolver *, Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus);
109 Boolean *applyPredicate(CSolver *, Predicate *predicate, Element **inputs, uint numInputs);
111 /** This function applies a logical operation to the Booleans in its input. */
113 Boolean *applyLogicalOperation(CSolver *, LogicOp op, Boolean **array, uint asize);
115 /** This function adds a boolean constraint to the set of constraints
118 void addConstraint(CSolver *, Boolean *constraint);
120 /** This function instantiates an order of type type over the set set. */
121 Order *createOrder(CSolver *, OrderType type, Set *set);
123 /** This function instantiates a boolean on two items in an order. */
124 Boolean *orderConstraint(CSolver *, Order *order, uint64_t first, uint64_t second);
126 /** When everything is done, the client calls this function and then csolver starts to encode*/
127 int startEncoding(CSolver *);
129 /** After getting the solution from the SAT solver, client can get the value of an element via this function*/
130 uint64_t getElementValue(CSolver *, Element *element);
132 /** After getting the solution from the SAT solver, client can get the value of a boolean via this function*/
133 bool getBooleanValue( CSolver *, Boolean *boolean);
135 HappenedBefore getOrderConstraintValue(CSolver *, Order *order, uint64_t first, uint64_t second);