File tree Expand file tree Collapse file tree 8 files changed +12
-77
lines changed
Expand file tree Collapse file tree 8 files changed +12
-77
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ literalt bv_utilst::is_one(const bvt &bv)
2828 return prop.land (is_zero (tmp), bv[0 ]);
2929}
3030
31+ void bv_utilst::set_equal (const bvt &a, const bvt &b)
32+ {
33+ PRECONDITION (a.size () == b.size ());
34+ for (std::size_t i=0 ; i<a.size (); i++)
35+ prop.set_equal (a[i], b[i]);
36+ }
37+
3138bvt bv_utilst::extract (const bvt &a, std::size_t first, std::size_t last)
3239{
3340 // preconditions
Original file line number Diff line number Diff line change @@ -196,6 +196,8 @@ class bv_utilst
196196 return result;
197197 }
198198
199+ void set_equal (const bvt &a, const bvt &b);
200+
199201 // if cond holds, a has to be equal to b
200202 void cond_implies_equal (literalt cond, const bvt &a, const bvt &b);
201203
Original file line number Diff line number Diff line change @@ -124,12 +124,6 @@ void equalityt::add_equality_constraints(const typestructt &typestruct)
124124 const bvt &bv1=eq_bvs[it->first .first ];
125125 const bvt &bv2=eq_bvs[it->first .second ];
126126
127- bvt equal_bv;
128- equal_bv.resize (bv1.size ());
129-
130- for (std::size_t i = 0 ; i < bv1.size (); i++)
131- equal_bv[i] = prop.lequal (bv1[i], bv2[i]);
132-
133- prop.gate_bv_and (equal_bv, it->second );
127+ prop.set_equal (bv_utils.equal (bv1, bv2), it->second );
134128 }
135129}
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ class propt
3232 virtual literalt land (literalt a, literalt b)=0;
3333 virtual literalt lor (literalt a, literalt b)=0;
3434 virtual literalt land (const bvt &bv)=0;
35- virtual void gate_bv_and (const bvt &bv, literalt output) = 0;
3635 virtual literalt lor (const bvt &bv)=0;
3736 virtual literalt lxor (literalt a, literalt b)=0;
3837 virtual literalt lxor (const bvt &bv)=0;
Original file line number Diff line number Diff line change @@ -270,8 +270,7 @@ void bv_refinementt::check_SAT(approximationt &a)
270270 UNREACHABLE;
271271
272272 CHECK_RETURN (r.size ()==res.size ());
273- for (std::size_t i = 0 ; i < r.size (); i++)
274- prop.set_equal (r[i], res[i]);
273+ bv_utils.set_equal (r, res);
275274 }
276275 }
277276 else if (type.id ()==ID_signedbv ||
@@ -339,9 +338,7 @@ void bv_refinementt::check_SAT(approximationt &a)
339338 else
340339 UNREACHABLE;
341340
342- CHECK_RETURN (r.size () == a.result_bv .size ());
343- for (std::size_t i = 0 ; i < r.size (); i++)
344- prop.set_equal (r[i], a.result_bv [i]);
341+ bv_utils.set_equal (r, a.result_bv );
345342 }
346343 else
347344 UNREACHABLE;
Original file line number Diff line number Diff line change @@ -196,64 +196,6 @@ literalt cnft::land(const bvt &bv)
196196 return literal;
197197}
198198
199- // / Tseitin encoding of conjunction between multiple literals
200- // / \param bv: Any number of inputs to the AND gate
201- // / \param output: Output signal of the circuit
202- void cnft::gate_bv_and (const bvt &bv, literalt output)
203- {
204- if (bv.empty ())
205- {
206- lcnf ({output});
207- return ;
208- }
209- if (bv.size () == 1 )
210- {
211- lcnf (bv[0 ], !output);
212- lcnf (!bv[0 ], output);
213- return ;
214- }
215- if (bv.size () == 2 )
216- {
217- gate_and (bv[0 ], bv[1 ], output);
218- return ;
219- }
220-
221- for (const auto &l : bv)
222- {
223- if (l.is_false ())
224- {
225- lcnf ({!output});
226- return ;
227- }
228- }
229-
230- if (is_all (bv, const_literal (true )))
231- {
232- lcnf ({output});
233- return ;
234- }
235-
236- bvt new_bv = eliminate_duplicates (bv);
237-
238- bvt lits (2 );
239- lits[1 ] = neg (output);
240-
241- for (const auto &l : new_bv)
242- {
243- lits[0 ] = pos (l);
244- lcnf (lits);
245- }
246-
247- lits.clear ();
248- lits.reserve (new_bv.size () + 1 );
249-
250- for (const auto &l : new_bv)
251- lits.push_back (neg (l));
252-
253- lits.push_back (pos (output));
254- lcnf (lits);
255- }
256-
257199// / Tseitin encoding of disjunction between multiple literals
258200// / \par parameters: Any number of inputs to the OR gate
259201// / \return Output signal of the OR gate as literal
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ class cnft:public propt
2828 virtual literalt land (literalt a, literalt b) override ;
2929 virtual literalt lor (literalt a, literalt b) override ;
3030 virtual literalt land (const bvt &bv) override ;
31- void gate_bv_and (const bvt &bv, literalt output) override ;
3231 virtual literalt lor (const bvt &bv) override ;
3332 virtual literalt lxor (const bvt &bv) override ;
3433 virtual literalt lxor (literalt a, literalt b) override ;
Original file line number Diff line number Diff line change @@ -82,11 +82,6 @@ class bdd_propt : public propt
8282 return to_literal (result);
8383 }
8484
85- void gate_bv_and (const bvt &bv, literalt output) override
86- {
87- UNREACHABLE;
88- }
89-
9085 literalt lor (const bvt &bv) override
9186 {
9287 mini_bddt result = mgr.False ();
You can’t perform that action at this time.
0 commit comments