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

Safe HaskellNone
LanguageHaskell98

Language.SMTLib2

Contents

Description

Example usage: This program tries to find two numbers greater than zero which sum up to 5.

import Language.SMTLib2
import Language.SMTLib2.Solver

program :: SMT (Integer,Integer)
program = do
  x <- var
  y <- var
  assert $ (plus [x,y]) .==. (constant 5)
  assert $ x .>. (constant 0)
  assert $ y .>. (constant 0)
  checkSat
  vx <- getValue x
  vy <- getValue y
  return (vx,vy)

main = withZ3 program >>= print
     

Synopsis

SMT Monad

data Backend b => SMT b a Source

Instances

Backend b => Monad (SMT b) Source 
Backend b => Functor (SMT b) Source 
Backend b => Applicative (SMT b) Source 
(Backend b, MonadIO (SMTMonad b)) => MonadIO (SMT b) Source 
(Backend b, (~) (Type -> *) e (Expr b)) => Embed (SMT b) e Source 
Backend b => MonadState (SMTState b) (SMT b) Source 
type EmVar (SMT b) e = Var b Source 
type EmQVar (SMT b) e = QVar b Source 
type EmFun (SMT b) e = Fun b Source 
type EmConstr (SMT b) e = Constr b Source 
type EmField (SMT b) e = Field b Source 
type EmFunArg (SMT b) e = FunArg b Source 
type EmLVar (SMT b) e = LVar b Source 

withBackend :: Backend b => SMTMonad b b -> SMT b a -> SMTMonad b a Source

withBackendExitCleanly :: (Backend b, SMTMonad b ~ IO) => IO b -> SMT b a -> IO a Source

Setting options

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

SMTLogic String 

Getting informations about the solver

getInfo :: Backend b => SMTInfo i -> SMT b i Source

Expressions

expr :: QuasiQuoter Source

This quasiquoter can be used to generate SMTLib2 expressions or pattern matches. For example, to assert the fact that variable x is equal to variable y we can use

[expr| (= x y) |] >>= assert

To perform pattern matching against an expression e, we can use:

analyze e >>= \re -> case re of
  [expr| (+ x y) |] -> ...

Types can also be generated using for example:

myExpr :: Backend b => SMT b (Expr b [expr| (Array Int Bool) |])
myExpr = [expr| ((as const (Array Int Bool)) False) |]

Declaring variables

declareVar :: Backend b => Repr t -> SMT b (Expr b t) Source

declareVarNamed :: Backend b => Repr t -> String -> SMT b (Expr b t) Source

Defining variables

defineVar :: Backend b => Expr b t -> SMT b (Expr b t) Source

defineVarNamed :: Backend b => String -> Expr b t -> SMT b (Expr b t) Source

defConst :: Backend b => Expr b t -> SMT b (Expr b t) Source

Declaring functions

declareFun :: Backend b => List Repr args -> Repr res -> SMT b (Fun b `(args, res)`) Source

declareFunNamed :: Backend b => List Repr args -> Repr res -> String -> SMT b (Fun b `(args, res)`) Source

Defining functions

defineFun :: Backend b => List Repr args -> (List (Expr b) args -> SMT b (Expr b res)) -> SMT b (Fun b `(args, res)`) Source

defineFunNamed :: Backend b => String -> List Repr args -> (List (Expr b) args -> SMT b (Expr b res)) -> SMT b (Fun b `(args, res)`) Source

Constants

Boolean constants

pattern ConstBool :: (~) Type rtp BoolType => Bool -> Expression v qv fun con field fv lv e rtp Source

cbool :: Embed m e => Bool -> m (e BoolType) Source

true :: Embed m e => m (e BoolType) Source

false :: Embed m e => m (e BoolType) Source

Integer constants

pattern ConstInt :: (~) Type rtp IntType => Integer -> Expression v qv fun con field fv lv e rtp Source

cint :: Embed m e => Integer -> m (e IntType) Source

Real constants

pattern ConstReal :: (~) Type rtp RealType => Rational -> Expression v qv fun con field fv lv e rtp Source

creal :: Embed m e => Rational -> m (e RealType) Source

Bitvector constants

pattern ConstBV :: (~) Type rtp (BitVecType bw) => Integer -> Natural bw -> Expression v qv fun con field fv lv e rtp Source

