-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathguard_expr.h
82 lines (62 loc) · 2.09 KB
/
guard_expr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*******************************************************************\
Module: Guard Data Structure
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// Guard Data Structure
#ifndef CPROVER_ANALYSES_GUARD_EXPR_H
#define CPROVER_ANALYSES_GUARD_EXPR_H
#include <util/std_expr.h>
/// This is unused by this implementation of guards, but can be used by other
/// implementations of the same interface.
struct guard_expr_managert
{
};
class guard_exprt
{
public:
/// Construct a BDD from an expression
/// The \c guard_managert parameter is not used, but we keep it for uniformity
/// with other implementations of guards which may use it.
explicit guard_exprt(const exprt &e, guard_expr_managert &) : expr(e)
{
}
guard_exprt &operator=(const guard_exprt &other)
{
expr = other.expr;
return *this;
}
void add(const exprt &expr);
void append(const guard_exprt &guard)
{
add(guard.as_expr());
}
exprt as_expr() const
{
return expr;
}
/// The result of \ref as_expr is not always in a simplified form
/// and may requires some simplification.
/// This can vary according to the guard implementation.
static constexpr bool is_always_simplified = false;
/// Return `guard => dest` or a simplified variant thereof if either guard or
/// dest are trivial.
exprt guard_expr(exprt expr) const;
bool is_true() const
{
return expr.is_constant() && to_constant_expr(expr).is_true();
}
bool is_false() const
{
return expr.is_constant() && to_constant_expr(expr).is_false();
}
friend guard_exprt &operator-=(guard_exprt &g1, const guard_exprt &g2);
friend guard_exprt &operator|=(guard_exprt &g1, const guard_exprt &g2);
/// Returns true if `operator|=` with \p other_guard may result in a simpler
/// expression. For `guard_exprt` in practice this means they're both
/// conjunctions, since for other things we just OR them together.
bool disjunction_may_simplify(const guard_exprt &other_guard);
private:
exprt expr;
};
#endif // CPROVER_ANALYSES_GUARD_EXPR_H