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)
28
28
return prop.land (is_zero (tmp), bv[0 ]);
29
29
}
30
30
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
+
31
38
bvt bv_utilst::extract (const bvt &a, std::size_t first, std::size_t last)
32
39
{
33
40
// preconditions
Original file line number Diff line number Diff line change @@ -196,6 +196,8 @@ class bv_utilst
196
196
return result;
197
197
}
198
198
199
+ void set_equal (const bvt &a, const bvt &b);
200
+
199
201
// if cond holds, a has to be equal to b
200
202
void cond_implies_equal (literalt cond, const bvt &a, const bvt &b);
201
203
Original file line number Diff line number Diff line change @@ -124,12 +124,6 @@ void equalityt::add_equality_constraints(const typestructt &typestruct)
124
124
const bvt &bv1=eq_bvs[it->first .first ];
125
125
const bvt &bv2=eq_bvs[it->first .second ];
126
126
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 );
134
128
}
135
129
}
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ class propt
32
32
virtual literalt land (literalt a, literalt b)=0;
33
33
virtual literalt lor (literalt a, literalt b)=0;
34
34
virtual literalt land (const bvt &bv)=0;
35
- virtual void gate_bv_and (const bvt &bv, literalt output) = 0;
36
35
virtual literalt lor (const bvt &bv)=0;
37
36
virtual literalt lxor (literalt a, literalt b)=0;
38
37
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)
270
270
UNREACHABLE;
271
271
272
272
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);
275
274
}
276
275
}
277
276
else if (type.id ()==ID_signedbv ||
@@ -339,9 +338,7 @@ void bv_refinementt::check_SAT(approximationt &a)
339
338
else
340
339
UNREACHABLE;
341
340
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 );
345
342
}
346
343
else
347
344
UNREACHABLE;
Original file line number Diff line number Diff line change @@ -196,64 +196,6 @@ literalt cnft::land(const bvt &bv)
196
196
return literal;
197
197
}
198
198
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
-
257
199
// / Tseitin encoding of disjunction between multiple literals
258
200
// / \par parameters: Any number of inputs to the OR gate
259
201
// / \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
28
28
virtual literalt land (literalt a, literalt b) override ;
29
29
virtual literalt lor (literalt a, literalt b) override ;
30
30
virtual literalt land (const bvt &bv) override ;
31
- void gate_bv_and (const bvt &bv, literalt output) override ;
32
31
virtual literalt lor (const bvt &bv) override ;
33
32
virtual literalt lxor (const bvt &bv) override ;
34
33
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
82
82
return to_literal (result);
83
83
}
84
84
85
- void gate_bv_and (const bvt &bv, literalt output) override
86
- {
87
- UNREACHABLE;
88
- }
89
-
90
85
literalt lor (const bvt &bv) override
91
86
{
92
87
mini_bddt result = mgr.False ();
You can’t perform that action at this time.
0 commit comments