@@ -4462,10 +4462,21 @@ inline cond_exprt &to_cond_expr(exprt &expr)
4462
4462
4463
4463
// / \brief Expression to define a mapping from an argument (index) to elements.
4464
4464
// / This enables constructing an array via an anonymous function.
4465
- class lambda_exprt : public binary_exprt
4465
+ // / Not all kinds of array comprehension can be expressed, only those of the
4466
+ // / form `[f(x) | x in {0, 1, ... array_size-1}]`.
4467
+ // / The LHS and RHS are the argument (`x`) and body (`f(x)`) of the anonymous
4468
+ // / function, respectively. The range is given by the type of the expression,
4469
+ // / which has to be an \ref array_typet (which includes a value for
4470
+ // / `array_size`).
4471
+ // / For legacy reasons, the ID of an array_comprehension_exprt is ID_lambda,
4472
+ // / even though it cannot be used to represent arbitrary lambda functions.
4473
+ class array_comprehension_exprt : public binary_exprt
4466
4474
{
4467
4475
public:
4468
- explicit lambda_exprt (symbol_exprt arg, exprt body, array_typet _type)
4476
+ explicit array_comprehension_exprt (
4477
+ symbol_exprt arg,
4478
+ exprt body,
4479
+ array_typet _type)
4469
4480
: binary_exprt(std::move(arg), ID_lambda, std::move(body), std::move(_type))
4470
4481
{
4471
4482
}
@@ -4502,35 +4513,38 @@ class lambda_exprt : public binary_exprt
4502
4513
};
4503
4514
4504
4515
template <>
4505
- inline bool can_cast_expr<lambda_exprt >(const exprt &base)
4516
+ inline bool can_cast_expr<array_comprehension_exprt >(const exprt &base)
4506
4517
{
4507
4518
return base.id () == ID_lambda;
4508
4519
}
4509
4520
4510
- inline void validate_expr (const lambda_exprt &value)
4521
+ inline void validate_expr (const array_comprehension_exprt &value)
4511
4522
{
4512
- validate_operands (value, 2 , " 'Lambda ' must have two operands" );
4523
+ validate_operands (value, 2 , " 'Array comprehension ' must have two operands" );
4513
4524
}
4514
4525
4515
- // / \brief Cast an exprt to a \ref lambda_exprt
4526
+ // / \brief Cast an exprt to a \ref array_comprehension_exprt
4516
4527
// /
4517
- // / \a expr must be known to be \ref lambda_exprt .
4528
+ // / \a expr must be known to be \ref array_comprehension_exprt .
4518
4529
// /
4519
4530
// / \param expr: Source expression
4520
- // / \return Object of type \ref lambda_exprt
4521
- inline const lambda_exprt &to_lambda_expr (const exprt &expr)
4531
+ // / \return Object of type \ref array_comprehension_exprt
4532
+ inline const array_comprehension_exprt &
4533
+ to_array_comprehension_expr (const exprt &expr)
4522
4534
{
4523
4535
PRECONDITION (expr.id () == ID_lambda);
4524
- const lambda_exprt &ret = static_cast <const lambda_exprt &>(expr);
4536
+ const array_comprehension_exprt &ret =
4537
+ static_cast <const array_comprehension_exprt &>(expr);
4525
4538
validate_expr (ret);
4526
4539
return ret;
4527
4540
}
4528
4541
4529
- // / \copydoc to_lambda_expr (const exprt &)
4530
- inline lambda_exprt & to_lambda_expr (exprt &expr)
4542
+ // / \copydoc to_array_comprehension_expr (const exprt &)
4543
+ inline array_comprehension_exprt & to_array_comprehension_expr (exprt &expr)
4531
4544
{
4532
4545
PRECONDITION (expr.id () == ID_lambda);
4533
- lambda_exprt &ret = static_cast <lambda_exprt &>(expr);
4546
+ array_comprehension_exprt &ret =
4547
+ static_cast <array_comprehension_exprt &>(expr);
4534
4548
validate_expr (ret);
4535
4549
return ret;
4536
4550
}
0 commit comments