z3 - Converting different widths of floating-point numbers -


i want compare 2 different widths of floating-point numbers giving assert z3. example, want compare between ieee 32-bit , ieee 64-bit floating-point number.

my try shown follows:

(set-logic qf_fpa) (set-option :produce-models true) (declare-fun x_64 () (_ fp 11 53)) (declare-fun x_32 () (_ fp 8 24)) (assert (== ((_ asfloat 11 53) roundnearesttiestoeven x_64 ) x_64)) (check-sat) 

but got error message:

(error "line 5 column 59: sort mismatch")

what correct way compare 32-bit , 64-bit number?

the z3 version using 4.3.1 (linux version).

in general, these conversions non-trivial, e.g., when converting 64-bit down 32-bit precision may lost. why conversion functions take rounding mode. smt standard floating-point numbers contain conversion functions of following type:

; floating point sort ((_ to_fp eb sb) roundingmode (_ floatingpoint m n) (_ floatingpoint eb sb)) 

so, correct way convert between floating-point numbers use to_fp function. [previously, asfloat function served purpose well; don't error using latest unstable version of z3 when using it.] full example this:

(set-logic qf_fpa) (set-option :produce-models true) (declare-fun x_64 () (_ fp 11 53)) (declare-fun x_32 () (_ fp 8 24)) (assert (== ((_ to_fp 11 53) roundnearesttiestoeven x_32) x_64)) (check-sat) 

which z3 (latest unstable) accepts without errors , solves instantly. alternatively, think of casting x_64 down 32 bit, in case assertion this:

(assert (== ((_ to_fp 8 24) roundnearesttiestoeven x_64) x_32)) 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -