algebraic reals: does z3 do rounding when pretty printing?

谁说胖子不能爱 提交于 2019-12-11 08:16:24

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!