@@ -34,6 +34,7 @@ void bool_rewriter::updt_params(params_ref const & _p) {
34
34
m_blast_distinct = p.blast_distinct ();
35
35
m_blast_distinct_threshold = p.blast_distinct_threshold ();
36
36
m_ite_extra_rules = p.ite_extra_rules ();
37
+ m_elim_ite_value_tree = p.elim_ite_value_tree ();
37
38
}
38
39
39
40
void bool_rewriter::get_param_descrs (param_descrs & r) {
@@ -680,9 +681,84 @@ br_status bool_rewriter::try_ite_value(app * ite, app * val, expr_ref & result)
680
681
return BR_REWRITE2;
681
682
}
682
683
684
+ if (m_elim_ite_value_tree) {
685
+ result = simplify_eq_ite (val, ite);
686
+ if (result)
687
+ return BR_REWRITE_FULL;
688
+ }
689
+
683
690
return BR_FAILED;
684
691
}
685
692
693
+ expr_ref bool_rewriter::simplify_eq_ite (expr* value, expr* ite) {
694
+ SASSERT (m ().is_value (value));
695
+ SASSERT (m ().is_ite (ite));
696
+ expr* c = nullptr , * t = nullptr , * e = nullptr ;
697
+ ptr_buffer<expr> todo;
698
+ ptr_vector<expr> values;
699
+ expr_ref_vector pinned (m ());
700
+ expr_ref r (m ());
701
+ todo.push_back (ite);
702
+ while (!todo.empty ()) {
703
+ expr* arg = todo.back ();
704
+ if (m ().is_value (arg)) {
705
+ todo.pop_back ();
706
+ if (m ().are_equal (arg, value)) {
707
+ values.setx (arg->get_id (), m ().mk_true (), nullptr );
708
+ continue ;
709
+ }
710
+ if (m ().are_distinct (arg, value)) {
711
+ values.setx (arg->get_id (), m ().mk_false (), nullptr );
712
+ continue ;
713
+ }
714
+ return expr_ref (nullptr , m ());
715
+ }
716
+ if (m ().is_ite (arg, c, t, e)) {
717
+ unsigned sz = todo.size ();
718
+ if (!values.get (t->get_id (), nullptr ))
719
+ todo.push_back (t);
720
+
721
+ if (!values.get (e->get_id (), nullptr ))
722
+ todo.push_back (e);
723
+
724
+ if (sz < todo.size ())
725
+ continue ;
726
+ todo.pop_back ();
727
+ if (m ().is_true (values[t->get_id ()])) {
728
+ r = m ().mk_or (c, values[e->get_id ()]);
729
+ values.setx (arg->get_id (), r, nullptr );
730
+ pinned.push_back (r);
731
+ continue ;
732
+ }
733
+ if (m ().is_false (values[t->get_id ()])) {
734
+ r = m ().mk_and (m ().mk_not (c), values[e->get_id ()]);
735
+ values.setx (arg->get_id (), r, nullptr );
736
+ pinned.push_back (r);
737
+ continue ;
738
+ }
739
+ if (m ().is_false (values[e->get_id ()])) {
740
+ r = m ().mk_and (c, values[t->get_id ()]);
741
+ values.setx (arg->get_id (), r, nullptr );
742
+ pinned.push_back (r);
743
+ continue ;
744
+ }
745
+ if (m ().is_true (values[e->get_id ()])) {
746
+ r = m ().mk_or (m ().mk_not (c), values[t->get_id ()]);
747
+ values.setx (arg->get_id (), r, nullptr );
748
+ pinned.push_back (r);
749
+ continue ;
750
+ }
751
+ r = m ().mk_ite (c, values[t->get_id ()], values[e->get_id ()]);
752
+ values.setx (arg->get_id (), r, nullptr );
753
+ pinned.push_back (r);
754
+ continue ;
755
+ }
756
+ IF_VERBOSE (10 , verbose_stream () << " bail " << mk_bounded_pp (arg, m ()) << " \n " );
757
+ return expr_ref (nullptr , m ());
758
+ }
759
+ return expr_ref (values[ite->get_id ()], m ());
760
+ }
761
+
686
762
687
763
app* bool_rewriter::mk_eq_plain (expr* lhs, expr* rhs) {
688
764
if (m ().are_equal (lhs, rhs))
0 commit comments