Skip to content

Commit 22e71cd

Browse files
author
Daniel Kroening
committed
use new handle interface in cover_goals
The literal-based interface is more specific, and cover_goals doesn't require anything beyond what decision_proceduret offers.
1 parent 23d2409 commit 22e71cd

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

jbmc/src/jbmc/all_properties.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()()
105105
{
106106
// Our goal is to falsify a property, i.e., we will
107107
// add the negation of the property as goal.
108-
literalt p = !solver.convert(g.second.as_expr());
109-
cover_goals.add(p);
108+
cover_goals.add(not_exprt(g.second.as_expr()));
110109
}
111110

112111
status() << "Running " << solver.decision_procedure_text() << eom;

src/solvers/prop/cover_goals.cpp

+4-15
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ void cover_goalst::mark()
2929
o->satisfying_assignment();
3030

3131
for(auto &g : goals)
32-
if(g.status==goalt::statust::UNKNOWN &&
33-
prop_conv.l_get(g.condition).is_true())
32+
if(
33+
g.status == goalt::statust::UNKNOWN &&
34+
prop_conv.get(g.condition).is_true())
3435
{
3536
g.status=goalt::statust::COVERED;
3637
_number_covered++;
@@ -50,20 +51,12 @@ void cover_goalst::constraint()
5051

5152
for(const auto &g : goals)
5253
if(g.status == goalt::statust::UNKNOWN && !g.condition.is_false())
53-
disjuncts.push_back(literal_exprt(g.condition));
54+
disjuncts.push_back(g.condition);
5455

5556
// this is 'false' if there are no disjuncts
5657
prop_conv.set_to_true(disjunction(disjuncts));
5758
}
5859

59-
/// Build clause
60-
void cover_goalst::freeze_goal_variables()
61-
{
62-
for(const auto &g : goals)
63-
if(!g.condition.is_constant())
64-
prop_conv.set_frozen(g.condition);
65-
}
66-
6760
/// Try to cover all goals
6861
decision_proceduret::resultt cover_goalst::
6962
operator()(message_handlert &message_handler)
@@ -72,10 +65,6 @@ operator()(message_handlert &message_handler)
7265

7366
decision_proceduret::resultt dec_result;
7467

75-
// We use incremental solving, so need to freeze some variables
76-
// to prevent them from being eliminated.
77-
freeze_goal_variables();
78-
7968
do
8069
{
8170
// We want (at least) one of the remaining goals, please!

src/solvers/prop/cover_goals.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Author: Daniel Kroening, [email protected]
1515
#include <list>
1616

1717
#include "decision_procedure.h"
18-
#include "literal.h"
18+
19+
#include <util/expr.h>
1920

2021
class message_handlert;
2122
class prop_convt;
@@ -41,10 +42,11 @@ class cover_goalst
4142

4243
struct goalt
4344
{
44-
literalt condition;
45+
exprt condition;
4546
enum class statust { UNKNOWN, COVERED, UNCOVERED, ERROR } status;
4647

47-
goalt():status(statust::UNKNOWN)
48+
explicit goalt(exprt _condition)
49+
: condition(std::move(_condition)), status(statust::UNKNOWN)
4850
{
4951
}
5052
};
@@ -71,10 +73,9 @@ class cover_goalst
7173

7274
// managing the goals
7375

74-
void add(const literalt condition)
76+
void add(exprt condition)
7577
{
76-
goals.push_back(goalt());
77-
goals.back().condition=condition;
78+
goals.emplace_back(std::move(condition));
7879
}
7980

8081
// register an observer if you want to be told
@@ -103,7 +104,6 @@ class cover_goalst
103104
private:
104105
void mark();
105106
void constraint();
106-
void freeze_goal_variables();
107107
};
108108

109109
#endif // CPROVER_SOLVERS_PROP_COVER_GOALS_H

0 commit comments

Comments
 (0)