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

Safe HaskellNone
LanguageHaskell98

Language.SMTLib2.Internals.Embed

Synopsis

Documentation

type EmbedExpr m e tp = Expression (EmVar m e) (EmQVar m e) (EmFun m e) (EmFunArg m e) (EmLVar m e) e tp Source #

class (Applicative m, GCompare (EmVar m e), GCompare (EmQVar m e), GCompare (EmFun m e), GCompare (EmFunArg m e), GCompare (EmLVar m e)) => Embed m e where Source #

A class of Monads that can be used to form SMTLib expressions. The default instance of this class is the SMT monad, together with its associated Expr type. An interesting instance is the Identity monad with the Value type, which allows evaluation of SMTLib expressions.

Minimal complete definition

embed, embedQuantifier, embedTypeOf

Associated Types

type EmVar m e :: Type -> * Source #

type EmQVar m e :: Type -> * Source #

type EmFun m e :: ([Type], Type) -> * Source #

type EmFunArg m e :: Type -> * Source #

type EmLVar m e :: Type -> * Source #

Methods

embed :: m (EmbedExpr m e tp) -> m (e tp) Source #

embedQuantifier :: Quantifier -> List Repr arg -> (forall m e. (Embed m e, Monad m) => List (EmQVar m e) arg -> m (e BoolType)) -> m (e BoolType) Source #

embedTypeOf :: m (e tp -> Repr tp) Source #

Instances

Embed Identity Repr Source # 

Associated Types

type EmVar (Identity :: * -> *) (Repr :: Type -> *) :: Type -> * Source #

type EmQVar (Identity :: * -> *) (Repr :: Type -> *) :: Type -> * Source #

