File tree 2 files changed +39
-2
lines changed
2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -854,6 +854,34 @@ decision_proceduret::resultt string_refinementt::dec_solve()
854
854
return resultt::D_ERROR;
855
855
}
856
856
857
+ static exprt simplify_if_recursive (exprt expr, const namespacet &ns)
858
+ {
859
+ for (auto it = expr.depth_begin (); it != expr.depth_end (); )
860
+ {
861
+ if (it->id () == ID_if)
862
+ {
863
+ if_exprt if_expr = to_if_expr (*it);
864
+ const exprt simp_cond = simplify_expr (if_expr.cond (), ns);
865
+ if (simp_cond.is_true ())
866
+ {
867
+ it.mutate () = simplify_if_recursive (if_expr.true_case (), ns);
868
+ it.next_sibling_or_parent ();
869
+ }
870
+ else if (simp_cond.is_false ())
871
+ {
872
+ it.mutate () = simplify_if_recursive (if_expr.false_case (), ns);
873
+ it.next_sibling_or_parent ();
874
+ }
875
+ else
876
+ ++it;
877
+ }
878
+ else
879
+ ++it;
880
+ }
881
+
882
+ return expr;
883
+ }
884
+
857
885
// / Add the given lemma to the solver.
858
886
// / \param lemma: a Boolean expression
859
887
// / \param simplify_lemma: whether the lemma should be simplified before being
@@ -869,7 +897,10 @@ void string_refinementt::add_lemma(
869
897
870
898
exprt simple_lemma = lemma;
871
899
if (simplify_lemma)
900
+ {
901
+ simple_lemma = simplify_if_recursive (std::move (simple_lemma), ns);
872
902
simplify (simple_lemma, ns);
903
+ }
873
904
874
905
if (simple_lemma.is_true ())
875
906
{
Original file line number Diff line number Diff line change 31
31
32
32
// #define DEBUGX
33
33
34
- #ifdef DEBUGX
34
+ // #ifdef DEBUGX
35
35
#include " format_expr.h"
36
36
#include < iostream>
37
- #endif
37
+ // #endif
38
38
39
39
#include " simplify_expr_class.h"
40
40
@@ -2542,6 +2542,12 @@ bool simplify_exprt::simplify_rec(exprt &expr)
2542
2542
2543
2543
if (!result)
2544
2544
{
2545
+ if (tmp.type () != expr.type ())
2546
+ {
2547
+ std::cerr << format (tmp) << std::endl;
2548
+ std::cerr << format (expr) << std::endl;
2549
+ std::cerr << expr.type ().pretty () << std::endl;
2550
+ }
2545
2551
POSTCONDITION (tmp.type () == expr.type ());
2546
2552
expr.swap (tmp);
2547
2553
You can’t perform that action at this time.
0 commit comments