CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cover_goals.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Cover a set of goals incrementally
4
5Author: 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
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 {
35
36 // notify observers
37 for(const auto &o : observers)
38 o->goal_covered(g);
39 }
40}
41
44{
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
59operator()(message_handlert &message_handler)
60{
62
64
65 do
66 {
67 // We want (at least) one of the remaining goals, please!
69
70 constraint();
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 }
93
95}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
observerst observers
virtual ~cover_goalst()
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.
void constraint()
Build clause.
void mark()
Mark goals that are covered.
decision_proceduret & decision_procedure
Definition cover_goals.h:98
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
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
static eomt eom
Definition message.h:289
Cover a set of goals incrementally.
double log(double x)
Definition math.c:2449
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:71
API to expression classes.