smtlib2-0.3.1: A type-safe interface to communicate with an SMT solver.

Safe HaskellNone
LanguageHaskell98

Language.SMTLib2.Internals

Synopsis

Documentation

data CheckSatLimits Source #

Describe limits on the ressources that an SMT-solver can use

Constructors

CheckSatLimits 

Fields

class Monad m => SMTBackend a m where Source #

Minimal complete definition

smtHandle, smtGetNames, smtNextName

Methods

smtHandle :: Typeable response => a -> SMTRequest response -> m (response, a) Source #

smtGetNames :: a -> m (Integer -> String) Source #

smtNextName :: a -> m (Maybe String -> String) Source #

Instances

MonadIO m => SMTBackend SMTPipe m Source # 

Methods

smtHandle :: Typeable * response => SMTPipe -> SMTRequest response -> m (response, SMTPipe) Source #

smtGetNames :: SMTPipe -> m (Integer -> String) Source #

smtNextName :: SMTPipe -> m (Maybe String -> String) Source #

Monad m => SMTBackend (AnyBackend m) m Source # 

Methods

smtHandle :: Typeable * response => AnyBackend m -> SMTRequest response -> m (response, AnyBackend m) Source #

smtGetNames :: AnyBackend m -> m (Integer -> String) Source #

smtNextName :: AnyBackend m -> m (Maybe String -> String) Source #

class (Ord t, Typeable t, Ord (SMTAnnotation t), Typeable (SMTAnnotation t), Show (SMTAnnotation t)) => SMTType t where Source #

Haskell types which can be represented in SMT

Minimal complete definition

getSort, asValueType, annotationFromSort, defaultExpr

Associated Types

type SMTAnnotation t Source #

data Unmangling a Source #

Constructors

PrimitiveUnmangling (Value -> SMTAnnotation a -> Maybe a) 
ComplexUnmangling (forall m s. Monad m => (forall b. SMTValue b => s -> SMTExpr b -> SMTAnnotation b -> m (b, s)) -> s -> SMTExpr a -> SMTAnnotation a -> m (Maybe a, s)) 

class (SMTType t, Show t) => SMTValue t where Source #

Haskell values which can be represented as SMT constants

Minimal complete definition

unmangle, mangle

class (SMTValue t, Num t, SMTAnnotation t ~ ()) => SMTArith t Source #

A type class for all types which support arithmetic operations in SMT

class SMTType t => SMTOrd t where Source #

Lifts the Ord class into SMT

Minimal complete definition

(.<.), (.>=.), (.>.), (.<=.)

Methods

