@@ -369,46 +369,14 @@ void add_quantified_variable(
369
369
exprt &expression,
370
370
const irep_idt &mode)
371
371
{
372
- if (expression.id () == ID_not || expression.id () == ID_typecast)
373
- {
374
- // For unary connectives, recursively check for
375
- // nested quantified formulae in the term
376
- auto &unary_expression = to_unary_expr (expression);
377
- add_quantified_variable (symbol_table, unary_expression.op (), mode);
378
- }
379
- if (expression.id () == ID_notequal || expression.id () == ID_implies)
380
- {
381
- // For binary connectives, recursively check for
382
- // nested quantified formulae in the left and right terms
383
- auto &binary_expression = to_binary_expr (expression);
384
- add_quantified_variable (symbol_table, binary_expression.lhs (), mode);
385
- add_quantified_variable (symbol_table, binary_expression.rhs (), mode);
386
- }
387
- if (expression.id () == ID_if)
388
- {
389
- // For ternary connectives, recursively check for
390
- // nested quantified formulae in all three terms
391
- auto &if_expression = to_if_expr (expression);
392
- add_quantified_variable (symbol_table, if_expression.cond (), mode);
393
- add_quantified_variable (symbol_table, if_expression.true_case (), mode);
394
- add_quantified_variable (symbol_table, if_expression.false_case (), mode);
395
- }
396
- if (expression.id () == ID_and || expression.id () == ID_or)
397
- {
398
- // For multi-ary connectives, recursively check for
399
- // nested quantified formulae in all terms
400
- auto &multi_ary_expression = to_multi_ary_expr (expression);
401
- for (auto &operand : multi_ary_expression.operands ())
402
- {
403
- add_quantified_variable (symbol_table, operand, mode);
404
- }
405
- }
406
- else if (expression.id () == ID_exists || expression.id () == ID_forall)
372
+ auto visitor = [&symbol_table, &mode](exprt &expr)
407
373
{
374
+ if (expr.id () != ID_exists && expr.id () != ID_forall)
375
+ return ;
408
376
// When a quantifier expression is found, create a fresh symbol for each
409
377
// quantified variable and rewrite the expression to use those fresh
410
378
// symbols.
411
- auto &quantifier_expression = to_quantifier_expr (expression );
379
+ auto &quantifier_expression = to_quantifier_expr (expr );
412
380
std::vector<symbol_exprt> fresh_variables;
413
381
fresh_variables.reserve (quantifier_expression.variables ().size ());
414
382
for (const auto &quantified_variable : quantifier_expression.variables ())
@@ -435,7 +403,8 @@ void add_quantified_variable(
435
403
// replace previous variables and body
436
404
quantifier_expression.variables () = fresh_variables;
437
405
quantifier_expression.where () = std::move (where);
438
- }
406
+ };
407
+ expression.visit_pre (visitor);
439
408
}
440
409
441
410
static void replace_history_parameter_rec (
0 commit comments