@@ -2138,6 +2138,26 @@ void smt2_convt::convert_expr(const exprt &expr)
2138
2138
{
2139
2139
convert_expr (simplify_expr (to_bitreverse_expr (expr).lower (), ns));
2140
2140
}
2141
+ else if (expr.id () == ID_function_application)
2142
+ {
2143
+ const auto &function_application_expr = to_function_application_expr (expr);
2144
+ // do not use parentheses if there function is a constant
2145
+ if (function_application_expr.arguments ().empty ())
2146
+ {
2147
+ convert_expr (function_application_expr.function ());
2148
+ }
2149
+ else
2150
+ {
2151
+ out << ' (' ;
2152
+ convert_expr (function_application_expr.function ());
2153
+ for (auto &op : function_application_expr.arguments ())
2154
+ {
2155
+ out << ' ' ;
2156
+ convert_expr (op);
2157
+ }
2158
+ out << ' )' ;
2159
+ }
2160
+ }
2141
2161
else
2142
2162
INVARIANT_WITH_DIAGNOSTICS (
2143
2163
false ,
@@ -4468,13 +4488,49 @@ void smt2_convt::set_to(const exprt &expr, bool value)
4468
4488
smt2_identifiers.insert (smt2_identifier);
4469
4489
4470
4490
out << " ; set_to true (equal)\n " ;
4471
- out << " (define-fun |" << smt2_identifier << " | () " ;
4491
+ out << " (define-fun |" << smt2_identifier << ' | ' ;
4472
4492
4473
- convert_type (equal_expr.lhs ().type ());
4474
- out << " " ;
4475
- convert_expr (prepared_rhs);
4493
+ if (equal_expr.lhs ().type ().id () == ID_mathematical_function)
4494
+ {
4495
+ auto &mathematical_function_type =
4496
+ to_mathematical_function_type (equal_expr.lhs ().type ());
4497
+ out << " (" ;
4498
+ bool first = true ;
4499
+
4500
+ for (std::size_t p_nr = 0 ;
4501
+ p_nr < mathematical_function_type.domain ().size ();
4502
+ p_nr++)
4503
+ {
4504
+ if (first)
4505
+ first = false ;
4506
+ else
4507
+ out << ' ' ;
4508
+
4509
+ out << ' (' << ' p' << (p_nr + 1 ) << ' ' ;
4510
+ convert_type (mathematical_function_type.domain ()[p_nr]);
4511
+ out << ' )' ;
4512
+ }
4476
4513
4477
- out << " )" << " \n " ;
4514
+ out << " ) " ;
4515
+ convert_type (mathematical_function_type.codomain ());
4516
+
4517
+ out << ' ' << ' (' ;
4518
+ convert_expr (prepared_rhs);
4519
+ for (std::size_t p_nr = 0 ;
4520
+ p_nr < mathematical_function_type.domain ().size ();
4521
+ p_nr++)
4522
+ out << ' ' << ' p' << (p_nr + 1 );
4523
+ out << ' )' ;
4524
+ }
4525
+ else
4526
+ {
4527
+ out << " () " ;
4528
+ convert_type (equal_expr.lhs ().type ());
4529
+ out << ' ' ;
4530
+ convert_expr (prepared_rhs);
4531
+ }
4532
+
4533
+ out << ' )' << ' \n ' ;
4478
4534
return ; // done
4479
4535
}
4480
4536
}
@@ -4616,10 +4672,33 @@ void smt2_convt::find_symbols(const exprt &expr)
4616
4672
smt2_identifiers.insert (smt2_identifier);
4617
4673
4618
4674
out << " ; find_symbols\n " ;
4619
- out << " (declare-fun |"
4620
- << smt2_identifier
4621
- << " | () " ;
4622
- convert_type (expr.type ());
4675
+ out << " (declare-fun |" << smt2_identifier << ' |' ;
4676
+
4677
+ if (expr.type ().id () == ID_mathematical_function)
4678
+ {
4679
+ auto &mathematical_function_type =
4680
+ to_mathematical_function_type (expr.type ());
4681
+ out << " (" ;
4682
+ bool first = true ;
4683
+
4684
+ for (auto &type : mathematical_function_type.domain ())
4685
+ {
4686
+ if (first)
4687
+ first = false ;
4688
+ else
4689
+ out << ' ' ;
4690
+ convert_type (type);
4691
+ }
4692
+
4693
+ out << " ) " ;
4694
+ convert_type (mathematical_function_type.codomain ());
4695
+ }
4696
+ else
4697
+ {
4698
+ out << " () " ;
4699
+ convert_type (expr.type ());
4700
+ }
4701
+
4623
4702
out << " )" << " \n " ;
4624
4703
}
4625
4704
}
@@ -5218,6 +5297,15 @@ void smt2_convt::find_symbols_rec(
5218
5297
find_symbols_rec (ns.follow_tag (union_tag), recstack);
5219
5298
}
5220
5299
}
5300
+ else if (type.id () == ID_mathematical_function)
5301
+ {
5302
+ const auto &mathematical_function_type =
5303
+ to_mathematical_function_type (type);
5304
+ for (auto &d_type : mathematical_function_type.domain ())
5305
+ find_symbols_rec (d_type, recstack);
5306
+
5307
+ find_symbols_rec (mathematical_function_type.codomain (), recstack);
5308
+ }
5221
5309
}
5222
5310
5223
5311
std::size_t smt2_convt::get_number_of_solver_calls () const
0 commit comments