Skip to content

Commit a951d96

Browse files
Move handle() from interface to implementation
The implementation should be in the implementation class.
1 parent e37ef07 commit a951d96

File tree

6 files changed

+35
-29
lines changed

6 files changed

+35
-29
lines changed

src/solvers/prop/prop_conv.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,6 @@ 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;

src/solvers/prop/prop_conv.h

Lines changed: 0 additions & 7 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

src/solvers/prop/prop_conv_solver.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ 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+
exprt prop_conv_solvert::handle(const exprt &expr)
19+
{
20+
// We can only improve Booleans.
21+
if(expr.type().id() != ID_bool)
22+
return expr;
23+
24+
// We convert to a literal to obtain a 'small' handle
25+
literalt l = convert(expr);
26+
27+
// The literal may be a constant as a result of non-trivial
28+
// propagation. We return constants as such.
29+
if(l.is_true())
30+
return true_exprt();
31+
else if(l.is_false())
32+
return false_exprt();
33+
34+
// freeze to enable incremental use
35+
set_frozen(l);
36+
37+
return literal_exprt(l);
38+
}
39+
1840
bool prop_conv_solvert::literal(const symbol_exprt &expr, literalt &dest) const
1941
{
2042
PRECONDITION(expr.type().id() == ID_bool);

src/solvers/prop/prop_conv_solver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class prop_conv_solvert : public conflict_providert,
6464
{
6565
return prop.has_set_assumptions();
6666
}
67+
68+
exprt handle(const exprt &expr) override;
69+
6770
void set_all_frozen() override
6871
{
6972
freeze_all = true;

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ 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;
117118
void set_frozen(literalt) override
118119
{ /* not needed */

0 commit comments

Comments
 (0)