(.<.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source #

(.>=.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source #

(.>.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source #

(.<=.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source #

data SMTArray i v Source #

An array which maps indices of type i to elements of type v.

Constructors

SMTArray 

Instances

Eq (SMTArray i v) Source # 

Methods

(==) :: SMTArray i v -> SMTArray i v -> Bool #

(/=) :: SMTArray i v -> SMTArray i v -> Bool #

Ord (SMTArray i v) Source # 

Methods

compare :: SMTArray i v -> SMTArray i v -> Ordering #

(<) :: SMTArray i v -> SMTArray i v -> Bool #

(<=) :: SMTArray i v -> SMTArray i v -> Bool #

(>) :: SMTArray i v -> SMTArray i v -> Bool #

(>=) :: SMTArray i v -> SMTArray i v -> Bool #

max :: SMTArray i v -> SMTArray i v -> SMTArray i v #

min :: SMTArray i v -> SMTArray i v -> SMTArray i v #

type SMTAnnotation (SMTArray idx val) Source # 

data AnyBackend m Source #

Constructors

SMTBackend b m => AnyBackend b 

Instances

Monad m => SMTBackend (AnyBackend m) m Source # 

Methods

smtHandle :: Typeable * response => AnyBackend m -> SMTRequest response -> m (response, AnyBackend m) Source #

smtGetNames :: AnyBackend m -> m (Integer -> String) Source #

smtNextName :: AnyBackend m -> m (Maybe String -> String) Source #

data SMT' m a Source #

The SMT monad used for communating with the SMT solver

Constructors

SMT 

Fields

Instances

MonadTrans SMT' Source # 

Methods

lift :: Monad m => m a -> SMT' m a #

Monad m => Monad (SMT' m) Source # 

Methods

(>>=) :: SMT' m a -> (a -> SMT' m b) -> SMT' m b #

(>>) :: SMT' m a -> SMT' m b -> SMT' m b #

return :: a -> SMT' m a #

fail :: String -> SMT' m a #

Functor m => Functor (SMT' m) Source # 

Methods

fmap :: (a -> b) -> SMT' m a -> SMT' m b #

(<$) :: a -> SMT' m b -> SMT' m a #

MonadFix m => MonadFix (SMT' m) Source # 

Methods

mfix :: (a -> SMT' m a) -> SMT' m a #

(Monad m, Functor m) => Applicative (SMT' m) Source # 

Methods

pure :: a -> SMT' m a #

(<*>) :: SMT' m (a -> b) -> SMT' m a -> SMT' m b #

(*>) :: SMT' m a -> SMT' m b -> SMT' m b #

(<*) :: SMT' m a -> SMT' m b -> SMT' m a #

MonadIO m => MonadIO (SMT' m) Source # 

Methods

liftIO :: IO a -> SMT' m a #

type SMT = SMT' IO Source #

smtBackend :: Monad m => (forall b. SMTBackend b m => b -> m (res, b)) -> SMT' m res Source #

data SMTExpr t where Source #

An abstract SMT expression

Constructors

Var :: SMTType t => Integer -> SMTAnnotation t -> SMTExpr t 
QVar :: SMTType t => Integer -> Integer -> SMTAnnotation t -> SMTExpr t 
FunArg :: SMTType t => Integer -> SMTAnnotation t -> SMTExpr t 
Const :: SMTValue t => t -> SMTAnnotation t -> SMTExpr t 
AsArray :: (Args arg, SMTType res) => SMTFunction arg res -> ArgAnnotation arg -> SMTExpr (SMTArray arg res) 
Forall :: Integer -> [ProxyArg] -> SMTExpr Bool -> SMTExpr Bool 
Exists :: Integer -> [ProxyArg] -> SMTExpr Bool -> SMTExpr Bool 
Let :: Integer -> [SMTExpr Untyped] -> SMTExpr b -> SMTExpr b 
App :: (Args arg, SMTType res) => SMTFunction arg res -> arg -> SMTExpr res 
Named :: SMTExpr a -> Integer -> SMTExpr a 
InternalObj :: (SMTType t, Typeable a, Ord a, Show a) => a -> SMTAnnotation t -> SMTExpr t 
UntypedExpr :: SMTType t => SMTExpr t -> SMTExpr Untyped 
UntypedExprValue :: SMTValue t => SMTExpr t -> SMTExpr UntypedValue 

Instances

Show (SMTExpr t) Source # 

Methods

showsPrec :: Int -> SMTExpr t -> ShowS #

show :: SMTExpr t -> String #

showList :: [SMTExpr t] -> ShowS #

type Unpacked (SMTExpr a) Source # 
type Unpacked (SMTExpr a) = a
type ArgAnnotation (SMTExpr a) Source # 
type Lifted [SMTExpr a] i Source # 
type Lifted [SMTExpr a] i = [SMTExpr (SMTArray i a)]
type Lifted (SMTExpr a) i Source # 
type Lifted (SMTExpr a) i = SMTExpr (SMTArray i a)

data Sort' a Source #

Instances

Functor Sort' Source # 

Methods

fmap :: (a -> b) -> Sort' a -> Sort' b #

(<$) :: a -> Sort' b -> Sort' a #

Foldable Sort' Source # 

Methods

fold :: Monoid m => Sort' m -> m #

foldMap :: Monoid m => (a -> m) -> Sort' a -> m #

foldr :: (a -> b -> b) -> b -> Sort' a -> b #

foldr' :: (a -> b -> b) -> b -> Sort' a -> b #

foldl :: (b -> a -> b) -> b -> Sort' a -> b #

foldl' :: (b -> a -> b) -> b -> Sort' a -> b #

foldr1 :: (a -> a -> a) -> Sort' a -> a #

foldl1 :: (a -> a -> a) -> Sort' a -> a #

toList :: Sort' a -> [a] #

null :: Sort' a -> Bool #

length :: Sort' a -> Int #

elem :: Eq a => a -> Sort' a -> Bool #

maximum :: Ord a => Sort' a -> a #

minimum :: Ord a => Sort' a -> a #

sum :: Num a => Sort' a -> a #

product :: Num a => Sort' a -> a #

Traversable Sort' Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Sort' a -> f (Sort' b) #

sequenceA :: Applicative f => Sort' (f a) -> f (Sort' a) #

mapM :: Monad m => (a -> m b) -> Sort' a -> m (Sort' b) #

sequence :: Monad m => Sort' (m a) -> m (Sort' a) #

Eq a => Eq (Sort' a) Source # 

Methods

(==) :: Sort' a -> Sort' a -> Bool #

(/=) :: Sort' a -> Sort' a -> Bool #

Ord a => Ord (Sort' a) Source # 

Methods

compare :: Sort' a -> Sort' a -> Ordering #

(<) :: Sort' a -> Sort' a -> Bool #

(<=) :: Sort' a -> Sort' a -> Bool #

(>) :: Sort' a -> Sort' a -> Bool #

(>=) :: Sort' a -> Sort' a -> Bool #

max :: Sort' a -> Sort' a -> Sort' a #

min :: Sort' a -> Sort' a -> Sort' a #

Show a => Show (Sort' a) Source # 

Methods

showsPrec :: Int -> Sort' a -> ShowS #

show :: Sort' a -> String #

showList :: [Sort' a] -> ShowS #

data SMTFunction arg res where Source #

Constructors

SMTEq :: SMTType a => SMTFunction [SMTExpr a] Bool 
SMTMap :: (Liftable arg, SMTType res, Args i) => SMTFunction arg res -> SMTFunction (Lifted arg i) (SMTArray i res) 
SMTFun :: (Args arg, SMTType res) => Integer -> SMTAnnotation res -> SMTFunction arg res 
SMTBuiltIn :: (Liftable arg, SMTType res) => String -> SMTAnnotation res -> SMTFunction arg res 
SMTOrd :: SMTArith a => SMTOrdOp -> SMTFunction (SMTExpr a, SMTExpr a) Bool 
SMTArith :: SMTArith a => SMTArithOp -> SMTFunction [SMTExpr a] a 
SMTMinus :: SMTArith a => SMTFunction (SMTExpr a, SMTExpr a) a 
SMTIntArith :: SMTIntArithOp -> SMTFunction (SMTExpr Integer, SMTExpr Integer) Integer 
SMTDivide :: SMTFunction (SMTExpr Rational, SMTExpr Rational) Rational 
SMTNeg :: (SMTType a, Num a) => SMTFunction (SMTExpr a) a 
SMTAbs :: (SMTType a, Num a) => SMTFunction (SMTExpr a) a 
SMTNot :: SMTFunction (SMTExpr Bool) Bool 
SMTLogic :: SMTLogicOp -> SMTFunction [SMTExpr Bool] Bool 
SMTDistinct :: SMTType a => SMTFunction [SMTExpr a] Bool 
SMTToReal :: SMTFunction (SMTExpr Integer) Rational 
SMTToInt :: SMTFunction (SMTExpr Rational) Integer 
SMTITE :: SMTType a => SMTFunction (SMTExpr Bool, SMTExpr a, SMTExpr a) a 
SMTBVComp :: IsBitVector a => SMTBVCompOp -> SMTFunction (SMTExpr (BitVector a), SMTExpr (BitVector a)) Bool 
SMTBVBin :: IsBitVector a => SMTBVBinOp -> SMTFunction (SMTExpr (BitVector a), SMTExpr (BitVector a)) (BitVector a) 
SMTBVUn :: IsBitVector a => SMTBVUnOp -> SMTFunction (SMTExpr (BitVector a)) (BitVector a) 
SMTSelect :: (Liftable i, SMTType v) => SMTFunction (SMTExpr (SMTArray i v), i) v 
SMTStore :: (Liftable i, SMTType v) => SMTFunction (SMTExpr (SMTArray i v), i, SMTExpr v) (SMTArray i v) 
SMTConstArray :: (Args i, SMTType v) => ArgAnnotation i -> SMTFunction (SMTExpr v) (SMTArray i v) 
SMTConcat :: Concatable a b => SMTFunction (SMTExpr (BitVector a), SMTExpr (BitVector b)) (BitVector (ConcatResult a b)) 
SMTExtract :: (TypeableNat start, TypeableNat len, Extractable from len') => Proxy start -> Proxy len -> SMTFunction (SMTExpr (BitVector from)) (BitVector len') 
SMTConstructor :: (Args arg, SMTType dt) => Constructor arg dt -> SMTFunction arg dt 
SMTConTest :: (Args arg, SMTType dt) => Constructor arg dt -> SMTFunction (SMTExpr dt) Bool 
SMTFieldSel :: (SMTType a, SMTType f) => Field a f -> SMTFunction (SMTExpr a) f 
SMTDivisible :: Integer -> SMTFunction (SMTExpr Integer) Bool 

Instances

Show (SMTFunction arg res) Source # 

Methods

showsPrec :: Int -> SMTFunction arg res -> ShowS #

show :: SMTFunction arg res -> String #

showList :: [SMTFunction arg res] -> ShowS #

class SMTValue (BitVector a) => IsBitVector a where Source #

Minimal complete definition

getBVSize

class (IsBitVector a, IsBitVector b, IsBitVector (ConcatResult a b)) => Concatable a b where Source #

Minimal complete definition

concatAnnotation

Associated Types

type ConcatResult a b Source #

class (IsBitVector a, IsBitVector b) => Extractable a b where Source #

Minimal complete definition

extractAnn, getExtractLen

data Constructor arg res Source #

Represents a constructor of a datatype a Can be obtained by using the template haskell extension module

Instances

Show (Constructor arg res) Source # 

Methods

showsPrec :: Int -> Constructor arg res -> ShowS #

show :: Constructor arg res -> String #

showList :: [Constructor arg res] -> ShowS #

data Field a f Source #

Represents a field of the datatype a of the type f

Instances

Show (Field a f) Source # 

Methods

showsPrec :: Int -> Field a f -> ShowS #

show :: Field a f -> String #

showList :: [Field a f] -> ShowS #

newtype ClauseId Source #

Identifies a clause in an unsatisfiable core

Constructors

ClauseId Integer 

data SMTOption Source #

Options controling the behaviour of the SMT solver

Constructors

PrintSuccess Bool

Whether or not to print "success" after each operation

ProduceModels Bool

Produce a satisfying assignment after each successful checkSat

ProduceProofs Bool

Produce a proof of unsatisfiability after each failed checkSat

ProduceUnsatCores Bool

Enable the querying of unsatisfiable cores after a failed checkSat

ProduceInterpolants Bool

Enable the generation of craig interpolants

class (Ord a, Typeable a, Show a, Ord (ArgAnnotation a), Typeable (ArgAnnotation a), Show (ArgAnnotation a)) => Args a where Source #

Instances of this class may be used as arguments for constructed functions and quantifiers.

Associated Types

type ArgAnnotation a Source #

Methods

foldExprs :: Monad m => (forall t. SMTType t => s -> SMTExpr t -> SMTAnnotation t -> m (s, SMTExpr t)) -> s -> a -> ArgAnnotation a -> m (s, a) Source #

foldsExprs :: Monad m => (forall t. SMTType t => s -> [(SMTExpr t, b)] -> SMTAnnotation t -> m (s, [SMTExpr t], SMTExpr t)) -> s -> [(a, b)] -> ArgAnnotation a -> m (s, [a], a) Source #

extractArgAnnotation :: a -> ArgAnnotation a Source #

toArgs :: ArgAnnotation a -> [SMTExpr Untyped] -> Maybe (a, [SMTExpr Untyped]) Source #

fromArgs :: a -> [SMTExpr Untyped] Source #

getTypes :: a -> ArgAnnotation a -> [ProxyArg] Source #

getArgAnnotation :: a -> [Sort] -> (ArgAnnotation a, [Sort]) Source #

Instances

Args () Source # 

Associated Types

type ArgAnnotation () :: * Source #

Methods

foldExprs :: Monad m => (forall t. SMTType t => s -> SMTExpr t -> SMTAnnotation t -> m (s, SMTExpr t)) -> s -> () -> ArgAnnotation () -> m (s, ()) Source #

foldsExprs :: Monad m => (forall t. SMTType t => s -> [(SMTExpr t, b)] -> SMTAnnotation t -> m (s, [SMTExpr t], SMTExpr t)) -> s -> [((), b)] -> ArgAnnotation () -> m (s, [()], ()) Source #

extractArgAnnotation :: () -> ArgAnnotation () Source #

toArgs :: ArgAnnotation () -> [SMTExpr Untyped] -> Maybe ((), [SMTExpr Untyped]) Source #

fromArgs :: () -> [SMTExpr Untyped] Source #

getTypes :: () -> ArgAnnotation () -> [ProxyArg] Source #

getArgAnnotation :: () -> [Sort] -> (ArgAnnotation (), [Sort]) Source #

getSorts :: Args a => a -> ArgAnnotation a -> [Sort] Source #

foldExprsId :: Args a => (forall t. SMTType t => s -> SMTExpr t -> SMTAnnotation t -> (s, SMTExpr t)) -> s -> a -> ArgAnnotation a -> (s, a) Source #

foldsExprsId :: Args a => (forall t. SMTType t => s -> [(SMTExpr t, b)] -> SMTAnnotation t -> (s, [SMTExpr t], SMTExpr t)) -> s -> [(a, b)] -> ArgAnnotation a -> (s, [a], a) Source #

class Args a => Liftable a where Source #

Associated Types

type Lifted a i Source #

argSorts :: Args a => a -> ArgAnnotation a -> [Sort] Source #

unpackArgs :: Args a => (forall t. SMTType t => SMTExpr t -> SMTAnnotation t -> s -> (c, s)) -> a -> ArgAnnotation a -> s -> ([c], s) Source #

class Args a => LiftArgs a where Source #

An extension of the Args class: Instances of this class can be represented as native haskell data types.

Minimal complete definition

liftArgs, unliftArgs

Associated Types

type Unpacked a Source #

Methods

liftArgs :: Unpacked a -> ArgAnnotation a -> a Source #

Converts a haskell value into its SMT representation.

unliftArgs :: Monad m => a -> (forall t. SMTValue t => SMTExpr t -> m t) -> m (Unpacked a) Source #

Converts a SMT representation back into a haskell value.

getFunUndef :: SMTFunction arg res -> (arg, res) Source #

getArrayUndef :: Args i => SMTExpr (SMTArray i v) -> (i, Unpacked i, v) Source #

withSMTBackend :: SMTBackend a m => a -> SMT' m b -> m b Source #

withSMTBackend' :: SMTBackend a m => a -> Bool -> SMT' m b -> m b Source #

declareType :: (Monad m, SMTType t) => t -> SMTAnnotation t -> SMT' m () Source #

withProxyArg :: ProxyArg -> (forall t. SMTType t => t -> SMTAnnotation t -> a) -> a Source #

withProxyArgValue :: ProxyArgValue -> (forall t. SMTValue t => t -> SMTAnnotation t -> a) -> a Source #

data AnyValue Source #

Constructors

SMTType t => AnyValue [ProxyArg] t (SMTAnnotation t) 

withAnyValue :: AnyValue -> (forall t. SMTType t => [ProxyArg] -> t -> SMTAnnotation t -> a) -> a Source #

data DataType Source #

Constructors

DataType 

Fields

data Constr Source #

Constructors

Constr 

Fields

data DataField Source #

Constructors

DataField 

Fields

getNewTypeCollections :: SMTType t => Proxy t -> SMTAnnotation t -> DataTypeInfo -> ([TypeCollection], DataTypeInfo) Source #

Get all the type collections which are not yet declared from a type.

data Z Source #

Constructors

Z 

Instances

TypeableNat Z Source # 
type Add Z n Source # 
type Add Z n = n

data S a Source #

Constructors

S 

Instances

TypeableNat n => TypeableNat (S n) Source # 

Methods

reflectNat :: Proxy * (S n) -> Integer -> Integer Source #

type Add (S n1) n2 Source # 
type Add (S n1) n2 = S (Add n1 n2)

class Typeable a => TypeableNat a where Source #

Minimal complete definition

reflectNat

type family Add n1 n2 Source #

Instances

type Add Z n Source # 
type Add Z n = n
type Add (S n1) n2 Source # 
type Add (S n1) n2 = S (Add n1 n2)

data BVTyped n Source #

Constructors

BVTyped 

Instances

reifyNat :: (Num a, Ord a) => a -> (forall n. TypeableNat n => Proxy n -> r) -> r Source #

reifySum :: (Num a, Ord a) => a -> a -> (forall n1 n2. (TypeableNat n1, TypeableNat n2, TypeableNat (Add n1 n2)) => Proxy n1 -> Proxy n2 -> Proxy (Add n1 n2) -> r) -> r Source #

reifyExtract :: (Num a, Ord a) => a -> a -> a -> (forall n1 n2 n3 n4. (TypeableNat n1, TypeableNat n2, TypeableNat n3, TypeableNat n4, Add n4 n2 ~ S n3) => Proxy n1 -> Proxy n2 -> Proxy n3 -> Proxy n4 -> r) -> r Source #

type N0 = Z Source #

type N1 = S N0 Source #

type N2 = S N1 Source #

type N3 = S N2 Source #

type N4 = S N3 Source #

type N5 = S N4 Source #

type N6 = S N5 Source #

type N7 = S N6 Source #

type N8 = S N7 Source #

type N9 = S N8 Source #

type N10 = S N9 Source #

type N11 = S N10 Source #

type N12 = S N11 Source #

type N13 = S N12 Source #

type N14 = S N13 Source #

type N15 = S N14 Source #

type N16 = S N15 Source #

type N17 = S N16 Source #

type N18 = S N17 Source #

type N19 = S N18 Source #

type N20 = S N19 Source #

type N21 = S N20 Source #

type N22 = S N21 Source #

type N23 = S N22 Source #

type N24 = S N23 Source #

type N25 = S N24 Source #

type N26 = S N25 Source #

type N27 = S N26 Source #

type N28 = S N27 Source #

type N29 = S N28 Source #

type N30 = S N29 Source #

type N31 = S N30 Source #

type N32 = S N31 Source #

type N33 = S N32 Source #

type N34 = S N33 Source #

type N35 = S N34 Source #

type N36 = S N35 Source #

type N37 = S N36 Source #

type N38 = S N37 Source #

type N39 = S N38 Source #

type N40 = S N39 Source #

type N41 = S N40 Source #

type N42 = S N41 Source #

type N43 = S N42 Source #

type N44 = S N43 Source #

type N45 = S N44 Source #

type N46 = S N45 Source #

type N47 = S N46 Source #

type N48 = S N47 Source #

type N49 = S N48 Source #

type N50 = S N49 Source #

type N51 = S N50 Source #

type N52 = S N51 Source #

type N53 = S N52 Source #

type N54 = S N53 Source #

type N55 = S N54 Source #

type N56 = S N55 Source #

type N57 = S N56 Source #

type N58 = S N57 Source #

type N59 = S N58 Source #

type N60 = S N59 Source #

type N61 = S N60 Source #

type N62 = S N61 Source #

type N63 = S N62 Source #

type N64 = S N63 Source #

newtype Bound Source #

Constructors

Bound Integer 

Instances

Eq Bound Source # 

Methods

(==) :: Bound -> Bound -> Bool #

(/=) :: Bound -> Bound -> Bool #

Ord Bound Source # 

Methods

compare :: Bound -> Bound -> Ordering #

(<) :: Bound -> Bound -> Bool #

(<=) :: Bound -> Bound -> Bool #

(>) :: Bound -> Bound -> Bool #

(>=) :: Bound -> Bound -> Bool #

max :: Bound -> Bound -> Bound #

min :: Bound -> Bound -> Bound #

Show Bound Source # 

Methods

showsPrec :: Int -> Bound -> ShowS #

show :: Bound -> String #

showList :: [Bound] -> ShowS #