{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wall -Werror -fno-warn-orphans #-}
module Data.SBV.Core.Symbolic
( NodeId(..)
, SV(..), swKind, trueSV, falseSV
, Op(..), PBOp(..), OvOp(..), FPOp(..), NROp(..), StrOp(..), SeqOp(..), SetOp(..)
, RegExp(..), regExpToSMTString
, Quantifier(..), needsExistentials, VarContext(..)
, RoundingMode(..)
, SBVType(..), svUninterpreted, newUninterpreted
, SVal(..)
, svMkSymVar, sWordN, sWordN_, sIntN, sIntN_
, ArrayContext(..), ArrayInfo
, svToSV, svToSymSV, forceSVArg
, SBVExpr(..), newExpr, isCodeGenMode, isSafetyCheckingIStage, isRunIStage, isSetupIStage
, Cached, cache, uncache, modifyState, modifyIncState
, ArrayIndex(..), FArrayIndex(..), uncacheAI, uncacheFAI
, NamedSymVar(..), Name, UserInputs, Inputs(..), getSV, swNodeId, namedNodeId, getUniversals
, prefixExistentials, prefixUniversals, onUserInputs, onInternInputs, onAllInputs
, addInternInput, addUserInput, getInputs, inputsFromListWith, userInputsToList
, getUserName', internInputsToList, inputsToList, quantifier, namedSymVar, getUserName
, lookupInput , getSValPathCondition, extendSValPathCondition
, getTableIndex
, SBVPgm(..), MonadSymbolic(..), SymbolicT, Symbolic, runSymbolic, State(..), withNewIncState, IncState(..), incrementInternalCounter
, inSMTMode, SBVRunMode(..), IStage(..), Result(..)
, registerKind, registerLabel, recordObservable
, addAssertion, addNewSMTOption, imposeConstraint, internalConstraint, internalVariable
, SMTLibPgm(..), SMTLibVersion(..), smtLibVersionExtension
, SolverCapabilities(..)
, extractSymbolicSimulationState, CnstMap
, OptimizeStyle(..), Objective(..), Penalty(..), objectiveName, addSValOptGoal
, MonadQuery(..), QueryT(..), Query, Queriable(..), Fresh(..), QueryState(..), QueryContext(..)
, SMTScript(..), Solver(..), SMTSolver(..), SMTResult(..), SMTModel(..), SMTConfig(..), SMTEngine
, validationRequested, outputSVal
) where
import Control.Arrow ((***))
import Control.DeepSeq (NFData(..))
import Control.Monad (when)
import Control.Monad.Except (MonadError, ExceptT)
import Control.Monad.Reader (MonadReader(..), ReaderT, runReaderT,
mapReaderT)
import Control.Monad.State.Lazy (MonadState)
import Control.Monad.Trans (MonadIO(liftIO), MonadTrans(lift))
import Control.Monad.Trans.Maybe (MaybeT)
import Control.Monad.Writer.Strict (MonadWriter)
import Data.Char (isAlpha, isAlphaNum, toLower)
import Data.IORef (IORef, newIORef, readIORef)
import Data.List (intercalate, sortBy)
import Data.Maybe (isJust, fromJust, fromMaybe)
import Data.String (IsString(fromString))
import Data.Time (getCurrentTime, UTCTime)
import GHC.Stack
import GHC.Generics (Generic)
import qualified Control.Monad.State.Lazy as LS
import qualified Control.Monad.State.Strict as SS
import qualified Control.Monad.Writer.Lazy as LW
import qualified Control.Monad.Writer.Strict as SW
import qualified Data.IORef as R (modifyIORef')
import qualified Data.Generics as G (Data(..))
import qualified Data.IntMap.Strict as IMap (IntMap, empty, toAscList, lookup, insertWith)
import qualified Data.Map.Strict as Map (Map, empty, toList, lookup, insert, size)
import qualified Data.Set as Set (Set, empty, toList, insert, member)
import qualified Data.Foldable as F (toList)
import qualified Data.Sequence as S (Seq, empty, (|>), (<|), filter, takeWhileL, fromList, lookup, elemIndexL)
import qualified Data.Text as T
import System.Mem.StableName
import Data.SBV.Core.Kind
import Data.SBV.Core.Concrete
import Data.SBV.SMT.SMTLibNames
import Data.SBV.Utils.TDiff (Timing)
import Data.SBV.Utils.Lib (stringToQFS)
import Data.SBV.Control.Types
#if MIN_VERSION_base(4,11,0)
import Control.Monad.Fail as Fail
#endif
newtype NodeId = NodeId { NodeId -> Int
getId :: Int }
deriving (NodeId -> NodeId -> Bool
(NodeId -> NodeId -> Bool)
-> (NodeId -> NodeId -> Bool) -> Eq NodeId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeId -> NodeId -> Bool
$c/= :: NodeId -> NodeId -> Bool
== :: NodeId -> NodeId -> Bool
$c== :: NodeId -> NodeId -> Bool
Eq, Eq NodeId
Eq NodeId
-> (NodeId -> NodeId -> Ordering)
-> (NodeId -> NodeId -> Bool)
-> (NodeId -> NodeId -> Bool)
-> (NodeId -> NodeId -> Bool)
-> (NodeId -> NodeId -> Bool)
-> (NodeId -> NodeId -> NodeId)
-> (NodeId -> NodeId -> NodeId)
-> Ord NodeId
NodeId -> NodeId -> Bool
NodeId -> NodeId -> Ordering
NodeId -> NodeId -> NodeId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NodeId -> NodeId -> NodeId
$cmin :: NodeId -> NodeId -> NodeId
max :: NodeId -> NodeId -> NodeId
$cmax :: NodeId -> NodeId -> NodeId
>= :: NodeId -> NodeId -> Bool
$c>= :: NodeId -> NodeId -> Bool
> :: NodeId -> NodeId -> Bool
$c> :: NodeId -> NodeId -> Bool
<= :: NodeId -> NodeId -> Bool
$c<= :: NodeId -> NodeId -> Bool
< :: NodeId -> NodeId -> Bool
$c< :: NodeId -> NodeId -> Bool
compare :: NodeId -> NodeId -> Ordering
$ccompare :: NodeId -> NodeId -> Ordering
$cp1Ord :: Eq NodeId
Ord, Typeable NodeId
DataType
Constr
Typeable NodeId
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NodeId -> c NodeId)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NodeId)
-> (NodeId -> Constr)
-> (NodeId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NodeId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NodeId))
-> ((forall b. Data b => b -> b) -> NodeId -> NodeId)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NodeId -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NodeId -> r)
-> (forall u. (forall d. Data d => d -> u) -> NodeId -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NodeId -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId)
-> Data NodeId
NodeId -> DataType
NodeId -> Constr
(forall b. Data b => b -> b) -> NodeId -> NodeId
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NodeId -> c NodeId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NodeId
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NodeId -> u
forall u. (forall d. Data d => d -> u) -> NodeId -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NodeId -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NodeId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NodeId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NodeId -> c NodeId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NodeId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NodeId)
$cNodeId :: Constr
$tNodeId :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NodeId -> m NodeId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId
gmapMp :: (forall d. Data d => d -> m d) -> NodeId -> m NodeId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId
gmapM :: (forall d. Data d => d -> m d) -> NodeId -> m NodeId
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NodeId -> m NodeId
gmapQi :: Int -> (forall d. Data d => d -> u) -> NodeId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NodeId -> u
gmapQ :: (forall d. Data d => d -> u) -> NodeId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NodeId -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NodeId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NodeId -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NodeId -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NodeId -> r
gmapT :: (forall b. Data b => b -> b) -> NodeId -> NodeId
$cgmapT :: (forall b. Data b => b -> b) -> NodeId -> NodeId
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NodeId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NodeId)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NodeId)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NodeId)
dataTypeOf :: NodeId -> DataType
$cdataTypeOf :: NodeId -> DataType
toConstr :: NodeId -> Constr
$ctoConstr :: NodeId -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NodeId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NodeId
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NodeId -> c NodeId
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NodeId -> c NodeId
$cp1Data :: Typeable NodeId
G.Data)
data SV = SV !Kind !NodeId
deriving Typeable SV
DataType
Constr
Typeable SV
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SV -> c SV)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SV)
-> (SV -> Constr)
-> (SV -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SV))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SV))
-> ((forall b. Data b => b -> b) -> SV -> SV)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r)
-> (forall u. (forall d. Data d => d -> u) -> SV -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SV -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SV -> m SV)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SV -> m SV)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SV -> m SV)
-> Data SV
SV -> DataType
SV -> Constr
(forall b. Data b => b -> b) -> SV -> SV
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SV -> c SV
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SV
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SV -> u
forall u. (forall d. Data d => d -> u) -> SV -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SV -> m SV
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SV -> m SV
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SV
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SV -> c SV
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SV)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SV)
$cSV :: Constr
$tSV :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SV -> m SV
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SV -> m SV
gmapMp :: (forall d. Data d => d -> m d) -> SV -> m SV
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SV -> m SV
gmapM :: (forall d. Data d => d -> m d) -> SV -> m SV
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SV -> m SV
gmapQi :: Int -> (forall d. Data d => d -> u) -> SV -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SV -> u
gmapQ :: (forall d. Data d => d -> u) -> SV -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SV -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SV -> r
gmapT :: (forall b. Data b => b -> b) -> SV -> SV
$cgmapT :: (forall b. Data b => b -> b) -> SV -> SV
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SV)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SV)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SV)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SV)
dataTypeOf :: SV -> DataType
$cdataTypeOf :: SV -> DataType
toConstr :: SV -> Constr
$ctoConstr :: SV -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SV
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SV
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SV -> c SV
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SV -> c SV
$cp1Data :: Typeable SV
G.Data
instance Eq SV where
SV Kind
_ NodeId
n1 == :: SV -> SV -> Bool
== SV Kind
_ NodeId
n2 = NodeId
n1 NodeId -> NodeId -> Bool
forall a. Eq a => a -> a -> Bool
== NodeId
n2
instance Ord SV where
SV Kind
_ NodeId
n1 compare :: SV -> SV -> Ordering
`compare` SV Kind
_ NodeId
n2 = NodeId
n1 NodeId -> NodeId -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` NodeId
n2
instance HasKind SV where
kindOf :: SV -> Kind
kindOf (SV Kind
k NodeId
_) = Kind
k
instance Show SV where
show :: SV -> String
show (SV Kind
_ (NodeId Int
n)) = case Int
n of
-2 -> String
"false"
-1 -> String
"true"
Int
_ -> Char
's' Char -> ShowS
forall a. a -> [a] -> [a]
: Int -> String
forall a. Show a => a -> String
show Int
n
swKind :: SV -> Kind
swKind :: SV -> Kind
swKind (SV Kind
k NodeId
_) = Kind
k
swNodeId :: SV -> NodeId
swNodeId :: SV -> NodeId
swNodeId (SV Kind
_ NodeId
nid) = NodeId
nid
forceSVArg :: SV -> IO ()
forceSVArg :: SV -> IO ()
forceSVArg (SV Kind
k NodeId
n) = Kind
k Kind -> IO () -> IO ()
`seq` NodeId
n NodeId -> IO () -> IO ()
`seq` () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
falseSV :: SV
falseSV :: SV
falseSV = Kind -> NodeId -> SV
SV Kind
KBool (NodeId -> SV) -> NodeId -> SV
forall a b. (a -> b) -> a -> b
$ Int -> NodeId
NodeId (-Int
2)
trueSV :: SV
trueSV :: SV
trueSV = Kind -> NodeId -> SV
SV Kind
KBool (NodeId -> SV) -> NodeId -> SV
forall a b. (a -> b) -> a -> b
$ Int -> NodeId
NodeId (-Int
1)
data Op = Plus
| Times
| Minus
| UNeg
| Abs
| Quot
| Rem
| Equal
| NotEqual
| LessThan
| GreaterThan
| LessEq
| GreaterEq
| Ite
| And
| Or
| XOr
| Not
| Shl
| Shr
| Rol Int
| Ror Int
| Int Int
| Join
| LkUp (Int, Kind, Kind, Int) !SV !SV
| ArrEq ArrayIndex ArrayIndex
| ArrRead ArrayIndex
| KindCast Kind Kind
| Uninterpreted String
| Label String
| IEEEFP FPOp
| NonLinear NROp
| OverflowOp OvOp
| PseudoBoolean PBOp
| StrOp StrOp
| SeqOp SeqOp
| SetOp SetOp
| TupleConstructor Int
| TupleAccess Int Int
| EitherConstructor Kind Kind Bool
| EitherIs Kind Kind Bool
| EitherAccess Bool
| MaybeConstructor Kind Bool
| MaybeIs Kind Bool
| MaybeAccess
deriving (Op -> Op -> Bool
(Op -> Op -> Bool) -> (Op -> Op -> Bool) -> Eq Op
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Op -> Op -> Bool
$c/= :: Op -> Op -> Bool
== :: Op -> Op -> Bool
$c== :: Op -> Op -> Bool
Eq, Eq Op
Eq Op
-> (Op -> Op -> Ordering)
-> (Op -> Op -> Bool)
-> (Op -> Op -> Bool)
-> (Op -> Op -> Bool)
-> (Op -> Op -> Bool)
-> (Op -> Op -> Op)
-> (Op -> Op -> Op)
-> Ord Op
Op -> Op -> Bool
Op -> Op -> Ordering
Op -> Op -> Op
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Op -> Op -> Op
$cmin :: Op -> Op -> Op
max :: Op -> Op -> Op
$cmax :: Op -> Op -> Op
>= :: Op -> Op -> Bool
$c>= :: Op -> Op -> Bool
> :: Op -> Op -> Bool
$c> :: Op -> Op -> Bool
<= :: Op -> Op -> Bool
$c<= :: Op -> Op -> Bool
< :: Op -> Op -> Bool
$c< :: Op -> Op -> Bool
compare :: Op -> Op -> Ordering
$ccompare :: Op -> Op -> Ordering
$cp1Ord :: Eq Op
Ord, )
data FPOp = FP_Cast Kind Kind SV
| FP_Reinterpret Kind Kind
| FP_Abs
| FP_Neg
| FP_Add
| FP_Sub
| FP_Mul
| FP_Div
| FP_FMA
| FP_Sqrt
| FP_Rem
| FP_RoundToIntegral
| FP_Min
| FP_Max
| FP_ObjEqual
| FP_IsNormal
| FP_IsSubnormal
| FP_IsZero
| FP_IsInfinite
| FP_IsNaN
| FP_IsNegative
| FP_IsPositive
deriving (FPOp -> FPOp -> Bool
(FPOp -> FPOp -> Bool) -> (FPOp -> FPOp -> Bool) -> Eq FPOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FPOp -> FPOp -> Bool
$c/= :: FPOp -> FPOp -> Bool
== :: FPOp -> FPOp -> Bool
$c== :: FPOp -> FPOp -> Bool
Eq, Eq FPOp
Eq FPOp
-> (FPOp -> FPOp -> Ordering)
-> (FPOp -> FPOp -> Bool)
-> (FPOp -> FPOp -> Bool)
-> (FPOp -> FPOp -> Bool)
-> (FPOp -> FPOp -> Bool)
-> (FPOp -> FPOp -> FPOp)
-> (FPOp -> FPOp -> FPOp)
-> Ord FPOp
FPOp -> FPOp -> Bool
FPOp -> FPOp -> Ordering
FPOp -> FPOp -> FPOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: FPOp -> FPOp -> FPOp
$cmin :: FPOp -> FPOp -> FPOp
max :: FPOp -> FPOp -> FPOp
$cmax :: FPOp -> FPOp -> FPOp
>= :: FPOp -> FPOp -> Bool
$c>= :: FPOp -> FPOp -> Bool
> :: FPOp -> FPOp -> Bool
$c> :: FPOp -> FPOp -> Bool
<= :: FPOp -> FPOp -> Bool
$c<= :: FPOp -> FPOp -> Bool
< :: FPOp -> FPOp -> Bool
$c< :: FPOp -> FPOp -> Bool
compare :: FPOp -> FPOp -> Ordering
$ccompare :: FPOp -> FPOp -> Ordering
$cp1Ord :: Eq FPOp
Ord, Typeable FPOp
DataType
Constr
Typeable FPOp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FPOp -> c FPOp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FPOp)
-> (FPOp -> Constr)
-> (FPOp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FPOp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FPOp))
-> ((forall b. Data b => b -> b) -> FPOp -> FPOp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r)
-> (forall u. (forall d. Data d => d -> u) -> FPOp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> FPOp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp)
-> Data FPOp
FPOp -> DataType
FPOp -> Constr
(forall b. Data b => b -> b) -> FPOp -> FPOp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FPOp -> c FPOp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FPOp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> FPOp -> u
forall u. (forall d. Data d => d -> u) -> FPOp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FPOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FPOp -> c FPOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FPOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FPOp)
$cFP_IsPositive :: Constr
$cFP_IsNegative :: Constr
$cFP_IsNaN :: Constr
$cFP_IsInfinite :: Constr
$cFP_IsZero :: Constr
$cFP_IsSubnormal :: Constr
$cFP_IsNormal :: Constr
$cFP_ObjEqual :: Constr
$cFP_Max :: Constr
$cFP_Min :: Constr
$cFP_RoundToIntegral :: Constr
$cFP_Rem :: Constr
$cFP_Sqrt :: Constr
$cFP_FMA :: Constr
$cFP_Div :: Constr
$cFP_Mul :: Constr
$cFP_Sub :: Constr
$cFP_Add :: Constr
$cFP_Neg :: Constr
$cFP_Abs :: Constr
$cFP_Reinterpret :: Constr
$cFP_Cast :: Constr
$tFPOp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> FPOp -> m FPOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp
gmapMp :: (forall d. Data d => d -> m d) -> FPOp -> m FPOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp
gmapM :: (forall d. Data d => d -> m d) -> FPOp -> m FPOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FPOp -> m FPOp
gmapQi :: Int -> (forall d. Data d => d -> u) -> FPOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FPOp -> u
gmapQ :: (forall d. Data d => d -> u) -> FPOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FPOp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FPOp -> r
gmapT :: (forall b. Data b => b -> b) -> FPOp -> FPOp
$cgmapT :: (forall b. Data b => b -> b) -> FPOp -> FPOp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FPOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FPOp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c FPOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FPOp)
dataTypeOf :: FPOp -> DataType
$cdataTypeOf :: FPOp -> DataType
toConstr :: FPOp -> Constr
$ctoConstr :: FPOp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FPOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FPOp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FPOp -> c FPOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FPOp -> c FPOp
$cp1Data :: Typeable FPOp
G.Data)
instance Show FPOp where
show :: FPOp -> String
show (FP_Cast Kind
f Kind
t SV
r) = String
"(FP_Cast: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
f String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" -> " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", using RM [" String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"])"
show (FP_Reinterpret Kind
f Kind
t) = case Kind
t of
Kind
KFloat -> String
"(_ to_fp 8 24)"
Kind
KDouble -> String
"(_ to_fp 11 53)"
KFP Int
eb Int
sb -> String
"(_ to_fp " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
eb String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
sb String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
Kind
_ -> ShowS
forall a. HasCallStack => String -> a
error ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
"SBV.FP_Reinterpret: Unexpected conversion: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
f String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" to " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
t
show FPOp
FP_Abs = String
"fp.abs"
show FPOp
FP_Neg = String
"fp.neg"
show FPOp
FP_Add = String
"fp.add"
show FPOp
FP_Sub = String
"fp.sub"
show FPOp
FP_Mul = String
"fp.mul"
show FPOp
FP_Div = String
"fp.div"
show FPOp
FP_FMA = String
"fp.fma"
show FPOp
FP_Sqrt = String
"fp.sqrt"
show FPOp
FP_Rem = String
"fp.rem"
show FPOp
FP_RoundToIntegral = String
"fp.roundToIntegral"
show FPOp
FP_Min = String
"fp.min"
show FPOp
FP_Max = String
"fp.max"
show FPOp
FP_ObjEqual = String
"="
show FPOp
FP_IsNormal = String
"fp.isNormal"
show FPOp
FP_IsSubnormal = String
"fp.isSubnormal"
show FPOp
FP_IsZero = String
"fp.isZero"
show FPOp
FP_IsInfinite = String
"fp.isInfinite"
show FPOp
FP_IsNaN = String
"fp.isNaN"
show FPOp
FP_IsNegative = String
"fp.isNegative"
show FPOp
FP_IsPositive = String
"fp.isPositive"
data NROp = NR_Sin
| NR_Cos
| NR_Tan
| NR_ASin
| NR_ACos
| NR_ATan
| NR_Sqrt
| NR_Sinh
| NR_Cosh
| NR_Tanh
| NR_Exp
| NR_Log
| NR_Pow
deriving (NROp -> NROp -> Bool
(NROp -> NROp -> Bool) -> (NROp -> NROp -> Bool) -> Eq NROp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NROp -> NROp -> Bool
$c/= :: NROp -> NROp -> Bool
== :: NROp -> NROp -> Bool
$c== :: NROp -> NROp -> Bool
Eq, Eq NROp
Eq NROp
-> (NROp -> NROp -> Ordering)
-> (NROp -> NROp -> Bool)
-> (NROp -> NROp -> Bool)
-> (NROp -> NROp -> Bool)
-> (NROp -> NROp -> Bool)
-> (NROp -> NROp -> NROp)
-> (NROp -> NROp -> NROp)
-> Ord NROp
NROp -> NROp -> Bool
NROp -> NROp -> Ordering
NROp -> NROp -> NROp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NROp -> NROp -> NROp
$cmin :: NROp -> NROp -> NROp
max :: NROp -> NROp -> NROp
$cmax :: NROp -> NROp -> NROp
>= :: NROp -> NROp -> Bool
$c>= :: NROp -> NROp -> Bool
> :: NROp -> NROp -> Bool
$c> :: NROp -> NROp -> Bool
<= :: NROp -> NROp -> Bool
$c<= :: NROp -> NROp -> Bool
< :: NROp -> NROp -> Bool
$c< :: NROp -> NROp -> Bool
compare :: NROp -> NROp -> Ordering
$ccompare :: NROp -> NROp -> Ordering
$cp1Ord :: Eq NROp
Ord, Typeable NROp
DataType
Constr
Typeable NROp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NROp -> c NROp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NROp)
-> (NROp -> Constr)
-> (NROp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NROp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NROp))
-> ((forall b. Data b => b -> b) -> NROp -> NROp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r)
-> (forall u. (forall d. Data d => d -> u) -> NROp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NROp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp)
-> Data NROp
NROp -> DataType
NROp -> Constr
(forall b. Data b => b -> b) -> NROp -> NROp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NROp -> c NROp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NROp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NROp -> u
forall u. (forall d. Data d => d -> u) -> NROp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NROp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NROp -> c NROp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NROp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NROp)
$cNR_Pow :: Constr
$cNR_Log :: Constr
$cNR_Exp :: Constr
$cNR_Tanh :: Constr
$cNR_Cosh :: Constr
$cNR_Sinh :: Constr
$cNR_Sqrt :: Constr
$cNR_ATan :: Constr
$cNR_ACos :: Constr
$cNR_ASin :: Constr
$cNR_Tan :: Constr
$cNR_Cos :: Constr
$cNR_Sin :: Constr
$tNROp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NROp -> m NROp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp
gmapMp :: (forall d. Data d => d -> m d) -> NROp -> m NROp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp
gmapM :: (forall d. Data d => d -> m d) -> NROp -> m NROp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NROp -> m NROp
gmapQi :: Int -> (forall d. Data d => d -> u) -> NROp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NROp -> u
gmapQ :: (forall d. Data d => d -> u) -> NROp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NROp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NROp -> r
gmapT :: (forall b. Data b => b -> b) -> NROp -> NROp
$cgmapT :: (forall b. Data b => b -> b) -> NROp -> NROp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NROp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NROp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NROp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NROp)
dataTypeOf :: NROp -> DataType
$cdataTypeOf :: NROp -> DataType
toConstr :: NROp -> Constr
$ctoConstr :: NROp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NROp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NROp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NROp -> c NROp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NROp -> c NROp
$cp1Data :: Typeable NROp
G.Data)
instance Show NROp where
show :: NROp -> String
show NROp
NR_Sin = String
"sin"
show NROp
NR_Cos = String
"cos"
show NROp
NR_Tan = String
"tan"
show NROp
NR_ASin = String
"asin"
show NROp
NR_ACos = String
"acos"
show NROp
NR_ATan = String
"atan"
show NROp
NR_Sinh = String
"sinh"
show NROp
NR_Cosh = String
"cosh"
show NROp
NR_Tanh = String
"tanh"
show NROp
NR_Sqrt = String
"sqrt"
show NROp
NR_Exp = String
"exp"
show NROp
NR_Log = String
"log"
show NROp
NR_Pow = String
"pow"
data PBOp = PB_AtMost Int
| PB_AtLeast Int
| PB_Exactly Int
| PB_Le [Int] Int
| PB_Ge [Int] Int
| PB_Eq [Int] Int
deriving (PBOp -> PBOp -> Bool
(PBOp -> PBOp -> Bool) -> (PBOp -> PBOp -> Bool) -> Eq PBOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PBOp -> PBOp -> Bool
$c/= :: PBOp -> PBOp -> Bool
== :: PBOp -> PBOp -> Bool
$c== :: PBOp -> PBOp -> Bool
Eq, Eq PBOp
Eq PBOp
-> (PBOp -> PBOp -> Ordering)
-> (PBOp -> PBOp -> Bool)
-> (PBOp -> PBOp -> Bool)
-> (PBOp -> PBOp -> Bool)
-> (PBOp -> PBOp -> Bool)
-> (PBOp -> PBOp -> PBOp)
-> (PBOp -> PBOp -> PBOp)
-> Ord PBOp
PBOp -> PBOp -> Bool
PBOp -> PBOp -> Ordering
PBOp -> PBOp -> PBOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PBOp -> PBOp -> PBOp
$cmin :: PBOp -> PBOp -> PBOp
max :: PBOp -> PBOp -> PBOp
$cmax :: PBOp -> PBOp -> PBOp
>= :: PBOp -> PBOp -> Bool
$c>= :: PBOp -> PBOp -> Bool
> :: PBOp -> PBOp -> Bool
$c> :: PBOp -> PBOp -> Bool
<= :: PBOp -> PBOp -> Bool
$c<= :: PBOp -> PBOp -> Bool
< :: PBOp -> PBOp -> Bool
$c< :: PBOp -> PBOp -> Bool
compare :: PBOp -> PBOp -> Ordering
$ccompare :: PBOp -> PBOp -> Ordering
$cp1Ord :: Eq PBOp
Ord, Int -> PBOp -> ShowS
[PBOp] -> ShowS
PBOp -> String
(Int -> PBOp -> ShowS)
-> (PBOp -> String) -> ([PBOp] -> ShowS) -> Show PBOp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PBOp] -> ShowS
$cshowList :: [PBOp] -> ShowS
show :: PBOp -> String
$cshow :: PBOp -> String
showsPrec :: Int -> PBOp -> ShowS
$cshowsPrec :: Int -> PBOp -> ShowS
Show, Typeable PBOp
DataType
Constr
Typeable PBOp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PBOp -> c PBOp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PBOp)
-> (PBOp -> Constr)
-> (PBOp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PBOp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PBOp))
-> ((forall b. Data b => b -> b) -> PBOp -> PBOp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r)
-> (forall u. (forall d. Data d => d -> u) -> PBOp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PBOp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp)
-> Data PBOp
PBOp -> DataType
PBOp -> Constr
(forall b. Data b => b -> b) -> PBOp -> PBOp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PBOp -> c PBOp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PBOp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PBOp -> u
forall u. (forall d. Data d => d -> u) -> PBOp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PBOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PBOp -> c PBOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PBOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PBOp)
$cPB_Eq :: Constr
$cPB_Ge :: Constr
$cPB_Le :: Constr
$cPB_Exactly :: Constr
$cPB_AtLeast :: Constr
$cPB_AtMost :: Constr
$tPBOp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> PBOp -> m PBOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp
gmapMp :: (forall d. Data d => d -> m d) -> PBOp -> m PBOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp
gmapM :: (forall d. Data d => d -> m d) -> PBOp -> m PBOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PBOp -> m PBOp
gmapQi :: Int -> (forall d. Data d => d -> u) -> PBOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PBOp -> u
gmapQ :: (forall d. Data d => d -> u) -> PBOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PBOp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PBOp -> r
gmapT :: (forall b. Data b => b -> b) -> PBOp -> PBOp
$cgmapT :: (forall b. Data b => b -> b) -> PBOp -> PBOp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PBOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PBOp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c PBOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PBOp)
dataTypeOf :: PBOp -> DataType
$cdataTypeOf :: PBOp -> DataType
toConstr :: PBOp -> Constr
$ctoConstr :: PBOp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PBOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PBOp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PBOp -> c PBOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PBOp -> c PBOp
$cp1Data :: Typeable PBOp
G.Data)
data OvOp = Overflow_SMul_OVFL
| Overflow_SMul_UDFL
| Overflow_UMul_OVFL
deriving (OvOp -> OvOp -> Bool
(OvOp -> OvOp -> Bool) -> (OvOp -> OvOp -> Bool) -> Eq OvOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OvOp -> OvOp -> Bool
$c/= :: OvOp -> OvOp -> Bool
== :: OvOp -> OvOp -> Bool
$c== :: OvOp -> OvOp -> Bool
Eq, Eq OvOp
Eq OvOp
-> (OvOp -> OvOp -> Ordering)
-> (OvOp -> OvOp -> Bool)
-> (OvOp -> OvOp -> Bool)
-> (OvOp -> OvOp -> Bool)
-> (OvOp -> OvOp -> Bool)
-> (OvOp -> OvOp -> OvOp)
-> (OvOp -> OvOp -> OvOp)
-> Ord OvOp
OvOp -> OvOp -> Bool
OvOp -> OvOp -> Ordering
OvOp -> OvOp -> OvOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OvOp -> OvOp -> OvOp
$cmin :: OvOp -> OvOp -> OvOp
max :: OvOp -> OvOp -> OvOp
$cmax :: OvOp -> OvOp -> OvOp
>= :: OvOp -> OvOp -> Bool
$c>= :: OvOp -> OvOp -> Bool
> :: OvOp -> OvOp -> Bool
$c> :: OvOp -> OvOp -> Bool
<= :: OvOp -> OvOp -> Bool
$c<= :: OvOp -> OvOp -> Bool
< :: OvOp -> OvOp -> Bool
$c< :: OvOp -> OvOp -> Bool
compare :: OvOp -> OvOp -> Ordering
$ccompare :: OvOp -> OvOp -> Ordering
$cp1Ord :: Eq OvOp
Ord, Typeable OvOp
DataType
Constr
Typeable OvOp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OvOp -> c OvOp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OvOp)
-> (OvOp -> Constr)
-> (OvOp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OvOp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OvOp))
-> ((forall b. Data b => b -> b) -> OvOp -> OvOp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r)
-> (forall u. (forall d. Data d => d -> u) -> OvOp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> OvOp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp)
-> Data OvOp
OvOp -> DataType
OvOp -> Constr
(forall b. Data b => b -> b) -> OvOp -> OvOp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OvOp -> c OvOp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OvOp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> OvOp -> u
forall u. (forall d. Data d => d -> u) -> OvOp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OvOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OvOp -> c OvOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OvOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OvOp)
$cOverflow_UMul_OVFL :: Constr
$cOverflow_SMul_UDFL :: Constr
$cOverflow_SMul_OVFL :: Constr
$tOvOp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> OvOp -> m OvOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp
gmapMp :: (forall d. Data d => d -> m d) -> OvOp -> m OvOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp
gmapM :: (forall d. Data d => d -> m d) -> OvOp -> m OvOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> OvOp -> m OvOp
gmapQi :: Int -> (forall d. Data d => d -> u) -> OvOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OvOp -> u
gmapQ :: (forall d. Data d => d -> u) -> OvOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> OvOp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OvOp -> r
gmapT :: (forall b. Data b => b -> b) -> OvOp -> OvOp
$cgmapT :: (forall b. Data b => b -> b) -> OvOp -> OvOp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OvOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OvOp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c OvOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OvOp)
dataTypeOf :: OvOp -> DataType
$cdataTypeOf :: OvOp -> DataType
toConstr :: OvOp -> Constr
$ctoConstr :: OvOp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OvOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OvOp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OvOp -> c OvOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OvOp -> c OvOp
$cp1Data :: Typeable OvOp
G.Data)
instance Show OvOp where
show :: OvOp -> String
show OvOp
Overflow_SMul_OVFL = String
"bvsmul_noovfl"
show OvOp
Overflow_SMul_UDFL = String
"bvsmul_noudfl"
show OvOp
Overflow_UMul_OVFL = String
"bvumul_noovfl"
data StrOp = StrConcat
| StrLen
| StrUnit
| StrNth
| StrSubstr
| StrIndexOf
| StrContains
| StrPrefixOf
| StrSuffixOf
| StrReplace
| StrStrToNat
| StrNatToStr
| StrToCode
| StrFromCode
| StrInRe RegExp
deriving (StrOp -> StrOp -> Bool
(StrOp -> StrOp -> Bool) -> (StrOp -> StrOp -> Bool) -> Eq StrOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StrOp -> StrOp -> Bool
$c/= :: StrOp -> StrOp -> Bool
== :: StrOp -> StrOp -> Bool
$c== :: StrOp -> StrOp -> Bool
Eq, Eq StrOp
Eq StrOp
-> (StrOp -> StrOp -> Ordering)
-> (StrOp -> StrOp -> Bool)
-> (StrOp -> StrOp -> Bool)
-> (StrOp -> StrOp -> Bool)
-> (StrOp -> StrOp -> Bool)
-> (StrOp -> StrOp -> StrOp)
-> (StrOp -> StrOp -> StrOp)
-> Ord StrOp
StrOp -> StrOp -> Bool
StrOp -> StrOp -> Ordering
StrOp -> StrOp -> StrOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: StrOp -> StrOp -> StrOp
$cmin :: StrOp -> StrOp -> StrOp
max :: StrOp -> StrOp -> StrOp
$cmax :: StrOp -> StrOp -> StrOp
>= :: StrOp -> StrOp -> Bool
$c>= :: StrOp -> StrOp -> Bool
> :: StrOp -> StrOp -> Bool
$c> :: StrOp -> StrOp -> Bool
<= :: StrOp -> StrOp -> Bool
$c<= :: StrOp -> StrOp -> Bool
< :: StrOp -> StrOp -> Bool
$c< :: StrOp -> StrOp -> Bool
compare :: StrOp -> StrOp -> Ordering
$ccompare :: StrOp -> StrOp -> Ordering
$cp1Ord :: Eq StrOp
Ord, Typeable StrOp
DataType
Constr
Typeable StrOp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> StrOp -> c StrOp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StrOp)
-> (StrOp -> Constr)
-> (StrOp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c StrOp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StrOp))
-> ((forall b. Data b => b -> b) -> StrOp -> StrOp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r)
-> (forall u. (forall d. Data d => d -> u) -> StrOp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> StrOp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp)
-> Data StrOp
StrOp -> DataType
StrOp -> Constr
(forall b. Data b => b -> b) -> StrOp -> StrOp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> StrOp -> c StrOp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StrOp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> StrOp -> u
forall u. (forall d. Data d => d -> u) -> StrOp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StrOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> StrOp -> c StrOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c StrOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StrOp)
$cStrInRe :: Constr
$cStrFromCode :: Constr
$cStrToCode :: Constr
$cStrNatToStr :: Constr
$cStrStrToNat :: Constr
$cStrReplace :: Constr
$cStrSuffixOf :: Constr
$cStrPrefixOf :: Constr
$cStrContains :: Constr
$cStrIndexOf :: Constr
$cStrSubstr :: Constr
$cStrNth :: Constr
$cStrUnit :: Constr
$cStrLen :: Constr
$cStrConcat :: Constr
$tStrOp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> StrOp -> m StrOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp
gmapMp :: (forall d. Data d => d -> m d) -> StrOp -> m StrOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp
gmapM :: (forall d. Data d => d -> m d) -> StrOp -> m StrOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> StrOp -> m StrOp
gmapQi :: Int -> (forall d. Data d => d -> u) -> StrOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> StrOp -> u
gmapQ :: (forall d. Data d => d -> u) -> StrOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> StrOp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StrOp -> r
gmapT :: (forall b. Data b => b -> b) -> StrOp -> StrOp
$cgmapT :: (forall b. Data b => b -> b) -> StrOp -> StrOp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StrOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StrOp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c StrOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c StrOp)
dataTypeOf :: StrOp -> DataType
$cdataTypeOf :: StrOp -> DataType
toConstr :: StrOp -> Constr
$ctoConstr :: StrOp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StrOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StrOp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> StrOp -> c StrOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> StrOp -> c StrOp
$cp1Data :: Typeable StrOp
G.Data)
data RegExp = Literal String
| All
| None
| Range Char Char
| Conc [RegExp]
| KStar RegExp
| KPlus RegExp
| Opt RegExp
| Loop Int Int RegExp
| Union [RegExp]
| Inter RegExp RegExp
deriving (RegExp -> RegExp -> Bool
(RegExp -> RegExp -> Bool)
-> (RegExp -> RegExp -> Bool) -> Eq RegExp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegExp -> RegExp -> Bool
$c/= :: RegExp -> RegExp -> Bool
== :: RegExp -> RegExp -> Bool
$c== :: RegExp -> RegExp -> Bool
Eq, Eq RegExp
Eq RegExp
-> (RegExp -> RegExp -> Ordering)
-> (RegExp -> RegExp -> Bool)
-> (RegExp -> RegExp -> Bool)
-> (RegExp -> RegExp -> Bool)
-> (RegExp -> RegExp -> Bool)
-> (RegExp -> RegExp -> RegExp)
-> (RegExp -> RegExp -> RegExp)
-> Ord RegExp
RegExp -> RegExp -> Bool
RegExp -> RegExp -> Ordering
RegExp -> RegExp -> RegExp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RegExp -> RegExp -> RegExp
$cmin :: RegExp -> RegExp -> RegExp
max :: RegExp -> RegExp -> RegExp
$cmax :: RegExp -> RegExp -> RegExp
>= :: RegExp -> RegExp -> Bool
$c>= :: RegExp -> RegExp -> Bool
> :: RegExp -> RegExp -> Bool
$c> :: RegExp -> RegExp -> Bool
<= :: RegExp -> RegExp -> Bool
$c<= :: RegExp -> RegExp -> Bool
< :: RegExp -> RegExp -> Bool
$c< :: RegExp -> RegExp -> Bool
compare :: RegExp -> RegExp -> Ordering
$ccompare :: RegExp -> RegExp -> Ordering
$cp1Ord :: Eq RegExp
Ord, Typeable RegExp
DataType
Constr
Typeable RegExp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RegExp -> c RegExp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RegExp)
-> (RegExp -> Constr)
-> (RegExp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RegExp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RegExp))
-> ((forall b. Data b => b -> b) -> RegExp -> RegExp)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RegExp -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RegExp -> r)
-> (forall u. (forall d. Data d => d -> u) -> RegExp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> RegExp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp)
-> Data RegExp
RegExp -> DataType
RegExp -> Constr
(forall b. Data b => b -> b) -> RegExp -> RegExp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RegExp -> c RegExp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RegExp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RegExp -> u
forall u. (forall d. Data d => d -> u) -> RegExp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RegExp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RegExp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RegExp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RegExp -> c RegExp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RegExp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RegExp)
$cInter :: Constr
$cUnion :: Constr
$cLoop :: Constr
$cOpt :: Constr
$cKPlus :: Constr
$cKStar :: Constr
$cConc :: Constr
$cRange :: Constr
$cNone :: Constr
$cAll :: Constr
$cLiteral :: Constr
$tRegExp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RegExp -> m RegExp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp
gmapMp :: (forall d. Data d => d -> m d) -> RegExp -> m RegExp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp
gmapM :: (forall d. Data d => d -> m d) -> RegExp -> m RegExp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RegExp -> m RegExp
gmapQi :: Int -> (forall d. Data d => d -> u) -> RegExp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RegExp -> u
gmapQ :: (forall d. Data d => d -> u) -> RegExp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RegExp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RegExp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RegExp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RegExp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RegExp -> r
gmapT :: (forall b. Data b => b -> b) -> RegExp -> RegExp
$cgmapT :: (forall b. Data b => b -> b) -> RegExp -> RegExp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RegExp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RegExp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RegExp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RegExp)
dataTypeOf :: RegExp -> DataType
$cdataTypeOf :: RegExp -> DataType
toConstr :: RegExp -> Constr
$ctoConstr :: RegExp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RegExp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RegExp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RegExp -> c RegExp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RegExp -> c RegExp
$cp1Data :: Typeable RegExp
G.Data)
instance IsString RegExp where
fromString :: String -> RegExp
fromString = String -> RegExp
Literal
instance Num RegExp where
Conc [RegExp]
xs * :: RegExp -> RegExp -> RegExp
* RegExp
y = [RegExp] -> RegExp
Conc ([RegExp]
xs [RegExp] -> [RegExp] -> [RegExp]
forall a. [a] -> [a] -> [a]
++ [RegExp
y])
RegExp
x * Conc [RegExp]
ys = [RegExp] -> RegExp
Conc (RegExp
x RegExp -> [RegExp] -> [RegExp]
forall a. a -> [a] -> [a]
: [RegExp]
ys)
RegExp
x * RegExp
y = [RegExp] -> RegExp
Conc [RegExp
x, RegExp
y]
Union [RegExp]
xs + :: RegExp -> RegExp -> RegExp
+ RegExp
y = [RegExp] -> RegExp
Union ([RegExp]
xs [RegExp] -> [RegExp] -> [RegExp]
forall a. [a] -> [a] -> [a]
++ [RegExp
y])
RegExp
x + Union [RegExp]
ys = [RegExp] -> RegExp
Union (RegExp
x RegExp -> [RegExp] -> [RegExp]
forall a. a -> [a] -> [a]
: [RegExp]
ys)
RegExp
x + RegExp
y = [RegExp] -> RegExp
Union [RegExp
x, RegExp
y]
abs :: RegExp -> RegExp
abs = String -> RegExp -> RegExp
forall a. HasCallStack => String -> a
error String
"Num.RegExp: no abs method"
signum :: RegExp -> RegExp
signum = String -> RegExp -> RegExp
forall a. HasCallStack => String -> a
error String
"Num.RegExp: no signum method"
fromInteger :: Integer -> RegExp
fromInteger Integer
x
| Integer
x Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
0 = RegExp
None
| Integer
x Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
1 = String -> RegExp
Literal String
""
| Bool
True = String -> RegExp
forall a. HasCallStack => String -> a
error (String -> RegExp) -> String -> RegExp
forall a b. (a -> b) -> a -> b
$ String
"Num.RegExp: Only 0 and 1 makes sense as a reg-exp, no meaning for: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
x
negate :: RegExp -> RegExp
negate = String -> RegExp -> RegExp
forall a. HasCallStack => String -> a
error String
"Num.RegExp: no negate method"
instance Show RegExp where
show :: RegExp -> String
show = ShowS -> RegExp -> String
regExpToString ShowS
forall a. Show a => a -> String
show
regExpToSMTString :: RegExp -> String
regExpToSMTString :: RegExp -> String
regExpToSMTString = ShowS -> RegExp -> String
regExpToString (\String
s -> Char
'"' Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
stringToQFS String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\"")
regExpToString :: (String -> String) -> RegExp -> String
regExpToString :: ShowS -> RegExp -> String
regExpToString ShowS
fs (Literal String
s) = String
"(str.to.re " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
fs String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
_ RegExp
All = String
"re.allchar"
regExpToString ShowS
_ RegExp
None = String
"re.nostr"
regExpToString ShowS
fs (Range Char
ch1 Char
ch2) = String
"(re.range " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
fs [Char
ch1] String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
fs [Char
ch2] String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
_ (Conc []) = Integer -> String
forall a. Show a => a -> String
show (Integer
1 :: Integer)
regExpToString ShowS
fs (Conc [RegExp
x]) = ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
x
regExpToString ShowS
fs (Conc [RegExp]
xs) = String
"(re.++ " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
unwords ((RegExp -> String) -> [RegExp] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (ShowS -> RegExp -> String
regExpToString ShowS
fs) [RegExp]
xs) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
fs (KStar RegExp
r) = String
"(re.* " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
fs (KPlus RegExp
r) = String
"(re.+ " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
fs (Opt RegExp
r) = String
"(re.opt " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
fs (Loop Int
lo Int
hi RegExp
r)
| Int
lo Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0, Int
hi Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
lo = String
"((_ re.loop " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
lo String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
hi String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
| Bool
True = ShowS
forall a. HasCallStack => String -> a
error ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
"Invalid regular-expression Loop with arguments: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Int, Int) -> String
forall a. Show a => a -> String
show (Int
lo, Int
hi)
regExpToString ShowS
fs (Inter RegExp
r1 RegExp
r2) = String
"(re.inter " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
r1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
r2 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
regExpToString ShowS
_ (Union []) = String
"re.nostr"
regExpToString ShowS
fs (Union [RegExp
x]) = ShowS -> RegExp -> String
regExpToString ShowS
fs RegExp
x
regExpToString ShowS
fs (Union [RegExp]
xs) = String
"(re.union " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
unwords ((RegExp -> String) -> [RegExp] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (ShowS -> RegExp -> String
regExpToString ShowS
fs) [RegExp]
xs) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
instance Show StrOp where
show :: StrOp -> String
show StrOp
StrConcat = String
"str.++"
show StrOp
StrLen = String
"str.len"
show StrOp
StrUnit = String
"str.unit"
show StrOp
StrNth = String
"str.at"
show StrOp
StrSubstr = String
"str.substr"
show StrOp
StrIndexOf = String
"str.indexof"
show StrOp
StrContains = String
"str.contains"
show StrOp
StrPrefixOf = String
"str.prefixof"
show StrOp
StrSuffixOf = String
"str.suffixof"
show StrOp
StrReplace = String
"str.replace"
show StrOp
StrStrToNat = String
"str.to.int"
show StrOp
StrNatToStr = String
"int.to.str"
show StrOp
StrToCode = String
"str.to_code"
show StrOp
StrFromCode = String
"str.from_code"
show (StrInRe RegExp
s) = String
"str.in.re " String -> ShowS
forall a. [a] -> [a] -> [a]
++ RegExp -> String
regExpToSMTString RegExp
s
data SeqOp = SeqConcat
| SeqLen
| SeqUnit
| SeqNth
| SeqSubseq
| SeqIndexOf
| SeqContains
| SeqPrefixOf
| SeqSuffixOf
| SeqReplace
deriving (SeqOp -> SeqOp -> Bool
(SeqOp -> SeqOp -> Bool) -> (SeqOp -> SeqOp -> Bool) -> Eq SeqOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SeqOp -> SeqOp -> Bool
$c/= :: SeqOp -> SeqOp -> Bool
== :: SeqOp -> SeqOp -> Bool
$c== :: SeqOp -> SeqOp -> Bool
Eq, Eq SeqOp
Eq SeqOp
-> (SeqOp -> SeqOp -> Ordering)
-> (SeqOp -> SeqOp -> Bool)
-> (SeqOp -> SeqOp -> Bool)
-> (SeqOp -> SeqOp -> Bool)
-> (SeqOp -> SeqOp -> Bool)
-> (SeqOp -> SeqOp -> SeqOp)
-> (SeqOp -> SeqOp -> SeqOp)
-> Ord SeqOp
SeqOp -> SeqOp -> Bool
SeqOp -> SeqOp -> Ordering
SeqOp -> SeqOp -> SeqOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SeqOp -> SeqOp -> SeqOp
$cmin :: SeqOp -> SeqOp -> SeqOp
max :: SeqOp -> SeqOp -> SeqOp
$cmax :: SeqOp -> SeqOp -> SeqOp
>= :: SeqOp -> SeqOp -> Bool
$c>= :: SeqOp -> SeqOp -> Bool
> :: SeqOp -> SeqOp -> Bool
$c> :: SeqOp -> SeqOp -> Bool
<= :: SeqOp -> SeqOp -> Bool
$c<= :: SeqOp -> SeqOp -> Bool
< :: SeqOp -> SeqOp -> Bool
$c< :: SeqOp -> SeqOp -> Bool
compare :: SeqOp -> SeqOp -> Ordering
$ccompare :: SeqOp -> SeqOp -> Ordering
$cp1Ord :: Eq SeqOp
Ord, Typeable SeqOp
DataType
Constr
Typeable SeqOp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SeqOp -> c SeqOp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SeqOp)
-> (SeqOp -> Constr)
-> (SeqOp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SeqOp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SeqOp))
-> ((forall b. Data b => b -> b) -> SeqOp -> SeqOp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r)
-> (forall u. (forall d. Data d => d -> u) -> SeqOp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SeqOp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp)
-> Data SeqOp
SeqOp -> DataType
SeqOp -> Constr
(forall b. Data b => b -> b) -> SeqOp -> SeqOp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SeqOp -> c SeqOp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SeqOp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SeqOp -> u
forall u. (forall d. Data d => d -> u) -> SeqOp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SeqOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SeqOp -> c SeqOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SeqOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SeqOp)
$cSeqReplace :: Constr
$cSeqSuffixOf :: Constr
$cSeqPrefixOf :: Constr
$cSeqContains :: Constr
$cSeqIndexOf :: Constr
$cSeqSubseq :: Constr
$cSeqNth :: Constr
$cSeqUnit :: Constr
$cSeqLen :: Constr
$cSeqConcat :: Constr
$tSeqOp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
gmapMp :: (forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
gmapM :: (forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SeqOp -> m SeqOp
gmapQi :: Int -> (forall d. Data d => d -> u) -> SeqOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SeqOp -> u
gmapQ :: (forall d. Data d => d -> u) -> SeqOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SeqOp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SeqOp -> r
gmapT :: (forall b. Data b => b -> b) -> SeqOp -> SeqOp
$cgmapT :: (forall b. Data b => b -> b) -> SeqOp -> SeqOp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SeqOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SeqOp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SeqOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SeqOp)
dataTypeOf :: SeqOp -> DataType
$cdataTypeOf :: SeqOp -> DataType
toConstr :: SeqOp -> Constr
$ctoConstr :: SeqOp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SeqOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SeqOp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SeqOp -> c SeqOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SeqOp -> c SeqOp
$cp1Data :: Typeable SeqOp
G.Data)
instance Show SeqOp where
show :: SeqOp -> String
show SeqOp
SeqConcat = String
"seq.++"
show SeqOp
SeqLen = String
"seq.len"
show SeqOp
SeqUnit = String
"seq.unit"
show SeqOp
SeqNth = String
"seq.nth"
show SeqOp
SeqSubseq = String
"seq.extract"
show SeqOp
SeqIndexOf = String
"seq.indexof"
show SeqOp
SeqContains = String
"seq.contains"
show SeqOp
SeqPrefixOf = String
"seq.prefixof"
show SeqOp
SeqSuffixOf = String
"seq.suffixof"
show SeqOp
SeqReplace = String
"seq.replace"
data SetOp = SetEqual
| SetMember
| SetInsert
| SetDelete
| SetIntersect
| SetUnion
| SetSubset
| SetDifference
| SetComplement
| SetHasSize
deriving (SetOp -> SetOp -> Bool
(SetOp -> SetOp -> Bool) -> (SetOp -> SetOp -> Bool) -> Eq SetOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetOp -> SetOp -> Bool
$c/= :: SetOp -> SetOp -> Bool
== :: SetOp -> SetOp -> Bool
$c== :: SetOp -> SetOp -> Bool
Eq, Eq SetOp
Eq SetOp
-> (SetOp -> SetOp -> Ordering)
-> (SetOp -> SetOp -> Bool)
-> (SetOp -> SetOp -> Bool)
-> (SetOp -> SetOp -> Bool)
-> (SetOp -> SetOp -> Bool)
-> (SetOp -> SetOp -> SetOp)
-> (SetOp -> SetOp -> SetOp)
-> Ord SetOp
SetOp -> SetOp -> Bool
SetOp -> SetOp -> Ordering
SetOp -> SetOp -> SetOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SetOp -> SetOp -> SetOp
$cmin :: SetOp -> SetOp -> SetOp
max :: SetOp -> SetOp -> SetOp
$cmax :: SetOp -> SetOp -> SetOp
>= :: SetOp -> SetOp -> Bool
$c>= :: SetOp -> SetOp -> Bool
> :: SetOp -> SetOp -> Bool
$c> :: SetOp -> SetOp -> Bool
<= :: SetOp -> SetOp -> Bool
$c<= :: SetOp -> SetOp -> Bool
< :: SetOp -> SetOp -> Bool
$c< :: SetOp -> SetOp -> Bool
compare :: SetOp -> SetOp -> Ordering
$ccompare :: SetOp -> SetOp -> Ordering
$cp1Ord :: Eq SetOp
Ord, Typeable SetOp
DataType
Constr
Typeable SetOp
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SetOp -> c SetOp)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SetOp)
-> (SetOp -> Constr)
-> (SetOp -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SetOp))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SetOp))
-> ((forall b. Data b => b -> b) -> SetOp -> SetOp)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r)
-> (forall u. (forall d. Data d => d -> u) -> SetOp -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SetOp -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp)
-> Data SetOp
SetOp -> DataType
SetOp -> Constr
(forall b. Data b => b -> b) -> SetOp -> SetOp
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SetOp -> c SetOp
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SetOp
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SetOp -> u
forall u. (forall d. Data d => d -> u) -> SetOp -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SetOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SetOp -> c SetOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SetOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SetOp)
$cSetHasSize :: Constr
$cSetComplement :: Constr
$cSetDifference :: Constr
$cSetSubset :: Constr
$cSetUnion :: Constr
$cSetIntersect :: Constr
$cSetDelete :: Constr
$cSetInsert :: Constr
$cSetMember :: Constr
$cSetEqual :: Constr
$tSetOp :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SetOp -> m SetOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp
gmapMp :: (forall d. Data d => d -> m d) -> SetOp -> m SetOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp
gmapM :: (forall d. Data d => d -> m d) -> SetOp -> m SetOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SetOp -> m SetOp
gmapQi :: Int -> (forall d. Data d => d -> u) -> SetOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SetOp -> u
gmapQ :: (forall d. Data d => d -> u) -> SetOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SetOp -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SetOp -> r
gmapT :: (forall b. Data b => b -> b) -> SetOp -> SetOp
$cgmapT :: (forall b. Data b => b -> b) -> SetOp -> SetOp
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SetOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SetOp)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SetOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SetOp)
dataTypeOf :: SetOp -> DataType
$cdataTypeOf :: SetOp -> DataType
toConstr :: SetOp -> Constr
$ctoConstr :: SetOp -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SetOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SetOp
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SetOp -> c SetOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SetOp -> c SetOp
$cp1Data :: Typeable SetOp
G.Data)
instance Show SetOp where
show :: SetOp -> String
show SetOp
SetEqual = String
"=="
show SetOp
SetMember = String
"Set.member"
show SetOp
SetInsert = String
"Set.insert"
show SetOp
SetDelete = String
"Set.delete"
show SetOp
SetIntersect = String
"Set.intersect"
show SetOp
SetUnion = String
"Set.union"
show SetOp
SetSubset = String
"Set.subset"
show SetOp
SetDifference = String
"Set.difference"
show SetOp
SetComplement = String
"Set.complement"
show SetOp
SetHasSize = String
"Set.setHasSize"
instance Show Op where
show :: Op -> String
show Op
Shl = String
"<<"
show Op
Shr = String
">>"
show (Rol Int
i) = String
"<<<" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
show (Ror Int
i) = String
">>>" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i
show (Extract Int
i Int
j) = String
"choose [" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
":" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
j String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"]"
show (LkUp (Int
ti, Kind
at, Kind
rt, Int
l) SV
i SV
e)
= String
"lookup(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
tinfo String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
e String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
where tinfo :: String
tinfo = String
"table" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
ti String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"(" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
at String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" -> " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
rt String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
l String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (ArrEq ArrayIndex
i ArrayIndex
j) = String
"array_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ ArrayIndex -> String
forall a. Show a => a -> String
show ArrayIndex
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" == array_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ ArrayIndex -> String
forall a. Show a => a -> String
show ArrayIndex
j
show (ArrRead ArrayIndex
i) = String
"select array_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ ArrayIndex -> String
forall a. Show a => a -> String
show ArrayIndex
i
show (KindCast Kind
fr Kind
to) = String
"cast_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
fr String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
to
show (Uninterpreted String
i) = String
"[uninterpreted] " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
i
show (Label String
s) = String
"[label] " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
show (IEEEFP FPOp
w) = FPOp -> String
forall a. Show a => a -> String
show FPOp
w
show (NonLinear NROp
w) = NROp -> String
forall a. Show a => a -> String
show NROp
w
show (PseudoBoolean PBOp
p) = PBOp -> String
forall a. Show a => a -> String
show PBOp
p
show (OverflowOp OvOp
o) = OvOp -> String
forall a. Show a => a -> String
show OvOp
o
show (StrOp StrOp
s) = StrOp -> String
forall a. Show a => a -> String
show StrOp
s
show (SeqOp SeqOp
s) = SeqOp -> String
forall a. Show a => a -> String
show SeqOp
s
show (SetOp SetOp
s) = SetOp -> String
forall a. Show a => a -> String
show SetOp
s
show (TupleConstructor Int
0) = String
"mkSBVTuple0"
show (TupleConstructor Int
n) = String
"mkSBVTuple" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n
show (TupleAccess Int
i Int
n) = String
"proj_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"_SBVTuple" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n
show (EitherConstructor Kind
k1 Kind
k2 Bool
False) = String
"(_ left_SBVEither " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind -> Kind
KEither Kind
k1 Kind
k2) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (EitherConstructor Kind
k1 Kind
k2 Bool
True ) = String
"(_ right_SBVEither " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind -> Kind
KEither Kind
k1 Kind
k2) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (EitherIs Kind
k1 Kind
k2 Bool
False) = String
"(_ is (left_SBVEither (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k1 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind -> Kind
KEither Kind
k1 Kind
k2) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"))"
show (EitherIs Kind
k1 Kind
k2 Bool
True ) = String
"(_ is (right_SBVEither (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k2 String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind -> Kind
KEither Kind
k1 Kind
k2) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"))"
show (EitherAccess Bool
False) = String
"get_left_SBVEither"
show (EitherAccess Bool
True ) = String
"get_right_SBVEither"
show (MaybeConstructor Kind
k Bool
False) = String
"(_ nothing_SBVMaybe " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind
KMaybe Kind
k) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (MaybeConstructor Kind
k Bool
True) = String
"(_ just_SBVMaybe " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind
KMaybe Kind
k) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (MaybeIs Kind
k Bool
False) = String
"(_ is (nothing_SBVMaybe () " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind
KMaybe Kind
k) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"))"
show (MaybeIs Kind
k Bool
True ) = String
"(_ is (just_SBVMaybe (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (Kind -> Kind
KMaybe Kind
k) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"))"
show Op
MaybeAccess = String
"get_just_SBVMaybe"
show Op
op
| Just String
s <- Op
op Op -> [(Op, String)] -> Maybe String
forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup` [(Op, String)]
syms = String
s
| Bool
True = ShowS
forall a. HasCallStack => String -> a
error String
"impossible happened; can't find op!"
where syms :: [(Op, String)]
syms = [ (Op
Plus, String
"+"), (Op
Times, String
"*"), (Op
Minus, String
"-"), (Op
UNeg, String
"-"), (Op
Abs, String
"abs")
, (Op
Quot, String
"quot")
, (Op
Rem, String
"rem")
, (Op
Equal, String
"=="), (Op
NotEqual, String
"/=")
, (Op
LessThan, String
"<"), (Op
GreaterThan, String
">"), (Op
LessEq, String
"<="), (Op
GreaterEq, String
">=")
, (Op
Ite, String
"if_then_else")
, (Op
And, String
"&"), (Op
Or, String
"|"), (Op
XOr, String
"^"), (Op
Not, String
"~")
, (Op
Join, String
"#")
]
data Quantifier = ALL | EX deriving Quantifier -> Quantifier -> Bool
(Quantifier -> Quantifier -> Bool)
-> (Quantifier -> Quantifier -> Bool) -> Eq Quantifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Quantifier -> Quantifier -> Bool
$c/= :: Quantifier -> Quantifier -> Bool
== :: Quantifier -> Quantifier -> Bool
$c== :: Quantifier -> Quantifier -> Bool
Eq
instance Show Quantifier where
show :: Quantifier -> String
show Quantifier
ALL = String
"Forall"
show Quantifier
EX = String
"Exists"
data VarContext = NonQueryVar (Maybe Quantifier)
| QueryVar
needsExistentials :: [Quantifier] -> Bool
needsExistentials :: [Quantifier] -> Bool
needsExistentials = (Quantifier
EX Quantifier -> [Quantifier] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem`)
newtype SBVType = SBVType [Kind]
deriving (SBVType -> SBVType -> Bool
(SBVType -> SBVType -> Bool)
-> (SBVType -> SBVType -> Bool) -> Eq SBVType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SBVType -> SBVType -> Bool
$c/= :: SBVType -> SBVType -> Bool
== :: SBVType -> SBVType -> Bool
$c== :: SBVType -> SBVType -> Bool
Eq, Eq SBVType
Eq SBVType
-> (SBVType -> SBVType -> Ordering)
-> (SBVType -> SBVType -> Bool)
-> (SBVType -> SBVType -> Bool)
-> (SBVType -> SBVType -> Bool)
-> (SBVType -> SBVType -> Bool)
-> (SBVType -> SBVType -> SBVType)
-> (SBVType -> SBVType -> SBVType)
-> Ord SBVType
SBVType -> SBVType -> Bool
SBVType -> SBVType -> Ordering
SBVType -> SBVType -> SBVType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SBVType -> SBVType -> SBVType
$cmin :: SBVType -> SBVType -> SBVType
max :: SBVType -> SBVType -> SBVType
$cmax :: SBVType -> SBVType -> SBVType
>= :: SBVType -> SBVType -> Bool
$c>= :: SBVType -> SBVType -> Bool
> :: SBVType -> SBVType -> Bool
$c> :: SBVType -> SBVType -> Bool
<= :: SBVType -> SBVType -> Bool
$c<= :: SBVType -> SBVType -> Bool
< :: SBVType -> SBVType -> Bool
$c< :: SBVType -> SBVType -> Bool
compare :: SBVType -> SBVType -> Ordering
$ccompare :: SBVType -> SBVType -> Ordering
$cp1Ord :: Eq SBVType
Ord)
instance Show SBVType where
show :: SBVType -> String
show (SBVType []) = ShowS
forall a. HasCallStack => String -> a
error String
"SBV: internal error, empty SBVType"
show (SBVType [Kind]
xs) = String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" -> " ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ (Kind -> String) -> [Kind] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Kind -> String
forall a. Show a => a -> String
show [Kind]
xs
data SBVExpr = SBVApp !Op ![SV]
deriving (SBVExpr -> SBVExpr -> Bool
(SBVExpr -> SBVExpr -> Bool)
-> (SBVExpr -> SBVExpr -> Bool) -> Eq SBVExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SBVExpr -> SBVExpr -> Bool
$c/= :: SBVExpr -> SBVExpr -> Bool
== :: SBVExpr -> SBVExpr -> Bool
$c== :: SBVExpr -> SBVExpr -> Bool
Eq, Eq SBVExpr
Eq SBVExpr
-> (SBVExpr -> SBVExpr -> Ordering)
-> (SBVExpr -> SBVExpr -> Bool)
-> (SBVExpr -> SBVExpr -> Bool)
-> (SBVExpr -> SBVExpr -> Bool)
-> (SBVExpr -> SBVExpr -> Bool)
-> (SBVExpr -> SBVExpr -> SBVExpr)
-> (SBVExpr -> SBVExpr -> SBVExpr)
-> Ord SBVExpr
SBVExpr -> SBVExpr -> Bool
SBVExpr -> SBVExpr -> Ordering
SBVExpr -> SBVExpr -> SBVExpr
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SBVExpr -> SBVExpr -> SBVExpr
$cmin :: SBVExpr -> SBVExpr -> SBVExpr
max :: SBVExpr -> SBVExpr -> SBVExpr
$cmax :: SBVExpr -> SBVExpr -> SBVExpr
>= :: SBVExpr -> SBVExpr -> Bool
$c>= :: SBVExpr -> SBVExpr -> Bool
> :: SBVExpr -> SBVExpr -> Bool
$c> :: SBVExpr -> SBVExpr -> Bool
<= :: SBVExpr -> SBVExpr -> Bool
$c<= :: SBVExpr -> SBVExpr -> Bool
< :: SBVExpr -> SBVExpr -> Bool
$c< :: SBVExpr -> SBVExpr -> Bool
compare :: SBVExpr -> SBVExpr -> Ordering
$ccompare :: SBVExpr -> SBVExpr -> Ordering
$cp1Ord :: Eq SBVExpr
Ord, Typeable SBVExpr
DataType
Constr
Typeable SBVExpr
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SBVExpr -> c SBVExpr)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SBVExpr)
-> (SBVExpr -> Constr)
-> (SBVExpr -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SBVExpr))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SBVExpr))
-> ((forall b. Data b => b -> b) -> SBVExpr -> SBVExpr)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r)
-> (forall u. (forall d. Data d => d -> u) -> SBVExpr -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SBVExpr -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr)
-> Data SBVExpr
SBVExpr -> DataType
SBVExpr -> Constr
(forall b. Data b => b -> b) -> SBVExpr -> SBVExpr
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SBVExpr -> c SBVExpr
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SBVExpr
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SBVExpr -> u
forall u. (forall d. Data d => d -> u) -> SBVExpr -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SBVExpr
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SBVExpr -> c SBVExpr
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SBVExpr)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SBVExpr)
$cSBVApp :: Constr
$tSBVExpr :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
gmapMp :: (forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
gmapM :: (forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SBVExpr -> m SBVExpr
gmapQi :: Int -> (forall d. Data d => d -> u) -> SBVExpr -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SBVExpr -> u
gmapQ :: (forall d. Data d => d -> u) -> SBVExpr -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SBVExpr -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SBVExpr -> r
gmapT :: (forall b. Data b => b -> b) -> SBVExpr -> SBVExpr
$cgmapT :: (forall b. Data b => b -> b) -> SBVExpr -> SBVExpr
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SBVExpr)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SBVExpr)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SBVExpr)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SBVExpr)
dataTypeOf :: SBVExpr -> DataType
$cdataTypeOf :: SBVExpr -> DataType
toConstr :: SBVExpr -> Constr
$ctoConstr :: SBVExpr -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SBVExpr
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SBVExpr
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SBVExpr -> c SBVExpr
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SBVExpr -> c SBVExpr
$cp1Data :: Typeable SBVExpr
G.Data)
reorder :: SBVExpr -> SBVExpr
reorder :: SBVExpr -> SBVExpr
reorder SBVExpr
s = case SBVExpr
s of
SBVApp Op
op [SV
a, SV
b] | Op -> Bool
isCommutative Op
op Bool -> Bool -> Bool
&& SV
a SV -> SV -> Bool
forall a. Ord a => a -> a -> Bool
> SV
b -> Op -> [SV] -> SBVExpr
SBVApp Op
op [SV
b, SV
a]
SBVExpr
_ -> SBVExpr
s
where isCommutative :: Op -> Bool
isCommutative :: Op -> Bool
isCommutative Op
o = Op
o Op -> [Op] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Op
Plus, Op
Times, Op
Equal, Op
NotEqual, Op
And, Op
Or, Op
XOr]
instance Show SBVExpr where
show :: SBVExpr -> String
show (SBVApp Op
Ite [SV
t, SV
a, SV
b]) = [String] -> String
unwords [String
"if", SV -> String
forall a. Show a => a -> String
show SV
t, String
"then", SV -> String
forall a. Show a => a -> String
show SV
a, String
"else", SV -> String
forall a. Show a => a -> String
show SV
b]
show (SBVApp Op
Shl [SV
a, SV
i]) = [String] -> String
unwords [SV -> String
forall a. Show a => a -> String
show SV
a, String
"<<", SV -> String
forall a. Show a => a -> String
show SV
i]
show (SBVApp Op
Shr [SV
a, SV
i]) = [String] -> String
unwords [SV -> String
forall a. Show a => a -> String
show SV
a, String
">>", SV -> String
forall a. Show a => a -> String
show SV
i]
show (SBVApp (Rol Int
i) [SV
a]) = [String] -> String
unwords [SV -> String
forall a. Show a => a -> String
show SV
a, String
"<<<", Int -> String
forall a. Show a => a -> String
show Int
i]
show (SBVApp (Ror Int
i) [SV
a]) = [String] -> String
unwords [SV -> String
forall a. Show a => a -> String
show SV
a, String
">>>", Int -> String
forall a. Show a => a -> String
show Int
i]
show (SBVApp (PseudoBoolean PBOp
pb) [SV]
args) = [String] -> String
unwords (PBOp -> String
forall a. Show a => a -> String
show PBOp
pb String -> [String] -> [String]
forall a. a -> [a] -> [a]
: (SV -> String) -> [SV] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map SV -> String
forall a. Show a => a -> String
show [SV]
args)
show (SBVApp (OverflowOp OvOp
op) [SV]
args) = [String] -> String
unwords (OvOp -> String
forall a. Show a => a -> String
show OvOp
op String -> [String] -> [String]
forall a. a -> [a] -> [a]
: (SV -> String) -> [SV] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map SV -> String
forall a. Show a => a -> String
show [SV]
args)
show (SBVApp Op
op [SV
a, SV
b]) = [String] -> String
unwords [SV -> String
forall a. Show a => a -> String
show SV
a, Op -> String
forall a. Show a => a -> String
show Op
op, SV -> String
forall a. Show a => a -> String
show SV
b]
show (SBVApp Op
op [SV]
args) = [String] -> String
unwords (Op -> String
forall a. Show a => a -> String
show Op
op String -> [String] -> [String]
forall a. a -> [a] -> [a]
: (SV -> String) -> [SV] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map SV -> String
forall a. Show a => a -> String
show [SV]
args)
newtype SBVPgm = SBVPgm {SBVPgm -> Seq (SV, SBVExpr)
pgmAssignments :: S.Seq (SV, SBVExpr)}
type Name = T.Text
data NamedSymVar = NamedSymVar !SV !Name
deriving (Int -> NamedSymVar -> ShowS
[NamedSymVar] -> ShowS
NamedSymVar -> String
(Int -> NamedSymVar -> ShowS)
-> (NamedSymVar -> String)
-> ([NamedSymVar] -> ShowS)
-> Show NamedSymVar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NamedSymVar] -> ShowS
$cshowList :: [NamedSymVar] -> ShowS
show :: NamedSymVar -> String
$cshow :: NamedSymVar -> String
showsPrec :: Int -> NamedSymVar -> ShowS
$cshowsPrec :: Int -> NamedSymVar -> ShowS
Show,(forall x. NamedSymVar -> Rep NamedSymVar x)
-> (forall x. Rep NamedSymVar x -> NamedSymVar)
-> Generic NamedSymVar
forall x. Rep NamedSymVar x -> NamedSymVar
forall x. NamedSymVar -> Rep NamedSymVar x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NamedSymVar x -> NamedSymVar
$cfrom :: forall x. NamedSymVar -> Rep NamedSymVar x
Generic)
instance Eq NamedSymVar where
== :: NamedSymVar -> NamedSymVar -> Bool
(==) (NamedSymVar SV
l Name
_) (NamedSymVar SV
r Name
_) = SV
l SV -> SV -> Bool
forall a. Eq a => a -> a -> Bool
== SV
r
instance Ord NamedSymVar where
compare :: NamedSymVar -> NamedSymVar -> Ordering
compare (NamedSymVar SV
l Name
_) (NamedSymVar SV
r Name
_) = SV -> SV -> Ordering
forall a. Ord a => a -> a -> Ordering
compare SV
l SV
r
toNamedSV' :: SV -> String -> NamedSymVar
toNamedSV' :: SV -> String -> NamedSymVar
toNamedSV' SV
s = SV -> Name -> NamedSymVar
NamedSymVar SV
s (Name -> NamedSymVar) -> (String -> Name) -> String -> NamedSymVar
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Name
T.pack
toNamedSV :: SV -> Name -> NamedSymVar
toNamedSV :: SV -> Name -> NamedSymVar
toNamedSV = SV -> Name -> NamedSymVar
NamedSymVar
namedNodeId :: NamedSymVar -> NodeId
namedNodeId :: NamedSymVar -> NodeId
namedNodeId = SV -> NodeId
swNodeId (SV -> NodeId) -> (NamedSymVar -> SV) -> NamedSymVar -> NodeId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NamedSymVar -> SV
getSV
getSV :: NamedSymVar -> SV
getSV :: NamedSymVar -> SV
getSV (NamedSymVar SV
s Name
_) = SV
s
getUserName :: NamedSymVar -> Name
getUserName :: NamedSymVar -> Name
getUserName (NamedSymVar SV
_ Name
nm) = Name
nm
getUserName' :: NamedSymVar -> String
getUserName' :: NamedSymVar -> String
getUserName' = Name -> String
T.unpack (Name -> String) -> (NamedSymVar -> Name) -> NamedSymVar -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NamedSymVar -> Name
getUserName
data OptimizeStyle = Lexicographic
| Independent
| Pareto (Maybe Int)
deriving (OptimizeStyle -> OptimizeStyle -> Bool
(OptimizeStyle -> OptimizeStyle -> Bool)
-> (OptimizeStyle -> OptimizeStyle -> Bool) -> Eq OptimizeStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptimizeStyle -> OptimizeStyle -> Bool
$c/= :: OptimizeStyle -> OptimizeStyle -> Bool
== :: OptimizeStyle -> OptimizeStyle -> Bool
$c== :: OptimizeStyle -> OptimizeStyle -> Bool
Eq, Int -> OptimizeStyle -> ShowS
[OptimizeStyle] -> ShowS
OptimizeStyle -> String
(Int -> OptimizeStyle -> ShowS)
-> (OptimizeStyle -> String)
-> ([OptimizeStyle] -> ShowS)
-> Show OptimizeStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptimizeStyle] -> ShowS
$cshowList :: [OptimizeStyle] -> ShowS
show :: OptimizeStyle -> String
$cshow :: OptimizeStyle -> String
showsPrec :: Int -> OptimizeStyle -> ShowS
$cshowsPrec :: Int -> OptimizeStyle -> ShowS
Show)
data Penalty = DefaultPenalty
| Penalty Rational (Maybe String)
deriving Int -> Penalty -> ShowS
[Penalty] -> ShowS
Penalty -> String
(Int -> Penalty -> ShowS)
-> (Penalty -> String) -> ([Penalty] -> ShowS) -> Show Penalty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Penalty] -> ShowS
$cshowList :: [Penalty] -> ShowS
show :: Penalty -> String
$cshow :: Penalty -> String
showsPrec :: Int -> Penalty -> ShowS
$cshowsPrec :: Int -> Penalty -> ShowS
Show
data Objective a = Minimize String a
| Maximize String a
| AssertWithPenalty String a Penalty
deriving (Int -> Objective a -> ShowS
[Objective a] -> ShowS
Objective a -> String
(Int -> Objective a -> ShowS)
-> (Objective a -> String)
-> ([Objective a] -> ShowS)
-> Show (Objective a)
forall a. Show a => Int -> Objective a -> ShowS
forall a. Show a => [Objective a] -> ShowS
forall a. Show a => Objective a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Objective a] -> ShowS
$cshowList :: forall a. Show a => [Objective a] -> ShowS
show :: Objective a -> String
$cshow :: forall a. Show a => Objective a -> String
showsPrec :: Int -> Objective a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Objective a -> ShowS
Show, a -> Objective b -> Objective a
(a -> b) -> Objective a -> Objective b
(forall a b. (a -> b) -> Objective a -> Objective b)
-> (forall a b. a -> Objective b -> Objective a)
-> Functor Objective
forall a b. a -> Objective b -> Objective a
forall a b. (a -> b) -> Objective a -> Objective b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Objective b -> Objective a
$c<$ :: forall a b. a -> Objective b -> Objective a
fmap :: (a -> b) -> Objective a -> Objective b
$cfmap :: forall a b. (a -> b) -> Objective a -> Objective b
Functor)
objectiveName :: Objective a -> String
objectiveName :: Objective a -> String
objectiveName (Minimize String
s a
_) = String
s
objectiveName (Maximize String
s a
_) = String
s
objectiveName (AssertWithPenalty String
s a
_ Penalty
_) = String
s
data QueryState = QueryState { QueryState -> Maybe Int -> String -> IO String
queryAsk :: Maybe Int -> String -> IO String
, QueryState -> Maybe Int -> String -> IO ()
querySend :: Maybe Int -> String -> IO ()
, QueryState -> Maybe Int -> IO String
queryRetrieveResponse :: Maybe Int -> IO String
, QueryState -> SMTConfig
queryConfig :: SMTConfig
, QueryState -> IO ()
queryTerminate :: IO ()
, QueryState -> Maybe Int
queryTimeOutValue :: Maybe Int
, QueryState -> Int
queryAssertionStackDepth :: Int
}
class Monad m => MonadQuery m where
queryState :: m State
default queryState :: (MonadTrans t, MonadQuery m', m ~ t m') => m State
queryState = m' State -> t m' State
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m' State
forall (m :: * -> *). MonadQuery m => m State
queryState
instance MonadQuery m => MonadQuery (ExceptT e m)
instance MonadQuery m => MonadQuery (MaybeT m)
instance MonadQuery m => MonadQuery (ReaderT r m)
instance MonadQuery m => MonadQuery (SS.StateT s m)
instance MonadQuery m => MonadQuery (LS.StateT s m)
instance (MonadQuery m, Monoid w) => MonadQuery (SW.WriterT w m)
instance (MonadQuery m, Monoid w) => MonadQuery (LW.WriterT w m)
newtype QueryT m a = QueryT { QueryT m a -> ReaderT State m a
runQueryT :: ReaderT State m a }
deriving (Functor (QueryT m)
a -> QueryT m a
Functor (QueryT m)
-> (forall a. a -> QueryT m a)
-> (forall a b. QueryT m (a -> b) -> QueryT m a -> QueryT m b)
-> (forall a b c.
(a -> b -> c) -> QueryT m a -> QueryT m b -> QueryT m c)
-> (forall a b. QueryT m a -> QueryT m b -> QueryT m b)
-> (forall a b. QueryT m a -> QueryT m b -> QueryT m a)
-> Applicative (QueryT m)
QueryT m a -> QueryT m b -> QueryT m b
QueryT m a -> QueryT m b -> QueryT m a
QueryT m (a -> b) -> QueryT m a -> QueryT m b
(a -> b -> c) -> QueryT m a -> QueryT m b -> QueryT m c
forall a. a -> QueryT m a
forall a b. QueryT m a -> QueryT m b -> QueryT m a
forall a b. QueryT m a -> QueryT m b -> QueryT m b
forall a b. QueryT m (a -> b) -> QueryT m a -> QueryT m b
forall a b c.
(a -> b -> c) -> QueryT m a -> QueryT m b -> QueryT m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (QueryT m)
forall (m :: * -> *) a. Applicative m => a -> QueryT m a
forall (m :: * -> *) a b.
Applicative m =>
QueryT m a -> QueryT m b -> QueryT m a
forall (m :: * -> *) a b.
Applicative m =>
QueryT m a -> QueryT m b -> QueryT m b
forall (m :: * -> *) a b.
Applicative m =>
QueryT m (a -> b) -> QueryT m a -> QueryT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> QueryT m a -> QueryT m b -> QueryT m c
<* :: QueryT m a -> QueryT m b -> QueryT m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
QueryT m a -> QueryT m b -> QueryT m a
*> :: QueryT m a -> QueryT m b -> QueryT m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
QueryT m a -> QueryT m b -> QueryT m b
liftA2 :: (a -> b -> c) -> QueryT m a -> QueryT m b -> QueryT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> QueryT m a -> QueryT m b -> QueryT m c
<*> :: QueryT m (a -> b) -> QueryT m a -> QueryT m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
QueryT m (a -> b) -> QueryT m a -> QueryT m b
pure :: a -> QueryT m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> QueryT m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (QueryT m)
Applicative, a -> QueryT m b -> QueryT m a
(a -> b) -> QueryT m a -> QueryT m b
(forall a b. (a -> b) -> QueryT m a -> QueryT m b)
-> (forall a b. a -> QueryT m b -> QueryT m a)
-> Functor (QueryT m)
forall a b. a -> QueryT m b -> QueryT m a
forall a b. (a -> b) -> QueryT m a -> QueryT m b
forall (m :: * -> *) a b.
Functor m =>
a -> QueryT m b -> QueryT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> QueryT m a -> QueryT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> QueryT m b -> QueryT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> QueryT m b -> QueryT m a
fmap :: (a -> b) -> QueryT m a -> QueryT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> QueryT m a -> QueryT m b
Functor, Applicative (QueryT m)
a -> QueryT m a
Applicative (QueryT m)
-> (forall a b. QueryT m a -> (a -> QueryT m b) -> QueryT m b)
-> (forall a b. QueryT m a -> QueryT m b -> QueryT m b)
-> (forall a. a -> QueryT m a)
-> Monad (QueryT m)
QueryT m a -> (a -> QueryT m b) -> QueryT m b
QueryT m a -> QueryT m b -> QueryT m b
forall a. a -> QueryT m a
forall a b. QueryT m a -> QueryT m b -> QueryT m b
forall a b. QueryT m a -> (a -> QueryT m b) -> QueryT m b
forall (m :: * -> *). Monad m => Applicative (QueryT m)
forall (m :: * -> *) a. Monad m => a -> QueryT m a
forall (m :: * -> *) a b.
Monad m =>
QueryT m a -> QueryT m b -> QueryT m b
forall (m :: * -> *) a b.
Monad m =>
QueryT m a -> (a -> QueryT m b) -> QueryT m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> QueryT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> QueryT m a
>> :: QueryT m a -> QueryT m b -> QueryT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
QueryT m a -> QueryT m b -> QueryT m b
>>= :: QueryT m a -> (a -> QueryT m b) -> QueryT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
QueryT m a -> (a -> QueryT m b) -> QueryT m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (QueryT m)
Monad, Monad (QueryT m)
Monad (QueryT m)
-> (forall a. IO a -> QueryT m a) -> MonadIO (QueryT m)
IO a -> QueryT m a
forall a. IO a -> QueryT m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (QueryT m)
forall (m :: * -> *) a. MonadIO m => IO a -> QueryT m a
liftIO :: IO a -> QueryT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> QueryT m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (QueryT m)
MonadIO, m a -> QueryT m a
(forall (m :: * -> *) a. Monad m => m a -> QueryT m a)
-> MonadTrans QueryT
forall (m :: * -> *) a. Monad m => m a -> QueryT m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> QueryT m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> QueryT m a
MonadTrans,
MonadError e, MonadState s, MonadWriter w)
instance Monad m => MonadQuery (QueryT m) where
queryState :: QueryT m State
queryState = ReaderT State m State -> QueryT m State
forall (m :: * -> *) a. ReaderT State m a -> QueryT m a
QueryT ReaderT State m State
forall r (m :: * -> *). MonadReader r m => m r
ask
mapQueryT :: (ReaderT State m a -> ReaderT State n b) -> QueryT m a -> QueryT n b
mapQueryT :: (ReaderT State m a -> ReaderT State n b)
-> QueryT m a -> QueryT n b
mapQueryT ReaderT State m a -> ReaderT State n b
f = ReaderT State n b -> QueryT n b
forall (m :: * -> *) a. ReaderT State m a -> QueryT m a
QueryT (ReaderT State n b -> QueryT n b)
-> (QueryT m a -> ReaderT State n b) -> QueryT m a -> QueryT n b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReaderT State m a -> ReaderT State n b
f (ReaderT State m a -> ReaderT State n b)
-> (QueryT m a -> ReaderT State m a)
-> QueryT m a
-> ReaderT State n b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QueryT m a -> ReaderT State m a
forall (m :: * -> *) a. QueryT m a -> ReaderT State m a
runQueryT
{-# INLINE mapQueryT #-}
class Fresh m a where
fresh :: QueryT m a
class Queriable m a b | a -> b where
create :: QueryT m a
project :: a -> QueryT m b
embed :: b -> QueryT m a
instance MonadReader r m => MonadReader r (QueryT m) where
ask :: QueryT m r
ask = m r -> QueryT m r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m r
forall r (m :: * -> *). MonadReader r m => m r
ask
local :: (r -> r) -> QueryT m a -> QueryT m a
local r -> r
f = (ReaderT State m a -> ReaderT State m a)
-> QueryT m a -> QueryT m a
forall (m :: * -> *) a (n :: * -> *) b.
(ReaderT State m a -> ReaderT State n b)
-> QueryT m a -> QueryT n b
mapQueryT ((ReaderT State m a -> ReaderT State m a)
-> QueryT m a -> QueryT m a)
-> (ReaderT State m a -> ReaderT State m a)
-> QueryT m a
-> QueryT m a
forall a b. (a -> b) -> a -> b
$ (m a -> m a) -> ReaderT State m a -> ReaderT State m a
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT ((m a -> m a) -> ReaderT State m a -> ReaderT State m a)
-> (m a -> m a) -> ReaderT State m a -> ReaderT State m a
forall a b. (a -> b) -> a -> b
$ (r -> r) -> m a -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f
type Query = QueryT IO
instance MonadSymbolic Query where
symbolicEnv :: Query State
symbolicEnv = Query State
forall (m :: * -> *). MonadQuery m => m State
queryState
instance NFData OptimizeStyle where
rnf :: OptimizeStyle -> ()
rnf OptimizeStyle
x = OptimizeStyle
x OptimizeStyle -> () -> ()
`seq` ()
instance NFData Penalty where
rnf :: Penalty -> ()
rnf Penalty
DefaultPenalty = ()
rnf (Penalty Rational
p Maybe String
mbs) = Rational -> ()
forall a. NFData a => a -> ()
rnf Rational
p () -> () -> ()
`seq` Maybe String -> ()
forall a. NFData a => a -> ()
rnf Maybe String
mbs
instance NFData a => NFData (Objective a) where
rnf :: Objective a -> ()
rnf (Minimize String
s a
a) = String -> ()
forall a. NFData a => a -> ()
rnf String
s () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
a
rnf (Maximize String
s a
a) = String -> ()
forall a. NFData a => a -> ()
rnf String
s () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
a
rnf (AssertWithPenalty String
s a
a Penalty
p) = String -> ()
forall a. NFData a => a -> ()
rnf String
s () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
a () -> () -> ()
`seq` Penalty -> ()
forall a. NFData a => a -> ()
rnf Penalty
p
data Result = Result { Result -> Set Kind
reskinds :: Set.Set Kind
, Result -> [(String, CV)]
resTraces :: [(String, CV)]
, Result -> [(String, CV -> Bool, SV)]
resObservables :: [(String, CV -> Bool, SV)]
, Result -> [(String, [String])]
resUISegs :: [(String, [String])]
, Result -> ([(Quantifier, NamedSymVar)], [NamedSymVar])
resInputs :: ([(Quantifier, NamedSymVar)], [NamedSymVar])
, Result -> (CnstMap, [(SV, CV)])
resConsts :: (CnstMap, [(SV, CV)])
, Result -> [((Int, Kind, Kind), [SV])]
resTables :: [((Int, Kind, Kind), [SV])]
, Result -> [(Int, ArrayInfo)]
resArrays :: [(Int, ArrayInfo)]
, Result -> [(String, SBVType)]
resUIConsts :: [(String, SBVType)]
, Result -> [(String, [String])]
resAxioms :: [(String, [String])]
, Result -> SBVPgm
resAsgns :: SBVPgm
, Result -> Seq (Bool, [(String, String)], SV)
resConstraints :: S.Seq (Bool, [(String, String)], SV)
, Result -> [(String, Maybe CallStack, SV)]
resAssertions :: [(String, Maybe CallStack, SV)]
, Result -> [SV]
resOutputs :: [SV]
}
instance Show Result where
show :: Result -> String
show Result{resConsts :: Result -> (CnstMap, [(SV, CV)])
resConsts=(CnstMap
_, [(SV, CV)]
cs), resOutputs :: Result -> [SV]
resOutputs=[SV
r]}
| Just CV
c <- SV
r SV -> [(SV, CV)] -> Maybe CV
forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup` [(SV, CV)]
cs
= CV -> String
forall a. Show a => a -> String
show CV
c
show (Result Set Kind
kinds [(String, CV)]
_ [(String, CV -> Bool, SV)]
_ [(String, [String])]
cgs ([(Quantifier, NamedSymVar)], [NamedSymVar])
is (CnstMap
_, [(SV, CV)]
cs) [((Int, Kind, Kind), [SV])]
ts [(Int, ArrayInfo)]
as [(String, SBVType)]
uis [(String, [String])]
axs SBVPgm
xs Seq (Bool, [(String, String)], SV)
cstrs [(String, Maybe CallStack, SV)]
asserts [SV]
os) = String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"\n" ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$
(if [String] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
usorts then [] else String
"SORTS" String -> [String] -> [String]
forall a. a -> [a] -> [a]
: ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++) [String]
usorts)
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"INPUTS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((Quantifier, NamedSymVar) -> String)
-> [(Quantifier, NamedSymVar)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Quantifier, NamedSymVar) -> String
shn (([(Quantifier, NamedSymVar)], [NamedSymVar])
-> [(Quantifier, NamedSymVar)]
forall a b. (a, b) -> a
fst ([(Quantifier, NamedSymVar)], [NamedSymVar])
is)
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ (if [NamedSymVar] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (([(Quantifier, NamedSymVar)], [NamedSymVar]) -> [NamedSymVar]
forall a b. (a, b) -> b
snd ([(Quantifier, NamedSymVar)], [NamedSymVar])
is) then [] else String
"TRACKER VARS" String -> [String] -> [String]
forall a. a -> [a] -> [a]
: (NamedSymVar -> String) -> [NamedSymVar] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ((Quantifier, NamedSymVar) -> String
shn ((Quantifier, NamedSymVar) -> String)
-> (NamedSymVar -> (Quantifier, NamedSymVar))
-> NamedSymVar
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Quantifier
EX,)) (([(Quantifier, NamedSymVar)], [NamedSymVar]) -> [NamedSymVar]
forall a b. (a, b) -> b
snd ([(Quantifier, NamedSymVar)], [NamedSymVar])
is))
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"CONSTANTS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((SV, CV) -> [String]) -> [(SV, CV)] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SV, CV) -> [String]
forall a. Show a => (SV, a) -> [String]
shc [(SV, CV)]
cs
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"TABLES"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ (((Int, Kind, Kind), [SV]) -> String)
-> [((Int, Kind, Kind), [SV])] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ((Int, Kind, Kind), [SV]) -> String
forall a a a a.
(Show a, Show a, Show a, Show a) =>
((a, a, a), a) -> String
sht [((Int, Kind, Kind), [SV])]
ts
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"ARRAYS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((Int, ArrayInfo) -> String) -> [(Int, ArrayInfo)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Int, ArrayInfo) -> String
forall a a a a.
(Show a, Show a, Show a, Show a) =>
(a, (String, (a, a), a)) -> String
sha [(Int, ArrayInfo)]
as
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"UNINTERPRETED CONSTANTS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((String, SBVType) -> String) -> [(String, SBVType)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, SBVType) -> String
forall a. Show a => (String, a) -> String
shui [(String, SBVType)]
uis
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"USER GIVEN CODE SEGMENTS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((String, [String]) -> [String])
-> [(String, [String])] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (String, [String]) -> [String]
shcg [(String, [String])]
cgs
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"AXIOMS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((String, [String]) -> String) -> [(String, [String])] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, [String]) -> String
shax [(String, [String])]
axs
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"DEFINE"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((SV, SBVExpr) -> String) -> [(SV, SBVExpr)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (\(SV
s, SBVExpr
e) -> String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
shs SV
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBVExpr -> String
forall a. Show a => a -> String
show SBVExpr
e) (Seq (SV, SBVExpr) -> [(SV, SBVExpr)]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList (SBVPgm -> Seq (SV, SBVExpr)
pgmAssignments SBVPgm
xs))
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"CONSTRAINTS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((Bool, [(String, String)], SV) -> String)
-> [(Bool, [(String, String)], SV)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ((String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++) ShowS
-> ((Bool, [(String, String)], SV) -> String)
-> (Bool, [(String, String)], SV)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool, [(String, String)], SV) -> String
forall a a.
(Eq a, IsString a, Show a, Show a) =>
(Bool, [(a, String)], a) -> String
shCstr) (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)
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"ASSERTIONS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ ((String, Maybe CallStack, SV) -> String)
-> [(String, Maybe CallStack, SV)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ((String
" "String -> ShowS
forall a. [a] -> [a] -> [a]
++) ShowS
-> ((String, Maybe CallStack, SV) -> String)
-> (String, Maybe CallStack, SV)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, Maybe CallStack, SV) -> String
forall a. Show a => (String, Maybe CallStack, a) -> String
shAssert) [(String, Maybe CallStack, SV)]
asserts
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"OUTPUTS"]
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [SV] -> [String]
forall a. Show a => [a] -> [String]
sh2 [SV]
os
where sh2 :: Show a => [a] -> [String]
sh2 :: [a] -> [String]
sh2 = (a -> String) -> [a] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ((String
" "String -> ShowS
forall a. [a] -> [a] -> [a]
++) ShowS -> (a -> String) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show)
usorts :: [String]
usorts = [String -> Maybe [String] -> String
sh String
s Maybe [String]
t | KUserSort String
s Maybe [String]
t <- Set Kind -> [Kind]
forall a. Set a -> [a]
Set.toList Set Kind
kinds]
where sh :: String -> Maybe [String] -> String
sh String
s Maybe [String]
Nothing = String
s
sh String
s (Just [String]
es) = String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " [String]
es String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
shs :: SV -> String
shs SV
sv = SV -> String
forall a. Show a => a -> String
show SV
sv String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SV -> Kind
swKind SV
sv)
sht :: ((a, a, a), a) -> String
sht ((a
i, a
at, a
rt), a
es) = String
" Table " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
at String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"->" String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
rt String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
es
shc :: (SV, a) -> [String]
shc (SV
sv, a
cv)
| SV
sv SV -> SV -> Bool
forall a. Eq a => a -> a -> Bool
== SV
falseSV Bool -> Bool -> Bool
|| SV
sv SV -> SV -> Bool
forall a. Eq a => a -> a -> Bool
== SV
trueSV
= []
| Bool
True
= [String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
sv String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
cv]
shcg :: (String, [String]) -> [String]
shcg (String
s, [String]
ss) = (String
"Variable: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s) String -> [String] -> [String]
forall a. a -> [a] -> [a]
: ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++) [String]
ss
shn :: (Quantifier, NamedSymVar) -> String
shn (Quantifier
q, NamedSymVar SV
sv Name
nm) = String
" " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
ni String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SV -> Kind
swKind SV
sv) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
ex String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
alias
where ni :: String
ni = SV -> String
forall a. Show a => a -> String
show SV
sv
ex :: String
ex | Quantifier
q Quantifier -> Quantifier -> Bool
forall a. Eq a => a -> a -> Bool
== Quantifier
ALL = String
""
| Bool
True = String
", existential"
alias :: String
alias | String
ni String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== Name -> String
T.unpack Name
nm = String
""
| Bool
True = String
", aliasing " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Name -> String
forall a. Show a => a -> String
show Name
nm
sha :: (a, (String, (a, a), a)) -> String
sha (a
i, (String
nm, (a
ai, a
bi), a
ctx)) = String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
ni String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
ai String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" -> " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
bi String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
alias
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\n Context: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
ctx
where ni :: String
ni = String
"array_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
i
alias :: String
alias | String
ni String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
nm = String
""
| Bool
True = String
", aliasing " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
nm
shui :: (String, a) -> String
shui (String
nm, a
t) = String
" [uninterpreted] " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
t
shax :: (String, [String]) -> String
shax (String
nm, [String]
ss) = String
" -- user defined axiom: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\n " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"\n " [String]
ss
shCstr :: (Bool, [(a, String)], a) -> String
shCstr (Bool
isSoft, [], a
c) = Bool -> String
forall p. IsString p => Bool -> p
soft Bool
isSoft String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
c
shCstr (Bool
isSoft, [(a
":named", String
nm)], a
c) = Bool -> String
forall p. IsString p => Bool -> p
soft Bool
isSoft String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
c
shCstr (Bool
isSoft, [(a, String)]
attrs, a
c) = Bool -> String
forall p. IsString p => Bool -> p
soft Bool
isSoft String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
c String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" (attributes: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [(a, String)] -> String
forall a. Show a => a -> String
show [(a, String)]
attrs String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
soft :: Bool -> p
soft Bool
True = p
"[SOFT] "
soft Bool
False = p
""
shAssert :: (String, Maybe CallStack, a) -> String
shAssert (String
nm, Maybe CallStack
stk, a
p) = String
" -- assertion: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> (CallStack -> String) -> Maybe CallStack -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"[No location]"
#if MIN_VERSION_base(4,9,0)
CallStack -> String
prettyCallStack
#else
showCallStack
#endif
Maybe CallStack
stk String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show a
p
data ArrayContext = ArrayFree (Maybe SV)
| ArrayMutate ArrayIndex SV SV
| ArrayMerge SV ArrayIndex ArrayIndex
instance Show ArrayContext where
show :: ArrayContext -> String
show (ArrayFree Maybe SV
Nothing) = String
" initialized with random elements"
show (ArrayFree (Just SV
sv)) = String
" initialized with " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
sv
show (ArrayMutate ArrayIndex
i SV
a SV
b) = String
" cloned from array_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ ArrayIndex -> String
forall a. Show a => a -> String
show ArrayIndex
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" with " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
a String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SV -> Kind
swKind SV
a) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" |-> " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
b String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show (SV -> Kind
swKind SV
b)
show (ArrayMerge SV
s ArrayIndex
i ArrayIndex
j) = String
" merged arrays " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ArrayIndex -> String
forall a. Show a => a -> String
show ArrayIndex
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" and " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ArrayIndex -> String
forall a. Show a => a -> String
show ArrayIndex
j String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" on condition " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
s
type ExprMap = Map.Map SBVExpr SV
type CnstMap = Map.Map CV SV
type KindSet = Set.Set Kind
type TableMap = Map.Map (Kind, Kind, [SV]) Int
type ArrayInfo = (String, (Kind, Kind), ArrayContext)
type ArrayMap = IMap.IntMap ArrayInfo
type FArrayMap = IMap.IntMap (SVal -> SVal, IORef (IMap.IntMap SV))
type UIMap = Map.Map String SBVType
type CgMap = Map.Map String [String]
type Cache a = IMap.IntMap [(StableName (State -> IO a), a)]
data IStage = ISetup
| ISafe
| IRun
isSafetyCheckingIStage :: IStage -> Bool
isSafetyCheckingIStage :: IStage -> Bool
isSafetyCheckingIStage IStage
s = case IStage
s of
IStage
ISetup -> Bool
False
IStage
ISafe -> Bool
True
IStage
IRun -> Bool
False
isSetupIStage :: IStage -> Bool
isSetupIStage :: IStage -> Bool
isSetupIStage IStage
s = case IStage
s of
IStage
ISetup -> Bool
True
IStage
ISafe -> Bool
False
IStage
IRun -> Bool
True
isRunIStage :: IStage -> Bool
isRunIStage :: IStage -> Bool
isRunIStage IStage
s = case IStage
s of
IStage
ISetup -> Bool
False
IStage
ISafe -> Bool
False
IStage
IRun -> Bool
True
data SBVRunMode = SMTMode QueryContext IStage Bool SMTConfig
| CodeGen
| Concrete (Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)]))
instance Show SBVRunMode where
show :: SBVRunMode -> String
show (SMTMode QueryContext
qc IStage
ISetup Bool
True SMTConfig
_) = String
"Satisfiability setup (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QueryContext -> String
forall a. Show a => a -> String
show QueryContext
qc String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (SMTMode QueryContext
qc IStage
ISafe Bool
True SMTConfig
_) = String
"Safety setup (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QueryContext -> String
forall a. Show a => a -> String
show QueryContext
qc String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (SMTMode QueryContext
qc IStage
IRun Bool
True SMTConfig
_) = String
"Satisfiability (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QueryContext -> String
forall a. Show a => a -> String
show QueryContext
qc String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (SMTMode QueryContext
qc IStage
ISetup Bool
False SMTConfig
_) = String
"Proof setup (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QueryContext -> String
forall a. Show a => a -> String
show QueryContext
qc String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (SMTMode QueryContext
qc IStage
ISafe Bool
False SMTConfig
_) = ShowS
forall a. HasCallStack => String -> a
error ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
"ISafe-False is not an expected/supported combination for SBVRunMode! (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QueryContext -> String
forall a. Show a => a -> String
show QueryContext
qc String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show (SMTMode QueryContext
qc IStage
IRun Bool
False SMTConfig
_) = String
"Proof (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QueryContext -> String
forall a. Show a => a -> String
show QueryContext
qc String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
show SBVRunMode
CodeGen = String
"Code generation"
show (Concrete Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)])
Nothing) = String
"Concrete evaluation with random values"
show (Concrete (Just (Bool
True, [((Quantifier, NamedSymVar), Maybe CV)]
_))) = String
"Concrete evaluation during model validation for sat"
show (Concrete (Just (Bool
False, [((Quantifier, NamedSymVar), Maybe CV)]
_))) = String
"Concrete evaluation during model validation for prove"
isCodeGenMode :: State -> IO Bool
isCodeGenMode :: State -> IO Bool
isCodeGenMode State{IORef SBVRunMode
runMode :: State -> IORef SBVRunMode
runMode :: IORef SBVRunMode
runMode} = do SBVRunMode
rm <- IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef IORef SBVRunMode
runMode
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> IO Bool) -> Bool -> IO Bool
forall a b. (a -> b) -> a -> b
$ case SBVRunMode
rm of
Concrete{} -> Bool
False
SMTMode{} -> Bool
False
SBVRunMode
CodeGen -> Bool
True
data IncState = IncState { IncState -> IORef [NamedSymVar]
rNewInps :: IORef [NamedSymVar]
, IncState -> IORef (Set Kind)
rNewKinds :: IORef KindSet
, IncState -> IORef CnstMap
rNewConsts :: IORef CnstMap
, IncState -> IORef ArrayMap
rNewArrs :: IORef ArrayMap
, IncState -> IORef TableMap
rNewTbls :: IORef TableMap
, IncState -> IORef UIMap
rNewUIs :: IORef UIMap
, IncState -> IORef SBVPgm
rNewAsgns :: IORef SBVPgm
, IncState -> IORef (Seq (Bool, [(String, String)], SV))
rNewConstraints :: IORef (S.Seq (Bool, [(String, String)], SV))
}
newIncState :: IO IncState
newIncState :: IO IncState
newIncState = do
IORef [NamedSymVar]
is <- [NamedSymVar] -> IO (IORef [NamedSymVar])
forall a. a -> IO (IORef a)
newIORef []
IORef (Set Kind)
ks <- Set Kind -> IO (IORef (Set Kind))
forall a. a -> IO (IORef a)
newIORef Set Kind
forall a. Set a
Set.empty
IORef CnstMap
nc <- CnstMap -> IO (IORef CnstMap)
forall a. a -> IO (IORef a)
newIORef CnstMap
forall k a. Map k a
Map.empty
IORef ArrayMap
am <- ArrayMap -> IO (IORef ArrayMap)
forall a. a -> IO (IORef a)
newIORef ArrayMap
forall a. IntMap a
IMap.empty
IORef TableMap
tm <- TableMap -> IO (IORef TableMap)
forall a. a -> IO (IORef a)
newIORef TableMap
forall k a. Map k a
Map.empty
IORef UIMap
ui <- UIMap -> IO (IORef UIMap)
forall a. a -> IO (IORef a)
newIORef UIMap
forall k a. Map k a
Map.empty
IORef SBVPgm
pgm <- SBVPgm -> IO (IORef SBVPgm)
forall a. a -> IO (IORef a)
newIORef (Seq (SV, SBVExpr) -> SBVPgm
SBVPgm Seq (SV, SBVExpr)
forall a. Seq a
S.empty)
IORef (Seq (Bool, [(String, String)], SV))
cstrs <- Seq (Bool, [(String, String)], SV)
-> IO (IORef (Seq (Bool, [(String, String)], SV)))
forall a. a -> IO (IORef a)
newIORef Seq (Bool, [(String, String)], SV)
forall a. Seq a
S.empty
IncState -> IO IncState
forall (m :: * -> *) a. Monad m => a -> m a
return IncState :: IORef [NamedSymVar]
-> IORef (Set Kind)
-> IORef CnstMap
-> IORef ArrayMap
-> IORef TableMap
-> IORef UIMap
-> IORef SBVPgm
-> IORef (Seq (Bool, [(String, String)], SV))
-> IncState
IncState { rNewInps :: IORef [NamedSymVar]
rNewInps = IORef [NamedSymVar]
is
, rNewKinds :: IORef (Set Kind)
rNewKinds = IORef (Set Kind)
ks
, rNewConsts :: IORef CnstMap
rNewConsts = IORef CnstMap
nc
, rNewArrs :: IORef ArrayMap
rNewArrs = IORef ArrayMap
am
, rNewTbls :: IORef TableMap
rNewTbls = IORef TableMap
tm
, rNewUIs :: IORef UIMap
rNewUIs = IORef UIMap
ui
, rNewAsgns :: IORef SBVPgm
rNewAsgns = IORef SBVPgm
pgm
, rNewConstraints :: IORef (Seq (Bool, [(String, String)], SV))
rNewConstraints = IORef (Seq (Bool, [(String, String)], SV))
cstrs
}
withNewIncState :: State -> (State -> IO a) -> IO (IncState, a)
withNewIncState :: State -> (State -> IO a) -> IO (IncState, a)
withNewIncState State
st State -> IO a
cont = do
IncState
is <- IO IncState
newIncState
IORef IncState -> (IncState -> IncState) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
R.modifyIORef' (State -> IORef IncState
rIncState State
st) (IncState -> IncState -> IncState
forall a b. a -> b -> a
const IncState
is)
a
r <- State -> IO a
cont State
st
IncState
finalIncState <- IORef IncState -> IO IncState
forall a. IORef a -> IO a
readIORef (State -> IORef IncState
rIncState State
st)
(IncState, a) -> IO (IncState, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (IncState
finalIncState, a
r)
type UserInputs = S.Seq (Quantifier, NamedSymVar)
type InternInps = S.Seq NamedSymVar
type AllInps = Set.Set Name
data Inputs = Inputs { Inputs -> UserInputs
userInputs :: !UserInputs
, Inputs -> InternInps
internInputs :: !InternInps
, Inputs -> AllInps
allInputs :: !AllInps
} deriving (Inputs -> Inputs -> Bool
(Inputs -> Inputs -> Bool)
-> (Inputs -> Inputs -> Bool) -> Eq Inputs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Inputs -> Inputs -> Bool
$c/= :: Inputs -> Inputs -> Bool
== :: Inputs -> Inputs -> Bool
$c== :: Inputs -> Inputs -> Bool
Eq,Int -> Inputs -> ShowS
[Inputs] -> ShowS
Inputs -> String
(Int -> Inputs -> ShowS)
-> (Inputs -> String) -> ([Inputs] -> ShowS) -> Show Inputs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Inputs] -> ShowS
$cshowList :: [Inputs] -> ShowS
show :: Inputs -> String
$cshow :: Inputs -> String
showsPrec :: Int -> Inputs -> ShowS
$cshowsPrec :: Int -> Inputs -> ShowS
Show)
instance Semigroup Inputs where
(Inputs UserInputs
lui InternInps
lii AllInps
lai) <> :: Inputs -> Inputs -> Inputs
<> (Inputs UserInputs
rui InternInps
rii AllInps
rai) = UserInputs -> InternInps -> AllInps -> Inputs
Inputs (UserInputs
lui UserInputs -> UserInputs -> UserInputs
forall a. Semigroup a => a -> a -> a
<> UserInputs
rui) (InternInps
lii InternInps -> InternInps -> InternInps
forall a. Semigroup a => a -> a -> a
<> InternInps
rii) (AllInps
lai AllInps -> AllInps -> AllInps
forall a. Semigroup a => a -> a -> a
<> AllInps
rai)
instance Monoid Inputs where
mempty :: Inputs
mempty = Inputs :: UserInputs -> InternInps -> AllInps -> Inputs
Inputs { userInputs :: UserInputs
userInputs = UserInputs
forall a. Monoid a => a
mempty
, internInputs :: InternInps
internInputs = InternInps
forall a. Monoid a => a
mempty
, allInputs :: AllInps
allInputs = AllInps
forall a. Monoid a => a
mempty
}
quantifier :: (Quantifier, NamedSymVar) -> Quantifier
quantifier :: (Quantifier, NamedSymVar) -> Quantifier
quantifier = (Quantifier, NamedSymVar) -> Quantifier
forall a b. (a, b) -> a
fst
namedSymVar :: (Quantifier, NamedSymVar) -> NamedSymVar
namedSymVar :: (Quantifier, NamedSymVar) -> NamedSymVar
namedSymVar = (Quantifier, NamedSymVar) -> NamedSymVar
forall a b. (a, b) -> b
snd
onUserInputs :: (UserInputs -> UserInputs) -> Inputs -> Inputs
onUserInputs :: (UserInputs -> UserInputs) -> Inputs -> Inputs
onUserInputs UserInputs -> UserInputs
f inp :: Inputs
inp@Inputs{UserInputs
userInputs :: UserInputs
userInputs :: Inputs -> UserInputs
userInputs} = Inputs
inp{userInputs :: UserInputs
userInputs = UserInputs -> UserInputs
f UserInputs
userInputs}
onInternInputs :: (InternInps -> InternInps) -> Inputs -> Inputs
onInternInputs :: (InternInps -> InternInps) -> Inputs -> Inputs
onInternInputs InternInps -> InternInps
f inp :: Inputs
inp@Inputs{InternInps
internInputs :: InternInps
internInputs :: Inputs -> InternInps
internInputs} = Inputs
inp{internInputs :: InternInps
internInputs = InternInps -> InternInps
f InternInps
internInputs}
onAllInputs :: (AllInps -> AllInps) -> Inputs -> Inputs
onAllInputs :: (AllInps -> AllInps) -> Inputs -> Inputs
onAllInputs AllInps -> AllInps
f inp :: Inputs
inp@Inputs{AllInps
allInputs :: AllInps
allInputs :: Inputs -> AllInps
allInputs} = Inputs
inp{allInputs :: AllInps
allInputs = AllInps -> AllInps
f AllInps
allInputs}
addInternInput :: SV -> Name -> Inputs -> Inputs
addInternInput :: SV -> Name -> Inputs -> Inputs
addInternInput SV
sv Name
nm = Inputs -> Inputs
goAll (Inputs -> Inputs) -> (Inputs -> Inputs) -> Inputs -> Inputs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inputs -> Inputs
goIntern
where !new :: NamedSymVar
new = SV -> Name -> NamedSymVar
toNamedSV SV
sv Name
nm
goIntern :: Inputs -> Inputs
goIntern = (InternInps -> InternInps) -> Inputs -> Inputs
onInternInputs (InternInps -> NamedSymVar -> InternInps
forall a. Seq a -> a -> Seq a
S.|> NamedSymVar
new)
goAll :: Inputs -> Inputs
goAll = (AllInps -> AllInps) -> Inputs -> Inputs
onAllInputs (Name -> AllInps -> AllInps
forall a. Ord a => a -> Set a -> Set a
Set.insert Name
nm)
addUserInput :: Quantifier -> SV -> Name -> Inputs -> Inputs
addUserInput :: Quantifier -> SV -> Name -> Inputs -> Inputs
addUserInput Quantifier
q SV
sv Name
nm = Inputs -> Inputs
goAll (Inputs -> Inputs) -> (Inputs -> Inputs) -> Inputs -> Inputs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inputs -> Inputs
goUser
where new :: NamedSymVar
new = SV -> Name -> NamedSymVar
toNamedSV SV
sv Name
nm
goUser :: Inputs -> Inputs
goUser = (UserInputs -> UserInputs) -> Inputs -> Inputs
onUserInputs (UserInputs -> (Quantifier, NamedSymVar) -> UserInputs
forall a. Seq a -> a -> Seq a
S.|> (Quantifier
q, NamedSymVar
new))
goAll :: Inputs -> Inputs
goAll = (AllInps -> AllInps) -> Inputs -> Inputs
onAllInputs (Name -> AllInps -> AllInps
forall a. Ord a => a -> Set a -> Set a
Set.insert Name
nm)
getInputs :: Inputs -> (UserInputs, InternInps)
getInputs :: Inputs -> (UserInputs, InternInps)
getInputs Inputs{UserInputs
userInputs :: UserInputs
userInputs :: Inputs -> UserInputs
userInputs, InternInps
internInputs :: InternInps
internInputs :: Inputs -> InternInps
internInputs} = (UserInputs
userInputs, InternInps
internInputs)
lookupInput :: Eq a => (a -> SV) -> SV -> S.Seq a -> Maybe a
lookupInput :: (a -> SV) -> SV -> Seq a -> Maybe a
lookupInput a -> SV
f SV
sv Seq a
ns = Maybe a
res
where
i :: Int
i = NodeId -> Int
getId (SV -> NodeId
swNodeId SV
sv)
svs :: Seq SV
svs = (a -> SV) -> Seq a -> Seq SV
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> SV
f Seq a
ns
res :: Maybe a
res = case Int -> Seq a -> Maybe a
forall a. Int -> Seq a -> Maybe a
S.lookup Int
i Seq a
ns of
Maybe a
Nothing -> Maybe a
secondLookup
x :: Maybe a
x@(Just a
e) -> if SV
sv SV -> SV -> Bool
forall a. Eq a => a -> a -> Bool
== a -> SV
f a
e then Maybe a
x else Maybe a
secondLookup
secondLookup :: Maybe a
secondLookup = SV -> Seq SV -> Maybe Int
forall a. Eq a => a -> Seq a -> Maybe Int
S.elemIndexL SV
sv Seq SV
svs Maybe Int -> (Int -> Maybe a) -> Maybe a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Int -> Seq a -> Maybe a) -> Seq a -> Int -> Maybe a
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> Seq a -> Maybe a
forall a. Int -> Seq a -> Maybe a
S.lookup Seq a
ns
getUniversals :: UserInputs -> S.Seq NamedSymVar
getUniversals :: UserInputs -> InternInps
getUniversals = ((Quantifier, NamedSymVar) -> NamedSymVar)
-> UserInputs -> InternInps
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Quantifier, NamedSymVar) -> NamedSymVar
namedSymVar (UserInputs -> InternInps)
-> (UserInputs -> UserInputs) -> UserInputs -> InternInps
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Quantifier, NamedSymVar) -> Bool) -> UserInputs -> UserInputs
forall a. (a -> Bool) -> Seq a -> Seq a
S.filter ((Quantifier -> Quantifier -> Bool
forall a. Eq a => a -> a -> Bool
== Quantifier
ALL) (Quantifier -> Bool)
-> ((Quantifier, NamedSymVar) -> Quantifier)
-> (Quantifier, NamedSymVar)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Quantifier, NamedSymVar) -> Quantifier
quantifier)
userInpsPrefixBy :: ((Quantifier, NamedSymVar) -> Bool) -> UserInputs -> UserInputs
userInpsPrefixBy :: ((Quantifier, NamedSymVar) -> Bool) -> UserInputs -> UserInputs
userInpsPrefixBy = ((Quantifier, NamedSymVar) -> Bool) -> UserInputs -> UserInputs
forall a. (a -> Bool) -> Seq a -> Seq a
S.takeWhileL
prefixExistentials :: UserInputs -> UserInputs
prefixExistentials :: UserInputs -> UserInputs
prefixExistentials = ((Quantifier, NamedSymVar) -> Bool) -> UserInputs -> UserInputs
userInpsPrefixBy ((Quantifier -> Quantifier -> Bool
forall a. Eq a => a -> a -> Bool
/= Quantifier
ALL) (Quantifier -> Bool)
-> ((Quantifier, NamedSymVar) -> Quantifier)
-> (Quantifier, NamedSymVar)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Quantifier, NamedSymVar) -> Quantifier
quantifier)
prefixUniversals :: UserInputs -> UserInputs
prefixUniversals :: UserInputs -> UserInputs
prefixUniversals = ((Quantifier, NamedSymVar) -> Bool) -> UserInputs -> UserInputs
userInpsPrefixBy ((Quantifier -> Quantifier -> Bool
forall a. Eq a => a -> a -> Bool
== Quantifier
ALL) (Quantifier -> Bool)
-> ((Quantifier, NamedSymVar) -> Quantifier)
-> (Quantifier, NamedSymVar)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Quantifier, NamedSymVar) -> Quantifier
quantifier)
inputsFromListWith :: (NamedSymVar -> Quantifier) -> [NamedSymVar] -> UserInputs
inputsFromListWith :: (NamedSymVar -> Quantifier) -> [NamedSymVar] -> UserInputs
inputsFromListWith NamedSymVar -> Quantifier
f = [(Quantifier, NamedSymVar)] -> UserInputs
forall a. [a] -> Seq a
S.fromList ([(Quantifier, NamedSymVar)] -> UserInputs)
-> ([NamedSymVar] -> [(Quantifier, NamedSymVar)])
-> [NamedSymVar]
-> UserInputs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NamedSymVar -> (Quantifier, NamedSymVar))
-> [NamedSymVar] -> [(Quantifier, NamedSymVar)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NamedSymVar -> (Quantifier, NamedSymVar)
go
where go :: NamedSymVar -> (Quantifier, NamedSymVar)
go NamedSymVar
n = (NamedSymVar -> Quantifier
f NamedSymVar
n, NamedSymVar
n)
userInputsToList :: UserInputs -> [(Quantifier, NamedSymVar)]
userInputsToList :: UserInputs -> [(Quantifier, NamedSymVar)]
userInputsToList = UserInputs -> [(Quantifier, NamedSymVar)]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList
internInputsToList :: InternInps -> [NamedSymVar]
internInputsToList :: InternInps -> [NamedSymVar]
internInputsToList = InternInps -> [NamedSymVar]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList
inputsToList :: Inputs -> ([(Quantifier, NamedSymVar)], [NamedSymVar])
inputsToList :: Inputs -> ([(Quantifier, NamedSymVar)], [NamedSymVar])
inputsToList = (UserInputs -> [(Quantifier, NamedSymVar)]
userInputsToList (UserInputs -> [(Quantifier, NamedSymVar)])
-> (InternInps -> [NamedSymVar])
-> (UserInputs, InternInps)
-> ([(Quantifier, NamedSymVar)], [NamedSymVar])
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** InternInps -> [NamedSymVar]
internInputsToList) ((UserInputs, InternInps)
-> ([(Quantifier, NamedSymVar)], [NamedSymVar]))
-> (Inputs -> (UserInputs, InternInps))
-> Inputs
-> ([(Quantifier, NamedSymVar)], [NamedSymVar])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inputs -> (UserInputs, InternInps)
getInputs
data State = State { State -> SVal
pathCond :: SVal
, State -> UTCTime
startTime :: UTCTime
, State -> IORef SBVRunMode
runMode :: IORef SBVRunMode
, State -> IORef IncState
rIncState :: IORef IncState
, State -> IORef [(String, CV)]
rCInfo :: IORef [(String, CV)]
, State -> IORef (Seq (Name, CV -> Bool, SV))
rObservables :: IORef (S.Seq (Name, CV -> Bool, SV))
, State -> IORef Int
rctr :: IORef Int
, State -> IORef (Set Kind)
rUsedKinds :: IORef KindSet
, State -> IORef (Set String)
rUsedLbls :: IORef (Set.Set String)
, State -> IORef Inputs
rinps :: IORef Inputs
, State -> IORef (Seq (Bool, [(String, String)], SV))
rConstraints :: IORef (S.Seq (Bool, [(String, String)], SV))
, State -> IORef [SV]
routs :: IORef [SV]
, State -> IORef TableMap
rtblMap :: IORef TableMap
, State -> IORef SBVPgm
spgm :: IORef SBVPgm
, State -> IORef CnstMap
rconstMap :: IORef CnstMap
, State -> IORef ExprMap
rexprMap :: IORef ExprMap
, State -> IORef ArrayMap
rArrayMap :: IORef ArrayMap
, State -> IORef FArrayMap
rFArrayMap :: IORef FArrayMap
, State -> IORef UIMap
rUIMap :: IORef UIMap
, State -> IORef CgMap
rCgMap :: IORef CgMap
, State -> IORef [(String, [String])]
raxioms :: IORef [(String, [String])]
, State -> IORef [SMTOption]
rSMTOptions :: IORef [SMTOption]
, State -> IORef [Objective (SV, SV)]
rOptGoals :: IORef [Objective (SV, SV)]
, State -> IORef [(String, Maybe CallStack, SV)]
rAsserts :: IORef [(String, Maybe CallStack, SV)]
, State -> IORef (Cache SV)
rSVCache :: IORef (Cache SV)
, State -> IORef (Cache ArrayIndex)
rAICache :: IORef (Cache ArrayIndex)
, State -> IORef (Cache FArrayIndex)
rFAICache :: IORef (Cache FArrayIndex)
, State -> IORef (Maybe QueryState)
rQueryState :: IORef (Maybe QueryState)
}
instance NFData State where
rnf :: State -> ()
rnf State{} = ()
getSValPathCondition :: State -> SVal
getSValPathCondition :: State -> SVal
getSValPathCondition = State -> SVal
pathCond
extendSValPathCondition :: State -> (SVal -> SVal) -> State
extendSValPathCondition :: State -> (SVal -> SVal) -> State
extendSValPathCondition State
st SVal -> SVal
f = State
st{pathCond :: SVal
pathCond = SVal -> SVal
f (State -> SVal
pathCond State
st)}
inSMTMode :: State -> IO Bool
inSMTMode :: State -> IO Bool
inSMTMode State{IORef SBVRunMode
runMode :: IORef SBVRunMode
runMode :: State -> IORef SBVRunMode
runMode} = do SBVRunMode
rm <- IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef IORef SBVRunMode
runMode
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> IO Bool) -> Bool -> IO Bool
forall a b. (a -> b) -> a -> b
$ case SBVRunMode
rm of
SBVRunMode
CodeGen -> Bool
False
Concrete{} -> Bool
False
SMTMode{} -> Bool
True
data SVal = SVal !Kind !(Either CV (Cached SV))
instance HasKind SVal where
kindOf :: SVal -> Kind
kindOf (SVal Kind
k Either CV (Cached SV)
_) = Kind
k
instance Show SVal where
show :: SVal -> String
show (SVal Kind
KBool (Left CV
c)) = Bool -> CV -> String
showCV Bool
False CV
c
show (SVal Kind
k (Left CV
c)) = Bool -> CV -> String
showCV Bool
False CV
c String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
show (SVal Kind
k (Right Cached SV
_)) = String
"<symbolic> :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
instance Eq SVal where
SVal
a == :: SVal -> SVal -> Bool
== SVal
b = String -> String -> (String, String) -> Bool
forall a. String -> String -> (String, String) -> a
noEquals String
"==" String
".==" (SVal -> String
forall a. Show a => a -> String
show SVal
a, SVal -> String
forall a. Show a => a -> String
show SVal
b)
SVal
a /= :: SVal -> SVal -> Bool
/= SVal
b = String -> String -> (String, String) -> Bool
forall a. String -> String -> (String, String) -> a
noEquals String
"/=" String
"./=" (SVal -> String
forall a. Show a => a -> String
show SVal
a, SVal -> String
forall a. Show a => a -> String
show SVal
b)
noEquals :: String -> String -> (String, String) -> a
noEquals :: String -> String -> (String, String) -> a
noEquals String
o String
n (String
l, String
r) = 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: Comparing symbolic values using Haskell's Eq class!"
, String
"***"
, String
"*** Received: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
l String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
o String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
r
, String
"*** Instead use: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
l String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
n String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
r
, String
"***"
, String
"*** The Eq instance for symbolic values are necessiated only because"
, String
"*** of the Bits class requirement. You must use symbolic equality"
, String
"*** operators instead. (And complain to Haskell folks that they"
, String
"*** remove the 'Eq' superclass from 'Bits'!.)"
]
noInteractive :: [String] -> a
noInteractive :: [String] -> a
noInteractive [String]
ss = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ [String] -> String
unlines ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ String
""
String -> [String] -> [String]
forall a. a -> [a] -> [a]
: String
"*** Data.SBV: Unsupported interactive/query mode feature."
String -> [String] -> [String]
forall a. a -> [a] -> [a]
: ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
"*** " String -> ShowS
forall a. [a] -> [a] -> [a]
++) [String]
ss
[String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"*** Data.SBV: Please report this as a feature request!"]
noInteractiveEver :: [String] -> a
noInteractiveEver :: [String] -> a
noInteractiveEver [String]
ss = String -> a
forall a. HasCallStack => String -> a
error (String -> a) -> String -> a
forall a b. (a -> b) -> a -> b
$ [String] -> String
unlines ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ String
""
String -> [String] -> [String]
forall a. a -> [a] -> [a]
: String
"*** Data.SBV: Unsupported interactive/query mode feature."
String -> [String] -> [String]
forall a. a -> [a] -> [a]
: ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
"*** " String -> ShowS
forall a. [a] -> [a] -> [a]
++) [String]
ss
modifyState :: State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState :: State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState st :: State
st@State{IORef SBVRunMode
runMode :: IORef SBVRunMode
runMode :: State -> IORef SBVRunMode
runMode} State -> IORef a
field a -> a
update IO ()
interactiveUpdate = do
IORef a -> (a -> a) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
R.modifyIORef' (State -> IORef a
field State
st) a -> a
update
SBVRunMode
rm <- IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef IORef SBVRunMode
runMode
case SBVRunMode
rm of
SMTMode QueryContext
_ IStage
IRun Bool
_ SMTConfig
_ -> IO ()
interactiveUpdate
SBVRunMode
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
modifyIncState :: State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState :: State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State{IORef IncState
rIncState :: IORef IncState
rIncState :: State -> IORef IncState
rIncState} IncState -> IORef a
field a -> a
update = do
IncState
incState <- IORef IncState -> IO IncState
forall a. IORef a -> IO a
readIORef IORef IncState
rIncState
IORef a -> (a -> a) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
R.modifyIORef' (IncState -> IORef a
field IncState
incState) a -> a
update
recordObservable :: State -> String -> (CV -> Bool) -> SV -> IO ()
recordObservable :: State -> String -> (CV -> Bool) -> SV -> IO ()
recordObservable State
st (String -> Name
T.pack -> Name
nm) CV -> Bool
chk SV
sv = State
-> (State -> IORef (Seq (Name, CV -> Bool, SV)))
-> (Seq (Name, CV -> Bool, SV) -> Seq (Name, CV -> Bool, SV))
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef (Seq (Name, CV -> Bool, SV))
rObservables ((Name
nm, CV -> Bool
chk, SV
sv) (Name, CV -> Bool, SV)
-> Seq (Name, CV -> Bool, SV) -> Seq (Name, CV -> Bool, SV)
forall a. a -> Seq a -> Seq a
S.<|) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
incrementInternalCounter :: State -> IO Int
incrementInternalCounter :: State -> IO Int
incrementInternalCounter State
st = do Int
ctr <- IORef Int -> IO Int
forall a. IORef a -> IO a
readIORef (State -> IORef Int
rctr State
st)
State -> (State -> IORef Int) -> (Int -> Int) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef Int
rctr (Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return Int
ctr
svUninterpreted :: Kind -> String -> Maybe [String] -> [SVal] -> SVal
svUninterpreted :: Kind -> String -> Maybe [String] -> [SVal] -> SVal
svUninterpreted Kind
k String
nm Maybe [String]
code [SVal]
args = 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
result
where result :: State -> IO SV
result State
st = do let ty :: SBVType
ty = [Kind] -> SBVType
SBVType ((SVal -> Kind) -> [SVal] -> [Kind]
forall a b. (a -> b) -> [a] -> [b]
map SVal -> Kind
forall a. HasKind a => a -> Kind
kindOf [SVal]
args [Kind] -> [Kind] -> [Kind]
forall a. [a] -> [a] -> [a]
++ [Kind
k])
State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm SBVType
ty Maybe [String]
code
[SV]
sws <- (SVal -> IO SV) -> [SVal] -> IO [SV]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (State -> SVal -> IO SV
svToSV State
st) [SVal]
args
(SV -> IO ()) -> [SV] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SV -> IO ()
forceSVArg [SV]
sws
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k (SBVExpr -> IO SV) -> SBVExpr -> IO SV
forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (String -> Op
Uninterpreted String
nm) [SV]
sws
newUninterpreted :: State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted :: State -> String -> SBVType -> Maybe [String] -> IO ()
newUninterpreted State
st String
nm SBVType
t Maybe [String]
mbCode
| String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
nm Bool -> Bool -> Bool
|| Bool -> Bool
not Bool
enclosed Bool -> Bool -> Bool
&& (Bool -> Bool
not (Char -> Bool
isAlpha (String -> Char
forall a. [a] -> a
head String
nm)) Bool -> Bool -> Bool
|| Bool -> Bool
not ((Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
validChar (ShowS
forall a. [a] -> [a]
tail String
nm)))
= String -> IO ()
forall a. HasCallStack => String -> a
error (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"Bad uninterpreted constant name: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
". Must be a valid identifier."
| Bool
True = do UIMap
uiMap <- IORef UIMap -> IO UIMap
forall a. IORef a -> IO a
readIORef (State -> IORef UIMap
rUIMap State
st)
case String
nm String -> UIMap -> Maybe SBVType
forall k a. Ord k => k -> Map k a -> Maybe a
`Map.lookup` UIMap
uiMap of
Just SBVType
t' -> SBVType -> IO () -> IO ()
forall r. SBVType -> r -> r
checkType SBVType
t' (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
Maybe SBVType
Nothing -> do State
-> (State -> IORef UIMap) -> (UIMap -> UIMap) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef UIMap
rUIMap (String -> SBVType -> UIMap -> UIMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert String
nm SBVType
t)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State -> (IncState -> IORef UIMap) -> (UIMap -> UIMap) -> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef UIMap
rNewUIs (\UIMap
newUIs -> case String
nm String -> UIMap -> Maybe SBVType
forall k a. Ord k => k -> Map k a -> Maybe a
`Map.lookup` UIMap
newUIs of
Just SBVType
t' -> SBVType -> UIMap -> UIMap
forall r. SBVType -> r -> r
checkType SBVType
t' UIMap
newUIs
Maybe SBVType
Nothing -> String -> SBVType -> UIMap -> UIMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert String
nm SBVType
t UIMap
newUIs)
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe [String] -> Bool
forall a. Maybe a -> Bool
isJust Maybe [String]
mbCode) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (State -> IORef CgMap) -> (CgMap -> CgMap) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef CgMap
rCgMap (String -> [String] -> CgMap -> CgMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert String
nm (Maybe [String] -> [String]
forall a. HasCallStack => Maybe a -> a
fromJust Maybe [String]
mbCode)) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
where checkType :: SBVType -> r -> r
checkType :: SBVType -> r -> r
checkType SBVType
t' r
cont
| SBVType
t SBVType -> SBVType -> Bool
forall a. Eq a => a -> a -> Bool
/= SBVType
t' = String -> r
forall a. HasCallStack => String -> a
error (String -> r) -> String -> r
forall a b. (a -> b) -> a -> b
$ String
"Uninterpreted constant " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" used at incompatible types\n"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" Current type : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBVType -> String
forall a. Show a => a -> String
show SBVType
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\n"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" Previously used at: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBVType -> String
forall a. Show a => a -> String
show SBVType
t'
| Bool
True = r
cont
validChar :: Char -> Bool
validChar Char
x = Char -> Bool
isAlphaNum Char
x Bool -> Bool -> Bool
|| Char
x Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (String
"_" :: String)
enclosed :: Bool
enclosed = String -> Char
forall a. [a] -> a
head String
nm Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'|' Bool -> Bool -> Bool
&& String -> Char
forall a. [a] -> a
last String
nm Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'|' Bool -> Bool -> Bool
&& String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
nm Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
2 Bool -> Bool -> Bool
&& Bool -> Bool
not ((Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (String
"|\\" :: String)) (ShowS
forall a. [a] -> [a]
tail (ShowS
forall a. [a] -> [a]
init String
nm)))
addAssertion :: State -> Maybe CallStack -> String -> SV -> IO ()
addAssertion :: State -> Maybe CallStack -> String -> SV -> IO ()
addAssertion State
st Maybe CallStack
cs String
msg SV
cond = State
-> (State -> IORef [(String, Maybe CallStack, SV)])
-> ([(String, Maybe CallStack, SV)]
-> [(String, Maybe CallStack, SV)])
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [(String, Maybe CallStack, SV)]
rAsserts ((String
msg, Maybe CallStack
cs, SV
cond)(String, Maybe CallStack, SV)
-> [(String, Maybe CallStack, SV)]
-> [(String, Maybe CallStack, SV)]
forall a. a -> [a] -> [a]
:)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ [String] -> IO ()
forall a. [String] -> a
noInteractive [ String
"Named assertions (sAssert):"
, String
" Tag: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
msg
, String
" Loc: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> (CallStack -> String) -> Maybe CallStack -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"Unknown" CallStack -> String
forall a. Show a => a -> String
show Maybe CallStack
cs
]
internalVariable :: State -> Kind -> IO SV
internalVariable :: State -> Kind -> IO SV
internalVariable State
st Kind
k = do (NamedSymVar SV
sv Name
nm) <- State -> Kind -> IO NamedSymVar
newSV State
st Kind
k
SBVRunMode
rm <- IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef (State -> IORef SBVRunMode
runMode State
st)
let q :: Quantifier
q = case SBVRunMode
rm of
SMTMode QueryContext
_ IStage
_ Bool
True SMTConfig
_ -> Quantifier
EX
SMTMode QueryContext
_ IStage
_ Bool
False SMTConfig
_ -> Quantifier
ALL
SBVRunMode
CodeGen -> Quantifier
ALL
Concrete{} -> Quantifier
ALL
n :: Name
n = Name
"__internal_sbv_" Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
nm
v :: NamedSymVar
v = SV -> Name -> NamedSymVar
NamedSymVar SV
sv Name
n
State
-> (State -> IORef Inputs) -> (Inputs -> Inputs) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef Inputs
rinps (Quantifier -> SV -> Name -> Inputs -> Inputs
addUserInput Quantifier
q SV
sv Name
n)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (IncState -> IORef [NamedSymVar])
-> ([NamedSymVar] -> [NamedSymVar])
-> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef [NamedSymVar]
rNewInps (\[NamedSymVar]
newInps -> case Quantifier
q of
Quantifier
EX -> NamedSymVar
v NamedSymVar -> [NamedSymVar] -> [NamedSymVar]
forall a. a -> [a] -> [a]
: [NamedSymVar]
newInps
Quantifier
ALL -> [String] -> [NamedSymVar]
forall a. [String] -> a
noInteractive [ String
"Internal universally quantified variable creation:"
, String
" Named: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Name -> String
T.unpack Name
nm
])
SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
sv
{-# INLINE internalVariable #-}
newSV :: State -> Kind -> IO NamedSymVar
newSV :: State -> Kind -> IO NamedSymVar
newSV State
st Kind
k = do Int
ctr <- State -> IO Int
incrementInternalCounter State
st
let sv :: SV
sv = Kind -> NodeId -> SV
SV Kind
k (Int -> NodeId
NodeId Int
ctr)
State -> Kind -> IO ()
registerKind State
st Kind
k
NamedSymVar -> IO NamedSymVar
forall (m :: * -> *) a. Monad m => a -> m a
return (NamedSymVar -> IO NamedSymVar) -> NamedSymVar -> IO NamedSymVar
forall a b. (a -> b) -> a -> b
$ SV -> Name -> NamedSymVar
NamedSymVar SV
sv (Name -> NamedSymVar) -> Name -> NamedSymVar
forall a b. (a -> b) -> a -> b
$ Char
's' Char -> Name -> Name
`T.cons` String -> Name
T.pack (Int -> String
forall a. Show a => a -> String
show Int
ctr)
{-# INLINE newSV #-}
registerKind :: State -> Kind -> IO ()
registerKind :: State -> Kind -> IO ()
registerKind State
st Kind
k
| KUserSort String
sortName Maybe [String]
_ <- Kind
k, (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
sortName String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
smtLibReservedNames
= String -> IO ()
forall a. HasCallStack => String -> a
error (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"SBV: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
sortName String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" is a reserved sort; please use a different name."
| Bool
True
= do
Set Kind
existingKinds <- IORef (Set Kind) -> IO (Set Kind)
forall a. IORef a -> IO a
readIORef (State -> IORef (Set Kind)
rUsedKinds State
st)
State
-> (State -> IORef (Set Kind))
-> (Set Kind -> Set Kind)
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef (Set Kind)
rUsedKinds (Kind -> Set Kind -> Set Kind
forall a. Ord a => a -> Set a -> Set a
Set.insert Kind
k) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
let needsAdding :: Bool
needsAdding = case Kind
k of
KUserSort{} -> Kind
k Kind -> Set Kind -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` Set Kind
existingKinds
KList{} -> Kind
k Kind -> Set Kind -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` Set Kind
existingKinds
KTuple [Kind]
nks -> [Kind] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Kind]
nks Int -> [Int] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [[Kind] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Kind]
oks | KTuple [Kind]
oks <- Set Kind -> [Kind]
forall a. Set a -> [a]
Set.toList Set Kind
existingKinds]
KMaybe{} -> Kind
k Kind -> Set Kind -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` Set Kind
existingKinds
KEither{} -> Kind
k Kind -> Set Kind -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` Set Kind
existingKinds
Kind
_ -> Bool
False
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
needsAdding (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (IncState -> IORef (Set Kind))
-> (Set Kind -> Set Kind)
-> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef (Set Kind)
rNewKinds (Kind -> Set Kind -> Set Kind
forall a. Ord a => a -> Set a -> Set a
Set.insert Kind
k)
case Kind
k of
KBool {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KBounded {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KUnbounded{} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KReal {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KUserSort {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KFloat {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KDouble {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KFP {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KChar {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KString {} -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
KList Kind
ek -> State -> Kind -> IO ()
registerKind State
st Kind
ek
KSet Kind
ek -> State -> Kind -> IO ()
registerKind State
st Kind
ek
KTuple [Kind]
eks -> (Kind -> IO ()) -> [Kind] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (State -> Kind -> IO ()
registerKind State
st) [Kind]
eks
KMaybe Kind
ke -> State -> Kind -> IO ()
registerKind State
st Kind
ke
KEither Kind
k1 Kind
k2 -> (Kind -> IO ()) -> [Kind] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (State -> Kind -> IO ()
registerKind State
st) [Kind
k1, Kind
k2]
registerLabel :: String -> State -> String -> IO ()
registerLabel :: String -> State -> String -> IO ()
registerLabel String
whence State
st String
nm
| (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
nm String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
smtLibReservedNames
= String -> IO ()
err String
"is a reserved string; please use a different name."
| Char
'|' Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
nm
= String -> IO ()
err String
"contains the character `|', which is not allowed!"
| Char
'\\' Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
nm
= String -> IO ()
err String
"contains the character `\\', which is not allowed!"
| Bool
True
= do Set String
old <- IORef (Set String) -> IO (Set String)
forall a. IORef a -> IO a
readIORef (IORef (Set String) -> IO (Set String))
-> IORef (Set String) -> IO (Set String)
forall a b. (a -> b) -> a -> b
$ State -> IORef (Set String)
rUsedLbls State
st
if String
nm String -> Set String -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set String
old
then String -> IO ()
err String
"is used multiple times. Please do not use duplicate names!"
else State
-> (State -> IORef (Set String))
-> (Set String -> Set String)
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef (Set String)
rUsedLbls (String -> Set String -> Set String
forall a. Ord a => a -> Set a -> Set a
Set.insert String
nm) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
where err :: String -> IO ()
err String
w = String -> IO ()
forall a. HasCallStack => String -> a
error (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"SBV (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
whence String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"): " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
w
newConst :: State -> CV -> IO SV
newConst :: State -> CV -> IO SV
newConst State
st CV
c = do
CnstMap
constMap <- IORef CnstMap -> IO CnstMap
forall a. IORef a -> IO a
readIORef (State -> IORef CnstMap
rconstMap State
st)
case CV
c CV -> CnstMap -> Maybe SV
forall k a. Ord k => k -> Map k a -> Maybe a
`Map.lookup` CnstMap
constMap of
Just SV
sv -> SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
sv
Maybe SV
Nothing -> do (NamedSymVar SV
sv Name
_) <- State -> Kind -> IO NamedSymVar
newSV State
st (CV -> Kind
forall a. HasKind a => a -> Kind
kindOf CV
c)
let ins :: CnstMap -> CnstMap
ins = CV -> SV -> CnstMap -> CnstMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert CV
c SV
sv
State
-> (State -> IORef CnstMap)
-> (CnstMap -> CnstMap)
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef CnstMap
rconstMap CnstMap -> CnstMap
ins (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (IncState -> IORef CnstMap) -> (CnstMap -> CnstMap) -> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef CnstMap
rNewConsts CnstMap -> CnstMap
ins
SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
sv
{-# INLINE newConst #-}
getTableIndex :: State -> Kind -> Kind -> [SV] -> IO Int
getTableIndex :: State -> Kind -> Kind -> [SV] -> IO Int
getTableIndex State
st Kind
at Kind
rt [SV]
elts = do
let key :: (Kind, Kind, [SV])
key = (Kind
at, Kind
rt, [SV]
elts)
TableMap
tblMap <- IORef TableMap -> IO TableMap
forall a. IORef a -> IO a
readIORef (State -> IORef TableMap
rtblMap State
st)
case (Kind, Kind, [SV])
key (Kind, Kind, [SV]) -> TableMap -> Maybe Int
forall k a. Ord k => k -> Map k a -> Maybe a
`Map.lookup` TableMap
tblMap of
Just Int
i -> Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return Int
i
Maybe Int
_ -> do let i :: Int
i = TableMap -> Int
forall k a. Map k a -> Int
Map.size TableMap
tblMap
upd :: TableMap -> TableMap
upd = (Kind, Kind, [SV]) -> Int -> TableMap -> TableMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert (Kind, Kind, [SV])
key Int
i
State
-> (State -> IORef TableMap)
-> (TableMap -> TableMap)
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef TableMap
rtblMap TableMap -> TableMap
upd (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (IncState -> IORef TableMap) -> (TableMap -> TableMap) -> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef TableMap
rNewTbls TableMap -> TableMap
upd
Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return Int
i
newExpr :: State -> Kind -> SBVExpr -> IO SV
newExpr :: State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k SBVExpr
app = do
let e :: SBVExpr
e = SBVExpr -> SBVExpr
reorder SBVExpr
app
ExprMap
exprMap <- IORef ExprMap -> IO ExprMap
forall a. IORef a -> IO a
readIORef (State -> IORef ExprMap
rexprMap State
st)
case SBVExpr
e SBVExpr -> ExprMap -> Maybe SV
forall k a. Ord k => k -> Map k a -> Maybe a
`Map.lookup` ExprMap
exprMap of
Just SV
sv | SV -> Kind
forall a. HasKind a => a -> Kind
kindOf SV
sv Kind -> Kind -> Bool
forall a. Eq a => a -> a -> Bool
== Kind
k -> SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
sv
Maybe SV
_ -> do (NamedSymVar SV
sv Name
_) <- State -> Kind -> IO NamedSymVar
newSV State
st Kind
k
let append :: SBVPgm -> SBVPgm
append (SBVPgm Seq (SV, SBVExpr)
xs) = Seq (SV, SBVExpr) -> SBVPgm
SBVPgm (Seq (SV, SBVExpr)
xs Seq (SV, SBVExpr) -> (SV, SBVExpr) -> Seq (SV, SBVExpr)
forall a. Seq a -> a -> Seq a
S.|> (SV
sv, SBVExpr
e))
State
-> (State -> IORef SBVPgm) -> (SBVPgm -> SBVPgm) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef SBVPgm
spgm SBVPgm -> SBVPgm
append (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State -> (IncState -> IORef SBVPgm) -> (SBVPgm -> SBVPgm) -> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef SBVPgm
rNewAsgns SBVPgm -> SBVPgm
append
State
-> (State -> IORef ExprMap)
-> (ExprMap -> ExprMap)
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef ExprMap
rexprMap (SBVExpr -> SV -> ExprMap -> ExprMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert SBVExpr
e SV
sv) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
SV -> IO SV
forall (m :: * -> *) a. Monad m => a -> m a
return SV
sv
{-# INLINE newExpr #-}
svToSV :: State -> SVal -> IO SV
svToSV :: State -> SVal -> IO SV
svToSV State
st (SVal Kind
_ (Left CV
c)) = State -> CV -> IO SV
newConst State
st CV
c
svToSV State
st (SVal Kind
_ (Right Cached SV
f)) = Cached SV -> State -> IO SV
uncache Cached SV
f State
st
svToSymSV :: MonadSymbolic m => SVal -> m SV
svToSymSV :: SVal -> m SV
svToSymSV SVal
sbv = do State
st <- m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
IO SV -> m SV
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SV -> m SV) -> IO SV -> m SV
forall a b. (a -> b) -> a -> b
$ State -> SVal -> IO SV
svToSV State
st SVal
sbv
class MonadIO m => MonadSymbolic m where
symbolicEnv :: m State
default symbolicEnv :: (MonadTrans t, MonadSymbolic m', m ~ t m') => m State
symbolicEnv = m' State -> t m' State
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m' State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
instance MonadSymbolic m => MonadSymbolic (ExceptT e m)
instance MonadSymbolic m => MonadSymbolic (MaybeT m)
instance MonadSymbolic m => MonadSymbolic (ReaderT r m)
instance MonadSymbolic m => MonadSymbolic (SS.StateT s m)
instance MonadSymbolic m => MonadSymbolic (LS.StateT s m)
instance (MonadSymbolic m, Monoid w) => MonadSymbolic (SW.WriterT w m)
instance (MonadSymbolic m, Monoid w) => MonadSymbolic (LW.WriterT w m)
newtype SymbolicT m a = SymbolicT { SymbolicT m a -> ReaderT State m a
runSymbolicT :: ReaderT State m a }
deriving ( Functor (SymbolicT m)
a -> SymbolicT m a
Functor (SymbolicT m)
-> (forall a. a -> SymbolicT m a)
-> (forall a b.
SymbolicT m (a -> b) -> SymbolicT m a -> SymbolicT m b)
-> (forall a b c.
(a -> b -> c) -> SymbolicT m a -> SymbolicT m b -> SymbolicT m c)
-> (forall a b. SymbolicT m a -> SymbolicT m b -> SymbolicT m b)
-> (forall a b. SymbolicT m a -> SymbolicT m b -> SymbolicT m a)
-> Applicative (SymbolicT m)
SymbolicT m a -> SymbolicT m b -> SymbolicT m b
SymbolicT m a -> SymbolicT m b -> SymbolicT m a
SymbolicT m (a -> b) -> SymbolicT m a -> SymbolicT m b
(a -> b -> c) -> SymbolicT m a -> SymbolicT m b -> SymbolicT m c
forall a. a -> SymbolicT m a
forall a b. SymbolicT m a -> SymbolicT m b -> SymbolicT m a
forall a b. SymbolicT m a -> SymbolicT m b -> SymbolicT m b
forall a b. SymbolicT m (a -> b) -> SymbolicT m a -> SymbolicT m b
forall a b c.
(a -> b -> c) -> SymbolicT m a -> SymbolicT m b -> SymbolicT m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (SymbolicT m)
forall (m :: * -> *) a. Applicative m => a -> SymbolicT m a
forall (m :: * -> *) a b.
Applicative m =>
SymbolicT m a -> SymbolicT m b -> SymbolicT m a
forall (m :: * -> *) a b.
Applicative m =>
SymbolicT m a -> SymbolicT m b -> SymbolicT m b
forall (m :: * -> *) a b.
Applicative m =>
SymbolicT m (a -> b) -> SymbolicT m a -> SymbolicT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> SymbolicT m a -> SymbolicT m b -> SymbolicT m c
<* :: SymbolicT m a -> SymbolicT m b -> SymbolicT m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
SymbolicT m a -> SymbolicT m b -> SymbolicT m a
*> :: SymbolicT m a -> SymbolicT m b -> SymbolicT m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
SymbolicT m a -> SymbolicT m b -> SymbolicT m b
liftA2 :: (a -> b -> c) -> SymbolicT m a -> SymbolicT m b -> SymbolicT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> SymbolicT m a -> SymbolicT m b -> SymbolicT m c
<*> :: SymbolicT m (a -> b) -> SymbolicT m a -> SymbolicT m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
SymbolicT m (a -> b) -> SymbolicT m a -> SymbolicT m b
pure :: a -> SymbolicT m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> SymbolicT m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (SymbolicT m)
Applicative, a -> SymbolicT m b -> SymbolicT m a
(a -> b) -> SymbolicT m a -> SymbolicT m b
(forall a b. (a -> b) -> SymbolicT m a -> SymbolicT m b)
-> (forall a b. a -> SymbolicT m b -> SymbolicT m a)
-> Functor (SymbolicT m)
forall a b. a -> SymbolicT m b -> SymbolicT m a
forall a b. (a -> b) -> SymbolicT m a -> SymbolicT m b
forall (m :: * -> *) a b.
Functor m =>
a -> SymbolicT m b -> SymbolicT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> SymbolicT m a -> SymbolicT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> SymbolicT m b -> SymbolicT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> SymbolicT m b -> SymbolicT m a
fmap :: (a -> b) -> SymbolicT m a -> SymbolicT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> SymbolicT m a -> SymbolicT m b
Functor, Applicative (SymbolicT m)
a -> SymbolicT m a
Applicative (SymbolicT m)
-> (forall a b.
SymbolicT m a -> (a -> SymbolicT m b) -> SymbolicT m b)
-> (forall a b. SymbolicT m a -> SymbolicT m b -> SymbolicT m b)
-> (forall a. a -> SymbolicT m a)
-> Monad (SymbolicT m)
SymbolicT m a -> (a -> SymbolicT m b) -> SymbolicT m b
SymbolicT m a -> SymbolicT m b -> SymbolicT m b
forall a. a -> SymbolicT m a
forall a b. SymbolicT m a -> SymbolicT m b -> SymbolicT m b
forall a b. SymbolicT m a -> (a -> SymbolicT m b) -> SymbolicT m b
forall (m :: * -> *). Monad m => Applicative (SymbolicT m)
forall (m :: * -> *) a. Monad m => a -> SymbolicT m a
forall (m :: * -> *) a b.
Monad m =>
SymbolicT m a -> SymbolicT m b -> SymbolicT m b
forall (m :: * -> *) a b.
Monad m =>
SymbolicT m a -> (a -> SymbolicT m b) -> SymbolicT m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> SymbolicT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> SymbolicT m a
>> :: SymbolicT m a -> SymbolicT m b -> SymbolicT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
SymbolicT m a -> SymbolicT m b -> SymbolicT m b
>>= :: SymbolicT m a -> (a -> SymbolicT m b) -> SymbolicT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
SymbolicT m a -> (a -> SymbolicT m b) -> SymbolicT m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (SymbolicT m)
Monad, Monad (SymbolicT m)
Monad (SymbolicT m)
-> (forall a. IO a -> SymbolicT m a) -> MonadIO (SymbolicT m)
IO a -> SymbolicT m a
forall a. IO a -> SymbolicT m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (SymbolicT m)
forall (m :: * -> *) a. MonadIO m => IO a -> SymbolicT m a
liftIO :: IO a -> SymbolicT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> SymbolicT m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (SymbolicT m)
MonadIO, m a -> SymbolicT m a
(forall (m :: * -> *) a. Monad m => m a -> SymbolicT m a)
-> MonadTrans SymbolicT
forall (m :: * -> *) a. Monad m => m a -> SymbolicT m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> SymbolicT m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> SymbolicT m a
MonadTrans
, MonadError e, MonadState s, MonadWriter w
#if MIN_VERSION_base(4,11,0)
, Monad (SymbolicT m)
Monad (SymbolicT m)
-> (forall a. String -> SymbolicT m a) -> MonadFail (SymbolicT m)
String -> SymbolicT m a
forall a. String -> SymbolicT m a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
forall (m :: * -> *). MonadFail m => Monad (SymbolicT m)
forall (m :: * -> *) a. MonadFail m => String -> SymbolicT m a
fail :: String -> SymbolicT m a
$cfail :: forall (m :: * -> *) a. MonadFail m => String -> SymbolicT m a
$cp1MonadFail :: forall (m :: * -> *). MonadFail m => Monad (SymbolicT m)
Fail.MonadFail
#endif
)
instance MonadIO m => MonadSymbolic (SymbolicT m) where
symbolicEnv :: SymbolicT m State
symbolicEnv = ReaderT State m State -> SymbolicT m State
forall (m :: * -> *) a. ReaderT State m a -> SymbolicT m a
SymbolicT ReaderT State m State
forall r (m :: * -> *). MonadReader r m => m r
ask
mapSymbolicT :: (ReaderT State m a -> ReaderT State n b) -> SymbolicT m a -> SymbolicT n b
mapSymbolicT :: (ReaderT State m a -> ReaderT State n b)
-> SymbolicT m a -> SymbolicT n b
mapSymbolicT ReaderT State m a -> ReaderT State n b
f = ReaderT State n b -> SymbolicT n b
forall (m :: * -> *) a. ReaderT State m a -> SymbolicT m a
SymbolicT (ReaderT State n b -> SymbolicT n b)
-> (SymbolicT m a -> ReaderT State n b)
-> SymbolicT m a
-> SymbolicT n b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReaderT State m a -> ReaderT State n b
f (ReaderT State m a -> ReaderT State n b)
-> (SymbolicT m a -> ReaderT State m a)
-> SymbolicT m a
-> ReaderT State n b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SymbolicT m a -> ReaderT State m a
forall (m :: * -> *) a. SymbolicT m a -> ReaderT State m a
runSymbolicT
{-# INLINE mapSymbolicT #-}
instance MonadReader r m => MonadReader r (SymbolicT m) where
ask :: SymbolicT m r
ask = m r -> SymbolicT m r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m r
forall r (m :: * -> *). MonadReader r m => m r
ask
local :: (r -> r) -> SymbolicT m a -> SymbolicT m a
local r -> r
f = (ReaderT State m a -> ReaderT State m a)
-> SymbolicT m a -> SymbolicT m a
forall (m :: * -> *) a (n :: * -> *) b.
(ReaderT State m a -> ReaderT State n b)
-> SymbolicT m a -> SymbolicT n b
mapSymbolicT ((ReaderT State m a -> ReaderT State m a)
-> SymbolicT m a -> SymbolicT m a)
-> (ReaderT State m a -> ReaderT State m a)
-> SymbolicT m a
-> SymbolicT m a
forall a b. (a -> b) -> a -> b
$ (m a -> m a) -> ReaderT State m a -> ReaderT State m a
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT ((m a -> m a) -> ReaderT State m a -> ReaderT State m a)
-> (m a -> m a) -> ReaderT State m a -> ReaderT State m a
forall a b. (a -> b) -> a -> b
$ (r -> r) -> m a -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f
type Symbolic = SymbolicT IO
svMkSymVar :: VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVar :: VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVar = Bool -> VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVarGen Bool
False
svMkTrackerVar :: Kind -> String -> State -> IO SVal
svMkTrackerVar :: Kind -> String -> State -> IO SVal
svMkTrackerVar Kind
k String
nm = Bool -> VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVarGen Bool
True (Maybe Quantifier -> VarContext
NonQueryVar (Quantifier -> Maybe Quantifier
forall a. a -> Maybe a
Just Quantifier
EX)) Kind
k (String -> Maybe String
forall a. a -> Maybe a
Just String
nm)
sWordN :: MonadSymbolic m => Int -> String -> m SVal
sWordN :: Int -> String -> m SVal
sWordN Int
w String
nm = m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv m State -> (State -> m SVal) -> m SVal
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO SVal -> m SVal
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SVal -> m SVal) -> (State -> IO SVal) -> State -> m SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVar (Maybe Quantifier -> VarContext
NonQueryVar Maybe Quantifier
forall a. Maybe a
Nothing) (Bool -> Int -> Kind
KBounded Bool
False Int
w) (String -> Maybe String
forall a. a -> Maybe a
Just String
nm)
sWordN_ :: MonadSymbolic m => Int -> m SVal
sWordN_ :: Int -> m SVal
sWordN_ Int
w = m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv m State -> (State -> m SVal) -> m SVal
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO SVal -> m SVal
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SVal -> m SVal) -> (State -> IO SVal) -> State -> m SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVar (Maybe Quantifier -> VarContext
NonQueryVar Maybe Quantifier
forall a. Maybe a
Nothing) (Bool -> Int -> Kind
KBounded Bool
False Int
w) Maybe String
forall a. Maybe a
Nothing
sIntN :: MonadSymbolic m => Int -> String -> m SVal
sIntN :: Int -> String -> m SVal
sIntN Int
w String
nm = m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv m State -> (State -> m SVal) -> m SVal
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO SVal -> m SVal
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SVal -> m SVal) -> (State -> IO SVal) -> State -> m SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVar (Maybe Quantifier -> VarContext
NonQueryVar Maybe Quantifier
forall a. Maybe a
Nothing) (Bool -> Int -> Kind
KBounded Bool
True Int
w) (String -> Maybe String
forall a. a -> Maybe a
Just String
nm)
sIntN_ :: MonadSymbolic m => Int -> m SVal
sIntN_ :: Int -> m SVal
sIntN_ Int
w = m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv m State -> (State -> m SVal) -> m SVal
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO SVal -> m SVal
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SVal -> m SVal) -> (State -> IO SVal) -> State -> m SVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVar (Maybe Quantifier -> VarContext
NonQueryVar Maybe Quantifier
forall a. Maybe a
Nothing) (Bool -> Int -> Kind
KBounded Bool
True Int
w) Maybe String
forall a. Maybe a
Nothing
svMkSymVarGen :: Bool -> VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVarGen :: Bool -> VarContext -> Kind -> Maybe String -> State -> IO SVal
svMkSymVarGen Bool
isTracker VarContext
varContext Kind
k Maybe String
mbNm State
st = do
SBVRunMode
rm <- IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef (State -> IORef SBVRunMode
runMode State
st)
let varInfo :: String
varInfo = case Maybe String
mbNm of
Maybe String
Nothing -> String
", of type " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
Just String
nm -> String
", while defining " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
nm String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
disallow :: String -> IO SVal
disallow String
what = String -> IO SVal
forall a. HasCallStack => String -> a
error (String -> IO SVal) -> String -> IO SVal
forall a b. (a -> b) -> a -> b
$ String
"Data.SBV: Unsupported: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
what String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
varInfo String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" in mode: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBVRunMode -> String
forall a. Show a => a -> String
show SBVRunMode
rm
noUI :: IO SVal -> IO SVal
noUI IO SVal
cont
| Kind -> Bool
forall a. HasKind a => a -> Bool
isUserSort Kind
k = String -> IO SVal
disallow String
"User defined sorts"
| Bool
True = IO SVal
cont
(Bool
isQueryVar, Maybe Quantifier
mbQ) = case VarContext
varContext of
NonQueryVar Maybe Quantifier
mq -> (Bool
False, Maybe Quantifier
mq)
VarContext
QueryVar -> (Bool
True, Quantifier -> Maybe Quantifier
forall a. a -> Maybe a
Just Quantifier
EX)
mkS :: Quantifier -> IO SVal
mkS Quantifier
q = do (NamedSymVar SV
sv Name
internalName) <- State -> Kind -> IO NamedSymVar
newSV State
st Kind
k
let nm :: String
nm = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe (Name -> String
T.unpack Name
internalName) Maybe String
mbNm
State
-> (Bool, Bool) -> String -> Kind -> Quantifier -> SV -> IO SVal
introduceUserName State
st (Bool
isQueryVar, Bool
isTracker) String
nm Kind
k Quantifier
q SV
sv
mkC :: CV -> IO SVal
mkC CV
cv = do State -> Kind -> IO ()
registerKind State
st Kind
k
State
-> (State -> IORef [(String, CV)])
-> ([(String, CV)] -> [(String, CV)])
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [(String, CV)]
rCInfo ((String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
"_" Maybe String
mbNm, CV
cv)(String, CV) -> [(String, CV)] -> [(String, CV)]
forall a. a -> [a] -> [a]
:) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
SVal -> IO SVal
forall (m :: * -> *) a. Monad m => a -> m a
return (SVal -> IO SVal) -> SVal -> IO SVal
forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k (CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left CV
cv)
case (Maybe Quantifier
mbQ, SBVRunMode
rm) of
(Just Quantifier
q, SMTMode{} ) -> Quantifier -> IO SVal
mkS Quantifier
q
(Maybe Quantifier
Nothing, SMTMode QueryContext
_ IStage
_ Bool
isSAT SMTConfig
_) -> Quantifier -> IO SVal
mkS (if Bool
isSAT then Quantifier
EX else Quantifier
ALL)
(Just Quantifier
EX, CodeGen{}) -> String -> IO SVal
disallow String
"Existentially quantified variables"
(Maybe Quantifier
_ , SBVRunMode
CodeGen) -> IO SVal -> IO SVal
noUI (IO SVal -> IO SVal) -> IO SVal -> IO SVal
forall a b. (a -> b) -> a -> b
$ Quantifier -> IO SVal
mkS Quantifier
ALL
(Just Quantifier
EX, Concrete Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)])
Nothing) -> String -> IO SVal
disallow String
"Existentially quantified variables"
(Maybe Quantifier
_ , Concrete Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)])
Nothing) -> IO SVal -> IO SVal
noUI (Kind -> IO CV
randomCV Kind
k IO CV -> (CV -> IO SVal) -> IO SVal
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CV -> IO SVal
mkC)
(Maybe Quantifier
_ , Concrete (Just (Bool
_isSat, [((Quantifier, NamedSymVar), Maybe CV)]
env))) -> do
let bad :: String -> String -> a
bad String
why String
conc = 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: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
why
, String
"***"
, String
"*** To turn validation off, use `cfg{validateModel = False}`"
, String
"***"
, String
"*** " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
conc
]
cant :: String
cant = String
"Validation engine is not capable of handling this case. Failed to validate."
report :: String
report = String
"Please report this as a bug in SBV!"
case () of
() | Kind -> Bool
forall a. HasKind a => a -> Bool
isUserSort Kind
k -> String -> String -> IO SVal
forall a. String -> String -> a
bad (String
"Cannot validate models in the presence of user defined kinds, saw: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k) String
cant
()
_ -> do (NamedSymVar SV
sv Name
internalName) <- State -> Kind -> IO NamedSymVar
newSV State
st Kind
k
let nm :: String
nm = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe (Name -> String
T.unpack Name
internalName) Maybe String
mbNm
nsv :: NamedSymVar
nsv = SV -> String -> NamedSymVar
toNamedSV' SV
sv String
nm
cv :: CV
cv = case [(Quantifier
q, Maybe CV
v) | ((Quantifier
q, NamedSymVar
nsv'), Maybe CV
v) <- [((Quantifier, NamedSymVar), Maybe CV)]
env, NamedSymVar
nsv NamedSymVar -> NamedSymVar -> Bool
forall a. Eq a => a -> a -> Bool
== NamedSymVar
nsv'] of
[] -> if Bool
isTracker
then
Kind -> Integer -> CV
forall a. Integral a => Kind -> a -> CV
mkConstCV Kind
k (Integer
0::Integer)
else String -> String -> CV
forall a. String -> String -> a
bad (String
"Cannot locate variable: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (NamedSymVar, Kind) -> String
forall a. Show a => a -> String
show (NamedSymVar
nsv, Kind
k)) String
report
[(Quantifier
ALL, Maybe CV
_)] ->
Kind -> Integer -> CV
forall a. Integral a => Kind -> a -> CV
mkConstCV Kind
k (Integer
0::Integer)
[(Quantifier
EX, Maybe CV
Nothing)] -> String -> String -> CV
forall a. String -> String -> a
bad (String
"Cannot locate model value of variable: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show (NamedSymVar -> String
getUserName' NamedSymVar
nsv)) String
report
[(Quantifier
EX, Just CV
c)] -> CV
c
[(Quantifier, Maybe CV)]
r -> String -> String -> CV
forall a. String -> String -> a
bad ( String
"Found multiple matching values for variable: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ NamedSymVar -> String
forall a. Show a => a -> String
show NamedSymVar
nsv
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"\n*** " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [(Quantifier, Maybe CV)] -> String
forall a. Show a => a -> String
show [(Quantifier, Maybe CV)]
r) String
report
CV -> IO SVal
mkC CV
cv
introduceUserName :: State -> (Bool, Bool) -> String -> Kind -> Quantifier -> SV -> IO SVal
introduceUserName :: State
-> (Bool, Bool) -> String -> Kind -> Quantifier -> SV -> IO SVal
introduceUserName st :: State
st@State{IORef SBVRunMode
runMode :: IORef SBVRunMode
runMode :: State -> IORef SBVRunMode
runMode} (Bool
isQueryVar, Bool
isTracker) String
nmOrig Kind
k Quantifier
q SV
sv = do
AllInps
old <- Inputs -> AllInps
allInputs (Inputs -> AllInps) -> IO Inputs -> IO AllInps
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef Inputs -> IO Inputs
forall a. IORef a -> IO a
readIORef (State -> IORef Inputs
rinps State
st)
let nm :: Name
nm = Name -> AllInps -> Name
mkUnique (String -> Name
T.pack String
nmOrig) AllInps
old
SBVRunMode
rm <- IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef IORef SBVRunMode
runMode
case SBVRunMode
rm of
SMTMode QueryContext
_ IStage
IRun Bool
_ SMTConfig
_ | Bool -> Bool
not Bool
isQueryVar -> [String] -> IO ()
forall a. [String] -> a
noInteractiveEver [ String
"Adding a new input variable in query mode: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Name -> String
forall a. Show a => a -> String
show Name
nm
, String
""
, String
"Hint: Use freshVar/freshVar_ for introducing new inputs in query mode."
]
SBVRunMode
_ -> () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
if Bool
isTracker Bool -> Bool -> Bool
&& Quantifier
q Quantifier -> Quantifier -> Bool
forall a. Eq a => a -> a -> Bool
== Quantifier
ALL
then String -> IO SVal
forall a. HasCallStack => String -> a
error (String -> IO SVal) -> String -> IO SVal
forall a b. (a -> b) -> a -> b
$ String
"SBV: Impossible happened! A universally quantified tracker variable is being introduced: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Name -> String
forall a. Show a => a -> String
show Name
nm
else do let newInp :: [NamedSymVar] -> [NamedSymVar]
newInp [NamedSymVar]
olds = case Quantifier
q of
Quantifier
EX -> SV -> Name -> NamedSymVar
toNamedSV SV
sv Name
nm NamedSymVar -> [NamedSymVar] -> [NamedSymVar]
forall a. a -> [a] -> [a]
: [NamedSymVar]
olds
Quantifier
ALL -> [String] -> [NamedSymVar]
forall a. [String] -> a
noInteractive [ String
"Adding a new universally quantified variable: "
, String
" Name : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Name -> String
forall a. Show a => a -> String
show Name
nm
, String
" Kind : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Show a => a -> String
show Kind
k
, String
" Quantifier: Universal"
, String
" Node : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SV -> String
forall a. Show a => a -> String
show SV
sv
, String
"Only existential variables are supported in query mode."
]
if Bool
isTracker
then State
-> (State -> IORef Inputs) -> (Inputs -> Inputs) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef Inputs
rinps (SV -> Name -> Inputs -> Inputs
addInternInput SV
sv Name
nm)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ [String] -> IO ()
forall a. [String] -> a
noInteractive [String
"Adding a new tracker variable in interactive mode: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Name -> String
forall a. Show a => a -> String
show Name
nm]
else State
-> (State -> IORef Inputs) -> (Inputs -> Inputs) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef Inputs
rinps (Quantifier -> SV -> Name -> Inputs -> Inputs
addUserInput Quantifier
q SV
sv Name
nm)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (IncState -> IORef [NamedSymVar])
-> ([NamedSymVar] -> [NamedSymVar])
-> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef [NamedSymVar]
rNewInps [NamedSymVar] -> [NamedSymVar]
newInp
SVal -> IO SVal
forall (m :: * -> *) a. Monad m => a -> m a
return (SVal -> IO SVal) -> SVal -> IO SVal
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 (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
sv))
where
mkUnique :: T.Text -> Set.Set Name -> T.Text
mkUnique :: Name -> AllInps -> Name
mkUnique Name
prefix AllInps
names = [Name] -> Name
forall a. [a] -> a
head ([Name] -> Name) -> [Name] -> Name
forall a b. (a -> b) -> a -> b
$ (Name -> Bool) -> [Name] -> [Name]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Name -> AllInps -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` AllInps
names) (Name
prefix Name -> [Name] -> [Name]
forall a. a -> [a] -> [a]
: [Name
prefix Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
"_" Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> String -> Name
T.pack (Int -> String
forall a. Show a => a -> String
show Int
i) | Int
i <- [(Int
0::Int)..]])
runSymbolic :: MonadIO m => SBVRunMode -> SymbolicT m a -> m (a, Result)
runSymbolic :: SBVRunMode -> SymbolicT m a -> m (a, Result)
runSymbolic SBVRunMode
currentRunMode (SymbolicT ReaderT State m a
c) = do
State
st <- IO State -> m State
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO State -> m State) -> IO State -> m State
forall a b. (a -> b) -> a -> b
$ do
UTCTime
currTime <- IO UTCTime
getCurrentTime
IORef SBVRunMode
rm <- SBVRunMode -> IO (IORef SBVRunMode)
forall a. a -> IO (IORef a)
newIORef SBVRunMode
currentRunMode
IORef Int
ctr <- Int -> IO (IORef Int)
forall a. a -> IO (IORef a)
newIORef (-Int
2)
IORef [(String, CV)]
cInfo <- [(String, CV)] -> IO (IORef [(String, CV)])
forall a. a -> IO (IORef a)
newIORef []
IORef (Seq (Name, CV -> Bool, SV))
observes <- Seq (Name, CV -> Bool, SV)
-> IO (IORef (Seq (Name, CV -> Bool, SV)))
forall a. a -> IO (IORef a)
newIORef Seq (Name, CV -> Bool, SV)
forall a. Monoid a => a
mempty
IORef SBVPgm
pgm <- SBVPgm -> IO (IORef SBVPgm)
forall a. a -> IO (IORef a)
newIORef (Seq (SV, SBVExpr) -> SBVPgm
SBVPgm Seq (SV, SBVExpr)
forall a. Seq a
S.empty)
IORef ExprMap
emap <- ExprMap -> IO (IORef ExprMap)
forall a. a -> IO (IORef a)
newIORef ExprMap
forall k a. Map k a
Map.empty
IORef CnstMap
cmap <- CnstMap -> IO (IORef CnstMap)
forall a. a -> IO (IORef a)
newIORef CnstMap
forall k a. Map k a
Map.empty
IORef Inputs
inps <- Inputs -> IO (IORef Inputs)
forall a. a -> IO (IORef a)
newIORef Inputs
forall a. Monoid a => a
mempty
IORef [SV]
outs <- [SV] -> IO (IORef [SV])
forall a. a -> IO (IORef a)
newIORef []
IORef TableMap
tables <- TableMap -> IO (IORef TableMap)
forall a. a -> IO (IORef a)
newIORef TableMap
forall k a. Map k a
Map.empty
IORef ArrayMap
arrays <- ArrayMap -> IO (IORef ArrayMap)
forall a. a -> IO (IORef a)
newIORef ArrayMap
forall a. IntMap a
IMap.empty
IORef FArrayMap
fArrays <- FArrayMap -> IO (IORef FArrayMap)
forall a. a -> IO (IORef a)
newIORef FArrayMap
forall a. IntMap a
IMap.empty
IORef UIMap
uis <- UIMap -> IO (IORef UIMap)
forall a. a -> IO (IORef a)
newIORef UIMap
forall k a. Map k a
Map.empty
IORef CgMap
cgs <- CgMap -> IO (IORef CgMap)
forall a. a -> IO (IORef a)
newIORef CgMap
forall k a. Map k a
Map.empty
IORef [(String, [String])]
axioms <- [(String, [String])] -> IO (IORef [(String, [String])])
forall a. a -> IO (IORef a)
newIORef []
IORef (Cache SV)
swCache <- Cache SV -> IO (IORef (Cache SV))
forall a. a -> IO (IORef a)
newIORef Cache SV
forall a. IntMap a
IMap.empty
IORef (Cache ArrayIndex)
aiCache <- Cache ArrayIndex -> IO (IORef (Cache ArrayIndex))
forall a. a -> IO (IORef a)
newIORef Cache ArrayIndex
forall a. IntMap a
IMap.empty
IORef (Cache FArrayIndex)
faiCache <- Cache FArrayIndex -> IO (IORef (Cache FArrayIndex))
forall a. a -> IO (IORef a)
newIORef Cache FArrayIndex
forall a. IntMap a
IMap.empty
IORef (Set Kind)
usedKinds <- Set Kind -> IO (IORef (Set Kind))
forall a. a -> IO (IORef a)
newIORef Set Kind
forall a. Set a
Set.empty
IORef (Set String)
usedLbls <- Set String -> IO (IORef (Set String))
forall a. a -> IO (IORef a)
newIORef Set String
forall a. Set a
Set.empty
IORef (Seq (Bool, [(String, String)], SV))
cstrs <- Seq (Bool, [(String, String)], SV)
-> IO (IORef (Seq (Bool, [(String, String)], SV)))
forall a. a -> IO (IORef a)
newIORef Seq (Bool, [(String, String)], SV)
forall a. Seq a
S.empty
IORef [SMTOption]
smtOpts <- [SMTOption] -> IO (IORef [SMTOption])
forall a. a -> IO (IORef a)
newIORef []
IORef [Objective (SV, SV)]
optGoals <- [Objective (SV, SV)] -> IO (IORef [Objective (SV, SV)])
forall a. a -> IO (IORef a)
newIORef []
IORef [(String, Maybe CallStack, SV)]
asserts <- [(String, Maybe CallStack, SV)]
-> IO (IORef [(String, Maybe CallStack, SV)])
forall a. a -> IO (IORef a)
newIORef []
IORef IncState
istate <- IncState -> IO (IORef IncState)
forall a. a -> IO (IORef a)
newIORef (IncState -> IO (IORef IncState))
-> IO IncState -> IO (IORef IncState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO IncState
newIncState
IORef (Maybe QueryState)
qstate <- Maybe QueryState -> IO (IORef (Maybe QueryState))
forall a. a -> IO (IORef a)
newIORef Maybe QueryState
forall a. Maybe a
Nothing
State -> IO State
forall (f :: * -> *) a. Applicative f => a -> f a
pure (State -> IO State) -> State -> IO State
forall a b. (a -> b) -> a -> b
$ State :: SVal
-> UTCTime
-> IORef SBVRunMode
-> IORef IncState
-> IORef [(String, CV)]
-> IORef (Seq (Name, CV -> Bool, SV))
-> IORef Int
-> IORef (Set Kind)
-> IORef (Set String)
-> IORef Inputs
-> IORef (Seq (Bool, [(String, String)], SV))
-> IORef [SV]
-> IORef TableMap
-> IORef SBVPgm
-> IORef CnstMap
-> IORef ExprMap
-> IORef ArrayMap
-> IORef FArrayMap
-> IORef UIMap
-> IORef CgMap
-> IORef [(String, [String])]
-> IORef [SMTOption]
-> IORef [Objective (SV, SV)]
-> IORef [(String, Maybe CallStack, SV)]
-> IORef (Cache SV)
-> IORef (Cache ArrayIndex)
-> IORef (Cache FArrayIndex)
-> IORef (Maybe QueryState)
-> State
State { runMode :: IORef SBVRunMode
runMode = IORef SBVRunMode
rm
, startTime :: UTCTime
startTime = UTCTime
currTime
, pathCond :: SVal
pathCond = Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool (CV -> Either CV (Cached SV)
forall a b. a -> Either a b
Left CV
trueCV)
, rIncState :: IORef IncState
rIncState = IORef IncState
istate
, rCInfo :: IORef [(String, CV)]
rCInfo = IORef [(String, CV)]
cInfo
, rObservables :: IORef (Seq (Name, CV -> Bool, SV))
rObservables = IORef (Seq (Name, CV -> Bool, SV))
observes
, rctr :: IORef Int
rctr = IORef Int
ctr
, rUsedKinds :: IORef (Set Kind)
rUsedKinds = IORef (Set Kind)
usedKinds
, rUsedLbls :: IORef (Set String)
rUsedLbls = IORef (Set String)
usedLbls
, rinps :: IORef Inputs
rinps = IORef Inputs
inps
, routs :: IORef [SV]
routs = IORef [SV]
outs
, rtblMap :: IORef TableMap
rtblMap = IORef TableMap
tables
, spgm :: IORef SBVPgm
spgm = IORef SBVPgm
pgm
, rconstMap :: IORef CnstMap
rconstMap = IORef CnstMap
cmap
, rArrayMap :: IORef ArrayMap
rArrayMap = IORef ArrayMap
arrays
, rFArrayMap :: IORef FArrayMap
rFArrayMap = IORef FArrayMap
fArrays
, rexprMap :: IORef ExprMap
rexprMap = IORef ExprMap
emap
, rUIMap :: IORef UIMap
rUIMap = IORef UIMap
uis
, rCgMap :: IORef CgMap
rCgMap = IORef CgMap
cgs
, raxioms :: IORef [(String, [String])]
raxioms = IORef [(String, [String])]
axioms
, rSVCache :: IORef (Cache SV)
rSVCache = IORef (Cache SV)
swCache
, rAICache :: IORef (Cache ArrayIndex)
rAICache = IORef (Cache ArrayIndex)
aiCache
, rFAICache :: IORef (Cache FArrayIndex)
rFAICache = IORef (Cache FArrayIndex)
faiCache
, rConstraints :: IORef (Seq (Bool, [(String, String)], SV))
rConstraints = IORef (Seq (Bool, [(String, String)], SV))
cstrs
, rSMTOptions :: IORef [SMTOption]
rSMTOptions = IORef [SMTOption]
smtOpts
, rOptGoals :: IORef [Objective (SV, SV)]
rOptGoals = IORef [Objective (SV, SV)]
optGoals
, rAsserts :: IORef [(String, Maybe CallStack, SV)]
rAsserts = IORef [(String, Maybe CallStack, SV)]
asserts
, rQueryState :: IORef (Maybe QueryState)
rQueryState = IORef (Maybe QueryState)
qstate
}
SV
_ <- IO SV -> m SV
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SV -> m SV) -> IO SV -> m SV
forall a b. (a -> b) -> a -> b
$ State -> CV -> IO SV
newConst State
st CV
falseCV
SV
_ <- IO SV -> m SV
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SV -> m SV) -> IO SV -> m SV
forall a b. (a -> b) -> a -> b
$ State -> CV -> IO SV
newConst State
st CV
trueCV
a
r <- ReaderT State m a -> State -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT ReaderT State m a
c State
st
Result
res <- IO Result -> m Result
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> m Result) -> IO Result -> m Result
forall a b. (a -> b) -> a -> b
$ State -> IO Result
extractSymbolicSimulationState State
st
Maybe QueryState
qs <- IO (Maybe QueryState) -> m (Maybe QueryState)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe QueryState) -> m (Maybe QueryState))
-> IO (Maybe QueryState) -> m (Maybe QueryState)
forall a b. (a -> b) -> a -> b
$ IORef (Maybe QueryState) -> IO (Maybe QueryState)
forall a. IORef a -> IO a
readIORef (IORef (Maybe QueryState) -> IO (Maybe QueryState))
-> IORef (Maybe QueryState) -> IO (Maybe QueryState)
forall a b. (a -> b) -> a -> b
$ State -> IORef (Maybe QueryState)
rQueryState State
st
case Maybe QueryState
qs of
Maybe QueryState
Nothing -> () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just QueryState{IO ()
queryTerminate :: IO ()
queryTerminate :: QueryState -> IO ()
queryTerminate} -> IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
queryTerminate
(a, Result) -> m (a, Result)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
r, Result
res)
extractSymbolicSimulationState :: State -> IO Result
st :: State
st@State{ spgm :: State -> IORef SBVPgm
spgm=IORef SBVPgm
pgm, rinps :: State -> IORef Inputs
rinps=IORef Inputs
inps, routs :: State -> IORef [SV]
routs=IORef [SV]
outs, rtblMap :: State -> IORef TableMap
rtblMap=IORef TableMap
tables, rArrayMap :: State -> IORef ArrayMap
rArrayMap=IORef ArrayMap
arrays, rUIMap :: State -> IORef UIMap
rUIMap=IORef UIMap
uis, raxioms :: State -> IORef [(String, [String])]
raxioms=IORef [(String, [String])]
axioms
, rAsserts :: State -> IORef [(String, Maybe CallStack, SV)]
rAsserts=IORef [(String, Maybe CallStack, SV)]
asserts, rUsedKinds :: State -> IORef (Set Kind)
rUsedKinds=IORef (Set Kind)
usedKinds, rCgMap :: State -> IORef CgMap
rCgMap=IORef CgMap
cgs, rCInfo :: State -> IORef [(String, CV)]
rCInfo=IORef [(String, CV)]
cInfo, rConstraints :: State -> IORef (Seq (Bool, [(String, String)], SV))
rConstraints=IORef (Seq (Bool, [(String, String)], SV))
cstrs
, rObservables :: State -> IORef (Seq (Name, CV -> Bool, SV))
rObservables=IORef (Seq (Name, CV -> Bool, SV))
observes
} = do
SBVPgm Seq (SV, SBVExpr)
rpgm <- IORef SBVPgm -> IO SBVPgm
forall a. IORef a -> IO a
readIORef IORef SBVPgm
pgm
([(Quantifier, NamedSymVar)], [NamedSymVar])
inpsO <- Inputs -> ([(Quantifier, NamedSymVar)], [NamedSymVar])
inputsToList (Inputs -> ([(Quantifier, NamedSymVar)], [NamedSymVar]))
-> IO Inputs -> IO ([(Quantifier, NamedSymVar)], [NamedSymVar])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef Inputs -> IO Inputs
forall a. IORef a -> IO a
readIORef IORef Inputs
inps
[SV]
outsO <- [SV] -> [SV]
forall a. [a] -> [a]
reverse ([SV] -> [SV]) -> IO [SV] -> IO [SV]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef [SV] -> IO [SV]
forall a. IORef a -> IO a
readIORef IORef [SV]
outs
let swap :: (b, a) -> (a, b)
swap (b
a, a
b) = (a
b, b
a)
cmp :: (a, b) -> (a, b) -> Ordering
cmp (a
a, b
_) (a
b, b
_) = a
a a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` a
b
arrange :: (a, (b, c, b)) -> ((a, b, c), b)
arrange (a
i, (b
at, c
rt, b
es)) = ((a
i, b
at, c
rt), b
es)
CnstMap
constMap <- IORef CnstMap -> IO CnstMap
forall a. IORef a -> IO a
readIORef (State -> IORef CnstMap
rconstMap State
st)
let cnsts :: [(SV, CV)]
cnsts = ((SV, CV) -> (SV, CV) -> Ordering) -> [(SV, CV)] -> [(SV, CV)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (SV, CV) -> (SV, CV) -> Ordering
forall a b b. Ord a => (a, b) -> (a, b) -> Ordering
cmp ([(SV, CV)] -> [(SV, CV)])
-> (CnstMap -> [(SV, CV)]) -> CnstMap -> [(SV, CV)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((CV, SV) -> (SV, CV)) -> [(CV, SV)] -> [(SV, CV)]
forall a b. (a -> b) -> [a] -> [b]
map (CV, SV) -> (SV, CV)
forall b a. (b, a) -> (a, b)
swap ([(CV, SV)] -> [(SV, CV)])
-> (CnstMap -> [(CV, SV)]) -> CnstMap -> [(SV, CV)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CnstMap -> [(CV, SV)]
forall k a. Map k a -> [(k, a)]
Map.toList (CnstMap -> [(SV, CV)]) -> CnstMap -> [(SV, CV)]
forall a b. (a -> b) -> a -> b
$ CnstMap
constMap
[((Int, Kind, Kind), [SV])]
tbls <- ((Int, (Kind, Kind, [SV])) -> ((Int, Kind, Kind), [SV]))
-> [(Int, (Kind, Kind, [SV]))] -> [((Int, Kind, Kind), [SV])]
forall a b. (a -> b) -> [a] -> [b]
map (Int, (Kind, Kind, [SV])) -> ((Int, Kind, Kind), [SV])
forall a b c b. (a, (b, c, b)) -> ((a, b, c), b)
arrange ([(Int, (Kind, Kind, [SV]))] -> [((Int, Kind, Kind), [SV])])
-> (TableMap -> [(Int, (Kind, Kind, [SV]))])
-> TableMap
-> [((Int, Kind, Kind), [SV])]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int, (Kind, Kind, [SV]))
-> (Int, (Kind, Kind, [SV])) -> Ordering)
-> [(Int, (Kind, Kind, [SV]))] -> [(Int, (Kind, Kind, [SV]))]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (Int, (Kind, Kind, [SV])) -> (Int, (Kind, Kind, [SV])) -> Ordering
forall a b b. Ord a => (a, b) -> (a, b) -> Ordering
cmp ([(Int, (Kind, Kind, [SV]))] -> [(Int, (Kind, Kind, [SV]))])
-> (TableMap -> [(Int, (Kind, Kind, [SV]))])
-> TableMap
-> [(Int, (Kind, Kind, [SV]))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((Kind, Kind, [SV]), Int) -> (Int, (Kind, Kind, [SV])))
-> [((Kind, Kind, [SV]), Int)] -> [(Int, (Kind, Kind, [SV]))]
forall a b. (a -> b) -> [a] -> [b]
map ((Kind, Kind, [SV]), Int) -> (Int, (Kind, Kind, [SV]))
forall b a. (b, a) -> (a, b)
swap ([((Kind, Kind, [SV]), Int)] -> [(Int, (Kind, Kind, [SV]))])
-> (TableMap -> [((Kind, Kind, [SV]), Int)])
-> TableMap
-> [(Int, (Kind, Kind, [SV]))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableMap -> [((Kind, Kind, [SV]), Int)]
forall k a. Map k a -> [(k, a)]
Map.toList (TableMap -> [((Int, Kind, Kind), [SV])])
-> IO TableMap -> IO [((Int, Kind, Kind), [SV])]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef TableMap -> IO TableMap
forall a. IORef a -> IO a
readIORef IORef TableMap
tables
[(Int, ArrayInfo)]
arrs <- ArrayMap -> [(Int, ArrayInfo)]
forall a. IntMap a -> [(Int, a)]
IMap.toAscList (ArrayMap -> [(Int, ArrayInfo)])
-> IO ArrayMap -> IO [(Int, ArrayInfo)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef ArrayMap -> IO ArrayMap
forall a. IORef a -> IO a
readIORef IORef ArrayMap
arrays
[(String, SBVType)]
unint <- UIMap -> [(String, SBVType)]
forall k a. Map k a -> [(k, a)]
Map.toList (UIMap -> [(String, SBVType)])
-> IO UIMap -> IO [(String, SBVType)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef UIMap -> IO UIMap
forall a. IORef a -> IO a
readIORef IORef UIMap
uis
[(String, [String])]
axs <- [(String, [String])] -> [(String, [String])]
forall a. [a] -> [a]
reverse ([(String, [String])] -> [(String, [String])])
-> IO [(String, [String])] -> IO [(String, [String])]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef [(String, [String])] -> IO [(String, [String])]
forall a. IORef a -> IO a
readIORef IORef [(String, [String])]
axioms
Set Kind
knds <- IORef (Set Kind) -> IO (Set Kind)
forall a. IORef a -> IO a
readIORef IORef (Set Kind)
usedKinds
[(String, [String])]
cgMap <- CgMap -> [(String, [String])]
forall k a. Map k a -> [(k, a)]
Map.toList (CgMap -> [(String, [String])])
-> IO CgMap -> IO [(String, [String])]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef CgMap -> IO CgMap
forall a. IORef a -> IO a
readIORef IORef CgMap
cgs
[(String, CV)]
traceVals <- [(String, CV)] -> [(String, CV)]
forall a. [a] -> [a]
reverse ([(String, CV)] -> [(String, CV)])
-> IO [(String, CV)] -> IO [(String, CV)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef [(String, CV)] -> IO [(String, CV)]
forall a. IORef a -> IO a
readIORef IORef [(String, CV)]
cInfo
[(String, CV -> Bool, SV)]
observables <- [(String, CV -> Bool, SV)] -> [(String, CV -> Bool, SV)]
forall a. [a] -> [a]
reverse ([(String, CV -> Bool, SV)] -> [(String, CV -> Bool, SV)])
-> (Seq (Name, CV -> Bool, SV) -> [(String, CV -> Bool, SV)])
-> Seq (Name, CV -> Bool, SV)
-> [(String, CV -> Bool, SV)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Name, CV -> Bool, SV) -> (String, CV -> Bool, SV))
-> [(Name, CV -> Bool, SV)] -> [(String, CV -> Bool, SV)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Name
n,CV -> Bool
f,SV
sv) -> (Name -> String
T.unpack Name
n, CV -> Bool
f, SV
sv)) ([(Name, CV -> Bool, SV)] -> [(String, CV -> Bool, SV)])
-> (Seq (Name, CV -> Bool, SV) -> [(Name, CV -> Bool, SV)])
-> Seq (Name, CV -> Bool, SV)
-> [(String, CV -> Bool, SV)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq (Name, CV -> Bool, SV) -> [(Name, CV -> Bool, SV)]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList
(Seq (Name, CV -> Bool, SV) -> [(String, CV -> Bool, SV)])
-> IO (Seq (Name, CV -> Bool, SV)) -> IO [(String, CV -> Bool, SV)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef (Seq (Name, CV -> Bool, SV))
-> IO (Seq (Name, CV -> Bool, SV))
forall a. IORef a -> IO a
readIORef IORef (Seq (Name, CV -> Bool, SV))
observes
Seq (Bool, [(String, String)], SV)
extraCstrs <- IORef (Seq (Bool, [(String, String)], SV))
-> IO (Seq (Bool, [(String, String)], SV))
forall a. IORef a -> IO a
readIORef IORef (Seq (Bool, [(String, String)], SV))
cstrs
[(String, Maybe CallStack, SV)]
assertions <- [(String, Maybe CallStack, SV)] -> [(String, Maybe CallStack, SV)]
forall a. [a] -> [a]
reverse ([(String, Maybe CallStack, SV)]
-> [(String, Maybe CallStack, SV)])
-> IO [(String, Maybe CallStack, SV)]
-> IO [(String, Maybe CallStack, SV)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IORef [(String, Maybe CallStack, SV)]
-> IO [(String, Maybe CallStack, SV)]
forall a. IORef a -> IO a
readIORef IORef [(String, Maybe CallStack, SV)]
asserts
Result -> IO Result
forall (m :: * -> *) a. Monad m => a -> m a
return (Result -> IO Result) -> Result -> IO Result
forall a b. (a -> b) -> a -> b
$ Set Kind
-> [(String, CV)]
-> [(String, CV -> Bool, SV)]
-> [(String, [String])]
-> ([(Quantifier, NamedSymVar)], [NamedSymVar])
-> (CnstMap, [(SV, CV)])
-> [((Int, Kind, Kind), [SV])]
-> [(Int, ArrayInfo)]
-> [(String, SBVType)]
-> [(String, [String])]
-> SBVPgm
-> Seq (Bool, [(String, String)], SV)
-> [(String, Maybe CallStack, SV)]
-> [SV]
-> Result
Result Set Kind
knds [(String, CV)]
traceVals [(String, CV -> Bool, SV)]
observables [(String, [String])]
cgMap ([(Quantifier, NamedSymVar)], [NamedSymVar])
inpsO (CnstMap
constMap, [(SV, CV)]
cnsts) [((Int, Kind, Kind), [SV])]
tbls [(Int, ArrayInfo)]
arrs [(String, SBVType)]
unint [(String, [String])]
axs (Seq (SV, SBVExpr) -> SBVPgm
SBVPgm Seq (SV, SBVExpr)
rpgm) Seq (Bool, [(String, String)], SV)
extraCstrs [(String, Maybe CallStack, SV)]
assertions [SV]
outsO
addNewSMTOption :: MonadSymbolic m => SMTOption -> m ()
addNewSMTOption :: SMTOption -> m ()
addNewSMTOption SMTOption
o = do State
st <- m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
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 [SMTOption])
-> ([SMTOption] -> [SMTOption])
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [SMTOption]
rSMTOptions (SMTOption
oSMTOption -> [SMTOption] -> [SMTOption]
forall a. a -> [a] -> [a]
:) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
imposeConstraint :: MonadSymbolic m => Bool -> [(String, String)] -> SVal -> m ()
imposeConstraint :: Bool -> [(String, String)] -> SVal -> m ()
imposeConstraint Bool
isSoft [(String, String)]
attrs SVal
c = do State
st <- m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
SBVRunMode
rm <- IO SBVRunMode -> m SBVRunMode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SBVRunMode -> m SBVRunMode) -> IO SBVRunMode -> m SBVRunMode
forall a b. (a -> b) -> a -> b
$ IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef (State -> IORef SBVRunMode
runMode State
st)
case SBVRunMode
rm of
SBVRunMode
CodeGen -> String -> m ()
forall a. HasCallStack => String -> a
error String
"SBV: constraints are not allowed in code-generation"
SBVRunMode
_ -> IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do (String -> IO ()) -> [String] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (String -> State -> String -> IO ()
registerLabel String
"Constraint" State
st) [String
nm | (String
":named", String
nm) <- [(String, String)]
attrs]
State -> Bool -> [(String, String)] -> SVal -> IO ()
internalConstraint State
st Bool
isSoft [(String, String)]
attrs SVal
c
internalConstraint :: State -> Bool -> [(String, String)] -> SVal -> IO ()
internalConstraint :: State -> Bool -> [(String, String)] -> SVal -> IO ()
internalConstraint State
st Bool
isSoft [(String, String)]
attrs SVal
b = do SV
v <- State -> SVal -> IO SV
svToSV State
st SVal
b
SBVRunMode
rm <- IO SBVRunMode -> IO SBVRunMode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SBVRunMode -> IO SBVRunMode) -> IO SBVRunMode -> IO SBVRunMode
forall a b. (a -> b) -> a -> b
$ IORef SBVRunMode -> IO SBVRunMode
forall a. IORef a -> IO a
readIORef (State -> IORef SBVRunMode
runMode State
st)
let isValidating :: Bool
isValidating = case SBVRunMode
rm of
SMTMode QueryContext
_ IStage
_ Bool
_ SMTConfig
cfg -> SMTConfig -> Bool
validationRequested SMTConfig
cfg
SBVRunMode
CodeGen -> Bool
False
Concrete Maybe (Bool, [((Quantifier, NamedSymVar), Maybe CV)])
Nothing -> Bool
False
Concrete (Just (Bool, [((Quantifier, NamedSymVar), Maybe CV)])
_) -> Bool
True
let c :: (Bool, [(String, String)], SV)
c = (Bool
isSoft, [(String, String)]
attrs, SV
v)
interesting :: Bool
interesting = SV
v SV -> SV -> Bool
forall a. Eq a => a -> a -> Bool
/= SV
trueSV Bool -> Bool -> Bool
|| Bool -> Bool
not ([(String, String)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(String, String)]
attrs)
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool
isValidating Bool -> Bool -> Bool
|| Bool
interesting) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
State
-> (State -> IORef (Seq (Bool, [(String, String)], SV)))
-> (Seq (Bool, [(String, String)], SV)
-> Seq (Bool, [(String, String)], SV))
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef (Seq (Bool, [(String, String)], SV))
rConstraints (Seq (Bool, [(String, String)], SV)
-> (Bool, [(String, String)], SV)
-> Seq (Bool, [(String, String)], SV)
forall a. Seq a -> a -> Seq a
S.|> (Bool, [(String, String)], SV)
c)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ State
-> (IncState -> IORef (Seq (Bool, [(String, String)], SV)))
-> (Seq (Bool, [(String, String)], SV)
-> Seq (Bool, [(String, String)], SV))
-> IO ()
forall a. State -> (IncState -> IORef a) -> (a -> a) -> IO ()
modifyIncState State
st IncState -> IORef (Seq (Bool, [(String, String)], SV))
rNewConstraints (Seq (Bool, [(String, String)], SV)
-> (Bool, [(String, String)], SV)
-> Seq (Bool, [(String, String)], SV)
forall a. Seq a -> a -> Seq a
S.|> (Bool, [(String, String)], SV)
c)
addSValOptGoal :: MonadSymbolic m => Objective SVal -> m ()
addSValOptGoal :: Objective SVal -> m ()
addSValOptGoal Objective SVal
obj = do State
st <- m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
let mkGoal :: String -> SVal -> m (SV, SV)
mkGoal String
nm SVal
orig = IO (SV, SV) -> m (SV, SV)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (SV, SV) -> m (SV, SV)) -> IO (SV, SV) -> m (SV, SV)
forall a b. (a -> b) -> a -> b
$ do SV
origSV <- State -> SVal -> IO SV
svToSV State
st SVal
orig
SVal
track <- Kind -> String -> State -> IO SVal
svMkTrackerVar (SVal -> Kind
forall a. HasKind a => a -> Kind
kindOf SVal
orig) String
nm State
st
SV
trackSV <- State -> SVal -> IO SV
svToSV State
st SVal
track
(SV, SV) -> IO (SV, SV)
forall (m :: * -> *) a. Monad m => a -> m a
return (SV
origSV, SV
trackSV)
let walk :: Objective SVal -> m (Objective (SV, SV))
walk (Minimize String
nm SVal
v) = String -> (SV, SV) -> Objective (SV, SV)
forall a. String -> a -> Objective a
Minimize String
nm ((SV, SV) -> Objective (SV, SV))
-> m (SV, SV) -> m (Objective (SV, SV))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> SVal -> m (SV, SV)
mkGoal String
nm SVal
v
walk (Maximize String
nm SVal
v) = String -> (SV, SV) -> Objective (SV, SV)
forall a. String -> a -> Objective a
Maximize String
nm ((SV, SV) -> Objective (SV, SV))
-> m (SV, SV) -> m (Objective (SV, SV))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> SVal -> m (SV, SV)
mkGoal String
nm SVal
v
walk (AssertWithPenalty String
nm SVal
v Penalty
mbP) = ((SV, SV) -> Penalty -> Objective (SV, SV))
-> Penalty -> (SV, SV) -> Objective (SV, SV)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (String -> (SV, SV) -> Penalty -> Objective (SV, SV)
forall a. String -> a -> Penalty -> Objective a
AssertWithPenalty String
nm) Penalty
mbP ((SV, SV) -> Objective (SV, SV))
-> m (SV, SV) -> m (Objective (SV, SV))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> SVal -> m (SV, SV)
mkGoal String
nm SVal
v
!Objective (SV, SV)
obj' <- Objective SVal -> m (Objective (SV, SV))
walk Objective SVal
obj
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 [Objective (SV, SV)])
-> ([Objective (SV, SV)] -> [Objective (SV, SV)])
-> IO ()
-> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [Objective (SV, SV)]
rOptGoals (Objective (SV, SV)
obj' Objective (SV, SV) -> [Objective (SV, SV)] -> [Objective (SV, SV)]
forall a. a -> [a] -> [a]
:)
(IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ [String] -> IO ()
forall a. [String] -> a
noInteractive [ String
"Adding an optimization objective:"
, String
" Objective: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Objective SVal -> String
forall a. Show a => a -> String
show Objective SVal
obj
]
outputSVal :: MonadSymbolic m => SVal -> m ()
outputSVal :: SVal -> m ()
outputSVal (SVal Kind
_ (Left CV
c)) = do
State
st <- m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
SV
sv <- IO SV -> m SV
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SV -> m SV) -> IO SV -> m SV
forall a b. (a -> b) -> a -> b
$ State -> CV -> IO SV
newConst State
st CV
c
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 [SV]) -> ([SV] -> [SV]) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [SV]
routs (SV
svSV -> [SV] -> [SV]
forall a. a -> [a] -> [a]
:) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
outputSVal (SVal Kind
_ (Right Cached SV
f)) = do
State
st <- m State
forall (m :: * -> *). MonadSymbolic m => m State
symbolicEnv
SV
sv <- IO SV -> m SV
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SV -> m SV) -> IO SV -> m SV
forall a b. (a -> b) -> a -> b
$ Cached SV -> State -> IO SV
uncache Cached SV
f State
st
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 [SV]) -> ([SV] -> [SV]) -> IO () -> IO ()
forall a. State -> (State -> IORef a) -> (a -> a) -> IO () -> IO ()
modifyState State
st State -> IORef [SV]
routs (SV
svSV -> [SV] -> [SV]
forall a. a -> [a] -> [a]
:) (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
newtype Cached a = Cached (State -> IO a)
cache :: (State -> IO a) -> Cached a
cache :: (State -> IO a) -> Cached a
cache = (State -> IO a) -> Cached a
forall a. (State -> IO a) -> Cached a
Cached
uncache :: Cached SV -> State -> IO SV
uncache :: Cached SV -> State -> IO SV
uncache = (State -> IORef (Cache SV)) -> Cached SV -> State -> IO SV
forall a. (State -> IORef (Cache a)) -> Cached a -> State -> IO a
uncacheGen State -> IORef (Cache SV)
rSVCache
newtype ArrayIndex = ArrayIndex { ArrayIndex -> Int
unArrayIndex :: Int } deriving (ArrayIndex -> ArrayIndex -> Bool
(ArrayIndex -> ArrayIndex -> Bool)
-> (ArrayIndex -> ArrayIndex -> Bool) -> Eq ArrayIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArrayIndex -> ArrayIndex -> Bool
$c/= :: ArrayIndex -> ArrayIndex -> Bool
== :: ArrayIndex -> ArrayIndex -> Bool
$c== :: ArrayIndex -> ArrayIndex -> Bool
Eq, Eq ArrayIndex
Eq ArrayIndex
-> (ArrayIndex -> ArrayIndex -> Ordering)
-> (ArrayIndex -> ArrayIndex -> Bool)
-> (ArrayIndex -> ArrayIndex -> Bool)
-> (ArrayIndex -> ArrayIndex -> Bool)
-> (ArrayIndex -> ArrayIndex -> Bool)
-> (ArrayIndex -> ArrayIndex -> ArrayIndex)
-> (ArrayIndex -> ArrayIndex -> ArrayIndex)
-> Ord ArrayIndex
ArrayIndex -> ArrayIndex -> Bool
ArrayIndex -> ArrayIndex -> Ordering
ArrayIndex -> ArrayIndex -> ArrayIndex
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ArrayIndex -> ArrayIndex -> ArrayIndex
$cmin :: ArrayIndex -> ArrayIndex -> ArrayIndex
max :: ArrayIndex -> ArrayIndex -> ArrayIndex
$cmax :: ArrayIndex -> ArrayIndex -> ArrayIndex
>= :: ArrayIndex -> ArrayIndex -> Bool
$c>= :: ArrayIndex -> ArrayIndex -> Bool
> :: ArrayIndex -> ArrayIndex -> Bool
$c> :: ArrayIndex -> ArrayIndex -> Bool
<= :: ArrayIndex -> ArrayIndex -> Bool
$c<= :: ArrayIndex -> ArrayIndex -> Bool
< :: ArrayIndex -> ArrayIndex -> Bool
$c< :: ArrayIndex -> ArrayIndex -> Bool
compare :: ArrayIndex -> ArrayIndex -> Ordering
$ccompare :: ArrayIndex -> ArrayIndex -> Ordering
$cp1Ord :: Eq ArrayIndex
Ord, Typeable ArrayIndex
DataType
Constr
Typeable ArrayIndex
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ArrayIndex -> c ArrayIndex)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ArrayIndex)
-> (ArrayIndex -> Constr)
-> (ArrayIndex -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ArrayIndex))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ArrayIndex))
-> ((forall b. Data b => b -> b) -> ArrayIndex -> ArrayIndex)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r)
-> (forall u. (forall d. Data d => d -> u) -> ArrayIndex -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> ArrayIndex -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex)
-> Data ArrayIndex
ArrayIndex -> DataType
ArrayIndex -> Constr
(forall b. Data b => b -> b) -> ArrayIndex -> ArrayIndex
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ArrayIndex -> c ArrayIndex
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ArrayIndex
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ArrayIndex -> u
forall u. (forall d. Data d => d -> u) -> ArrayIndex -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ArrayIndex
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ArrayIndex -> c ArrayIndex
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ArrayIndex)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ArrayIndex)
$cArrayIndex :: Constr
$tArrayIndex :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
gmapMp :: (forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
gmapM :: (forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ArrayIndex -> m ArrayIndex
gmapQi :: Int -> (forall d. Data d => d -> u) -> ArrayIndex -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ArrayIndex -> u
gmapQ :: (forall d. Data d => d -> u) -> ArrayIndex -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ArrayIndex -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ArrayIndex -> r
gmapT :: (forall b. Data b => b -> b) -> ArrayIndex -> ArrayIndex
$cgmapT :: (forall b. Data b => b -> b) -> ArrayIndex -> ArrayIndex
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ArrayIndex)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ArrayIndex)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ArrayIndex)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ArrayIndex)
dataTypeOf :: ArrayIndex -> DataType
$cdataTypeOf :: ArrayIndex -> DataType
toConstr :: ArrayIndex -> Constr
$ctoConstr :: ArrayIndex -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ArrayIndex
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ArrayIndex
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ArrayIndex -> c ArrayIndex
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ArrayIndex -> c ArrayIndex
$cp1Data :: Typeable ArrayIndex
G.Data)
instance Show ArrayIndex where
show :: ArrayIndex -> String
show (ArrayIndex Int
i) = Int -> String
forall a. Show a => a -> String
show Int
i
newtype FArrayIndex = FArrayIndex { FArrayIndex -> Int
unFArrayIndex :: Int } deriving (FArrayIndex -> FArrayIndex -> Bool
(FArrayIndex -> FArrayIndex -> Bool)
-> (FArrayIndex -> FArrayIndex -> Bool) -> Eq FArrayIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FArrayIndex -> FArrayIndex -> Bool
$c/= :: FArrayIndex -> FArrayIndex -> Bool
== :: FArrayIndex -> FArrayIndex -> Bool
$c== :: FArrayIndex -> FArrayIndex -> Bool
Eq, Eq FArrayIndex
Eq FArrayIndex
-> (FArrayIndex -> FArrayIndex -> Ordering)
-> (FArrayIndex -> FArrayIndex -> Bool)
-> (FArrayIndex -> FArrayIndex -> Bool)
-> (FArrayIndex -> FArrayIndex -> Bool)
-> (FArrayIndex -> FArrayIndex -> Bool)
-> (FArrayIndex -> FArrayIndex -> FArrayIndex)
-> (FArrayIndex -> FArrayIndex -> FArrayIndex)
-> Ord FArrayIndex
FArrayIndex -> FArrayIndex -> Bool
FArrayIndex -> FArrayIndex -> Ordering
FArrayIndex -> FArrayIndex -> FArrayIndex
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: FArrayIndex -> FArrayIndex -> FArrayIndex
$cmin :: FArrayIndex -> FArrayIndex -> FArrayIndex
max :: FArrayIndex -> FArrayIndex -> FArrayIndex
$cmax :: FArrayIndex -> FArrayIndex -> FArrayIndex
>= :: FArrayIndex -> FArrayIndex -> Bool
$c>= :: FArrayIndex -> FArrayIndex -> Bool
> :: FArrayIndex -> FArrayIndex -> Bool
$c> :: FArrayIndex -> FArrayIndex -> Bool
<= :: FArrayIndex -> FArrayIndex -> Bool
$c<= :: FArrayIndex -> FArrayIndex -> Bool
< :: FArrayIndex -> FArrayIndex -> Bool
$c< :: FArrayIndex -> FArrayIndex -> Bool
compare :: FArrayIndex -> FArrayIndex -> Ordering
$ccompare :: FArrayIndex -> FArrayIndex -> Ordering
$cp1Ord :: Eq FArrayIndex
Ord)
instance Show FArrayIndex where
show :: FArrayIndex -> String
show (FArrayIndex Int
i) = Int -> String
forall a. Show a => a -> String
show Int
i
uncacheAI :: Cached ArrayIndex -> State -> IO ArrayIndex
uncacheAI :: Cached ArrayIndex -> State -> IO ArrayIndex
uncacheAI = (State -> IORef (Cache ArrayIndex))
-> Cached ArrayIndex -> State -> IO ArrayIndex
forall a. (State -> IORef (Cache a)) -> Cached a -> State -> IO a
uncacheGen State -> IORef (Cache ArrayIndex)
rAICache
uncacheFAI :: Cached FArrayIndex -> State -> IO FArrayIndex
uncacheFAI :: Cached FArrayIndex -> State -> IO FArrayIndex
uncacheFAI = (State -> IORef (Cache FArrayIndex))
-> Cached FArrayIndex -> State -> IO FArrayIndex
forall a. (State -> IORef (Cache a)) -> Cached a -> State -> IO a
uncacheGen State -> IORef (Cache FArrayIndex)
rFAICache
uncacheGen :: (State -> IORef (Cache a)) -> Cached a -> State -> IO a
uncacheGen :: (State -> IORef (Cache a)) -> Cached a -> State -> IO a
uncacheGen State -> IORef (Cache a)
getCache (Cached State -> IO a
f) State
st = do
let rCache :: IORef (Cache a)
rCache = State -> IORef (Cache a)
getCache State
st
Cache a
stored <- IORef (Cache a) -> IO (Cache a)
forall a. IORef a -> IO a
readIORef IORef (Cache a)
rCache
StableName (State -> IO a)
sn <- State -> IO a
f (State -> IO a)
-> IO (StableName (State -> IO a))
-> IO (StableName (State -> IO a))
`seq` (State -> IO a) -> IO (StableName (State -> IO a))
forall a. a -> IO (StableName a)
makeStableName State -> IO a
f
let h :: Int
h = StableName (State -> IO a) -> Int
forall a. StableName a -> Int
hashStableName StableName (State -> IO a)
sn
case (Int
h Int -> Cache a -> Maybe [(StableName (State -> IO a), a)]
forall a. Int -> IntMap a -> Maybe a
`IMap.lookup` Cache a
stored) Maybe [(StableName (State -> IO a), a)]
-> ([(StableName (State -> IO a), a)] -> Maybe a) -> Maybe a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (StableName (State -> IO a)
sn StableName (State -> IO a)
-> [(StableName (State -> IO a), a)] -> Maybe a
forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup`) of
Just a
r -> a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
Maybe a
Nothing -> do a
r <- State -> IO a
f State
st
a
r a -> IO () -> IO ()
`seq` IORef (Cache a) -> (Cache a -> Cache a) -> IO ()
forall a. IORef a -> (a -> a) -> IO ()
R.modifyIORef' IORef (Cache a)
rCache (([(StableName (State -> IO a), a)]
-> [(StableName (State -> IO a), a)]
-> [(StableName (State -> IO a), a)])
-> Int -> [(StableName (State -> IO a), a)] -> Cache a -> Cache a
forall a. (a -> a -> a) -> Int -> a -> IntMap a -> IntMap a
IMap.insertWith [(StableName (State -> IO a), a)]
-> [(StableName (State -> IO a), a)]
-> [(StableName (State -> IO a), a)]
forall a. [a] -> [a] -> [a]
(++) Int
h [(StableName (State -> IO a)
sn, a
r)])
a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
data SMTLibVersion = SMTLib2
deriving (SMTLibVersion
SMTLibVersion -> SMTLibVersion -> Bounded SMTLibVersion
forall a. a -> a -> Bounded a
maxBound :: SMTLibVersion
$cmaxBound :: SMTLibVersion
minBound :: SMTLibVersion
$cminBound :: SMTLibVersion
Bounded, Int -> SMTLibVersion
SMTLibVersion -> Int
SMTLibVersion -> [SMTLibVersion]
SMTLibVersion -> SMTLibVersion
SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
SMTLibVersion -> SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
(SMTLibVersion -> SMTLibVersion)
-> (SMTLibVersion -> SMTLibVersion)
-> (Int -> SMTLibVersion)
-> (SMTLibVersion -> Int)
-> (SMTLibVersion -> [SMTLibVersion])
-> (SMTLibVersion -> SMTLibVersion -> [SMTLibVersion])
-> (SMTLibVersion -> SMTLibVersion -> [SMTLibVersion])
-> (SMTLibVersion
-> SMTLibVersion -> SMTLibVersion -> [SMTLibVersion])
-> Enum SMTLibVersion
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SMTLibVersion -> SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
$cenumFromThenTo :: SMTLibVersion -> SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
enumFromTo :: SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
$cenumFromTo :: SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
enumFromThen :: SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
$cenumFromThen :: SMTLibVersion -> SMTLibVersion -> [SMTLibVersion]
enumFrom :: SMTLibVersion -> [SMTLibVersion]
$cenumFrom :: SMTLibVersion -> [SMTLibVersion]
fromEnum :: SMTLibVersion -> Int
$cfromEnum :: SMTLibVersion -> Int
toEnum :: Int -> SMTLibVersion
$ctoEnum :: Int -> SMTLibVersion
pred :: SMTLibVersion -> SMTLibVersion
$cpred :: SMTLibVersion -> SMTLibVersion
succ :: SMTLibVersion -> SMTLibVersion
$csucc :: SMTLibVersion -> SMTLibVersion
Enum, SMTLibVersion -> SMTLibVersion -> Bool
(SMTLibVersion -> SMTLibVersion -> Bool)
-> (SMTLibVersion -> SMTLibVersion -> Bool) -> Eq SMTLibVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SMTLibVersion -> SMTLibVersion -> Bool
$c/= :: SMTLibVersion -> SMTLibVersion -> Bool
== :: SMTLibVersion -> SMTLibVersion -> Bool
$c== :: SMTLibVersion -> SMTLibVersion -> Bool
Eq, Int -> SMTLibVersion -> ShowS
[SMTLibVersion] -> ShowS
SMTLibVersion -> String
(Int -> SMTLibVersion -> ShowS)
-> (SMTLibVersion -> String)
-> ([SMTLibVersion] -> ShowS)
-> Show SMTLibVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SMTLibVersion] -> ShowS
$cshowList :: [SMTLibVersion] -> ShowS
show :: SMTLibVersion -> String
$cshow :: SMTLibVersion -> String
showsPrec :: Int -> SMTLibVersion -> ShowS
$cshowsPrec :: Int -> SMTLibVersion -> ShowS
Show)
smtLibVersionExtension :: SMTLibVersion -> String
smtLibVersionExtension :: SMTLibVersion -> String
smtLibVersionExtension SMTLibVersion
SMTLib2 = String
"smt2"
data SMTLibPgm = SMTLibPgm SMTLibVersion [String]
instance NFData SMTLibVersion where rnf :: SMTLibVersion -> ()
rnf SMTLibVersion
a = SMTLibVersion
a SMTLibVersion -> () -> ()
`seq` ()
instance NFData SMTLibPgm where rnf :: SMTLibPgm -> ()
rnf (SMTLibPgm SMTLibVersion
v [String]
p) = SMTLibVersion -> ()
forall a. NFData a => a -> ()
rnf SMTLibVersion
v () -> () -> ()
`seq` [String] -> ()
forall a. NFData a => a -> ()
rnf [String]
p
instance Show SMTLibPgm where
show :: SMTLibPgm -> String
show (SMTLibPgm SMTLibVersion
_ [String]
pre) = String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"\n" [String]
pre
instance NFData CV where
rnf :: CV -> ()
rnf (CV Kind
x CVal
y) = Kind
x Kind -> () -> ()
`seq` CVal
y CVal -> () -> ()
`seq` ()
instance NFData GeneralizedCV where
rnf :: GeneralizedCV -> ()
rnf (ExtendedCV ExtCV
e) = ExtCV
e ExtCV -> () -> ()
`seq` ()
rnf (RegularCV CV
c) = CV
c CV -> () -> ()
`seq` ()
#if MIN_VERSION_base(4,9,0)
#else
instance NFData CallStack where
rnf _ = ()
#endif
instance NFData NamedSymVar where
rnf :: NamedSymVar -> ()
rnf (NamedSymVar SV
s Name
n) = SV -> ()
forall a. NFData a => a -> ()
rnf SV
s () -> () -> ()
`seq` Name -> ()
forall a. NFData a => a -> ()
rnf Name
n
instance NFData Result where
rnf :: Result -> ()
rnf (Result Set Kind
kindInfo [(String, CV)]
qcInfo [(String, CV -> Bool, SV)]
obs [(String, [String])]
cgs ([(Quantifier, NamedSymVar)], [NamedSymVar])
inps (CnstMap, [(SV, CV)])
consts [((Int, Kind, Kind), [SV])]
tbls [(Int, ArrayInfo)]
arrs [(String, SBVType)]
uis [(String, [String])]
axs SBVPgm
pgm Seq (Bool, [(String, String)], SV)
cstr [(String, Maybe CallStack, SV)]
asserts [SV]
outs)
= Set Kind -> ()
forall a. NFData a => a -> ()
rnf Set Kind
kindInfo () -> () -> ()
`seq` [(String, CV)] -> ()
forall a. NFData a => a -> ()
rnf [(String, CV)]
qcInfo () -> () -> ()
`seq` [(String, CV -> Bool, SV)] -> ()
forall a. NFData a => a -> ()
rnf [(String, CV -> Bool, SV)]
obs () -> () -> ()
`seq` [(String, [String])] -> ()
forall a. NFData a => a -> ()
rnf [(String, [String])]
cgs
() -> () -> ()
`seq` ([(Quantifier, NamedSymVar)], [NamedSymVar]) -> ()
forall a. NFData a => a -> ()
rnf ([(Quantifier, NamedSymVar)], [NamedSymVar])
inps () -> () -> ()
`seq` (CnstMap, [(SV, CV)]) -> ()
forall a. NFData a => a -> ()
rnf (CnstMap, [(SV, CV)])
consts () -> () -> ()
`seq` [((Int, Kind, Kind), [SV])] -> ()
forall a. NFData a => a -> ()
rnf [((Int, Kind, Kind), [SV])]
tbls
() -> () -> ()
`seq` [(Int, ArrayInfo)] -> ()
forall a. NFData a => a -> ()
rnf [(Int, ArrayInfo)]
arrs () -> () -> ()
`seq` [(String, SBVType)] -> ()
forall a. NFData a => a -> ()
rnf [(String, SBVType)]
uis () -> () -> ()
`seq` [(String, [String])] -> ()
forall a. NFData a => a -> ()
rnf [(String, [String])]
axs
() -> () -> ()
`seq` SBVPgm -> ()
forall a. NFData a => a -> ()
rnf SBVPgm
pgm () -> () -> ()
`seq` Seq (Bool, [(String, String)], SV) -> ()
forall a. NFData a => a -> ()
rnf Seq (Bool, [(String, String)], SV)
cstr () -> () -> ()
`seq` [(String, Maybe CallStack, SV)] -> ()
forall a. NFData a => a -> ()
rnf [(String, Maybe CallStack, SV)]
asserts
() -> () -> ()
`seq` [SV] -> ()
forall a. NFData a => a -> ()
rnf [SV]
outs
instance NFData Kind where rnf :: Kind -> ()
rnf Kind
a = Kind -> () -> ()
seq Kind
a ()
instance NFData ArrayContext where rnf :: ArrayContext -> ()
rnf ArrayContext
a = ArrayContext -> () -> ()
seq ArrayContext
a ()
instance NFData SV where rnf :: SV -> ()
rnf SV
a = SV -> () -> ()
seq SV
a ()
instance NFData SBVExpr where rnf :: SBVExpr -> ()
rnf SBVExpr
a = SBVExpr -> () -> ()
seq SBVExpr
a ()
instance NFData Quantifier where rnf :: Quantifier -> ()
rnf Quantifier
a = Quantifier -> () -> ()
seq Quantifier
a ()
instance NFData SBVType where rnf :: SBVType -> ()
rnf SBVType
a = SBVType -> () -> ()
seq SBVType
a ()
instance NFData SBVPgm where rnf :: SBVPgm -> ()
rnf SBVPgm
a = SBVPgm -> () -> ()
seq SBVPgm
a ()
instance NFData (Cached a) where rnf :: Cached a -> ()
rnf (Cached State -> IO a
f) = State -> IO a
f (State -> IO a) -> () -> ()
`seq` ()
instance NFData SVal where rnf :: SVal -> ()
rnf (SVal Kind
x Either CV (Cached SV)
y) = Kind -> ()
forall a. NFData a => a -> ()
rnf Kind
x () -> () -> ()
`seq` Either CV (Cached SV) -> ()
forall a. NFData a => a -> ()
rnf Either CV (Cached SV)
y
instance NFData SMTResult where
rnf :: SMTResult -> ()
rnf (Unsatisfiable SMTConfig
_ Maybe [String]
m ) = Maybe [String] -> ()
forall a. NFData a => a -> ()
rnf Maybe [String]
m
rnf (Satisfiable SMTConfig
_ SMTModel
m ) = SMTModel -> ()
forall a. NFData a => a -> ()
rnf SMTModel
m
rnf (DeltaSat SMTConfig
_ Maybe String
p SMTModel
m ) = SMTModel -> ()
forall a. NFData a => a -> ()
rnf SMTModel
m () -> () -> ()
`seq` Maybe String -> ()
forall a. NFData a => a -> ()
rnf Maybe String
p
rnf (SatExtField SMTConfig
_ SMTModel
m ) = SMTModel -> ()
forall a. NFData a => a -> ()
rnf SMTModel
m
rnf (Unknown SMTConfig
_ SMTReasonUnknown
m ) = SMTReasonUnknown -> ()
forall a. NFData a => a -> ()
rnf SMTReasonUnknown
m
rnf (ProofError SMTConfig
_ [String]
m Maybe SMTResult
mr) = [String] -> ()
forall a. NFData a => a -> ()
rnf [String]
m () -> () -> ()
`seq` Maybe SMTResult -> ()
forall a. NFData a => a -> ()
rnf Maybe SMTResult
mr
instance NFData SMTModel where
rnf :: SMTModel -> ()
rnf (SMTModel [(String, GeneralizedCV)]
objs Maybe [((Quantifier, NamedSymVar), Maybe CV)]
bndgs [(String, CV)]
assocs [(String, (SBVType, ([([CV], CV)], CV)))]
uifuns) = [(String, GeneralizedCV)] -> ()
forall a. NFData a => a -> ()
rnf [(String, GeneralizedCV)]
objs () -> () -> ()
`seq` Maybe [((Quantifier, NamedSymVar), Maybe CV)] -> ()
forall a. NFData a => a -> ()
rnf Maybe [((Quantifier, NamedSymVar), Maybe CV)]
bndgs () -> () -> ()
`seq` [(String, CV)] -> ()
forall a. NFData a => a -> ()
rnf [(String, CV)]
assocs () -> () -> ()
`seq` [(String, (SBVType, ([([CV], CV)], CV)))] -> ()
forall a. NFData a => a -> ()
rnf [(String, (SBVType, ([([CV], CV)], CV)))]
uifuns
instance NFData SMTScript where
rnf :: SMTScript -> ()
rnf (SMTScript String
b [String]
m) = String -> ()
forall a. NFData a => a -> ()
rnf String
b () -> () -> ()
`seq` [String] -> ()
forall a. NFData a => a -> ()
rnf [String]
m
data SolverCapabilities = SolverCapabilities {
SolverCapabilities -> Bool
supportsQuantifiers :: Bool
, SolverCapabilities -> Bool
supportsDefineFun :: Bool
, SolverCapabilities -> Bool
supportsDistinct :: Bool
, SolverCapabilities -> Bool
supportsBitVectors :: Bool
, SolverCapabilities -> Bool
supportsUninterpretedSorts :: Bool
, SolverCapabilities -> Bool
supportsUnboundedInts :: Bool
, SolverCapabilities -> Bool
supportsInt2bv :: Bool
, SolverCapabilities -> Bool
supportsReals :: Bool
, SolverCapabilities -> Bool
supportsApproxReals :: Bool
, SolverCapabilities -> Maybe String
supportsDeltaSat :: Maybe String
, SolverCapabilities -> Bool
supportsIEEE754 :: Bool
, SolverCapabilities -> Bool
supportsSets :: Bool
, SolverCapabilities -> Bool
supportsOptimization :: Bool
, SolverCapabilities -> Bool
supportsPseudoBooleans :: Bool
, SolverCapabilities -> Bool
supportsCustomQueries :: Bool
, SolverCapabilities -> Bool
supportsGlobalDecls :: Bool
, SolverCapabilities -> Bool
supportsDataTypes :: Bool
, SolverCapabilities -> Bool
supportsDirectAccessors :: Bool
, SolverCapabilities -> Maybe [String]
supportsFlattenedModels :: Maybe [String]
}
data SMTConfig = SMTConfig {
SMTConfig -> Bool
verbose :: Bool
, SMTConfig -> Timing
timing :: Timing
, SMTConfig -> Int
printBase :: Int
, SMTConfig -> Int
printRealPrec :: Int
, SMTConfig -> Bool
crackNum :: Bool
, SMTConfig -> String
satCmd :: String
, SMTConfig -> Maybe Int
allSatMaxModelCount :: Maybe Int
, SMTConfig -> Bool
allSatPrintAlong :: Bool
, SMTConfig -> Bool
satTrackUFs :: Bool
, SMTConfig -> String -> Bool
isNonModelVar :: String -> Bool
, SMTConfig -> Bool
validateModel :: Bool
, SMTConfig -> Bool
optimizeValidateConstraints :: Bool
, SMTConfig -> Maybe String
transcript :: Maybe FilePath
, SMTConfig -> SMTLibVersion
smtLibVersion :: SMTLibVersion
, SMTConfig -> Maybe Double
dsatPrecision :: Maybe Double
, SMTConfig -> SMTSolver
solver :: SMTSolver
, :: [String]
, SMTConfig -> Bool
allowQuantifiedQueries :: Bool
, SMTConfig -> RoundingMode
roundingMode :: RoundingMode
, SMTConfig -> [SMTOption]
solverSetOptions :: [SMTOption]
, SMTConfig -> Bool
ignoreExitCode :: Bool
, SMTConfig -> Maybe String
redirectVerbose :: Maybe FilePath
}
instance Show SMTConfig where
show :: SMTConfig -> String
show = Solver -> String
forall a. Show a => a -> String
show (Solver -> String) -> (SMTConfig -> Solver) -> SMTConfig -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SMTSolver -> Solver
name (SMTSolver -> Solver)
-> (SMTConfig -> SMTSolver) -> SMTConfig -> Solver
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SMTConfig -> SMTSolver
solver
validationRequested :: SMTConfig -> Bool
validationRequested :: SMTConfig -> Bool
validationRequested SMTConfig{Bool
validateModel :: Bool
validateModel :: SMTConfig -> Bool
validateModel, Bool
optimizeValidateConstraints :: Bool
optimizeValidateConstraints :: SMTConfig -> Bool
optimizeValidateConstraints} = Bool
validateModel Bool -> Bool -> Bool
|| Bool
optimizeValidateConstraints
instance NFData SMTConfig where
rnf :: SMTConfig -> ()
rnf SMTConfig{} = ()
data SMTModel = SMTModel {
SMTModel -> [(String, GeneralizedCV)]
modelObjectives :: [(String, GeneralizedCV)]
, SMTModel -> Maybe [((Quantifier, NamedSymVar), Maybe CV)]
modelBindings :: Maybe [((Quantifier, NamedSymVar), Maybe CV)]
, SMTModel -> [(String, CV)]
modelAssocs :: [(String, CV)]
, SMTModel -> [(String, (SBVType, ([([CV], CV)], CV)))]
modelUIFuns :: [(String, (SBVType, ([([CV], CV)], CV)))]
}
deriving Int -> SMTModel -> ShowS
[SMTModel] -> ShowS
SMTModel -> String
(Int -> SMTModel -> ShowS)
-> (SMTModel -> String) -> ([SMTModel] -> ShowS) -> Show SMTModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SMTModel] -> ShowS
$cshowList :: [SMTModel] -> ShowS
show :: SMTModel -> String
$cshow :: SMTModel -> String
showsPrec :: Int -> SMTModel -> ShowS
$cshowsPrec :: Int -> SMTModel -> ShowS
Show
data SMTResult = Unsatisfiable SMTConfig (Maybe [String])
| Satisfiable SMTConfig SMTModel
| DeltaSat SMTConfig (Maybe String) SMTModel
| SatExtField SMTConfig SMTModel
| Unknown SMTConfig SMTReasonUnknown
| ProofError SMTConfig [String] (Maybe SMTResult)
data SMTScript = SMTScript {
SMTScript -> String
scriptBody :: String
, SMTScript -> [String]
scriptModel :: [String]
}
type SMTEngine = forall res.
SMTConfig
-> State
-> String
-> (State -> IO res)
-> IO res
data Solver = ABC
| Boolector
| CVC4
| DReal
| MathSAT
| Yices
| Z3
deriving (Int -> Solver -> ShowS
[Solver] -> ShowS
Solver -> String
(Int -> Solver -> ShowS)
-> (Solver -> String) -> ([Solver] -> ShowS) -> Show Solver
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Solver] -> ShowS
$cshowList :: [Solver] -> ShowS
show :: Solver -> String
$cshow :: Solver -> String
showsPrec :: Int -> Solver -> ShowS
$cshowsPrec :: Int -> Solver -> ShowS
Show, Int -> Solver
Solver -> Int
Solver -> [Solver]
Solver -> Solver
Solver -> Solver -> [Solver]
Solver -> Solver -> Solver -> [Solver]
(Solver -> Solver)
-> (Solver -> Solver)
-> (Int -> Solver)
-> (Solver -> Int)
-> (Solver -> [Solver])
-> (Solver -> Solver -> [Solver])
-> (Solver -> Solver -> [Solver])
-> (Solver -> Solver -> Solver -> [Solver])
-> Enum Solver
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Solver -> Solver -> Solver -> [Solver]
$cenumFromThenTo :: Solver -> Solver -> Solver -> [Solver]
enumFromTo :: Solver -> Solver -> [Solver]
$cenumFromTo :: Solver -> Solver -> [Solver]
enumFromThen :: Solver -> Solver -> [Solver]
$cenumFromThen :: Solver -> Solver -> [Solver]
enumFrom :: Solver -> [Solver]
$cenumFrom :: Solver -> [Solver]
fromEnum :: Solver -> Int
$cfromEnum :: Solver -> Int
toEnum :: Int -> Solver
$ctoEnum :: Int -> Solver
pred :: Solver -> Solver
$cpred :: Solver -> Solver
succ :: Solver -> Solver
$csucc :: Solver -> Solver
Enum, Solver
Solver -> Solver -> Bounded Solver
forall a. a -> a -> Bounded a
maxBound :: Solver
$cmaxBound :: Solver
minBound :: Solver
$cminBound :: Solver
Bounded)
data SMTSolver = SMTSolver {
SMTSolver -> Solver
name :: Solver
, SMTSolver -> String
executable :: String
, SMTSolver -> ShowS
preprocess :: String -> String
, SMTSolver -> SMTConfig -> [String]
options :: SMTConfig -> [String]
, SMTSolver
-> forall res.
SMTConfig -> State -> String -> (State -> IO res) -> IO res
engine :: SMTEngine
, SMTSolver -> SolverCapabilities
capabilities :: SolverCapabilities
}
data QueryContext = QueryInternal
| QueryExternal
instance Show QueryContext where
show :: QueryContext -> String
show QueryContext
QueryInternal = String
"Internal Query"
show QueryContext
QueryExternal = String
"User Query"
{-# ANN type FPOp ("HLint: ignore Use camelCase" :: String) #-}
{-# ANN type PBOp ("HLint: ignore Use camelCase" :: String) #-}
{-# ANN type OvOp ("HLint: ignore Use camelCase" :: String) #-}
{-# ANN type NROp ("HLint: ignore Use camelCase" :: String) #-}