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