blob: a1840a35a0ccfd4fa6ee8010f07d4656e18697d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include "expr/node.h"
#include "context/cdhashmap.h"
namespace CVC4 {
namespace theory {
namespace idl {
/**
* A reason for a value of a variable in the model is a constraint that implies
* this value by means of the value of another variable. For example, if the
* value of x is 0, then the variable x and the constraint (y > 0) are a reason
* for the y taking the value 1.
*/
struct IDLReason {
/** The variable of the reason */
TNode x;
/** The constraint of the reaason */
TNode constraint;
IDLReason(TNode x, TNode constraint)
: x(x), constraint(constraint) {}
IDLReason() {}
};
/**
* A model maps variables to integer values and backs them up with reasons.
* Default values (if not set with setValue) for all variables are 0.
*/
class IDLModel {
typedef context::CDHashMap<TNode, Integer, TNodeHashFunction> model_value_map;
typedef context::CDHashMap<TNode, IDLReason, TNodeHashFunction> model_reason_map;
/** Values assigned to individual variables */
model_value_map d_model;
/** Reasons constraining the individual variables */
model_reason_map d_reason;
public:
IDLModel(context::Context* context);
/** Get the model value of the variable */
Integer getValue(TNode var) const;
/** Set the value of the variable */
void setValue(TNode var, Integer value, IDLReason reason);
/** Get the cycle of reasons behind the variable var */
void getReasonCycle(TNode var, std::vector<TNode>& reasons);
/** Output to the given stream */
void toStream(std::ostream& out) const;
};
inline std::ostream& operator << (std::ostream& out, const IDLModel& model) {
model.toStream(out);
return out;
}
}
}
}
|