cbv :: Embed m e => Integer -> Natural bw -> m (e (BitVecType bw)) Source

Functions

pattern Fun :: (~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type arg res) => t ((,) [Type] Type arg res) -> List Type t arg -> Expression t t t t t t t t t Source

fun :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ List e args) => EmFun m e `(args, res)` -> a -> m (e res) Source

Equality

pattern EqLst :: (~) Type rtp BoolType => GetType e => [e tp] -> Expression v qv fun con field fv lv e rtp Source

pattern Eq :: ((~) Type rtp BoolType, Same tps) => GetType e => List Type e tps -> Expression v qv fun con field fv lv e rtp Source

pattern (:==:) :: (~) Type rtp BoolType => GetType e => e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

eq :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp) => [a] -> m (e BoolType) Source

(.==.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => a -> b -> m (e BoolType) infix 4 Source

pattern DistinctLst :: (~) Type rtp BoolType => GetType e => [e tp] -> Expression v qv fun con field fv lv e rtp Source

pattern Distinct :: ((~) Type rtp BoolType, Same tps) => GetType e => List Type e tps -> Expression v qv fun con field fv lv e rtp Source

pattern (:/=:) :: (~) Type rtp BoolType => GetType e => e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

distinct :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp) => [a] -> m (e BoolType) Source

(./=.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => a -> b -> m (e BoolType) infix 4 Source

Map

map' :: (Embed m e, HasMonad arg, MatchMonad arg m, MonadResult arg ~ List e (Lifted tps idx), Unlift tps idx, GetType e, GetFunType (EmFun m e), GetFieldType (EmField m e), GetConType (EmConstr m e)) => Function (EmFun m e) (EmConstr m e) (EmField m e) `(tps, res)` -> arg -> m (e (ArrayType idx res)) Source

Comparison

pattern Ord :: ((~) Type rtp BoolType, IsSMTNumber tp) => OrdOp -> e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

pattern (:>=:) :: ((~) Type rtp BoolType, IsSMTNumber tp) => e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

pattern (:>:) :: ((~) Type rtp BoolType, IsSMTNumber tp) => e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

pattern (:<=:) :: ((~) Type rtp BoolType, IsSMTNumber tp) => e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

pattern (:<:) :: ((~) Type rtp BoolType, IsSMTNumber tp) => e tp -> e tp -> Expression v qv fun con field fv lv e rtp Source

ord :: (Embed m e, IsSMTNumber tp, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => OrdOp -> a -> b -> m (e BoolType) Source

(.>=.) :: (Embed m e, IsSMTNumber tp, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => a -> b -> m (e BoolType) infix 4 Source

(.>.) :: (Embed m e, IsSMTNumber tp, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => a -> b -> m (e BoolType) infix 4 Source

(.<=.) :: (Embed m e, IsSMTNumber tp, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => a -> b -> m (e BoolType) infix 4 Source

(.<.) :: (Embed m e, IsSMTNumber tp, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp) => a -> b -> m (e BoolType) infix 4 Source

Arithmetic

pattern ArithLst :: IsSMTNumber tp => ArithOp -> [e tp] -> Expression v qv fun con field fv lv e tp Source

pattern Arith :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps)) => ArithOp -> List Type e tps -> Expression v qv fun con field fv lv e tp Source

arith :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp, IsSMTNumber tp) => ArithOp -> [a] -> m (e tp) Source

pattern PlusLst :: IsSMTNumber tp => [e tp] -> Expression v qv fun con field fv lv e tp Source

pattern Plus :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps)) => List Type e tps -> Expression v qv fun con field fv lv e tp Source

pattern (:+:) :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps), (~) [Type] tps ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => e x -> e x -> Expression v qv fun con field fv lv e tp Source

plus :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp, IsSMTNumber tp) => [a] -> m (e tp) Source

(.+.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp, IsSMTNumber tp) => a -> b -> m (e tp) infixl 6 Source

pattern MultLst :: IsSMTNumber tp => [e tp] -> Expression v qv fun con field fv lv e tp Source

pattern Mult :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps)) => List Type e tps -> Expression v qv fun con field fv lv e tp Source

