-
Notifications
You must be signed in to change notification settings - Fork 1
/
statesetcompositions.cc
118 lines (92 loc) · 3.97 KB
/
statesetcompositions.cc
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "statesetcompositions.h"
#include "global_funcs.h"
#include "proofchecker.h"
StateSetUnion::StateSetUnion(std::stringstream &input, Task &)
: id_left(read_uint(input)), id_right(read_uint(input)) {
}
SetID StateSetUnion::get_left_id() const {
return id_left;
}
SetID StateSetUnion::get_right_id() const {
return id_right;
}
bool StateSetUnion::gather_union_variables(
const ProofChecker &proof_checker,
std::vector<const StateSetVariable *> &positive,
std::vector<const StateSetVariable *> &negative) const {
const StateSet *left = proof_checker.get_set<StateSet>(id_left);
const StateSet *right = proof_checker.get_set<StateSet>(id_right);
return left->gather_union_variables(proof_checker, positive, negative)
&& right->gather_union_variables(proof_checker, positive, negative);
}
StateSetBuilder<StateSetUnion> union_builder("u");
StateSetIntersection::StateSetIntersection(std::stringstream &input, Task &)
: id_left(read_uint(input)), id_right(read_uint(input)) {
}
SetID StateSetIntersection::get_left_id() const {
return id_left;
}
SetID StateSetIntersection::get_right_id() const {
return id_right;
}
bool StateSetIntersection::gather_intersection_variables(
const ProofChecker &proof_checker,
std::vector<const StateSetVariable *> &positive,
std::vector<const StateSetVariable *> &negative) const {
const StateSet *left = proof_checker.get_set<StateSet>(id_left);
const StateSet *right = proof_checker.get_set<StateSet>(id_right);
return left->gather_intersection_variables(proof_checker, positive, negative)
&& right->gather_intersection_variables(proof_checker, positive, negative);
}
StateSetBuilder<StateSetIntersection> intersection_builder("i");
StateSetNegation::StateSetNegation(std::stringstream &input, Task &)
: id_child(read_uint(input)) {
}
SetID StateSetNegation::get_child_id() const {
return id_child;
}
bool StateSetNegation::gather_union_variables(
const ProofChecker &proof_checker,
std::vector<const StateSetVariable *> &positive,
std::vector<const StateSetVariable *> &negative) const {
const StateSet *child = proof_checker.get_set<StateSet>(id_child);
//Negation is only allowed to occur directly before a StateSetVariable
const StateSetVariable *child_var = dynamic_cast<const StateSetVariable *>(child);
if (!child_var) {
throw std::runtime_error("Encountered negation of a composed state set.");
}
return child->gather_union_variables(proof_checker, negative, positive);
}
bool StateSetNegation::gather_intersection_variables(
const ProofChecker &proof_checker,
std::vector<const StateSetVariable *> &positive,
std::vector<const StateSetVariable *> &negative) const {
const StateSet *child = proof_checker.get_set<StateSet>(id_child);
//Negation is only allowed to occur directly before a StateSetVariable
const StateSetVariable *child_var = dynamic_cast<const StateSetVariable *>(child);
if (!child_var) {
throw std::runtime_error("Encountered negation of a composed state set.");
}
return child->gather_intersection_variables(proof_checker, negative, positive);
}
StateSetBuilder<StateSetNegation> negation_builder("n");
StateSetProgression::StateSetProgression(std::stringstream &input, Task &)
: id_stateset(read_uint(input)), id_actionset(read_uint(input)) {
}
SetID StateSetProgression::get_actionset_id() const {
return id_actionset;
}
SetID StateSetProgression::get_stateset_id() const {
return id_stateset;
}
StateSetBuilder<StateSetProgression> progression_builder("p");
StateSetRegression::StateSetRegression(std::stringstream &input, Task &)
: id_stateset(read_uint(input)), id_actionset(read_uint(input)) {
}
SetID StateSetRegression::get_actionset_id() const {
return id_actionset;
}
SetID StateSetRegression::get_stateset_id() const {
return id_stateset;
}
StateSetBuilder<StateSetRegression> regression_builder("r");