Skip to content

Commit ce8b26c

Browse files
author
Daniel Kroening
committed
introduce binding_exprt
This is a base class that factors out some common functionality of various expressions that are variable bindings; examples are let, lambda, forall, exists; future additions might include choose.
1 parent 1edf4d9 commit ce8b26c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/util/mathematical_expr.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,47 @@ inline function_application_exprt &to_function_application_expr(exprt &expr)
273273
return ret;
274274
}
275275

276+
/// \brief A base class for variable bindings (quantifiers, let, lambda)
277+
class binding_exprt : public binary_exprt
278+
{
279+
public:
280+
using variablest = std::vector<symbol_exprt>;
281+
282+
/// construct the binding expression
283+
binding_exprt(
284+
irep_idt _id,
285+
const variablest &_variables,
286+
exprt _where,
287+
typet _type)
288+
: binary_exprt(
289+
tuple_exprt((const operandst &)_variables),
290+
_id,
291+
std::move(_where),
292+
std::move(_type))
293+
{
294+
}
295+
296+
variablest &variables()
297+
{
298+
return (variablest &)static_cast<tuple_exprt &>(op0()).operands();
299+
}
300+
301+
const variablest &variables() const
302+
{
303+
return (variablest &)static_cast<const tuple_exprt &>(op0()).operands();
304+
}
305+
306+
exprt &where()
307+
{
308+
return op1();
309+
}
310+
311+
const exprt &where() const
312+
{
313+
return op1();
314+
}
315+
};
316+
276317
/// \brief A base class for quantifier expressions
277318
class quantifier_exprt : public binary_predicate_exprt
278319
{

0 commit comments

Comments
 (0)