type EmFun (Identity :: * -> *) (Repr :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (Identity :: * -> *) (Repr :: Type -> *) :: Type -> * Source #

type EmLVar (Identity :: * -> *) (Repr :: Type -> *) :: Type -> * Source #

Methods

embed :: Identity (EmbedExpr Identity Repr tp) -> Identity (Repr tp) Source #

embedQuantifier :: Quantifier -> List Type Repr arg -> (forall m e. (Embed m e, Monad m) => List Type (EmQVar m e) arg -> m (e BoolType)) -> Identity (Repr BoolType) Source #

embedTypeOf :: Identity (Repr tp -> Repr tp) Source #

Embed Identity Value Source # 

Associated Types

type EmVar (Identity :: * -> *) (Value :: Type -> *) :: Type -> * Source #

type EmQVar (Identity :: * -> *) (Value :: Type -> *) :: Type -> * Source #

type EmFun (Identity :: * -> *) (Value :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (Identity :: * -> *) (Value :: Type -> *) :: Type -> * Source #

type EmLVar (Identity :: * -> *) (Value :: Type -> *) :: Type -> * Source #

Methods

embed :: Identity (EmbedExpr Identity Value tp) -> Identity (Value tp) Source #

embedQuantifier :: Quantifier -> List Type Repr arg -> (forall m e. (Embed m e, Monad m) => List Type (EmQVar m e) arg -> m (e BoolType)) -> Identity (Value BoolType) Source #

embedTypeOf :: Identity (Value tp -> Repr tp) Source #

Embed Identity (ValueExt Identity) Source # 

Associated Types

type EmVar (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

type EmQVar (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

type EmFun (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

type EmLVar (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

(GCompare Type var, GetType var, GCompare Type qvar, GetType qvar, GCompare ([Type], Type) fun, GetFunType fun, GCompare Type farg, GetType farg, GCompare Type lvar, GetType lvar) => Embed Identity (SMTExpr var qvar fun farg lvar) Source # 

Associated Types

type EmVar (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type EmQVar (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type EmFun (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type EmLVar (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

Methods

embed :: Identity (EmbedExpr Identity (SMTExpr var qvar fun farg lvar) tp) -> Identity (SMTExpr var qvar fun farg lvar tp) Source #

embedQuantifier :: Quantifier -> List Type Repr arg -> (forall m e. (Embed m e, Monad m) => List Type (EmQVar m e) arg -> m (e BoolType)) -> Identity (SMTExpr var qvar fun farg lvar BoolType) Source #

embedTypeOf :: Identity (SMTExpr var qvar fun farg lvar tp -> Repr tp) Source #

Backend b => Embed (SMT b) (Expr b) Source # 

Associated Types

type EmVar (SMT b :: * -> *) (Expr b :: Type -> *) :: Type -> * Source #

type EmQVar (SMT b :: * -> *) (Expr b :: Type -> *) :: Type -> * Source #

type EmFun (SMT b :: * -> *) (Expr b :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (SMT b :: * -> *) (Expr b :: Type -> *) :: Type -> * Source #

type EmLVar (SMT b :: * -> *) (Expr b :: Type -> *) :: Type -> * Source #

Methods

embed :: SMT b (EmbedExpr (SMT b) (Expr b) tp) -> SMT b (Expr b tp) Source #

embedQuantifier :: Quantifier -> List Type Repr arg -> (forall m e. (Embed m e, Monad m) => List Type (EmQVar m e) arg -> m (e BoolType)) -> SMT b (Expr b BoolType) Source #

embedTypeOf :: SMT b (Expr b tp -> Repr tp) Source #

(Embed m e, Monad m) => Embed (ExceptT err m) e Source # 

Associated Types

type EmVar (ExceptT err m :: * -> *) (e :: Type -> *) :: Type -> * Source #

type EmQVar (ExceptT err m :: * -> *) (e :: Type -> *) :: Type -> * Source #

type EmFun (ExceptT err m :: * -> *) (e :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (ExceptT err m :: * -> *) (e :: Type -> *) :: Type -> * Source #

type EmLVar (ExceptT err m :: * -> *) (e :: Type -> *) :: Type -> * Source #

Methods

embed :: ExceptT err m (EmbedExpr (ExceptT err m) e tp) -> ExceptT err m (e tp) Source #

embedQuantifier :: Quantifier -> List Type Repr arg -> (forall a b. (Embed a b, Monad a) => List Type (EmQVar a b) arg -> a (b BoolType)) -> ExceptT err m (e BoolType) Source #

embedTypeOf :: ExceptT err m (e tp -> Repr tp) Source #

class (GCompare (ExVar i e), GCompare (ExQVar i e), GCompare (ExFun i e), GCompare (ExFunArg i e), GCompare (ExLVar i e)) => Extract i e where Source #

Minimal complete definition

extract

Associated Types

type ExVar i e :: Type -> * Source #

type ExQVar i e :: Type -> * Source #

type ExFun i e :: ([Type], Type) -> * Source #

type ExFunArg i e :: Type -> * Source #

type ExLVar i e :: Type -> * Source #

Methods

extract :: i -> e tp -> Maybe (Expression (ExVar i e) (ExQVar i e) (ExFun i e) (ExFunArg i e) (ExLVar i e) e tp) Source #

Instances

(GCompare Type var, GCompare Type qvar, GCompare ([Type], Type) fun, GCompare Type farg, GCompare Type lvar) => Extract () (SMTExpr var qvar fun farg lvar) Source # 

Associated Types

type ExVar () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type ExQVar () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type ExFun () (SMTExpr var qvar fun farg lvar :: Type -> *) :: ([Type], Type) -> * Source #

type ExFunArg () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type ExLVar () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

Methods

extract :: () -> SMTExpr var qvar fun farg lvar tp -> Maybe (Expression (ExVar () (SMTExpr var qvar fun farg lvar)) (ExQVar () (SMTExpr var qvar fun farg lvar)) (ExFun () (SMTExpr var qvar fun farg lvar)) (ExFunArg () (SMTExpr var qvar fun farg lvar)) (ExLVar () (SMTExpr var qvar fun farg lvar)) (SMTExpr var qvar fun farg lvar) tp) Source #

Backend b => Extract (BackendInfo b) (Expr b) Source # 

Associated Types

type ExVar (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

type ExQVar (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

type ExFun (BackendInfo b) (Expr b :: Type -> *) :: ([Type], Type) -> * Source #

type ExFunArg (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

type ExLVar (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

Methods

extract :: BackendInfo b -> Expr b tp -> Maybe (Expression (ExVar (BackendInfo b) (Expr b)) (ExQVar (BackendInfo b) (Expr b)) (ExFun (BackendInfo b) (Expr b)) (ExFunArg (BackendInfo b) (Expr b)) (ExLVar (BackendInfo b) (Expr b)) (Expr b) tp) Source #

data UserFun m e sig where Source #

A user-supplied function. Can be used in embedding Values or EvalResults. Since we don't have function equality in haskell, an integer is provided to distinguish functions.

Constructors

UserFun :: List Repr arg -> Repr res -> Int -> (List e arg -> m (e res)) -> UserFun m e '(arg, res) 

Instances

GetFunType (UserFun m e) Source # 

Methods

getFunType :: UserFun m e (([Type], Type) arg res) -> (List Type Repr arg, Repr res) Source #

GCompare ([Type], Type) (UserFun m e) Source # 

Methods

gcompare :: f a -> f b -> GOrdering (UserFun m e) a b #

GEq ([Type], Type) (UserFun m e) Source # 

Methods

geq :: f a -> f b -> Maybe ((UserFun m e := a) b) #

GShow ([Type], Type) (UserFun m e) Source # 

Methods

gshowsPrec :: Int -> t a -> ShowS #

newtype ValueExt m tp Source #

Constructors

ValueExt 

Fields

Instances

GCompare Type (ValueExt m) Source # 

Methods

gcompare :: f a -> f b -> GOrdering (ValueExt m) a b #

GEq Type (ValueExt m) Source # 

Methods

geq :: f a -> f b -> Maybe ((ValueExt m := a) b) #

GShow Type (ValueExt m) Source # 

Methods

gshowsPrec :: Int -> t a -> ShowS #

Embed Identity (ValueExt Identity) Source # 

Associated Types

type EmVar (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

type EmQVar (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

type EmFun (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

type EmLVar (Identity :: * -> *) (ValueExt Identity :: Type -> *) :: Type -> * Source #

GetType (ValueExt m) Source # 

Methods

getType :: ValueExt m tp -> Repr tp Source #

type EmVar Identity (ValueExt Identity) Source # 
type EmQVar Identity (ValueExt Identity) Source # 
type EmFun Identity (ValueExt Identity) Source # 
type EmFunArg Identity (ValueExt Identity) Source # 
type EmLVar Identity (ValueExt Identity) Source # 

newtype BackendInfo b Source #

Constructors

BackendInfo b 

Instances

Backend b => Extract (BackendInfo b) (Expr b) Source # 

Associated Types

type ExVar (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

type ExQVar (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

type ExFun (BackendInfo b) (Expr b :: Type -> *) :: ([Type], Type) -> * Source #

type ExFunArg (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

type ExLVar (BackendInfo b) (Expr b :: Type -> *) :: Type -> * Source #

Methods

extract :: BackendInfo b -> Expr b tp -> Maybe (Expression (ExVar (BackendInfo b) (Expr b)) (ExQVar (BackendInfo b) (Expr b)) (ExFun (BackendInfo b) (Expr b)) (ExFunArg (BackendInfo b) (Expr b)) (ExLVar (BackendInfo b) (Expr b)) (Expr b) tp) Source #

type ExVar (BackendInfo b) (Expr b) Source # 
type ExVar (BackendInfo b) (Expr b) = Var b
type ExQVar (BackendInfo b) (Expr b) Source # 
type ExQVar (BackendInfo b) (Expr b) = QVar b
type ExFun (BackendInfo b) (Expr b) Source # 
type ExFun (BackendInfo b) (Expr b) = Fun b
type ExFunArg (BackendInfo b) (Expr b) Source # 
type ExFunArg (BackendInfo b) (Expr b) = FunArg b
type ExLVar (BackendInfo b) (Expr b) Source # 
type ExLVar (BackendInfo b) (Expr b) = LVar b

data SMTExpr var qvar fun farg lvar tp where Source #

Constructors

SMTExpr :: Expression var qvar fun farg lvar (SMTExpr var qvar fun farg lvar) tp -> SMTExpr var qvar fun farg lvar tp 
SMTQuant :: Quantifier -> List Repr args -> (List qvar args -> SMTExpr var qvar fun farg lvar BoolType) -> SMTExpr var qvar fun farg lvar BoolType 

Instances

(GCompare Type var, GCompare Type qvar, GCompare ([Type], Type) fun, GCompare Type farg, GCompare Type lvar) => Extract () (SMTExpr var qvar fun farg lvar) Source # 

Associated Types

type ExVar () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type ExQVar () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type ExFun () (SMTExpr var qvar fun farg lvar :: Type -> *) :: ([Type], Type) -> * Source #

type ExFunArg () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type ExLVar () (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

Methods

extract :: () -> SMTExpr var qvar fun farg lvar tp -> Maybe (Expression (ExVar () (SMTExpr var qvar fun farg lvar)) (ExQVar () (SMTExpr var qvar fun farg lvar)) (ExFun () (SMTExpr var qvar fun farg lvar)) (ExFunArg () (SMTExpr var qvar fun farg lvar)) (ExLVar () (SMTExpr var qvar fun farg lvar)) (SMTExpr var qvar fun farg lvar) tp) Source #

(GCompare Type var, GetType var, GCompare Type qvar, GetType qvar, GCompare ([Type], Type) fun, GetFunType fun, GCompare Type farg, GetType farg, GCompare Type lvar, GetType lvar) => Embed Identity (SMTExpr var qvar fun farg lvar) Source # 

Associated Types

type EmVar (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type EmQVar (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type EmFun (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: ([Type], Type) -> * Source #

type EmFunArg (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

type EmLVar (Identity :: * -> *) (SMTExpr var qvar fun farg lvar :: Type -> *) :: Type -> * Source #

Methods

embed :: Identity (EmbedExpr Identity (SMTExpr var qvar fun farg lvar) tp) -> Identity (SMTExpr var qvar fun farg lvar tp) Source #

embedQuantifier :: Quantifier -> List Type Repr arg -> (forall m e. (Embed m e, Monad m) => List Type (EmQVar m e) arg -> m (e BoolType)) -> Identity (SMTExpr var qvar fun farg lvar BoolType) Source #

embedTypeOf :: Identity (SMTExpr var qvar fun farg lvar tp -> Repr tp) Source #

(GetType var, GetType qvar, GetFunType fun, GetType farg, GetType lvar) => GetType (SMTExpr var qvar fun farg lvar) Source # 

Methods

getType :: SMTExpr var qvar fun farg lvar tp -> Repr tp Source #

type ExVar () (SMTExpr var qvar fun farg lvar) Source # 
type ExVar () (SMTExpr var qvar fun farg lvar) = var
type ExQVar () (SMTExpr var qvar fun farg lvar) Source # 
type ExQVar () (SMTExpr var qvar fun farg lvar) = qvar
type ExFun () (SMTExpr var qvar fun farg lvar) Source # 
type ExFun () (SMTExpr var qvar fun farg lvar) = fun
type ExFunArg () (SMTExpr var qvar fun farg lvar) Source # 
type ExFunArg () (SMTExpr var qvar fun farg lvar) = farg
type ExLVar () (SMTExpr var qvar fun farg lvar) Source # 
type ExLVar () (SMTExpr var qvar fun farg lvar) = lvar
type EmVar Identity (SMTExpr var qvar fun farg lvar) Source # 
type EmVar Identity (SMTExpr var qvar fun farg lvar) = var
type EmQVar Identity (SMTExpr var qvar fun farg lvar) Source # 
type EmQVar Identity (SMTExpr var qvar fun farg lvar) = qvar
type EmFun Identity (SMTExpr var qvar fun farg lvar) Source # 
type EmFun Identity (SMTExpr var qvar fun farg lvar) = fun
type EmFunArg Identity (SMTExpr var qvar fun farg lvar) Source # 
type EmFunArg Identity (SMTExpr var qvar fun farg lvar) = farg
type EmLVar Identity (SMTExpr var qvar fun farg lvar) Source # 
type EmLVar Identity (SMTExpr var qvar fun farg lvar) = lvar

encodeExpr :: Backend b => SMTExpr (Var b) (QVar b) (Fun b) (FunArg b) (LVar b) tp -> SMT b (Expr b tp) Source #

decodeExpr :: Backend b => Expr b tp -> SMT b (SMTExpr (Var b) (QVar b) (Fun b) (FunArg b) (LVar b) tp) Source #

data AnalyzedExpr i e tp Source #

Constructors

AnalyzedExpr (Maybe (Expression (ExVar i e) (ExQVar i e) (ExFun i e) (ExFunArg i e) (ExLVar i e) (AnalyzedExpr i e) tp)) (e tp) 

analyze' :: Extract i e => i -> e tp -> AnalyzedExpr i e tp Source #

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