问题
If I issue:
(set-option :pp-decimal true)
(set-option :pp-decimal-precision 10)
Does Z3 do any rounding after the 10th digit of the real number? Or does it just chop the remaining digits without any rounding?
回答1:
In Z3 4.0, an algebraic number alpha
is represented using a univariate polynomial p
and two binary rationals: lower
and upper
. A binary rational is a rational number of the form a/2^k
where a
is an integer and k
a natural number. We have that alpha
is the only root of p
in the interval (lower, upper)
. When the options
(set-option :pp-decimal true)
(set-option :pp-decimal-precision N)
are provided. First, I squeeze/refine the interval (lower, upper)
until upper - lower < 1/10^N
. Then, I peek the upper bound (which is a binary rational) and display it in decimal by chopping after the Nth digit. To be more precise, the refinement is actually performed until upper - lower < 1/16^N
.
I realize this is not an ideal solution, but it is good enough for most purposes.
来源:https://stackoverflow.com/questions/10302680/algebraic-reals-does-z3-do-rounding-when-pretty-printing