pattern (:*:) :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps), (~) [Type] tps ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => e x -> e x -> Expression v qv fun con field fv lv e tp Source

mult :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp, IsSMTNumber tp) => [a] -> m (e tp) Source

(.*.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp, IsSMTNumber tp) => a -> b -> m (e tp) infixl 7 Source

pattern MinusLst :: IsSMTNumber tp => [e tp] -> Expression v qv fun con field fv lv e tp Source

pattern Minus :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps)) => List Type e tps -> Expression v qv fun con field fv lv e tp Source

pattern (:-:) :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps), (~) [Type] tps ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => e x -> e x -> Expression v qv fun con field fv lv e tp Source

pattern Neg :: (IsSMTNumber tp, Same tps, (~) Type tp (SameType tps), (~) [Type] tps ((:) Type x xs), (~) [Type] xs ([] Type)) => e x -> Expression v qv fun con field fv lv e tp Source

minus :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp, IsSMTNumber tp) => [a] -> m (e tp) Source

(.-.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e tp, MonadResult b ~ e tp, IsSMTNumber tp) => a -> b -> m (e tp) infixl 6 Source

neg :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp, IsSMTNumber tp) => a -> m (e tp) Source

pattern Div :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type IntType ((:) Type IntType ([] Type))) IntType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> t x -> Expression t t t t t t t t t Source

pattern Mod :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type IntType ((:) Type IntType ([] Type))) IntType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> t x -> Expression t t t t t t t t t Source

pattern Rem :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type IntType ((:) Type IntType ([] Type))) IntType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> t x -> Expression t t t t t t t t t Source

div' :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e IntType, MonadResult b ~ e IntType) => a -> b -> m (e IntType) infixl 7 Source

mod' :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e IntType, MonadResult b ~ e IntType) => a -> b -> m (e IntType) infixl 7 Source

rem' :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e IntType, MonadResult b ~ e IntType) => a -> b -> m (e IntType) infixl 7 Source

pattern (:/:) :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type RealType ((:) Type RealType ([] Type))) RealType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> t x -> Expression t t t t t t t t t Source

(./.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e RealType, MonadResult b ~ e RealType) => a -> b -> m (e RealType) infixl 7 Source

pattern Abs :: IsSMTNumber tp => e tp -> Expression v qv fun con field fv lv e tp Source

abs' :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp, IsSMTNumber tp) => a -> m (e tp) Source

Logic

pattern Not :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type BoolType ([] Type)) BoolType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> Expression t t t t t t t t t Source

not' :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e BoolType) => a -> m (e BoolType) Source

pattern LogicLst :: (~) Type rtp BoolType => LogicOp -> [e BoolType] -> Expression v qv fun con field fv lv e rtp Source

pattern Logic :: ((~) Type rtp BoolType, Same tps, (~) Type (SameType tps) BoolType) => LogicOp -> List Type e tps -> Expression v qv fun con field fv lv e rtp Source

logic :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e BoolType) => LogicOp -> [a] -> m (e BoolType) Source

pattern AndLst :: (~) Type rtp BoolType => [e BoolType] -> Expression v qv fun con field fv lv e rtp Source

pattern And :: ((~) Type rtp BoolType, Same tps, (~) Type (SameType tps) BoolType) => List Type e tps -> Expression v qv fun con field fv lv e rtp Source

pattern (:&:) :: (~) Type rtp BoolType => e BoolType -> e BoolType -> Expression v qv fun con field fv lv e rtp Source

and' :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e BoolType) => [a] -> m (e BoolType) Source

(.&.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e BoolType, MonadResult b ~ e BoolType) => a -> b -> m (e BoolType) infixr 3 Source

pattern OrLst :: (~) Type rtp BoolType => [e BoolType] -> Expression v qv fun con field fv lv e rtp Source

pattern Or :: ((~) Type rtp BoolType, Same tps, (~) Type (SameType tps) BoolType) => List Type e tps -> Expression v qv fun con field fv lv e rtp Source

pattern (:|:) :: (~) Type rtp BoolType => e BoolType -> e BoolType -> Expression v qv fun con field fv lv e rtp Source

or' :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e BoolType) => [a] -> m (e BoolType) Source

