d11523b2c2ed031252c724dd4d28f6e9b9c84c77
[satune.git] / src / csolver.h
1 #ifndef CSOLVER_H
2 #define CSOLVER_H
3 #include "classlist.h"
4 #include "ops.h"
5 #include "structs.h"
6
7 struct CSolver {
8         /** This is a vector of constraints that must be satisfied. */
9         VectorBoolean * constraints;
10
11         /** This is a vector of all boolean structs that we have allocated. */
12         VectorBoolean * allBooleans;
13
14         /** This is a vector of all set structs that we have allocated. */
15         VectorSet * allSets;
16
17         /** This is a vector of all element structs that we have allocated. */
18         VectorElement * allElements;
19 };
20
21 /** Create a new solver instance. */
22
23 CSolver * allocCSolver();
24
25 /** This function creates a set containing the elements passed in the array. */
26
27 Set * createSet(CSolver *, VarType type, uint64_t * elements, uint num);
28
29 /** This function creates a set from lowrange to highrange (inclusive). */
30
31 Set * createRangeSet(CSolver *, VarType type, uint64_t lowrange, uint64_t highrange);
32
33 /** This function creates a mutable set. */
34
35 MutableSet * createMutableSet(CSolver *, VarType type);
36
37 /** This function adds a new item to a set. */
38
39 void addItem(CSolver *, MutableSet * set, uint64_t element);
40
41 /** This function adds a new unique item to the set and returns it.
42     This function cannot be used in conjunction with manually adding
43     items to the set. */
44
45 uint64_t createUniqueItem(CSolver *, MutableSet * set);
46
47 /** This function creates an element variable over a set. */
48
49 Element * getElementVar(CSolver *, Set * set);
50
51 /** This function creates a boolean variable. */
52
53 Boolean * getBooleanVar(CSolver *, VarType type);
54
55 /** This function creates a function operator. */
56
57 Function * createFunctionOperator(CSolver *solver, enum ArithOp op, Set ** domain, uint numDomain, Set * range,
58                                                                                                                                         enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus);
59
60 /** This function creates a predicate operator. */
61
62 Predicate * createPredicateOperator(CSolver *solver, enum CompOp op, Set ** domain, uint numDomain);
63
64 /** This function creates an empty instance table.*/
65
66 Table * createTable(CSolver *solver, Set **domains, uint numDomain, Set * range);
67
68 /** This function adds an input output relation to a table. */
69
70 void addTableEntry(CSolver *solver, uint64_t* inputs, uint inputSize, uint64_t result);
71
72 /** This function converts a completed table into a function. */
73
74 Function * completeTable(CSolver *, Table *);
75
76 /** This function applies a function to the Elements in its input. */
77
78 Element * applyFunction(CSolver *, Function * function, Element ** array);
79
80 /** This function applies a predicate to the Elements in its input. */
81
82 Boolean * applyPredicate(CSolver *, Predicate * predicate, Element ** inputs);
83
84 /** This function applies a logical operation to the Booleans in its input. */
85
86 Boolean * applyLogicalOperation(CSolver *, enum LogicOp op, Boolean ** array);
87
88 /** This function adds a boolean constraint to the set of constraints
89     to be satisfied */
90
91 void addBoolean(CSolver *, Boolean * constraint);
92
93 /** This function instantiates an order of type type over the set set. */
94 Order * createOrder(CSolver *, enum OrderType type, Set * set);
95
96 /** This function instantiates a predicate on two items in an order. */
97 Boolean * orderConstraint(CSolver *, Order * order, uint64_t first, uint64_t second);
98 #endif