@@ -25,14 +25,14 @@ Author: Daniel Kroening, kroening@kroening.com
2525class smt2_solvert :public smt2_parsert
2626{
2727public:
28- smt2_solvert (std::istream &_in, decision_proceduret &_solver)
28+ smt2_solvert (std::istream &_in, stack_decision_proceduret &_solver)
2929 : smt2_parsert(_in), solver(_solver), status(NOT_SOLVED)
3030 {
3131 setup_commands ();
3232 }
3333
3434protected:
35- decision_proceduret &solver;
35+ stack_decision_proceduret &solver;
3636
3737 void setup_commands ();
3838 void define_constants ();
@@ -158,7 +158,47 @@ void smt2_solvert::setup_commands()
158158 };
159159
160160 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 ();
162202 };
163203
164204 commands[" display" ] = [this ]() {
@@ -168,6 +208,10 @@ void smt2_solvert::setup_commands()
168208 std::cout << smt2_format (e) << ' \n ' ;
169209 };
170210
211+ commands[" get-unsat-assumptions" ] = [this ]() {
212+ throw error (" not yet implemented" );
213+ };
214+
171215 commands[" get-value" ] = [this ]() {
172216 std::vector<exprt> ops;
173217
0 commit comments