Skip to content

Commit 9557087

Browse files
Merge pull request #4577 from peterschrammel/do-not-expose-set-frozen
Do not expose set frozen [depends: 4573]
2 parents e37ef07 + 13f5f0c commit 9557087

File tree

10 files changed

+66
-73
lines changed

10 files changed

+66
-73
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ std::chrono::duration<double> prepare_property_decider(
365365
property_decider.update_properties_goals_from_symex_target_equation(
366366
properties);
367367
property_decider.convert_goals();
368-
property_decider.freeze_goal_variables();
369368

370369
auto solver_stop = std::chrono::steady_clock::now();
371370
return std::chrono::duration<double>(solver_stop - solver_start);

src/goto-checker/goto_symex_property_decider.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,7 @@ void goto_symex_property_decidert::convert_goals()
7474
// Our goal is to falsify a property, i.e., we will
7575
// add the negation of the property as goal.
7676
goal_pair.second.condition =
77-
!solver->prop_conv().convert(goal_pair.second.as_expr());
78-
}
79-
}
80-
81-
void goto_symex_property_decidert::freeze_goal_variables()
82-
{
83-
for(const auto &goal_pair : goal_map)
84-
{
85-
if(!goal_pair.second.condition.is_constant())
86-
solver->prop_conv().set_frozen(goal_pair.second.condition);
77+
solver->prop_conv().handle(not_exprt(goal_pair.second.as_expr()));
8778
}
8879
}
8980

@@ -98,7 +89,7 @@ void goto_symex_property_decidert::add_constraint_from_goals(
9889
select_property(goal_pair.first) &&
9990
!goal_pair.second.condition.is_false())
10091
{
101-
disjuncts.push_back(literal_exprt(goal_pair.second.condition));
92+
disjuncts.push_back(goal_pair.second.condition);
10293
}
10394
}
10495

@@ -134,7 +125,7 @@ void goto_symex_property_decidert::update_properties_status_from_goals(
134125
{
135126
auto &status = properties.at(goal_pair.first).status;
136127
if(
137-
solver->prop_conv().l_get(goal_pair.second.condition).is_true() &&
128+
solver->prop_conv().get(goal_pair.second.condition).is_true() &&
138129
status != property_statust::FAIL)
139130
{
140131
status |= property_statust::FAIL;

src/goto-checker/goto_symex_property_decider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class goto_symex_property_decidert
7979
std::vector<symex_target_equationt::SSA_stepst::iterator> instances;
8080

8181
/// The goal variable
82-
literalt condition;
82+
exprt condition;
8383

8484
exprt as_expr() const;
8585
};

src/solvers/decision_procedure.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ class decision_proceduret
3030
/// For a Boolean expression \p expr, add the constraint 'not expr'
3131
void set_to_false(const exprt &expr);
3232

33-
/// Generate a handle for an expression; this offers an efficient way
33+
/// Generate a handle, which is an expression that
34+
/// has the same value as the argument in any model
35+
/// that is generated; this offers an efficient way
3436
/// to refer to the expression in subsequent calls to \ref get or
35-
/// \ref set_to
37+
/// \ref set_to.
38+
/// The returned expression may be the expression itself or a more compact
39+
/// but solver-specific representation.
3640
virtual exprt handle(const exprt &expr) = 0;
3741

3842
/// Result of running the decision procedure

src/solvers/prop/prop_conv.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,7 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <algorithm>
1616

17-
exprt prop_convt::handle(const exprt &expr)
18-
{
19-
// We can only improve Booleans.
20-
if(expr.type().id() != ID_bool)
21-
return expr;
22-
23-
// We convert to a literal to obtain a 'small' handle
24-
literalt l = convert(expr);
25-
26-
// The literal may be a constant as a result of non-trivial
27-
// propagation. We return constants as such.
28-
if(l.is_true())
29-
return true_exprt();
30-
else if(l.is_false())
31-
return false_exprt();
32-
33-
// freeze to enable incremental use
34-
set_frozen(l);
35-
36-
return literal_exprt(l);
37-
}
38-
3917
void prop_convt::set_assumptions(const bvt &)
4018
{
4119
UNREACHABLE;
4220
}
43-
44-
void prop_convt::set_frozen(const literalt)
45-
{
46-
UNREACHABLE;
47-
}
48-
49-
void prop_convt::set_frozen(const bvt &bv)
50-
{
51-
for(const auto &bit : bv)
52-
if(!bit.is_constant())
53-
set_frozen(bit);
54-
}

src/solvers/prop/prop_conv.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ class prop_convt:public decision_proceduret
2626

2727
using decision_proceduret::operator();
2828

29-
/// returns a 'handle', which is an expression that
30-
/// has the same value as the argument in any model
31-
/// that is generated.
32-
/// This may be the expression itself or a more compact
33-
/// but solver-specific representation.
34-
exprt handle(const exprt &expr) override;
35-
3629
/// Convert a Boolean expression and return the corresponding literal
3730
virtual literalt convert(const exprt &expr) = 0;
3831

@@ -41,11 +34,8 @@ class prop_convt:public decision_proceduret
4134
virtual tvt l_get(literalt l) const = 0;
4235

4336
// incremental solving
44-
virtual void set_frozen(literalt a);
45-
virtual void set_frozen(const bvt &);
4637
virtual void set_assumptions(const bvt &_assumptions);
4738
virtual bool has_set_assumptions() const { return false; }
48-
virtual void set_all_frozen() {}
4939
};
5040

5141
#endif // CPROVER_SOLVERS_PROP_PROP_CONV_H

src/solvers/prop/prop_conv_solver.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,45 @@ bool prop_conv_solvert::is_in_conflict(const exprt &expr) const
1515
return prop.is_in_conflict(to_literal_expr(expr).get_literal());
1616
}
1717

