File tree 3 files changed +51
-1
lines changed
regression/smt2_solver/get-assignment 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change
1
+ CORE
2
+ get-assignment1.smt2
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^sat$
7
+ ^\(\(y_equality true\)\)$
8
+ --
Original file line number Diff line number Diff line change
1
+ (set-logic QF_BV)
2
+ (set-option :produce-assignments true )
3
+
4
+ (declare-const var_x (_ BitVec 8 )) ; nullary function
5
+ (declare-const var_y (_ BitVec 8 )) ; nullary function
6
+ (declare-const var_z (_ BitVec 8 )) ; nullary function
7
+
8
+ (assert (= var_x #x01 ))
9
+ (assert (! (= var_y #x02 ) :name d y_equality))
10
+ (assert (= var_z (bvadd var_x var_y)))
11
+
12
+ (check-sat )
13
+ (get-assignment )
Original file line number Diff line number Diff line change @@ -232,6 +232,36 @@ void smt2_solvert::command(const std::string &c)
232
232
233
233
std::cout << smt2_format (constant_exprt (buffer, string_typet ())) << ' \n ' ;
234
234
}
235
+ else if (c == " get-assignment" )
236
+ {
237
+ // print satisfying assignment for all named expressions
238
+
239
+ if (status != SAT)
240
+ throw error (" model is not available" );
241
+
242
+ bool first = true ;
243
+
244
+ std::cout << ' (' ;
245
+ for (const auto &named_term : named_terms)
246
+ {
247
+ const symbol_tablet symbol_table;
248
+ const namespacet ns (symbol_table);
249
+ const auto value =
250
+ simplify_expr (solver.get (named_term.second .term ), ns);
251
+
252
+ if (value.is_constant ())
253
+ {
254
+ if (first)
255
+ first = false ;
256
+ else
257
+ std::cout << ' \n ' << ' ' ;
258
+
259
+ std::cout << ' (' << smt2_format (named_term.second .name ) << ' '
260
+ << smt2_format (value) << ' )' ;
261
+ }
262
+ }
263
+ std::cout << ' )' << ' \n ' ;
264
+ }
235
265
else if (c == " simplify" )
236
266
{
237
267
// this is a command that Z3 appears to implement
@@ -256,7 +286,6 @@ void smt2_solvert::command(const std::string &c)
256
286
| ( define-funs-rec ( hfunction_deci n+1 ) ( htermi n+1 ) )
257
287
| ( define-sort hsymboli ( hsymboli ??? ) hsorti )
258
288
| ( get-assertions )
259
- | ( get-assignment )
260
289
| ( get-info hinfo_flag i )
261
290
| ( get-model )
262
291
| ( get-option hkeywordi )
You can’t perform that action at this time.
0 commit comments