Skip to content

Commit 91f8fd8

Browse files
author
Daniel Kroening
committed
elaborate prop_convt::handle(expr)
This change adds three features: 1) Non-boolean expressions are returned verbatim. 2) Boolean expressions that are determined to be a constant (e.g., by means of constant folding) are returned as constants, to enable further optimisation by users. 3) Literals returned are frozen, to simplify incremental usage.
1 parent 21811fa commit 91f8fd8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/solvers/prop/prop_conv.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,30 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include "literal_expr.h"
1212

13+
#include <util/std_expr.h>
14+
1315
#include <algorithm>
1416

1517
exprt prop_convt::handle(const exprt &expr)
1618
{
17-
return literal_exprt(convert(expr));
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);
1837
}
1938

2039
/// determine whether a variable is in the final conflict

0 commit comments

Comments
 (0)