@@ -48,7 +48,19 @@ void MyTracer::add_derived_clause(uint64_t id, bool /*red*/, const std::vector<i
4848
4949 const uint64_t id1 = rantec[0 ];
5050 auto aig = fs_clid[id1];
51+ release_assert (aig != nullptr );
5152 set<Lit> resolvent (cls[id1].begin (),cls[id1].end ());
53+ std::vector<aig_ptr> same_op_terms;
54+ bool same_op_is_and = false ;
55+ bool same_op_started = false ;
56+
57+ auto flush_terms = [&]() {
58+ if (!same_op_started) return ;
59+ aig = combine_balanced (std::move (same_op_terms), same_op_is_and);
60+ same_op_terms.clear ();
61+ same_op_started = false ;
62+ };
63+
5264 for (uint32_t i = 1 ; i < rantec.size (); i++) {
5365 if (conf.verb >= 4 ) {
5466 cout << " resolvent: " ; for (const auto & l: resolvent) cout << l << " " ; cout << endl;
@@ -70,9 +82,24 @@ void MyTracer::add_derived_clause(uint64_t id, bool /*red*/, const std::vector<i
7082 }
7183 assert (res_lit != lit_Undef);
7284 bool input_or_copy = input.count (res_lit.var ()) || res_lit.var () >= (uint32_t )orig_num_vars;
73- if (input_or_copy) aig = AIG::new_and (aig, fs_clid[id2]);
74- else aig = AIG::new_or (aig, fs_clid[id2]);
85+ auto rhs = fs_clid[id2];
86+ release_assert (rhs != nullptr );
87+ if (!same_op_started) {
88+ same_op_started = true ;
89+ same_op_is_and = input_or_copy;
90+ same_op_terms.push_back (aig);
91+ same_op_terms.push_back (rhs);
92+ } else if (same_op_is_and == input_or_copy) {
93+ same_op_terms.push_back (rhs);
94+ } else {
95+ flush_terms ();
96+ same_op_started = true ;
97+ same_op_is_and = input_or_copy;
98+ same_op_terms.push_back (aig);
99+ same_op_terms.push_back (rhs);
100+ }
75101 }
102+ flush_terms ();
76103 fs_clid[id] = aig;
77104 verb_print (5 , " intermediate formula: " << fs_clid[id]);
78105 if (clause.empty ()) {
@@ -179,8 +206,8 @@ void Interpolant::generate_interpolant(
179206 }
180207
181208 // CaDiCaL on the core only
182- auto cdcl = std::make_unique<Solver>();
183209 MyTracer t (orig_num_vars, input_vars, conf, lit_to_aig, cnf.get_aig_mng ());
210+ auto cdcl = std::make_unique<Solver>();
184211
185212 cdcl->connect_proof_tracer (&t, true );
186213 /* std::stringstream name; */
@@ -204,6 +231,7 @@ void Interpolant::generate_interpolant(
204231 }
205232 release_assert (pret == Status::UNSATISFIABLE);
206233 cdcl->disconnect_proof_tracer (&t);
234+ cdcl.reset ();
207235
208236 defs[test_var] = t.out ;
209237 verb_print (5 , " definition of var: " << test_var+1 << " is: " << t.out );
0 commit comments