mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
add binary_merge encoding option
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
c4ee4ffae4
commit
4c76d43670
6 changed files with 283 additions and 4 deletions
|
@ -161,7 +161,6 @@ struct pb2bv_rewriter::imp {
|
|||
}
|
||||
|
||||
if (m_pb_solver == "segmented") {
|
||||
expr_ref result(m);
|
||||
switch (is_le) {
|
||||
case l_true: return mk_seg_le(k);
|
||||
case l_false: return mk_seg_ge(k);
|
||||
|
@ -169,6 +168,11 @@ struct pb2bv_rewriter::imp {
|
|||
}
|
||||
}
|
||||
|
||||
if (m_pb_solver == "binary_merge") {
|
||||
expr_ref result = binary_merge(is_le, k);
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
// fall back to divide and conquer encoding.
|
||||
SASSERT(k.is_pos());
|
||||
expr_ref zero(m), bound(m);
|
||||
|
@ -494,6 +498,37 @@ struct pb2bv_rewriter::imp {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief binary merge encoding.
|
||||
*/
|
||||
expr_ref binary_merge(lbool is_le, rational const& k) {
|
||||
expr_ref result(m);
|
||||
unsigned_vector coeffs;
|
||||
for (rational const& c : m_coeffs) {
|
||||
if (c.is_unsigned()) {
|
||||
coeffs.push_back(c.get_unsigned());
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (!k.is_unsigned()) {
|
||||
return result;
|
||||
}
|
||||
switch (is_le) {
|
||||
case l_true:
|
||||
result = m_sort.le(k.get_unsigned(), coeffs.size(), coeffs.c_ptr(), m_args.c_ptr());
|
||||
break;
|
||||
case l_false:
|
||||
result = m_sort.ge(k.get_unsigned(), coeffs.size(), coeffs.c_ptr(), m_args.c_ptr());
|
||||
break;
|
||||
case l_undef:
|
||||
result = m_sort.eq(k.get_unsigned(), coeffs.size(), coeffs.c_ptr(), m_args.c_ptr());
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Segment based encoding.
|
||||
The PB terms are partitoned into segments, such that each segment contains arguments with the same cofficient.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue