CBMC
guard_bdd.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Guard Data Structure
4 
5 Author: Romain Brenguier, romain.brenguier@diffblue.com
6 
7 \*******************************************************************/
8 
12 
13 #ifndef CPROVER_ANALYSES_GUARD_BDD_H
14 #define CPROVER_ANALYSES_GUARD_BDD_H
15 
16 #include <solvers/bdd/bdd.h> // IWYU pragma: keep
17 
18 class bdd_exprt;
19 class exprt;
20 
22 {
23 public:
24  guard_bddt(const exprt &e, bdd_exprt &manager);
25  guard_bddt(const guard_bddt &other) : manager(other.manager), bdd(other.bdd)
26  {
27  }
28 
29  guard_bddt &operator=(const guard_bddt &other);
31  guard_bddt &add(const exprt &expr);
33  exprt as_expr() const;
34 
38  static constexpr bool is_always_simplified = true;
39 
42  exprt guard_expr(exprt expr) const;
43 
44  bool is_true() const
45  {
46  return bdd.is_true();
47  }
48 
49  bool is_false() const
50  {
51  return bdd.is_false();
52  }
53 
56  friend guard_bddt &operator-=(guard_bddt &g1, const guard_bddt &g2);
57 
58  friend guard_bddt &operator|=(guard_bddt &g1, const guard_bddt &g2);
59 
61  {
62  return guard_bddt(manager, bdd.bdd_not());
63  }
64 
67  bool disjunction_may_simplify(const guard_bddt &other_guard)
68  {
69  return true;
70  }
71 
72 private:
75 
77  : manager(manager), bdd(std::move(bdd))
78  {
79  }
80 };
81 
82 #endif // CPROVER_ANALYSES_GUARD_BDD_H
Choice between the different interface to BDD libraries.
static exprt guard(const exprt::operandst &guards, exprt cond)
Conversion between exprt and bbdt This encapsulate a bdd_managert, thus BDDs created with this class ...
Definition: bdd_expr.h:34
Logical operations on BDDs.
Definition: bdd_cudd.h:78
bddt bdd_not() const
Definition: bdd_cudd.h:95
bool is_true() const
Definition: bdd_cudd.h:85
bool is_false() const
Definition: bdd_cudd.h:90
Base class for all expressions.
Definition: expr.h:56
guard_bddt operator!() const
Definition: guard_bdd.h:60
bool is_true() const
Definition: guard_bdd.h:44
bool disjunction_may_simplify(const guard_bddt &other_guard)
Returns true if operator|= with other_guard may result in a simpler expression.
Definition: guard_bdd.h:67
guard_bddt(const guard_bddt &other)
Definition: guard_bdd.h:25
exprt as_expr() const
Definition: guard_bdd.cpp:82
guard_bddt & add(const exprt &expr)
Definition: guard_bdd.cpp:64
static constexpr bool is_always_simplified
BDDs are always in a simplified form and thus no further simplification is required after calls to as...
Definition: guard_bdd.h:38
guard_bddt(const exprt &e, bdd_exprt &manager)
Definition: guard_bdd.cpp:19
guard_bddt & append(const guard_bddt &guard)
Definition: guard_bdd.cpp:58
guard_bddt(bdd_exprt &manager, bddt bdd)
Definition: guard_bdd.h:76
exprt guard_expr(exprt expr) const
Return guard => dest or a simplified variant thereof if either guard or dest are trivial.
Definition: guard_bdd.cpp:38
bddt bdd
Definition: guard_bdd.h:74
bool is_false() const
Definition: guard_bdd.h:49
bdd_exprt & manager
Definition: guard_bdd.h:73
guard_bddt & operator=(const guard_bddt &other)
Definition: guard_bdd.cpp:24
friend guard_bddt & operator|=(guard_bddt &g1, const guard_bddt &g2)
Definition: guard_bdd.cpp:76
friend guard_bddt & operator-=(guard_bddt &g1, const guard_bddt &g2)
Transforms g1 into g1' such that ‘g1’ & g2 => g1 => g1'` and returns a reference to g1.
Definition: guard_bdd.cpp:70