CBMC
cover_goals.cpp
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 #include "cover_goals.h"
13 
14 #include <util/message.h>
15 #include <util/std_expr.h>
16 
18 {
19 }
20 
23 {
24  // notify observers
25  for(const auto &o : observers)
26  o->satisfying_assignment();
27 
28  for(auto &g : goals)
29  if(
30  g.status == goalt::statust::UNKNOWN &&
31  decision_procedure.get(g.condition).is_true())
32  {
33  g.status=goalt::statust::COVERED;
35 
36  // notify observers
37  for(const auto &o : observers)
38  o->goal_covered(g);
39  }
40 }
41 
44 {
45  exprt::operandst disjuncts;
46 
47  // cover at least one unknown goal
48 
49  for(const auto &g : goals)
50  if(g.status == goalt::statust::UNKNOWN && !g.condition.is_false())
51  disjuncts.push_back(g.condition);
52 
53  // this is 'false' if there are no disjuncts
55 }
56 
59 operator()(message_handlert &message_handler)
60 {
62 
64 
65  do
66  {
67  // We want (at least) one of the remaining goals, please!
68  _iterations++;
69 
70  constraint();
71  dec_result = decision_procedure();
72 
73  switch(dec_result)
74  {
76  return dec_result;
77 
79  // mark the goals we got, and notify observers
80  mark();
81  break;
82 
84  {
85  messaget log(message_handler);
86  log.error() << "decision procedure has failed" << messaget::eom;
87  return dec_result;
88  }
89  }
90  }
92  number_covered()<size());
93 
95 }
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
unsigned _iterations
Definition: cover_goals.h:97
std::size_t number_covered() const
Definition: cover_goals.h:58
goalst::size_type size() const
Definition: cover_goals.h:68
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
decision_proceduret & decision_procedure
Definition: cover_goals.h:98
goalst goals
Definition: cover_goals.h:54
virtual exprt get(const exprt &) const =0
Return expr with variables replaced by values from satisfying assignment if available.
resultt
Result of running the decision procedure.
void set_to_true(const exprt &)
For a Boolean expression expr, add the constraint 'expr'.
std::vector< exprt > operandst
Definition: expr.h:58
bool is_true() const
Return whether the expression is a constant representing true.
Definition: expr.cpp:27
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
static eomt eom
Definition: message.h:297
Cover a set of goals incrementally.
double log(double x)
Definition: math.c:2776
exprt disjunction(const exprt::operandst &op)
1) generates a disjunction for two or more operands 2) for one operand, returns the operand 3) return...
Definition: std_expr.cpp:54
API to expression classes.