Copyright | (c) Galois Inc 2014-2020 |
---|---|
License | BSD3 |
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Safe Haskell | None |
Language | Haskell2010 |
Defines interface between the simulator and terms that are sent to the SAT or SMT solver. The simulator can use a richer set of types, but the symbolic values must be representable by types supported by this interface.
A solver backend is defined in terms of a type parameter sym
, which
is the type that tracks whatever state or context is needed by that
particular backend. To instantiate the solver interface, one must
provide several type family definitions and class instances for sym
:
type
SymExpr
sym ::BaseType
-> *- Type of symbolic expressions.
type
BoundVar
sym ::BaseType
-> *- Representation of bound variables in symbolic expressions.
type
SymFn
sym :: Ctx BaseType -> BaseType -> *- Representation of symbolic functions.
instance
IsExprBuilder
sym- Functions for building expressions of various types.
instance
IsSymExprBuilder
sym- Functions for building expressions with bound variables and quantifiers.
instance
IsExpr
(SymExpr
sym)- Recognizers for various kinds of literal expressions.
instance
OrdF
(SymExpr
sym)instance
TestEquality
(SymExpr
sym)instance
HashableF
(SymExpr
sym)
The canonical implementation of these interface classes is found in What4.Expr.Builder.
Synopsis
- type family SymExpr (sym :: Type) :: BaseType -> Type
- type family BoundVar (sym :: Type) :: BaseType -> Type
- type family SymFn sym :: Ctx BaseType -> BaseType -> Type
- type family SymAnnotation (sym :: Type) :: BaseType -> Type
- class HasAbsValue e => IsExpr e where
- asConstantPred :: e BaseBoolType -> Maybe Bool
- asNat :: e BaseNatType -> Maybe Natural
- natBounds :: e BaseNatType -> NatValueRange
- asInteger :: e BaseIntegerType -> Maybe Integer
- integerBounds :: e BaseIntegerType -> ValueRange Integer
- asRational :: e BaseRealType -> Maybe Rational
- rationalBounds :: e BaseRealType -> ValueRange Rational
- asComplex :: e BaseComplexType -> Maybe (Complex Rational)
- asBV :: e (BaseBVType w) -> Maybe (BV w)
- unsignedBVBounds :: 1 <= w => e (BaseBVType w) -> Maybe (Integer, Integer)
- signedBVBounds :: 1 <= w => e (BaseBVType w) -> Maybe (Integer, Integer)
- asAffineVar :: e tp -> Maybe (ConcreteVal tp, e tp, ConcreteVal tp)
- asString :: e (BaseStringType si) -> Maybe (StringLiteral si)
- stringInfo :: e (BaseStringType si) -> StringInfoRepr si
- asConstantArray :: e (BaseArrayType idx bt) -> Maybe (e bt)
- asStruct :: e (BaseStructType flds) -> Maybe (Assignment e flds)
- exprType :: e tp -> BaseTypeRepr tp
- bvWidth :: e (BaseBVType w) -> NatRepr w
- printSymExpr :: e tp -> Doc
- class IsSymFn fn where
- fnArgTypes :: fn args ret -> Assignment BaseTypeRepr args
- fnReturnType :: fn args ret -> BaseTypeRepr ret
- data UnfoldPolicy
- shouldUnfold :: IsExpr e => UnfoldPolicy -> Assignment e args -> Bool
- class (IsExpr (SymExpr sym), HashableF (SymExpr sym), TestEquality (SymAnnotation sym), OrdF (SymAnnotation sym), HashableF (SymAnnotation sym)) => IsExprBuilder sym where
- getConfiguration :: sym -> Config
- setSolverLogListener :: sym -> Maybe (SolverEvent -> IO ()) -> IO ()
- getSolverLogListener :: sym -> IO (Maybe (SolverEvent -> IO ()))
- logSolverEvent :: sym -> SolverEvent -> IO ()
- getStatistics :: sym -> IO Statistics
- getCurrentProgramLoc :: sym -> IO ProgramLoc
- setCurrentProgramLoc :: sym -> ProgramLoc -> IO ()
- isEq :: sym -> SymExpr sym tp -> SymExpr sym tp -> IO (Pred sym)
- baseTypeIte :: sym -> Pred sym -> SymExpr sym tp -> SymExpr sym tp -> IO (SymExpr sym tp)
- annotateTerm :: sym -> SymExpr sym tp -> IO (SymAnnotation sym tp, SymExpr sym tp)
- truePred :: sym -> Pred sym
- falsePred :: sym -> Pred sym
- notPred :: sym -> Pred sym -> IO (Pred sym)
- andPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym)
- orPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym)
- impliesPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym)
- xorPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym)
- eqPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym)
- itePred :: sym -> Pred sym -> Pred sym -> Pred sym -> IO (Pred sym)
- natLit :: sym -> Natural -> IO (SymNat sym)
- natAdd :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym)
- natSub :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym)
- natMul :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym)
- natDiv :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym)
- natMod :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym)
- natIte :: sym -> Pred sym -> SymNat sym -> SymNat sym -> IO (SymNat sym)
- natEq :: sym -> SymNat sym -> SymNat sym -> IO (Pred sym)
- natLe :: sym -> SymNat sym -> SymNat sym -> IO (Pred sym)
- natLt :: sym -> SymNat sym -> SymNat sym -> IO (Pred sym)
- intLit :: sym -> Integer -> IO (SymInteger sym)
- intNeg :: sym -> SymInteger sym -> IO (SymInteger sym)
- intAdd :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
- intSub :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
- intMul :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
- intIte :: sym -> Pred sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
- intEq :: sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym)
- intLe :: sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym)
- intLt :: sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym)
- intAbs :: sym -> SymInteger sym -> IO (SymInteger sym)
- intDiv :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
- intMod :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
- intDivisible :: sym -> SymInteger sym -> Natural -> IO (Pred sym)
- bvLit :: 1 <= w => sym -> NatRepr w -> BV w -> IO (SymBV sym w)
- bvConcat :: (1 <= u, 1 <= v) => sym -> SymBV sym u -> SymBV sym v -> IO (SymBV sym (u + v))
- bvSelect :: forall idx n w. (1 <= n, (idx + n) <= w) => sym -> NatRepr idx -> NatRepr n -> SymBV sym w -> IO (SymBV sym n)
- bvNeg :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w)
- bvAdd :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvSub :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvMul :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvUdiv :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvUrem :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvSdiv :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvSrem :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- testBitBV :: 1 <= w => sym -> Natural -> SymBV sym w -> IO (Pred sym)
- bvIsNeg :: 1 <= w => sym -> SymBV sym w -> IO (Pred sym)
- bvIte :: 1 <= w => sym -> Pred sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvEq :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvNe :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvUlt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvUle :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvUge :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvUgt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvSlt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvSgt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvSle :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvSge :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
- bvIsNonzero :: 1 <= w => sym -> SymBV sym w -> IO (Pred sym)
- bvShl :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvLshr :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvAshr :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvRol :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvRor :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvZext :: (1 <= u, (u + 1) <= r) => sym -> NatRepr r -> SymBV sym u -> IO (SymBV sym r)
- bvSext :: (1 <= u, (u + 1) <= r) => sym -> NatRepr r -> SymBV sym u -> IO (SymBV sym r)
- bvTrunc :: (1 <= r, (r + 1) <= w) => sym -> NatRepr r -> SymBV sym w -> IO (SymBV sym r)
- bvAndBits :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvOrBits :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvXorBits :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
- bvNotBits :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w)
- bvSet :: forall w. 1 <= w => sym -> SymBV sym w -> Natural -> Pred sym -> IO (SymBV sym w)
- bvFill :: forall w. 1 <= w => sym -> NatRepr w -> Pred sym -> IO (SymBV sym w)
- minUnsignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w)
- maxUnsignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w)
- maxSignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w)
- minSignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w)
- bvPopcount :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w)
- bvCountLeadingZeros :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w)
- bvCountTrailingZeros :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w)
- addUnsignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w)
- addSignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w)
- subUnsignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w)
- subSignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w)
- carrylessMultiply :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym (w + w))
- unsignedWideMultiplyBV :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w, SymBV sym w)
- mulUnsignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w)
- signedWideMultiplyBV :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w, SymBV sym w)
- mulSignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w)
- mkStruct :: sym -> Assignment (SymExpr sym) flds -> IO (SymStruct sym flds)
- structField :: sym -> SymStruct sym flds -> Index flds tp -> IO (SymExpr sym tp)
- structEq :: forall flds. sym -> SymStruct sym flds -> SymStruct sym flds -> IO (Pred sym)
- structIte :: sym -> Pred sym -> SymStruct sym flds -> SymStruct sym flds -> IO (SymStruct sym flds)
- constantArray :: sym -> Assignment BaseTypeRepr (idx ::> tp) -> SymExpr sym b -> IO (SymArray sym (idx ::> tp) b)
- arrayFromFn :: sym -> SymFn sym (idx ::> itp) ret -> IO (SymArray sym (idx ::> itp) ret)
- arrayMap :: sym -> SymFn sym (ctx ::> d) r -> Assignment (ArrayResultWrapper (SymExpr sym) (idx ::> itp)) (ctx ::> d) -> IO (SymArray sym (idx ::> itp) r)
- arrayUpdate :: sym -> SymArray sym (idx ::> tp) b -> Assignment (SymExpr sym) (idx ::> tp) -> SymExpr sym b -> IO (SymArray sym (idx ::> tp) b)
- arrayLookup :: sym -> SymArray sym (idx ::> tp) b -> Assignment (SymExpr sym) (idx ::> tp) -> IO (SymExpr sym b)
- arrayFromMap :: sym -> Assignment BaseTypeRepr (idx ::> itp) -> ArrayUpdateMap (SymExpr sym) (idx ::> itp) tp -> SymExpr sym tp -> IO (SymArray sym (idx ::> itp) tp)
- arrayUpdateAtIdxLits :: sym -> ArrayUpdateMap (SymExpr sym) (idx ::> itp) tp -> SymArray sym (idx ::> itp) tp -> IO (SymArray sym (idx ::> itp) tp)
- arrayIte :: sym -> Pred sym -> SymArray sym idx b -> SymArray sym idx b -> IO (SymArray sym idx b)
- arrayEq :: sym -> SymArray sym idx b -> SymArray sym idx b -> IO (Pred sym)
- allTrueEntries :: sym -> SymArray sym idx BaseBoolType -> IO (Pred sym)
- arrayTrueOnEntries :: sym -> SymFn sym (idx ::> itp) BaseBoolType -> SymArray sym (idx ::> itp) BaseBoolType -> IO (Pred sym)
- natToInteger :: sym -> SymNat sym -> IO (SymInteger sym)
- integerToReal :: sym -> SymInteger sym -> IO (SymReal sym)
- bvToNat :: 1 <= w => sym -> SymBV sym w -> IO (SymNat sym)
- bvToInteger :: 1 <= w => sym -> SymBV sym w -> IO (SymInteger sym)
- sbvToInteger :: 1 <= w => sym -> SymBV sym w -> IO (SymInteger sym)
- predToBV :: 1 <= w => sym -> Pred sym -> NatRepr w -> IO (SymBV sym w)
- natToReal :: sym -> SymNat sym -> IO (SymReal sym)
- uintToReal :: 1 <= w => sym -> SymBV sym w -> IO (SymReal sym)
- sbvToReal :: 1 <= w => sym -> SymBV sym w -> IO (SymReal sym)
- realRound :: sym -> SymReal sym -> IO (SymInteger sym)
- realRoundEven :: sym -> SymReal sym -> IO (SymInteger sym)
- realFloor :: sym -> SymReal sym -> IO (SymInteger sym)
- realCeil :: sym -> SymReal sym -> IO (SymInteger sym)
- realTrunc :: sym -> SymReal sym -> IO (SymInteger sym)
- integerToBV :: 1 <= w => sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w)
- integerToNat :: sym -> SymInteger sym -> IO (SymNat sym)
- realToInteger :: sym -> SymReal sym -> IO (SymInteger sym)
- realToNat :: sym -> SymReal sym -> IO (SymNat sym)
- realToBV :: 1 <= w => sym -> SymReal sym -> NatRepr w -> IO (SymBV sym w)
- realToSBV :: 1 <= w => sym -> SymReal sym -> NatRepr w -> IO (SymBV sym w)
- clampedIntToSBV :: 1 <= w => sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w)
- clampedIntToBV :: 1 <= w => sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w)
- intSetWidth :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n)
- uintSetWidth :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n)
- intToUInt :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n)
- uintToInt :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n)
- stringEmpty :: sym -> StringInfoRepr si -> IO (SymString sym si)
- stringLit :: sym -> StringLiteral si -> IO (SymString sym si)
- stringEq :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym)
- stringIte :: sym -> Pred sym -> SymString sym si -> SymString sym si -> IO (SymString sym si)
- stringConcat :: sym -> SymString sym si -> SymString sym si -> IO (SymString sym si)
- stringContains :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym)
- stringIsPrefixOf :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym)
- stringIsSuffixOf :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym)
- stringIndexOf :: sym -> SymString sym si -> SymString sym si -> SymNat sym -> IO (SymInteger sym)
- stringLength :: sym -> SymString sym si -> IO (SymNat sym)
- stringSubstring :: sym -> SymString sym si -> SymNat sym -> SymNat sym -> IO (SymString sym si)
- realZero :: sym -> SymReal sym
- realLit :: sym -> Rational -> IO (SymReal sym)
- sciLit :: sym -> Scientific -> IO (SymReal sym)
- realEq :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym)
- realNe :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym)
- realLe :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym)
- realLt :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym)
- realGe :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym)
- realGt :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym)
- realIte :: sym -> Pred sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- realNeg :: sym -> SymReal sym -> IO (SymReal sym)
- realAdd :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- realMul :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- realSub :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- realSq :: sym -> SymReal sym -> IO (SymReal sym)
- realDiv :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- realMod :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- isInteger :: sym -> SymReal sym -> IO (Pred sym)
- realIsNonNeg :: sym -> SymReal sym -> IO (Pred sym)
- realSqrt :: sym -> SymReal sym -> IO (SymReal sym)
- realAtan2 :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- realPi :: sym -> IO (SymReal sym)
- realLog :: sym -> SymReal sym -> IO (SymReal sym)
- realExp :: sym -> SymReal sym -> IO (SymReal sym)
- realSin :: sym -> SymReal sym -> IO (SymReal sym)
- realCos :: sym -> SymReal sym -> IO (SymReal sym)
- realTan :: sym -> SymReal sym -> IO (SymReal sym)
- realSinh :: sym -> SymReal sym -> IO (SymReal sym)
- realCosh :: sym -> SymReal sym -> IO (SymReal sym)
- realTanh :: sym -> SymReal sym -> IO (SymReal sym)
- realAbs :: sym -> SymReal sym -> IO (SymReal sym)
- realHypot :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym)
- floatPZero :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp)
- floatNZero :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp)
- floatNaN :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp)
- floatPInf :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp)
- floatNInf :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp)
- floatLit :: sym -> FloatPrecisionRepr fpp -> Rational -> IO (SymFloat sym fpp)
- floatNeg :: sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatAbs :: sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatSqrt :: sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatAdd :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatSub :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatMul :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatDiv :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatRem :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatMin :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatMax :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatFMA :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatEq :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatNe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatFpEq :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatFpNe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatLe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatLt :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatGe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatGt :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
- floatIsNaN :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIsInf :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIsZero :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIsPos :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIsNeg :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIsSubnorm :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIsNorm :: sym -> SymFloat sym fpp -> IO (Pred sym)
- floatIte :: sym -> Pred sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatCast :: sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymFloat sym fpp' -> IO (SymFloat sym fpp)
- floatRound :: sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp)
- floatFromBinary :: (2 <= eb, 2 <= sb) => sym -> FloatPrecisionRepr (FloatingPointPrecision eb sb) -> SymBV sym (eb + sb) -> IO (SymFloat sym (FloatingPointPrecision eb sb))
- floatToBinary :: (2 <= eb, 2 <= sb) => sym -> SymFloat sym (FloatingPointPrecision eb sb) -> IO (SymBV sym (eb + sb))
- bvToFloat :: 1 <= w => sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymBV sym w -> IO (SymFloat sym fpp)
- sbvToFloat :: 1 <= w => sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymBV sym w -> IO (SymFloat sym fpp)
- realToFloat :: sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymReal sym -> IO (SymFloat sym fpp)
- floatToBV :: 1 <= w => sym -> NatRepr w -> RoundingMode -> SymFloat sym fpp -> IO (SymBV sym w)
- floatToSBV :: 1 <= w => sym -> NatRepr w -> RoundingMode -> SymFloat sym fpp -> IO (SymBV sym w)
- floatToReal :: sym -> SymFloat sym fpp -> IO (SymReal sym)
- mkComplex :: sym -> Complex (SymReal sym) -> IO (SymCplx sym)
- getRealPart :: sym -> SymCplx sym -> IO (SymReal sym)
- getImagPart :: sym -> SymCplx sym -> IO (SymReal sym)
- cplxGetParts :: sym -> SymCplx sym -> IO (Complex (SymReal sym))
- mkComplexLit :: sym -> Complex Rational -> IO (SymCplx sym)
- cplxFromReal :: sym -> SymReal sym -> IO (SymCplx sym)
- cplxIte :: sym -> Pred sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym)
- cplxNeg :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxAdd :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym)
- cplxSub :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym)
- cplxMul :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym)
- cplxMag :: sym -> SymCplx sym -> IO (SymReal sym)
- cplxSqrt :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxSin :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxCos :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxTan :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxHypot :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym)
- cplxRound :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxFloor :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxCeil :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxConj :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxExp :: sym -> SymCplx sym -> IO (SymCplx sym)
- cplxEq :: sym -> SymCplx sym -> SymCplx sym -> IO (Pred sym)
- cplxNe :: sym -> SymCplx sym -> SymCplx sym -> IO (Pred sym)
- class (IsExprBuilder sym, IsSymFn (SymFn sym), OrdF (SymExpr sym)) => IsSymExprBuilder sym where
- freshConstant :: sym -> SolverSymbol -> BaseTypeRepr tp -> IO (SymExpr sym tp)
- freshLatch :: sym -> SolverSymbol -> BaseTypeRepr tp -> IO (SymExpr sym tp)
- freshBoundedBV :: 1 <= w => sym -> SolverSymbol -> NatRepr w -> Maybe Natural -> Maybe Natural -> IO (SymBV sym w)
- freshBoundedSBV :: 1 <= w => sym -> SolverSymbol -> NatRepr w -> Maybe Integer -> Maybe Integer -> IO (SymBV sym w)
- freshBoundedNat :: sym -> SolverSymbol -> Maybe Natural -> Maybe Natural -> IO (SymNat sym)
- freshBoundedInt :: sym -> SolverSymbol -> Maybe Integer -> Maybe Integer -> IO (SymInteger sym)
- freshBoundedReal :: sym -> SolverSymbol -> Maybe Rational -> Maybe Rational -> IO (SymReal sym)
- freshBoundVar :: sym -> SolverSymbol -> BaseTypeRepr tp -> IO (BoundVar sym tp)
- varExpr :: sym -> BoundVar sym tp -> SymExpr sym tp
- forallPred :: sym -> BoundVar sym tp -> Pred sym -> IO (Pred sym)
- existsPred :: sym -> BoundVar sym tp -> Pred sym -> IO (Pred sym)
- definedFn :: sym -> SolverSymbol -> Assignment (BoundVar sym) args -> SymExpr sym ret -> UnfoldPolicy -> IO (SymFn sym args ret)
- inlineDefineFun :: CurryAssignmentClass args => sym -> SolverSymbol -> Assignment BaseTypeRepr args -> UnfoldPolicy -> CurryAssignment args (SymExpr sym) (IO (SymExpr sym ret)) -> IO (SymFn sym args ret)
- freshTotalUninterpFn :: forall args ret. sym -> SolverSymbol -> Assignment BaseTypeRepr args -> BaseTypeRepr ret -> IO (SymFn sym args ret)
- applySymFn :: sym -> SymFn sym args ret -> Assignment (SymExpr sym) args -> IO (SymExpr sym ret)
- data SolverEvent
- = SolverStartSATQuery { }
- | SolverEndSATQuery {
- satQueryResult :: !(SatResult () ())
- satQueryError :: !(Maybe String)
- bvJoinVector :: forall sym n w. (1 <= w, IsExprBuilder sym) => sym -> NatRepr w -> Vector n (SymBV sym w) -> IO (SymBV sym (n * w))
- bvSplitVector :: forall sym n w. (IsExprBuilder sym, 1 <= w, 1 <= n) => sym -> NatRepr n -> NatRepr w -> SymBV sym (n * w) -> IO (Vector n (SymBV sym w))
- bvSwap :: forall sym n. (1 <= n, IsExprBuilder sym) => sym -> NatRepr n -> SymBV sym (n * 8) -> IO (SymBV sym (n * 8))
- bvBitreverse :: forall sym w. (1 <= w, IsExprBuilder sym) => sym -> SymBV sym w -> IO (SymBV sym w)
- data RoundingMode
- data Statistics = Statistics {
- statAllocs :: !Integer
- statNonLinearOps :: !Integer
- zeroStatistics :: Statistics
- type Pred sym = SymExpr sym BaseBoolType
- type SymNat sym = SymExpr sym BaseNatType
- type SymInteger sym = SymExpr sym BaseIntegerType
- type SymReal sym = SymExpr sym BaseRealType
- type SymFloat sym fpp = SymExpr sym (BaseFloatType fpp)
- type SymString sym si = SymExpr sym (BaseStringType si)
- type SymCplx sym = SymExpr sym BaseComplexType
- type SymStruct sym flds = SymExpr sym (BaseStructType flds)
- type SymBV sym n = SymExpr sym (BaseBVType n)
- type SymArray sym idx b = SymExpr sym (BaseArrayType idx b)
- data IndexLit idx where
- NatIndexLit :: !Natural -> IndexLit BaseNatType
- BVIndexLit :: 1 <= w => !(NatRepr w) -> !(BV w) -> IndexLit (BaseBVType w)
- indexLit :: IsExprBuilder sym => sym -> IndexLit idx -> IO (SymExpr sym idx)
- newtype ArrayResultWrapper f idx tp = ArrayResultWrapper {
- unwrapArrayResult :: f (BaseArrayType idx tp)
- asConcrete :: IsExpr e => e tp -> Maybe (ConcreteVal tp)
- concreteToSym :: IsExprBuilder sym => sym -> ConcreteVal tp -> IO (SymExpr sym tp)
- baseIsConcrete :: forall e bt. IsExpr e => e bt -> Bool
- baseDefaultValue :: forall sym bt. IsExprBuilder sym => sym -> BaseTypeRepr bt -> IO (SymExpr sym bt)
- realExprAsInteger :: (IsExpr e, MonadFail m) => e BaseRealType -> m Integer
- rationalAsInteger :: MonadFail m => Rational -> m Integer
- cplxExprAsRational :: (MonadFail m, IsExpr e) => e BaseComplexType -> m Rational
- cplxExprAsInteger :: (MonadFail m, IsExpr e) => e BaseComplexType -> m Integer
- data SymEncoder sym v tp = SymEncoder {
- symEncoderType :: !(BaseTypeRepr tp)
- symFromExpr :: !(sym -> SymExpr sym tp -> IO v)
- symToExpr :: !(sym -> v -> IO (SymExpr sym tp))
- backendPred :: IsExprBuilder sym => sym -> Bool -> Pred sym
- andAllOf :: IsExprBuilder sym => sym -> Fold s (Pred sym) -> s -> IO (Pred sym)
- orOneOf :: IsExprBuilder sym => sym -> Fold s (Pred sym) -> s -> IO (Pred sym)
- itePredM :: (IsExpr (SymExpr sym), IsExprBuilder sym, MonadIO m) => sym -> Pred sym -> m (Pred sym) -> m (Pred sym) -> m (Pred sym)
- iteM :: IsExprBuilder sym => (sym -> Pred sym -> v -> v -> IO v) -> sym -> Pred sym -> IO v -> IO v -> IO v
- predToReal :: IsExprBuilder sym => sym -> Pred sym -> IO (SymReal sym)
- cplxDiv :: IsExprBuilder sym => sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym)
- cplxLog :: IsExprBuilder sym => sym -> SymCplx sym -> IO (SymCplx sym)
- cplxLogBase :: IsExprBuilder sym => Rational -> sym -> SymCplx sym -> IO (SymCplx sym)
- mkRational :: IsExprBuilder sym => sym -> Rational -> IO (SymCplx sym)
- mkReal :: (IsExprBuilder sym, Real a) => sym -> a -> IO (SymCplx sym)
- isNonZero :: IsExprBuilder sym => sym -> SymCplx sym -> IO (Pred sym)
- isReal :: IsExprBuilder sym => sym -> SymCplx sym -> IO (Pred sym)
- muxRange :: (IsExpr e, Monad m) => (Natural -> m (e BaseBoolType)) -> (e BaseBoolType -> a -> a -> m a) -> (Natural -> m a) -> Natural -> Natural -> m a
- module Data.Parameterized.NatRepr
- module What4.BaseTypes
- class HasAbsValue f
- data SolverSymbol
- emptySymbol :: SolverSymbol
- userSymbol :: String -> Either SolverSymbolError SolverSymbol
- safeSymbol :: String -> SolverSymbol
- data NatValueRange
- data ValueRange tp
- = SingleRange !tp
- | MultiRange !(ValueBound tp) !(ValueBound tp)
- data StringLiteral (si :: StringInfo) :: Type where
- stringLiteralInfo :: StringLiteral si -> StringInfoRepr si
Interface classes
Type Families
type family SymExpr (sym :: Type) :: BaseType -> Type Source #
The class for expressions.
Instances
type SymExpr (ExprBuilder t st fs) Source # | |
Defined in What4.Expr.Builder |
type family BoundVar (sym :: Type) :: BaseType -> Type Source #
Type of bound variable associated with symbolic state.
This type is used by some methods in class IsSymExprBuilder
.
Instances
type BoundVar (ExprBuilder t st fs) Source # | |
Defined in What4.Expr.Builder |
type family SymFn sym :: Ctx BaseType -> BaseType -> Type Source #
A function that can be applied to symbolic arguments.
This type is used by some methods in classes IsExprBuilder
and
IsSymExprBuilder
.
Instances
type SymFn (ExprBuilder t st fs) Source # | |
Defined in What4.Expr.Builder |
type family SymAnnotation (sym :: Type) :: BaseType -> Type Source #
Type used to uniquely identify expressions that have been annotated.
Instances
type SymAnnotation (ExprBuilder t st fs) Source # | |
Defined in What4.Expr.Builder |
Expression recognizers
class HasAbsValue e => IsExpr e where Source #
This class provides operations for recognizing when symbolic expressions represent concrete values, extracting the type from an expression, and for providing pretty-printed representations of an expression.
natBounds, integerBounds, rationalBounds, unsignedBVBounds, signedBVBounds, asAffineVar, exprType, printSymExpr
asConstantPred :: e BaseBoolType -> Maybe Bool Source #
Evaluate if predicate is constant.
asNat :: e BaseNatType -> Maybe Natural Source #
Return nat if this is a constant natural number.
natBounds :: e BaseNatType -> NatValueRange Source #
Return any bounding information we have about the term
asInteger :: e BaseIntegerType -> Maybe Integer Source #
Return integer if this is a constant integer.
integerBounds :: e BaseIntegerType -> ValueRange Integer Source #
Return any bounding information we have about the term
asRational :: e BaseRealType -> Maybe Rational Source #
Return rational if this is a constant value.
rationalBounds :: e BaseRealType -> ValueRange Rational Source #
Return any bounding information we have about the term
asComplex :: e BaseComplexType -> Maybe (Complex Rational) Source #
Return complex if this is a constant value.
asBV :: e (BaseBVType w) -> Maybe (BV w) Source #
Return a bitvector if this is a constant bitvector.
unsignedBVBounds :: 1 <= w => e (BaseBVType w) -> Maybe (Integer, Integer) Source #
If we have bounds information about the term, return unsigned upper and lower bounds as integers
signedBVBounds :: 1 <= w => e (BaseBVType w) -> Maybe (Integer, Integer) Source #
If we have bounds information about the term, return signed upper and lower bounds as integers
asAffineVar :: e tp -> Maybe (ConcreteVal tp, e tp, ConcreteVal tp) Source #
asString :: e (BaseStringType si) -> Maybe (StringLiteral si) Source #
Return the string value if this is a constant string
stringInfo :: e (BaseStringType si) -> StringInfoRepr si Source #
asConstantArray :: e (BaseArrayType idx bt) -> Maybe (e bt) Source #
Return the unique element value if this is a constant array,
such as one made with constantArray
.
asStruct :: e (BaseStructType flds) -> Maybe (Assignment e flds) Source #
Return the struct fields if this is a concrete struct.
exprType :: e tp -> BaseTypeRepr tp Source #
Get type of expression.
bvWidth :: e (BaseBVType w) -> NatRepr w Source #
Get the width of a bitvector
printSymExpr :: e tp -> Doc Source #
Print a sym expression for debugging or display purposes.
Instances
class IsSymFn fn where Source #
A class for extracting type representatives from symbolic functions
fnArgTypes :: fn args ret -> Assignment BaseTypeRepr args Source #
Get the argument types of a function.
fnReturnType :: fn args ret -> BaseTypeRepr ret Source #
Get the return type of a function.
Instances
IsExpr e => IsSymFn (ExprSymFn t e) Source # | |
Defined in What4.Expr.App fnArgTypes :: ExprSymFn t e args ret -> Assignment BaseTypeRepr args Source # fnReturnType :: ExprSymFn t e args ret -> BaseTypeRepr ret Source # |
data UnfoldPolicy Source #
Describes when we unfold the body of defined functions.
NeverUnfold | What4 will not unfold the body of functions when applied to arguments |
AlwaysUnfold | The function will be unfolded into its definition whenever it is applied to arguments |
UnfoldConcrete | The function will be unfolded into its definition only if all the provided arguments are concrete. |
Instances
Eq UnfoldPolicy Source # | |
Defined in What4.Interface (==) :: UnfoldPolicy -> UnfoldPolicy -> Bool # (/=) :: UnfoldPolicy -> UnfoldPolicy -> Bool # | |
Ord UnfoldPolicy Source # | |
Defined in What4.Interface compare :: UnfoldPolicy -> UnfoldPolicy -> Ordering # (<) :: UnfoldPolicy -> UnfoldPolicy -> Bool # (<=) :: UnfoldPolicy -> UnfoldPolicy -> Bool # (>) :: UnfoldPolicy -> UnfoldPolicy -> Bool # (>=) :: UnfoldPolicy -> UnfoldPolicy -> Bool # max :: UnfoldPolicy -> UnfoldPolicy -> UnfoldPolicy # min :: UnfoldPolicy -> UnfoldPolicy -> UnfoldPolicy # | |
Show UnfoldPolicy Source # | |
Defined in What4.Interface showsPrec :: Int -> UnfoldPolicy -> ShowS # show :: UnfoldPolicy -> String # showList :: [UnfoldPolicy] -> ShowS # |
shouldUnfold :: IsExpr e => UnfoldPolicy -> Assignment e args -> Bool Source #
IsExprBuilder
class (IsExpr (SymExpr sym), HashableF (SymExpr sym), TestEquality (SymAnnotation sym), OrdF (SymAnnotation sym), HashableF (SymAnnotation sym)) => IsExprBuilder sym where Source #
This class allows the simulator to build symbolic expressions.
Methods of this class refer to type families
and SymExpr
sym
.SymFn
sym
Note: Some methods in this class represent operations that are partial functions on their domain (e.g., division by 0). Such functions will have documentation strings indicating that they are undefined under some conditions.
The behavior of these functions is generally to throw an error if it is concretely obvious that the function results in an undefined value; but otherwise they will silently produce an unspecified value of the expected type.
getConfiguration, setSolverLogListener, getSolverLogListener, logSolverEvent, getCurrentProgramLoc, setCurrentProgramLoc, annotateTerm, truePred, falsePred, notPred, andPred, orPred, xorPred, eqPred, itePred, natLit, natAdd, natSub, natMul, natDiv, natMod, natIte, natEq, natLe, intLit, intNeg, intAdd, intMul, intIte, intEq, intLe, intAbs, intDiv, intMod, intDivisible, bvLit, bvConcat, bvSelect, bvNeg, bvAdd, bvMul, bvUdiv, bvUrem, bvSdiv, bvSrem, testBitBV, bvIte, bvEq, bvUlt, bvSlt, bvShl, bvLshr, bvAshr, bvRol, bvRor, bvZext, bvSext, bvAndBits, bvOrBits, bvXorBits, bvNotBits, bvFill, bvPopcount, bvCountLeadingZeros, bvCountTrailingZeros, mkStruct, structField, structIte, constantArray, arrayFromFn, arrayMap, arrayUpdate, arrayLookup, arrayIte, arrayEq, arrayTrueOnEntries, natToInteger, integerToReal, bvToNat, bvToInteger, sbvToInteger, predToBV, realRound, realRoundEven, realFloor, realCeil, integerToBV, integerToNat, realToInteger, stringEmpty, stringLit, stringEq, stringIte, stringConcat, stringContains, stringIsPrefixOf, stringIsSuffixOf, stringIndexOf, stringLength, stringSubstring, realZero, realLit, realEq, realLe, realIte, realNeg, realAdd, realMul, realDiv, isInteger, realSqrt, realAtan2, realPi, realLog, realExp, realSin, realCos, realSinh, realCosh, floatPZero, floatNZero, floatNaN, floatPInf, floatNInf, floatLit, floatNeg, floatAbs, floatSqrt, floatAdd, floatSub, floatMul, floatDiv, floatRem, floatMin, floatMax, floatFMA, floatEq, floatNe, floatFpEq, floatFpNe, floatLe, floatLt, floatGe, floatGt, floatIsNaN, floatIsInf, floatIsZero, floatIsPos, floatIsNeg, floatIsSubnorm, floatIsNorm, floatIte, floatCast, floatRound, floatFromBinary, floatToBinary, bvToFloat, sbvToFloat, realToFloat, floatToBV, floatToSBV, floatToReal, mkComplex, getRealPart, getImagPart, cplxGetParts
getConfiguration :: sym -> Config Source #
Retrieve the configuration object corresponding to this solver interface.
setSolverLogListener :: sym -> Maybe (SolverEvent -> IO ()) -> IO () Source #
Install an action that will be invoked before and after calls to
backend solvers. This action is primarily intended to be used for
logging/profiling/debugging purposes. Passing Nothing
to this
function disables logging.
getSolverLogListener :: sym -> IO (Maybe (SolverEvent -> IO ())) Source #
Get the currently-installed solver log listener, if one has been installed.
logSolverEvent :: sym -> SolverEvent -> IO () Source #
Provide the given even to the currently installed solver log listener, if any.
getStatistics :: sym -> IO Statistics Source #
Get statistics on execution from the initialization of the symbolic interface to this point. May return zeros if gathering statistics isn't supported.
getCurrentProgramLoc :: sym -> IO ProgramLoc Source #
Get current location of program for term creation purposes.
setCurrentProgramLoc :: sym -> ProgramLoc -> IO () Source #
Set current location of program for term creation purposes.
isEq :: sym -> SymExpr sym tp -> SymExpr sym tp -> IO (Pred sym) Source #
Return true if two expressions are equal. The default
implementation dispatches eqPred
, bvEq
, natEq
, intEq
,
realEq
, cplxEq
, structEq
, or arrayEq
, depending on the
type.
baseTypeIte :: sym -> Pred sym -> SymExpr sym tp -> SymExpr sym tp -> IO (SymExpr sym tp) Source #
Take the if-then-else of two expressions. The default
implementation dispatches itePred
, bvIte
, natIte
, intIte
,
realIte
, cplxIte
, structIte
, or arrayIte
, depending on
the type.
annotateTerm :: sym -> SymExpr sym tp -> IO (SymAnnotation sym tp, SymExpr sym tp) Source #
Given a symbolic expression, annotate it with a unique identifier
that can be used to maintain a connection with the given term.
The SymAnnotation
is intended to be used as the key in a hash
table or map to additional data can be maintained alongside the terms.
The returned SymExpr
has the same semantics as the arugmnent, but
has embedded in it the SymAnnotation
value so that it can be used
later during term traversals.
Note, the returned annotation is not necessarily fresh; if an already-annotated term is passed in, the same annotation value will be returned.
truePred :: sym -> Pred sym Source #
Constant true predicate
falsePred :: sym -> Pred sym Source #
Constant false predicate
notPred :: sym -> Pred sym -> IO (Pred sym) Source #
Boolean negation
andPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym) Source #
Boolean conjunction
orPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym) Source #
Boolean disjunction
impliesPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym) Source #
Boolean implication
xorPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym) Source #
Exclusive-or operation
eqPred :: sym -> Pred sym -> Pred sym -> IO (Pred sym) Source #
Equality of boolean values
itePred :: sym -> Pred sym -> Pred sym -> Pred sym -> IO (Pred sym) Source #
If-then-else on a predicate.
natLit :: sym -> Natural -> IO (SymNat sym) Source #
A natural number literal.
natAdd :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym) Source #
Add two natural numbers.
natSub :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym) Source #
Subtract one number from another.
The result is undefined if this would result in a negative number.
natMul :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym) Source #
Multiply one number by another.
natDiv :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym) Source #
performs division on naturals.natDiv
sym x y
The result is undefined if y
equals 0
.
natDiv
and natMod
satisfy the property that given
d <- natDiv sym x y m <- natMod sym x y
and y > 0
, we have that y * d + m = x
and m < y
.
natMod :: sym -> SymNat sym -> SymNat sym -> IO (SymNat sym) Source #
returns natMod
sym x yx
mod y
.
See natDiv
for a description of the properties the return
value is expected to satisfy.
natIte :: sym -> Pred sym -> SymNat sym -> SymNat sym -> IO (SymNat sym) Source #
If-then-else applied to natural numbers.
natEq :: sym -> SymNat sym -> SymNat sym -> IO (Pred sym) Source #
Equality predicate for natural numbers.
natLe :: sym -> SymNat sym -> SymNat sym -> IO (Pred sym) Source #
returns natLe
sym x ytrue
if x <= y
.
natLt :: sym -> SymNat sym -> SymNat sym -> IO (Pred sym) Source #
returns natLt
sym x ytrue
if x < y
.
intLit :: sym -> Integer -> IO (SymInteger sym) Source #
Create an integer literal.
intNeg :: sym -> SymInteger sym -> IO (SymInteger sym) Source #
Negate an integer.
intAdd :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym) Source #
Add two integers.
intSub :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym) Source #
Subtract one integer from another.
intMul :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym) Source #
Multiply one integer by another.
intIte :: sym -> Pred sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym) Source #
If-then-else applied to integers.
intEq :: sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym) Source #
Integer equality.
intLe :: sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym) Source #
Integer less-than-or-equal.
intLt :: sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym) Source #
Integer less-than.
intAbs :: sym -> SymInteger sym -> IO (SymInteger sym) Source #
Compute the absolute value of an integer.
intDiv :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym) Source #
intDiv x y
computes the integer division of x
by y
. This division is
interpreted the same way as the SMT-Lib integer theory, which states that
div
and mod
are the unique Eucledian division operations satisfying the
following for all y /= 0
:
x * (div x y) + (mod x y) == x
0 <= mod x y < abs y
The value of intDiv x y
is undefined when y = 0
.
Integer division requires nonlinear support whenever the divisor is not a constant.
Note: div x y
is floor (x/y)
when y
is positive
(regardless of sign of x
) and ceiling (x/y)
when y
is
negative. This is neither of the more common "round toward
zero" nor "round toward -inf" definitions.
Some useful theorems that are true of this division/modulus pair:
* mod x y == mod x (- y) == mod x (abs y)
* div x (-y) == -(div x y)
intMod :: sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym) Source #
intMod x y
computes the integer modulus of x
by y
. See intDiv
for
more details.
The value of intMod x y
is undefined when y = 0
.
Integer modulus requires nonlinear support whenever the divisor is not a constant.
intDivisible :: sym -> SymInteger sym -> Natural -> IO (Pred sym) Source #
intDivisible x k
is true whenever x
is an integer divisible
by the known natural number k
. In other words `divisible x k`
holds if there exists an integer z
such that `x = k*z`.
bvLit :: 1 <= w => sym -> NatRepr w -> BV w -> IO (SymBV sym w) Source #
Create a bitvector with the given width and value.
:: (1 <= u, 1 <= v) | |
=> sym | |
-> SymBV sym u | most significant bits |
-> SymBV sym v | least significant bits |
-> IO (SymBV sym (u + v)) |
Concatenate two bitvectors.
:: (1 <= n, (idx + n) <= w) | |
=> sym | |
-> NatRepr idx | Starting index, from 0 as least significant bit |
-> NatRepr n | Number of bits to take |
-> SymBV sym w | Bitvector to select from |
-> IO (SymBV sym n) |
Select a subsequence from a bitvector.
bvNeg :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w) Source #
2's complement negation.
bvAdd :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Add two bitvectors.
bvSub :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Subtract one bitvector from another.
bvMul :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Multiply one bitvector by another.
bvUdiv :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Unsigned bitvector division.
The result of bvUdiv x y
is undefined when y
is zero,
but is otherwise equal to floor( x / y )
.
bvUrem :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Unsigned bitvector remainder.
The result of bvUrem x y
is undefined when y
is zero,
but is otherwise equal to x - (bvUdiv x y) * y
.
bvSdiv :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Signed bitvector division. The result is truncated to zero.
The result of bvSdiv x y
is undefined when y
is zero,
but is equal to floor(x/y)
when x
and y
have the same sign,
and equal to ceiling(x/y)
when x
and y
have opposite signs.
NOTE! However, that there is a corner case when dividing MIN_INT
by
-1
, in which case an overflow condition occurs, and the result is instead
MIN_INT
.
bvSrem :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Signed bitvector remainder.
The result of bvSrem x y
is undefined when y
is zero, but is
otherwise equal to x - (bvSdiv x y) * y
.
:: 1 <= w | |
=> sym | |
-> Natural | Index of bit (0 is the least significant bit) |
-> SymBV sym w | |
-> IO (Pred sym) |
Returns true if the corresponding bit in the bitvector is set.
bvIsNeg :: 1 <= w => sym -> SymBV sym w -> IO (Pred sym) Source #
Return true if bitvector is negative.
bvIte :: 1 <= w => sym -> Pred sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
If-then-else applied to bitvectors.
bvEq :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Return true if bitvectors are equal.
bvNe :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Return true if bitvectors are distinct.
bvUlt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Unsigned less-than.
bvUle :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Unsigned less-than-or-equal.
bvUge :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Unsigned greater-than-or-equal.
bvUgt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Unsigned greater-than.
bvSlt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Signed less-than.
bvSgt :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Signed greater-than.
bvSle :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Signed less-than-or-equal.
bvSge :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym) Source #
Signed greater-than-or-equal.
bvIsNonzero :: 1 <= w => sym -> SymBV sym w -> IO (Pred sym) Source #
returns true if the given bitvector is non-zero.
Left shift. The shift amount is treated as an unsigned value.
Logical right shift. The shift amount is treated as an unsigned value.
Arithmetic right shift. The shift amount is treated as an unsigned value.
:: 1 <= w | |
=> sym | |
-> SymBV sym w | bitvector to rotate |
-> SymBV sym w | amount to rotate by |
-> IO (SymBV sym w) |
Rotate left. The rotate amount is treated as an unsigned value.
:: 1 <= w | |
=> sym | |
-> SymBV sym w | bitvector to rotate |
-> SymBV sym w | amount to rotate by |
-> IO (SymBV sym w) |
Rotate right. The rotate amount is treated as an unsigned value.
bvZext :: (1 <= u, (u + 1) <= r) => sym -> NatRepr r -> SymBV sym u -> IO (SymBV sym r) Source #
Zero-extend a bitvector.
bvSext :: (1 <= u, (u + 1) <= r) => sym -> NatRepr r -> SymBV sym u -> IO (SymBV sym r) Source #
Sign-extend a bitvector.
bvTrunc :: (1 <= r, (r + 1) <= w) => sym -> NatRepr r -> SymBV sym w -> IO (SymBV sym r) Source #
Truncate a bitvector.
bvAndBits :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Bitwise logical and.
bvOrBits :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Bitwise logical or.
bvXorBits :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w) Source #
Bitwise logical exclusive or.
bvNotBits :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w) Source #
Bitwise complement.
:: 1 <= w | |
=> sym | Symbolic interface |
-> SymBV sym w | Bitvector to update |
-> Natural | 0-based index to set |
-> Pred sym | Predicate to set. |
-> IO (SymBV sym w) |
bvSet sym v i p
returns a bitvector v'
where bit i
of v'
is set to
p
, and the bits at the other indices are the same as in v
.
:: 1 <= w | |
=> sym | symbolic interface |
-> NatRepr w | output bitvector width |
-> Pred sym | predicate to fill the bitvector with |
-> IO (SymBV sym w) |
bvFill sym w p
returns a bitvector w
-bits long where every bit
is given by the boolean value of p
.
minUnsignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w) Source #
Return the bitvector of the desired width with all 0 bits; this is the minimum unsigned integer.
maxUnsignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w) Source #
Return the bitvector of the desired width with all bits set; this is the maximum unsigned integer.
maxSignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w) Source #
Return the bitvector representing the largest 2's complement signed integer of the given width. This consists of all bits set except the MSB.
minSignedBV :: 1 <= w => sym -> NatRepr w -> IO (SymBV sym w) Source #
Return the bitvector representing the smallest 2's complement signed integer of the given width. This consists of all 0 bits except the MSB, which is set.
bvPopcount :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w) Source #
Return the number of 1 bits in the input.
bvCountLeadingZeros :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w) Source #
Return the number of consecutive 0 bits in the input, starting from the most significant bit position. If the input is zero, all bits are counted as leading.
bvCountTrailingZeros :: 1 <= w => sym -> SymBV sym w -> IO (SymBV sym w) Source #
Return the number of consecutive 0 bits in the input, starting from the least significant bit position. If the input is zero, all bits are counted as leading.
addUnsignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w) Source #
Unsigned add with overflow bit.
addSignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w) Source #
Signed add with overflow bit. Overflow is true if positive + positive = negative, or if negative + negative = positive.
subUnsignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w) Source #
Unsigned subtract with overflow bit. Overflow is true if x < y.
subSignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w) Source #
Signed subtract with overflow bit. Overflow is true if positive - negative = negative, or if negative - positive = positive.
carrylessMultiply :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym (w + w)) Source #
Compute the carryless multiply of the two input bitvectors. This operation is essentially the same as a standard multiply, except that the partial addends are simply XOR'd together instead of using a standard adder. This operation is useful for computing on GF(2^n) polynomials.
unsignedWideMultiplyBV :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w, SymBV sym w) Source #
unsignedWideMultiplyBV sym x y
multiplies two unsigned w
bit numbers x
and y
.
It returns a pair containing the top w
bits as the first element, and the
lower w
bits as the second element.
mulUnsignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w) Source #
Compute the unsigned multiply of two values with overflow bit.
signedWideMultiplyBV :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w, SymBV sym w) Source #
signedWideMultiplyBV sym x y
multiplies two signed w
bit numbers x
and y
.
It returns a pair containing the top w
bits as the first element, and the
lower w
bits as the second element.
mulSignedOF :: 1 <= w => sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym, SymBV sym w) Source #
Compute the signed multiply of two values with overflow bit.
mkStruct :: sym -> Assignment (SymExpr sym) flds -> IO (SymStruct sym flds) Source #
Create a struct from an assignment of expressions.
structField :: sym -> SymStruct sym flds -> Index flds tp -> IO (SymExpr sym tp) Source #
Get the value of a specific field in a struct.
structEq :: forall flds. sym -> SymStruct sym flds -> SymStruct sym flds -> IO (Pred sym) Source #
Check if two structs are equal.
structIte :: sym -> Pred sym -> SymStruct sym flds -> SymStruct sym flds -> IO (SymStruct sym flds) Source #
Take the if-then-else of two structures.
:: sym | |
-> Assignment BaseTypeRepr (idx ::> tp) | Index type |
-> SymExpr sym b | Constant |
-> IO (SymArray sym (idx ::> tp) b) |
Create an array where each element has the same value.
arrayFromFn :: sym -> SymFn sym (idx ::> itp) ret -> IO (SymArray sym (idx ::> itp) ret) Source #
Create an array from an arbitrary symbolic function.
Arrays created this way can typically not be compared for equality when provided to backend solvers.
arrayMap :: sym -> SymFn sym (ctx ::> d) r -> Assignment (ArrayResultWrapper (SymExpr sym) (idx ::> itp)) (ctx ::> d) -> IO (SymArray sym (idx ::> itp) r) Source #
Create an array by mapping a function over one or more existing arrays.
arrayUpdate :: sym -> SymArray sym (idx ::> tp) b -> Assignment (SymExpr sym) (idx ::> tp) -> SymExpr sym b -> IO (SymArray sym (idx ::> tp) b) Source #
Update an array at a specific location.
arrayLookup :: sym -> SymArray sym (idx ::> tp) b -> Assignment (SymExpr sym) (idx ::> tp) -> IO (SymExpr sym b) Source #
Return element in array.
:: sym | |
-> Assignment BaseTypeRepr (idx ::> itp) | Types for indices |
-> ArrayUpdateMap (SymExpr sym) (idx ::> itp) tp | Value for known indices. |
-> SymExpr sym tp | Value for other entries. |
-> IO (SymArray sym (idx ::> itp) tp) |
Create an array from a map of concrete indices to values.
This is implemented, but designed to be overridden for efficiency.
:: sym | |
-> ArrayUpdateMap (SymExpr sym) (idx ::> itp) tp | Value for known indices. |
-> SymArray sym (idx ::> itp) tp | Value for existing array. |
-> IO (SymArray sym (idx ::> itp) tp) |
Update an array at specific concrete indices.
This is implemented, but designed to be overriden for efficiency.
arrayIte :: sym -> Pred sym -> SymArray sym idx b -> SymArray sym idx b -> IO (SymArray sym idx b) Source #
If-then-else applied to arrays.
arrayEq :: sym -> SymArray sym idx b -> SymArray sym idx b -> IO (Pred sym) Source #
Return true if two arrays are equal.
Note that in the backend, arrays do not have a fixed number of elements, so this equality requires that arrays are equal on all elements.
allTrueEntries :: sym -> SymArray sym idx BaseBoolType -> IO (Pred sym) Source #
Return true if all entries in the array are true.
:: sym | |
-> SymFn sym (idx ::> itp) BaseBoolType | Predicate that indicates if array should be true. |
-> SymArray sym (idx ::> itp) BaseBoolType | |
-> IO (Pred sym) |
Return true if the array has the value true at every index satisfying the given predicate.
natToInteger :: sym -> SymNat sym -> IO (SymInteger sym) Source #
Convert a natural number to an integer.
integerToReal :: sym -> SymInteger sym -> IO (SymReal sym) Source #
Convert an integer to a real number.
bvToNat :: 1 <= w => sym -> SymBV sym w -> IO (SymNat sym) Source #
Convert the unsigned value of a bitvector to a natural.
bvToInteger :: 1 <= w => sym -> SymBV sym w -> IO (SymInteger sym) Source #
Return the unsigned value of the given bitvector as an integer.
sbvToInteger :: 1 <= w => sym -> SymBV sym w -> IO (SymInteger sym) Source #
Return the signed value of the given bitvector as an integer.
predToBV :: 1 <= w => sym -> Pred sym -> NatRepr w -> IO (SymBV sym w) Source #
Return 1
if the predicate is true; 0
otherwise.
natToReal :: sym -> SymNat sym -> IO (SymReal sym) Source #
Convert a natural number to a real number.
uintToReal :: 1 <= w => sym -> SymBV sym w -> IO (SymReal sym) Source #
Convert an unsigned bitvector to a real number.
sbvToReal :: 1 <= w => sym -> SymBV sym w -> IO (SymReal sym) Source #
Convert an signed bitvector to a real number.
realRound :: sym -> SymReal sym -> IO (SymInteger sym) Source #
Round a real number to an integer.
Numbers are rounded to the nearest integer, with rounding away from zero when two integers are equi-distant (e.g., 1.5 rounds to 2).
realRoundEven :: sym -> SymReal sym -> IO (SymInteger sym) Source #
Round a real number to an integer.
Numbers are rounded to the neareset integer, with rounding toward even values when two integers are equi-distant (e.g., 2.5 rounds to 2).
realFloor :: sym -> SymReal sym -> IO (SymInteger sym) Source #
Round down to the nearest integer that is at most this value.
realCeil :: sym -> SymReal sym -> IO (SymInteger sym) Source #
Round up to the nearest integer that is at least this value.
realTrunc :: sym -> SymReal sym -> IO (SymInteger sym) Source #
Round toward zero. This is floor(x)
when x is positive
and celing(x)
when x
is negative.
integerToBV :: 1 <= w => sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w) Source #
Convert an integer to a bitvector. The result is the unique bitvector
whose value (signed or unsigned) is congruent to the input integer, modulo 2^w
.
This operation has the following properties:
* bvToInteger (integerToBv x w) == mod x (2^w)
* bvToInteger (integerToBV x w) == x
when 0 <= x < 2^w
.
* sbvToInteger (integerToBV x w) == mod (x + 2^(w-1)) (2^w) - 2^(w-1)
* sbvToInteger (integerToBV x w) == x
when -2^(w-1) <= x < 2^(w-1)
* integerToBV (bvToInteger y) w == y
when y
is a SymBV sym w
* integerToBV (sbvToInteger y) w == y
when y
is a SymBV sym w
integerToNat :: sym -> SymInteger sym -> IO (SymNat sym) Source #
Convert an integer to a natural number.
For negative integers, the result is undefined.
realToInteger :: sym -> SymReal sym -> IO (SymInteger sym) Source #
Convert a real number to an integer.
The result is undefined if the given real number does not represent an integer.
realToNat :: sym -> SymReal sym -> IO (SymNat sym) Source #
Convert a real number to a natural number.
The result is undefined if the given real number does not represent a natural number.
realToBV :: 1 <= w => sym -> SymReal sym -> NatRepr w -> IO (SymBV sym w) Source #
Convert a real number to an unsigned bitvector.
Numbers are rounded to the nearest representable number, with rounding away from zero when two integers are equi-distant (e.g., 1.5 rounds to 2). When the real is negative the result is zero.
realToSBV :: 1 <= w => sym -> SymReal sym -> NatRepr w -> IO (SymBV sym w) Source #
Convert a real number to a signed bitvector.
Numbers are rounded to the nearest representable number, with rounding away from zero when two integers are equi-distant (e.g., 1.5 rounds to 2).
clampedIntToSBV :: 1 <= w => sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w) Source #
Convert an integer to the nearest signed bitvector.
Numbers are rounded to the nearest representable number.
clampedIntToBV :: 1 <= w => sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w) Source #
Convert an integer to the nearest unsigned bitvector.
Numbers are rounded to the nearest representable number.
intSetWidth :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n) Source #
Convert a signed bitvector to the nearest signed bitvector with the given width. If the resulting width is smaller, this clamps the value to min-int or max-int when necessary.
uintSetWidth :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n) Source #
Convert an unsigned bitvector to the nearest unsigned bitvector with the given width (clamp on overflow).
intToUInt :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n) Source #
Convert an signed bitvector to the nearest unsigned bitvector with the given width (clamp on overflow).
uintToInt :: (1 <= m, 1 <= n) => sym -> SymBV sym m -> NatRepr n -> IO (SymBV sym n) Source #
Convert an unsigned bitvector to the nearest signed bitvector with the given width (clamp on overflow).
stringEmpty :: sym -> StringInfoRepr si -> IO (SymString sym si) Source #
Create an empty string literal
stringLit :: sym -> StringLiteral si -> IO (SymString sym si) Source #
Create a concrete string literal
stringEq :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym) Source #
Check the equality of two strings
stringIte :: sym -> Pred sym -> SymString sym si -> SymString sym si -> IO (SymString sym si) Source #
If-then-else on strings
stringConcat :: sym -> SymString sym si -> SymString sym si -> IO (SymString sym si) Source #
Concatenate two strings
stringContains :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym) Source #
Test if the first string contains the second string as a substring
stringIsPrefixOf :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym) Source #
Test if the first string is a prefix of the second string
stringIsSuffixOf :: sym -> SymString sym si -> SymString sym si -> IO (Pred sym) Source #
Test if the first string is a suffix of the second string
stringIndexOf :: sym -> SymString sym si -> SymString sym si -> SymNat sym -> IO (SymInteger sym) Source #
Return the first position at which the second string can be found as a substring in the first string, starting from the given index. If no such position exists, return a negative value.
stringLength :: sym -> SymString sym si -> IO (SymNat sym) Source #
Compute the length of a string
stringSubstring :: sym -> SymString sym si -> SymNat sym -> SymNat sym -> IO (SymString sym si) Source #
stringSubstring s off len
extracts the substring of s
starting at index off
and
having length len
. The result of this operation is undefined if off
and len
do not specify a valid substring of s
; in particular, we must have off+len <= length(s)
.
realZero :: sym -> SymReal sym Source #
Return real number 0.
realLit :: sym -> Rational -> IO (SymReal sym) Source #
Create a constant real literal.
sciLit :: sym -> Scientific -> IO (SymReal sym) Source #
Make a real literal from a scientific value. May be overridden if we want to avoid the overhead of converting scientific value to rational.
realEq :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym) Source #
Check equality of two real numbers.
realNe :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym) Source #
Check non-equality of two real numbers.
realLe :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym) Source #
Check <=
on two real numbers.
realLt :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym) Source #
Check <
on two real numbers.
realGe :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym) Source #
Check >=
on two real numbers.
realGt :: sym -> SymReal sym -> SymReal sym -> IO (Pred sym) Source #
Check >
on two real numbers.
realIte :: sym -> Pred sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
If-then-else on real numbers.
realNeg :: sym -> SymReal sym -> IO (SymReal sym) Source #
Negate a real number.
realAdd :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
Add two real numbers.
realMul :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
Multiply two real numbers.
realSub :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
Subtract one real from another.
realSq :: sym -> SymReal sym -> IO (SymReal sym) Source #
realSq sym x
returns x * x
.
realDiv :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
realDiv sym x y
returns term equivalent to x/y
.
The result is undefined when y
is zero.
realMod :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
realMod x y
returns the value of x - y * floor(x / y)
when
y
is not zero and x
when y
is zero.
isInteger :: sym -> SymReal sym -> IO (Pred sym) Source #
Predicate that holds if the real number is an exact integer.
realIsNonNeg :: sym -> SymReal sym -> IO (Pred sym) Source #
Return true if the real is non-negative.
realSqrt :: sym -> SymReal sym -> IO (SymReal sym) Source #
realSqrt sym x
returns sqrt(x). Result is undefined
if x
is negative.
realAtan2 :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
realAtan2 sym y x
returns the arctangent of y/x
with a range
of -pi
to pi
; this corresponds to the angle between the positive
x-axis and the line from the origin (x,y)
.
When x
is 0
this returns pi/2 * sgn y
.
When x
and y
are both zero, this function is undefined.
realPi :: sym -> IO (SymReal sym) Source #
Return value denoting pi.
realLog :: sym -> SymReal sym -> IO (SymReal sym) Source #
Natural logarithm. realLog x
is undefined
for x <= 0
.
realExp :: sym -> SymReal sym -> IO (SymReal sym) Source #
Natural exponentiation
realSin :: sym -> SymReal sym -> IO (SymReal sym) Source #
Sine trig function
realCos :: sym -> SymReal sym -> IO (SymReal sym) Source #
Cosine trig function
realTan :: sym -> SymReal sym -> IO (SymReal sym) Source #
Tangent trig function. realTan x
is undefined
when cos x = 0
, i.e., when x = pi/2 + k*pi
for
some integer k
.
realSinh :: sym -> SymReal sym -> IO (SymReal sym) Source #
Hyperbolic sine
realCosh :: sym -> SymReal sym -> IO (SymReal sym) Source #
Hyperbolic cosine
realTanh :: sym -> SymReal sym -> IO (SymReal sym) Source #
Hyperbolic tangent
realAbs :: sym -> SymReal sym -> IO (SymReal sym) Source #
Return absolute value of the real number.
realHypot :: sym -> SymReal sym -> SymReal sym -> IO (SymReal sym) Source #
realHypot x y
returns sqrt(x^2 + y^2).
floatPZero :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp) Source #
Return floating point number +0
.
floatNZero :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp) Source #
Return floating point number -0
.
floatNaN :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp) Source #
Return floating point NaN.
floatPInf :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp) Source #
Return floating point +infinity
.
floatNInf :: sym -> FloatPrecisionRepr fpp -> IO (SymFloat sym fpp) Source #
Return floating point -infinity
.
floatLit :: sym -> FloatPrecisionRepr fpp -> Rational -> IO (SymFloat sym fpp) Source #
Create a floating point literal from a rational literal.
floatNeg :: sym -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Negate a floating point number.
floatAbs :: sym -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Return the absolute value of a floating point number.
floatSqrt :: sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Compute the square root of a floating point number.
floatAdd :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Add two floating point numbers.
floatSub :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Subtract two floating point numbers.
floatMul :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Multiply two floating point numbers.
floatDiv :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Divide two floating point numbers.
floatRem :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Compute the reminder: x - y * n
, where n
in Z is nearest to x / y
.
floatMin :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Return the min of two floating point numbers.
floatMax :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Return the max of two floating point numbers.
floatFMA :: sym -> RoundingMode -> SymFloat sym fpp -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Compute the fused multiplication and addition: (x * y) + z
.
floatEq :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check logical equality of two floating point numbers.
NOTE! This does NOT accurately represent the equality test on floating point
values typically found in programming languages. See floatFpEq
instead.
floatNe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check logical non-equality of two floating point numbers.
NOTE! This does NOT accurately represent the non-equality test on floating point
values typically found in programming languages. See floatFpEq
instead.
floatFpEq :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check IEEE-754 equality of two floating point numbers.
NOTE! This test returns false if either value is NaN
; in particular
NaN
is not equal to itself! Moreover, positive and negative 0 will
compare equal, despite having different bit patterns.
This test is most appropriate for interpreting the equality tests of
typical languages using floating point. Moreover, not-equal tests
are usually the negation of this test, rather than the floatFpNe
test below.
floatFpNe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check IEEE-754 non-equality of two floating point numbers.
NOTE! This test returns false if either value is NaN
; in particular
NaN
is not distinct from any other value! Moreover, positive and
negative 0 will not compare distinct, despite having different
bit patterns.
This test usually does NOT correspond to the not-equal tests found
in programming languages. Instead, one generally takes the logical
negation of the floatFpEq
test.
floatLe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check IEEE-754 <=
on two floating point numbers.
NOTE! This test returns false if either value is NaN
; in particular
NaN
is not less-than-or-equal-to any other value! Moreover, positive
and negative 0 are considered equal, despite having different bit patterns.
floatLt :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check IEEE-754 <
on two floating point numbers.
NOTE! This test returns false if either value is NaN
; in particular
NaN
is not less-than any other value! Moreover, positive
and negative 0 are considered equal, despite having different bit patterns.
floatGe :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check IEEE-754 >=
on two floating point numbers.
NOTE! This test returns false if either value is NaN
; in particular
NaN
is not greater-than-or-equal-to any other value! Moreover, positive
and negative 0 are considered equal, despite having different bit patterns.
floatGt :: sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym) Source #
Check IEEE-754 >
on two floating point numbers.
NOTE! This test returns false if either value is NaN
; in particular
NaN
is not greater-than any other value! Moreover, positive
and negative 0 are considered equal, despite having different bit patterns.
floatIsNaN :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floating-point value is NaN.
floatIsInf :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floating-point value is (positive or negative) infinity.
floatIsZero :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floaint-point value is (positive or negative) zero.
floatIsPos :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floaint-point value is positive. NOTE! NaN is considered neither positive nor negative.
floatIsNeg :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floaint-point value is negative. NOTE! NaN is considered neither positive nor negative.
floatIsSubnorm :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floaint-point value is subnormal.
floatIsNorm :: sym -> SymFloat sym fpp -> IO (Pred sym) Source #
Test if a floaint-point value is normal.
floatIte :: sym -> Pred sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
If-then-else on floating point numbers.
floatCast :: sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymFloat sym fpp' -> IO (SymFloat sym fpp) Source #
Change the precision of a floating point number.
floatRound :: sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp) Source #
Round a floating point number to an integral value.
floatFromBinary :: (2 <= eb, 2 <= sb) => sym -> FloatPrecisionRepr (FloatingPointPrecision eb sb) -> SymBV sym (eb + sb) -> IO (SymFloat sym (FloatingPointPrecision eb sb)) Source #
Convert from binary representation in IEEE 754-2008 format to floating point.
floatToBinary :: (2 <= eb, 2 <= sb) => sym -> SymFloat sym (FloatingPointPrecision eb sb) -> IO (SymBV sym (eb + sb)) Source #
Convert from floating point from to the binary representation in IEEE 754-2008 format.
NOTE! NaN
has multiple representations, i.e. all bit patterns where
the exponent is 0b1..1
and the significant is not 0b0..0
.
This functions returns the representation of positive "quiet" NaN
,
i.e. the bit pattern where the sign is 0b0
, the exponent is 0b1..1
,
and the significant is 0b10..0
.
bvToFloat :: 1 <= w => sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymBV sym w -> IO (SymFloat sym fpp) Source #
Convert a unsigned bitvector to a floating point number.
sbvToFloat :: 1 <= w => sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymBV sym w -> IO (SymFloat sym fpp) Source #
Convert a signed bitvector to a floating point number.
realToFloat :: sym -> FloatPrecisionRepr fpp -> RoundingMode -> SymReal sym -> IO (SymFloat sym fpp) Source #
Convert a real number to a floating point number.
floatToBV :: 1 <= w => sym -> NatRepr w -> RoundingMode -> SymFloat sym fpp -> IO (SymBV sym w) Source #
Convert a floating point number to a unsigned bitvector.
floatToSBV :: 1 <= w => sym -> NatRepr w -> RoundingMode -> SymFloat sym fpp -> IO (SymBV sym w) Source #
Convert a floating point number to a signed bitvector.
floatToReal :: sym -> SymFloat sym fpp -> IO (SymReal sym) Source #
Convert a floating point number to a real number.
mkComplex :: sym -> Complex (SymReal sym) -> IO (SymCplx sym) Source #
Create a complex from cartesian coordinates.
getRealPart :: sym -> SymCplx sym -> IO (SymReal sym) Source #
getRealPart x
returns the real part of x
.
getImagPart :: sym -> SymCplx sym -> IO (SymReal sym) Source #
getImagPart x
returns the imaginary part of x
.
cplxGetParts :: sym -> SymCplx sym -> IO (Complex (SymReal sym)) Source #
Convert a complex number into the real and imaginary part.
mkComplexLit :: sym -> Complex Rational -> IO (SymCplx sym) Source #
Create a constant complex literal.
cplxFromReal :: sym -> SymReal sym -> IO (SymCplx sym) Source #
Create a complex from a real value.
cplxIte :: sym -> Pred sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym) Source #
If-then-else on complex values.
cplxNeg :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
Negate a complex number.
cplxAdd :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym) Source #
Add two complex numbers together.
cplxSub :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym) Source #
Subtract one complex number from another.
cplxMul :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym) Source #
Multiply two complex numbers together.
cplxMag :: sym -> SymCplx sym -> IO (SymReal sym) Source #
Compute the magnitude of a complex number.
cplxSqrt :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
Return the principal square root of a complex number.
cplxSin :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
Compute sine of a complex number.
cplxCos :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
Compute cosine of a complex number.
cplxTan :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
Compute tangent of a complex number. cplxTan x
is undefined
when cplxCos x
is 0
, which occurs only along the real line
in the same conditions where realCos x
is 0
.
cplxHypot :: sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym) Source #
hypotCplx x y
returns sqrt(abs(x)^2 + abs(y)^2)
.
cplxRound :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
roundCplx x
rounds complex number to nearest integer.
Numbers with a fractional part of 0.5 are rounded away from 0.
Imaginary and real parts are rounded independently.
cplxFloor :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
cplxFloor x
rounds to nearest integer less than or equal to x.
Imaginary and real parts are rounded independently.
cplxCeil :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
cplxCeil x
rounds to nearest integer greater than or equal to x.
Imaginary and real parts are rounded independently.
cplxConj :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
conjReal x
returns the complex conjugate of the input.
cplxExp :: sym -> SymCplx sym -> IO (SymCplx sym) Source #
Returns exponential of a complex number.
cplxEq :: sym -> SymCplx sym -> SymCplx sym -> IO (Pred sym) Source #
Check equality of two complex numbers.
cplxNe :: sym -> SymCplx sym -> SymCplx sym -> IO (Pred sym) Source #
Check non-equality of two complex numbers.
Instances
class (IsExprBuilder sym, IsSymFn (SymFn sym), OrdF (SymExpr sym)) => IsSymExprBuilder sym where Source #
This extends the interface for building expressions with operations for creating new symbolic constants and functions.
freshConstant, freshLatch, freshBoundedBV, freshBoundedSBV, freshBoundedNat, freshBoundedInt, freshBoundedReal, freshBoundVar, varExpr, forallPred, existsPred, definedFn, freshTotalUninterpFn, applySymFn
freshConstant :: sym -> SolverSymbol -> BaseTypeRepr tp -> IO (SymExpr sym tp) Source #
Create a fresh top-level uninterpreted constant.
freshLatch :: sym -> SolverSymbol -> BaseTypeRepr tp -> IO (SymExpr sym tp) Source #
Create a fresh latch variable.
freshBoundedBV :: 1 <= w => sym -> SolverSymbol -> NatRepr w -> Maybe Natural -> Maybe Natural -> IO (SymBV sym w) Source #
Create a fresh bitvector value with optional upper and lower bounds (which bound the unsigned value of the bitvector).
freshBoundedSBV :: 1 <= w => sym -> SolverSymbol -> NatRepr w -> Maybe Integer -> Maybe Integer -> IO (SymBV sym w) Source #
Create a fresh bitvector value with optional upper and lower bounds (which bound the signed value of the bitvector)
freshBoundedNat :: sym -> SolverSymbol -> Maybe Natural -> Maybe Natural -> IO (SymNat sym) Source #
Create a fresh natural number constant with optional upper and lower bounds. If provided, the bounds are inclusive.
freshBoundedInt :: sym -> SolverSymbol -> Maybe Integer -> Maybe Integer -> IO (SymInteger sym) Source #
Create a fresh integer constant with optional upper and lower bounds. If provided, the bounds are inclusive.
freshBoundedReal :: sym -> SolverSymbol -> Maybe Rational -> Maybe Rational -> IO (SymReal sym) Source #
Create a fresh real constant with optional upper and lower bounds. If provided, the bounds are inclusive.
freshBoundVar :: sym -> SolverSymbol -> BaseTypeRepr tp -> IO (BoundVar sym tp) Source #
Creates a bound variable.
This will be treated as a free constant when appearing inside asserted expressions. These are intended to be bound using quantifiers or symbolic functions.
varExpr :: sym -> BoundVar sym tp -> SymExpr sym tp Source #
Return an expression that references the bound variable.
forallPred :: sym -> BoundVar sym tp -> Pred sym -> IO (Pred sym) Source #
forallPred sym v e
returns an expression that repesents forall v . e
.
Throws a user error if bound var has already been used in a quantifier.
existsPred :: sym -> BoundVar sym tp -> Pred sym -> IO (Pred sym) Source #
existsPred sym v e
returns an expression that repesents exists v . e
.
Throws a user error if bound var has already been used in a quantifier.
:: sym | Symbolic interface |
-> SolverSymbol | The name to give a function (need not be unique) |
-> Assignment (BoundVar sym) args | Bound variables to use as arguments for function. |
-> SymExpr sym ret | Operation defining result of defined function. |
-> UnfoldPolicy | Policy for unfolding on applications |
-> IO (SymFn sym args ret) |
Return a function defined by an expression over bound variables. The predicate argument allows the user to specify when an application of the function should be unfolded and evaluated, e.g. to perform constant folding.
:: CurryAssignmentClass args | |
=> sym | Symbolic interface |
-> SolverSymbol | The name to give a function (need not be unique) |
-> Assignment BaseTypeRepr args | Type signature for the arguments |
-> UnfoldPolicy | Policy for unfolding on applications |
-> CurryAssignment args (SymExpr sym) (IO (SymExpr sym ret)) | Operation defining result of defined function. |
-> IO (SymFn sym args ret) |
Return a function defined by Haskell computation over symbolic expressions.
:: sym | Symbolic interface |
-> SolverSymbol | The name to give a function (need not be unique) |
-> Assignment BaseTypeRepr args | Types of arguments expected by function |
-> BaseTypeRepr ret | Return type of function |
-> IO (SymFn sym args ret) |
Create a new uninterpreted function.
:: sym | Symbolic interface |
-> SymFn sym args ret | Function to call |
-> Assignment (SymExpr sym) args | Arguments to function |
-> IO (SymExpr sym ret) |
Apply a set of arguments to a symbolic function.
Instances
data SolverEvent Source #
This datatype describes events that involve interacting with
solvers. A SolverEvent
will be provided to the action
installed via setSolverLogListener
whenever an interesting
event occurs.
SolverStartSATQuery | |
| |
SolverEndSATQuery | |
|
Instances
Bitvector operations
bvJoinVector :: forall sym n w. (1 <= w, IsExprBuilder sym) => sym -> NatRepr w -> Vector n (SymBV sym w) -> IO (SymBV sym (n * w)) Source #
Join a Vector
of smaller bitvectors.
bvSplitVector :: forall sym n w. (IsExprBuilder sym, 1 <= w, 1 <= n) => sym -> NatRepr n -> NatRepr w -> SymBV sym (n * w) -> IO (Vector n (SymBV sym w)) Source #
Split a bitvector to a Vector
of smaller bitvectors.
:: (1 <= n, IsExprBuilder sym) | |
=> sym | Symbolic interface |
-> NatRepr n | |
-> SymBV sym (n * 8) | Bitvector to swap around |
-> IO (SymBV sym (n * 8)) |
Implement LLVM's "bswap" intrinsic
See <https://llvm.org/docs/LangRef.html#llvm-bswap-intrinsics
the LLVM bswap
documentation.>
This is the implementation in SawCore:
llvmBSwap :: (n :: Nat) -> bitvector (mulNat n 8) -> bitvector (mulNat n 8); llvmBSwap n x = join n 8 Bool (reverse n (bitvector 8) (split n 8 Bool x));
bvBitreverse :: forall sym w. (1 <= w, IsExprBuilder sym) => sym -> SymBV sym w -> IO (SymBV sym w) Source #
Swap the order of the bits in a bitvector.
Floating-point rounding modes
data RoundingMode Source #
Rounding modes for IEEE-754 floating point operations.
RNE | Round to nearest even. |
RNA | Round to nearest away. |
RTP | Round toward plus Infinity. |
RTN | Round toward minus Infinity. |
RTZ | Round toward zero. |
Instances
Run-time statistics
data Statistics Source #
Statistics gathered on a running expression builder. See
getStatistics
.
Statistics | |
|
Instances
Show Statistics Source # | |
Defined in What4.Interface showsPrec :: Int -> Statistics -> ShowS # show :: Statistics -> String # showList :: [Statistics] -> ShowS # |
Type Aliases
type Pred sym = SymExpr sym BaseBoolType Source #
type SymNat sym = SymExpr sym BaseNatType Source #
Symbolic natural numbers.
type SymInteger sym = SymExpr sym BaseIntegerType Source #
Symbolic integers.
type SymReal sym = SymExpr sym BaseRealType Source #
Symbolic real numbers.
type SymFloat sym fpp = SymExpr sym (BaseFloatType fpp) Source #
Symbolic floating point numbers.
type SymString sym si = SymExpr sym (BaseStringType si) Source #
Symbolic strings.
type SymCplx sym = SymExpr sym BaseComplexType Source #
Symbolic complex numbers.
type SymStruct sym flds = SymExpr sym (BaseStructType flds) Source #
Symbolic structures.
type SymBV sym n = SymExpr sym (BaseBVType n) Source #
Symbolic bitvectors.
type SymArray sym idx b = SymExpr sym (BaseArrayType idx b) Source #
Symbolic arrays.
Array utility types
data IndexLit idx where Source #
This represents a concrete index value, and is used for creating arrays.
NatIndexLit :: !Natural -> IndexLit BaseNatType | |
BVIndexLit :: 1 <= w => !(NatRepr w) -> !(BV w) -> IndexLit (BaseBVType w) |
indexLit :: IsExprBuilder sym => sym -> IndexLit idx -> IO (SymExpr sym idx) Source #
Create a literal from an IndexLit
.
newtype ArrayResultWrapper f idx tp Source #
ArrayResultWrapper | |
|
Instances
TestEquality f => TestEquality (ArrayResultWrapper f idx :: BaseType -> Type) Source # | |
Defined in What4.Interface testEquality :: ArrayResultWrapper f idx a -> ArrayResultWrapper f idx b -> Maybe (a :~: b) # | |
HashableF e => HashableF (ArrayResultWrapper e idx :: BaseType -> Type) Source # | |
Defined in What4.Interface hashWithSaltF :: Int -> ArrayResultWrapper e idx tp -> Int # hashF :: ArrayResultWrapper e idx tp -> Int # |
Concrete values
asConcrete :: IsExpr e => e tp -> Maybe (ConcreteVal tp) Source #
Return a concrete representation of a value, if it is concrete.
concreteToSym :: IsExprBuilder sym => sym -> ConcreteVal tp -> IO (SymExpr sym tp) Source #
Create a literal symbolic value from a concrete value.
baseIsConcrete :: forall e bt. IsExpr e => e bt -> Bool Source #
This returns true if the value corresponds to a concrete value.
baseDefaultValue :: forall sym bt. IsExprBuilder sym => sym -> BaseTypeRepr bt -> IO (SymExpr sym bt) Source #
realExprAsInteger :: (IsExpr e, MonadFail m) => e BaseRealType -> m Integer Source #
Return value as a constant integer if it exists.
rationalAsInteger :: MonadFail m => Rational -> m Integer Source #
Return value as a constant integer if it exists.
cplxExprAsRational :: (MonadFail m, IsExpr e) => e BaseComplexType -> m Rational Source #
Extract the value of a complex expression, which is assumed to be a constant real number. Fail if the number has nonzero imaginary component, or if it is not a constant.
cplxExprAsInteger :: (MonadFail m, IsExpr e) => e BaseComplexType -> m Integer Source #
Return a complex value as a constant integer if it exists.
SymEncoder
data SymEncoder sym v tp Source #
This provides an interface for converting between Haskell values and a solver representation.
SymEncoder | |
|
Utilitity combinators
Boolean operations
backendPred :: IsExprBuilder sym => sym -> Bool -> Pred sym Source #
Return predicate equivalent to a Boolean.
andAllOf :: IsExprBuilder sym => sym -> Fold s (Pred sym) -> s -> IO (Pred sym) Source #
Compute the conjunction of a sequence of predicates.
orOneOf :: IsExprBuilder sym => sym -> Fold s (Pred sym) -> s -> IO (Pred sym) Source #
Compute the disjunction of a sequence of predicates.
itePredM :: (IsExpr (SymExpr sym), IsExprBuilder sym, MonadIO m) => sym -> Pred sym -> m (Pred sym) -> m (Pred sym) -> m (Pred sym) Source #
Perform an ite on a predicate lazily.
iteM :: IsExprBuilder sym => (sym -> Pred sym -> v -> v -> IO v) -> sym -> Pred sym -> IO v -> IO v -> IO v Source #
predToReal :: IsExprBuilder sym => sym -> Pred sym -> IO (SymReal sym) Source #
Return 1 if the predicate is true; 0 otherwise.
Complex number operations
cplxDiv :: IsExprBuilder sym => sym -> SymCplx sym -> SymCplx sym -> IO (SymCplx sym) Source #
Divide one number by another.
cplxDiv x y
is undefined when y
is 0
.
cplxLog :: IsExprBuilder sym => sym -> SymCplx sym -> IO (SymCplx sym) Source #
Returns the principal logarithm of the input value.
cplxLog x
is undefined when x
is 0
, and has a
cut discontinuity along the negative real line.
:: IsExprBuilder sym | |
=> Rational | Base for the logarithm |
-> sym | |
-> SymCplx sym | |
-> IO (SymCplx sym) |
Returns logarithm of input at a given base.
cplxLogBase b x
is undefined when x
is 0
.
mkRational :: IsExprBuilder sym => sym -> Rational -> IO (SymCplx sym) Source #
Create a value from a rational.
mkReal :: (IsExprBuilder sym, Real a) => sym -> a -> IO (SymCplx sym) Source #
Create a value from an integer.
isNonZero :: IsExprBuilder sym => sym -> SymCplx sym -> IO (Pred sym) Source #
Return predicate that holds if value is non-zero.
isReal :: IsExprBuilder sym => sym -> SymCplx sym -> IO (Pred sym) Source #
Return predicate that holds if imaginary part of number is zero.
Indexing
:: (IsExpr e, Monad m) | |
=> (Natural -> m (e BaseBoolType)) | Returns predicate that holds if we have found the value we are looking for. It is assumed that the predicate must hold for a unique integer in the range. |
-> (e BaseBoolType -> a -> a -> m a) | Ite function |
-> (Natural -> m a) | Function for concrete values |
-> Natural | Lower bound (inclusive) |
-> Natural | Upper bound (inclusive) |
-> m a |
This function is used for selecting a value from among potential values in a range.
muxRange p ite f l h
returns an expression denoting the value obtained
from the value f i
where i
is the smallest value in the range [l..h]
such that p i
is true. If p i
is true for no such value, then
this returns the value f h
.
Reexports
module Data.Parameterized.NatRepr
module What4.BaseTypes
class HasAbsValue f Source #
A utility class for values that contain abstract values
Instances
HasAbsValue (Expr t) Source # | |
Defined in What4.Expr.Builder getAbsValue :: Expr t tp -> AbstractValue tp Source # |
data SolverSymbol Source #
This represents a name known to the solver.
We have three types of symbols:
- The empty symbol
- A user symbol
- A system symbol
A user symbol should consist of a letter followed by any combination of letters, digits, and underscore characters. It also cannot be a reserved word in Yices or SMTLIB.
A system symbol should start with a letter followed by any number of letter, digit, underscore or an exclamation mark characters. It must contain at least one exclamation mark to distinguish itself from user symbols.
Instances
Eq SolverSymbol Source # | |
Defined in What4.Symbol (==) :: SolverSymbol -> SolverSymbol -> Bool # (/=) :: SolverSymbol -> SolverSymbol -> Bool # | |
Ord SolverSymbol Source # | |
Defined in What4.Symbol compare :: SolverSymbol -> SolverSymbol -> Ordering # (<) :: SolverSymbol -> SolverSymbol -> Bool # (<=) :: SolverSymbol -> SolverSymbol -> Bool # (>) :: SolverSymbol -> SolverSymbol -> Bool # (>=) :: SolverSymbol -> SolverSymbol -> Bool # max :: SolverSymbol -> SolverSymbol -> SolverSymbol # min :: SolverSymbol -> SolverSymbol -> SolverSymbol # | |
Show SolverSymbol Source # | |
Defined in What4.Symbol showsPrec :: Int -> SolverSymbol -> ShowS # show :: SolverSymbol -> String # showList :: [SolverSymbol] -> ShowS # | |
Hashable SolverSymbol Source # | |
Defined in What4.Symbol hashWithSalt :: Int -> SolverSymbol -> Int # hash :: SolverSymbol -> Int # |
emptySymbol :: SolverSymbol Source #
Return the empty symbol.
userSymbol :: String -> Either SolverSymbolError SolverSymbol Source #
This returns either a user symbol or the empty symbol if the string is empty.
safeSymbol :: String -> SolverSymbol Source #
Attempts to create a user symbol from the given string. If this fails for some reason, the string is Z-encoded into a system symbol instead with the prefix "zenc!".
data ValueRange tp Source #
Describes a range of values in a totally ordered set.
SingleRange !tp | Indicates that range denotes a single value |
MultiRange !(ValueBound tp) !(ValueBound tp) | Indicates that the number is somewhere between the given upper and lower bound. |
data StringLiteral (si :: StringInfo) :: Type where Source #
UnicodeLiteral :: !Text -> StringLiteral Unicode | |
Char8Literal :: !ByteString -> StringLiteral Char8 | |
Char16Literal :: !Word16String -> StringLiteral Char16 |
Instances
stringLiteralInfo :: StringLiteral si -> StringInfoRepr si Source #