@@ -186,7 +186,7 @@ namespace euf {
186186
187187 for (unsigned i = qhead (); i < sz; ++i) {
188188 auto [f, p, d] = m_fmls[i]();
189- add_constraint (f, d);
189+ add_constraint (f, p, d);
190190 }
191191 m_should_propagate = true ;
192192 while (m_should_propagate && !should_stop ()) {
@@ -200,7 +200,7 @@ namespace euf {
200200 }
201201 }
202202
203- void completion::add_constraint (expr* f, expr_dependency* d) {
203+ void completion::add_constraint (expr* f, proof* pr, expr_dependency* d) {
204204 if (m_egraph.inconsistent ())
205205 return ;
206206 auto add_children = [&](enode* n) {
@@ -234,21 +234,21 @@ namespace euf {
234234 mk_enode (g);
235235 m_mam->add_pattern (q, p);
236236 }
237- if (!get_dependency (q)) {
238- m_q2dep.insert (q, d);
239- get_trail ().push (insert_obj_map (m_q2dep, q));
240- }
237+ auto pq = get_dependency (q);
238+ m_q2dep.insert (q, pq);
239+ get_trail ().push (insert_obj_map (m_q2dep, q));
241240 }
242- add_rule (f, d);
241+ add_rule (f, pr, d);
243242 }
244243 if (m_side_condition_solver)
245- m_side_condition_solver->add_constraint (f, d);
244+ m_side_condition_solver->add_constraint (f, pr, d);
246245 }
247246
248- lbool completion::eval_cond (expr* f, expr_dependency*& d) {
247+ lbool completion::eval_cond (expr* f, proof_ref& pr, expr_dependency*& d) {
249248 auto n = mk_enode (f);
250249 if (m.is_true (n->get_root ()->get_expr ())) {
251250 d = m.mk_join (d, explain_eq (n, n->get_root ()));
251+ // TODO update pr
252252 return l_true;
253253 }
254254 if (m.is_false (n->get_root ()->get_expr ()))
@@ -259,34 +259,39 @@ namespace euf {
259259 n = mk_enode (g);
260260 if (m.is_false (n->get_root ()->get_expr ())) {
261261 d = m.mk_join (d, explain_eq (n, n->get_root ()));
262+ // TODO update pr
262263 return l_true;
263264 }
264265 if (m.is_true (n->get_root ()->get_expr ()))
265266 return l_false;
266267 }
267268 if (m_side_condition_solver) {
268269 expr_dependency* sd = nullptr ;
269- if (m_side_condition_solver->is_true (f, sd)) {
270- add_constraint (f, sd);
270+ if (m_side_condition_solver->is_true (f, pr, sd)) {
271+ add_constraint (f, pr, sd);
271272 d = m.mk_join (d, sd);
272273 return l_true;
273274 }
274275 }
275276 return l_undef;
276277 }
277278
278- void completion::add_rule (expr* f, expr_dependency* d) {
279+ void completion::add_rule (expr* f, proof* pr, expr_dependency* d) {
279280 expr* x = nullptr , * y = nullptr ;
280281 if (!m.is_implies (f, x, y))
281282 return ;
282283 expr_ref_vector body (m);
284+ proof_ref pr_i (m), pr0 (m);
285+ proof_ref_vector prs (m);
283286 expr_ref head (y, m);
284287 body.push_back (x);
285288 flatten_and (body);
286289 unsigned j = 0 ;
287290 for (auto f : body) {
288- switch (eval_cond (f, d)) {
291+ switch (eval_cond (f, pr_i, d)) {
289292 case l_true:
293+ if (m.proofs_enabled ())
294+ prs.push_back (pr_i);
290295 break ;
291296 case l_false:
292297 return ;
@@ -296,13 +301,16 @@ namespace euf {
296301 }
297302 }
298303 body.shrink (j);
304+ if (m.proofs_enabled ()) {
305+ // TODO
306+ }
299307 if (body.empty ())
300- add_constraint (head, d);
308+ add_constraint (head, pr0, d);
301309 else {
302310 euf::enode_vector _body;
303311 for (auto * f : body)
304312 _body.push_back (m_egraph.find (f)->get_root ());
305- auto r = alloc (conditional_rule, _body, head, d);
313+ auto r = alloc (conditional_rule, _body, head, pr0, d);
306314 m_rules.push_back (r);
307315 get_trail ().push (new_obj_trail (r));
308316 get_trail ().push (push_back_vector (m_rules));
@@ -340,11 +348,13 @@ namespace euf {
340348 if (!r.m_active )
341349 return ;
342350 for (unsigned i = r.m_watch_index ; i < r.m_body .size (); ++i) {
343- auto * f = r.m_body .get (i);
344- switch (eval_cond (f->get_expr (), r.m_dep )) {
351+ auto * f = r.m_body .get (i);
352+ proof_ref pr (m);
353+ switch (eval_cond (f->get_expr (), pr, r.m_dep )) {
345354 case l_true:
346355 get_trail ().push (value_trail (r.m_watch_index ));
347356 ++r.m_watch_index ;
357+ // TODO accumulate proof in r?
348358 break ;
349359 case l_false:
350360 get_trail ().push (value_trail (r.m_active ));
@@ -356,7 +366,7 @@ namespace euf {
356366 }
357367 }
358368 if (r.m_body .empty ()) {
359- add_constraint (r.m_head , r.m_dep );
369+ add_constraint (r.m_head , r.m_proof , r. m_dep );
360370 get_trail ().push (value_trail (r.m_active ));
361371 r.m_active = false ;
362372 }
@@ -375,9 +385,10 @@ namespace euf {
375385 }
376386 expr_ref r = subst (q->get_expr (), _binding);
377387 IF_VERBOSE (12 , verbose_stream () << " add " << r << " \n " );
378-
388+ IF_VERBOSE ( 1 , verbose_stream () << max_generation << " \n " );
379389 scoped_generation sg (*this , max_generation + 1 );
380- add_constraint (r, get_dependency (q));
390+ auto [pr, d] = get_dependency (q);
391+ add_constraint (r, pr, d);
381392 propagate_rules ();
382393 m_should_propagate = true ;
383394 ++m_stats.m_num_instances ;
0 commit comments