what4-1.8: Solver-agnostic symbolic values support for issuing queries
Safe HaskellNone
LanguageHaskell2010

What4.SFloat

Description

Working with floats of dynamic sizes.

Synopsis

Interface

data SFloat sym where Source #

Symbolic floating point numbers.

Constructors

SFloat :: forall sym (fpp :: FloatPrecision). IsExpr (SymExpr sym) => SymFloat sym fpp -> SFloat sym 

fpReprOf :: forall sym (fpp :: FloatPrecision). IsExpr (SymExpr sym) => sym -> SymFloat sym fpp -> FloatPrecisionRepr fpp Source #

fpRepr Source #

Arguments

:: Integer

Exponent width

-> Integer

Precision width

-> Maybe (Some FloatPrecisionRepr) 

Construct the FloatPrecisionRepr with the given parameters.

fpIte :: IsExprBuilder sym => sym -> Pred sym -> SFloat sym -> SFloat sym -> IO (SFloat sym) Source #

Constants

fpFresh :: IsSymExprBuilder sym => sym -> Integer -> Integer -> IO (SFloat sym) Source #

A fresh variable of the given type (see freshConstant).

fpNaN Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> IO (SFloat sym) 

Not a number (see floatNaN).

fpPosZero Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> IO (SFloat sym) 

Positive zero (see floatPZero).

fpNegZero Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> IO (SFloat sym) 

Negative zero (see floatNZero).

fpPosInf Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> IO (SFloat sym) 

Positive infinity (see floatPInf).

fpNegInf Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> IO (SFloat sym) 

Negative infinity (see floatNInf).

fpFromLit Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> BigFloat 
-> IO (SFloat sym) 

A floating point number corresponding to the given BigFloat (see floatLit).

fpFromRationalLit Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> Rational 
-> IO (SFloat sym) 

A floating point number corresponding to the given rational (see floatLitRational).

Interchange formats

fpFromBinary Source #

Arguments

:: IsExprBuilder sym 
=> sym 
-> Integer

Exponent width

-> Integer

Precision width

-> SWord sym 
-> IO (SFloat sym) 

Make a floating point number with the given bit representation (see floatFromBinary).

fpToBinary :: IsExprBuilder sym => sym -> SFloat sym -> IO (SWord sym) Source #

Relations

type SFloatRel sym = sym -> SFloat sym -> SFloat sym -> IO (Pred sym) Source #

Arithmetic

type SFloatBinArith sym = sym -> RoundingMode -> SFloat sym -> SFloat sym -> IO (SFloat sym) Source #

fpNeg :: IsExprBuilder sym => sym -> SFloat sym -> IO (SFloat sym) Source #

fpAbs :: IsExprBuilder sym => sym -> SFloat sym -> IO (SFloat sym) Source #

fpSqrt :: IsExprBuilder sym => sym -> RoundingMode -> SFloat sym -> IO (SFloat sym) Source #

fpRem :: IsExprBuilder sym => sym -> SFloat sym -> SFloat sym -> IO (SFloat sym) Source #

fpMin :: IsExprBuilder sym => sym -> SFloat sym -> SFloat sym -> IO (SFloat sym) Source #

fpMax :: IsExprBuilder sym => sym -> SFloat sym -> SFloat sym -> IO (SFloat sym) Source #

fpFMA :: IsExprBuilder sym => sym -> RoundingMode -> SFloat sym -> SFloat sym -> SFloat sym -> IO (SFloat sym) Source #

See floatRMA.

Conversions

fpRound :: IsExprBuilder sym => sym -> RoundingMode -> SFloat sym -> IO (SFloat sym) Source #

fpToReal :: IsExprBuilder sym => sym -> SFloat sym -> IO (SymReal sym) Source #

See floatToReal. This is undefined on "special" values (NaN,infinity)

fpToRational :: IsSymExprBuilder sym => sym -> SFloat sym -> IO (Pred sym, SymInteger sym, SymInteger sym) Source #

Returns a predicate and two integers, x and y. If the the predicate holds, then x / y is a rational representing the floating point number. Assumes the FP number is not one of the special ones that has no real representation.

fpCast :: IsExprBuilder sym => sym -> Integer -> Integer -> RoundingMode -> SFloat sym -> IO (SFloat sym) Source #

Change the precision of a floating point number (see floatCast).

fpFromBV :: IsExprBuilder sym => sym -> Integer -> Integer -> RoundingMode -> SWord sym -> IO (SFloat sym) Source #

Convert a unsigned bitvector to a floating point number (see bvToFloat).

fpFromSBV :: IsExprBuilder sym => sym -> Integer -> Integer -> RoundingMode -> SWord sym -> IO (SFloat sym) Source #

Convert a signed bitvector to a floating point number (see sbvToFloat).

fpToBV :: IsExprBuilder sym => sym -> Natural -> RoundingMode -> SFloat sym -> IO (SWord sym) Source #

Convert a floating point number to a unsigned bitvector (see floatToBV). Precondition: the supplied Natural (the bit width of the returned bitvector) is non-zero.

fpToSBV :: IsExprBuilder sym => sym -> Natural -> RoundingMode -> SFloat sym -> IO (SWord sym) Source #

Convert a floating point number to a signed bitvector (see floatToSBV). Precondition: the supplied Natural (the bit width of the returned bitvector) is non-zero.

Queries

fpIsInf :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

fpIsNaN :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

fpIsZero :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

fpIsNeg :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

fpIsPos :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

fpIsSubnorm :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

fpIsNorm :: IsExprBuilder sym => sym -> SFloat sym -> IO (Pred sym) Source #

Exceptions

data UnsupportedFloat Source #

This exception is thrown if the operations try to create a floating point value we do not support

data FPTypeError Source #

This exceptoin is throws if the types don't match.