{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wall -Werror -fno-warn-orphans #-}
module Data.SBV.Core.Model (
Mergeable(..), Equality(..), EqSymbolic(..), OrdSymbolic(..), SDivisible(..), Uninterpreted(..), Metric(..), minimize, maximize, assertWithPenalty, SIntegral, SFiniteBits(..)
, ite, iteLazy, sFromIntegral, sShiftLeft, sShiftRight, sRotateLeft, sBarrelRotateLeft, sRotateRight, sBarrelRotateRight, sSignedShiftArithRight, (.^)
, oneIf, genVar, genVar_, forall, forall_, exists, exists_
, pbAtMost, pbAtLeast, pbExactly, pbLe, pbGe, pbEq, pbMutexed, pbStronglyMutexed
, sBool, sBool_, sBools, sWord8, sWord8_, sWord8s, sWord16, sWord16_, sWord16s, sWord32, sWord32_, sWord32s
, sWord64, sWord64_, sWord64s, sInt8, sInt8_, sInt8s, sInt16, sInt16_, sInt16s, sInt32, sInt32_, sInt32s, sInt64, sInt64_
, sInt64s, sInteger, sInteger_, sIntegers, sReal, sReal_, sReals, sFloat, sFloat_, sFloats, sDouble, sDouble_, sDoubles
, sFPHalf, sFPHalf_, sFPHalfs, sFPBFloat, sFPBFloat_, sFPBFloats, sFPSingle, sFPSingle_, sFPSingles, sFPDouble, sFPDouble_, sFPDoubles, sFPQuad, sFPQuad_, sFPQuads
, sFloatingPoint, sFloatingPoint_, sFloatingPoints
, sChar, sChar_, sChars, sString, sString_, sStrings, sList, sList_, sLists
, sRational, sRational_, sRationals
, SymTuple, sTuple, sTuple_, sTuples
, sEither, sEither_, sEithers, sMaybe, sMaybe_, sMaybes
, sSet, sSet_, sSets
, solve
, slet
, sRealToSInteger, label, observe, observeIf, sObserve
, sAssert
, liftQRem, liftDMod, symbolicMergeWithKind
, genLiteral, genFromCV, genMkSymVar
, sbvQuickCheck
)
where
import Control.Applicative (ZipList(ZipList))
import Control.Monad (when, unless, mplus)
import Control.Monad.Trans (liftIO)
import Control.Monad.IO.Class (MonadIO)
import GHC.Generics (U1(..), M1(..), (:*:)(..), K1(..))
import qualified GHC.Generics as G
import GHC.Stack
import Data.Array (Array, Ix, listArray, elems, bounds, rangeSize)
import Data.Bits (Bits(..))
import Data.Char (toLower, isDigit)
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Kind (Type)
import Data.List (genericLength, genericIndex, genericTake, unzip4, unzip5, unzip6, unzip7, intercalate, isPrefixOf)
import Data.Maybe (fromMaybe, mapMaybe)
import Data.String (IsString(..))
import Data.Word (Word8, Word16, Word32, Word64)
import qualified Data.Set as Set
import Data.Proxy
import Data.Dynamic (fromDynamic, toDyn)
import Test.QuickCheck (Testable(..), Arbitrary(..))
import qualified Test.QuickCheck.Test as QC (isSuccess)
import qualified Test.QuickCheck as QC (quickCheckResult, counterexample)
import qualified Test.QuickCheck.Monadic as QC (monadicIO, run, assert, pre, monitor)
import qualified Data.Foldable as F (toList)
import Data.SBV.Core.AlgReals
import Data.SBV.Core.SizedFloats
import Data.SBV.Core.Data
import Data.SBV.Core.Symbolic
import Data.SBV.Core.Operations
import Data.SBV.Core.Kind
import Data.SBV.Provers.Prover (defaultSMTCfg, SafeResult(..), prove)
import Data.SBV.SMT.SMT (ThmResult, showModel)
import Data.SBV.Utils.Lib (isKString)
genVar :: MonadSymbolic m => VarContext -> Kind -> String -> m (SBV a)
genVar :: VarContext -> Kind -> String -> m (SBV a)
genVar VarContext
q Kind
k = VarContext -> Kind -> Maybe String -> m (SBV a)
forall a (m :: * -> *).
MonadSymbolic m =>
VarContext -> Kind -> Maybe String -> m (SBV a)
mkSymSBV VarContext
q Kind
k (Maybe String -> m (SBV a))
-> (String -> Maybe String) -> String -> m (SBV a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe String
forall a. a -> Maybe a
Just
genVar_ :: MonadSymbolic m => VarContext -> Kind -> m (SBV a)
genVar_ :: VarContext -> Kind -> m (SBV a)
genVar_ VarContext
q Kind
k = VarContext -> Kind -> Maybe String -> m (SBV a)
forall a (m :: * -> *).
MonadSymbolic m =>
VarContext -> Kind -> Maybe String -> m (SBV a)
mkSymSBV VarContext
q Kind
k Maybe String
forall a. Maybe a
Nothing
genLiteral :: Integral a => Kind -> a -> SBV b
genLiteral :: Kind -> a -> SBV b
genLiteral Kind
k = SVal -> SBV b
forall a. SVal -> SBV a
SBV (SVal -> SBV b) -> (a -> SVal) -> a -> SBV b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal)
-> (a -> Either CV (Cached SV)) -> a -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (a -> CV) -> a -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> a -> CV
forall a. Integral a => Kind -> a -> CV
mkConstCV Kind
k
genFromCV :: Integral a => CV -> a
genFromCV :: CV -> a
genFromCV (CV Kind
_ (CInteger Integer
x)) = Integer -> a
forall a. Num a => Integer -> a
fromInteger Integer
x
genFromCV CV
c = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"genFromCV: Unsupported non-integral value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
genMkSymVar :: MonadSymbolic m => Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar :: Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
k VarContext
mbq Maybe String
Nothing = VarContext -> Kind -> m (SBV a)
forall (m :: * -> *) a.
MonadSymbolic m =>
VarContext -> Kind -> m (SBV a)
genVar_ VarContext
mbq Kind
k
genMkSymVar Kind
k VarContext
mbq (Just String
s) = VarContext -> Kind -> String -> m (SBV a)
forall (m :: * -> *) a.
MonadSymbolic m =>
VarContext -> Kind -> String -> m (SBV a)
genVar VarContext
mbq Kind
k String
s
instance SymVal Bool where
mkSymVal :: VarContext -> Maybe String -> m (SBV Bool)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Bool)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KBool
literal :: Bool -> SBV Bool
literal = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SBV Bool) -> (Bool -> SVal) -> Bool -> SBV Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> SVal
svBool
fromCV :: CV -> Bool
fromCV = CV -> Bool
cvToBool
instance SymVal Word8 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Word8)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Word8)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
False Int
8)
literal :: Word8 -> SBV Word8
literal = Kind -> Word8 -> SBV Word8
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
False Int
8)
fromCV :: CV -> Word8
fromCV = CV -> Word8
forall a. Integral a => CV -> a
genFromCV
instance SymVal Int8 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Int8)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Int8)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
True Int
8)
literal :: Int8 -> SBV Int8
literal = Kind -> Int8 -> SBV Int8
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
True Int
8)
fromCV :: CV -> Int8
fromCV = CV -> Int8
forall a. Integral a => CV -> a
genFromCV
instance SymVal Word16 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Word16)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Word16)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
False Int
16)
literal :: Word16 -> SBV Word16
literal = Kind -> Word16 -> SBV Word16
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
False Int
16)
fromCV :: CV -> Word16
fromCV = CV -> Word16
forall a. Integral a => CV -> a
genFromCV
instance SymVal Int16 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Int16)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Int16)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
True Int
16)
literal :: Int16 -> SBV Int16
literal = Kind -> Int16 -> SBV Int16
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
True Int
16)
fromCV :: CV -> Int16
fromCV = CV -> Int16
forall a. Integral a => CV -> a
genFromCV
instance SymVal Word32 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Word32)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Word32)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
False Int
32)
literal :: Word32 -> SBV Word32
literal = Kind -> Word32 -> SBV Word32
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
False Int
32)
fromCV :: CV -> Word32
fromCV = CV -> Word32
forall a. Integral a => CV -> a
genFromCV
instance SymVal Int32 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Int32)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Int32)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
True Int
32)
literal :: Int32 -> SBV Int32
literal = Kind -> Int32 -> SBV Int32
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
True Int
32)
fromCV :: CV -> Int32
fromCV = CV -> Int32
forall a. Integral a => CV -> a
genFromCV
instance SymVal Word64 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Word64)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Word64)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
False Int
64)
literal :: Word64 -> SBV Word64
literal = Kind -> Word64 -> SBV Word64
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
False Int
64)
fromCV :: CV -> Word64
fromCV = CV -> Word64
forall a. Integral a => CV -> a
genFromCV
instance SymVal Int64 where
mkSymVal :: VarContext -> Maybe String -> m (SBV Int64)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Int64)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Bool -> Int -> Kind
KBounded Bool
True Int
64)
literal :: Int64 -> SBV Int64
literal = Kind -> Int64 -> SBV Int64
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (Bool -> Int -> Kind
KBounded Bool
True Int
64)
fromCV :: CV -> Int64
fromCV = CV -> Int64
forall a. Integral a => CV -> a
genFromCV
instance SymVal Integer where
mkSymVal :: VarContext -> Maybe String -> m (SBV Integer)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Integer)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KUnbounded
literal :: Integer -> SBV Integer
literal = SVal -> SBV Integer
forall a. SVal -> SBV a
SBV (SVal -> SBV Integer)
-> (Integer -> SVal) -> Integer -> SBV Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KUnbounded (Either CV (Cached SV) -> SVal)
-> (Integer -> Either CV (Cached SV)) -> Integer -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (Integer -> CV) -> Integer -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Integer -> CV
forall a. Integral a => Kind -> a -> CV
mkConstCV Kind
KUnbounded
fromCV :: CV -> Integer
fromCV = CV -> Integer
forall a. Integral a => CV -> a
genFromCV
instance SymVal Rational where
mkSymVal :: VarContext -> Maybe String -> m (SBV Rational)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Rational)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KRational
literal :: Rational -> SBV Rational
literal = SVal -> SBV Rational
forall a. SVal -> SBV a
SBV (SVal -> SBV Rational)
-> (Rational -> SVal) -> Rational -> SBV Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KRational (Either CV (Cached SV) -> SVal)
-> (Rational -> Either CV (Cached SV)) -> Rational -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (Rational -> CV) -> Rational -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
KRational (CVal -> CV) -> (Rational -> CVal) -> Rational -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> CVal
CRational
fromCV :: CV -> Rational
fromCV (CV Kind
_ (CRational Rational
r)) = Rational
r
fromCV CV
c = String -> Rational
forall a. HasCallStack => String -> a
error (String -> Rational) -> String -> Rational
forall a b. (a -> b) -> a -> b
$ String
"SymVal.Rational: Unexpected non-rational value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
instance SymVal AlgReal where
mkSymVal :: VarContext -> Maybe String -> m (SBV AlgReal)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV AlgReal)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KReal
literal :: AlgReal -> SBV AlgReal
literal = SVal -> SBV AlgReal
forall a. SVal -> SBV a
SBV (SVal -> SBV AlgReal)
-> (AlgReal -> SVal) -> AlgReal -> SBV AlgReal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KReal (Either CV (Cached SV) -> SVal)
-> (AlgReal -> Either CV (Cached SV)) -> AlgReal -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (AlgReal -> CV) -> AlgReal -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
KReal (CVal -> CV) -> (AlgReal -> CVal) -> AlgReal -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlgReal -> CVal
CAlgReal
fromCV :: CV -> AlgReal
fromCV (CV Kind
_ (CAlgReal AlgReal
a)) = AlgReal
a
fromCV CV
c = String -> AlgReal
forall a. HasCallStack => String -> a
error (String -> AlgReal) -> String -> AlgReal
forall a b. (a -> b) -> a -> b
$ String
"SymVal.AlgReal: Unexpected non-real value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
isConcretely :: SBV AlgReal -> (AlgReal -> Bool) -> Bool
isConcretely (SBV (SVal Kind
KReal (Left (CV Kind
KReal (CAlgReal AlgReal
v))))) AlgReal -> Bool
p
| AlgReal -> Bool
isExactRational AlgReal
v = AlgReal -> Bool
p AlgReal
v
isConcretely SBV AlgReal
_ AlgReal -> Bool
_ = Bool
False
instance SymVal Float where
mkSymVal :: VarContext -> Maybe String -> m (SBV Float)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Float)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KFloat
literal :: Float -> SBV Float
literal = SVal -> SBV Float
forall a. SVal -> SBV a
SBV (SVal -> SBV Float) -> (Float -> SVal) -> Float -> SBV Float
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KFloat (Either CV (Cached SV) -> SVal)
-> (Float -> Either CV (Cached SV)) -> Float -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (Float -> CV) -> Float -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
KFloat (CVal -> CV) -> (Float -> CVal) -> Float -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> CVal
CFloat
fromCV :: CV -> Float
fromCV (CV Kind
_ (CFloat Float
a)) = Float
a
fromCV CV
c = String -> Float
forall a. HasCallStack => String -> a
error (String -> Float) -> String -> Float
forall a b. (a -> b) -> a -> b
$ String
"SymVal.Float: Unexpected non-float value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
isConcretely :: SBV Float -> (Float -> Bool) -> Bool
isConcretely SBV Float
_ Float -> Bool
_ = Bool
False
instance SymVal Double where
mkSymVal :: VarContext -> Maybe String -> m (SBV Double)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Double)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KDouble
literal :: Double -> SBV Double
literal = SVal -> SBV Double
forall a. SVal -> SBV a
SBV (SVal -> SBV Double) -> (Double -> SVal) -> Double -> SBV Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KDouble (Either CV (Cached SV) -> SVal)
-> (Double -> Either CV (Cached SV)) -> Double -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (Double -> CV) -> Double -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
KDouble (CVal -> CV) -> (Double -> CVal) -> Double -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> CVal
CDouble
fromCV :: CV -> Double
fromCV (CV Kind
_ (CDouble Double
a)) = Double
a
fromCV CV
c = String -> Double
forall a. HasCallStack => String -> a
error (String -> Double) -> String -> Double
forall a b. (a -> b) -> a -> b
$ String
"SymVal.Double: Unexpected non-double value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
isConcretely :: SBV Double -> (Double -> Bool) -> Bool
isConcretely SBV Double
_ Double -> Bool
_ = Bool
False
instance SymVal Char where
mkSymVal :: VarContext -> Maybe String -> m (SBV Char)
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV Char)
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KChar
literal :: Char -> SBV Char
literal Char
c = SVal -> SBV Char
forall a. SVal -> SBV a
SBV (SVal -> SBV Char) -> (CVal -> SVal) -> CVal -> SBV Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KChar (Either CV (Cached SV) -> SVal)
-> (CVal -> Either CV (Cached SV)) -> CVal -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (CVal -> CV) -> CVal -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
KChar (CVal -> SBV Char) -> CVal -> SBV Char
forall a b. (a -> b) -> a -> b
$ Char -> CVal
CChar Char
c
fromCV :: CV -> Char
fromCV (CV Kind
_ (CChar Char
a)) = Char
a
fromCV CV
c = String -> Char
forall a. HasCallStack => String -> a
error (String -> Char) -> String -> Char
forall a b. (a -> b) -> a -> b
$ String
"SymVal.String: Unexpected non-char value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
instance SymVal a => SymVal [a] where
mkSymVal :: VarContext -> Maybe String -> m (SBV [a])
mkSymVal
| [a] -> Bool
forall a. Typeable a => a -> Bool
isKString @[a] [a]
forall a. HasCallStack => a
undefined = Kind -> VarContext -> Maybe String -> m (SBV [a])
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar Kind
KString
| Bool
True = Kind -> VarContext -> Maybe String -> m (SBV [a])
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Kind -> Kind
KList (Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)))
literal :: [a] -> SBV [a]
literal [a]
as
| [a] -> Bool
forall a. Typeable a => a -> Bool
isKString @[a] [a]
forall a. HasCallStack => a
undefined = case Dynamic -> Maybe String
forall a. Typeable a => Dynamic -> Maybe a
fromDynamic ([a] -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn [a]
as) of
Just String
s -> SVal -> SBV [a]
forall a. SVal -> SBV a
SBV (SVal -> SBV [a]) -> (String -> SVal) -> String -> SBV [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KString (Either CV (Cached SV) -> SVal)
-> (String -> Either CV (Cached SV)) -> String -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (String -> CV) -> String -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
KString (CVal -> CV) -> (String -> CVal) -> String -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CVal
CString (String -> SBV [a]) -> String -> SBV [a]
forall a b. (a -> b) -> a -> b
$ String
s
Maybe String
Nothing -> String -> SBV [a]
forall a. HasCallStack => String -> a
error String
"SString: Cannot construct literal string!"
| Bool
True = let k :: Kind
k = Kind -> Kind
KList (Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a))
in SVal -> SBV [a]
forall a. SVal -> SBV a
SBV (SVal -> SBV [a]) -> SVal -> SBV [a]
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV)) -> CV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k (CVal -> CV) -> CVal -> CV
forall a b. (a -> b) -> a -> b
$ [CVal] -> CVal
CList ([CVal] -> CVal) -> [CVal] -> CVal
forall a b. (a -> b) -> a -> b
$ (a -> CVal) -> [a] -> [CVal]
forall a b. (a -> b) -> [a] -> [b]
map a -> CVal
forall a. SymVal a => a -> CVal
toCV [a]
as
fromCV :: CV -> [a]
fromCV (CV Kind
_ (CString String
a)) = [a] -> Maybe [a] -> [a]
forall a. a -> Maybe a -> a
fromMaybe (String -> [a]
forall a. HasCallStack => String -> a
error String
"SString: Cannot extract a literal string!")
(Dynamic -> Maybe [a]
forall a. Typeable a => Dynamic -> Maybe a
fromDynamic (String -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn String
a))
fromCV (CV Kind
_ (CList [CVal]
a)) = CV -> a
forall a. SymVal a => CV -> a
fromCV (CV -> a) -> (CVal -> CV) -> CVal -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV (Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)) (CVal -> a) -> [CVal] -> [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [CVal]
a
fromCV CV
c = String -> [a]
forall a. HasCallStack => String -> a
error (String -> [a]) -> String -> [a]
forall a b. (a -> b) -> a -> b
$ String
"SymVal.fromCV: Unexpected non-list value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
instance ValidFloat eb sb => HasKind (FloatingPoint eb sb) where
kindOf :: FloatingPoint eb sb -> Kind
kindOf FloatingPoint eb sb
_ = Int -> Int -> Kind
KFP (Proxy eb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy eb
forall k (t :: k). Proxy t
Proxy @eb)) (Proxy sb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy sb
forall k (t :: k). Proxy t
Proxy @sb))
instance ValidFloat eb sb => SymVal (FloatingPoint eb sb) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (FloatingPoint eb sb))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (FloatingPoint eb sb))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Int -> Int -> Kind
KFP (Proxy eb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy eb
forall k (t :: k). Proxy t
Proxy @eb)) (Proxy sb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy sb
forall k (t :: k). Proxy t
Proxy @sb)))
literal :: FloatingPoint eb sb -> SBV (FloatingPoint eb sb)
literal (FloatingPoint FP
r) = let k :: Kind
k = Int -> Int -> Kind
KFP (Proxy eb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy eb
forall k (t :: k). Proxy t
Proxy @eb)) (Proxy sb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy sb
forall k (t :: k). Proxy t
Proxy @sb))
in SVal -> SBV (FloatingPoint eb sb)
forall a. SVal -> SBV a
SBV (SVal -> SBV (FloatingPoint eb sb))
-> SVal -> SBV (FloatingPoint eb sb)
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV)) -> CV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k (FP -> CVal
CFP FP
r)
fromCV :: CV -> FloatingPoint eb sb
fromCV (CV Kind
_ (CFP FP
r)) = FP -> FloatingPoint eb sb
forall (eb :: Nat) (sb :: Nat). FP -> FloatingPoint eb sb
FloatingPoint FP
r
fromCV CV
c = String -> FloatingPoint eb sb
forall a. HasCallStack => String -> a
error (String -> FloatingPoint eb sb) -> String -> FloatingPoint eb sb
forall a b. (a -> b) -> a -> b
$ String
"SymVal.FPR: Unexpected non-arbitrary-precision value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
c
toCV :: SymVal a => a -> CVal
toCV :: a -> CVal
toCV a
a = case a -> SBV a
forall a. SymVal a => a -> SBV a
literal a
a of
SBV (SVal Kind
_ (Left CV
cv)) -> CV -> CVal
cvVal CV
cv
SBV a
_ -> String -> CVal
forall a. HasCallStack => String -> a
error String
"SymVal.toCV: Impossible happened, couldn't produce a concrete value"
mkCVTup :: Int -> Kind -> [CVal] -> SBV a
mkCVTup :: Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
i k :: Kind
k@(KTuple [Kind]
ks) [CVal]
cs
| Int
lks Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
lcs Bool -> Bool -> Bool
&& Int
lks Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
i
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV)) -> CV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k (CVal -> CV) -> CVal -> CV
forall a b. (a -> b) -> a -> b
$ [CVal] -> CVal
CTuple [CVal]
cs
| Bool
True
= String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"SymVal.mkCVTup: Impossible happened. Malformed tuple received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Kind) -> String
forall a. Show a => a -> String
show (Int
i, Kind
k)
where lks :: Int
lks = [Kind] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Kind]
ks
lcs :: Int
lcs = [CVal] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [CVal]
cs
mkCVTup Int
i Kind
k [CVal]
_
= String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"SymVal.mkCVTup: Impossible happened. Non-tuple received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Kind) -> String
forall a. Show a => a -> String
show (Int
i, Kind
k)
fromCVTup :: Int -> CV -> [CV]
fromCVTup :: Int -> CV -> [CV]
fromCVTup Int
i inp :: CV
inp@(CV (KTuple [Kind]
ks) (CTuple [CVal]
cs))
| Int
lks Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
lcs Bool -> Bool -> Bool
&& Int
lks Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
i
= (Kind -> CVal -> CV) -> [Kind] -> [CVal] -> [CV]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Kind -> CVal -> CV
CV [Kind]
ks [CVal]
cs
| Bool
True
= String -> [CV]
forall a. HasCallStack => String -> a
error (String -> [CV]) -> String -> [CV]
forall a b. (a -> b) -> a -> b
$ String
"SymVal.fromCTup: Impossible happened. Malformed tuple received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, CV) -> String
forall a. Show a => a -> String
show (Int
i, CV
inp)
where lks :: Int
lks = [Kind] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Kind]
ks
lcs :: Int
lcs = [CVal] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [CVal]
cs
fromCVTup Int
i CV
inp = String -> [CV]
forall a. HasCallStack => String -> a
error (String -> [CV]) -> String -> [CV]
forall a b. (a -> b) -> a -> b
$ String
"SymVal.fromCVTup: Impossible happened. Non-tuple received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, CV) -> String
forall a. Show a => a -> String
show (Int
i, CV
inp)
instance (SymVal a, SymVal b) => SymVal (Either a b) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (Either a b))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (Either a b))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (Either a b) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (Either a b)
forall k (t :: k). Proxy t
Proxy @(Either a b)))
literal :: Either a b -> SBV (Either a b)
literal Either a b
s
| Left a
a <- Either a b
s = Either CVal CVal -> SBV (Either a b)
mk (Either CVal CVal -> SBV (Either a b))
-> Either CVal CVal -> SBV (Either a b)
forall a b. (a -> b) -> a -> b
$ CVal -> Either CVal CVal
forall a b. a -> Either a b
Left (a -> CVal
forall a. SymVal a => a -> CVal
toCV a
a)
| Right b
b <- Either a b
s = Either CVal CVal -> SBV (Either a b)
mk (Either CVal CVal -> SBV (Either a b))
-> Either CVal CVal -> SBV (Either a b)
forall a b. (a -> b) -> a -> b
$ CVal -> Either CVal CVal
forall a b. b -> Either a b
Right (b -> CVal
forall a. SymVal a => a -> CVal
toCV b
b)
where k :: Kind
k = Proxy (Either a b) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (Either a b)
forall k (t :: k). Proxy t
Proxy @(Either a b))
mk :: Either CVal CVal -> SBV (Either a b)
mk = SVal -> SBV (Either a b)
forall a. SVal -> SBV a
SBV (SVal -> SBV (Either a b))
-> (Either CVal CVal -> SVal)
-> Either CVal CVal
-> SBV (Either a b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal)
-> (Either CVal CVal -> Either CV (Cached SV))
-> Either CVal CVal
-> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (Either CVal CVal -> CV)
-> Either CVal CVal
-> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
k (CVal -> CV)
-> (Either CVal CVal -> CVal) -> Either CVal CVal -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either CVal CVal -> CVal
CEither
fromCV :: CV -> Either a b
fromCV (CV (KEither Kind
k1 Kind
_ ) (CEither (Left CVal
c))) = a -> Either a b
forall a b. a -> Either a b
Left (a -> Either a b) -> a -> Either a b
forall a b. (a -> b) -> a -> b
$ CV -> a
forall a. SymVal a => CV -> a
fromCV (CV -> a) -> CV -> a
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k1 CVal
c
fromCV (CV (KEither Kind
_ Kind
k2) (CEither (Right CVal
c))) = b -> Either a b
forall a b. b -> Either a b
Right (b -> Either a b) -> b -> Either a b
forall a b. (a -> b) -> a -> b
$ CV -> b
forall a. SymVal a => CV -> a
fromCV (CV -> b) -> CV -> b
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k2 CVal
c
fromCV CV
bad = String -> Either a b
forall a. HasCallStack => String -> a
error (String -> Either a b) -> String -> Either a b
forall a b. (a -> b) -> a -> b
$ String
"SymVal.fromCV (Either): Malformed either received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
bad
instance SymVal a => SymVal (Maybe a) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (Maybe a))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (Maybe a))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (Maybe a) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (Maybe a)
forall k (t :: k). Proxy t
Proxy @(Maybe a)))
literal :: Maybe a -> SBV (Maybe a)
literal Maybe a
s
| Maybe a
Nothing <- Maybe a
s = Maybe CVal -> SBV (Maybe a)
mk Maybe CVal
forall a. Maybe a
Nothing
| Just a
a <- Maybe a
s = Maybe CVal -> SBV (Maybe a)
mk (Maybe CVal -> SBV (Maybe a)) -> Maybe CVal -> SBV (Maybe a)
forall a b. (a -> b) -> a -> b
$ CVal -> Maybe CVal
forall a. a -> Maybe a
Just (a -> CVal
forall a. SymVal a => a -> CVal
toCV a
a)
where k :: Kind
k = Proxy (Maybe a) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (Maybe a)
forall k (t :: k). Proxy t
Proxy @(Maybe a))
mk :: Maybe CVal -> SBV (Maybe a)
mk = SVal -> SBV (Maybe a)
forall a. SVal -> SBV a
SBV (SVal -> SBV (Maybe a))
-> (Maybe CVal -> SVal) -> Maybe CVal -> SBV (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal)
-> (Maybe CVal -> Either CV (Cached SV)) -> Maybe CVal -> SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV))
-> (Maybe CVal -> CV) -> Maybe CVal -> Either CV (Cached SV)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
k (CVal -> CV) -> (Maybe CVal -> CVal) -> Maybe CVal -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe CVal -> CVal
CMaybe
fromCV :: CV -> Maybe a
fromCV (CV (KMaybe Kind
_) (CMaybe Maybe CVal
Nothing)) = Maybe a
forall a. Maybe a
Nothing
fromCV (CV (KMaybe Kind
k) (CMaybe (Just CVal
x))) = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ CV -> a
forall a. SymVal a => CV -> a
fromCV (CV -> a) -> CV -> a
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k CVal
x
fromCV CV
bad = String -> Maybe a
forall a. HasCallStack => String -> a
error (String -> Maybe a) -> String -> Maybe a
forall a b. (a -> b) -> a -> b
$ String
"SymVal.fromCV (Maybe): Malformed sum received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
bad
instance (Ord a, SymVal a) => SymVal (RCSet a) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (RCSet a))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (RCSet a))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (RCSet a) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (RCSet a)
forall k (t :: k). Proxy t
Proxy @(RCSet a)))
literal :: RCSet a -> SBV (RCSet a)
literal RCSet a
eur = SVal -> SBV (RCSet a)
forall a. SVal -> SBV a
SBV (SVal -> SBV (RCSet a)) -> SVal -> SBV (RCSet a)
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left (CV -> Either CV (Cached SV)) -> CV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k (CVal -> CV) -> CVal -> CV
forall a b. (a -> b) -> a -> b
$ RCSet CVal -> CVal
CSet (RCSet CVal -> CVal) -> RCSet CVal -> CVal
forall a b. (a -> b) -> a -> b
$ Set CVal -> RCSet CVal
dir (Set CVal -> RCSet CVal) -> Set CVal -> RCSet CVal
forall a b. (a -> b) -> a -> b
$ (a -> CVal) -> Set a -> Set CVal
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map a -> CVal
forall a. SymVal a => a -> CVal
toCV Set a
s
where (Set CVal -> RCSet CVal
dir, Set a
s) = case RCSet a
eur of
RegularSet Set a
x -> (Set CVal -> RCSet CVal
forall a. Set a -> RCSet a
RegularSet, Set a
x)
ComplementSet Set a
x -> (Set CVal -> RCSet CVal
forall a. Set a -> RCSet a
ComplementSet, Set a
x)
k :: Kind
k = Proxy (RCSet a) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (RCSet a)
forall k (t :: k). Proxy t
Proxy @(RCSet a))
fromCV :: CV -> RCSet a
fromCV (CV (KSet Kind
a) (CSet (RegularSet Set CVal
s))) = Set a -> RCSet a
forall a. Set a -> RCSet a
RegularSet (Set a -> RCSet a) -> Set a -> RCSet a
forall a b. (a -> b) -> a -> b
$ (CVal -> a) -> Set CVal -> Set a
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map (CV -> a
forall a. SymVal a => CV -> a
fromCV (CV -> a) -> (CVal -> CV) -> CVal -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
a) Set CVal
s
fromCV (CV (KSet Kind
a) (CSet (ComplementSet Set CVal
s))) = Set a -> RCSet a
forall a. Set a -> RCSet a
ComplementSet (Set a -> RCSet a) -> Set a -> RCSet a
forall a b. (a -> b) -> a -> b
$ (CVal -> a) -> Set CVal -> Set a
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map (CV -> a
forall a. SymVal a => CV -> a
fromCV (CV -> a) -> (CVal -> CV) -> CVal -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> CVal -> CV
CV Kind
a) Set CVal
s
fromCV CV
bad = String -> RCSet a
forall a. HasCallStack => String -> a
error (String -> RCSet a) -> String -> RCSet a
forall a b. (a -> b) -> a -> b
$ String
"SymVal.fromCV (Set): Malformed set received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CV -> String
forall a. Show a => a -> String
show CV
bad
instance SymVal () where
mkSymVal :: VarContext -> Maybe String -> m (SBV ())
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV ())
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar ([Kind] -> Kind
KTuple [])
literal :: () -> SBV ()
literal () = Int -> Kind -> [CVal] -> SBV ()
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
0 (Proxy () -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy ()
forall k (t :: k). Proxy t
Proxy @())) []
fromCV :: CV -> ()
fromCV CV
cv = Int -> CV -> [CV]
fromCVTup Int
0 CV
cv [CV] -> () -> ()
`seq` ()
instance (SymVal a, SymVal b) => SymVal (a, b) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (a, b))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b)
forall k (t :: k). Proxy t
Proxy @(a, b)))
literal :: (a, b) -> SBV (a, b)
literal (a
v1, b
v2) = Int -> Kind -> [CVal] -> SBV (a, b)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
2 (Proxy (a, b) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b)
forall k (t :: k). Proxy t
Proxy @(a, b))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2]
fromCV :: CV -> (a, b)
fromCV CV
cv = let ~[CV
v1, CV
v2] = Int -> CV -> [CV]
fromCVTup Int
2 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2)
instance (SymVal a, SymVal b, SymVal c) => SymVal (a, b, c) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b, c))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (a, b, c))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b, c) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c)
forall k (t :: k). Proxy t
Proxy @(a, b, c)))
literal :: (a, b, c) -> SBV (a, b, c)
literal (a
v1, b
v2, c
v3) = Int -> Kind -> [CVal] -> SBV (a, b, c)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
3 (Proxy (a, b, c) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c)
forall k (t :: k). Proxy t
Proxy @(a, b, c))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2, c -> CVal
forall a. SymVal a => a -> CVal
toCV c
v3]
fromCV :: CV -> (a, b, c)
fromCV CV
cv = let ~[CV
v1, CV
v2, CV
v3] = Int -> CV -> [CV]
fromCVTup Int
3 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2, CV -> c
forall a. SymVal a => CV -> a
fromCV CV
v3)
instance (SymVal a, SymVal b, SymVal c, SymVal d) => SymVal (a, b, c, d) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b, c, d))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (a, b, c, d))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b, c, d) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d)))
literal :: (a, b, c, d) -> SBV (a, b, c, d)
literal (a
v1, b
v2, c
v3, d
v4) = Int -> Kind -> [CVal] -> SBV (a, b, c, d)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
4 (Proxy (a, b, c, d) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2, c -> CVal
forall a. SymVal a => a -> CVal
toCV c
v3, d -> CVal
forall a. SymVal a => a -> CVal
toCV d
v4]
fromCV :: CV -> (a, b, c, d)
fromCV CV
cv = let ~[CV
v1, CV
v2, CV
v3, CV
v4] = Int -> CV -> [CV]
fromCVTup Int
4 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2, CV -> c
forall a. SymVal a => CV -> a
fromCV CV
v3, CV -> d
forall a. SymVal a => CV -> a
fromCV CV
v4)
instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e) => SymVal (a, b, c, d, e) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b, c, d, e))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (a, b, c, d, e))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b, c, d, e) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e)))
literal :: (a, b, c, d, e) -> SBV (a, b, c, d, e)
literal (a
v1, b
v2, c
v3, d
v4, e
v5) = Int -> Kind -> [CVal] -> SBV (a, b, c, d, e)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
5 (Proxy (a, b, c, d, e) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2, c -> CVal
forall a. SymVal a => a -> CVal
toCV c
v3, d -> CVal
forall a. SymVal a => a -> CVal
toCV d
v4, e -> CVal
forall a. SymVal a => a -> CVal
toCV e
v5]
fromCV :: CV -> (a, b, c, d, e)
fromCV CV
cv = let ~[CV
v1, CV
v2, CV
v3, CV
v4, CV
v5] = Int -> CV -> [CV]
fromCVTup Int
5 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2, CV -> c
forall a. SymVal a => CV -> a
fromCV CV
v3, CV -> d
forall a. SymVal a => CV -> a
fromCV CV
v4, CV -> e
forall a. SymVal a => CV -> a
fromCV CV
v5)
instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f) => SymVal (a, b, c, d, e, f) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b, c, d, e, f))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (a, b, c, d, e, f))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b, c, d, e, f) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e, f)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e, f)))
literal :: (a, b, c, d, e, f) -> SBV (a, b, c, d, e, f)
literal (a
v1, b
v2, c
v3, d
v4, e
v5, f
v6) = Int -> Kind -> [CVal] -> SBV (a, b, c, d, e, f)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
6 (Proxy (a, b, c, d, e, f) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e, f)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e, f))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2, c -> CVal
forall a. SymVal a => a -> CVal
toCV c
v3, d -> CVal
forall a. SymVal a => a -> CVal
toCV d
v4, e -> CVal
forall a. SymVal a => a -> CVal
toCV e
v5, f -> CVal
forall a. SymVal a => a -> CVal
toCV f
v6]
fromCV :: CV -> (a, b, c, d, e, f)
fromCV CV
cv = let ~[CV
v1, CV
v2, CV
v3, CV
v4, CV
v5, CV
v6] = Int -> CV -> [CV]
fromCVTup Int
6 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2, CV -> c
forall a. SymVal a => CV -> a
fromCV CV
v3, CV -> d
forall a. SymVal a => CV -> a
fromCV CV
v4, CV -> e
forall a. SymVal a => CV -> a
fromCV CV
v5, CV -> f
forall a. SymVal a => CV -> a
fromCV CV
v6)
instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g) => SymVal (a, b, c, d, e, f, g) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b, c, d, e, f, g))
mkSymVal = Kind -> VarContext -> Maybe String -> m (SBV (a, b, c, d, e, f, g))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b, c, d, e, f, g) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e, f, g)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e, f, g)))
literal :: (a, b, c, d, e, f, g) -> SBV (a, b, c, d, e, f, g)
literal (a
v1, b
v2, c
v3, d
v4, e
v5, f
v6, g
v7) = Int -> Kind -> [CVal] -> SBV (a, b, c, d, e, f, g)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
7 (Proxy (a, b, c, d, e, f, g) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e, f, g)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e, f, g))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2, c -> CVal
forall a. SymVal a => a -> CVal
toCV c
v3, d -> CVal
forall a. SymVal a => a -> CVal
toCV d
v4, e -> CVal
forall a. SymVal a => a -> CVal
toCV e
v5, f -> CVal
forall a. SymVal a => a -> CVal
toCV f
v6, g -> CVal
forall a. SymVal a => a -> CVal
toCV g
v7]
fromCV :: CV -> (a, b, c, d, e, f, g)
fromCV CV
cv = let ~[CV
v1, CV
v2, CV
v3, CV
v4, CV
v5, CV
v6, CV
v7] = Int -> CV -> [CV]
fromCVTup Int
7 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2, CV -> c
forall a. SymVal a => CV -> a
fromCV CV
v3, CV -> d
forall a. SymVal a => CV -> a
fromCV CV
v4, CV -> e
forall a. SymVal a => CV -> a
fromCV CV
v5, CV -> f
forall a. SymVal a => CV -> a
fromCV CV
v6, CV -> g
forall a. SymVal a => CV -> a
fromCV CV
v7)
instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, SymVal h) => SymVal (a, b, c, d, e, f, g, h) where
mkSymVal :: VarContext -> Maybe String -> m (SBV (a, b, c, d, e, f, g, h))
mkSymVal = Kind
-> VarContext -> Maybe String -> m (SBV (a, b, c, d, e, f, g, h))
forall (m :: * -> *) a.
MonadSymbolic m =>
Kind -> VarContext -> Maybe String -> m (SBV a)
genMkSymVar (Proxy (a, b, c, d, e, f, g, h) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e, f, g, h)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e, f, g, h)))
literal :: (a, b, c, d, e, f, g, h) -> SBV (a, b, c, d, e, f, g, h)
literal (a
v1, b
v2, c
v3, d
v4, e
v5, f
v6, g
v7, h
v8) = Int -> Kind -> [CVal] -> SBV (a, b, c, d, e, f, g, h)
forall a. Int -> Kind -> [CVal] -> SBV a
mkCVTup Int
8 (Proxy (a, b, c, d, e, f, g, h) -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy (a, b, c, d, e, f, g, h)
forall k (t :: k). Proxy t
Proxy @(a, b, c, d, e, f, g, h))) [a -> CVal
forall a. SymVal a => a -> CVal
toCV a
v1, b -> CVal
forall a. SymVal a => a -> CVal
toCV b
v2, c -> CVal
forall a. SymVal a => a -> CVal
toCV c
v3, d -> CVal
forall a. SymVal a => a -> CVal
toCV d
v4, e -> CVal
forall a. SymVal a => a -> CVal
toCV e
v5, f -> CVal
forall a. SymVal a => a -> CVal
toCV f
v6, g -> CVal
forall a. SymVal a => a -> CVal
toCV g
v7, h -> CVal
forall a. SymVal a => a -> CVal
toCV h
v8]
fromCV :: CV -> (a, b, c, d, e, f, g, h)
fromCV CV
cv = let ~[CV
v1, CV
v2, CV
v3, CV
v4, CV
v5, CV
v6, CV
v7, CV
v8] = Int -> CV -> [CV]
fromCVTup Int
8 CV
cv
in (CV -> a
forall a. SymVal a => CV -> a
fromCV CV
v1, CV -> b
forall a. SymVal a => CV -> a
fromCV CV
v2, CV -> c
forall a. SymVal a => CV -> a
fromCV CV
v3, CV -> d
forall a. SymVal a => CV -> a
fromCV CV
v4, CV -> e
forall a. SymVal a => CV -> a
fromCV CV
v5, CV -> f
forall a. SymVal a => CV -> a
fromCV CV
v6, CV -> g
forall a. SymVal a => CV -> a
fromCV CV
v7, CV -> h
forall a. SymVal a => CV -> a
fromCV CV
v8)
instance IsString SString where
fromString :: String -> SString
fromString = String -> SString
forall a. SymVal a => a -> SBV a
literal
sBool :: MonadSymbolic m => String -> m SBool
sBool :: String -> m (SBV Bool)
sBool = String -> m (SBV Bool)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sBool_ :: MonadSymbolic m => m SBool
sBool_ :: m (SBV Bool)
sBool_ = m (SBV Bool)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sBools :: MonadSymbolic m => [String] -> m [SBool]
sBools :: [String] -> m [SBV Bool]
sBools = [String] -> m [SBV Bool]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sWord8 :: MonadSymbolic m => String -> m SWord8
sWord8 :: String -> m (SBV Word8)
sWord8 = String -> m (SBV Word8)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sWord8_ :: MonadSymbolic m => m SWord8
sWord8_ :: m (SBV Word8)
sWord8_ = m (SBV Word8)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sWord8s :: MonadSymbolic m => [String] -> m [SWord8]
sWord8s :: [String] -> m [SBV Word8]
sWord8s = [String] -> m [SBV Word8]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sWord16 :: MonadSymbolic m => String -> m SWord16
sWord16 :: String -> m (SBV Word16)
sWord16 = String -> m (SBV Word16)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sWord16_ :: MonadSymbolic m => m SWord16
sWord16_ :: m (SBV Word16)
sWord16_ = m (SBV Word16)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sWord16s :: MonadSymbolic m => [String] -> m [SWord16]
sWord16s :: [String] -> m [SBV Word16]
sWord16s = [String] -> m [SBV Word16]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sWord32 :: MonadSymbolic m => String -> m SWord32
sWord32 :: String -> m (SBV Word32)
sWord32 = String -> m (SBV Word32)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sWord32_ :: MonadSymbolic m => m SWord32
sWord32_ :: m (SBV Word32)
sWord32_ = m (SBV Word32)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sWord32s :: MonadSymbolic m => [String] -> m [SWord32]
sWord32s :: [String] -> m [SBV Word32]
sWord32s = [String] -> m [SBV Word32]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sWord64 :: MonadSymbolic m => String -> m SWord64
sWord64 :: String -> m (SBV Word64)
sWord64 = String -> m (SBV Word64)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sWord64_ :: MonadSymbolic m => m SWord64
sWord64_ :: m (SBV Word64)
sWord64_ = m (SBV Word64)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sWord64s :: MonadSymbolic m => [String] -> m [SWord64]
sWord64s :: [String] -> m [SBV Word64]
sWord64s = [String] -> m [SBV Word64]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sInt8 :: MonadSymbolic m => String -> m SInt8
sInt8 :: String -> m (SBV Int8)
sInt8 = String -> m (SBV Int8)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sInt8_ :: MonadSymbolic m => m SInt8
sInt8_ :: m (SBV Int8)
sInt8_ = m (SBV Int8)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sInt8s :: MonadSymbolic m => [String] -> m [SInt8]
sInt8s :: [String] -> m [SBV Int8]
sInt8s = [String] -> m [SBV Int8]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sInt16 :: MonadSymbolic m => String -> m SInt16
sInt16 :: String -> m (SBV Int16)
sInt16 = String -> m (SBV Int16)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sInt16_ :: MonadSymbolic m => m SInt16
sInt16_ :: m (SBV Int16)
sInt16_ = m (SBV Int16)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sInt16s :: MonadSymbolic m => [String] -> m [SInt16]
sInt16s :: [String] -> m [SBV Int16]
sInt16s = [String] -> m [SBV Int16]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sInt32 :: MonadSymbolic m => String -> m SInt32
sInt32 :: String -> m (SBV Int32)
sInt32 = String -> m (SBV Int32)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sInt32_ :: MonadSymbolic m => m SInt32
sInt32_ :: m (SBV Int32)
sInt32_ = m (SBV Int32)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sInt32s :: MonadSymbolic m => [String] -> m [SInt32]
sInt32s :: [String] -> m [SBV Int32]
sInt32s = [String] -> m [SBV Int32]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sInt64 :: MonadSymbolic m => String -> m SInt64
sInt64 :: String -> m (SBV Int64)
sInt64 = String -> m (SBV Int64)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sInt64_ :: MonadSymbolic m => m SInt64
sInt64_ :: m (SBV Int64)
sInt64_ = m (SBV Int64)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sInt64s :: MonadSymbolic m => [String] -> m [SInt64]
sInt64s :: [String] -> m [SBV Int64]
sInt64s = [String] -> m [SBV Int64]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sInteger:: MonadSymbolic m => String -> m SInteger
sInteger :: String -> m (SBV Integer)
sInteger = String -> m (SBV Integer)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sInteger_:: MonadSymbolic m => m SInteger
sInteger_ :: m (SBV Integer)
sInteger_ = m (SBV Integer)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sIntegers :: MonadSymbolic m => [String] -> m [SInteger]
sIntegers :: [String] -> m [SBV Integer]
sIntegers = [String] -> m [SBV Integer]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sReal:: MonadSymbolic m => String -> m SReal
sReal :: String -> m (SBV AlgReal)
sReal = String -> m (SBV AlgReal)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sReal_:: MonadSymbolic m => m SReal
sReal_ :: m (SBV AlgReal)
sReal_ = m (SBV AlgReal)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sReals :: MonadSymbolic m => [String] -> m [SReal]
sReals :: [String] -> m [SBV AlgReal]
sReals = [String] -> m [SBV AlgReal]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFloat :: MonadSymbolic m => String -> m SFloat
sFloat :: String -> m (SBV Float)
sFloat = String -> m (SBV Float)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFloat_ :: MonadSymbolic m => m SFloat
sFloat_ :: m (SBV Float)
sFloat_ = m (SBV Float)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFloats :: MonadSymbolic m => [String] -> m [SFloat]
sFloats :: [String] -> m [SBV Float]
sFloats = [String] -> m [SBV Float]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sDouble :: MonadSymbolic m => String -> m SDouble
sDouble :: String -> m (SBV Double)
sDouble = String -> m (SBV Double)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sDouble_ :: MonadSymbolic m => m SDouble
sDouble_ :: m (SBV Double)
sDouble_ = m (SBV Double)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sDoubles :: MonadSymbolic m => [String] -> m [SDouble]
sDoubles :: [String] -> m [SBV Double]
sDoubles = [String] -> m [SBV Double]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFPHalf :: String -> Symbolic SFPHalf
sFPHalf :: String -> Symbolic SFPHalf
sFPHalf = String -> Symbolic SFPHalf
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFPHalf_ :: Symbolic SFPHalf
sFPHalf_ :: Symbolic SFPHalf
sFPHalf_ = Symbolic SFPHalf
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFPHalfs :: [String] -> Symbolic [SFPHalf]
sFPHalfs :: [String] -> Symbolic [SFPHalf]
sFPHalfs = [String] -> Symbolic [SFPHalf]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFPBFloat :: String -> Symbolic SFPBFloat
sFPBFloat :: String -> Symbolic SFPBFloat
sFPBFloat = String -> Symbolic SFPBFloat
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFPBFloat_ :: Symbolic SFPBFloat
sFPBFloat_ :: Symbolic SFPBFloat
sFPBFloat_ = Symbolic SFPBFloat
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFPBFloats :: [String] -> Symbolic [SFPBFloat]
sFPBFloats :: [String] -> Symbolic [SFPBFloat]
sFPBFloats = [String] -> Symbolic [SFPBFloat]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFPSingle :: String -> Symbolic SFPSingle
sFPSingle :: String -> Symbolic SFPSingle
sFPSingle = String -> Symbolic SFPSingle
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFPSingle_ :: Symbolic SFPSingle
sFPSingle_ :: Symbolic SFPSingle
sFPSingle_ = Symbolic SFPSingle
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFPSingles :: [String] -> Symbolic [SFPSingle]
sFPSingles :: [String] -> Symbolic [SFPSingle]
sFPSingles = [String] -> Symbolic [SFPSingle]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFPDouble :: String -> Symbolic SFPDouble
sFPDouble :: String -> Symbolic SFPDouble
sFPDouble = String -> Symbolic SFPDouble
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFPDouble_ :: Symbolic SFPDouble
sFPDouble_ :: Symbolic SFPDouble
sFPDouble_ = Symbolic SFPDouble
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFPDoubles :: [String] -> Symbolic [SFPDouble]
sFPDoubles :: [String] -> Symbolic [SFPDouble]
sFPDoubles = [String] -> Symbolic [SFPDouble]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFPQuad :: String -> Symbolic SFPQuad
sFPQuad :: String -> Symbolic SFPQuad
sFPQuad = String -> Symbolic SFPQuad
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFPQuad_ :: Symbolic SFPQuad
sFPQuad_ :: Symbolic SFPQuad
sFPQuad_ = Symbolic SFPQuad
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFPQuads :: [String] -> Symbolic [SFPQuad]
sFPQuads :: [String] -> Symbolic [SFPQuad]
sFPQuads = [String] -> Symbolic [SFPQuad]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sFloatingPoint :: ValidFloat eb sb => String -> Symbolic (SFloatingPoint eb sb)
sFloatingPoint :: String -> Symbolic (SFloatingPoint eb sb)
sFloatingPoint = String -> Symbolic (SFloatingPoint eb sb)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sFloatingPoint_ :: ValidFloat eb sb => Symbolic (SFloatingPoint eb sb)
sFloatingPoint_ :: Symbolic (SFloatingPoint eb sb)
sFloatingPoint_ = Symbolic (SFloatingPoint eb sb)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sFloatingPoints :: ValidFloat eb sb => [String] -> Symbolic [SFloatingPoint eb sb]
sFloatingPoints :: [String] -> Symbolic [SFloatingPoint eb sb]
sFloatingPoints = [String] -> Symbolic [SFloatingPoint eb sb]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sChar :: MonadSymbolic m => String -> m SChar
sChar :: String -> m (SBV Char)
sChar = String -> m (SBV Char)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sChar_ :: MonadSymbolic m => m SChar
sChar_ :: m (SBV Char)
sChar_ = m (SBV Char)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sChars :: MonadSymbolic m => [String] -> m [SChar]
sChars :: [String] -> m [SBV Char]
sChars = [String] -> m [SBV Char]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sString :: MonadSymbolic m => String -> m SString
sString :: String -> m SString
sString = String -> m SString
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sString_ :: MonadSymbolic m => m SString
sString_ :: m SString
sString_ = m SString
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sStrings :: MonadSymbolic m => [String] -> m [SString]
sStrings :: [String] -> m [SString]
sStrings = [String] -> m [SString]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sList :: (SymVal a, MonadSymbolic m) => String -> m (SList a)
sList :: String -> m (SList a)
sList = String -> m (SList a)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sList_ :: (SymVal a, MonadSymbolic m) => m (SList a)
sList_ :: m (SList a)
sList_ = m (SList a)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sLists :: (SymVal a, MonadSymbolic m) => [String] -> m [SList a]
sLists :: [String] -> m [SList a]
sLists = [String] -> m [SList a]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
class SymTuple a
instance SymTuple ()
instance SymTuple (a, b)
instance SymTuple (a, b, c)
instance SymTuple (a, b, c, d)
instance SymTuple (a, b, c, d, e)
instance SymTuple (a, b, c, d, e, f)
instance SymTuple (a, b, c, d, e, f, g)
instance SymTuple (a, b, c, d, e, f, g, h)
sTuple :: (SymTuple tup, SymVal tup, MonadSymbolic m) => String -> m (SBV tup)
sTuple :: String -> m (SBV tup)
sTuple = String -> m (SBV tup)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sTuple_ :: (SymTuple tup, SymVal tup, MonadSymbolic m) => m (SBV tup)
sTuple_ :: m (SBV tup)
sTuple_ = m (SBV tup)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sTuples :: (SymTuple tup, SymVal tup, MonadSymbolic m) => [String] -> m [SBV tup]
sTuples :: [String] -> m [SBV tup]
sTuples = [String] -> m [SBV tup]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sRational :: MonadSymbolic m => String -> m SRational
sRational :: String -> m (SBV Rational)
sRational = String -> m (SBV Rational)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sRational_ :: MonadSymbolic m => m SRational
sRational_ :: m (SBV Rational)
sRational_ = m (SBV Rational)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sRationals :: MonadSymbolic m => [String] -> m [SRational]
sRationals :: [String] -> m [SBV Rational]
sRationals = [String] -> m [SBV Rational]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sEither :: (SymVal a, SymVal b, MonadSymbolic m) => String -> m (SEither a b)
sEither :: String -> m (SEither a b)
sEither = String -> m (SEither a b)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sEither_ :: (SymVal a, SymVal b, MonadSymbolic m) => m (SEither a b)
sEither_ :: m (SEither a b)
sEither_ = m (SEither a b)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sEithers :: (SymVal a, SymVal b, MonadSymbolic m) => [String] -> m [SEither a b]
sEithers :: [String] -> m [SEither a b]
sEithers = [String] -> m [SEither a b]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sMaybe :: (SymVal a, MonadSymbolic m) => String -> m (SMaybe a)
sMaybe :: String -> m (SMaybe a)
sMaybe = String -> m (SMaybe a)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sMaybe_ :: (SymVal a, MonadSymbolic m) => m (SMaybe a)
sMaybe_ :: m (SMaybe a)
sMaybe_ = m (SMaybe a)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sMaybes :: (SymVal a, MonadSymbolic m) => [String] -> m [SMaybe a]
sMaybes :: [String] -> m [SMaybe a]
sMaybes = [String] -> m [SMaybe a]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
sSet :: (Ord a, SymVal a, MonadSymbolic m) => String -> m (SSet a)
sSet :: String -> m (SSet a)
sSet = String -> m (SSet a)
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
String -> m (SBV a)
symbolic
sSet_ :: (Ord a, SymVal a, MonadSymbolic m) => m (SSet a)
sSet_ :: m (SSet a)
sSet_ = m (SSet a)
forall a (m :: * -> *). (SymVal a, MonadSymbolic m) => m (SBV a)
free_
sSets :: (Ord a, SymVal a, MonadSymbolic m) => [String] -> m [SSet a]
sSets :: [String] -> m [SSet a]
sSets = [String] -> m [SSet a]
forall a (m :: * -> *).
(SymVal a, MonadSymbolic m) =>
[String] -> m [SBV a]
symbolics
solve :: MonadSymbolic m => [SBool] -> m SBool
solve :: [SBV Bool] -> m (SBV Bool)
solve = SBV Bool -> m (SBV Bool)
forall (m :: * -> *) a. Monad m => a -> m a
return (SBV Bool -> m (SBV Bool))
-> ([SBV Bool] -> SBV Bool) -> [SBV Bool] -> m (SBV Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [SBV Bool] -> SBV Bool
sAnd
sRealToSInteger :: SReal -> SInteger
sRealToSInteger :: SBV AlgReal -> SBV Integer
sRealToSInteger SBV AlgReal
x
| Just AlgReal
i <- SBV AlgReal -> Maybe AlgReal
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV AlgReal
x, AlgReal -> Bool
isExactRational AlgReal
i
= Integer -> SBV Integer
forall a. SymVal a => a -> SBV a
literal (Integer -> SBV Integer) -> Integer -> SBV Integer
forall a b. (a -> b) -> a -> b
$ Rational -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
floor (AlgReal -> Rational
forall a. Real a => a -> Rational
toRational AlgReal
i)
| Bool
True
= SVal -> SBV Integer
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KUnbounded (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
y)))
where y :: State -> IO SV
y State
st = do SV
xsv <- State -> SBV AlgReal -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV AlgReal
x
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KUnbounded (Op -> [SV] -> SBVExpr
SBVApp (Kind -> Kind -> Op
KindCast Kind
KReal Kind
KUnbounded) [SV
xsv])
label :: SymVal a => String -> SBV a -> SBV a
label :: String -> SBV a -> SBV a
label String
m SBV a
x
| Just a
_ <- SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
x = SBV a
x
| Bool
True = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x
r :: State -> IO SV
r State
st = do SV
xsv <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
x
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k (Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Label String
m) [SV
xsv])
checkObservableName :: String -> Maybe String
checkObservableName :: String -> Maybe String
checkObservableName String
lbl
| String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
lbl
= String -> Maybe String
forall a. a -> Maybe a
Just String
"SBV.observe: Bad empty name!"
| (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
lbl String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
smtLibReservedNames
= String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ String
"SBV.observe: The name chosen is reserved, please change it!: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
forall a. Show a => a -> String
show String
lbl
| String
"s" String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` String
lbl Bool -> Bool -> Bool
&& (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isDigit (Int -> String -> String
forall a. Int -> [a] -> [a]
drop Int
1 String
lbl)
= String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ String
"SBV.observe: Names of the form sXXX are internal to SBV, please use a different name: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
forall a. Show a => a -> String
show String
lbl
| Bool
True
= Maybe String
forall a. Maybe a
Nothing
observeIf :: SymVal a => (a -> Bool) -> String -> SBV a -> SBV a
observeIf :: (a -> Bool) -> String -> SBV a -> SBV a
observeIf a -> Bool
cond String
m SBV a
x
| Just String
bad <- String -> Maybe String
checkObservableName String
m
= String -> SBV a
forall a. HasCallStack => String -> a
error String
bad
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x
r :: State -> IO SV
r State
st = do SV
xsv <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
x
State -> String -> (CV -> Bool) -> SV -> IO ()
recordObservable State
st String
m (a -> Bool
cond (a -> Bool) -> (CV -> a) -> CV -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CV -> a
forall a. SymVal a => CV -> a
fromCV) SV
xsv
SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
xsv
observe :: SymVal a => String -> SBV a -> SBV a
observe :: String -> SBV a -> SBV a
observe = (a -> Bool) -> String -> SBV a -> SBV a
forall a. SymVal a => (a -> Bool) -> String -> SBV a -> SBV a
observeIf (Bool -> a -> Bool
forall a b. a -> b -> a
const Bool
True)
sObserve :: SymVal a => String -> SBV a -> Symbolic ()
sObserve :: String -> SBV a -> Symbolic ()
sObserve String
m SBV a
x
| Just String
bad <- String -> Maybe String
checkObservableName String
m
= String -> Symbolic ()
forall a. HasCallStack => String -> a
error String
bad
| Bool
True
= do State
st <- SymbolicT IO State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
IO () -> Symbolic ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Symbolic ()) -> IO () -> Symbolic ()
forall a b. (a -> b) -> a -> b
$ do SV
xsv <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
x
State -> String -> (CV -> Bool) -> SV -> IO ()
recordObservable State
st String
m (Bool -> CV -> Bool
forall a b. a -> b -> a
const Bool
True) SV
xsv
infix 4 .==, ./=, .===, ./==
class EqSymbolic a where
(.==) :: a -> a -> SBool
(./=) :: a -> a -> SBool
(.===) :: a -> a -> SBool
(./==) :: a -> a -> SBool
distinct :: [a] -> SBool
distinctExcept :: [a] -> [a] -> SBool
allEqual :: [a] -> SBool
sElem :: a -> [a] -> SBool
sNotElem :: a -> [a] -> SBool
{-# MINIMAL (.==) #-}
a
x ./= a
y = SBV Bool -> SBV Bool
sNot (a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
y)
a
x .=== a
y = a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
y
a
x ./== a
y = SBV Bool -> SBV Bool
sNot (a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.=== a
y)
allEqual [] = SBV Bool
sTrue
allEqual (a
x:[a]
xs) = (a -> SBV Bool) -> [a] -> SBV Bool
forall a. (a -> SBV Bool) -> [a] -> SBV Bool
sAll (a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.==) [a]
xs
distinct [] = SBV Bool
sTrue
distinct (a
x:[a]
xs) = (a -> SBV Bool) -> [a] -> SBV Bool
forall a. (a -> SBV Bool) -> [a] -> SBV Bool
sAll (a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
./=) [a]
xs SBV Bool -> SBV Bool -> SBV Bool
.&& [a] -> SBV Bool
forall a. EqSymbolic a => [a] -> SBV Bool
distinct [a]
xs
distinctExcept [a]
es [a]
ignored = [a] -> SBV Bool
go [a]
es
where isIgnored :: a -> SBV Bool
isIgnored = (a -> [a] -> SBV Bool
forall a. EqSymbolic a => a -> [a] -> SBV Bool
`sElem` [a]
ignored)
go :: [a] -> SBV Bool
go [] = SBV Bool
sTrue
go (a
x:[a]
xs) = let xOK :: SBV Bool
xOK = a -> SBV Bool
isIgnored a
x SBV Bool -> SBV Bool -> SBV Bool
.|| (a -> SBV Bool) -> [a] -> SBV Bool
forall a. (a -> SBV Bool) -> [a] -> SBV Bool
sAll (\a
y -> a -> SBV Bool
isIgnored a
y SBV Bool -> SBV Bool -> SBV Bool
.|| a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
./= a
y) [a]
xs
in SBV Bool
xOK SBV Bool -> SBV Bool -> SBV Bool
.&& [a] -> SBV Bool
go [a]
xs
a
x `sElem` [a]
xs = (a -> SBV Bool) -> [a] -> SBV Bool
forall a. (a -> SBV Bool) -> [a] -> SBV Bool
sAny (a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
x) [a]
xs
a
x `sNotElem` [a]
xs = SBV Bool -> SBV Bool
sNot (a
x a -> [a] -> SBV Bool
forall a. EqSymbolic a => a -> [a] -> SBV Bool
`sElem` [a]
xs)
infix 4 .<, .<=, .>, .>=
class (Mergeable a, EqSymbolic a) => OrdSymbolic a where
(.<) :: a -> a -> SBool
(.<=) :: a -> a -> SBool
(.>) :: a -> a -> SBool
(.>=) :: a -> a -> SBool
smin :: a -> a -> a
smax :: a -> a -> a
inRange :: a -> (a, a) -> SBool
{-# MINIMAL (.<) #-}
a
a .<= a
b = a
a a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< a
b SBV Bool -> SBV Bool -> SBV Bool
.|| a
a a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
b
a
a .> a
b = a
b a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< a
a
a
a .>= a
b = a
b a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.<= a
a
a
a `smin` a
b = SBV Bool -> a -> a -> a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (a
a a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.<= a
b) a
a a
b
a
a `smax` a
b = SBV Bool -> a -> a -> a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (a
a a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.<= a
b) a
b a
a
inRange a
x (a
y, a
z) = a
x a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.>= a
y SBV Bool -> SBV Bool -> SBV Bool
.&& a
x a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.<= a
z
instance EqSymbolic (SBV a) where
SBV SVal
x .== :: SBV a -> SBV a -> SBV Bool
.== SBV SVal
y = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svEqual SVal
x SVal
y)
SBV SVal
x ./= :: SBV a -> SBV a -> SBV Bool
./= SBV SVal
y = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svNotEqual SVal
x SVal
y)
SBV SVal
x .=== :: SBV a -> SBV a -> SBV Bool
.=== SBV SVal
y = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svStrongEqual SVal
x SVal
y)
distinct :: [SBV a] -> SBV Bool
distinct [] = SBV Bool
sTrue
distinct [SBV a
_] = SBV Bool
sTrue
distinct [SBV a]
xs | (SBV a -> Bool) -> [SBV a] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all SBV a -> Bool
forall a. SBV a -> Bool
isConc [SBV a]
xs = [SBV a] -> SBV Bool
forall a. EqSymbolic a => [a] -> SBV Bool
checkDiff [SBV a]
xs
| [SBV SVal
a, SBV SVal
b] <- [SBV a]
xs, SVal
a SVal -> SVal -> Bool
`is` Bool -> SVal
svBool Bool
True = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SBV Bool) -> SVal -> SBV Bool
forall a b. (a -> b) -> a -> b
$ SVal -> SVal
svNot SVal
b
| [SBV SVal
a, SBV SVal
b] <- [SBV a]
xs, SVal
b SVal -> SVal -> Bool
`is` Bool -> SVal
svBool Bool
True = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SBV Bool) -> SVal -> SBV Bool
forall a b. (a -> b) -> a -> b
$ SVal -> SVal
svNot SVal
a
| [SBV SVal
a, SBV SVal
b] <- [SBV a]
xs, SVal
a SVal -> SVal -> Bool
`is` Bool -> SVal
svBool Bool
False = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV SVal
b
| [SBV SVal
a, SBV SVal
b] <- [SBV a]
xs, SVal
b SVal -> SVal -> Bool
`is` Bool -> SVal
svBool Bool
False = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV SVal
a
| [SBV a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SBV a]
xs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
2 Bool -> Bool -> Bool
&& SBV a -> Bool
forall a. SBV a -> Bool
isBool ([SBV a] -> SBV a
forall a. [a] -> a
head [SBV a]
xs) = SBV Bool
sFalse
| Bool
True = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r)))
where r :: State -> IO SV
r State
st = do [SV]
xsv <- (SBV a -> IO SV) -> [SBV a] -> IO [SV]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st) [SBV a]
xs
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KBool (Op -> [SV] -> SBVExpr
SBVApp Op
NotEqual [SV]
xsv)
checkDiff :: [a] -> SBV Bool
checkDiff [] = SBV Bool
sTrue
checkDiff (a
a:[a]
as) = (a -> SBV Bool) -> [a] -> SBV Bool
forall a. (a -> SBV Bool) -> [a] -> SBV Bool
sAll (a
a a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
./=) [a]
as SBV Bool -> SBV Bool -> SBV Bool
.&& [a] -> SBV Bool
checkDiff [a]
as
isConc :: SBV a -> Bool
isConc (SBV (SVal Kind
_ (Left CV
_))) = Bool
True
isConc SBV a
_ = Bool
False
SVal Kind
k1 (Left CV
c1) is :: SVal -> SVal -> Bool
`is` SVal Kind
k2 (Left CV
c2) = (Kind
k1, CV
c1) (Kind, CV) -> (Kind, CV) -> Bool
forall a. Eq a => a -> a -> Bool
== (Kind
k2, CV
c2)
SVal
_ `is` SVal
_ = Bool
False
isBool :: SBV a -> Bool
isBool (SBV (SVal Kind
KBool Either CV (Cached SV)
_)) = Bool
True
isBool SBV a
_ = Bool
False
distinctExcept :: [SBV a] -> [SBV a] -> SBV Bool
distinctExcept [] [SBV a]
_ = SBV Bool
sTrue
distinctExcept [SBV a
_] [SBV a]
_ = SBV Bool
sTrue
distinctExcept [SBV a]
es [SBV a]
ignored
| (SBV a -> Bool) -> [SBV a] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all SBV a -> Bool
forall a. SBV a -> Bool
isConc ([SBV a]
es [SBV a] -> [SBV a] -> [SBV a]
forall a. [a] -> [a] -> [a]
++ [SBV a]
ignored)
= [SBV a] -> SBV Bool
forall a. EqSymbolic a => [a] -> SBV Bool
distinct ((SBV a -> Bool) -> [SBV a] -> [SBV a]
forall a. (a -> Bool) -> [a] -> [a]
filter SBV a -> Bool
ignoreConc [SBV a]
es)
| Bool
True
= SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r)))
where ignoreConc :: SBV a -> Bool
ignoreConc SBV a
x = case SBV a
x SBV a -> [SBV a] -> SBV Bool
forall a. EqSymbolic a => a -> [a] -> SBV Bool
`sElem` [SBV a]
ignored of
SBV (SVal Kind
KBool (Left CV
cv)) -> CV -> Bool
cvToBool CV
cv
SBV Bool
_ -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"distinctExcept: Impossible happened, concrete sElem failed: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ([SBV a], [SBV a], SBV a) -> String
forall a. Show a => a -> String
show ([SBV a]
es, [SBV a]
ignored, SBV a
x)
ek :: Kind
ek = case [SBV a] -> SBV a
forall a. [a] -> a
head [SBV a]
es of
SBV (SVal Kind
k Either CV (Cached SV)
_) -> Kind
k
r :: State -> IO SV
r State
st = do let zero :: SBV Integer
zero = SBV Integer
0 :: SInteger
SArray a Integer
arr <- SArr -> SArray a Integer
forall a b. SArr -> SArray a b
SArray (SArr -> SArray a Integer) -> IO SArr -> IO (SArray a Integer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> State -> (Kind, Kind) -> (Int -> String) -> Maybe SVal -> IO SArr
newSArr State
st (Kind
ek, Kind
KUnbounded) (\Int
i -> String
"array_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i) (SVal -> Maybe SVal
forall a. a -> Maybe a
Just (SBV Integer -> SVal
forall a. SBV a -> SVal
unSBV SBV Integer
zero))
let incr :: SBV a -> SArray a Integer -> SBV Integer
incr SBV a
x SArray a Integer
table = SBV Bool -> SBV Integer -> SBV Integer -> SBV Integer
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
x SBV a -> [SBV a] -> SBV Bool
forall a. EqSymbolic a => a -> [a] -> SBV Bool
`sElem` [SBV a]
ignored) SBV Integer
zero (SBV Integer
1 SBV Integer -> SBV Integer -> SBV Integer
forall a. Num a => a -> a -> a
+ SArray a Integer -> SBV a -> SBV Integer
forall (array :: * -> * -> *) a b.
SymArray array =>
array a b -> SBV a -> SBV b
readArray SArray a Integer
table SBV a
x)
finalArray :: SArray a Integer
finalArray = (SArray a Integer -> SBV a -> SArray a Integer)
-> SArray a Integer -> [SBV a] -> SArray a Integer
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (\SArray a Integer
table SBV a
x -> SArray a Integer -> SBV a -> SBV Integer -> SArray a Integer
forall (array :: * -> * -> *) b a.
(SymArray array, SymVal b) =>
array a b -> SBV a -> SBV b -> array a b
writeArray SArray a Integer
table SBV a
x (SBV a -> SArray a Integer -> SBV Integer
incr SBV a
x SArray a Integer
table)) SArray a Integer
arr [SBV a]
es
State -> SBV Bool -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV Bool -> IO SV) -> SBV Bool -> IO SV
forall a b. (a -> b) -> a -> b
$ (SBV a -> SBV Bool) -> [SBV a] -> SBV Bool
forall a. (a -> SBV Bool) -> [a] -> SBV Bool
sAll (\SBV a
e -> SArray a Integer -> SBV a -> SBV Integer
forall (array :: * -> * -> *) a b.
SymArray array =>
array a b -> SBV a -> SBV b
readArray SArray a Integer
finalArray SBV a
e SBV Integer -> SBV Integer -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.<= SBV Integer
1) [SBV a]
es
isConc :: SBV a -> Bool
isConc (SBV (SVal Kind
_ (Left CV
_))) = Bool
True
isConc SBV a
_ = Bool
False
instance (Ord a, SymVal a) => OrdSymbolic (SBV a) where
a :: SBV a
a@(SBV SVal
x) .< :: SBV a -> SBV a -> SBV Bool
.< b :: SBV a
b@(SBV SVal
y) | String -> SBV a -> SBV a -> Bool
forall a. (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool
smtComparable String
"<" SBV a
a SBV a
b = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svLessThan SVal
x SVal
y)
| Bool
True = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svStructuralLessThan SVal
x SVal
y)
a :: SBV a
a@(SBV SVal
x) .<= :: SBV a -> SBV a -> SBV Bool
.<= b :: SBV a
b@(SBV SVal
y) | String -> SBV a -> SBV a -> Bool
forall a. (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool
smtComparable String
".<=" SBV a
a SBV a
b = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svLessEq SVal
x SVal
y)
| Bool
True = SBV a
a SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< SBV a
b SBV Bool -> SBV Bool -> SBV Bool
.|| SBV a
a SBV a -> SBV a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a
b
a :: SBV a
a@(SBV SVal
x) .> :: SBV a -> SBV a -> SBV Bool
.> b :: SBV a
b@(SBV SVal
y) | String -> SBV a -> SBV a -> Bool
forall a. (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool
smtComparable String
">" SBV a
a SBV a
b = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svGreaterThan SVal
x SVal
y)
| Bool
True = SBV a
b SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< SBV a
a
a :: SBV a
a@(SBV SVal
x) .>= :: SBV a -> SBV a -> SBV Bool
.>= b :: SBV a
b@(SBV SVal
y) | String -> SBV a -> SBV a -> Bool
forall a. (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool
smtComparable String
">=" SBV a
a SBV a
b = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svGreaterEq SVal
x SVal
y)
| Bool
True = SBV a
b SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.<= SBV a
a
smtComparable :: (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool
smtComparable :: String -> SBV a -> SBV a -> Bool
smtComparable String
op SBV a
x SBV a
y
| SBV a -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV a
x Bool -> Bool -> Bool
&& SBV a -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV a
y Bool -> Bool -> Bool
&& Bool -> Bool
not (Kind -> Bool
forall a. HasKind a => a -> Bool
isSet Kind
k)
= Bool
True
| Bool
True
= case Kind
k of
Kind
KBool -> Bool
True
KBounded {} -> Bool
True
KUnbounded {} -> Bool
True
KReal {} -> Bool
True
KUserSort {} -> Bool
True
Kind
KFloat -> Bool
True
Kind
KDouble -> Bool
True
KRational {} -> Bool
True
KFP {} -> Bool
True
Kind
KChar -> Bool
True
Kind
KString -> Bool
True
KList {} -> Bool
nope
KSet {} -> Bool
nope
KTuple {} -> Bool
False
KMaybe {} -> Bool
False
KEither {} -> Bool
False
where k :: Kind
k = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x
nope :: Bool
nope = String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Data.SBV.OrdSymbolic: SMTLib does not support " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
op String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" for " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
instance EqSymbolic Bool where
Bool
x .== :: Bool -> Bool -> SBV Bool
.== Bool
y = Bool -> SBV Bool
fromBool (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ Bool
x Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
y
instance EqSymbolic a => EqSymbolic [a] where
[] .== :: [a] -> [a] -> SBV Bool
.== [] = SBV Bool
sTrue
(a
x:[a]
xs) .== (a
y:[a]
ys) = a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
y SBV Bool -> SBV Bool -> SBV Bool
.&& [a]
xs [a] -> [a] -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== [a]
ys
[a]
_ .== [a]
_ = SBV Bool
sFalse
instance OrdSymbolic a => OrdSymbolic [a] where
[] .< :: [a] -> [a] -> SBV Bool
.< [] = SBV Bool
sFalse
[] .< [a]
_ = SBV Bool
sTrue
[a]
_ .< [] = SBV Bool
sFalse
(a
x:[a]
xs) .< (a
y:[a]
ys) = a
x a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< a
y SBV Bool -> SBV Bool -> SBV Bool
.|| (a
x a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
y SBV Bool -> SBV Bool -> SBV Bool
.&& [a]
xs [a] -> [a] -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< [a]
ys)
instance EqSymbolic a => EqSymbolic (Maybe a) where
Maybe a
Nothing .== :: Maybe a -> Maybe a -> SBV Bool
.== Maybe a
Nothing = SBV Bool
sTrue
Just a
a .== Just a
b = a
a a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
b
Maybe a
_ .== Maybe a
_ = SBV Bool
sFalse
instance OrdSymbolic a => OrdSymbolic (Maybe a) where
Maybe a
Nothing .< :: Maybe a -> Maybe a -> SBV Bool
.< Maybe a
Nothing = SBV Bool
sFalse
Maybe a
Nothing .< Maybe a
_ = SBV Bool
sTrue
Just a
_ .< Maybe a
Nothing = SBV Bool
sFalse
Just a
a .< Just a
b = a
a a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< a
b
instance (EqSymbolic a, EqSymbolic b) => EqSymbolic (Either a b) where
Left a
a .== :: Either a b -> Either a b -> SBV Bool
.== Left a
b = a
a a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
b
Right b
a .== Right b
b = b
a b -> b -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== b
b
Either a b
_ .== Either a b
_ = SBV Bool
sFalse
instance (OrdSymbolic a, OrdSymbolic b) => OrdSymbolic (Either a b) where
Left a
a .< :: Either a b -> Either a b -> SBV Bool
.< Left a
b = a
a a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< a
b
Left a
_ .< Right b
_ = SBV Bool
sTrue
Right b
_ .< Left a
_ = SBV Bool
sFalse
Right b
a .< Right b
b = b
a b -> b -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< b
b
instance (EqSymbolic a, EqSymbolic b) => EqSymbolic (a, b) where
(a
a0, b
b0) .== :: (a, b) -> (a, b) -> SBV Bool
.== (a
a1, b
b1) = a
a0 a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
a1 SBV Bool -> SBV Bool -> SBV Bool
.&& b
b0 b -> b -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== b
b1
instance (OrdSymbolic a, OrdSymbolic b) => OrdSymbolic (a, b) where
(a
a0, b
b0) .< :: (a, b) -> (a, b) -> SBV Bool
.< (a
a1, b
b1) = a
a0 a -> a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< a
a1 SBV Bool -> SBV Bool -> SBV Bool
.|| (a
a0 a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
a1 SBV Bool -> SBV Bool -> SBV Bool
.&& b
b0 b -> b -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< b
b1)
instance (EqSymbolic a, EqSymbolic b, EqSymbolic c) => EqSymbolic (a, b, c) where
(a
a0, b
b0, c
c0) .== :: (a, b, c) -> (a, b, c) -> SBV Bool
.== (a
a1, b
b1, c
c1) = (a
a0, b
b0) (a, b) -> (a, b) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1) SBV Bool -> SBV Bool -> SBV Bool
.&& c
c0 c -> c -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== c
c1
instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c) => OrdSymbolic (a, b, c) where
(a
a0, b
b0, c
c0) .< :: (a, b, c) -> (a, b, c) -> SBV Bool
.< (a
a1, b
b1, c
c1) = (a
a0, b
b0) (a, b) -> (a, b) -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< (a
a1, b
b1) SBV Bool -> SBV Bool -> SBV Bool
.|| ((a
a0, b
b0) (a, b) -> (a, b) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1) SBV Bool -> SBV Bool -> SBV Bool
.&& c
c0 c -> c -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< c
c1)
instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d) => EqSymbolic (a, b, c, d) where
(a
a0, b
b0, c
c0, d
d0) .== :: (a, b, c, d) -> (a, b, c, d) -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1) = (a
a0, b
b0, c
c0) (a, b, c) -> (a, b, c) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1) SBV Bool -> SBV Bool -> SBV Bool
.&& d
d0 d -> d -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== d
d1
instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d) => OrdSymbolic (a, b, c, d) where
(a
a0, b
b0, c
c0, d
d0) .< :: (a, b, c, d) -> (a, b, c, d) -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1) = (a
a0, b
b0, c
c0) (a, b, c) -> (a, b, c) -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< (a
a1, b
b1, c
c1) SBV Bool -> SBV Bool -> SBV Bool
.|| ((a
a0, b
b0, c
c0) (a, b, c) -> (a, b, c) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1) SBV Bool -> SBV Bool -> SBV Bool
.&& d
d0 d -> d -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< d
d1)
instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e) => EqSymbolic (a, b, c, d, e) where
(a
a0, b
b0, c
c0, d
d0, e
e0) .== :: (a, b, c, d, e) -> (a, b, c, d, e) -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1) = (a
a0, b
b0, c
c0, d
d0) (a, b, c, d) -> (a, b, c, d) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1) SBV Bool -> SBV Bool -> SBV Bool
.&& e
e0 e -> e -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== e
e1
instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e) => OrdSymbolic (a, b, c, d, e) where
(a
a0, b
b0, c
c0, d
d0, e
e0) .< :: (a, b, c, d, e) -> (a, b, c, d, e) -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1, e
e1) = (a
a0, b
b0, c
c0, d
d0) (a, b, c, d) -> (a, b, c, d) -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1) SBV Bool -> SBV Bool -> SBV Bool
.|| ((a
a0, b
b0, c
c0, d
d0) (a, b, c, d) -> (a, b, c, d) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1) SBV Bool -> SBV Bool -> SBV Bool
.&& e
e0 e -> e -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< e
e1)
instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e, EqSymbolic f) => EqSymbolic (a, b, c, d, e, f) where
(a
a0, b
b0, c
c0, d
d0, e
e0, f
f0) .== :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1) = (a
a0, b
b0, c
c0, d
d0, e
e0) (a, b, c, d, e) -> (a, b, c, d, e) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1) SBV Bool -> SBV Bool -> SBV Bool
.&& f
f0 f -> f -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== f
f1
instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e, OrdSymbolic f) => OrdSymbolic (a, b, c, d, e, f) where
(a
a0, b
b0, c
c0, d
d0, e
e0, f
f0) .< :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1) = (a
a0, b
b0, c
c0, d
d0, e
e0) (a, b, c, d, e) -> (a, b, c, d, e) -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1, e
e1)
SBV Bool -> SBV Bool -> SBV Bool
.|| ((a
a0, b
b0, c
c0, d
d0, e
e0) (a, b, c, d, e) -> (a, b, c, d, e) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1) SBV Bool -> SBV Bool -> SBV Bool
.&& f
f0 f -> f -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< f
f1)
instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e, EqSymbolic f, EqSymbolic g) => EqSymbolic (a, b, c, d, e, f, g) where
(a
a0, b
b0, c
c0, d
d0, e
e0, f
f0, g
g0) .== :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1, g
g1) = (a
a0, b
b0, c
c0, d
d0, e
e0, f
f0) (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1) SBV Bool -> SBV Bool -> SBV Bool
.&& g
g0 g -> g -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== g
g1
instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e, OrdSymbolic f, OrdSymbolic g) => OrdSymbolic (a, b, c, d, e, f, g) where
(a
a0, b
b0, c
c0, d
d0, e
e0, f
f0, g
g0) .< :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1, g
g1) = (a
a0, b
b0, c
c0, d
d0, e
e0, f
f0) (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1)
SBV Bool -> SBV Bool -> SBV Bool
.|| ((a
a0, b
b0, c
c0, d
d0, e
e0, f
f0) (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1) SBV Bool -> SBV Bool -> SBV Bool
.&& g
g0 g -> g -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< g
g1)
class (SymVal a, Num a, Bits a, Integral a) => SIntegral a
instance SIntegral Word8
instance SIntegral Word16
instance SIntegral Word32
instance SIntegral Word64
instance SIntegral Int8
instance SIntegral Int16
instance SIntegral Int32
instance SIntegral Int64
instance SIntegral Integer
class (Ord a, SymVal a, Num a, Bits a) => SFiniteBits a where
sFiniteBitSize :: SBV a -> Int
lsb :: SBV a -> SBool
msb :: SBV a -> SBool
blastBE :: SBV a -> [SBool]
blastLE :: SBV a -> [SBool]
fromBitsBE :: [SBool] -> SBV a
fromBitsLE :: [SBool] -> SBV a
sTestBit :: SBV a -> Int -> SBool
:: SBV a -> [Int] -> [SBool]
sPopCount :: SBV a -> SWord8
setBitTo :: SBV a -> Int -> SBool -> SBV a
fullAdder :: SBV a -> SBV a -> (SBool, SBV a)
fullMultiplier :: SBV a -> SBV a -> (SBV a, SBV a)
sCountLeadingZeros :: SBV a -> SWord8
sCountTrailingZeros :: SBV a -> SWord8
{-# MINIMAL sFiniteBitSize #-}
lsb (SBV SVal
v) = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svTestBit SVal
v Int
0)
msb SBV a
x = SBV a -> Int -> SBV Bool
forall a. SFiniteBits a => SBV a -> Int -> SBV Bool
sTestBit SBV a
x (SBV a -> Int
forall a. SFiniteBits a => SBV a -> Int
sFiniteBitSize SBV a
x Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
blastBE = [SBV Bool] -> [SBV Bool]
forall a. [a] -> [a]
reverse ([SBV Bool] -> [SBV Bool])
-> (SBV a -> [SBV Bool]) -> SBV a -> [SBV Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SBV a -> [SBV Bool]
forall a. SFiniteBits a => SBV a -> [SBV Bool]
blastLE
blastLE SBV a
x = (Int -> SBV Bool) -> [Int] -> [SBV Bool]
forall a b. (a -> b) -> [a] -> [b]
map (SBV a -> Int -> SBV Bool
forall a. SFiniteBits a => SBV a -> Int -> SBV Bool
sTestBit SBV a
x) [Int
0 .. SBV a -> Int
forall a. HasKind a => a -> Int
intSizeOf SBV a
x Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
fromBitsBE = [SBV Bool] -> SBV a
forall a. SFiniteBits a => [SBV Bool] -> SBV a
fromBitsLE ([SBV Bool] -> SBV a)
-> ([SBV Bool] -> [SBV Bool]) -> [SBV Bool] -> SBV a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [SBV Bool] -> [SBV Bool]
forall a. [a] -> [a]
reverse
fromBitsLE [SBV Bool]
bs
| [SBV Bool] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SBV Bool]
bs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
w
= String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"SBV.SFiniteBits.fromBitsLE/BE: Expected: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" bits, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show ([SBV Bool] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SBV Bool]
bs)
| Bool
True
= SBV a
result
where w :: Int
w = SBV a -> Int
forall a. SFiniteBits a => SBV a -> Int
sFiniteBitSize SBV a
result
result :: SBV a
result = SBV a -> Int -> [SBV Bool] -> SBV a
forall t. (Mergeable t, Bits t) => t -> Int -> [SBV Bool] -> t
go SBV a
0 Int
0 [SBV Bool]
bs
go :: t -> Int -> [SBV Bool] -> t
go !t
acc Int
_ [] = t
acc
go !t
acc !Int
i (SBV Bool
x:[SBV Bool]
xs) = t -> Int -> [SBV Bool] -> t
go (SBV Bool -> t -> t -> t
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
x (t -> Int -> t
forall a. Bits a => a -> Int -> a
setBit t
acc Int
i) t
acc) (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) [SBV Bool]
xs
sTestBit (SBV SVal
x) Int
i = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svTestBit SVal
x Int
i)
sExtractBits SBV a
x = (Int -> SBV Bool) -> [Int] -> [SBV Bool]
forall a b. (a -> b) -> [a] -> [b]
map (SBV a -> Int -> SBV Bool
forall a. SFiniteBits a => SBV a -> Int -> SBV Bool
sTestBit SBV a
x)
sPopCount SBV a
x
| SBV a -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV a
x = SBV Word8 -> SBV a -> SBV Word8
forall t t. (Num t, Num t, Bits t) => t -> t -> t
go SBV Word8
0 SBV a
x
| Bool
True = [SBV Word8] -> SBV Word8
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [SBV Bool -> SBV Word8 -> SBV Word8 -> SBV Word8
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
b SBV Word8
1 SBV Word8
0 | SBV Bool
b <- SBV a -> [SBV Bool]
forall a. SFiniteBits a => SBV a -> [SBV Bool]
blastLE SBV a
x]
where
go :: t -> t -> t
go !t
c t
0 = t
c
go !t
c t
w = t -> t -> t
go (t
ct -> t -> t
forall a. Num a => a -> a -> a
+t
1) (t
w t -> t -> t
forall a. Bits a => a -> a -> a
.&. (t
wt -> t -> t
forall a. Num a => a -> a -> a
-t
1))
setBitTo SBV a
x Int
i SBV Bool
b = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
b (SBV a -> Int -> SBV a
forall a. Bits a => a -> Int -> a
setBit SBV a
x Int
i) (SBV a -> Int -> SBV a
forall a. Bits a => a -> Int -> a
clearBit SBV a
x Int
i)
fullAdder SBV a
a SBV a
b
| SBV a -> Bool
forall a. Bits a => a -> Bool
isSigned SBV a
a = String -> (SBV Bool, SBV a)
forall a. HasCallStack => String -> a
error String
"fullAdder: only works on unsigned numbers"
| Bool
True = (SBV a
a SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.> SBV a
s SBV Bool -> SBV Bool -> SBV Bool
.|| SBV a
b SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.> SBV a
s, SBV a
s)
where s :: SBV a
s = SBV a
a SBV a -> SBV a -> SBV a
forall a. Num a => a -> a -> a
+ SBV a
b
fullMultiplier SBV a
a SBV a
b
| SBV a -> Bool
forall a. Bits a => a -> Bool
isSigned SBV a
a = String -> (SBV a, SBV a)
forall a. HasCallStack => String -> a
error String
"fullMultiplier: only works on unsigned numbers"
| Bool
True = (Int -> SBV a -> SBV a -> SBV a
go (SBV a -> Int
forall a. SFiniteBits a => SBV a -> Int
sFiniteBitSize SBV a
a) SBV a
0 SBV a
a, SBV a
aSBV a -> SBV a -> SBV a
forall a. Num a => a -> a -> a
*SBV a
b)
where go :: Int -> SBV a -> SBV a -> SBV a
go Int
0 SBV a
p SBV a
_ = SBV a
p
go Int
n SBV a
p SBV a
x = let (SBV Bool
c, SBV a
p') = SBV Bool
-> (SBV Bool, SBV a) -> (SBV Bool, SBV a) -> (SBV Bool, SBV a)
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a -> SBV Bool
forall a. SFiniteBits a => SBV a -> SBV Bool
lsb SBV a
x) (SBV a -> SBV a -> (SBV Bool, SBV a)
forall a. SFiniteBits a => SBV a -> SBV a -> (SBV Bool, SBV a)
fullAdder SBV a
p SBV a
b) (SBV Bool
sFalse, SBV a
p)
(SBV Bool
o, SBV a
p'') = SBV Bool -> SBV a -> (SBV Bool, SBV a)
forall a. SFiniteBits a => SBV Bool -> SBV a -> (SBV Bool, SBV a)
shiftIn SBV Bool
c SBV a
p'
(SBV Bool
_, SBV a
x') = SBV Bool -> SBV a -> (SBV Bool, SBV a)
forall a. SFiniteBits a => SBV Bool -> SBV a -> (SBV Bool, SBV a)
shiftIn SBV Bool
o SBV a
x
in Int -> SBV a -> SBV a -> SBV a
go (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) SBV a
p'' SBV a
x'
shiftIn :: SBV Bool -> SBV a -> (SBV Bool, SBV a)
shiftIn SBV Bool
k SBV a
v = (SBV a -> SBV Bool
forall a. SFiniteBits a => SBV a -> SBV Bool
lsb SBV a
v, SBV a
mask SBV a -> SBV a -> SBV a
forall a. Bits a => a -> a -> a
.|. (SBV a
v SBV a -> Int -> SBV a
forall a. Bits a => a -> Int -> a
`shiftR` Int
1))
where mask :: SBV a
mask = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
k (Int -> SBV a
forall a. Bits a => Int -> a
bit (SBV a -> Int
forall a. SFiniteBits a => SBV a -> Int
sFiniteBitSize SBV a
v Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)) SBV a
0
sCountLeadingZeros SBV a
x = Int -> SBV Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
m SBV Word8 -> SBV Word8 -> SBV Word8
forall a. Num a => a -> a -> a
- Int -> SBV Word8
go Int
m
where m :: Int
m = SBV a -> Int
forall a. SFiniteBits a => SBV a -> Int
sFiniteBitSize SBV a
x Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
go :: Int -> SWord8
go :: Int -> SBV Word8
go Int
i | Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = SBV Word8
i8
| Bool
True = SBV Bool -> SBV Word8 -> SBV Word8 -> SBV Word8
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a -> Int -> SBV Bool
forall a. SFiniteBits a => SBV a -> Int -> SBV Bool
sTestBit SBV a
x Int
i) SBV Word8
i8 (Int -> SBV Word8
go (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1))
where i8 :: SBV Word8
i8 = Word8 -> SBV Word8
forall a. SymVal a => a -> SBV a
literal (Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i :: Word8)
sCountTrailingZeros SBV a
x = Int -> SBV Word8
go Int
0
where m :: Int
m = SBV a -> Int
forall a. SFiniteBits a => SBV a -> Int
sFiniteBitSize SBV a
x
go :: Int -> SWord8
go :: Int -> SBV Word8
go Int
i | Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
m = SBV Word8
i8
| Bool
True = SBV Bool -> SBV Word8 -> SBV Word8 -> SBV Word8
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a -> Int -> SBV Bool
forall a. SFiniteBits a => SBV a -> Int -> SBV Bool
sTestBit SBV a
x Int
i) SBV Word8
i8 (Int -> SBV Word8
go (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1))
where i8 :: SBV Word8
i8 = Word8 -> SBV Word8
forall a. SymVal a => a -> SBV a
literal (Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i :: Word8)
instance SFiniteBits Word8 where sFiniteBitSize :: SBV Word8 -> Int
sFiniteBitSize SBV Word8
_ = Int
8
instance SFiniteBits Word16 where sFiniteBitSize :: SBV Word16 -> Int
sFiniteBitSize SBV Word16
_ = Int
16
instance SFiniteBits Word32 where sFiniteBitSize :: SBV Word32 -> Int
sFiniteBitSize SBV Word32
_ = Int
32
instance SFiniteBits Word64 where sFiniteBitSize :: SBV Word64 -> Int
sFiniteBitSize SBV Word64
_ = Int
64
instance SFiniteBits Int8 where sFiniteBitSize :: SBV Int8 -> Int
sFiniteBitSize SBV Int8
_ = Int
8
instance SFiniteBits Int16 where sFiniteBitSize :: SBV Int16 -> Int
sFiniteBitSize SBV Int16
_ = Int
16
instance SFiniteBits Int32 where sFiniteBitSize :: SBV Int32 -> Int
sFiniteBitSize SBV Int32
_ = Int
32
instance SFiniteBits Int64 where sFiniteBitSize :: SBV Int64 -> Int
sFiniteBitSize SBV Int64
_ = Int
64
oneIf :: (Ord a, Num a, SymVal a) => SBool -> SBV a
oneIf :: SBV Bool -> SBV a
oneIf SBV Bool
t = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
t SBV a
1 SBV a
0
liftPB :: String -> PBOp -> [SBool] -> SBool
liftPB :: String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
w PBOp
o [SBV Bool]
xs
| Just String
e <- PBOp -> Maybe String
check PBOp
o
= String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV." String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
e
| Bool
True
= SBV Bool
result
where check :: PBOp -> Maybe String
check (PB_AtMost Int
k) = Int -> Maybe String
forall a. (Ord a, Num a, Show a) => a -> Maybe String
pos Int
k
check (PB_AtLeast Int
k) = Int -> Maybe String
forall a. (Ord a, Num a, Show a) => a -> Maybe String
pos Int
k
check (PB_Exactly Int
k) = Int -> Maybe String
forall a. (Ord a, Num a, Show a) => a -> Maybe String
pos Int
k
check (PB_Le [Int]
cs Int
k) = Int -> Maybe String
forall a. (Ord a, Num a, Show a) => a -> Maybe String
pos Int
k Maybe String -> Maybe String -> Maybe String
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` [Int] -> Maybe String
match [Int]
cs
check (PB_Ge [Int]
cs Int
k) = Int -> Maybe String
forall a. (Ord a, Num a, Show a) => a -> Maybe String
pos Int
k Maybe String -> Maybe String -> Maybe String
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` [Int] -> Maybe String
match [Int]
cs
check (PB_Eq [Int]
cs Int
k) = Int -> Maybe String
forall a. (Ord a, Num a, Show a) => a -> Maybe String
pos Int
k Maybe String -> Maybe String -> Maybe String
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` [Int] -> Maybe String
match [Int]
cs
pos :: a -> Maybe String
pos a
k
| a
k a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0 = String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ String
"comparison value must be positive, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
k
| Bool
True = Maybe String
forall a. Maybe a
Nothing
match :: [Int] -> Maybe String
match [Int]
cs
| (Int -> Bool) -> [Int] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0) [Int]
cs = String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ String
"coefficients must be non-negative. Received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ [Int] -> String
forall a. Show a => a -> String
show [Int]
cs
| Int
lxs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
lcs = String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ String
"coefficient length must match number of arguments. Received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Int) -> String
forall a. Show a => a -> String
show (Int
lcs, Int
lxs)
| Bool
True = Maybe String
forall a. Maybe a
Nothing
where lxs :: Int
lxs = [SBV Bool] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SBV Bool]
xs
lcs :: Int
lcs = [Int] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Int]
cs
result :: SBV Bool
result = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r)))
r :: State -> IO SV
r State
st = do [SV]
xsv <- (SBV Bool -> IO SV) -> [SBV Bool] -> IO [SV]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (State -> SBV Bool -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st) [SBV Bool]
xs
State -> Kind -> IO ()
registerKind State
st Kind
KUnbounded
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KBool (Op -> [SV] -> SBVExpr
SBVApp (PBOp -> Op
PseudoBoolean PBOp
o) [SV]
xsv)
pbAtMost :: [SBool] -> Int -> SBool
pbAtMost :: [SBV Bool] -> Int -> SBV Bool
pbAtMost [SBV Bool]
xs Int
k
| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbAtMost: Non-negative value required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
k
| (SBV Bool -> Bool) -> [SBV Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all SBV Bool -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete [SBV Bool]
xs = Bool -> SBV Bool
forall a. SymVal a => a -> SBV a
literal (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ((SBV Bool -> Integer) -> [SBV Bool] -> [Integer]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Int -> SBV Bool -> Integer
pbToInteger String
"pbAtMost" Int
1) [SBV Bool]
xs) Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k
| Bool
True = String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
"pbAtMost" (Int -> PBOp
PB_AtMost Int
k) [SBV Bool]
xs
pbAtLeast :: [SBool] -> Int -> SBool
pbAtLeast :: [SBV Bool] -> Int -> SBV Bool
pbAtLeast [SBV Bool]
xs Int
k
| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbAtLeast: Non-negative value required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
k
| (SBV Bool -> Bool) -> [SBV Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all SBV Bool -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete [SBV Bool]
xs = Bool -> SBV Bool
forall a. SymVal a => a -> SBV a
literal (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ((SBV Bool -> Integer) -> [SBV Bool] -> [Integer]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Int -> SBV Bool -> Integer
pbToInteger String
"pbAtLeast" Int
1) [SBV Bool]
xs) Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k
| Bool
True = String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
"pbAtLeast" (Int -> PBOp
PB_AtLeast Int
k) [SBV Bool]
xs
pbExactly :: [SBool] -> Int -> SBool
pbExactly :: [SBV Bool] -> Int -> SBV Bool
pbExactly [SBV Bool]
xs Int
k
| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbExactly: Non-negative value required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
k
| (SBV Bool -> Bool) -> [SBV Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all SBV Bool -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete [SBV Bool]
xs = Bool -> SBV Bool
forall a. SymVal a => a -> SBV a
literal (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ((SBV Bool -> Integer) -> [SBV Bool] -> [Integer]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Int -> SBV Bool -> Integer
pbToInteger String
"pbExactly" Int
1) [SBV Bool]
xs) Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k
| Bool
True = String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
"pbExactly" (Int -> PBOp
PB_Exactly Int
k) [SBV Bool]
xs
pbLe :: [(Int, SBool)] -> Int -> SBool
pbLe :: [(Int, SBV Bool)] -> Int -> SBV Bool
pbLe [(Int, SBV Bool)]
xs Int
k
| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbLe: Non-negative value required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
k
| ((Int, SBV Bool) -> Bool) -> [(Int, SBV Bool)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (SBV Bool -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete (SBV Bool -> Bool)
-> ((Int, SBV Bool) -> SBV Bool) -> (Int, SBV Bool) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, SBV Bool) -> SBV Bool
forall a b. (a, b) -> b
snd) [(Int, SBV Bool)]
xs = Bool -> SBV Bool
forall a. SymVal a => a -> SBV a
literal (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [String -> Int -> SBV Bool -> Integer
pbToInteger String
"pbLe" Int
c SBV Bool
b | (Int
c, SBV Bool
b) <- [(Int, SBV Bool)]
xs] Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k
| Bool
True = String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
"pbLe" ([Int] -> Int -> PBOp
PB_Le (((Int, SBV Bool) -> Int) -> [(Int, SBV Bool)] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map (Int, SBV Bool) -> Int
forall a b. (a, b) -> a
fst [(Int, SBV Bool)]
xs) Int
k) (((Int, SBV Bool) -> SBV Bool) -> [(Int, SBV Bool)] -> [SBV Bool]
forall a b. (a -> b) -> [a] -> [b]
map (Int, SBV Bool) -> SBV Bool
forall a b. (a, b) -> b
snd [(Int, SBV Bool)]
xs)
pbGe :: [(Int, SBool)] -> Int -> SBool
pbGe :: [(Int, SBV Bool)] -> Int -> SBV Bool
pbGe [(Int, SBV Bool)]
xs Int
k
| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbGe: Non-negative value required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
k
| ((Int, SBV Bool) -> Bool) -> [(Int, SBV Bool)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (SBV Bool -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete (SBV Bool -> Bool)
-> ((Int, SBV Bool) -> SBV Bool) -> (Int, SBV Bool) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, SBV Bool) -> SBV Bool
forall a b. (a, b) -> b
snd) [(Int, SBV Bool)]
xs = Bool -> SBV Bool
forall a. SymVal a => a -> SBV a
literal (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [String -> Int -> SBV Bool -> Integer
pbToInteger String
"pbGe" Int
c SBV Bool
b | (Int
c, SBV Bool
b) <- [(Int, SBV Bool)]
xs] Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k
| Bool
True = String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
"pbGe" ([Int] -> Int -> PBOp
PB_Ge (((Int, SBV Bool) -> Int) -> [(Int, SBV Bool)] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map (Int, SBV Bool) -> Int
forall a b. (a, b) -> a
fst [(Int, SBV Bool)]
xs) Int
k) (((Int, SBV Bool) -> SBV Bool) -> [(Int, SBV Bool)] -> [SBV Bool]
forall a b. (a -> b) -> [a] -> [b]
map (Int, SBV Bool) -> SBV Bool
forall a b. (a, b) -> b
snd [(Int, SBV Bool)]
xs)
pbEq :: [(Int, SBool)] -> Int -> SBool
pbEq :: [(Int, SBV Bool)] -> Int -> SBV Bool
pbEq [(Int, SBV Bool)]
xs Int
k
| Int
k Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> SBV Bool
forall a. HasCallStack => String -> a
error (String -> SBV Bool) -> String -> SBV Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbEq: Non-negative value required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
k
| ((Int, SBV Bool) -> Bool) -> [(Int, SBV Bool)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (SBV Bool -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete (SBV Bool -> Bool)
-> ((Int, SBV Bool) -> SBV Bool) -> (Int, SBV Bool) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, SBV Bool) -> SBV Bool
forall a b. (a, b) -> b
snd) [(Int, SBV Bool)]
xs = Bool -> SBV Bool
forall a. SymVal a => a -> SBV a
literal (Bool -> SBV Bool) -> Bool -> SBV Bool
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [String -> Int -> SBV Bool -> Integer
pbToInteger String
"pbEq" Int
c SBV Bool
b | (Int
c, SBV Bool
b) <- [(Int, SBV Bool)]
xs] Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k
| Bool
True = String -> PBOp -> [SBV Bool] -> SBV Bool
liftPB String
"pbEq" ([Int] -> Int -> PBOp
PB_Eq (((Int, SBV Bool) -> Int) -> [(Int, SBV Bool)] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map (Int, SBV Bool) -> Int
forall a b. (a, b) -> a
fst [(Int, SBV Bool)]
xs) Int
k) (((Int, SBV Bool) -> SBV Bool) -> [(Int, SBV Bool)] -> [SBV Bool]
forall a b. (a -> b) -> [a] -> [b]
map (Int, SBV Bool) -> SBV Bool
forall a b. (a, b) -> b
snd [(Int, SBV Bool)]
xs)
pbMutexed :: [SBool] -> SBool
pbMutexed :: [SBV Bool] -> SBV Bool
pbMutexed [SBV Bool]
xs = [SBV Bool] -> Int -> SBV Bool
pbAtMost [SBV Bool]
xs Int
1
pbStronglyMutexed :: [SBool] -> SBool
pbStronglyMutexed :: [SBV Bool] -> SBV Bool
pbStronglyMutexed [SBV Bool]
xs = [SBV Bool] -> Int -> SBV Bool
pbExactly [SBV Bool]
xs Int
1
pbToInteger :: String -> Int -> SBool -> Integer
pbToInteger :: String -> Int -> SBV Bool -> Integer
pbToInteger String
w Int
c SBV Bool
b
| Int
c Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = String -> Integer
forall a. HasCallStack => String -> a
error (String -> Integer) -> String -> Integer
forall a b. (a -> b) -> a -> b
$ String
"SBV." String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": Non-negative coefficient required, received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
c
| Just Bool
v <- SBV Bool -> Maybe Bool
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Bool
b = if Bool
v then Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
c else Integer
0
| Bool
True = String -> Integer
forall a. HasCallStack => String -> a
error (String -> Integer) -> String -> Integer
forall a b. (a -> b) -> a -> b
$ String
"SBV.pbToInteger: Received a symbolic boolean: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, SBV Bool) -> String
forall a. Show a => a -> String
show (Int
c, SBV Bool
b)
isConcreteZero :: SBV a -> Bool
isConcreteZero :: SBV a -> Bool
isConcreteZero (SBV (SVal Kind
_ (Left (CV Kind
_ (CInteger Integer
n))))) = Integer
n Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
0
isConcreteZero (SBV (SVal Kind
KReal (Left (CV Kind
KReal (CAlgReal AlgReal
v))))) = AlgReal -> Bool
isExactRational AlgReal
v Bool -> Bool -> Bool
&& AlgReal
v AlgReal -> AlgReal -> Bool
forall a. Eq a => a -> a -> Bool
== AlgReal
0
isConcreteZero SBV a
_ = Bool
False
isConcreteOne :: SBV a -> Bool
isConcreteOne :: SBV a -> Bool
isConcreteOne (SBV (SVal Kind
_ (Left (CV Kind
_ (CInteger Integer
1))))) = Bool
True
isConcreteOne (SBV (SVal Kind
KReal (Left (CV Kind
KReal (CAlgReal AlgReal
v))))) = AlgReal -> Bool
isExactRational AlgReal
v Bool -> Bool -> Bool
&& AlgReal
v AlgReal -> AlgReal -> Bool
forall a. Eq a => a -> a -> Bool
== AlgReal
1
isConcreteOne SBV a
_ = Bool
False
instance (Ord a, Num a, SymVal a) => Num (SBV a) where
fromInteger :: Integer -> SBV a
fromInteger = a -> SBV a
forall a. SymVal a => a -> SBV a
literal (a -> SBV a) -> (Integer -> a) -> Integer -> SBV a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral
SBV SVal
x + :: SBV a -> SBV a -> SBV a
+ SBV SVal
y = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svPlus SVal
x SVal
y)
SBV SVal
x * :: SBV a -> SBV a -> SBV a
* SBV SVal
y = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svTimes SVal
x SVal
y)
SBV SVal
x - :: SBV a -> SBV a -> SBV a
- SBV SVal
y = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svMinus SVal
x SVal
y)
abs :: SBV a -> SBV a
abs (SBV SVal
x) = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal
svAbs SVal
x)
signum :: SBV a -> SBV a
signum SBV a
a
| SBV a -> Bool
forall a. HasKind a => a -> Bool
hasSign SBV a
a = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.> SBV a
z) SBV a
i
(SBV a -> SBV a) -> SBV a -> SBV a
forall a b. (a -> b) -> a -> b
$ SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< SBV a
z) (SBV a -> SBV a
forall a. Num a => a -> a
negate SBV a
i) SBV a
a
| Bool
True = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.> SBV a
z) SBV a
i SBV a
a
where z :: SBV a
z = Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
a) (Integer
0::Integer)
i :: SBV a
i = Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
a) (Integer
1::Integer)
negate :: SBV a -> SBV a
negate (SBV SVal
x) = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal
svUNeg SVal
x)
(.^) :: (Mergeable b, Num b, SIntegral e) => b -> SBV e -> b
b
b .^ :: b -> SBV e -> b
.^ SBV e
e
| SBV e -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV e
e, Just (Integer
x :: Integer) <- SBV Integer -> Maybe Integer
forall a. SymVal a => SBV a -> Maybe a
unliteral (SBV e -> SBV Integer
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV e
e)
= if Integer
x Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0 then let go :: a -> a -> a
go a
n a
v
| a
n a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0 = a
1
| a -> Bool
forall a. Integral a => a -> Bool
even a
n = a -> a -> a
go (a
n a -> a -> a
forall a. Integral a => a -> a -> a
`div` a
2) (a
v a -> a -> a
forall a. Num a => a -> a -> a
* a
v)
| Bool
True = a
v a -> a -> a
forall a. Num a => a -> a -> a
* a -> a -> a
go (a
n a -> a -> a
forall a. Integral a => a -> a -> a
`div` a
2) (a
v a -> a -> a
forall a. Num a => a -> a -> a
* a
v)
in Integer -> b -> b
forall a a. (Num a, Integral a) => a -> a -> a
go Integer
x b
b
else String -> b
forall a. HasCallStack => String -> a
error (String -> b) -> String -> b
forall a b. (a -> b) -> a -> b
$ String
"(.^): exponentiation: negative exponent: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
x
| Bool -> Bool
not (SBV e -> Bool
forall a. HasKind a => a -> Bool
isBounded SBV e
e) Bool -> Bool -> Bool
|| SBV e -> Bool
forall a. Bits a => a -> Bool
isSigned SBV e
e
= String -> b
forall a. HasCallStack => String -> a
error (String -> b) -> String -> b
forall a b. (a -> b) -> a -> b
$ String
"(.^): exponentiation only works with unsigned bounded symbolic exponents, kind: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SBV e -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV e
e)
| Bool
True
=
let SBV SVal
expt = SBV e
e
expBit :: Int -> SBV Bool
expBit Int
i = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svTestBit SVal
expt Int
i)
blasted :: [SBV Bool]
blasted = (Int -> SBV Bool) -> [Int] -> [SBV Bool]
forall a b. (a -> b) -> [a] -> [b]
map Int -> SBV Bool
expBit [Int
0 .. SBV e -> Int
forall a. HasKind a => a -> Int
intSizeOf SBV e
e Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
in [b] -> b
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product ([b] -> b) -> [b] -> b
forall a b. (a -> b) -> a -> b
$ (SBV Bool -> b -> b) -> [SBV Bool] -> [b] -> [b]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\SBV Bool
use b
n -> SBV Bool -> b -> b -> b
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
use b
n b
1)
[SBV Bool]
blasted
((b -> b) -> b -> [b]
forall a. (a -> a) -> a -> [a]
iterate (\b
x -> b
xb -> b -> b
forall a. Num a => a -> a -> a
*b
x) b
b)
instance (Ord a, SymVal a, Fractional a) => Fractional (SBV a) where
fromRational :: Rational -> SBV a
fromRational = a -> SBV a
forall a. SymVal a => a -> SBV a
literal (a -> SBV a) -> (Rational -> a) -> Rational -> SBV a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> a
forall a. Fractional a => Rational -> a
fromRational
SBV SVal
x / :: SBV a -> SBV a -> SBV a
/ sy :: SBV a
sy@(SBV SVal
y) | Bool
div0 = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
sy SBV a -> SBV a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a
0) SBV a
0 SBV a
res
| Bool
True = SBV a
res
where res :: SBV a
res = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svDivide SVal
x SVal
y)
div0 :: Bool
div0 = case SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
sy of
Kind
KFloat -> Bool
False
Kind
KDouble -> Bool
False
KFP{} -> Bool
False
Kind
KReal -> Bool
True
Kind
KRational -> Bool
True
k :: Kind
k@KBounded{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@Kind
KUnbounded -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@Kind
KBool -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@Kind
KString -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@Kind
KChar -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@KList{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@KSet{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@KUserSort{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@KTuple{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@KMaybe{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
k :: Kind
k@KEither{} -> String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"Unexpected Fractional case for: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
instance (Ord a, SymVal a, Fractional a, Floating a) => Floating (SBV a) where
pi :: SBV a
pi = Rational -> SBV a
forall a. Fractional a => Rational -> a
fromRational (Rational -> SBV a) -> (Double -> Rational) -> Double -> SBV a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Rational
forall a. Real a => a -> Rational
toRational (Double -> SBV a) -> Double -> SBV a
forall a b. (a -> b) -> a -> b
$ (Double
forall a. Floating a => a
pi :: Double)
exp :: SBV a -> SBV a
exp = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"exp" a -> a
forall a. Floating a => a -> a
exp
log :: SBV a -> SBV a
log = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"log" a -> a
forall a. Floating a => a -> a
log
sqrt :: SBV a -> SBV a
sqrt = FPOp -> (a -> a) -> SBV a -> SBV a
forall a. SymVal a => FPOp -> (a -> a) -> SBV a -> SBV a
lift1F FPOp
FP_Sqrt a -> a
forall a. Floating a => a -> a
sqrt
sin :: SBV a -> SBV a
sin = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"sin" a -> a
forall a. Floating a => a -> a
sin
cos :: SBV a -> SBV a
cos = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"cos" a -> a
forall a. Floating a => a -> a
cos
tan :: SBV a -> SBV a
tan = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"tan" a -> a
forall a. Floating a => a -> a
tan
asin :: SBV a -> SBV a
asin = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"asin" a -> a
forall a. Floating a => a -> a
asin
acos :: SBV a -> SBV a
acos = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"acos" a -> a
forall a. Floating a => a -> a
acos
atan :: SBV a -> SBV a
atan = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"atan" a -> a
forall a. Floating a => a -> a
atan
sinh :: SBV a -> SBV a
sinh = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"sinh" a -> a
forall a. Floating a => a -> a
sinh
cosh :: SBV a -> SBV a
cosh = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"cosh" a -> a
forall a. Floating a => a -> a
cosh
tanh :: SBV a -> SBV a
tanh = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"tanh" a -> a
forall a. Floating a => a -> a
tanh
asinh :: SBV a -> SBV a
asinh = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"asinh" a -> a
forall a. Floating a => a -> a
asinh
acosh :: SBV a -> SBV a
acosh = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"acosh" a -> a
forall a. Floating a => a -> a
acosh
atanh :: SBV a -> SBV a
atanh = String -> (a -> a) -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"atanh" a -> a
forall a. Floating a => a -> a
atanh
** :: SBV a -> SBV a -> SBV a
(**) = String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
lift2FNS String
"**" a -> a -> a
forall a. Floating a => a -> a -> a
(**)
logBase :: SBV a -> SBV a -> SBV a
logBase = String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
forall a.
(SymVal a, Floating a) =>
String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
lift2FNS String
"logBase" a -> a -> a
forall a. Floating a => a -> a -> a
logBase
unsupported :: String -> a
unsupported :: String -> a
unsupported String
w = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"Data.SBV.FloatingPoint: Unsupported operation: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
". Please request this as a feature!"
instance {-# OVERLAPPING #-} ValidFloat eb sb => Floating (SFloatingPoint eb sb) where
pi :: SFloatingPoint eb sb
pi
| Int
ei Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
11 Bool -> Bool -> Bool
|| Int
si Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
53 = String -> SFloatingPoint eb sb
forall a. String -> a
unsupported (String -> SFloatingPoint eb sb) -> String -> SFloatingPoint eb sb
forall a b. (a -> b) -> a -> b
$ String
"Floating.SFloatingPoint.pi (not-enough-precision for " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Int) -> String
forall a. Show a => a -> String
show (Int
ei, Int
si) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
| Bool
True = FloatingPoint eb sb -> SFloatingPoint eb sb
forall a. SymVal a => a -> SBV a
literal (FloatingPoint eb sb -> SFloatingPoint eb sb)
-> FloatingPoint eb sb -> SFloatingPoint eb sb
forall a b. (a -> b) -> a -> b
$ FP -> FloatingPoint eb sb
forall (eb :: Nat) (sb :: Nat). FP -> FloatingPoint eb sb
FloatingPoint (FP -> FloatingPoint eb sb) -> FP -> FloatingPoint eb sb
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Rational -> FP
fpFromRational Int
ei Int
si (Double -> Rational
forall a. Real a => a -> Rational
toRational (Double
forall a. Floating a => a
pi :: Double))
where ei :: Int
ei = Proxy eb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy eb
forall k (t :: k). Proxy t
Proxy @eb)
si :: Int
si = Proxy sb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy sb
forall k (t :: k). Proxy t
Proxy @sb)
exp :: SFloatingPoint eb sb -> SFloatingPoint eb sb
exp SFloatingPoint eb sb
i
| Int
ei Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
11 Bool -> Bool -> Bool
|| Int
si Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
53 = String -> SFloatingPoint eb sb
forall a. String -> a
unsupported (String -> SFloatingPoint eb sb) -> String -> SFloatingPoint eb sb
forall a b. (a -> b) -> a -> b
$ String
"Floating.SFloatingPoint.exp (not-enough-precision for " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Int) -> String
forall a. Show a => a -> String
show (Int
ei, Int
si) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
| Bool
True = FloatingPoint eb sb -> SFloatingPoint eb sb
forall a. SymVal a => a -> SBV a
literal FloatingPoint eb sb
e SFloatingPoint eb sb
-> SFloatingPoint eb sb -> SFloatingPoint eb sb
forall a. Floating a => a -> a -> a
** SFloatingPoint eb sb
i
where ei :: Int
ei = Proxy eb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy eb
forall k (t :: k). Proxy t
Proxy @eb)
si :: Int
si = Proxy sb -> Int
forall (n :: Nat). KnownNat n => Proxy n -> Int
intOfProxy (Proxy sb
forall k (t :: k). Proxy t
Proxy @sb)
e :: FloatingPoint eb sb
e = FP -> FloatingPoint eb sb
forall (eb :: Nat) (sb :: Nat). FP -> FloatingPoint eb sb
FloatingPoint (FP -> FloatingPoint eb sb) -> FP -> FloatingPoint eb sb
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Rational -> FP
fpFromRational Int
ei Int
si (Double -> Rational
forall a. Real a => a -> Rational
toRational (Double -> Double
forall a. Floating a => a -> a
exp Double
1 :: Double))
log :: SFloatingPoint eb sb -> SFloatingPoint eb sb
log = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"log" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
log
sqrt :: SFloatingPoint eb sb -> SFloatingPoint eb sb
sqrt = FPOp
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a. SymVal a => FPOp -> (a -> a) -> SBV a -> SBV a
lift1F FPOp
FP_Sqrt FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
sqrt
sin :: SFloatingPoint eb sb -> SFloatingPoint eb sb
sin = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"sin" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
sin
cos :: SFloatingPoint eb sb -> SFloatingPoint eb sb
cos = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"cos" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
cos
tan :: SFloatingPoint eb sb -> SFloatingPoint eb sb
tan = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"tan" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
tan
asin :: SFloatingPoint eb sb -> SFloatingPoint eb sb
asin = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"asin" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
asin
acos :: SFloatingPoint eb sb -> SFloatingPoint eb sb
acos = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"acos" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
acos
atan :: SFloatingPoint eb sb -> SFloatingPoint eb sb
atan = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"atan" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
atan
sinh :: SFloatingPoint eb sb -> SFloatingPoint eb sb
sinh = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"sinh" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
sinh
cosh :: SFloatingPoint eb sb -> SFloatingPoint eb sb
cosh = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"cosh" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
cosh
tanh :: SFloatingPoint eb sb -> SFloatingPoint eb sb
tanh = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"tanh" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
tanh
asinh :: SFloatingPoint eb sb -> SFloatingPoint eb sb
asinh = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"asinh" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
asinh
acosh :: SFloatingPoint eb sb -> SFloatingPoint eb sb
acosh = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"acosh" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
acosh
atanh :: SFloatingPoint eb sb -> SFloatingPoint eb sb
atanh = String
-> (FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
"atanh" FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a
atanh
** :: SFloatingPoint eb sb
-> SFloatingPoint eb sb -> SFloatingPoint eb sb
(**) = String
-> (FloatingPoint eb sb
-> FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
lift2FNS String
"**" FloatingPoint eb sb -> FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a -> a
(**)
logBase :: SFloatingPoint eb sb
-> SFloatingPoint eb sb -> SFloatingPoint eb sb
logBase = String
-> (FloatingPoint eb sb
-> FloatingPoint eb sb -> FloatingPoint eb sb)
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
-> SFloatingPoint eb sb
forall a.
(SymVal a, Floating a) =>
String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
lift2FNS String
"logBase" FloatingPoint eb sb -> FloatingPoint eb sb -> FloatingPoint eb sb
forall a. Floating a => a -> a -> a
logBase
lift1F :: SymVal a => FPOp -> (a -> a) -> SBV a -> SBV a
lift1F :: FPOp -> (a -> a) -> SBV a -> SBV a
lift1F FPOp
w a -> a
op SBV a
a
| Just a
v <- SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
a
= a -> SBV a
forall a. SymVal a => a -> SBV a
literal (a -> SBV a) -> a -> SBV a
forall a b. (a -> b) -> a -> b
$ a -> a
op a
v
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
a
r :: State -> IO SV
r State
st = do SV
swa <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
a
SV
swm <- State -> SBV RoundingMode -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV RoundingMode
sRNE
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k (Op -> [SV] -> SBVExpr
SBVApp (FPOp -> Op
IEEEFP FPOp
w) [SV
swm, SV
swa])
lift1FNS :: (SymVal a, Floating a) => String -> (a -> a) -> SBV a -> SBV a
lift1FNS :: String -> (a -> a) -> SBV a -> SBV a
lift1FNS String
nm a -> a
f SBV a
sv
| Just a
v <- SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
sv = a -> SBV a
forall a. SymVal a => a -> SBV a
literal (a -> SBV a) -> a -> SBV a
forall a b. (a -> b) -> a -> b
$ a -> a
f a
v
| Bool
True = String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"SBV." String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": not supported for symbolic values of type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
sv)
lift2FNS :: (SymVal a, Floating a) => String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
lift2FNS :: String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a
lift2FNS String
nm a -> a -> a
f SBV a
sv1 SBV a
sv2
| Just a
v1 <- SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
sv1
, Just a
v2 <- SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
sv2 = a -> SBV a
forall a. SymVal a => a -> SBV a
literal (a -> SBV a) -> a -> SBV a
forall a b. (a -> b) -> a -> b
$ a -> a -> a
f a
v1 a
v2
| Bool
True = String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"SBV." String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": not supported for symbolic values of type " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
sv1)
instance {-# OVERLAPPING #-} Floating SReal where
pi :: SBV AlgReal
pi = Rational -> SBV AlgReal
forall a. Fractional a => Rational -> a
fromRational (Rational -> SBV AlgReal)
-> (Double -> Rational) -> Double -> SBV AlgReal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Rational
forall a. Real a => a -> Rational
toRational (Double -> SBV AlgReal) -> Double -> SBV AlgReal
forall a b. (a -> b) -> a -> b
$ (Double
forall a. Floating a => a
pi :: Double)
exp :: SBV AlgReal -> SBV AlgReal
exp = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Exp
log :: SBV AlgReal -> SBV AlgReal
log = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Log
sqrt :: SBV AlgReal -> SBV AlgReal
sqrt = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Sqrt
sin :: SBV AlgReal -> SBV AlgReal
sin = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Sin
cos :: SBV AlgReal -> SBV AlgReal
cos = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Cos
tan :: SBV AlgReal -> SBV AlgReal
tan = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Tan
asin :: SBV AlgReal -> SBV AlgReal
asin = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_ASin
acos :: SBV AlgReal -> SBV AlgReal
acos = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_ACos
atan :: SBV AlgReal -> SBV AlgReal
atan = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_ATan
sinh :: SBV AlgReal -> SBV AlgReal
sinh = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Sinh
cosh :: SBV AlgReal -> SBV AlgReal
cosh = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Cosh
tanh :: SBV AlgReal -> SBV AlgReal
tanh = NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
NR_Tanh
asinh :: SBV AlgReal -> SBV AlgReal
asinh = String -> SBV AlgReal -> SBV AlgReal
forall a. HasCallStack => String -> a
error String
"Data.SBV.SReal: asinh is currently not supported. Please request this as a feature!"
acosh :: SBV AlgReal -> SBV AlgReal
acosh = String -> SBV AlgReal -> SBV AlgReal
forall a. HasCallStack => String -> a
error String
"Data.SBV.SReal: acosh is currently not supported. Please request this as a feature!"
atanh :: SBV AlgReal -> SBV AlgReal
atanh = String -> SBV AlgReal -> SBV AlgReal
forall a. HasCallStack => String -> a
error String
"Data.SBV.SReal: atanh is currently not supported. Please request this as a feature!"
** :: SBV AlgReal -> SBV AlgReal -> SBV AlgReal
(**) = NROp -> SBV AlgReal -> SBV AlgReal -> SBV AlgReal
lift2SReal NROp
NR_Pow
logBase :: SBV AlgReal -> SBV AlgReal -> SBV AlgReal
logBase SBV AlgReal
x SBV AlgReal
y = SBV AlgReal -> SBV AlgReal
forall a. Floating a => a -> a
log SBV AlgReal
y SBV AlgReal -> SBV AlgReal -> SBV AlgReal
forall a. Fractional a => a -> a -> a
/ SBV AlgReal -> SBV AlgReal
forall a. Floating a => a -> a
log SBV AlgReal
x
lift1SReal :: NROp -> SReal -> SReal
lift1SReal :: NROp -> SBV AlgReal -> SBV AlgReal
lift1SReal NROp
w SBV AlgReal
a = SVal -> SBV AlgReal
forall a. SVal -> SBV a
SBV (SVal -> SBV AlgReal) -> SVal -> SBV AlgReal
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = SBV AlgReal -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV AlgReal
a
r :: State -> IO SV
r State
st = do SV
swa <- State -> SBV AlgReal -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV AlgReal
a
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k (Op -> [SV] -> SBVExpr
SBVApp (NROp -> Op
NonLinear NROp
w) [SV
swa])
lift2SReal :: NROp -> SReal -> SReal -> SReal
lift2SReal :: NROp -> SBV AlgReal -> SBV AlgReal -> SBV AlgReal
lift2SReal NROp
w SBV AlgReal
a SBV AlgReal
b = SVal -> SBV AlgReal
forall a. SVal -> SBV a
SBV (SVal -> SBV AlgReal) -> SVal -> SBV AlgReal
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = SBV AlgReal -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV AlgReal
a
r :: State -> IO SV
r State
st = do SV
swa <- State -> SBV AlgReal -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV AlgReal
a
SV
swb <- State -> SBV AlgReal -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV AlgReal
b
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k (Op -> [SV] -> SBVExpr
SBVApp (NROp -> Op
NonLinear NROp
w) [SV
swa, SV
swb])
instance (Ord a, Num a, Bits a, SymVal a) => Bits (SBV a) where
SBV SVal
x .&. :: SBV a -> SBV a -> SBV a
.&. SBV SVal
y = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svAnd SVal
x SVal
y)
SBV SVal
x .|. :: SBV a -> SBV a -> SBV a
.|. SBV SVal
y = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svOr SVal
x SVal
y)
SBV SVal
x xor :: SBV a -> SBV a -> SBV a
`xor` SBV SVal
y = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal -> SVal
svXOr SVal
x SVal
y)
complement :: SBV a -> SBV a
complement (SBV SVal
x) = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SVal
svNot SVal
x)
bitSize :: SBV a -> Int
bitSize SBV a
x = SBV a -> Int
forall a. HasKind a => a -> Int
intSizeOf SBV a
x
bitSizeMaybe :: SBV a -> Maybe Int
bitSizeMaybe SBV a
x = Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> Int -> Maybe Int
forall a b. (a -> b) -> a -> b
$ SBV a -> Int
forall a. HasKind a => a -> Int
intSizeOf SBV a
x
isSigned :: SBV a -> Bool
isSigned SBV a
x = SBV a -> Bool
forall a. HasKind a => a -> Bool
hasSign SBV a
x
bit :: Int -> SBV a
bit Int
i = SBV a
1 SBV a -> Int -> SBV a
forall a. Bits a => a -> Int -> a
`shiftL` Int
i
setBit :: SBV a -> Int -> SBV a
setBit SBV a
x Int
i = SBV a
x SBV a -> SBV a -> SBV a
forall a. Bits a => a -> a -> a
.|. Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Int -> Integer
forall a. Bits a => Int -> a
bit Int
i :: Integer)
clearBit :: SBV a -> Int -> SBV a
clearBit SBV a
x Int
i = SBV a
x SBV a -> SBV a -> SBV a
forall a. Bits a => a -> a -> a
.&. Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Integer -> Integer
forall a. Bits a => a -> a
complement (Int -> Integer
forall a. Bits a => Int -> a
bit Int
i) :: Integer)
complementBit :: SBV a -> Int -> SBV a
complementBit SBV a
x Int
i = SBV a
x SBV a -> SBV a -> SBV a
forall a. Bits a => a -> a -> a
`xor` Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Int -> Integer
forall a. Bits a => Int -> a
bit Int
i :: Integer)
shiftL :: SBV a -> Int -> SBV a
shiftL (SBV SVal
x) Int
i = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svShl SVal
x Int
i)
shiftR :: SBV a -> Int -> SBV a
shiftR (SBV SVal
x) Int
i = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svShr SVal
x Int
i)
rotateL :: SBV a -> Int -> SBV a
rotateL (SBV SVal
x) Int
i = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svRol SVal
x Int
i)
rotateR :: SBV a -> Int -> SBV a
rotateR (SBV SVal
x) Int
i = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> Int -> SVal
svRor SVal
x Int
i)
SBV a
x testBit :: SBV a -> Int -> Bool
`testBit` Int
i
| SBV (SVal Kind
_ (Left (CV Kind
_ (CInteger Integer
n)))) <- SBV a
x
= Integer -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit Integer
n Int
i
| Bool
True
= String -> Bool
forall a. HasCallStack => String -> a
error (String -> Bool) -> String -> Bool
forall a b. (a -> b) -> a -> b
$ String
"SBV.testBit: Called on symbolic value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. Show a => a -> String
show SBV a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
". Use sTestBit instead."
popCount :: SBV a -> Int
popCount SBV a
x
| SBV (SVal Kind
_ (Left (CV (KBounded Bool
_ Int
w) (CInteger Integer
n)))) <- SBV a
x
= Integer -> Int
forall a. Bits a => a -> Int
popCount (Integer
n Integer -> Integer -> Integer
forall a. Bits a => a -> a -> a
.&. (Int -> Integer
forall a. Bits a => Int -> a
bit Int
w Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
1))
| Bool
True
= String -> Int
forall a. HasCallStack => String -> a
error (String -> Int) -> String -> Int
forall a b. (a -> b) -> a -> b
$ String
"SBV.popCount: Called on symbolic value: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. Show a => a -> String
show SBV a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
". Use sPopCount instead."
sFromIntegral :: forall a b. (Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b, SymVal b) => SBV a -> SBV b
sFromIntegral :: SBV a -> SBV b
sFromIntegral SBV a
x
| Kind
kFrom Kind -> Kind -> Bool
forall a. Eq a => a -> a -> Bool
== Kind
kTo
= SVal -> SBV b
forall a. SVal -> SBV a
SBV (SBV a -> SVal
forall a. SBV a -> SVal
unSBV SBV a
x)
| SBV a -> Bool
forall a. HasKind a => a -> Bool
isReal SBV a
x
= String -> SBV b
forall a. HasCallStack => String -> a
error String
"SBV.sFromIntegral: Called on a real value"
| Just a
v <- SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
x
= b -> SBV b
forall a. SymVal a => a -> SBV a
literal (a -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
v)
| Bool
True
= SBV b
result
where result :: SBV b
result = SVal -> SBV b
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
kTo (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
y)))
kFrom :: Kind
kFrom = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x
kTo :: Kind
kTo = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
y :: State -> IO SV
y State
st = do SV
xsv <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
x
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
kTo (Op -> [SV] -> SBVExpr
SBVApp (Kind -> Kind -> Op
KindCast Kind
kFrom Kind
kTo) [SV
xsv])
liftViaSVal :: (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal :: (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
f (SBV SVal
a) (SBV SVal
b) = SVal -> SBV c
forall a. SVal -> SBV a
SBV (SVal -> SBV c) -> SVal -> SBV c
forall a b. (a -> b) -> a -> b
$ SVal -> SVal -> SVal
f SVal
a SVal
b
sShiftLeft :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
sShiftLeft :: SBV a -> SBV b -> SBV a
sShiftLeft = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV a
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svShiftLeft
sShiftRight :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
sShiftRight :: SBV a -> SBV b -> SBV a
sShiftRight = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV a
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svShiftRight
sSignedShiftArithRight:: (SFiniteBits a, SIntegral b) => SBV a -> SBV b -> SBV a
sSignedShiftArithRight :: SBV a -> SBV b -> SBV a
sSignedShiftArithRight SBV a
x SBV b
i
| SBV b -> Bool
forall a. Bits a => a -> Bool
isSigned SBV b
i = String -> SBV a
forall a. HasCallStack => String -> a
error String
"sSignedShiftArithRight: shift amount should be unsigned"
| SBV a -> Bool
forall a. Bits a => a -> Bool
isSigned SBV a
x = SBV a -> SBV b -> SBV a
forall a b c. SBV a -> SBV b -> SBV c
ssa SBV a
x SBV b
i
| Bool
True = SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a -> SBV Bool
forall a. SFiniteBits a => SBV a -> SBV Bool
msb SBV a
x)
(SBV a -> SBV a
forall a. Bits a => a -> a
complement (SBV a -> SBV b -> SBV a
forall a b c. SBV a -> SBV b -> SBV c
ssa (SBV a -> SBV a
forall a. Bits a => a -> a
complement SBV a
x) SBV b
i))
(SBV a -> SBV b -> SBV a
forall a b c. SBV a -> SBV b -> SBV c
ssa SBV a
x SBV b
i)
where ssa :: SBV a -> SBV b -> SBV c
ssa = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svShiftRight
sRotateLeft :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
sRotateLeft :: SBV a -> SBV b -> SBV a
sRotateLeft = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV a
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svRotateLeft
sBarrelRotateLeft :: (SFiniteBits a, SFiniteBits b) => SBV a -> SBV b -> SBV a
sBarrelRotateLeft :: SBV a -> SBV b -> SBV a
sBarrelRotateLeft = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV a
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svBarrelRotateLeft
sRotateRight :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a
sRotateRight :: SBV a -> SBV b -> SBV a
sRotateRight = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV a
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svRotateRight
sBarrelRotateRight :: (SFiniteBits a, SFiniteBits b) => SBV a -> SBV b -> SBV a
sBarrelRotateRight :: SBV a -> SBV b -> SBV a
sBarrelRotateRight = (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV a
forall a b c. (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c
liftViaSVal SVal -> SVal -> SVal
svBarrelRotateRight
instance (Show a, Bounded a, Integral a, Num a, SymVal a) => Enum (SBV a) where
succ :: SBV a -> SBV a
succ SBV a
x
| a
v a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== (a
forall a. Bounded a => a
maxBound :: a) = String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"Enum.succ{" String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. HasKind a => a -> String
showType SBV a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}: tried to take `succ' of maxBound"
| Bool
True = a -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a -> SBV a) -> a -> SBV a
forall a b. (a -> b) -> a -> b
$ a
v a -> a -> a
forall a. Num a => a -> a -> a
+ a
1
where v :: a
v = String -> SBV a -> a
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"succ" SBV a
x
pred :: SBV a -> SBV a
pred SBV a
x
| a
v a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== (a
forall a. Bounded a => a
minBound :: a) = String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"Enum.pred{" String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. HasKind a => a -> String
showType SBV a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}: tried to take `pred' of minBound"
| Bool
True = a -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a -> SBV a) -> a -> SBV a
forall a b. (a -> b) -> a -> b
$ a
v a -> a -> a
forall a. Num a => a -> a -> a
- a
1
where v :: a
v = String -> SBV a -> a
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"pred" SBV a
x
toEnum :: Int -> SBV a
toEnum Int
x
| Integer
xi Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< a -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
forall a. Bounded a => a
minBound :: a) Bool -> Bool -> Bool
|| Integer
xi Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> a -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
forall a. Bounded a => a
maxBound :: a)
= String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"Enum.toEnum{" String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. HasKind a => a -> String
showType SBV a
r String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is out-of-bounds " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (a, a) -> String
forall a. Show a => a -> String
show (a
forall a. Bounded a => a
minBound :: a, a
forall a. Bounded a => a
maxBound :: a)
| Bool
True
= SBV a
r
where xi :: Integer
xi :: Integer
xi = Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x
r :: SBV a
r :: SBV a
r = Int -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x
fromEnum :: SBV a -> Int
fromEnum SBV a
x
| Integer
r Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
forall a. Bounded a => a
minBound :: Int) Bool -> Bool -> Bool
|| Integer
r Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
forall a. Bounded a => a
maxBound :: Int)
= String -> Int
forall a. HasCallStack => String -> a
error (String -> Int) -> String -> Int
forall a b. (a -> b) -> a -> b
$ String
"Enum.fromEnum{" String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. HasKind a => a -> String
showType SBV a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}: value " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
r String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is outside of Int's bounds " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Int) -> String
forall a. Show a => a -> String
show (Int
forall a. Bounded a => a
minBound :: Int, Int
forall a. Bounded a => a
maxBound :: Int)
| Bool
True
= Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
r
where r :: Integer
r :: Integer
r = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"fromEnum" SBV a
x
enumFrom :: SBV a -> [SBV a]
enumFrom SBV a
x = (Integer -> SBV a) -> [Integer] -> [SBV a]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Integer
xi .. a -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
forall a. Bounded a => a
maxBound :: a)]
where xi :: Integer
xi :: Integer
xi = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"enumFrom" SBV a
x
enumFromThen :: SBV a -> SBV a -> [SBV a]
enumFromThen SBV a
x SBV a
y
| Integer
yi Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
xi = (Integer -> SBV a) -> [Integer] -> [SBV a]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Integer
xi, Integer
yi .. a -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
forall a. Bounded a => a
maxBound :: a)]
| Bool
True = (Integer -> SBV a) -> [Integer] -> [SBV a]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Integer
xi, Integer
yi .. a -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
forall a. Bounded a => a
minBound :: a)]
where xi, yi :: Integer
xi :: Integer
xi = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"enumFromThen.x" SBV a
x
yi :: Integer
yi = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"enumFromThen.y" SBV a
y
enumFromThenTo :: SBV a -> SBV a -> SBV a -> [SBV a]
enumFromThenTo SBV a
x SBV a
y SBV a
z = (Integer -> SBV a) -> [Integer] -> [SBV a]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> SBV a
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Integer
xi, Integer
yi .. Integer
zi]
where xi, yi, zi :: Integer
xi :: Integer
xi = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"enumFromThenTo.x" SBV a
x
yi :: Integer
yi = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"enumFromThenTo.y" SBV a
y
zi :: Integer
zi = String -> SBV a -> Integer
forall a b. (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt String
"enumFromThenTo.z" SBV a
z
enumCvt :: (SymVal a, Integral a, Num b) => String -> SBV a -> b
enumCvt :: String -> SBV a -> b
enumCvt String
w SBV a
x = case SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
x of
Maybe a
Nothing -> String -> b
forall a. HasCallStack => String -> a
error (String -> b) -> String -> b
forall a b. (a -> b) -> a -> b
$ String
"Enum." String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"{" String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. HasKind a => a -> String
showType SBV a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"}: Called on symbolic value " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. Show a => a -> String
show SBV a
x
Just a
v -> a -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
v
class SDivisible a where
sQuotRem :: a -> a -> (a, a)
sDivMod :: a -> a -> (a, a)
sQuot :: a -> a -> a
sRem :: a -> a -> a
sDiv :: a -> a -> a
sMod :: a -> a -> a
{-# MINIMAL sQuotRem, sDivMod #-}
a
x `sQuot` a
y = (a, a) -> a
forall a b. (a, b) -> a
fst ((a, a) -> a) -> (a, a) -> a
forall a b. (a -> b) -> a -> b
$ a
x a -> a -> (a, a)
forall a. SDivisible a => a -> a -> (a, a)
`sQuotRem` a
y
a
x `sRem` a
y = (a, a) -> a
forall a b. (a, b) -> b
snd ((a, a) -> a) -> (a, a) -> a
forall a b. (a -> b) -> a -> b
$ a
x a -> a -> (a, a)
forall a. SDivisible a => a -> a -> (a, a)
`sQuotRem` a
y
a
x `sDiv` a
y = (a, a) -> a
forall a b. (a, b) -> a
fst ((a, a) -> a) -> (a, a) -> a
forall a b. (a -> b) -> a -> b
$ a
x a -> a -> (a, a)
forall a. SDivisible a => a -> a -> (a, a)
`sDivMod` a
y
a
x `sMod` a
y = (a, a) -> a
forall a b. (a, b) -> b
snd ((a, a) -> a) -> (a, a) -> a
forall a b. (a -> b) -> a -> b
$ a
x a -> a -> (a, a)
forall a. SDivisible a => a -> a -> (a, a)
`sDivMod` a
y
instance SDivisible Word64 where
sQuotRem :: Word64 -> Word64 -> (Word64, Word64)
sQuotRem Word64
x Word64
0 = (Word64
0, Word64
x)
sQuotRem Word64
x Word64
y = Word64
x Word64 -> Word64 -> (Word64, Word64)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Word64
y
sDivMod :: Word64 -> Word64 -> (Word64, Word64)
sDivMod Word64
x Word64
0 = (Word64
0, Word64
x)
sDivMod Word64
x Word64
y = Word64
x Word64 -> Word64 -> (Word64, Word64)
forall a. Integral a => a -> a -> (a, a)
`divMod` Word64
y
instance SDivisible Int64 where
sQuotRem :: Int64 -> Int64 -> (Int64, Int64)
sQuotRem Int64
x Int64
0 = (Int64
0, Int64
x)
sQuotRem Int64
x Int64
y = Int64
x Int64 -> Int64 -> (Int64, Int64)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Int64
y
sDivMod :: Int64 -> Int64 -> (Int64, Int64)
sDivMod Int64
x Int64
0 = (Int64
0, Int64
x)
sDivMod Int64
x Int64
y = Int64
x Int64 -> Int64 -> (Int64, Int64)
forall a. Integral a => a -> a -> (a, a)
`divMod` Int64
y
instance SDivisible Word32 where
sQuotRem :: Word32 -> Word32 -> (Word32, Word32)
sQuotRem Word32
x Word32
0 = (Word32
0, Word32
x)
sQuotRem Word32
x Word32
y = Word32
x Word32 -> Word32 -> (Word32, Word32)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Word32
y
sDivMod :: Word32 -> Word32 -> (Word32, Word32)
sDivMod Word32
x Word32
0 = (Word32
0, Word32
x)
sDivMod Word32
x Word32
y = Word32
x Word32 -> Word32 -> (Word32, Word32)
forall a. Integral a => a -> a -> (a, a)
`divMod` Word32
y
instance SDivisible Int32 where
sQuotRem :: Int32 -> Int32 -> (Int32, Int32)
sQuotRem Int32
x Int32
0 = (Int32
0, Int32
x)
sQuotRem Int32
x Int32
y = Int32
x Int32 -> Int32 -> (Int32, Int32)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Int32
y
sDivMod :: Int32 -> Int32 -> (Int32, Int32)
sDivMod Int32
x Int32
0 = (Int32
0, Int32
x)
sDivMod Int32
x Int32
y = Int32
x Int32 -> Int32 -> (Int32, Int32)
forall a. Integral a => a -> a -> (a, a)
`divMod` Int32
y
instance SDivisible Word16 where
sQuotRem :: Word16 -> Word16 -> (Word16, Word16)
sQuotRem Word16
x Word16
0 = (Word16
0, Word16
x)
sQuotRem Word16
x Word16
y = Word16
x Word16 -> Word16 -> (Word16, Word16)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Word16
y
sDivMod :: Word16 -> Word16 -> (Word16, Word16)
sDivMod Word16
x Word16
0 = (Word16
0, Word16
x)
sDivMod Word16
x Word16
y = Word16
x Word16 -> Word16 -> (Word16, Word16)
forall a. Integral a => a -> a -> (a, a)
`divMod` Word16
y
instance SDivisible Int16 where
sQuotRem :: Int16 -> Int16 -> (Int16, Int16)
sQuotRem Int16
x Int16
0 = (Int16
0, Int16
x)
sQuotRem Int16
x Int16
y = Int16
x Int16 -> Int16 -> (Int16, Int16)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Int16
y
sDivMod :: Int16 -> Int16 -> (Int16, Int16)
sDivMod Int16
x Int16
0 = (Int16
0, Int16
x)
sDivMod Int16
x Int16
y = Int16
x Int16 -> Int16 -> (Int16, Int16)
forall a. Integral a => a -> a -> (a, a)
`divMod` Int16
y
instance SDivisible Word8 where
sQuotRem :: Word8 -> Word8 -> (Word8, Word8)
sQuotRem Word8
x Word8
0 = (Word8
0, Word8
x)
sQuotRem Word8
x Word8
y = Word8
x Word8 -> Word8 -> (Word8, Word8)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Word8
y
sDivMod :: Word8 -> Word8 -> (Word8, Word8)
sDivMod Word8
x Word8
0 = (Word8
0, Word8
x)
sDivMod Word8
x Word8
y = Word8
x Word8 -> Word8 -> (Word8, Word8)
forall a. Integral a => a -> a -> (a, a)
`divMod` Word8
y
instance SDivisible Int8 where
sQuotRem :: Int8 -> Int8 -> (Int8, Int8)
sQuotRem Int8
x Int8
0 = (Int8
0, Int8
x)
sQuotRem Int8
x Int8
y = Int8
x Int8 -> Int8 -> (Int8, Int8)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Int8
y
sDivMod :: Int8 -> Int8 -> (Int8, Int8)
sDivMod Int8
x Int8
0 = (Int8
0, Int8
x)
sDivMod Int8
x Int8
y = Int8
x Int8 -> Int8 -> (Int8, Int8)
forall a. Integral a => a -> a -> (a, a)
`divMod` Int8
y
instance SDivisible Integer where
sQuotRem :: Integer -> Integer -> (Integer, Integer)
sQuotRem Integer
x Integer
0 = (Integer
0, Integer
x)
sQuotRem Integer
x Integer
y = Integer
x Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Integer
y
sDivMod :: Integer -> Integer -> (Integer, Integer)
sDivMod Integer
x Integer
0 = (Integer
0, Integer
x)
sDivMod Integer
x Integer
y = Integer
x Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`divMod` Integer
y
instance SDivisible CV where
sQuotRem :: CV -> CV -> (CV, CV)
sQuotRem CV
a CV
b
| CInteger Integer
x <- CV -> CVal
cvVal CV
a, CInteger Integer
y <- CV -> CVal
cvVal CV
b
= let (Integer
r1, Integer
r2) = Integer -> Integer -> (Integer, Integer)
forall a. SDivisible a => a -> a -> (a, a)
sQuotRem Integer
x Integer
y in (CV -> CV
normCV CV
a{ cvVal :: CVal
cvVal = Integer -> CVal
CInteger Integer
r1 }, CV -> CV
normCV CV
b{ cvVal :: CVal
cvVal = Integer -> CVal
CInteger Integer
r2 })
sQuotRem CV
a CV
b = String -> (CV, CV)
forall a. HasCallStack => String -> a
error (String -> (CV, CV)) -> String -> (CV, CV)
forall a b. (a -> b) -> a -> b
$ String
"SBV.sQuotRem: impossible, unexpected args received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (CV, CV) -> String
forall a. Show a => a -> String
show (CV
a, CV
b)
sDivMod :: CV -> CV -> (CV, CV)
sDivMod CV
a CV
b
| CInteger Integer
x <- CV -> CVal
cvVal CV
a, CInteger Integer
y <- CV -> CVal
cvVal CV
b
= let (Integer
r1, Integer
r2) = Integer -> Integer -> (Integer, Integer)
forall a. SDivisible a => a -> a -> (a, a)
sDivMod Integer
x Integer
y in (CV -> CV
normCV CV
a{ cvVal :: CVal
cvVal = Integer -> CVal
CInteger Integer
r1 }, CV -> CV
normCV CV
b{ cvVal :: CVal
cvVal = Integer -> CVal
CInteger Integer
r2 })
sDivMod CV
a CV
b = String -> (CV, CV)
forall a. HasCallStack => String -> a
error (String -> (CV, CV)) -> String -> (CV, CV)
forall a b. (a -> b) -> a -> b
$ String
"SBV.sDivMod: impossible, unexpected args received: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (CV, CV) -> String
forall a. Show a => a -> String
show (CV
a, CV
b)
instance SDivisible SWord64 where
sQuotRem :: SBV Word64 -> SBV Word64 -> (SBV Word64, SBV Word64)
sQuotRem = SBV Word64 -> SBV Word64 -> (SBV Word64, SBV Word64)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Word64 -> SBV Word64 -> (SBV Word64, SBV Word64)
sDivMod = SBV Word64 -> SBV Word64 -> (SBV Word64, SBV Word64)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SInt64 where
sQuotRem :: SBV Int64 -> SBV Int64 -> (SBV Int64, SBV Int64)
sQuotRem = SBV Int64 -> SBV Int64 -> (SBV Int64, SBV Int64)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Int64 -> SBV Int64 -> (SBV Int64, SBV Int64)
sDivMod = SBV Int64 -> SBV Int64 -> (SBV Int64, SBV Int64)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SWord32 where
sQuotRem :: SBV Word32 -> SBV Word32 -> (SBV Word32, SBV Word32)
sQuotRem = SBV Word32 -> SBV Word32 -> (SBV Word32, SBV Word32)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Word32 -> SBV Word32 -> (SBV Word32, SBV Word32)
sDivMod = SBV Word32 -> SBV Word32 -> (SBV Word32, SBV Word32)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SInt32 where
sQuotRem :: SBV Int32 -> SBV Int32 -> (SBV Int32, SBV Int32)
sQuotRem = SBV Int32 -> SBV Int32 -> (SBV Int32, SBV Int32)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Int32 -> SBV Int32 -> (SBV Int32, SBV Int32)
sDivMod = SBV Int32 -> SBV Int32 -> (SBV Int32, SBV Int32)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SWord16 where
sQuotRem :: SBV Word16 -> SBV Word16 -> (SBV Word16, SBV Word16)
sQuotRem = SBV Word16 -> SBV Word16 -> (SBV Word16, SBV Word16)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Word16 -> SBV Word16 -> (SBV Word16, SBV Word16)
sDivMod = SBV Word16 -> SBV Word16 -> (SBV Word16, SBV Word16)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SInt16 where
sQuotRem :: SBV Int16 -> SBV Int16 -> (SBV Int16, SBV Int16)
sQuotRem = SBV Int16 -> SBV Int16 -> (SBV Int16, SBV Int16)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Int16 -> SBV Int16 -> (SBV Int16, SBV Int16)
sDivMod = SBV Int16 -> SBV Int16 -> (SBV Int16, SBV Int16)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SWord8 where
sQuotRem :: SBV Word8 -> SBV Word8 -> (SBV Word8, SBV Word8)
sQuotRem = SBV Word8 -> SBV Word8 -> (SBV Word8, SBV Word8)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Word8 -> SBV Word8 -> (SBV Word8, SBV Word8)
sDivMod = SBV Word8 -> SBV Word8 -> (SBV Word8, SBV Word8)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
instance SDivisible SInt8 where
sQuotRem :: SBV Int8 -> SBV Int8 -> (SBV Int8, SBV Int8)
sQuotRem = SBV Int8 -> SBV Int8 -> (SBV Int8, SBV Int8)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem
sDivMod :: SBV Int8 -> SBV Int8 -> (SBV Int8, SBV Int8)
sDivMod = SBV Int8 -> SBV Int8 -> (SBV Int8, SBV Int8)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
liftQRem :: (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem :: SBV a -> SBV a -> (SBV a, SBV a)
liftQRem SBV a
x SBV a
y
| SBV a -> Bool
forall a. SBV a -> Bool
isConcreteZero SBV a
x
= (SBV a
x, SBV a
x)
| SBV a -> Bool
forall a. SBV a -> Bool
isConcreteOne SBV a
y
= (SBV a
x, SBV a
z)
| Bool
True
= SBV Bool -> (SBV a, SBV a) -> (SBV a, SBV a) -> (SBV a, SBV a)
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
y SBV a -> SBV a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a
z) (SBV a
z, SBV a
x) (SBV a -> SBV a -> (SBV a, SBV a)
forall a a a a. SBV a -> SBV a -> (SBV a, SBV a)
qr SBV a
x SBV a
y)
where qr :: SBV a -> SBV a -> (SBV a, SBV a)
qr (SBV (SVal Kind
sgnsz (Left CV
a))) (SBV (SVal Kind
_ (Left CV
b))) = let (CV
q, CV
r) = CV -> CV -> (CV, CV)
forall a. SDivisible a => a -> a -> (a, a)
sQuotRem CV
a CV
b in (SVal -> SBV a
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
sgnsz (CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left CV
q)), SVal -> SBV a
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
sgnsz (CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left CV
r)))
qr a :: SBV a
a@(SBV (SVal Kind
sgnsz Either CV (Cached SV)
_)) SBV a
b = (SVal -> SBV a
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
sgnsz (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache (Op -> State -> IO SV
mk Op
Quot)))), SVal -> SBV a
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
sgnsz (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache (Op -> State -> IO SV
mk Op
Rem)))))
where mk :: Op -> State -> IO SV
mk Op
o State
st = do SV
sw1 <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
a
SV
sw2 <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
b
Op -> State -> Kind -> SV -> SV -> IO SV
mkSymOp Op
o State
st Kind
sgnsz SV
sw1 SV
sw2
z :: SBV a
z = Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Integer
0::Integer)
liftDMod :: (Ord a, SymVal a, Num a, SDivisible (SBV a)) => SBV a -> SBV a -> (SBV a, SBV a)
liftDMod :: SBV a -> SBV a -> (SBV a, SBV a)
liftDMod SBV a
x SBV a
y
| SBV a -> Bool
forall a. SBV a -> Bool
isConcreteZero SBV a
x
= (SBV a
x, SBV a
x)
| SBV a -> Bool
forall a. SBV a -> Bool
isConcreteOne SBV a
y
= (SBV a
x, SBV a
z)
| Bool
True
= SBV Bool -> (SBV a, SBV a) -> (SBV a, SBV a) -> (SBV a, SBV a)
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a
y SBV a -> SBV a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a
z) (SBV a
z, SBV a
x) ((SBV a, SBV a) -> (SBV a, SBV a))
-> (SBV a, SBV a) -> (SBV a, SBV a)
forall a b. (a -> b) -> a -> b
$ SBV Bool -> (SBV a, SBV a) -> (SBV a, SBV a) -> (SBV a, SBV a)
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV a -> SBV a
forall a. Num a => a -> a
signum SBV a
r SBV a -> SBV a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV a
forall a. Num a => a -> a
negate (SBV a -> SBV a
forall a. Num a => a -> a
signum SBV a
y)) (SBV a
qSBV a -> SBV a -> SBV a
forall a. Num a => a -> a -> a
-SBV a
i, SBV a
rSBV a -> SBV a -> SBV a
forall a. Num a => a -> a -> a
+SBV a
y) (SBV a, SBV a)
qr
where qr :: (SBV a, SBV a)
qr@(SBV a
q, SBV a
r) = SBV a
x SBV a -> SBV a -> (SBV a, SBV a)
forall a. SDivisible a => a -> a -> (a, a)
`sQuotRem` SBV a
y
z :: SBV a
z = Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Integer
0::Integer)
i :: SBV a
i = Kind -> Integer -> SBV a
forall a b. Integral a => Kind -> a -> SBV b
genLiteral (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Integer
1::Integer)
instance SDivisible SInteger where
sDivMod :: SBV Integer -> SBV Integer -> (SBV Integer, SBV Integer)
sDivMod = SBV Integer -> SBV Integer -> (SBV Integer, SBV Integer)
forall a.
(Ord a, SymVal a, Num a, SDivisible (SBV a)) =>
SBV a -> SBV a -> (SBV a, SBV a)
liftDMod
sQuotRem :: SBV Integer -> SBV Integer -> (SBV Integer, SBV Integer)
sQuotRem SBV Integer
x SBV Integer
y
| Bool -> Bool
not (SBV Integer -> Bool
forall a. SymVal a => SBV a -> Bool
isSymbolic SBV Integer
x Bool -> Bool -> Bool
|| SBV Integer -> Bool
forall a. SymVal a => SBV a -> Bool
isSymbolic SBV Integer
y)
= SBV Integer -> SBV Integer -> (SBV Integer, SBV Integer)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem SBV Integer
x SBV Integer
y
| Bool
True
= SBV Bool
-> (SBV Integer, SBV Integer)
-> (SBV Integer, SBV Integer)
-> (SBV Integer, SBV Integer)
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV Integer
y SBV Integer -> SBV Integer -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV Integer
0) (SBV Integer
0, SBV Integer
x) (SBV Integer
qESBV Integer -> SBV Integer -> SBV Integer
forall a. Num a => a -> a -> a
+SBV Integer
i, SBV Integer
rESBV Integer -> SBV Integer -> SBV Integer
forall a. Num a => a -> a -> a
-SBV Integer
iSBV Integer -> SBV Integer -> SBV Integer
forall a. Num a => a -> a -> a
*SBV Integer
y)
where (SBV Integer
qE, SBV Integer
rE) = SBV Integer -> SBV Integer -> (SBV Integer, SBV Integer)
forall a. (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)
liftQRem SBV Integer
x SBV Integer
y
i :: SBV Integer
i = SBV Bool -> SBV Integer -> SBV Integer -> SBV Integer
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV Integer
x SBV Integer -> SBV Integer -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.>= SBV Integer
0 SBV Bool -> SBV Bool -> SBV Bool
.|| SBV Integer
rE SBV Integer -> SBV Integer -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV Integer
0) SBV Integer
0
(SBV Integer -> SBV Integer) -> SBV Integer -> SBV Integer
forall a b. (a -> b) -> a -> b
$ SBV Bool -> SBV Integer -> SBV Integer -> SBV Integer
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV Integer
y SBV Integer -> SBV Integer -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.> SBV Integer
0) SBV Integer
1 (-SBV Integer
1)
instance (SymVal a, Arbitrary a) => Arbitrary (SBV a) where
arbitrary :: Gen (SBV a)
arbitrary = a -> SBV a
forall a. SymVal a => a -> SBV a
literal (a -> SBV a) -> Gen a -> Gen (SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Gen a
forall a. Arbitrary a => Gen a
arbitrary
class Mergeable a where
symbolicMerge :: Bool -> SBool -> a -> a -> a
select :: (Ord b, SymVal b, Num b) => [a] -> a -> SBV b -> a
select [a]
xs a
err SBV b
ind
| SBV b -> Bool
forall a. HasKind a => a -> Bool
isReal SBV b
ind = String -> a
forall a. String -> a
bad String
"real"
| SBV b -> Bool
forall a. HasKind a => a -> Bool
isFloat SBV b
ind = String -> a
forall a. String -> a
bad String
"float"
| SBV b -> Bool
forall a. HasKind a => a -> Bool
isDouble SBV b
ind = String -> a
forall a. String -> a
bad String
"double"
| SBV b -> Bool
forall a. HasKind a => a -> Bool
hasSign SBV b
ind = SBV Bool -> a -> a -> a
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (SBV b
ind SBV b -> SBV b -> SBV Bool
forall a. OrdSymbolic a => a -> a -> SBV Bool
.< SBV b
0) a
err ([a] -> SBV b -> a -> a
forall a t.
(Num a, Mergeable t, EqSymbolic a) =>
[t] -> a -> t -> t
walk [a]
xs SBV b
ind a
err)
| Bool
True = [a] -> SBV b -> a -> a
forall a t.
(Num a, Mergeable t, EqSymbolic a) =>
[t] -> a -> t -> t
walk [a]
xs SBV b
ind a
err
where bad :: String -> a
bad String
w = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ String
"SBV.select: unsupported " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" valued select/index expression"
walk :: [t] -> a -> t -> t
walk [] a
_ t
acc = t
acc
walk (t
e:[t]
es) a
i t
acc = [t] -> a -> t -> t
walk [t]
es (a
ia -> a -> a
forall a. Num a => a -> a -> a
-a
1) (SBV Bool -> t -> t -> t
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite (a
i a -> a -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== a
0) t
e t
acc)
default symbolicMerge :: (G.Generic a, GMergeable (G.Rep a)) => Bool -> SBool -> a -> a -> a
symbolicMerge = Bool -> SBV Bool -> a -> a -> a
forall a.
(Generic a, GMergeable (Rep a)) =>
Bool -> SBV Bool -> a -> a -> a
symbolicMergeDefault
ite :: Mergeable a => SBool -> a -> a -> a
ite :: SBV Bool -> a -> a -> a
ite SBV Bool
t a
a a
b
| Just Bool
r <- SBV Bool -> Maybe Bool
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Bool
t = if Bool
r then a
a else a
b
| Bool
True = Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
True SBV Bool
t a
a a
b
iteLazy :: Mergeable a => SBool -> a -> a -> a
iteLazy :: SBV Bool -> a -> a -> a
iteLazy SBV Bool
t a
a a
b
| Just Bool
r <- SBV Bool -> Maybe Bool
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Bool
t = if Bool
r then a
a else a
b
| Bool
True = Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
False SBV Bool
t a
a a
b
sAssert :: HasKind a => Maybe CallStack -> String -> SBool -> SBV a -> SBV a
sAssert :: Maybe CallStack -> String -> SBV Bool -> SBV a -> SBV a
sAssert Maybe CallStack
cs String
msg SBV Bool
cond SBV a
x
| Just Bool
mustHold <- SBV Bool -> Maybe Bool
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Bool
cond
= if Bool
mustHold
then SBV a
x
else String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ SafeResult -> String
forall a. Show a => a -> String
show (SafeResult -> String) -> SafeResult -> String
forall a b. (a -> b) -> a -> b
$ (Maybe String, String, SMTResult) -> SafeResult
SafeResult (([(String, SrcLoc)] -> String
locInfo ([(String, SrcLoc)] -> String)
-> (CallStack -> [(String, SrcLoc)]) -> CallStack -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CallStack -> [(String, SrcLoc)]
getCallStack) (CallStack -> String) -> Maybe CallStack -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe CallStack
cs, String
msg, SMTConfig -> SMTModel -> SMTResult
Satisfiable SMTConfig
defaultSMTCfg ([(String, GeneralizedCV)]
-> Maybe [((Quantifier, NamedSymVar), Maybe CV)]
-> [(String, CV)]
-> [(String, (SBVType, ([([CV], CV)], CV)))]
-> SMTModel
SMTModel [] Maybe [((Quantifier, NamedSymVar), Maybe CV)]
forall a. Maybe a
Nothing [] []))
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x
r :: State -> IO SV
r State
st = do SV
xsv <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
x
let pc :: SBV Bool
pc = State -> SBV Bool
getPathCondition State
st
mustNeverHappen :: SBV Bool
mustNeverHappen = SBV Bool
pc SBV Bool -> SBV Bool -> SBV Bool
.&& SBV Bool -> SBV Bool
sNot SBV Bool
cond
SV
cnd <- State -> SBV Bool -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV Bool
mustNeverHappen
State -> Maybe CallStack -> String -> SV -> IO ()
addAssertion State
st Maybe CallStack
cs String
msg SV
cnd
SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
xsv
locInfo :: [(String, SrcLoc)] -> String
locInfo [(String, SrcLoc)]
ps = String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
",\n " (((String, SrcLoc) -> String) -> [(String, SrcLoc)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, SrcLoc) -> String
loc [(String, SrcLoc)]
ps)
where loc :: (String, SrcLoc) -> String
loc (String
f, SrcLoc
sl) = [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [SrcLoc -> String
srcLocFile SrcLoc
sl, String
":", Int -> String
forall a. Show a => a -> String
show (SrcLoc -> Int
srcLocStartLine SrcLoc
sl), String
":", Int -> String
forall a. Show a => a -> String
show (SrcLoc -> Int
srcLocStartCol SrcLoc
sl), String
":", String
f]
symbolicMergeWithKind :: Kind -> Bool -> SBool -> SBV a -> SBV a -> SBV a
symbolicMergeWithKind :: Kind -> Bool -> SBV Bool -> SBV a -> SBV a -> SBV a
symbolicMergeWithKind Kind
k Bool
force (SBV SVal
t) (SBV SVal
a) (SBV SVal
b) = SVal -> SBV a
forall a. SVal -> SBV a
SBV (Kind -> Bool -> SVal -> SVal -> SVal -> SVal
svSymbolicMerge Kind
k Bool
force SVal
t SVal
a SVal
b)
instance SymVal a => Mergeable (SBV a) where
symbolicMerge :: Bool -> SBV Bool -> SBV a -> SBV a -> SBV a
symbolicMerge Bool
force SBV Bool
t SBV a
x SBV a
y
| Bool
force = Kind -> Bool -> SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Kind -> Bool -> SBV Bool -> SBV a -> SBV a -> SBV a
symbolicMergeWithKind (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) Bool
True SBV Bool
t SBV a
x SBV a
y
| Bool
True = Kind -> Bool -> SBV Bool -> SBV a -> SBV a -> SBV a
forall a. Kind -> Bool -> SBV Bool -> SBV a -> SBV a -> SBV a
symbolicMergeWithKind (Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)) Bool
False SBV Bool
t SBV a
x SBV a
y
select :: [SBV a] -> SBV a -> SBV b -> SBV a
select [SBV a]
xs SBV a
err SBV b
ind
| SBV (SVal Kind
_ (Left CV
c)) <- SBV b
ind = case CV -> CVal
cvVal CV
c of
CInteger Integer
i -> if Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 Bool -> Bool -> Bool
|| Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= [SBV a] -> Integer
forall i a. Num i => [a] -> i
genericLength [SBV a]
xs
then SBV a
err
else [SBV a]
xs [SBV a] -> Integer -> SBV a
forall i a. Integral i => [a] -> i -> a
`genericIndex` Integer
i
CVal
_ -> String -> SBV a
forall a. HasCallStack => String -> a
error (String -> SBV a) -> String -> SBV a
forall a b. (a -> b) -> a -> b
$ String
"SBV.select: unsupported " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SBV b -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV b
ind) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" valued select/index expression"
select [SBV a]
xsOrig SBV a
err SBV b
ind = [SBV a]
xs [SBV a] -> SBV a -> SBV a
`seq` SVal -> SBV a
forall a. SVal -> SBV a
SBV (Kind -> Either CV (Cached SV) -> SVal
SVal Kind
kElt (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r)))
where kInd :: Kind
kInd = SBV b -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV b
ind
kElt :: Kind
kElt = SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
err
xs :: [SBV a]
xs = case SBV b -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV b
ind of
KBounded Bool
False Int
i -> Integer -> [SBV a] -> [SBV a]
forall i a. Integral i => i -> [a] -> [a]
genericTake ((Integer
2::Integer) Integer -> Integer -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i :: Integer)) [SBV a]
xsOrig
KBounded Bool
True Int
i -> Integer -> [SBV a] -> [SBV a]
forall i a. Integral i => i -> [a] -> [a]
genericTake ((Integer
2::Integer) Integer -> Integer -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) :: Integer)) [SBV a]
xsOrig
Kind
KUnbounded -> [SBV a]
xsOrig
Kind
_ -> String -> [SBV a]
forall a. HasCallStack => String -> a
error (String -> [SBV a]) -> String -> [SBV a]
forall a b. (a -> b) -> a -> b
$ String
"SBV.select: unsupported " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SBV b -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV b
ind) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" valued select/index expression"
r :: State -> IO SV
r State
st = do [SV]
sws <- (SBV a -> IO SV) -> [SBV a] -> IO [SV]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st) [SBV a]
xs
SV
swe <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
err
if (SV -> Bool) -> [SV] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (SV -> SV -> Bool
forall a. Eq a => a -> a -> Bool
== SV
swe) [SV]
sws
then SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
swe
else do Int
idx <- State -> Kind -> Kind -> [SV] -> IO Int
getTableIndex State
st Kind
kInd Kind
kElt [SV]
sws
SV
swi <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
ind
let len :: Int
len = [SBV a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SBV a]
xs
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
kElt (Op -> [SV] -> SBVExpr
SBVApp ((Int, Kind, Kind, Int) -> SV -> SV -> Op
LkUp (Int
idx, Kind
kInd, Kind
kElt, Int
len) SV
swi SV
swe) [])
instance Mergeable () where
symbolicMerge :: Bool -> SBV Bool -> () -> () -> ()
symbolicMerge Bool
_ SBV Bool
_ ()
_ ()
_ = ()
select :: [()] -> () -> SBV b -> ()
select [()]
_ ()
_ SBV b
_ = ()
cannotMerge :: String -> String -> String -> a
cannotMerge :: String -> String -> String -> a
cannotMerge String
typ String
why String
hint = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ [String] -> String
unlines [ String
""
, String
"*** Data.SBV.Mergeable: Cannot merge instances of " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
typ String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"."
, String
"*** While trying to do a symbolic if-then-else with incompatible branch results."
, String
"***"
, String
"*** " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
why
, String
"*** "
, String
"*** Hint: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
hint
]
instance Mergeable a => Mergeable [a] where
symbolicMerge :: Bool -> SBV Bool -> [a] -> [a] -> [a]
symbolicMerge Bool
f SBV Bool
t [a]
xs [a]
ys
| Int
lxs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
lys = (a -> a -> a) -> [a] -> [a] -> [a]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t) [a]
xs [a]
ys
| Bool
True = String -> String -> String -> [a]
forall a. String -> String -> String -> a
cannotMerge String
"lists"
(String
"Branches produce different sizes: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
lxs String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" vs " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
lys String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
". Must have the same length.")
String
"Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."
where (Int
lxs, Int
lys) = ([a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs, [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
ys)
instance Mergeable a => Mergeable (ZipList a) where
symbolicMerge :: Bool -> SBV Bool -> ZipList a -> ZipList a -> ZipList a
symbolicMerge Bool
force SBV Bool
test (ZipList [a]
xs) (ZipList [a]
ys)
= [a] -> ZipList a
forall a. [a] -> ZipList a
ZipList (Bool -> SBV Bool -> [a] -> [a] -> [a]
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
force SBV Bool
test [a]
xs [a]
ys)
instance Mergeable a => Mergeable (Maybe a) where
symbolicMerge :: Bool -> SBV Bool -> Maybe a -> Maybe a -> Maybe a
symbolicMerge Bool
_ SBV Bool
_ Maybe a
Nothing Maybe a
Nothing = Maybe a
forall a. Maybe a
Nothing
symbolicMerge Bool
f SBV Bool
t (Just a
a) (Just a
b) = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
a a
b
symbolicMerge Bool
_ SBV Bool
_ Maybe a
a Maybe a
b = String -> String -> String -> Maybe a
forall a. String -> String -> String -> a
cannotMerge String
"'Maybe' values"
(String
"Branches produce different constructors: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (String, String) -> String
forall a. Show a => a -> String
show (Maybe a -> String
forall a. Maybe a -> String
k Maybe a
a, Maybe a -> String
forall a. Maybe a -> String
k Maybe a
b))
String
"Instead of an option type, try using a valid bit to indicate when a result is valid."
where k :: Maybe a -> String
k Maybe a
Nothing = String
"Nothing"
k Maybe a
_ = String
"Just"
instance (Mergeable a, Mergeable b) => Mergeable (Either a b) where
symbolicMerge :: Bool -> SBV Bool -> Either a b -> Either a b -> Either a b
symbolicMerge Bool
f SBV Bool
t (Left a
a) (Left a
b) = a -> Either a b
forall a b. a -> Either a b
Left (a -> Either a b) -> a -> Either a b
forall a b. (a -> b) -> a -> b
$ Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
a a
b
symbolicMerge Bool
f SBV Bool
t (Right b
a) (Right b
b) = b -> Either a b
forall a b. b -> Either a b
Right (b -> Either a b) -> b -> Either a b
forall a b. (a -> b) -> a -> b
$ Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
a b
b
symbolicMerge Bool
_ SBV Bool
_ Either a b
a Either a b
b = String -> String -> String -> Either a b
forall a. String -> String -> String -> a
cannotMerge String
"'Either' values"
(String
"Branches produce different constructors: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (String, String) -> String
forall a. Show a => a -> String
show (Either a b -> String
forall a b. Either a b -> String
k Either a b
a, Either a b -> String
forall a b. Either a b -> String
k Either a b
b))
String
"Consider using a product type by a tag instead."
where k :: Either a b -> String
k (Left a
_) = String
"Left"
k (Right b
_) = String
"Right"
instance (Ix a, Mergeable b) => Mergeable (Array a b) where
symbolicMerge :: Bool -> SBV Bool -> Array a b -> Array a b -> Array a b
symbolicMerge Bool
f SBV Bool
t Array a b
a Array a b
b
| (a, a)
ba (a, a) -> (a, a) -> Bool
forall a. Eq a => a -> a -> Bool
== (a, a)
bb = (a, a) -> [b] -> Array a b
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (a, a)
ba ((b -> b -> b) -> [b] -> [b] -> [b]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t) (Array a b -> [b]
forall i e. Array i e -> [e]
elems Array a b
a) (Array a b -> [b]
forall i e. Array i e -> [e]
elems Array a b
b))
| Bool
True = String -> String -> String -> Array a b
forall a. String -> String -> String -> a
cannotMerge String
"'Array' values"
(String
"Branches produce different ranges: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int, Int) -> String
forall a. Show a => a -> String
show ((a, a) -> Int
k (a, a)
ba, (a, a) -> Int
k (a, a)
bb))
String
"Consider using SBV's native arrays 'SArray' and 'SFunArray' instead."
where [(a, a)
ba, (a, a)
bb] = (Array a b -> (a, a)) -> [Array a b] -> [(a, a)]
forall a b. (a -> b) -> [a] -> [b]
map Array a b -> (a, a)
forall i e. Array i e -> (i, i)
bounds [Array a b
a, Array a b
b]
k :: (a, a) -> Int
k = (a, a) -> Int
forall a. Ix a => (a, a) -> Int
rangeSize
instance Mergeable b => Mergeable (a -> b) where
symbolicMerge :: Bool -> SBV Bool -> (a -> b) -> (a -> b) -> a -> b
symbolicMerge Bool
f SBV Bool
t a -> b
g a -> b
h a
x = Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t (a -> b
g a
x) (a -> b
h a
x)
instance (Mergeable a, Mergeable b) => Mergeable (a, b) where
symbolicMerge :: Bool -> SBV Bool -> (a, b) -> (a, b) -> (a, b)
symbolicMerge Bool
f SBV Bool
t (a
i0, b
i1) (a
j0, b
j1) = ( Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
i0 a
j0
, Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
i1 b
j1
)
select :: [(a, b)] -> (a, b) -> SBV b -> (a, b)
select [(a, b)]
xs (a
err1, b
err2) SBV b
ind = ( [a] -> a -> SBV b -> a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [a]
as a
err1 SBV b
ind
, [b] -> b -> SBV b -> b
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [b]
bs b
err2 SBV b
ind
)
where ([a]
as, [b]
bs) = [(a, b)] -> ([a], [b])
forall a b. [(a, b)] -> ([a], [b])
unzip [(a, b)]
xs
instance (Mergeable a, Mergeable b, Mergeable c) => Mergeable (a, b, c) where
symbolicMerge :: Bool -> SBV Bool -> (a, b, c) -> (a, b, c) -> (a, b, c)
symbolicMerge Bool
f SBV Bool
t (a
i0, b
i1, c
i2) (a
j0, b
j1, c
j2) = ( Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
i0 a
j0
, Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
i1 b
j1
, Bool -> SBV Bool -> c -> c -> c
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t c
i2 c
j2
)
select :: [(a, b, c)] -> (a, b, c) -> SBV b -> (a, b, c)
select [(a, b, c)]
xs (a
err1, b
err2, c
err3) SBV b
ind = ( [a] -> a -> SBV b -> a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [a]
as a
err1 SBV b
ind
, [b] -> b -> SBV b -> b
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [b]
bs b
err2 SBV b
ind
, [c] -> c -> SBV b -> c
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [c]
cs c
err3 SBV b
ind
)
where ([a]
as, [b]
bs, [c]
cs) = [(a, b, c)] -> ([a], [b], [c])
forall a b c. [(a, b, c)] -> ([a], [b], [c])
unzip3 [(a, b, c)]
xs
instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d) => Mergeable (a, b, c, d) where
symbolicMerge :: Bool -> SBV Bool -> (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d)
symbolicMerge Bool
f SBV Bool
t (a
i0, b
i1, c
i2, d
i3) (a
j0, b
j1, c
j2, d
j3) = ( Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
i0 a
j0
, Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
i1 b
j1
, Bool -> SBV Bool -> c -> c -> c
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t c
i2 c
j2
, Bool -> SBV Bool -> d -> d -> d
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t d
i3 d
j3
)
select :: [(a, b, c, d)] -> (a, b, c, d) -> SBV b -> (a, b, c, d)
select [(a, b, c, d)]
xs (a
err1, b
err2, c
err3, d
err4) SBV b
ind = ( [a] -> a -> SBV b -> a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [a]
as a
err1 SBV b
ind
, [b] -> b -> SBV b -> b
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [b]
bs b
err2 SBV b
ind
, [c] -> c -> SBV b -> c
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [c]
cs c
err3 SBV b
ind
, [d] -> d -> SBV b -> d
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [d]
ds d
err4 SBV b
ind
)
where ([a]
as, [b]
bs, [c]
cs, [d]
ds) = [(a, b, c, d)] -> ([a], [b], [c], [d])
forall a b c d. [(a, b, c, d)] -> ([a], [b], [c], [d])
unzip4 [(a, b, c, d)]
xs
instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e) => Mergeable (a, b, c, d, e) where
symbolicMerge :: Bool
-> SBV Bool
-> (a, b, c, d, e)
-> (a, b, c, d, e)
-> (a, b, c, d, e)
symbolicMerge Bool
f SBV Bool
t (a
i0, b
i1, c
i2, d
i3, e
i4) (a
j0, b
j1, c
j2, d
j3, e
j4) = ( Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
i0 a
j0
, Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
i1 b
j1
, Bool -> SBV Bool -> c -> c -> c
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t c
i2 c
j2
, Bool -> SBV Bool -> d -> d -> d
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t d
i3 d
j3
, Bool -> SBV Bool -> e -> e -> e
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t e
i4 e
j4
)
select :: [(a, b, c, d, e)] -> (a, b, c, d, e) -> SBV b -> (a, b, c, d, e)
select [(a, b, c, d, e)]
xs (a
err1, b
err2, c
err3, d
err4, e
err5) SBV b
ind = ( [a] -> a -> SBV b -> a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [a]
as a
err1 SBV b
ind
, [b] -> b -> SBV b -> b
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [b]
bs b
err2 SBV b
ind
, [c] -> c -> SBV b -> c
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [c]
cs c
err3 SBV b
ind
, [d] -> d -> SBV b -> d
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [d]
ds d
err4 SBV b
ind
, [e] -> e -> SBV b -> e
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [e]
es e
err5 SBV b
ind
)
where ([a]
as, [b]
bs, [c]
cs, [d]
ds, [e]
es) = [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])
forall a b c d e. [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])
unzip5 [(a, b, c, d, e)]
xs
instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f) => Mergeable (a, b, c, d, e, f) where
symbolicMerge :: Bool
-> SBV Bool
-> (a, b, c, d, e, f)
-> (a, b, c, d, e, f)
-> (a, b, c, d, e, f)
symbolicMerge Bool
f SBV Bool
t (a
i0, b
i1, c
i2, d
i3, e
i4, f
i5) (a
j0, b
j1, c
j2, d
j3, e
j4, f
j5) = ( Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
i0 a
j0
, Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
i1 b
j1
, Bool -> SBV Bool -> c -> c -> c
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t c
i2 c
j2
, Bool -> SBV Bool -> d -> d -> d
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t d
i3 d
j3
, Bool -> SBV Bool -> e -> e -> e
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t e
i4 e
j4
, Bool -> SBV Bool -> f -> f -> f
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t f
i5 f
j5
)
select :: [(a, b, c, d, e, f)]
-> (a, b, c, d, e, f) -> SBV b -> (a, b, c, d, e, f)
select [(a, b, c, d, e, f)]
xs (a
err1, b
err2, c
err3, d
err4, e
err5, f
err6) SBV b
ind = ( [a] -> a -> SBV b -> a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [a]
as a
err1 SBV b
ind
, [b] -> b -> SBV b -> b
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [b]
bs b
err2 SBV b
ind
, [c] -> c -> SBV b -> c
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [c]
cs c
err3 SBV b
ind
, [d] -> d -> SBV b -> d
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [d]
ds d
err4 SBV b
ind
, [e] -> e -> SBV b -> e
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [e]
es e
err5 SBV b
ind
, [f] -> f -> SBV b -> f
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [f]
fs f
err6 SBV b
ind
)
where ([a]
as, [b]
bs, [c]
cs, [d]
ds, [e]
es, [f]
fs) = [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])
forall a b c d e f.
[(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])
unzip6 [(a, b, c, d, e, f)]
xs
instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f, Mergeable g) => Mergeable (a, b, c, d, e, f, g) where
symbolicMerge :: Bool
-> SBV Bool
-> (a, b, c, d, e, f, g)
-> (a, b, c, d, e, f, g)
-> (a, b, c, d, e, f, g)
symbolicMerge Bool
f SBV Bool
t (a
i0, b
i1, c
i2, d
i3, e
i4, f
i5, g
i6) (a
j0, b
j1, c
j2, d
j3, e
j4, f
j5, g
j6) = ( Bool -> SBV Bool -> a -> a -> a
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t a
i0 a
j0
, Bool -> SBV Bool -> b -> b -> b
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t b
i1 b
j1
, Bool -> SBV Bool -> c -> c -> c
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t c
i2 c
j2
, Bool -> SBV Bool -> d -> d -> d
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t d
i3 d
j3
, Bool -> SBV Bool -> e -> e -> e
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t e
i4 e
j4
, Bool -> SBV Bool -> f -> f -> f
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t f
i5 f
j5
, Bool -> SBV Bool -> g -> g -> g
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
f SBV Bool
t g
i6 g
j6
)
select :: [(a, b, c, d, e, f, g)]
-> (a, b, c, d, e, f, g) -> SBV b -> (a, b, c, d, e, f, g)
select [(a, b, c, d, e, f, g)]
xs (a
err1, b
err2, c
err3, d
err4, e
err5, f
err6, g
err7) SBV b
ind = ( [a] -> a -> SBV b -> a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [a]
as a
err1 SBV b
ind
, [b] -> b -> SBV b -> b
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [b]
bs b
err2 SBV b
ind
, [c] -> c -> SBV b -> c
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [c]
cs c
err3 SBV b
ind
, [d] -> d -> SBV b -> d
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [d]
ds d
err4 SBV b
ind
, [e] -> e -> SBV b -> e
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [e]
es e
err5 SBV b
ind
, [f] -> f -> SBV b -> f
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [f]
fs f
err6 SBV b
ind
, [g] -> g -> SBV b -> g
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[a] -> a -> SBV b -> a
select [g]
gs g
err7 SBV b
ind
)
where ([a]
as, [b]
bs, [c]
cs, [d]
ds, [e]
es, [f]
fs, [g]
gs) = [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])
forall a b c d e f g.
[(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])
unzip7 [(a, b, c, d, e, f, g)]
xs
symbolicMergeDefault :: (G.Generic a, GMergeable (G.Rep a)) => Bool -> SBool -> a -> a -> a
symbolicMergeDefault :: Bool -> SBV Bool -> a -> a -> a
symbolicMergeDefault Bool
force SBV Bool
t a
x a
y = Rep a Any -> a
forall a x. Generic a => Rep a x -> a
G.to (Rep a Any -> a) -> Rep a Any -> a
forall a b. (a -> b) -> a -> b
$ Bool -> SBV Bool -> Rep a Any -> Rep a Any -> Rep a Any
forall (f :: * -> *) a.
GMergeable f =>
Bool -> SBV Bool -> f a -> f a -> f a
symbolicMerge' Bool
force SBV Bool
t (a -> Rep a Any
forall a x. Generic a => a -> Rep a x
G.from a
x) (a -> Rep a Any
forall a x. Generic a => a -> Rep a x
G.from a
y)
class GMergeable f where
symbolicMerge' :: Bool -> SBool -> f a -> f a -> f a
instance GMergeable U1 where
symbolicMerge' :: Bool -> SBV Bool -> U1 a -> U1 a -> U1 a
symbolicMerge' Bool
_ SBV Bool
_ U1 a
_ U1 a
_ = U1 a
forall k (p :: k). U1 p
U1
instance (Mergeable c) => GMergeable (K1 i c) where
symbolicMerge' :: Bool -> SBV Bool -> K1 i c a -> K1 i c a -> K1 i c a
symbolicMerge' Bool
force SBV Bool
t (K1 c
x) (K1 c
y) = c -> K1 i c a
forall k i c (p :: k). c -> K1 i c p
K1 (c -> K1 i c a) -> c -> K1 i c a
forall a b. (a -> b) -> a -> b
$ Bool -> SBV Bool -> c -> c -> c
forall a. Mergeable a => Bool -> SBV Bool -> a -> a -> a
symbolicMerge Bool
force SBV Bool
t c
x c
y
instance (GMergeable f) => GMergeable (M1 i c f) where
symbolicMerge' :: Bool -> SBV Bool -> M1 i c f a -> M1 i c f a -> M1 i c f a
symbolicMerge' Bool
force SBV Bool
t (M1 f a
x) (M1 f a
y) = f a -> M1 i c f a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (f a -> M1 i c f a) -> f a -> M1 i c f a
forall a b. (a -> b) -> a -> b
$ Bool -> SBV Bool -> f a -> f a -> f a
forall (f :: * -> *) a.
GMergeable f =>
Bool -> SBV Bool -> f a -> f a -> f a
symbolicMerge' Bool
force SBV Bool
t f a
x f a
y
instance (GMergeable f, GMergeable g) => GMergeable (f :*: g) where
symbolicMerge' :: Bool -> SBV Bool -> (:*:) f g a -> (:*:) f g a -> (:*:) f g a
symbolicMerge' Bool
force SBV Bool
t (f a
x1 :*: g a
y1) (f a
x2 :*: g a
y2) = Bool -> SBV Bool -> f a -> f a -> f a
forall (f :: * -> *) a.
GMergeable f =>
Bool -> SBV Bool -> f a -> f a -> f a
symbolicMerge' Bool
force SBV Bool
t f a
x1 f a
x2 f a -> g a -> (:*:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: Bool -> SBV Bool -> g a -> g a -> g a
forall (f :: * -> *) a.
GMergeable f =>
Bool -> SBV Bool -> f a -> f a -> f a
symbolicMerge' Bool
force SBV Bool
t g a
y1 g a
y2
instance (SymVal a, Bounded a) => Bounded (SBV a) where
minBound :: SBV a
minBound = a -> SBV a
forall a. SymVal a => a -> SBV a
literal a
forall a. Bounded a => a
minBound
maxBound :: SBV a
maxBound = a -> SBV a
forall a. SymVal a => a -> SBV a
literal a
forall a. Bounded a => a
maxBound
instance EqSymbolic (SArray a b) where
SArray SArr
a .== :: SArray a b -> SArray a b -> SBV Bool
.== SArray SArr
b = SVal -> SBV Bool
forall a. SVal -> SBV a
SBV (SArr
a SArr -> SArr -> SVal
`eqSArr` SArr
b)
instance SymVal b => Mergeable (SArray a b) where
symbolicMerge :: Bool -> SBV Bool -> SArray a b -> SArray a b -> SArray a b
symbolicMerge Bool
_ = SBV Bool -> SArray a b -> SArray a b -> SArray a b
forall (array :: * -> * -> *) b a.
(SymArray array, SymVal b) =>
SBV Bool -> array a b -> array a b -> array a b
mergeArrays
instance SymVal b => Mergeable (SFunArray a b) where
symbolicMerge :: Bool -> SBV Bool -> SFunArray a b -> SFunArray a b -> SFunArray a b
symbolicMerge Bool
_ = SBV Bool -> SFunArray a b -> SFunArray a b -> SFunArray a b
forall (array :: * -> * -> *) b a.
(SymArray array, SymVal b) =>
SBV Bool -> array a b -> array a b -> array a b
mergeArrays
class Uninterpreted a where
uninterpret :: String -> a
cgUninterpret :: String -> [String] -> a -> a
sbvUninterpret :: Maybe ([String], a) -> String -> a
sym :: String -> a
{-# MINIMAL sbvUninterpret #-}
uninterpret = Maybe ([String], a) -> String -> a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret Maybe ([String], a)
forall a. Maybe a
Nothing
cgUninterpret String
nm [String]
code a
v = Maybe ([String], a) -> String -> a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String], a) -> Maybe ([String], a)
forall a. a -> Maybe a
Just ([String]
code, a
v)) String
nm
sym = String -> a
forall a. Uninterpreted a => String -> a
uninterpret
instance HasKind a => Uninterpreted (SBV a) where
sbvUninterpret :: Maybe ([String], SBV a) -> String -> SBV a
sbvUninterpret Maybe ([String], SBV a)
mbCgData String
nm
| Just ([String]
_, SBV a
v) <- Maybe ([String], SBV a)
mbCgData = SBV a
v
| Bool
True = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe ([String], SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
v
(Bool, Maybe ([String], SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
ka]) (([String], SBV a) -> [String]
forall a b. (a, b) -> a
fst (([String], SBV a) -> [String])
-> Maybe ([String], SBV a) -> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], SBV a)
mbCgData)
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) []
instance (SymVal b, HasKind a) => Uninterpreted (SBV b -> SBV a) where
sbvUninterpret :: Maybe ([String], SBV b -> SBV a) -> String -> SBV b -> SBV a
sbvUninterpret Maybe ([String], SBV b -> SBV a)
mbCgData String
nm = SBV b -> SBV a
f
where f :: SBV b -> SBV a
f SBV b
arg0
| Just ([String]
_, SBV b -> SBV a
v) <- Maybe ([String], SBV b -> SBV a)
mbCgData, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg0
= SBV b -> SBV a
v SBV b
arg0
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe ([String], SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV b -> SBV a
v SBV b
arg0)
(Bool, Maybe ([String], SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
kb, Kind
ka]) (([String], SBV b -> SBV a) -> [String]
forall a b. (a, b) -> a
fst (([String], SBV b -> SBV a) -> [String])
-> Maybe ([String], SBV b -> SBV a) -> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg0
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0]
instance (SymVal c, SymVal b, HasKind a) => Uninterpreted (SBV c -> SBV b -> SBV a) where
sbvUninterpret :: Maybe ([String], SBV c -> SBV b -> SBV a)
-> String -> SBV c -> SBV b -> SBV a
sbvUninterpret Maybe ([String], SBV c -> SBV b -> SBV a)
mbCgData String
nm = SBV c -> SBV b -> SBV a
f
where f :: SBV c -> SBV b -> SBV a
f SBV c
arg0 SBV b
arg1
| Just ([String]
_, SBV c -> SBV b -> SBV a
v) <- Maybe ([String], SBV c -> SBV b -> SBV a)
mbCgData, SBV c -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV c
arg0, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg1
= SBV c -> SBV b -> SBV a
v SBV c
arg0 SBV b
arg1
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
kc :: Kind
kc = Proxy c -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy c
forall k (t :: k). Proxy t
Proxy @c)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe ([String], SBV c -> SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV c -> SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV c -> SBV b -> SBV a
v SBV c
arg0 SBV b
arg1)
(Bool, Maybe ([String], SBV c -> SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
kc, Kind
kb, Kind
ka]) (([String], SBV c -> SBV b -> SBV a) -> [String]
forall a b. (a, b) -> a
fst (([String], SBV c -> SBV b -> SBV a) -> [String])
-> Maybe ([String], SBV c -> SBV b -> SBV a) -> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], SBV c -> SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV c -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV c
arg0
SV
sw1 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg1
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0, SV
sw1]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0, SV
sw1]
instance (SymVal d, SymVal c, SymVal b, HasKind a) => Uninterpreted (SBV d -> SBV c -> SBV b -> SBV a) where
sbvUninterpret :: Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
-> String -> SBV d -> SBV c -> SBV b -> SBV a
sbvUninterpret Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
mbCgData String
nm = SBV d -> SBV c -> SBV b -> SBV a
f
where f :: SBV d -> SBV c -> SBV b -> SBV a
f SBV d
arg0 SBV c
arg1 SBV b
arg2
| Just ([String]
_, SBV d -> SBV c -> SBV b -> SBV a
v) <- Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
mbCgData, SBV d -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV d
arg0, SBV c -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV c
arg1, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg2
= SBV d -> SBV c -> SBV b -> SBV a
v SBV d
arg0 SBV c
arg1 SBV b
arg2
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
kc :: Kind
kc = Proxy c -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy c
forall k (t :: k). Proxy t
Proxy @c)
kd :: Kind
kd = Proxy d -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy d
forall k (t :: k). Proxy t
Proxy @d)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV d -> SBV c -> SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV d -> SBV c -> SBV b -> SBV a
v SBV d
arg0 SBV c
arg1 SBV b
arg2)
(Bool, Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
kd, Kind
kc, Kind
kb, Kind
ka]) (([String], SBV d -> SBV c -> SBV b -> SBV a) -> [String]
forall a b. (a, b) -> a
fst (([String], SBV d -> SBV c -> SBV b -> SBV a) -> [String])
-> Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
-> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV d -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV d
arg0
SV
sw1 <- State -> SBV c -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV c
arg1
SV
sw2 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg2
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0, SV
sw1, SV
sw2]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0, SV
sw1, SV
sw2]
instance (SymVal e, SymVal d, SymVal c, SymVal b, HasKind a) => Uninterpreted (SBV e -> SBV d -> SBV c -> SBV b -> SBV a) where
sbvUninterpret :: Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
sbvUninterpret Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData String
nm = SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f
where f :: SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV e
arg0 SBV d
arg1 SBV c
arg2 SBV b
arg3
| Just ([String]
_, SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v) <- Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData, SBV e -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV e
arg0, SBV d -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV d
arg1, SBV c -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV c
arg2, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg3
= SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV e
arg0 SBV d
arg1 SBV c
arg2 SBV b
arg3
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
kc :: Kind
kc = Proxy c -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy c
forall k (t :: k). Proxy t
Proxy @c)
kd :: Kind
kd = Proxy d -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy d
forall k (t :: k). Proxy t
Proxy @d)
ke :: Kind
ke = Proxy e -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy e
forall k (t :: k). Proxy t
Proxy @e)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV e
arg0 SBV d
arg1 SBV c
arg2 SBV b
arg3)
(Bool, Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
ke, Kind
kd, Kind
kc, Kind
kb, Kind
ka]) (([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a) -> [String]
forall a b. (a, b) -> a
fst (([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a) -> [String])
-> Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV e -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV e
arg0
SV
sw1 <- State -> SBV d -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV d
arg1
SV
sw2 <- State -> SBV c -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV c
arg2
SV
sw3 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg3
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0, SV
sw1, SV
sw2, SV
sw3]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0, SV
sw1, SV
sw2, SV
sw3]
instance (SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, HasKind a) => Uninterpreted (SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a) where
sbvUninterpret :: Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
sbvUninterpret Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData String
nm = SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f
where f :: SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV f
arg0 SBV e
arg1 SBV d
arg2 SBV c
arg3 SBV b
arg4
| Just ([String]
_, SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v) <- Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData, SBV f -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV f
arg0, SBV e -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV e
arg1, SBV d -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV d
arg2, SBV c -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV c
arg3, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg4
= SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV f
arg0 SBV e
arg1 SBV d
arg2 SBV c
arg3 SBV b
arg4
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
kc :: Kind
kc = Proxy c -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy c
forall k (t :: k). Proxy t
Proxy @c)
kd :: Kind
kd = Proxy d -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy d
forall k (t :: k). Proxy t
Proxy @d)
ke :: Kind
ke = Proxy e -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy e
forall k (t :: k). Proxy t
Proxy @e)
kf :: Kind
kf = Proxy f -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy f
forall k (t :: k). Proxy t
Proxy @f)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV f
arg0 SBV e
arg1 SBV d
arg2 SBV c
arg3 SBV b
arg4)
(Bool,
Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
kf, Kind
ke, Kind
kd, Kind
kc, Kind
kb, Kind
ka]) (([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> [String]
forall a b. (a, b) -> a
fst (([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> [String])
-> Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV f -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV f
arg0
SV
sw1 <- State -> SBV e -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV e
arg1
SV
sw2 <- State -> SBV d -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV d
arg2
SV
sw3 <- State -> SBV c -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV c
arg3
SV
sw4 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg4
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0, SV
sw1, SV
sw2, SV
sw3, SV
sw4]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0, SV
sw1, SV
sw2, SV
sw3, SV
sw4]
instance (SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, HasKind a) => Uninterpreted (SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a) where
sbvUninterpret :: Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String
-> SBV g
-> SBV f
-> SBV e
-> SBV d
-> SBV c
-> SBV b
-> SBV a
sbvUninterpret Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData String
nm = SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f
where f :: SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV g
arg0 SBV f
arg1 SBV e
arg2 SBV d
arg3 SBV c
arg4 SBV b
arg5
| Just ([String]
_, SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v) <- Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData, SBV g -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV g
arg0, SBV f -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV f
arg1, SBV e -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV e
arg2, SBV d -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV d
arg3, SBV c -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV c
arg4, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg5
= SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV g
arg0 SBV f
arg1 SBV e
arg2 SBV d
arg3 SBV c
arg4 SBV b
arg5
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
kc :: Kind
kc = Proxy c -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy c
forall k (t :: k). Proxy t
Proxy @c)
kd :: Kind
kd = Proxy d -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy d
forall k (t :: k). Proxy t
Proxy @d)
ke :: Kind
ke = Proxy e -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy e
forall k (t :: k). Proxy t
Proxy @e)
kf :: Kind
kf = Proxy f -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy f
forall k (t :: k). Proxy t
Proxy @f)
kg :: Kind
kg = Proxy g -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy g
forall k (t :: k). Proxy t
Proxy @g)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV g
arg0 SBV f
arg1 SBV e
arg2 SBV d
arg3 SBV c
arg4 SBV b
arg5)
(Bool,
Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
kg, Kind
kf, Kind
ke, Kind
kd, Kind
kc, Kind
kb, Kind
ka]) (([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> [String]
forall a b. (a, b) -> a
fst (([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> [String])
-> Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV g -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV g
arg0
SV
sw1 <- State -> SBV f -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV f
arg1
SV
sw2 <- State -> SBV e -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV e
arg2
SV
sw3 <- State -> SBV d -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV d
arg3
SV
sw4 <- State -> SBV c -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV c
arg4
SV
sw5 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg5
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0, SV
sw1, SV
sw2, SV
sw3, SV
sw4, SV
sw5]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0, SV
sw1, SV
sw2, SV
sw3, SV
sw4, SV
sw5]
instance (SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, HasKind a)
=> Uninterpreted (SBV h -> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a) where
sbvUninterpret :: Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String
-> SBV h
-> SBV g
-> SBV f
-> SBV e
-> SBV d
-> SBV c
-> SBV b
-> SBV a
sbvUninterpret Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData String
nm = SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f
where f :: SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV h
arg0 SBV g
arg1 SBV f
arg2 SBV e
arg3 SBV d
arg4 SBV c
arg5 SBV b
arg6
| Just ([String]
_, SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v) <- Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData, SBV h -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV h
arg0, SBV g -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV g
arg1, SBV f -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV f
arg2, SBV e -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV e
arg3, SBV d -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV d
arg4, SBV c -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV c
arg5, SBV b -> Bool
forall a. SymVal a => SBV a -> Bool
isConcrete SBV b
arg6
= SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV h
arg0 SBV g
arg1 SBV f
arg2 SBV e
arg3 SBV d
arg4 SBV c
arg5 SBV b
arg6
| Bool
True
= SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
ka (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
result
where ka :: Kind
ka = Proxy a -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
kb :: Kind
kb = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
kc :: Kind
kc = Proxy c -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy c
forall k (t :: k). Proxy t
Proxy @c)
kd :: Kind
kd = Proxy d -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy d
forall k (t :: k). Proxy t
Proxy @d)
ke :: Kind
ke = Proxy e -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy e
forall k (t :: k). Proxy t
Proxy @e)
kf :: Kind
kf = Proxy f -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy f
forall k (t :: k). Proxy t
Proxy @f)
kg :: Kind
kg = Proxy g -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy g
forall k (t :: k). Proxy t
Proxy @g)
kh :: Kind
kh = Proxy h -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy h
forall k (t :: k). Proxy t
Proxy @h)
result :: State -> IO SV
result State
st = do Bool
isSMT <- State -> IO Bool
inSMTMode State
st
case (Bool
isSMT, Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData) of
(Bool
True, Just ([String]
_, SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v)) -> State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st (SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
v SBV h
arg0 SBV g
arg1 SBV f
arg2 SBV e
arg3 SBV d
arg4 SBV c
arg5 SBV b
arg6)
(Bool,
Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
_ -> do State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm ([Kind] -> SBVType
SBVType [Kind
kh, Kind
kg, Kind
kf, Kind
ke, Kind
kd, Kind
kc, Kind
kb, Kind
ka]) (([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> [String]
forall a b. (a, b) -> a
fst (([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> [String])
-> Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
mbCgData)
SV
sw0 <- State -> SBV h -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV h
arg0
SV
sw1 <- State -> SBV g -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV g
arg1
SV
sw2 <- State -> SBV f -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV f
arg2
SV
sw3 <- State -> SBV e -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV e
arg3
SV
sw4 <- State -> SBV d -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV d
arg4
SV
sw5 <- State -> SBV c -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV c
arg5
SV
sw6 <- State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
arg6
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV
sw0, SV
sw1, SV
sw2, SV
sw3, SV
sw4, SV
sw5, SV
sw6]
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
ka (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV
sw0, SV
sw1, SV
sw2, SV
sw3, SV
sw4, SV
sw5, SV
sw6]
instance (SymVal c, SymVal b, HasKind a) => Uninterpreted ((SBV c, SBV b) -> SBV a) where
sbvUninterpret :: Maybe ([String], (SBV c, SBV b) -> SBV a)
-> String -> (SBV c, SBV b) -> SBV a
sbvUninterpret Maybe ([String], (SBV c, SBV b) -> SBV a)
mbCgData String
nm = let f :: SBV c -> SBV b -> SBV a
f = Maybe ([String], SBV c -> SBV b -> SBV a)
-> String -> SBV c -> SBV b -> SBV a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String], (SBV c, SBV b) -> SBV a)
-> ([String], SBV c -> SBV b -> SBV a)
forall a a b c. (a, (a, b) -> c) -> (a, a -> b -> c)
uc2 (([String], (SBV c, SBV b) -> SBV a)
-> ([String], SBV c -> SBV b -> SBV a))
-> Maybe ([String], (SBV c, SBV b) -> SBV a)
-> Maybe ([String], SBV c -> SBV b -> SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], (SBV c, SBV b) -> SBV a)
mbCgData) String
nm in (SBV c -> SBV b -> SBV a) -> (SBV c, SBV b) -> SBV a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry SBV c -> SBV b -> SBV a
f
where uc2 :: (a, (a, b) -> c) -> (a, a -> b -> c)
uc2 (a
cs, (a, b) -> c
fn) = (a
cs, ((a, b) -> c) -> a -> b -> c
forall a b c. ((a, b) -> c) -> a -> b -> c
curry (a, b) -> c
fn)
instance (SymVal d, SymVal c, SymVal b, HasKind a) => Uninterpreted ((SBV d, SBV c, SBV b) -> SBV a) where
sbvUninterpret :: Maybe ([String], (SBV d, SBV c, SBV b) -> SBV a)
-> String -> (SBV d, SBV c, SBV b) -> SBV a
sbvUninterpret Maybe ([String], (SBV d, SBV c, SBV b) -> SBV a)
mbCgData String
nm = let f :: SBV d -> SBV c -> SBV b -> SBV a
f = Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
-> String -> SBV d -> SBV c -> SBV b -> SBV a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String], (SBV d, SBV c, SBV b) -> SBV a)
-> ([String], SBV d -> SBV c -> SBV b -> SBV a)
forall a a b c t. (a, (a, b, c) -> t) -> (a, a -> b -> c -> t)
uc3 (([String], (SBV d, SBV c, SBV b) -> SBV a)
-> ([String], SBV d -> SBV c -> SBV b -> SBV a))
-> Maybe ([String], (SBV d, SBV c, SBV b) -> SBV a)
-> Maybe ([String], SBV d -> SBV c -> SBV b -> SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], (SBV d, SBV c, SBV b) -> SBV a)
mbCgData) String
nm in \(SBV d
arg0, SBV c
arg1, SBV b
arg2) -> SBV d -> SBV c -> SBV b -> SBV a
f SBV d
arg0 SBV c
arg1 SBV b
arg2
where uc3 :: (a, (a, b, c) -> t) -> (a, a -> b -> c -> t)
uc3 (a
cs, (a, b, c) -> t
fn) = (a
cs, \a
a b
b c
c -> (a, b, c) -> t
fn (a
a, b
b, c
c))
instance (SymVal e, SymVal d, SymVal c, SymVal b, HasKind a)
=> Uninterpreted ((SBV e, SBV d, SBV c, SBV b) -> SBV a) where
sbvUninterpret :: Maybe ([String], (SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> String -> (SBV e, SBV d, SBV c, SBV b) -> SBV a
sbvUninterpret Maybe ([String], (SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData String
nm = let f :: SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f = Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String], (SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall a a b c d t.
(a, (a, b, c, d) -> t) -> (a, a -> b -> c -> d -> t)
uc4 (([String], (SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
-> Maybe ([String], (SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> Maybe ([String], SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], (SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData) String
nm in \(SBV e
arg0, SBV d
arg1, SBV c
arg2, SBV b
arg3) -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV e
arg0 SBV d
arg1 SBV c
arg2 SBV b
arg3
where uc4 :: (a, (a, b, c, d) -> t) -> (a, a -> b -> c -> d -> t)
uc4 (a
cs, (a, b, c, d) -> t
fn) = (a
cs, \a
a b
b c
c d
d -> (a, b, c, d) -> t
fn (a
a, b
b, c
c, d
d))
instance (SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, HasKind a)
=> Uninterpreted ((SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where
sbvUninterpret :: Maybe ([String], (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> String -> (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a
sbvUninterpret Maybe ([String], (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData String
nm = let f :: SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f = Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String], (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall a a b c d e t.
(a, (a, b, c, d, e) -> t) -> (a, a -> b -> c -> d -> e -> t)
uc5 (([String], (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
-> Maybe ([String], (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> Maybe
([String], SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe ([String], (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData) String
nm in \(SBV f
arg0, SBV e
arg1, SBV d
arg2, SBV c
arg3, SBV b
arg4) -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV f
arg0 SBV e
arg1 SBV d
arg2 SBV c
arg3 SBV b
arg4
where uc5 :: (a, (a, b, c, d, e) -> t) -> (a, a -> b -> c -> d -> e -> t)
uc5 (a
cs, (a, b, c, d, e) -> t
fn) = (a
cs, \a
a b
b c
c d
d e
e -> (a, b, c, d, e) -> t
fn (a
a, b
b, c
c, d
d, e
e))
instance (SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, HasKind a)
=> Uninterpreted ((SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where
sbvUninterpret :: Maybe
([String], (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> String -> (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a
sbvUninterpret Maybe
([String], (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData String
nm = let f :: SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f = Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String
-> SBV g
-> SBV f
-> SBV e
-> SBV d
-> SBV c
-> SBV b
-> SBV a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String], (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall a a b c d e f t.
(a, (a, b, c, d, e, f) -> t)
-> (a, a -> b -> c -> d -> e -> f -> t)
uc6 (([String], (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
-> Maybe
([String], (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> Maybe
([String],
SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe
([String], (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData) String
nm in \(SBV g
arg0, SBV f
arg1, SBV e
arg2, SBV d
arg3, SBV c
arg4, SBV b
arg5) -> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV g
arg0 SBV f
arg1 SBV e
arg2 SBV d
arg3 SBV c
arg4 SBV b
arg5
where uc6 :: (a, (a, b, c, d, e, f) -> t)
-> (a, a -> b -> c -> d -> e -> f -> t)
uc6 (a
cs, (a, b, c, d, e, f) -> t
fn) = (a
cs, \a
a b
b c
c d
d e
e f
f -> (a, b, c, d, e, f) -> t
fn (a
a, b
b, c
c, d
d, e
e, f
f))
instance (SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, HasKind a)
=> Uninterpreted ((SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where
sbvUninterpret :: Maybe
([String],
(SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> String
-> (SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b)
-> SBV a
sbvUninterpret Maybe
([String],
(SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData String
nm = let f :: SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f = Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
-> String
-> SBV h
-> SBV g
-> SBV f
-> SBV e
-> SBV d
-> SBV c
-> SBV b
-> SBV a
forall a. Uninterpreted a => Maybe ([String], a) -> String -> a
sbvUninterpret (([String],
(SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall a a b c d e f g t.
(a, (a, b, c, d, e, f, g) -> t)
-> (a, a -> b -> c -> d -> e -> f -> g -> t)
uc7 (([String],
(SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> ([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a))
-> Maybe
([String],
(SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
-> Maybe
([String],
SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe
([String],
(SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a)
mbCgData) String
nm in \(SBV h
arg0, SBV g
arg1, SBV f
arg2, SBV e
arg3, SBV d
arg4, SBV c
arg5, SBV b
arg6) -> SBV h
-> SBV g -> SBV f -> SBV e -> SBV d -> SBV c -> SBV b -> SBV a
f SBV h
arg0 SBV g
arg1 SBV f
arg2 SBV e
arg3 SBV d
arg4 SBV c
arg5 SBV b
arg6
where uc7 :: (a, (a, b, c, d, e, f, g) -> t)
-> (a, a -> b -> c -> d -> e -> f -> g -> t)
uc7 (a
cs, (a, b, c, d, e, f, g) -> t
fn) = (a
cs, \a
a b
b c
c d
d e
e f
f g
g -> (a, b, c, d, e, f, g) -> t
fn (a
a, b
b, c
c, d
d, e
e, f
f, g
g))
instance MonadIO m => SolverContext (SymbolicT m) where
constrain :: SBV Bool -> SymbolicT m ()
constrain (SBV SVal
c) = Bool -> [(String, String)] -> SVal -> SymbolicT m ()
forall (m :: * -> *).
MonadSymbolic m =>
Bool -> [(String, String)] -> SVal -> m ()
imposeConstraint Bool
False [] SVal
c
softConstrain :: SBV Bool -> SymbolicT m ()
softConstrain (SBV SVal
c) = Bool -> [(String, String)] -> SVal -> SymbolicT m ()
forall (m :: * -> *).
MonadSymbolic m =>
Bool -> [(String, String)] -> SVal -> m ()
imposeConstraint Bool
True [] SVal
c
namedConstraint :: String -> SBV Bool -> SymbolicT m ()
namedConstraint String
nm (SBV SVal
c) = Bool -> [(String, String)] -> SVal -> SymbolicT m ()
forall (m :: * -> *).
MonadSymbolic m =>
Bool -> [(String, String)] -> SVal -> m ()
imposeConstraint Bool
False [(String
":named", String
nm)] SVal
c
constrainWithAttribute :: [(String, String)] -> SBV Bool -> SymbolicT m ()
constrainWithAttribute [(String, String)]
atts (SBV SVal
c) = Bool -> [(String, String)] -> SVal -> SymbolicT m ()
forall (m :: * -> *).
MonadSymbolic m =>
Bool -> [(String, String)] -> SVal -> m ()
imposeConstraint Bool
False [(String, String)]
atts SVal
c
addAxiom :: String -> [String] -> SymbolicT m ()
addAxiom = String -> [String] -> SymbolicT m ()
forall (m :: * -> *).
(SolverContext m, MonadIO m) =>
String -> [String] -> m ()
addSymAxiom
contextState :: SymbolicT m State
contextState = SymbolicT m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
setOption :: SMTOption -> SymbolicT m ()
setOption SMTOption
o = SMTOption -> SymbolicT m ()
forall (m :: * -> *). MonadSymbolic m => SMTOption -> m ()
addNewSMTOption SMTOption
o
addSymAxiom :: (SolverContext m, MonadIO m) => String -> [String] -> m ()
addSymAxiom :: String -> [String] -> m ()
addSymAxiom String
nm [String]
ax = do
State
st <- m State
forall (m :: * -> *). SolverContext m => m State
contextState
IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ State
-> (State -> IORef [(String, [String])])
-> ([(String, [String])] -> [(String, [String])])
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [(String, [String])]
raxioms ((String
nm, [String]
ax) (String, [String]) -> [(String, [String])] -> [(String, [String])]
forall a. a -> [a] -> [a]
:) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
assertWithPenalty :: MonadSymbolic m => String -> SBool -> Penalty -> m ()
assertWithPenalty :: String -> SBV Bool -> Penalty -> m ()
assertWithPenalty String
nm SBV Bool
o Penalty
p = Objective SVal -> m ()
forall (m :: * -> *). MonadSymbolic m => Objective SVal -> m ()
addSValOptGoal (Objective SVal -> m ()) -> Objective SVal -> m ()
forall a b. (a -> b) -> a -> b
$ SBV Bool -> SVal
forall a. SBV a -> SVal
unSBV (SBV Bool -> SVal) -> Objective (SBV Bool) -> Objective SVal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` String -> SBV Bool -> Penalty -> Objective (SBV Bool)
forall a. String -> a -> Penalty -> Objective a
AssertWithPenalty String
nm SBV Bool
o Penalty
p
class Metric a where
type MetricSpace a :: Type
type MetricSpace a = a
toMetricSpace :: SBV a -> SBV (MetricSpace a)
fromMetricSpace :: SBV (MetricSpace a) -> SBV a
msMinimize :: (MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()
msMinimize String
nm SBV a
o = Objective SVal -> m ()
forall (m :: * -> *). MonadSymbolic m => Objective SVal -> m ()
addSValOptGoal (Objective SVal -> m ()) -> Objective SVal -> m ()
forall a b. (a -> b) -> a -> b
$ SBV (MetricSpace a) -> SVal
forall a. SBV a -> SVal
unSBV (SBV (MetricSpace a) -> SVal)
-> Objective (SBV (MetricSpace a)) -> Objective SVal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` String -> SBV (MetricSpace a) -> Objective (SBV (MetricSpace a))
forall a. String -> a -> Objective a
Minimize String
nm (SBV a -> SBV (MetricSpace a)
forall a. Metric a => SBV a -> SBV (MetricSpace a)
toMetricSpace SBV a
o)
msMaximize :: (MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()
msMaximize String
nm SBV a
o = Objective SVal -> m ()
forall (m :: * -> *). MonadSymbolic m => Objective SVal -> m ()
addSValOptGoal (Objective SVal -> m ()) -> Objective SVal -> m ()
forall a b. (a -> b) -> a -> b
$ SBV (MetricSpace a) -> SVal
forall a. SBV a -> SVal
unSBV (SBV (MetricSpace a) -> SVal)
-> Objective (SBV (MetricSpace a)) -> Objective SVal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` String -> SBV (MetricSpace a) -> Objective (SBV (MetricSpace a))
forall a. String -> a -> Objective a
Maximize String
nm (SBV a -> SBV (MetricSpace a)
forall a. Metric a => SBV a -> SBV (MetricSpace a)
toMetricSpace SBV a
o)
default toMetricSpace :: (a ~ MetricSpace a) => SBV a -> SBV (MetricSpace a)
toMetricSpace = SBV a -> SBV (MetricSpace a)
forall a. a -> a
id
default fromMetricSpace :: (a ~ MetricSpace a) => SBV (MetricSpace a) -> SBV a
fromMetricSpace = SBV (MetricSpace a) -> SBV a
forall a. a -> a
id
instance Metric Bool where
type MetricSpace Bool = Word8
toMetricSpace :: SBV Bool -> SBV (MetricSpace Bool)
toMetricSpace SBV Bool
t = SBV Bool -> SBV Word8 -> SBV Word8 -> SBV Word8
forall a. Mergeable a => SBV Bool -> a -> a -> a
ite SBV Bool
t SBV Word8
1 SBV Word8
0
fromMetricSpace :: SBV (MetricSpace Bool) -> SBV Bool
fromMetricSpace SBV (MetricSpace Bool)
w = SBV Word8
SBV (MetricSpace Bool)
w SBV Word8 -> SBV Word8 -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
./= SBV Word8
0
minimize :: (Metric a, MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()
minimize :: String -> SBV a -> m ()
minimize = String -> SBV a -> m ()
forall a (m :: * -> *).
(Metric a, MonadSymbolic m, SolverContext m) =>
String -> SBV a -> m ()
msMinimize
maximize :: (Metric a, MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()
maximize :: String -> SBV a -> m ()
maximize = String -> SBV a -> m ()
forall a (m :: * -> *).
(Metric a, MonadSymbolic m, SolverContext m) =>
String -> SBV a -> m ()
msMaximize
instance Metric Word8
instance Metric Word16
instance Metric Word32
instance Metric Word64
instance Metric Integer
instance Metric AlgReal
instance Metric Int8 where
type MetricSpace Int8 = Word8
toMetricSpace :: SBV Int8 -> SBV (MetricSpace Int8)
toMetricSpace SBV Int8
x = SBV Int8 -> SBV Word8
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Int8
x SBV Word8 -> SBV Word8 -> SBV Word8
forall a. Num a => a -> a -> a
+ SBV Word8
128
fromMetricSpace :: SBV (MetricSpace Int8) -> SBV Int8
fromMetricSpace SBV (MetricSpace Int8)
x = SBV Word8 -> SBV Int8
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Word8
SBV (MetricSpace Int8)
x SBV Int8 -> SBV Int8 -> SBV Int8
forall a. Num a => a -> a -> a
- SBV Int8
128
instance Metric Int16 where
type MetricSpace Int16 = Word16
toMetricSpace :: SBV Int16 -> SBV (MetricSpace Int16)
toMetricSpace SBV Int16
x = SBV Int16 -> SBV Word16
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Int16
x SBV Word16 -> SBV Word16 -> SBV Word16
forall a. Num a => a -> a -> a
+ SBV Word16
32768
fromMetricSpace :: SBV (MetricSpace Int16) -> SBV Int16
fromMetricSpace SBV (MetricSpace Int16)
x = SBV Word16 -> SBV Int16
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Word16
SBV (MetricSpace Int16)
x SBV Int16 -> SBV Int16 -> SBV Int16
forall a. Num a => a -> a -> a
- SBV Int16
32768
instance Metric Int32 where
type MetricSpace Int32 = Word32
toMetricSpace :: SBV Int32 -> SBV (MetricSpace Int32)
toMetricSpace SBV Int32
x = SBV Int32 -> SBV Word32
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Int32
x SBV Word32 -> SBV Word32 -> SBV Word32
forall a. Num a => a -> a -> a
+ SBV Word32
2147483648
fromMetricSpace :: SBV (MetricSpace Int32) -> SBV Int32
fromMetricSpace SBV (MetricSpace Int32)
x = SBV Word32 -> SBV Int32
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Word32
SBV (MetricSpace Int32)
x SBV Int32 -> SBV Int32 -> SBV Int32
forall a. Num a => a -> a -> a
- SBV Int32
2147483648
instance Metric Int64 where
type MetricSpace Int64 = Word64
toMetricSpace :: SBV Int64 -> SBV (MetricSpace Int64)
toMetricSpace SBV Int64
x = SBV Int64 -> SBV Word64
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Int64
x SBV Word64 -> SBV Word64 -> SBV Word64
forall a. Num a => a -> a -> a
+ SBV Word64
9223372036854775808
fromMetricSpace :: SBV (MetricSpace Int64) -> SBV Int64
fromMetricSpace SBV (MetricSpace Int64)
x = SBV Word64 -> SBV Int64
forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV Word64
SBV (MetricSpace Int64)
x SBV Int64 -> SBV Int64 -> SBV Int64
forall a. Num a => a -> a -> a
- SBV Int64
9223372036854775808
instance Testable SBool where
property :: SBV Bool -> Property
property (SBV (SVal Kind
_ (Left CV
b))) = Bool -> Property
forall prop. Testable prop => prop -> Property
property (CV -> Bool
cvToBool CV
b)
property SBV Bool
_ = String -> Property
forall a. HasCallStack => String -> a
error String
"Quick-check: Constant folding produced a symbolic value! Perhaps used a non-reducible expression? Please report!"
instance Testable (Symbolic SBool) where
property :: Symbolic (SBV Bool) -> Property
property Symbolic (SBV Bool)
prop = PropertyM IO () -> Property
forall a. Testable a => PropertyM IO a -> Property
QC.monadicIO (PropertyM IO () -> Property) -> PropertyM IO () -> Property
forall a b. (a -> b) -> a -> b
$ do (Bool
cond, Bool
r, [(String, CV)]
modelVals) <- IO (Bool, Bool, [(String, CV)])
-> PropertyM IO (Bool, Bool, [(String, CV)])
forall (m :: * -> *) a. Monad m => m a -> PropertyM m a
QC.run IO (Bool, Bool, [(String, CV)])
test
Bool -> PropertyM IO ()
forall (m :: * -> *). Monad m => Bool -> PropertyM m ()
QC.pre Bool
cond
Bool -> PropertyM IO () -> PropertyM IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Bool
r Bool -> Bool -> Bool
|| [(String, CV)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(String, CV)]
modelVals) (PropertyM IO () -> PropertyM IO ())
-> PropertyM IO () -> PropertyM IO ()
forall a b. (a -> b) -> a -> b
$ (Property -> Property) -> PropertyM IO ()
forall (m :: * -> *).
Monad m =>
(Property -> Property) -> PropertyM m ()
QC.monitor (String -> Property -> Property
forall prop. Testable prop => String -> prop -> Property
QC.counterexample ([(String, CV)] -> String
complain [(String, CV)]
modelVals))
Bool -> PropertyM IO ()
forall (m :: * -> *). Monad m => Bool -> PropertyM m ()
QC.assert Bool
r
where test :: IO (Bool, Bool, [(String, CV)])
test = do (SBV Bool
r, Result{resTraces :: Result -> [(String, CV)]
resTraces=[(String, CV)]
tvals, resObservables :: Result -> [(String, CV -> Bool, SV)]
resObservables=[(String, CV -> Bool, SV)]
ovals, resConsts :: Result -> (CnstMap, [(SV, CV)])
resConsts=(CnstMap
_, [(SV, CV)]
cs), resConstraints :: Result -> Seq (Bool, [(String, String)], SV)
resConstraints=Seq (Bool, [(String, String)], SV)
cstrs, resUIConsts :: Result -> [(String, SBVType)]
resUIConsts=[(String, SBVType)]
unints}) <- SBVRunMode -> Symbolic (SBV Bool) -> IO (SBV Bool, Result)
forall (m :: * -> *) a.
MonadIO m =>
SBVRunMode -> SymbolicT m a -> m (a, Result)
runSymbolic (Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)]) -> SBVRunMode
Concrete Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)])
forall a. Maybe a
Nothing) Symbolic (SBV Bool)
prop
let cval :: SV -> CV
cval = CV -> Maybe CV -> CV
forall a. a -> Maybe a -> a
fromMaybe (String -> CV
forall a. HasCallStack => String -> a
error String
"Cannot quick-check in the presence of uninterpeted constants!") (Maybe CV -> CV) -> (SV -> Maybe CV) -> SV -> CV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SV -> [(SV, CV)] -> Maybe CV
forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup` [(SV, CV)]
cs)
cond :: Bool
cond = [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and [CV -> Bool
cvToBool (SV -> CV
cval SV
v) | (Bool
False, [(String, String)]
_, SV
v) <- Seq (Bool, [(String, String)], SV)
-> [(Bool, [(String, String)], SV)]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList Seq (Bool, [(String, String)], SV)
cstrs]
getObservable :: (String, CV -> Bool, SV) -> Maybe (String, CV)
getObservable (String
nm, CV -> Bool
f, SV
v) = case SV
v SV -> [(SV, CV)] -> Maybe CV
forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup` [(SV, CV)]
cs of
Just CV
cv -> if CV -> Bool
f CV
cv then (String, CV) -> Maybe (String, CV)
forall a. a -> Maybe a
Just (String
nm, CV
cv) else Maybe (String, CV)
forall a. Maybe a
Nothing
Maybe CV
Nothing -> String -> Maybe (String, CV)
forall a. HasCallStack => String -> a
error (String -> Maybe (String, CV)) -> String -> Maybe (String, CV)
forall a b. (a -> b) -> a -> b
$ String
"Quick-check: Observable " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" did not reduce to a constant!"
case ((String, SBVType) -> String) -> [(String, SBVType)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, SBVType) -> String
forall a b. (a, b) -> a
fst [(String, SBVType)]
unints of
[] -> case SBV Bool -> Maybe Bool
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Bool
r of
Maybe Bool
Nothing -> String -> IO (Bool, Bool, [(String, CV)])
forall a. HasCallStack => String -> a
error (String -> IO (Bool, Bool, [(String, CV)]))
-> String -> IO (Bool, Bool, [(String, CV)])
forall a b. (a -> b) -> a -> b
$ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"\n" [ String
"Quick-check: Calls to 'observe' not supported in quick-check mode. Please use 'sObserve' for full support."
, String
" (If you haven't used 'observe', please report this as a bug!)"
]
Just Bool
b -> (Bool, Bool, [(String, CV)]) -> IO (Bool, Bool, [(String, CV)])
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
cond, Bool
b, [(String, CV)]
tvals [(String, CV)] -> [(String, CV)] -> [(String, CV)]
forall a. [a] -> [a] -> [a]
++ ((String, CV -> Bool, SV) -> Maybe (String, CV))
-> [(String, CV -> Bool, SV)] -> [(String, CV)]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (String, CV -> Bool, SV) -> Maybe (String, CV)
getObservable [(String, CV -> Bool, SV)]
ovals)
[String]
us -> String -> IO (Bool, Bool, [(String, CV)])
forall a. HasCallStack => String -> a
error (String -> IO (Bool, Bool, [(String, CV)]))
-> String -> IO (Bool, Bool, [(String, CV)])
forall a b. (a -> b) -> a -> b
$ String
"Cannot quick-check in the presence of uninterpreted constants: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " [String]
us
complain :: [(String, CV)] -> String
complain [(String, CV)]
qcInfo = SMTConfig -> SMTModel -> String
showModel SMTConfig
defaultSMTCfg ([(String, GeneralizedCV)]
-> Maybe [((Quantifier, NamedSymVar), Maybe CV)]
-> [(String, CV)]
-> [(String, (SBVType, ([([CV], CV)], CV)))]
-> SMTModel
SMTModel [] Maybe [((Quantifier, NamedSymVar), Maybe CV)]
forall a. Maybe a
Nothing [(String, CV)]
qcInfo [])
sbvQuickCheck :: Symbolic SBool -> IO Bool
sbvQuickCheck :: Symbolic (SBV Bool) -> IO Bool
sbvQuickCheck Symbolic (SBV Bool)
prop = Result -> Bool
QC.isSuccess (Result -> Bool) -> IO Result -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Symbolic (SBV Bool) -> IO Result
forall prop. Testable prop => prop -> IO Result
QC.quickCheckResult Symbolic (SBV Bool)
prop
instance Testable (Symbolic SVal) where
property :: Symbolic SVal -> Property
property Symbolic SVal
m = Symbolic (SBV Bool) -> Property
forall prop. Testable prop => prop -> Property
property (Symbolic (SBV Bool) -> Property)
-> Symbolic (SBV Bool) -> Property
forall a b. (a -> b) -> a -> b
$ do SVal
s <- Symbolic SVal
m
Bool -> Symbolic () -> Symbolic ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SVal -> Kind
forall a. HasKind a => a -> Kind
kindOf SVal
s Kind -> Kind -> Bool
forall a. Eq a => a -> a -> Bool
/= Kind
KBool) (Symbolic () -> Symbolic ()) -> Symbolic () -> Symbolic ()
forall a b. (a -> b) -> a -> b
$ String -> Symbolic ()
forall a. HasCallStack => String -> a
error String
"Cannot quickcheck non-boolean value"
SBV Bool -> Symbolic (SBV Bool)
forall (m :: * -> *) a. Monad m => a -> m a
return (SVal -> SBV Bool
forall a. SVal -> SBV a
SBV SVal
s :: SBool)
slet :: forall a b. (HasKind a, HasKind b) => SBV a -> (SBV a -> SBV b) -> SBV b
slet :: SBV a -> (SBV a -> SBV b) -> SBV b
slet SBV a
x SBV a -> SBV b
f = SVal -> SBV b
forall a. SVal -> SBV a
SBV (SVal -> SBV b) -> SVal -> SBV b
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (Either CV (Cached SV) -> SVal) -> Either CV (Cached SV) -> SVal
forall a b. (a -> b) -> a -> b
$ Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right (Cached SV -> Either CV (Cached SV))
-> Cached SV -> Either CV (Cached SV)
forall a b. (a -> b) -> a -> b
$ (State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = Proxy b -> Kind
forall a. HasKind a => a -> Kind
kindOf (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
r :: State -> IO SV
r State
st = do SV
xsv <- State -> SBV a -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
x
let xsbv :: SBV a
xsbv = SVal -> SBV a
forall a. SVal -> SBV a
SBV (SVal -> SBV a) -> SVal -> SBV a
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal (SBV a -> Kind
forall a. HasKind a => a -> Kind
kindOf SBV a
x) (Cached SV -> Either CV (Cached SV)
forall a b. b -> Either a b
Right ((State -> IO SV) -> Cached SV
forall a. (State -> IO a) -> Cached a
cache (IO SV -> State -> IO SV
forall a b. a -> b -> a
const (SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
xsv))))
res :: SBV b
res = SBV a -> SBV b
f SBV a
xsbv
State -> SBV b -> IO SV
forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV b
res
infix 4 ===
class Equality a where
(===) :: a -> a -> IO ThmResult
instance {-# OVERLAPPABLE #-} (SymVal a, EqSymbolic z) => Equality (SBV a -> z) where
SBV a -> z
k === :: (SBV a -> z) -> (SBV a -> z) -> IO ThmResult
=== SBV a -> z
l = (SBV a -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a -> SBV a -> z
k SBV a
a z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> z
l SBV a
a
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, EqSymbolic z) => Equality (SBV a -> SBV b -> z) where
SBV a -> SBV b -> z
k === :: (SBV a -> SBV b -> z) -> (SBV a -> SBV b -> z) -> IO ThmResult
=== SBV a -> SBV b -> z
l = (SBV a -> SBV b -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV b -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b -> SBV a -> SBV b -> z
k SBV a
a SBV b
b z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV b -> z
l SBV a
a SBV b
b
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, EqSymbolic z) => Equality ((SBV a, SBV b) -> z) where
(SBV a, SBV b) -> z
k === :: ((SBV a, SBV b) -> z) -> ((SBV a, SBV b) -> z) -> IO ThmResult
=== (SBV a, SBV b) -> z
l = (SBV a -> SBV b -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV b -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b -> (SBV a, SBV b) -> z
k (SBV a
a, SBV b
b) z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (SBV a, SBV b) -> z
l (SBV a
a, SBV b
b)
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> z) where
SBV a -> SBV b -> SBV c -> z
k === :: (SBV a -> SBV b -> SBV c -> z)
-> (SBV a -> SBV b -> SBV c -> z) -> IO ThmResult
=== SBV a -> SBV b -> SBV c -> z
l = (SBV a -> SBV b -> SBV c -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c -> SBV a -> SBV b -> SBV c -> z
k SBV a
a SBV b
b SBV c
c z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV b -> SBV c -> z
l SBV a
a SBV b
b SBV c
c
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c) -> z) where
(SBV a, SBV b, SBV c) -> z
k === :: ((SBV a, SBV b, SBV c) -> z)
-> ((SBV a, SBV b, SBV c) -> z) -> IO ThmResult
=== (SBV a, SBV b, SBV c) -> z
l = (SBV a -> SBV b -> SBV c -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c -> (SBV a, SBV b, SBV c) -> z
k (SBV a
a, SBV b
b, SBV c
c) z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (SBV a, SBV b, SBV c) -> z
l (SBV a
a, SBV b
b, SBV c
c)
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> z) where
SBV a -> SBV b -> SBV c -> SBV d -> z
k === :: (SBV a -> SBV b -> SBV c -> SBV d -> z)
-> (SBV a -> SBV b -> SBV c -> SBV d -> z) -> IO ThmResult
=== SBV a -> SBV b -> SBV c -> SBV d -> z
l = (SBV a -> SBV b -> SBV c -> SBV d -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV d -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d -> SBV a -> SBV b -> SBV c -> SBV d -> z
k SBV a
a SBV b
b SBV c
c SBV d
d z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV b -> SBV c -> SBV d -> z
l SBV a
a SBV b
b SBV c
c SBV d
d
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d) -> z) where
(SBV a, SBV b, SBV c, SBV d) -> z
k === :: ((SBV a, SBV b, SBV c, SBV d) -> z)
-> ((SBV a, SBV b, SBV c, SBV d) -> z) -> IO ThmResult
=== (SBV a, SBV b, SBV c, SBV d) -> z
l = (SBV a -> SBV b -> SBV c -> SBV d -> SBV Bool) -> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV d -> SBV Bool) -> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV Bool) -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d -> (SBV a, SBV b, SBV c, SBV d) -> z
k (SBV a
a, SBV b
b, SBV c
c, SBV d
d) z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (SBV a, SBV b, SBV c, SBV d) -> z
l (SBV a
a, SBV b
b, SBV c
c, SBV d
d)
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z) where
SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z
k === :: (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z) -> IO ThmResult
=== SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z
l = (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV Bool)
-> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV Bool)
-> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV Bool)
-> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e -> SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z
k SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z
l SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e) -> z) where
(SBV a, SBV b, SBV c, SBV d, SBV e) -> z
k === :: ((SBV a, SBV b, SBV c, SBV d, SBV e) -> z)
-> ((SBV a, SBV b, SBV c, SBV d, SBV e) -> z) -> IO ThmResult
=== (SBV a, SBV b, SBV c, SBV d, SBV e) -> z
l = (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV Bool)
-> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV Bool)
-> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV Bool)
-> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e -> (SBV a, SBV b, SBV c, SBV d, SBV e) -> z
k (SBV a
a, SBV b
b, SBV c
c, SBV d
d, SBV e
e) z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (SBV a, SBV b, SBV c, SBV d, SBV e) -> z
l (SBV a
a, SBV b
b, SBV c
c, SBV d
d, SBV e
e)
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z) where
SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z
k === :: (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z)
-> IO ThmResult
=== SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z
l = (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV Bool)
-> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV Bool)
-> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV Bool)
-> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f -> SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z
k SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z
l SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f
instance {-# OVERLAPPABLE #-}
(SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z) where
(SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z
k === :: ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z)
-> ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z)
-> IO ThmResult
=== (SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z
l = (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV Bool)
-> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV Bool)
-> IO ThmResult)
-> (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV Bool)
-> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f -> (SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z
k (SBV a
a, SBV b
b, SBV c
c, SBV d
d, SBV e
e, SBV f
f) z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z
l (SBV a
a, SBV b
b, SBV c
c, SBV d
d, SBV e
e, SBV f
f)
instance {-# OVERLAPPABLE #-}
(SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z) where
SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z
k === :: (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z)
-> (SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z)
-> IO ThmResult
=== SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z
l = (SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> SBV Bool)
-> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> SBV Bool)
-> IO ThmResult)
-> (SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> SBV Bool)
-> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f SBV g
g -> SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z
k SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f SBV g
g z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z
l SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f SBV g
g
instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z) where
(SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z
k === :: ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z)
-> ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z)
-> IO ThmResult
=== (SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z
l = (SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> SBV Bool)
-> IO ThmResult
forall (m :: * -> *) a. MProvable m a => a -> m ThmResult
prove ((SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> SBV Bool)
-> IO ThmResult)
-> (SBV a
-> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> SBV Bool)
-> IO ThmResult
forall a b. (a -> b) -> a -> b
$ \SBV a
a SBV b
b SBV c
c SBV d
d SBV e
e SBV f
f SBV g
g -> (SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z
k (SBV a
a, SBV b
b, SBV c
c, SBV d
d, SBV e
e, SBV f
f, SBV g
g) z -> z -> SBV Bool
forall a. EqSymbolic a => a -> a -> SBV Bool
.== (SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z
l (SBV a
a, SBV b
b, SBV c
c, SBV d
d, SBV e
e, SBV f
f, SBV g
g)
{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}
{-# ANN module ("HLint: ignore Eta reduce" :: String) #-}