13 /** This function creates a set containing the elements passed in the array. */
14 Set *createSet(VarType type, uint64_t *elements, uint num);
16 /** This function creates a set from lowrange to highrange (inclusive). */
18 Set *createRangeSet(VarType type, uint64_t lowrange, uint64_t highrange);
20 /** This function creates a mutable set. */
22 MutableSet *createMutableSet(VarType type);
24 /** This function adds a new item to a set. */
26 void addItem(MutableSet *set, uint64_t element);
28 /** This function adds a new unique item to the set and returns it.
29 This function cannot be used in conjunction with manually adding
32 uint64_t createUniqueItem(MutableSet *set);
34 /** This function creates an element variable over a set. */
36 Element *getElementVar(Set *set);
38 /** This function creates an element constrant. */
39 Element *getElementConst(VarType type, uint64_t value);
41 /** This function creates a boolean variable. */
43 Boolean *getBooleanVar(VarType type);
45 /** This function creates a function operator. */
47 Function *createFunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range,
48 OverFlowBehavior overflowbehavior);
50 /** This function creates a predicate operator. */
52 Predicate *createPredicateOperator(CompOp op, Set **domain, uint numDomain);
54 Predicate *createPredicateTable(Table *table, UndefinedBehavior behavior);
56 /** This function creates an empty instance table.*/
58 Table *createTable(Set **domains, uint numDomain, Set *range);
60 Table *createTableForPredicate(Set **domains, uint numDomain);
61 /** This function adds an input output relation to a table. */
63 void addTableEntry(Table *table, uint64_t *inputs, uint inputSize, uint64_t result);
65 /** This function converts a completed table into a function. */
67 Function *completeTable(Table *, UndefinedBehavior behavior);
69 /** This function applies a function to the Elements in its input. */
71 Element *applyFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
73 /** This function applies a predicate to the Elements in its input. */
75 Boolean *applyPredicateTable(Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus);
77 Boolean *applyPredicate(Predicate *predicate, Element **inputs, uint numInputs);
79 /** This function applies a logical operation to the Booleans in its input. */
81 Boolean *applyLogicalOperation(LogicOp op, Boolean **array, uint asize);
83 /** This function adds a boolean constraint to the set of constraints
86 void addConstraint(Boolean *constraint);
88 /** This function instantiates an order of type type over the set set. */
89 Order *createOrder(OrderType type, Set *set);
91 /** This function instantiates a boolean on two items in an order. */
92 Boolean *orderConstraint(Order *order, uint64_t first, uint64_t second);
94 /** When everything is done, the client calls this function and then csolver starts to encode*/
97 /** After getting the solution from the SAT solver, client can get the value of an element via this function*/
98 uint64_t getElementValue(Element *element);
100 /** After getting the solution from the SAT solver, client can get the value of a boolean via this function*/
101 bool getBooleanValue(Boolean *boolean);
103 HappenedBefore getOrderConstraintValue(Order *order, uint64_t first, uint64_t second);
105 void setUnSAT() { unsat = true; }
107 bool isUnSAT() { return unsat; }
109 Vector<Order *> *getOrders() { return &allOrders;}
111 Tuner *getTuner() { return tuner; }
113 HSIteratorBoolean *getConstraints() { return constraints.iterator(); }
115 SATEncoder *getSATEncoder() {return satEncoder;}
117 void replaceBooleanWithTrue(Boolean *bexpr);
118 void replaceBooleanWithFalse(Boolean *bexpr);
119 void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb);
121 void autoTune(uint budget);
123 void setTuner(Tuner * _tuner) { tuner = _tuner; }
124 long long getElapsedTime() { return elapsedTime; }
125 long long getEncodeTime();
126 long long getSolveTime();
131 void handleXORFalse(BooleanLogic *bexpr, Boolean *child);
132 void handleIMPLIESTrue(BooleanLogic *bexpr, Boolean *child);
133 void handleIMPLIESFalse(BooleanLogic *bexpr, Boolean *child);
134 void handleANDTrue(BooleanLogic *bexpr, Boolean *child);
135 void handleORFalse(BooleanLogic *bexpr, Boolean *child);
137 /** This is a vector of constraints that must be satisfied. */
138 HashSetBoolean constraints;
140 /** This is a vector of all boolean structs that we have allocated. */
141 Vector<Boolean *> allBooleans;
143 /** This is a vector of all set structs that we have allocated. */
144 Vector<Set *> allSets;
146 /** This is a vector of all element structs that we have allocated. */
147 Vector<Element *> allElements;
149 /** This is a vector of all predicate structs that we have allocated. */
150 Vector<Predicate *> allPredicates;
152 /** This is a vector of all table structs that we have allocated. */
153 Vector<Table *> allTables;
155 /** This is a vector of all order structs that we have allocated. */
156 Vector<Order *> allOrders;
158 /** This is a vector of all function structs that we have allocated. */
159 Vector<Function *> allFunctions;
161 /** These two tables are used for deduplicating entries. */
162 BooleanMatchMap boolMap;
163 ElementMatchMap elemMap;
165 SATEncoder *satEncoder;
169 long long elapsedTime;