1212
1313#include " temporal_logic.h"
1414
15- static std::optional<exprt> is_state_formula (const exprt &expr)
15+ static std::optional<exprt> is_state_predicate (const exprt &expr)
1616{
17- if (expr.id () == ID_typecast && expr.type ().id () == ID_verilog_sva_sequence)
18- return to_typecast_expr (expr).op ();
19- else if (expr.type ().id () == ID_bool)
20- return expr;
17+ if (expr.id () == ID_sva_boolean)
18+ return to_sva_boolean_expr (expr).op ();
2119 else
2220 return {};
2321}
@@ -30,8 +28,8 @@ exprt trivial_sva(exprt expr)
3028 // Same as regular implication if lhs and rhs are not sequences.
3129 auto &sva_implication = to_sva_overlapped_implication_expr (expr);
3230
33- auto lhs = is_state_formula (sva_implication.lhs ());
34- auto rhs = is_state_formula (sva_implication.rhs ());
31+ auto lhs = is_state_predicate (sva_implication.lhs ());
32+ auto rhs = is_state_predicate (sva_implication.rhs ());
3533
3634 if (lhs.has_value () && rhs.has_value ())
3735 expr = implies_exprt{*lhs, *rhs};
@@ -51,22 +49,22 @@ exprt trivial_sva(exprt expr)
5149 auto &sva_and = to_sva_and_expr (expr);
5250
5351 // Same as a ∧ b if the expression is not a sequence.
54- auto lhs = is_state_formula (sva_and.lhs ());
55- auto rhs = is_state_formula (sva_and.rhs ());
52+ auto lhs = is_state_predicate (sva_and.lhs ());
53+ auto rhs = is_state_predicate (sva_and.rhs ());
5654
5755 if (lhs.has_value () && rhs.has_value ())
58- expr = and_exprt{*lhs, *rhs};
56+ expr = sva_boolean_exprt{ and_exprt{*lhs, *rhs}, expr. type () };
5957 }
6058 else if (expr.id () == ID_sva_or)
6159 {
6260 auto &sva_or = to_sva_or_expr (expr);
6361
6462 // Same as a ∨ b if the expression is not a sequence.
65- auto lhs = is_state_formula (sva_or.lhs ());
66- auto rhs = is_state_formula (sva_or.rhs ());
63+ auto lhs = is_state_predicate (sva_or.lhs ());
64+ auto rhs = is_state_predicate (sva_or.rhs ());
6765
6866 if (lhs.has_value () && rhs.has_value ())
69- expr = or_exprt{*lhs, *rhs};
67+ expr = sva_boolean_exprt{ or_exprt{*lhs, *rhs}, expr. type () };
7068 }
7169 else if (expr.id () == ID_sva_not)
7270 {
@@ -113,9 +111,10 @@ exprt trivial_sva(exprt expr)
113111 {
114112 // We simplify sequences to boolean expressions, and hence can drop
115113 // the sva_sequence_property converter
116- auto &op = to_sva_sequence_property_expr_base (expr).sequence ();
117- if (op.type ().id () == ID_bool)
118- return op;
114+ auto &sequence = to_sva_sequence_property_expr_base (expr).sequence ();
115+ auto pred_opt = is_state_predicate (sequence);
116+ if (pred_opt.has_value ())
117+ return *pred_opt;
119118 }
120119
121120 return expr;
0 commit comments