Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#10881·z3

False `unsat` for inexact symbolic Real-to-binary64 rounding

Author: mrzvCreated Sep 20, 2026Updated Sep 21, 2026

(The following is edited down from an AI bug report.)

Summary

On Linux x86-64, Z3 4.16.0 and 5.1.0 report unsat for the satisfiable first query below, which asks for a finite binary64 value obtained by rounding a real number inexactly. After reset, the second query checks a concrete witness and returns sat. The failure occurs without custom solver options.

Standalone reproduction

smt2
(set-logic ALL)
(declare-const x Real)
(declare-const rounded (_ FloatingPoint 11 53))
(declare-fun Finite ((_ FloatingPoint 11 53)) Bool)
(assert (forall ((f (_ FloatingPoint 11 53)))
  (! (= (Finite f) (and (not (fp.isNaN f)) (not (fp.isInfinite f))))
     :pattern ((Finite f)))))
(assert (Finite rounded))
(assert (fp.eq rounded ((_ to_fp 11 53) RNE x)))
(assert (distinct (fp.to_real rounded) x))
(check-sat)
(reset)
(set-logic ALL)
(define-fun x () Real (+ 1.0 (/ 1.0 18014398509481984.0)))
(define-fun rounded () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 1.0))
(assert (and (not (fp.isNaN rounded)) (not (fp.isInfinite rounded))))
(assert (fp.eq rounded ((_ to_fp 11 53) RNE x)))
(assert (distinct (fp.to_real rounded) x))
(check-sat)

The quantified Finite classifier preserves the relevant Dafny encoding. The second query removes that classifier and checks the concrete witness independently.

Environment and commands

Observed answers for both tested Z3 versions, in query order:

unsat
sat

For the comparison, observed CVC5 answers, in query order:

unknown
sat

Expected result and mathematical witness

Both queries are satisfiable; the expected answers from a solver deciding both queries are:

sat
sat

Satisfiability follows from the following witness and binary64 rounding arithmetic, independently of the CVC5 result:

  • Let x = 1 + 2^-54 = 1 + 1/18014398509481984 as an exact real, and let rounded be binary64 1.
  • The next binary64 number above 1 is 1 + 2^-52. Their midpoint is 1 + 2^-53.
  • Thus 1 < x < 1 + 2^-53. Its distance to 1 is 2^-54, while its distance to 1 + 2^-52 is 3 * 2^-54. It is strictly nearer 1; there is no tie. RNE therefore rounds x to binary64 1.
  • This rounded value is neither NaN nor infinite, and fp.to_real(rounded) = 1 != x.
  • Interpret Finite(f) as exactly not fp.isNaN(f) and not fp.isInfinite(f) for every floating-point value. This satisfies the universal classifier and Finite(rounded).

This interpretation satisfies every assertion in the first query. The second query encodes the same numerical witness explicitly.

Source evidence and related work

In the tagged Z3 4.16.0 fpa2bv_converter.cpp, lines 2780–2800, the non-numeral real-input branch of fpa2bv_converter::mk_to_fp_real calls round(...) and then adds:

cpp
expr * e = m.mk_eq(m_util.mk_to_real(result), x);
m_extra_assertions.push_back(e);

Suspected mechanism, not a traced execution claim: this equality imposes exact real round-trip behavior on a symbolic conversion. If applied to the finite conversion in this reproduction, it excludes the inexact rounding witness above and is consistent with the false unsat.

Related PR #9966, “Fix unsound symbolic to_fp-from-Real encoding causing false unsat in Float32 FP/Real round-trip constraints,” discusses the same exact-round-trip constraint for symbolic real conversion.

Source: Z3Prover/z3

View original on GitHubView discussion on GitHub