@@ -4744,13 +4744,12 @@ inline void validate_expr(const let_exprt &value)
4744
4744
validate_operands (value, 3 , " Let must have three operands" );
4745
4745
}
4746
4746
4747
-
4748
- /* ! \brief A forall expression
4747
+ /* ! \brief A base class for quantifier expressions
4749
4748
*/
4750
- class forall_exprt :public binary_exprt
4749
+ class quantifier_exprt :public binary_predicate_exprt
4751
4750
{
4752
4751
public:
4753
- forall_exprt ():binary_exprt(ID_forall )
4752
+ explicit quantifier_exprt ( const irep_idt &_id):binary_predicate_exprt(_id )
4754
4753
{
4755
4754
op0 ()=symbol_exprt ();
4756
4755
}
@@ -4776,34 +4775,60 @@ class forall_exprt:public binary_exprt
4776
4775
}
4777
4776
};
4778
4777
4779
- /* ! \brief An exists expression
4778
+ /* ! \brief Cast a generic exprt to a \ref quantifier_exprt
4779
+ *
4780
+ * This is an unchecked conversion. \a expr must be known to be \ref
4781
+ * quantifier_exprt.
4782
+ *
4783
+ * \param expr Source expression
4784
+ * \return Object of type \ref quantifier_exprt
4785
+ *
4786
+ * \ingroup gr_std_expr
4780
4787
*/
4781
- class exists_exprt : public binary_exprt
4788
+ inline const quantifier_exprt & to_quantifier_expr ( const exprt &expr)
4782
4789
{
4783
- public:
4784
- exists_exprt ():binary_exprt(ID_exists)
4785
- {
4786
- op0 ()=symbol_exprt ();
4787
- }
4790
+ DATA_INVARIANT (expr.operands ().size ()==2 ,
4791
+ " quantifier expressions must have two operands" );
4792
+ return static_cast <const quantifier_exprt &>(expr);
4793
+ }
4788
4794
4789
- symbol_exprt &symbol ()
4790
- {
4791
- return static_cast <symbol_exprt &>(op0 ());
4792
- }
4795
+ /* ! \copydoc to_quantifier_expr(const exprt &)
4796
+ * \ingroup gr_std_expr
4797
+ */
4798
+ inline quantifier_exprt &to_quantifier_expr (exprt &expr)
4799
+ {
4800
+ DATA_INVARIANT (expr.operands ().size ()==2 ,
4801
+ " quantifier expressions must have two operands" );
4802
+ return static_cast <quantifier_exprt &>(expr);
4803
+ }
4793
4804
4794
- const symbol_exprt &symbol () const
4795
- {
4796
- return static_cast <const symbol_exprt &>(op0 ());
4797
- }
4805
+ template <> inline bool can_cast_expr<quantifier_exprt>(const exprt &base)
4806
+ {
4807
+ return true ;
4808
+ }
4809
+ inline void validate_expr (const quantifier_exprt &value)
4810
+ {
4811
+ validate_operands (value, 2 ,
4812
+ " quantifier expressions must have two operands" );
4813
+ }
4798
4814
4799
- exprt &where ()
4815
+ /* ! \brief A forall expression
4816
+ */
4817
+ class forall_exprt :public quantifier_exprt
4818
+ {
4819
+ public:
4820
+ forall_exprt ():quantifier_exprt(ID_forall)
4800
4821
{
4801
- return op1 ();
4802
4822
}
4823
+ };
4803
4824
4804
- const exprt &where () const
4825
+ /* ! \brief An exists expression
4826
+ */
4827
+ class exists_exprt :public quantifier_exprt
4828
+ {
4829
+ public:
4830
+ exists_exprt ():quantifier_exprt(ID_exists)
4805
4831
{
4806
- return op1 ();
4807
4832
}
4808
4833
};
4809
4834
0 commit comments