Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a base class for forall_exprt and exists_exprt #1897

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 48 additions & 23 deletions src/util/std_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4744,13 +4744,12 @@ inline void validate_expr(const let_exprt &value)
validate_operands(value, 3, "Let must have three operands");
}


/*! \brief A forall expression
/*! \brief A base class for quantifier expressions
*/
class forall_exprt:public binary_exprt
class quantifier_exprt:public binary_predicate_exprt
{
public:
forall_exprt():binary_exprt(ID_forall)
explicit quantifier_exprt(const irep_idt &_id):binary_predicate_exprt(_id)
{
op0()=symbol_exprt();
}
Expand All @@ -4776,34 +4775,60 @@ class forall_exprt:public binary_exprt
}
};

/*! \brief An exists expression
/*! \brief Cast a generic exprt to a \ref quantifier_exprt
*
* This is an unchecked conversion. \a expr must be known to be \ref
* quantifier_exprt.
*
* \param expr Source expression
* \return Object of type \ref quantifier_exprt
*
* \ingroup gr_std_expr
*/
class exists_exprt:public binary_exprt
inline const quantifier_exprt &to_quantifier_expr(const exprt &expr)
{
public:
exists_exprt():binary_exprt(ID_exists)
{
op0()=symbol_exprt();
}
DATA_INVARIANT(expr.operands().size()==2,
"quantifier expressions must have two operands");
return static_cast<const quantifier_exprt &>(expr);
}

symbol_exprt &symbol()
{
return static_cast<symbol_exprt &>(op0());
}
/*! \copydoc to_quantifier_expr(const exprt &)
* \ingroup gr_std_expr
*/
inline quantifier_exprt &to_quantifier_expr(exprt &expr)
{
DATA_INVARIANT(expr.operands().size()==2,
"quantifier expressions must have two operands");
return static_cast<quantifier_exprt &>(expr);
}

const symbol_exprt &symbol() const
{
return static_cast<const symbol_exprt &>(op0());
}
template<> inline bool can_cast_expr<quantifier_exprt>(const exprt &base)
{
return true;
}
inline void validate_expr(const quantifier_exprt &value)
{
validate_operands(value, 2,
"quantifier expressions must have two operands");
}

exprt &where()
/*! \brief A forall expression
*/
class forall_exprt:public quantifier_exprt
{
public:
forall_exprt():quantifier_exprt(ID_forall)
{
return op1();
}
};

const exprt &where() const
/*! \brief An exists expression
*/
class exists_exprt:public quantifier_exprt
{
public:
exists_exprt():quantifier_exprt(ID_exists)
{
return op1();
}
};

Expand Down