25
25
class smt2_solvert :public smt2_parsert
26
26
{
27
27
public:
28
- smt2_solvert (std::istream &_in, decision_proceduret &_solver)
28
+ smt2_solvert (std::istream &_in, stack_decision_proceduret &_solver)
29
29
: smt2_parsert(_in), solver(_solver), status(NOT_SOLVED)
30
30
{
31
31
setup_commands ();
32
32
}
33
33
34
34
protected:
35
- decision_proceduret &solver;
35
+ stack_decision_proceduret &solver;
36
36
37
37
void setup_commands ();
38
38
void define_constants ();
@@ -158,7 +158,47 @@ void smt2_solvert::setup_commands()
158
158
};
159
159
160
160
commands[" check-sat-assuming" ] = [this ]() {
161
- throw error (" not yet implemented" );
161
+ std::vector<exprt> assumptions;
162
+
163
+ if (next_token () != smt2_tokenizert::OPEN)
164
+ throw error (" check-sat-assuming expects list as argument" );
165
+
166
+ while (smt2_tokenizer.peek () != smt2_tokenizert::CLOSE &&
167
+ smt2_tokenizer.peek () != smt2_tokenizert::END_OF_FILE)
168
+ {
169
+ auto e = expression (); // any term
170
+ expand_function_applications (e);
171
+ assumptions.push_back (solver.handle (e));
172
+ }
173
+
174
+ if (next_token () != smt2_tokenizert::CLOSE)
175
+ throw error (" check-sat-assuming expects ')' at end of list" );
176
+
177
+ // add constant definitions as constraints
178
+ define_constants ();
179
+
180
+ // add the assumptions
181
+ solver.push (assumptions);
182
+
183
+ switch (solver ())
184
+ {
185
+ case decision_proceduret::resultt::D_SATISFIABLE:
186
+ std::cout << " sat\n " ;
187
+ status = SAT;
188
+ break ;
189
+
190
+ case decision_proceduret::resultt::D_UNSATISFIABLE:
191
+ std::cout << " unsat\n " ;
192
+ status = UNSAT;
193
+ break ;
194
+
195
+ case decision_proceduret::resultt::D_ERROR:
196
+ std::cout << " error\n " ;
197
+ status = NOT_SOLVED;
198
+ }
199
+
200
+ // remove the assumptions again
201
+ solver.pop ();
162
202
};
163
203
164
204
commands[" display" ] = [this ]() {
@@ -168,6 +208,10 @@ void smt2_solvert::setup_commands()
168
208
std::cout << smt2_format (e) << ' \n ' ;
169
209
};
170
210
211
+ commands[" get-unsat-assumptions" ] = [this ]() {
212
+ throw error (" not yet implemented" );
213
+ };
214
+
171
215
commands[" get-value" ] = [this ]() {
172
216
std::vector<exprt> ops;
173
217
0 commit comments