@@ -690,84 +690,36 @@ br_status bool_rewriter::try_ite_value(app * ite, app * val, expr_ref & result)
690
690
return BR_FAILED;
691
691
}
692
692
693
+ // check that all leaves are disjoint.
693
694
expr_ref bool_rewriter::simplify_eq_ite (expr* value, expr* ite) {
694
695
SASSERT (m ().is_value (value));
695
696
SASSERT (m ().is_ite (ite));
696
697
expr* c = nullptr , * t = nullptr , * e = nullptr ;
697
- expr_ref r (m ());
698
698
auto & todo = m_todo1;
699
699
todo.reset ();
700
- auto & values = m_values;
701
- auto & pinned = m_pinned;
702
- auto & indices = m_indices;
703
- expr* result = nullptr ;
704
- SASSERT (indices.empty ());
705
-
706
700
todo.push_back (ite);
701
+ bool is_disjoint = true ;
707
702
while (!todo.empty ()) {
708
703
expr* arg = todo.back ();
709
- unsigned id = arg->get_id ();
710
- if (m ().is_value (arg)) {
711
- if (m ().are_equal (arg, value)) {
712
- todo.pop_back ();
713
- values.setx (id, m ().mk_true (), nullptr );
714
- indices.push_back (id);
715
- continue ;
716
- }
717
- if (m ().are_distinct (arg, value)) {
718
- todo.pop_back ();
719
- values.setx (id, m ().mk_false (), nullptr );
720
- indices.push_back (id);
721
- continue ;
722
- }
723
- goto bail;
724
- }
704
+ todo.pop_back ();
705
+ if (m_marked.is_marked (arg))
706
+ continue ;
707
+ m_marked.mark (arg, true );
708
+ if (m ().is_value (arg) && m ().are_distinct (arg, value))
709
+ continue ;
725
710
if (m ().is_ite (arg, c, t, e)) {
726
- unsigned sz = todo.size ();
727
- auto th = values.get (t->get_id (), nullptr );
728
- auto el = values.get (e->get_id (), nullptr );
729
- if (!th)
730
- todo.push_back (t);
731
- if (!el)
732
- todo.push_back (e);
733
- if (sz < todo.size ())
734
- continue ;
735
-
736
- if (m ().is_false (th) && m ().is_false (el))
737
- r = m ().mk_false ();
738
- else if (m ().is_true (th) && m ().is_true (el))
739
- r = m ().mk_true ();
740
- else if (m ().is_true (th) && m ().is_false (el))
741
- r = c;
742
- else if (m ().is_false (th) && m ().is_true (el))
743
- r = m ().mk_not (c);
744
- else if (m ().is_true (th))
745
- r = m ().mk_or (c, el);
746
- else if (m ().is_false (th))
747
- r = m ().mk_and (m ().mk_not (c), el);
748
- else if (m ().is_false (el))
749
- r = m ().mk_and (c, th);
750
- else if (m ().is_true (el))
751
- r = m ().mk_or (m ().mk_not (c), th);
752
- else
753
- r = m ().mk_ite (c, th, el);
754
-
755
- todo.pop_back ();
756
- values.setx (id, r, nullptr );
757
- indices.push_back (id);
758
- pinned.push_back (r);
711
+ if (!m_marked.is_marked (t))
712
+ todo.push_back (t);
713
+ if (!m_marked.is_marked (e))
714
+ todo.push_back (e);
759
715
continue ;
760
716
}
761
- IF_VERBOSE ( 10 , verbose_stream () << " bail " << mk_bounded_pp (arg, m ()) << " \n " ) ;
762
- goto bail ;
717
+ is_disjoint = false ;
718
+ break ;
763
719
}
764
- bail:
765
- if (todo.empty ())
766
- result = values[ite->get_id ()];
767
- for (auto idx : indices)
768
- values[idx] = nullptr ;
769
- indices.reset ();
770
- return expr_ref (result, m ());
720
+ m_marked.reset ();
721
+ todo.reset ();
722
+ return expr_ref (is_disjoint ? m ().mk_false () : nullptr , m ());
771
723
}
772
724
773
725
0 commit comments