False `unsat` for inexact symbolic Real-to-binary64 rounding
(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
(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
satFor the comparison, observed CVC5 answers, in query order:
unknown
satExpected result and mathematical witness
Both queries are satisfiable; the expected answers from a solver deciding both queries are:
sat
satSatisfiability follows from the following witness and binary64 rounding arithmetic, independently of the CVC5 result:
- Let
x = 1 + 2^-54 = 1 + 1/18014398509481984as an exact real, and letroundedbe binary641. - The next binary64 number above
1is1 + 2^-52. Their midpoint is1 + 2^-53. - Thus
1 < x < 1 + 2^-53. Its distance to1is2^-54, while its distance to1 + 2^-52is3 * 2^-54. It is strictly nearer1; there is no tie. RNE therefore roundsxto binary641. - This
roundedvalue is neither NaN nor infinite, andfp.to_real(rounded) = 1 != x. - Interpret
Finite(f)as exactlynot fp.isNaN(f) and not fp.isInfinite(f)for every floating-point value. This satisfies the universal classifier andFinite(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:
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