File tree Expand file tree Collapse file tree 8 files changed +63
-22
lines changed
cbmc/uninterpreted_function
smt2_solver/uninterpreted-functions Expand file tree Collapse file tree 8 files changed +63
-22
lines changed Original file line number Diff line number Diff line change 1
1
int __CPROVER_uninterpreted_f (int , int );
2
+ __CPROVER_bool __CPROVER_uninterpreted_g (int , int );
2
3
3
4
main ()
4
5
{
8
9
int inst2 = __CPROVER_uninterpreted_f (1 , b );
9
10
10
11
if (a == b )
11
- __CPROVER_assert (inst1 == inst2 , "functional consistency" );
12
+ __CPROVER_assert (inst1 == inst2 , "functional consistency for f" );
13
+
14
+ int inst3 = __CPROVER_uninterpreted_g (1 , a );
15
+ int inst4 = __CPROVER_uninterpreted_g (1 , b );
16
+
17
+ if (a == b )
18
+ __CPROVER_assert (inst3 == inst4 , "functional consistency for g" );
12
19
}
Original file line number Diff line number Diff line change
1
+ CORE
2
+ boolean_uf1.smt2
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^unsat$
7
+ --
Original file line number Diff line number Diff line change
1
+ (set-logic QF_UFBV)
2
+
3
+ (declare-fun myfun ((_ BitVec 32 )) Bool )
4
+
5
+ (assert (myfun (_ bv10 32 )))
6
+
7
+ (declare-const x (_ BitVec 32 ))
8
+ (assert (= x (_ bv10 32 )))
9
+ (assert (not (myfun x)))
10
+
11
+ (check-sat )
Original file line number Diff line number Diff line change
1
+ CORE
2
+ uf1.smt2
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^unsat$
7
+ --
Original file line number Diff line number Diff line change
1
+ (set-logic QF_UFBV)
2
+
3
+ (declare-fun myfun ((_ BitVec 32 )) (_ BitVec 32 ))
4
+
5
+ (assert (= (myfun (_ bv10 32 )) (_ bv20 32 )))
6
+
7
+ (declare-const x (_ BitVec 32 ))
8
+ (assert (= x (_ bv10 32 )))
9
+ (assert (= (myfun x) (_ bv30 32 )))
10
+
11
+ (check-sat )
Original file line number Diff line number Diff line change @@ -565,6 +565,11 @@ literalt boolbvt::convert_rest(const exprt &expr)
565
565
else if (op.type ().id () == ID_fixedbv)
566
566
return const_literal (true );
567
567
}
568
+ else if (expr.id () == ID_function_application)
569
+ {
570
+ functions.record (to_function_application_expr (expr));
571
+ return prop.new_variable ();
572
+ }
568
573
569
574
return SUB::convert_rest (expr);
570
575
}
Original file line number Diff line number Diff line change @@ -1223,19 +1223,8 @@ typet smt2_parsert::function_signature_declaration()
1223
1223
mathematical_function_typet::domaint domain;
1224
1224
1225
1225
while (smt2_tokenizer.peek () != smt2_tokenizert::CLOSE)
1226
- {
1227
- if (next_token () != smt2_tokenizert::OPEN)
1228
- throw error (" expected '(' at beginning of parameter" );
1229
-
1230
- if (next_token () != smt2_tokenizert::SYMBOL)
1231
- throw error (" expected symbol in parameter" );
1232
-
1233
1226
domain.push_back (sort ());
1234
1227
1235
- if (next_token () != smt2_tokenizert::CLOSE)
1236
- throw error (" expected ')' at end of parameter" );
1237
- }
1238
-
1239
1228
next_token (); // eat the ')'
1240
1229
1241
1230
typet codomain = sort ();
Original file line number Diff line number Diff line change @@ -102,18 +102,22 @@ void smt2_solvert::expand_function_applications(exprt &expr)
102
102
domain.size () == app.arguments ().size (),
103
103
" number of parameters must match number of arguments" );
104
104
105
- replace_symbolt replace_symbol;
106
-
107
- for (std::size_t i = 0 ; i < domain.size (); i++)
105
+ // Does it have a definition? It's otherwise uninterpreted.
106
+ if (!f.definition .is_nil ())
108
107
{
109
- replace_symbol.insert (
110
- symbol_exprt (f.parameters [i], domain[i]), app.arguments ()[i]);
108
+ replace_symbolt replace_symbol;
109
+
110
+ for (std::size_t i = 0 ; i < domain.size (); i++)
111
+ {
112
+ replace_symbol.insert (
113
+ symbol_exprt (f.parameters [i], domain[i]), app.arguments ()[i]);
114
+ }
115
+
116
+ exprt body = f.definition ;
117
+ replace_symbol (body);
118
+ expand_function_applications (body);
119
+ expr = body;
111
120
}
112
-
113
- exprt body = f.definition ;
114
- replace_symbol (body);
115
- expand_function_applications (body);
116
- expr = body;
117
121
}
118
122
}
119
123
}
You can’t perform that action at this time.
0 commit comments