CBMC
guard_bdd.cpp
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 
11 
12 #include "guard_bdd.h"
13 
14 #include <solvers/prop/bdd_expr.h>
15 #include <util/expr_util.h>
16 #include <util/invariant.h>
17 #include <util/std_expr.h>
18 
20  : manager(manager), bdd(manager.from_expr(e))
21 {
22 }
23 
25 {
26  PRECONDITION(&manager == &other.manager);
27  bdd = other.bdd;
28  return *this;
29 }
30 
32 {
33  PRECONDITION(&manager == &other.manager);
34  std::swap(bdd, other.bdd);
35  return *this;
36 }
37 
39 {
40  if(is_true())
41  {
42  // do nothing
43  return expr;
44  }
45  else
46  {
47  if(expr.is_false())
48  {
49  return boolean_negate(as_expr());
50  }
51  else
52  {
53  return implies_exprt{as_expr(), expr};
54  }
55  }
56 }
57 
59 {
60  bdd = bdd.bdd_and(guard.bdd);
61  return *this;
62 }
63 
65 {
66  bdd = bdd.bdd_and(manager.from_expr(expr));
67  return *this;
68 }
69 
71 {
72  g1.bdd = g1.bdd.constrain(g2.bdd.bdd_or(g1.bdd));
73  return g1;
74 }
75 
77 {
78  g1.bdd = g1.bdd.bdd_or(g2.bdd);
79  return g1;
80 }
81 
83 {
84  return manager.as_expr(bdd);
85 }
Conversion between exprt and miniBDD.
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
exprt as_expr(const bddt &root) const
Definition: bdd_expr.cpp:171
bddt from_expr(const exprt &expr)
Definition: bdd_expr.cpp:87
bddt constrain(const bddt &other)
Definition: bdd_cudd.h:120
bddt bdd_or(const bddt &other) const
Definition: bdd_cudd.h:100
bddt bdd_and(const bddt &other) const
Definition: bdd_cudd.h:105
BDD bdd
Definition: bdd_cudd.h:128
Base class for all expressions.
Definition: expr.h:56
bool is_false() const
Return whether the expression is a constant representing false.
Definition: expr.cpp:34
bool is_true() const
Definition: guard_bdd.h:44
exprt as_expr() const
Definition: guard_bdd.cpp:82
guard_bddt & add(const exprt &expr)
Definition: guard_bdd.cpp:64
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
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
bdd_exprt & manager
Definition: guard_bdd.h:73
guard_bddt & operator=(const guard_bddt &other)
Definition: guard_bdd.cpp:24
Boolean implication.
Definition: std_expr.h:2188
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
Definition: expr_util.cpp:103
Deprecated expression utility functions.
guard_bddt & operator|=(guard_bddt &g1, const guard_bddt &g2)
Definition: guard_bdd.cpp:76
guard_bddt & operator-=(guard_bddt &g1, const guard_bddt &g2)
Definition: guard_bdd.cpp:70
Guard Data Structure Implementation using BDDs.
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
API to expression classes.