11
11
#include < util/string_utils.h>
12
12
#include < util/symbol.h>
13
13
14
+ #include < solvers/lowering/expr_lowering.h>
14
15
#include < solvers/smt2_incremental/ast/smt_commands.h>
15
16
#include < solvers/smt2_incremental/ast/smt_responses.h>
16
17
#include < solvers/smt2_incremental/ast/smt_terms.h>
@@ -257,19 +258,23 @@ smt2_incremental_decision_proceduret::smt2_incremental_decision_proceduret(
257
258
}
258
259
259
260
void smt2_incremental_decision_proceduret::ensure_handle_for_expr_defined (
260
- const exprt &expr )
261
+ const exprt &in_expr )
261
262
{
262
263
if (
263
- expression_handle_identifiers.find (expr ) !=
264
+ expression_handle_identifiers.find (in_expr ) !=
264
265
expression_handle_identifiers.cend ())
265
266
{
266
267
return ;
267
268
}
268
269
269
- define_dependent_functions (expr);
270
+ const exprt lowered_expr = lower_byte_operators (in_expr, ns);
271
+
272
+ define_dependent_functions (lowered_expr);
270
273
smt_define_function_commandt function{
271
- " B" + std::to_string (handle_sequence ()), {}, convert_expr_to_smt (expr)};
272
- expression_handle_identifiers.emplace (expr, function.identifier ());
274
+ " B" + std::to_string (handle_sequence ()),
275
+ {},
276
+ convert_expr_to_smt (lowered_expr)};
277
+ expression_handle_identifiers.emplace (in_expr, function.identifier ());
273
278
identifier_table.emplace (
274
279
function.identifier ().identifier (), function.identifier ());
275
280
solver_process->send (function);
@@ -283,15 +288,23 @@ void smt2_incremental_decision_proceduret::define_index_identifiers(
283
288
return ;
284
289
if (const auto with_expr = expr_try_dynamic_cast<with_exprt>(expr_node))
285
290
{
286
- const auto index_expr = with_expr->where ();
287
- const auto index_term = convert_expr_to_smt (index_expr);
288
- const auto index_identifier = " index_" + std::to_string (index_sequence ());
289
- const auto index_definition =
290
- smt_define_function_commandt{index_identifier, {}, index_term};
291
- expression_identifiers.emplace (index_expr, index_definition.identifier ());
292
- identifier_table.emplace (index_identifier, index_definition.identifier ());
293
- solver_process->send (
294
- smt_define_function_commandt{index_identifier, {}, index_term});
291
+ for (auto operand_ite = ++with_expr->operands ().begin ();
292
+ operand_ite != with_expr->operands ().end ();
293
+ operand_ite += 2 )
294
+ {
295
+ const auto index_expr = *operand_ite;
296
+ const auto index_term = convert_expr_to_smt (index_expr);
297
+ const auto index_identifier =
298
+ " index_" + std::to_string (index_sequence ());
299
+ const auto index_definition =
300
+ smt_define_function_commandt{index_identifier, {}, index_term};
301
+ expression_identifiers.emplace (
302
+ index_expr, index_definition.identifier ());
303
+ identifier_table.emplace (
304
+ index_identifier, index_definition.identifier ());
305
+ solver_process->send (
306
+ smt_define_function_commandt{index_identifier, {}, index_term});
307
+ }
295
308
}
296
309
});
297
310
}
@@ -476,22 +489,25 @@ smt2_incremental_decision_proceduret::get_number_of_solver_calls() const
476
489
return number_of_solver_calls;
477
490
}
478
491
479
- void smt2_incremental_decision_proceduret::set_to (const exprt &expr, bool value)
492
+ void smt2_incremental_decision_proceduret::set_to (
493
+ const exprt &in_expr,
494
+ bool value)
480
495
{
481
- PRECONDITION (can_cast_type<bool_typet>(expr.type ()));
496
+ const exprt lowered_expr = lower_byte_operators (in_expr, ns);
497
+ PRECONDITION (can_cast_type<bool_typet>(lowered_expr.type ()));
482
498
log .conditional_output (log .debug (), [&](messaget::mstreamt &debug) {
483
499
debug << " `set_to` (" << std::string{value ? " true" : " false" } << " ) -\n "
484
- << expr .pretty (2 , 0 ) << messaget::eom;
500
+ << lowered_expr .pretty (2 , 0 ) << messaget::eom;
485
501
});
486
502
487
- define_dependent_functions (expr );
503
+ define_dependent_functions (lowered_expr );
488
504
auto converted_term = [&]() -> smt_termt {
489
505
const auto expression_handle_identifier =
490
- expression_handle_identifiers.find (expr );
506
+ expression_handle_identifiers.find (lowered_expr );
491
507
if (expression_handle_identifier != expression_handle_identifiers.cend ())
492
508
return expression_handle_identifier->second ;
493
509
else
494
- return convert_expr_to_smt (expr );
510
+ return convert_expr_to_smt (lowered_expr );
495
511
}();
496
512
if (!value)
497
513
converted_term = smt_core_theoryt::make_not (converted_term);
0 commit comments