(.|.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e BoolType, MonadResult b ~ e BoolType) => a -> b -> m (e BoolType) infixr 2 Source

pattern XOrLst :: (~) Type rtp BoolType => [e BoolType] -> Expression v qv fun con field fv lv e rtp Source

pattern XOr :: ((~) Type rtp BoolType, Same tps, (~) Type (SameType tps) BoolType) => List Type e tps -> Expression v qv fun con field fv lv e rtp Source

xor' :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e BoolType) => [a] -> m (e BoolType) Source

pattern ImpliesLst :: (~) Type rtp BoolType => [e BoolType] -> Expression v qv fun con field fv lv e rtp Source

pattern Implies :: ((~) Type rtp BoolType, Same tps, (~) Type (SameType tps) BoolType) => List Type e tps -> Expression v qv fun con field fv lv e rtp Source

pattern (:=>:) :: (~) Type rtp BoolType => e BoolType -> e BoolType -> Expression v qv fun con field fv lv e rtp Source

implies :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e BoolType) => [a] -> m (e BoolType) Source

(.=>.) :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e BoolType, MonadResult b ~ e BoolType) => a -> b -> m (e BoolType) infixr 2 Source

Conversion

pattern ToReal :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type IntType ([] Type)) RealType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> Expression t t t t t t t t t Source

pattern ToInt :: ((~) ((,) [Type] Type) ((,) [Type] Type arg t) ((,) [Type] Type ((:) Type RealType ([] Type)) IntType), (~) [Type] arg ((:) Type x xs), (~) [Type] xs ([] Type)) => t x -> Expression t t t t t t t t t Source

toReal :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e IntType) => a -> m (e RealType) Source

toInt :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e RealType) => a -> m (e IntType) Source

If-then-else

pattern ITE :: () => GetType e => e BoolType -> e tp -> e tp -> Expression v qv fun con field fv lv e tp Source

ite :: (Embed m e, HasMonad a, HasMonad b, HasMonad c, MatchMonad a m, MatchMonad b m, MatchMonad c m, MonadResult a ~ e BoolType, MonadResult b ~ e tp, MonadResult c ~ e tp) => a -> b -> c -> m (e tp) Source

Bitvectors

pattern BVComp :: (~) Type rtp BoolType => GetType e => BVCompOp -> e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVULE :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVULT :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVUGE :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVUGT :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSLE :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSLT :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSGE :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSGT :: (~) Type rtp BoolType => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

bvcomp :: forall m e a b bw. (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => BVCompOp -> a -> b -> m (e BoolType) Source

bvule :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvult :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvuge :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvugt :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvsle :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvslt :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvsge :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

bvsgt :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e BoolType) Source

pattern BVBin :: (~) Type rtp (BitVecType bw) => GetType e => BVBinOp -> e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVAdd :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSub :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVMul :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVURem :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSRem :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVUDiv :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSDiv :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVSHL :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVLSHR :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVASHR :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVXor :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVAnd :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVOr :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

bvbin :: forall m e a b bw. (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => BVBinOp -> a -> b -> m (e (BitVecType bw)) Source

bvadd :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvsub :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvmul :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvurem :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvsrem :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvudiv :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvsdiv :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvshl :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvlshr :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvashr :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvxor :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvand :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

bvor :: (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType bw), MonadResult b ~ e (BitVecType bw)) => a -> b -> m (e (BitVecType bw)) Source

pattern BVUn :: (~) Type rtp (BitVecType bw) => GetType e => BVUnOp -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVNot :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

pattern BVNeg :: (~) Type rtp (BitVecType bw) => GetType e => e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

bvun :: forall m e a bw. (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e (BitVecType bw)) => BVUnOp -> a -> m (e (BitVecType bw)) Source

bvnot :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e (BitVecType bw)) => a -> m (e (BitVecType bw)) Source

bvneg :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e (BitVecType bw)) => a -> m (e (BitVecType bw)) Source

pattern Concat :: (~) Type rtp (BitVecType ((+) n1 n2)) => GetType e => e (BitVecType n1) -> e (BitVecType n2) -> Expression v qv fun con field fv lv e rtp Source

pattern Extract :: ((~) Type rtp (BitVecType len), (~) Bool ((<=) ((+) start len) bw) True) => GetType e => Natural start -> Natural len -> e (BitVecType bw) -> Expression v qv fun con field fv lv e rtp Source

