mirror of
https://github.com/Z3Prover/z3
synced 2025-08-25 20:46:01 +00:00
Pseudo-inverse op_constraint
This commit is contained in:
parent
84a5ec221f
commit
79e7380ffc
10 changed files with 144 additions and 47 deletions
|
@ -154,7 +154,7 @@ bool rational::mult_inverse(unsigned num_bits, rational & result) const {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compute multiplicative pseudo-inverse modulo 2^num_bits:
|
||||
* Compute the smallest multiplicative pseudo-inverse modulo 2^num_bits:
|
||||
*
|
||||
* mod(n * n.pseudo_inverse(bits), 2^bits) == 2^k,
|
||||
* where k is maximal such that 2^k divides n.
|
||||
|
@ -167,7 +167,7 @@ rational rational::pseudo_inverse(unsigned num_bits) const {
|
|||
SASSERT(!n.is_zero()); // TODO: or we define pseudo-inverse of 0 as 0.
|
||||
unsigned const k = n.trailing_zeros();
|
||||
rational const odd = machine_div2k(n, k);
|
||||
VERIFY(odd.mult_inverse(num_bits, result));
|
||||
VERIFY(odd.mult_inverse(num_bits - k, result));
|
||||
SASSERT_EQ(mod(n * result, rational::power_of_two(num_bits)), rational::power_of_two(k));
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue