Skip to content

Commit 439bf5b

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 602e2e8 commit 439bf5b

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
@@ -271,6 +271,47 @@ inline function_application_exprt &to_function_application_expr(exprt &expr)
271271
return ret;
272272
}
273273

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

0 commit comments

Comments
 (0)