18+
void prop_conv_solvert::set_frozen(const bvt &bv)
19+
{
20+
for(const auto &bit : bv)
21+
if(!bit.is_constant())
22+
set_frozen(bit);
23+
}
24+
25+
void prop_conv_solvert::set_frozen(literalt a)
26+
{
27+
prop.set_frozen(a);
28+
}
29+
30+
void prop_conv_solvert::set_all_frozen()
31+
{
32+
freeze_all = true;
33+
}
34+
35+
exprt prop_conv_solvert::handle(const exprt &expr)
36+
{
37+
// We can only improve Booleans.
38+
if(expr.type().id() != ID_bool)
39+
return expr;
40+
41+
// We convert to a literal to obtain a 'small' handle
42+
literalt l = convert(expr);
43+
44+
// The literal may be a constant as a result of non-trivial
45+
// propagation. We return constants as such.
46+
if(l.is_true())
47+
return true_exprt();
48+
else if(l.is_false())
49+
return false_exprt();
50+
51+
// freeze to enable incremental use
52+
set_frozen(l);
53+
54+
return literal_exprt(l);
55+
}
56+
1857
bool prop_conv_solvert::literal(const symbol_exprt &expr, literalt &dest) const
1958
{
2059
PRECONDITION(expr.type().id() == ID_bool);

src/solvers/prop/prop_conv_solver.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,10 @@ class prop_conv_solvert : public conflict_providert,
4646
}
4747
exprt get(const exprt &expr) const override;
4848

49-
// overloading from prop_convt
50-
using prop_convt::set_frozen;
5149
tvt l_get(literalt a) const override
5250
{
5351
return prop.l_get(a);
5452
}
55-
void set_frozen(literalt a) override
56-
{
57-
prop.set_frozen(a);
58-
}
5953
void set_assumptions(const bvt &_assumptions) override
6054
{
6155
prop.set_assumptions(_assumptions);
@@ -64,10 +58,13 @@ class prop_conv_solvert : public conflict_providert,
6458
{
6559
return prop.has_set_assumptions();
6660
}
67-
void set_all_frozen() override
68-
{
69-
freeze_all = true;
70-
}
61+
62+
exprt handle(const exprt &expr) override;
63+
64+
void set_frozen(literalt);
65+
void set_frozen(const bvt &);
66+
void set_all_frozen();
67+
7168
literalt convert(const exprt &expr) override;
7269
bool is_in_conflict(const exprt &expr) const override;
7370

src/solvers/smt2/smt2_conv.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,15 @@ literalt smt2_convt::convert(const exprt &expr)
661661
return l;
662662
}
663663

664+
exprt smt2_convt::handle(const exprt &expr)
665+
{
666+
// We can only improve Booleans.
667+
if(expr.type().id() != ID_bool)
668+
return expr;
669+
670+
return literal_exprt(convert(expr));
671+
}
672+
664673
void smt2_convt::convert_literal(const literalt l)
665674
{
666675
if(l==const_literal(false))

src/solvers/smt2/smt2_conv.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ class smt2_convt:public prop_convt
113113
bool use_array_of_bool;
114114
bool emit_set_logic;
115115

116+
exprt handle(const exprt &expr) override;
116117
literalt convert(const exprt &expr) override;
117-
void set_frozen(literalt) override
118-
{ /* not needed */
119-
}
120118
void set_to(const exprt &expr, bool value) override;
121119
exprt get(const exprt &expr) const override;
122120
std::string decision_procedure_text() const override

0 commit comments

Comments
 (0)