#10931·z3

Unsound unsat: to_fp from a symbolic Real loses the rounding carry into the next binade (6-line repro)

Author: headintheboxCreated Sep 27, 2026Updated Sep 27, 2026

Summary

to_fp from a symbolic Real (or Int via to_real) loses a rounding carry into the next binade, and z3 answers unsat on a satisfiable query. z3 5.1.0, default configuration.

Repro (6 lines)

smt2
(set-logic ALL)
(declare-fun r () Real)
(declare-fun c () (_ FloatingPoint 8 24))
(assert (< r 2.0))
(assert (= c ((_ to_fp 8 24) roundNearestTiesToEven r)))
(assert (= c (fp #b0 #x80 #b00000000000000000000000)))   ; c == 2.0
(check-sat)

This is SAT: any r in [2 - 2^-24, 2) rounds to 2.0 under RNE (e.g. r = 1.99999998). z3 returns unsat.

variant z3 5.1.0 expected
the file above unsat sat
+ (assert (= r 1.99999998)) sat (c = 2.0) sat
+ (assert (>= r 1.99999997)) (forces rounding up) unsat sat
Int form: v < 2^25, c = to_fp(RNE, to_real v), c == 2^25 unsat sat (v = 2^25 - 1)

So z3 contradicts itself: the pinned instance is sat, the unpinned one unsat.

Sweep over the binade edge (v < 2^k, c = to_fp(RNE, to_real v), c > pred(2^k); truth is unsat for k <= 24 and **sat** for k >= 25): with the extra true fact c <= 2^k, z3 returns unsat for k in {25, 26, 28, 31, 40}, under smt.arith.solver=2, 6, and in incremental mode. Without it the symbolic instances time out.

The bit-vector conversion ((_ to_fp 8 24) roundNearestTiesToEven ((_ int2bv 64) v)) (with 0 <= v) is correct on every instance, as is FP->FP conversion (f64 -> f32) at the same edge.

Suspected site

The real->fp rounding encoding appears to compute the result exponent from the unrounded value and not re-normalise when the significand rounds up to 2.0 (the carry into the next binade).

cvc5 1.3.4 answers unsat on the same file as well; reported there separately.