CBMC
cover_goals.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Cover a set of goals incrementally
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_SOLVERS_PROP_COVER_GOALS_H
13 #define CPROVER_SOLVERS_PROP_COVER_GOALS_H
14 
15 #include <list>
16 
18 
19 #include <util/expr.h>
20 
21 class message_handlert;
22 
26 {
27 public:
28  explicit cover_goalst(decision_proceduret &_decision_procedure)
29  : _number_covered(0),
30  _iterations(0),
31  decision_procedure(_decision_procedure)
32  {
33  }
34 
35  virtual ~cover_goalst();
36 
37  // returns result of last run on success
39 
40  // the goals
41 
42  struct goalt
43  {
46 
47  explicit goalt(exprt _condition)
48  : condition(std::move(_condition)), status(statust::UNKNOWN)
49  {
50  }
51  };
52 
53  typedef std::list<goalt> goalst;
55 
56  // statistics
57 
58  std::size_t number_covered() const
59  {
60  return _number_covered;
61  }
62 
63  unsigned iterations() const
64  {
65  return _iterations;
66  }
67 
69  {
70  return goals.size();
71  }
72 
73  // managing the goals
74 
75  void add(exprt condition)
76  {
77  goals.emplace_back(std::move(condition));
78  }
79 
80  // register an observer if you want to be told
81  // about satisfying assignments
82 
83  class observert
84  {
85  public:
86  virtual void goal_covered(const goalt &) { }
87  virtual void satisfying_assignment() { }
88  };
89 
91  {
92  observers.push_back(&o);
93  }
94 
95 protected:
96  std::size_t _number_covered;
97  unsigned _iterations;
99 
100  typedef std::vector<observert *> observerst;
102 
103 private:
104  void mark();
105  void constraint();
106 };
107 
108 #endif // CPROVER_SOLVERS_PROP_COVER_GOALS_H
virtual void goal_covered(const goalt &)
Definition: cover_goals.h:86
virtual void satisfying_assignment()
Definition: cover_goals.h:87
Try to cover some given set of goals incrementally.
Definition: cover_goals.h:26
observerst observers
Definition: cover_goals.h:101
virtual ~cover_goalst()
Definition: cover_goals.cpp:17
std::size_t _number_covered
Definition: cover_goals.h:96
std::vector< observert * > observerst
Definition: cover_goals.h:100
unsigned iterations() const
Definition: cover_goals.h:63
unsigned _iterations
Definition: cover_goals.h:97
std::size_t number_covered() const
Definition: cover_goals.h:58
void register_observer(observert &o)
Definition: cover_goals.h:90
goalst::size_type size() const
Definition: cover_goals.h:68
void add(exprt condition)
Definition: cover_goals.h:75
std::list< goalt > goalst
Definition: cover_goals.h:53
decision_proceduret::resultt operator()(message_handlert &)
Try to cover all goals.
Definition: cover_goals.cpp:59
void constraint()
Build clause.
Definition: cover_goals.cpp:43
void mark()
Mark goals that are covered.
Definition: cover_goals.cpp:22
cover_goalst(decision_proceduret &_decision_procedure)
Definition: cover_goals.h:28
decision_proceduret & decision_procedure
Definition: cover_goals.h:98
goalst goals
Definition: cover_goals.h:54
An interface for a decision procedure for satisfiability problems.
resultt
Result of running the decision procedure.
Base class for all expressions.
Definition: expr.h:56
Decision Procedure Interface.
goalt(exprt _condition)
Definition: cover_goals.h:47
enum cover_goalst::goalt::statust status
#define size_type
Definition: unistd.c:347