@@ -51,10 +51,6 @@ Delayed solver invocation
5151Mam optimization?
5252 match(p, t, S) = suppose all variables in p are bound in S, check equality using canonization of p[S], otherwise prune instances from S.
5353
54-
55-
56-
57-
5854--*/
5955
6056#include " ast/ast_pp.h"
@@ -94,13 +90,6 @@ namespace euf {
9490 }
9591
9692 completion::~completion () {
97- reset_rules ();
98- }
99-
100- void completion::reset_rules () {
101- for (auto r : m_rules)
102- dealloc (r);
103- m_rules.reset ();
10493 }
10594
10695 void completion::reduce () {
@@ -113,7 +102,6 @@ namespace euf {
113102 read_egraph ();
114103 IF_VERBOSE (11 , verbose_stream () << " (euf.completion :rounds " << rounds << " )\n " );
115104 }
116- reset_rules ();
117105 }
118106
119107 void completion::add_egraph () {
@@ -229,45 +217,44 @@ namespace euf {
229217 }
230218 }
231219 body.shrink (j);
232- if (body.empty ()) {
233- add_constraint (head, d);
234- return ;
220+ if (body.empty ())
221+ add_constraint (head, d);
222+ else {
223+ m_rules.push_back (alloc (ground_rule, body, head, d));
224+ get_trail ().push (push_back_vector (m_rules));
235225 }
236- m_rules.push_back (alloc (ground_rule, body, head, d));
237226 }
238227
239228 void completion::check_rules () {
240- unsigned j = 0 ;
241229 for (auto & r : m_rules) {
230+ if (!r->m_active )
231+ continue ;
242232 switch (check_rule (*r)) {
243233 case l_true:
244- dealloc (r);
234+ get_trail ().push (value_trail (r->m_active ));
235+ r->m_active = false ;
245236 break ; // remove rule, it is activated
246237 case l_false:
247- dealloc (r);
238+ get_trail ().push (value_trail (r->m_active ));
239+ r->m_active = false ;
248240 break ; // remove rule, premise is false
249241 case l_undef:
250- m_rules[j++] = r;
251242 break ;
252243 }
253244 }
254- m_rules.shrink (j);
255245 }
256246
257247 lbool completion::check_rule (ground_rule& r) {
258- unsigned j = 0 ;
259248 for (auto * f : r.m_body ) {
260249 switch (eval_cond (f, r.m_dep )) {
261250 case l_true:
262251 break ;
263252 case l_false:
264253 return l_false;
265254 default :
266- r.m_body [j++] = f;
267255 break ;
268256 }
269257 }
270- r.m_body .shrink (j);
271258 if (r.m_body .empty ()) {
272259 add_constraint (r.m_head , r.m_dep );
273260 return l_true;
@@ -650,6 +637,4 @@ namespace euf {
650637 }
651638 }
652639
653- }
654-
655-
640+ }
0 commit comments