concat' :: forall m e a b n1 n2. (Embed m e, HasMonad a, HasMonad b, MatchMonad a m, MatchMonad b m, MonadResult a ~ e (BitVecType n1), MonadResult b ~ e (BitVecType n2)) => a -> b -> m (e (BitVecType (n1 + n2))) Source

extract' :: forall m e a bw start len. (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e (BitVecType bw), ((start + len) <= bw) ~ True) => Natural start -> Natural len -> a -> m (e (BitVecType len)) Source

Arrays

pattern Select :: (~) Type rtp val => GetType e => e (ArrayType idx val) -> List Type e idx -> Expression v qv fun con field fv lv e rtp Source

pattern Store :: (~) Type rtp (ArrayType idx val) => GetType e => e (ArrayType idx val) -> List Type e idx -> e val -> Expression v qv fun con field fv lv e rtp Source

pattern ConstArray :: (~) Type rtp (ArrayType idx val) => GetType e => List Type Repr idx -> e val -> Expression v qv fun con field fv lv e rtp Source

select :: (Embed m e, HasMonad arr, MatchMonad arr m, MonadResult arr ~ e (ArrayType idx el), HasMonad i, MatchMonad i m, MonadResult i ~ List e idx) => arr -> i -> m (e el) Source

select1 :: (Embed m e, HasMonad arr, HasMonad idx, MatchMonad arr m, MatchMonad idx m, MonadResult arr ~ e (ArrayType `[idx']` el), MonadResult idx ~ e idx') => arr -> idx -> m (e el) Source

store :: (Embed m e, HasMonad arr, MatchMonad arr m, MonadResult arr ~ e (ArrayType idx el), HasMonad i, MatchMonad i m, MonadResult i ~ List e idx, HasMonad nel, MatchMonad nel m, MonadResult nel ~ e el) => arr -> i -> nel -> m (e (ArrayType idx el)) Source

store1 :: (Embed m e, HasMonad arr, HasMonad idx, HasMonad el, MatchMonad arr m, MatchMonad idx m, MatchMonad el m, MonadResult arr ~ e (ArrayType `[idx']` el'), MonadResult idx ~ e idx', MonadResult el ~ e el') => arr -> idx -> el -> m (e (ArrayType `[idx']` el')) Source

constArray :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e tp) => List Repr idx -> a -> m (e (ArrayType idx tp)) Source

Misc

pattern Divisible :: (~) Type rtp BoolType => Integer -> e IntType -> Expression v qv fun con field fv lv e rtp Source

divisible :: (Embed m e, HasMonad a, MatchMonad a m, MonadResult a ~ e IntType) => Integer -> a -> m (e BoolType) Source

Analyzation

data AnalyzedExpr i e tp Source

analyze :: Backend b => Expr b tp -> SMT b (AnalyzedExpr (BackendInfo b) (Expr b) tp) Source

getExpr :: Backend b => Expr b tp -> SMT b (Expression (Var b) (QVar b) (Fun b) (Constr b) (Field b) (FunArg b) (LVar b) (Expr b) tp) Source

Satisfiability

assert :: Backend b => Expr b BoolType -> SMT b () Source

Asserts a boolean expression to be true. A successive successful checkSat calls mean that the generated model is consistent with the assertion.

checkSat :: Backend b => SMT b CheckSatResult Source

Checks if the set of asserted expressions is satisfiable.

data CheckSatResult Source

The result of a check-sat query

Constructors

Sat

The formula is satisfiable

Unsat

The formula is unsatisfiable

Unknown

The solver cannot determine the satisfiability of a formula

data CheckSatLimits Source

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

Constructors

CheckSatLimits 

Fields

limitTime :: Maybe Integer

A limit on the amount of time the solver can spend on the problem (in milliseconds)

limitMemory :: Maybe Integer

A limit on the amount of memory the solver can use (in megabytes)

Unsatisfiable core

assertId :: Backend b => Expr b BoolType -> SMT b (ClauseId b) Source

Works like assert, but additionally allows the user to find the unsatisfiable core of a set of assignments using getUnsatCore.

Interpolation

data Partition Source

The interpolation partition

Constructors

PartitionA 
PartitionB 

Proofs

Stack

push :: Backend b => SMT b () Source

pop :: Backend b => SMT b () Source

stack :: Backend b => SMT b a -> SMT b a Source

Models

getModel :: Backend b => SMT b (Model b) Source

After a successful checkSat query, return a satisfying assignment that makes all asserted formula true.

modelEvaluate :: Backend b => Model b -> Expr b t -> SMT b (ConcreteValue t) Source

Evaluate an expression in a model, yielding a concrete value.

Types

data Type Source

Describes the kind of all SMT types. It is only used in promoted form, for a concrete representation see Repr.

Constructors

BoolType 
IntType 
RealType 
BitVecType Nat 
ArrayType [Type] Type 
forall a . DataType a 

Instances

GCompare Type NumRepr Source 
GCompare Type Repr Source 
GCompare Type ConcreteValue Source 
GCompare Type NoVar 
GEq Type NumRepr Source 
GEq Type Repr Source 
GEq Type ConcreteValue Source 
GEq Type NoVar 
GShow Type NumRepr Source 
GShow Type Repr Source 
GShow Type ConcreteValue Source 
GShow Type NoVar 
GCompare ((,) [Type] *) con => GCompare Type (Value con) Source 
Ord v => GCompare Type (UntypedVar v) 
GEq ((,) [Type] *) con => GEq Type (Value con) Source 
Eq v => GEq Type (UntypedVar v) 
GShow ((,) [Type] *) con => GShow Type (Value con) Source 
Show v => GShow Type (UntypedVar v) 
(GCompare Type v, GCompare Type e) => GCompare Type (LetBinding v e) 
(GEq Type v, GEq Type e) => GEq Type (LetBinding v e) 
(GCompare Type v, GCompare Type qv, GCompare ((,) [Type] Type) fun, GCompare ((,) [Type] *) con, GCompare ((,) * Type) field, GCompare Type fv, GCompare Type lv, GCompare Type e) => GCompare Type (Expression v qv fun con field fv lv e) 
(GEq Type v, GEq Type qv, GEq ((,) [Type] Type) fun, GEq ((,) [Type] *) con, GEq ((,) * Type) field, GEq Type fv, GEq Type lv, GEq Type e) => GEq Type (Expression v qv fun con field fv lv e) 
(GShow Type v, GShow Type qv, GShow ((,) [Type] Type) fun, GShow ((,) [Type] *) con, GShow ((,) * Type) field, GShow Type fv, GShow Type lv, GShow Type e) => GShow Type (Expression v qv fun con field fv lv e) 
HasMonad (m (List Type e tp)) Source 
GCompare ((,) [Type] *) NoCon 
GCompare ((,) [Type] Type) FunRepr Source 
GCompare ((,) [Type] Type) NoFun 
GCompare ((,) * Type) NoField 
GEq ((,) [Type] *) NoCon 
GEq ((,) [Type] Type) FunRepr Source 
GEq ((,) [Type] Type) NoFun 
GEq ((,) * Type) NoField 
GShow ((,) [[Type]] *) Datatype Source 
GShow ((,) [Type] *) NoCon 
GShow ((,) [Type] Type) NoFun 
GShow ((,) * Type) NoField 
Ord v => GCompare ((,) [Type] *) (UntypedCon v) 
Ord v => GCompare ((,) [Type] Type) (UntypedFun v) 
Ord v => GCompare ((,) * Type) (UntypedField v) 
Eq v => GEq ((,) [Type] *) (UntypedCon v) 
Eq v => GEq ((,) [Type] Type) (UntypedFun v) 
Eq v => GEq ((,) * Type) (UntypedField v) 
Show v => GShow ((,) [Type] *) (UntypedCon v) 
Show v => GShow ((,) [Type] Type) (UntypedFun v) 
Show v => GShow ((,) * Type) (UntypedField v) 
(GCompare ((,) [Type] Type) fun, GCompare ((,) [Type] *) con, GCompare ((,) * Type) field) => GCompare ((,) [Type] Type) (Function fun con field) 
(GEq ((,) [Type] Type) fun, GEq ((,) [Type] *) con, GEq ((,) * Type) field) => GEq ((,) [Type] Type) (Function fun con field) 
(GShow ((,) [Type] Type) fun, GShow ((,) [Type] *) con, GShow ((,) * Type) field) => GShow ((,) [Type] Type) (Function fun con field) 
HasMonad (List Type e tp) Source 
(Same ((:) Type tp tps), (~) Type tp (SameType ((:) Type tp tps))) => Same ((:) Type tp ((:) Type tp tps)) Source 
Same ((:) Type tp ([] Type)) Source 
Unlift ((:) Type t2 ts) idx => Unlift ((:) Type t1 ((:) Type t2 ts)) idx Source 
Unlift ((:) Type tp ([] Type)) idx Source 
type MonadResult (m (List Type e tp)) = List Type e tp Source 
type MatchMonad (m (List Type e tp)) m' = (~) (* -> *) m m' Source 
type MonadResult (List Type e tp) = List Type e tp Source 
type MatchMonad (List Type e tp) m = () Source 

data Repr t where Source

A concrete representation of an SMT type. For aesthetic reasons, it's recommended to use the functions bool, int, real, bitvec or array.

Constructors

BoolRepr :: Repr BoolType 
IntRepr :: Repr IntType 
RealRepr :: Repr RealType 
BitVecRepr :: Natural n -> Repr (BitVecType n) 
ArrayRepr :: List Repr idx -> Repr val -> Repr (ArrayType idx val) 
DataRepr :: IsDatatype dt => Datatype `(DatatypeSig dt, dt)` -> Repr (DataType dt) 

class GetType v where Source

Methods

getType :: v tp -> Repr tp Source

Instances

GetType Repr Source 
GetType ConcreteValue Source 
GetType NoVar Source 
GetType (Value con) Source 
GetType (UntypedVar v) Source 
(GetType var, GetType qvar, GetFunType fun, GetConType con, GetFieldType field, GetType farg, GetType lvar) => GetType (SMTExpr var qvar fun con field farg lvar) Source 
(GetType v, GetType qv, GetFunType fun, GetConType con, GetFieldType field, GetType fv, GetType lv, GetType e) => GetType (Expression v qv fun con field fv lv e) Source 

reifyType :: Type -> (forall tp. Repr tp -> a) -> a Source

Get a concrete representation for a type.

bool :: Repr BoolType Source

A representation of the SMT Bool type. Holds the values true or false.

array :: List Repr idx -> Repr el -> Repr (ArrayType idx el) Source

Numbers

nat :: (Num a, Ord a) => a -> ExpQ Source

reifyNat :: Nat -> (forall n. Natural n -> r) -> r Source

Lists

data List e tp where Source

Constructors

Nil :: List e `[]` 
(:::) :: e x -> List e xs -> List e (x : xs) infixr 9 

Instances

HasMonad (m (List Type e tp)) Source 
GCompare k e => GCompare [k] (List k e) Source 
GEq k e => GEq [k] (List k e) Source 
GShow k e => GShow [k] (List k e) Source 
GEq k e => Eq (List k e lst) Source 
GCompare k e => Ord (List k e lst) Source 
GShow k e => Show (List k e lst) Source 
HasMonad (List Type e tp) Source 
type MonadResult (m (List Type e tp)) = List Type e tp Source 
type MatchMonad (m (List Type e tp)) m' = (~) (* -> *) m m' Source 
type MonadResult (List Type e tp) = List Type e tp Source 
type MatchMonad (List Type e tp) m = () Source 

reifyList :: (forall r'. a -> (forall tp. e tp -> r') -> r') -> [a] -> (forall tp. List e tp -> r) -> r Source

list1 :: e t1 -> List e `[t1]` Source

list2 :: e t1 -> e t2 -> List e `[t1, t2]` Source

list3 :: e t1 -> e t2 -> e t3 -> List e `[t1, t2, t3]` Source

(.:.) :: (HasMonad a, MonadResult a ~ e tp, MatchMonad a m, Monad m) => a -> m (List e tps) -> m (List e (tp : tps)) infixr 5 Source

nil :: Monad m => m (List e `[]`) Source

Misc

comment :: Backend b => String -> SMT b () Source

simplify :: Backend b => Expr b tp -> SMT b (Expr b tp) Source

Use the SMT solver to simplify a given expression.