1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mudathir Mohamed, Andrew Reynolds, Gereon Kremer |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Inference generator utility. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BAGS__INFERENCE_GENERATOR_H |
19 |
|
#define CVC5__THEORY__BAGS__INFERENCE_GENERATOR_H |
20 |
|
|
21 |
|
#include "expr/node.h" |
22 |
|
#include "infer_info.h" |
23 |
|
|
24 |
|
namespace cvc5 { |
25 |
|
namespace theory { |
26 |
|
namespace bags { |
27 |
|
|
28 |
|
class InferenceManager; |
29 |
|
class SolverState; |
30 |
|
|
31 |
|
/** |
32 |
|
* An inference generator class. This class is used by the core solver to |
33 |
|
* generate lemmas |
34 |
|
*/ |
35 |
19706 |
class InferenceGenerator |
36 |
|
{ |
37 |
|
public: |
38 |
|
InferenceGenerator(SolverState* state, InferenceManager* im); |
39 |
|
|
40 |
|
/** |
41 |
|
* @param A is a bag of type (Bag E) |
42 |
|
* @param e is a node of type E |
43 |
|
* @return an inference that represents the following implication |
44 |
|
* (=> |
45 |
|
* true |
46 |
|
* (>= (bag.count e A) 0) |
47 |
|
*/ |
48 |
|
InferInfo nonNegativeCount(Node n, Node e); |
49 |
|
|
50 |
|
/** |
51 |
|
* @param n is (bag x c) of type (Bag E) |
52 |
|
* @param e is a node of type E |
53 |
|
* @return an inference that represents the following implication |
54 |
|
* (=> |
55 |
|
* true |
56 |
|
* (= (bag.count e skolem) c)) |
57 |
|
* if e is exactly node x. Node skolem is a fresh variable equals (bag x c). |
58 |
|
* Otherwise the following inference is returned |
59 |
|
* (=> |
60 |
|
* true |
61 |
|
* (= (bag.count e skolem) (ite (= e x) c 0))) |
62 |
|
*/ |
63 |
|
InferInfo mkBag(Node n, Node e); |
64 |
|
/** |
65 |
|
* @param n is (= A B) where A, B are bags of type (Bag E), and |
66 |
|
* (not (= A B)) is an assertion in the equality engine |
67 |
|
* @return an inference that represents the following implication |
68 |
|
* (=> |
69 |
|
* (not (= A B)) |
70 |
|
* (not (= (count e A) (count e B)))) |
71 |
|
* where e is a fresh skolem of type E. |
72 |
|
*/ |
73 |
|
InferInfo bagDisequality(Node n); |
74 |
|
/** |
75 |
|
* @param n is (as emptybag (Bag E)) |
76 |
|
* @param e is a node of Type E |
77 |
|
* @return an inference that represents the following implication |
78 |
|
* (=> |
79 |
|
* true |
80 |
|
* (= 0 (count e skolem))) |
81 |
|
* where skolem = (as emptybag (Bag String)) |
82 |
|
*/ |
83 |
|
InferInfo empty(Node n, Node e); |
84 |
|
/** |
85 |
|
* @param n is (union_disjoint A B) where A, B are bags of type (Bag E) |
86 |
|
* @param e is a node of Type E |
87 |
|
* @return an inference that represents the following implication |
88 |
|
* (=> |
89 |
|
* true |
90 |
|
* (= (count e skolem) |
91 |
|
* (+ (count e A) (count e B)))) |
92 |
|
* where skolem is a fresh variable equals (union_disjoint A B) |
93 |
|
*/ |
94 |
|
InferInfo unionDisjoint(Node n, Node e); |
95 |
|
/** |
96 |
|
* @param n is (union_disjoint A B) where A, B are bags of type (Bag E) |
97 |
|
* @param e is a node of Type E |
98 |
|
* @return an inference that represents the following implication |
99 |
|
* (=> |
100 |
|
* true |
101 |
|
* (= |
102 |
|
* (count e skolem) |
103 |
|
* (ite |
104 |
|
* (> (count e A) (count e B)) |
105 |
|
* (count e A) |
106 |
|
* (count e B))))) |
107 |
|
* where skolem is a fresh variable equals (union_max A B) |
108 |
|
*/ |
109 |
|
InferInfo unionMax(Node n, Node e); |
110 |
|
/** |
111 |
|
* @param n is (intersection_min A B) where A, B are bags of type (Bag E) |
112 |
|
* @param e is a node of Type E |
113 |
|
* @return an inference that represents the following implication |
114 |
|
* (=> |
115 |
|
* true |
116 |
|
* (= |
117 |
|
* (count e skolem) |
118 |
|
* (ite( |
119 |
|
* (< (count e A) (count e B)) |
120 |
|
* (count e A) |
121 |
|
* (count e B))))) |
122 |
|
* where skolem is a fresh variable equals (intersection_min A B) |
123 |
|
*/ |
124 |
|
InferInfo intersection(Node n, Node e); |
125 |
|
/** |
126 |
|
* @param n is (difference_subtract A B) where A, B are bags of type (Bag E) |
127 |
|
* @param e is a node of Type E |
128 |
|
* @return an inference that represents the following implication |
129 |
|
* (=> |
130 |
|
* true |
131 |
|
* (= |
132 |
|
* (count e skolem) |
133 |
|
* (ite |
134 |
|
* (>= (count e A) (count e B)) |
135 |
|
* (- (count e A) (count e B)) |
136 |
|
* 0)))) |
137 |
|
* where skolem is a fresh variable equals (difference_subtract A B) |
138 |
|
*/ |
139 |
|
InferInfo differenceSubtract(Node n, Node e); |
140 |
|
/** |
141 |
|
* @param n is (difference_remove A B) where A, B are bags of type (Bag E) |
142 |
|
* @param e is a node of Type E |
143 |
|
* @return an inference that represents the following implication |
144 |
|
* (=> |
145 |
|
* true |
146 |
|
* (= |
147 |
|
* (count e skolem) |
148 |
|
* (ite |
149 |
|
* (= (count e B) 0) |
150 |
|
* (count e A) |
151 |
|
* 0)))) |
152 |
|
* where skolem is a fresh variable equals (difference_remove A B) |
153 |
|
*/ |
154 |
|
InferInfo differenceRemove(Node n, Node e); |
155 |
|
/** |
156 |
|
* @param n is (duplicate_removal A) where A is a bag of type (Bag E) |
157 |
|
* @param e is a node of Type E |
158 |
|
* @return an inference that represents the following implication |
159 |
|
* (=> |
160 |
|
* true |
161 |
|
* (= |
162 |
|
* (count e skolem) |
163 |
|
* (ite (>= (count e A) 1) 1 0)))) |
164 |
|
* where skolem is a fresh variable equals (duplicate_removal A) |
165 |
|
*/ |
166 |
|
InferInfo duplicateRemoval(Node n, Node e); |
167 |
|
|
168 |
|
/** |
169 |
|
* @param element of type T |
170 |
|
* @param bag of type (bag T) |
171 |
|
* @return a count term (bag.count element bag) |
172 |
|
*/ |
173 |
|
Node getMultiplicityTerm(Node element, Node bag); |
174 |
|
|
175 |
|
private: |
176 |
|
/** generate skolem variable for node n and add it to inferInfo */ |
177 |
|
Node getSkolem(Node& n, InferInfo& inferInfo); |
178 |
|
|
179 |
|
NodeManager* d_nm; |
180 |
|
SkolemManager* d_sm; |
181 |
|
SolverState* d_state; |
182 |
|
/** Pointer to the inference manager */ |
183 |
|
InferenceManager* d_im; |
184 |
|
/** Commonly used constants */ |
185 |
|
Node d_true; |
186 |
|
Node d_zero; |
187 |
|
Node d_one; |
188 |
|
}; |
189 |
|
|
190 |
|
} // namespace bags |
191 |
|
} // namespace theory |
192 |
|
} // namespace cvc5 |
193 |
|
|
194 |
|
#endif /* CVC5__THEORY__BAGS__INFERENCE_GENERATOR_H */ |