Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Type
- type family Lifted (tps :: [Type]) (idx :: [Type]) :: [Type] where ...
- class Unlift tps idx where
- type family Fst (a :: (p, q)) :: p where ...
- type family Snd (a :: (p, q)) :: q where ...
- class (Typeable dt, Ord (Datatype dt), GCompare (Constr dt), GCompare (Field dt)) => IsDatatype dt where
- type family CType (tp :: Type) (par :: [Type]) :: Type where ...
- type family Instantiated (sig :: [Type]) (par :: [Type]) :: [Type] where ...
- data ConApp dt par e = Length par ~ Parameters dt => ConApp {
- parameters' :: List Repr par
- constructor :: Constr dt csig
- arguments :: List e (Instantiated csig par)
- data AnyDatatype = IsDatatype dt => AnyDatatype (Datatype dt)
- data AnyConstr = IsDatatype dt => AnyConstr (Datatype dt) (Constr dt csig)
- data AnyField = IsDatatype dt => AnyField (Datatype dt) (Field dt tp)
- data TypeRegistry dt con field = TypeRegistry {
- allDatatypes :: Map dt AnyDatatype
- revDatatypes :: Map AnyDatatype dt
- allConstructors :: Map con AnyConstr
- revConstructors :: Map AnyConstr con
- allFields :: Map field AnyField
- revFields :: Map AnyField field
- emptyTypeRegistry :: TypeRegistry dt con field
- dependencies :: IsDatatype dt => Set String -> Datatype dt -> (Set String, [[AnyDatatype]])
- signature :: IsDatatype dt => Datatype dt -> List (List Repr) (Signature dt)
- constrSig :: IsDatatype dt => Constr dt sig -> List Repr sig
- instantiate :: List Repr sig -> List Repr par -> (List Repr (Instantiated sig par), Length sig :~: Length (Instantiated sig par))
- ctype :: Repr tp -> List Repr par -> Repr (CType tp par)
- determines :: IsDatatype dt => Datatype dt -> Constr dt sig -> Bool
- containedParameter :: Repr tp -> Set Integer -> Set Integer
- typeInference :: Repr atp -> Repr ctp -> (forall n ntp. Natural n -> Repr ntp -> a -> Maybe a) -> a -> Maybe a
- typeInferences :: List Repr atps -> List Repr ctps -> (forall n ntp. Natural n -> Repr ntp -> a -> Maybe a) -> a -> Maybe a
- partialInstantiation :: Repr tp -> (forall n a. Natural n -> (forall ntp. Repr ntp -> a) -> Maybe a) -> (forall rtp. Repr rtp -> a) -> a
- partialInstantiations :: List Repr tp -> (forall n a. Natural n -> (forall ntp. Repr ntp -> a) -> Maybe a) -> (forall rtp. Length tp ~ Length rtp => List Repr rtp -> a) -> a
- registerType :: (Monad m, IsDatatype tp, Ord dt, Ord con, Ord field) => dt -> (forall sig. Constr tp sig -> m con) -> (forall sig tp'. Field tp tp' -> m field) -> Datatype tp -> TypeRegistry dt con field -> m (TypeRegistry dt con field)
- registerTypeName :: IsDatatype dt => Datatype dt -> TypeRegistry String String String -> TypeRegistry String String String
- data DynamicDatatype par sig = DynDatatype {
- dynDatatypeParameters :: Natural par
- dynDatatypeSig :: List (DynamicConstructor sig) sig
- dynDatatypeName :: String
- data DynamicConstructor sig csig where
- DynConstructor :: Natural idx -> String -> List (DynamicField sig) (Index sig idx) -> DynamicConstructor sig (Index sig idx)
- data DynamicField sig tp where
- data DynamicValue plen sig par e where
- DynValue :: DynamicDatatype (Length par) sig -> List Repr par -> DynamicConstructor sig csig -> List e (Instantiated csig par) -> DynamicValue (Length par) sig par e
- newtype BitWidth bw = BitWidth {}
- getBw :: Integer -> (forall bw. KnownNat bw => BitWidth bw -> a) -> a
- data Value a where
- pattern ConstrValue :: forall a. () => forall par dt csig. ((~) Nat (Length Type par) (Parameters dt), (~) Type a (DataType ([Type] -> (Type -> *) -> *) dt par), IsDatatype dt) => List Type Repr par -> Constr dt csig -> List Type Value (Instantiated csig par) -> Value a
- data AnyValue = AnyValue (Value t)
- data Repr t where
- BoolRepr :: Repr BoolType
- IntRepr :: Repr IntType
- RealRepr :: Repr RealType
- BitVecRepr :: BitWidth bw -> Repr (BitVecType bw)
- ArrayRepr :: List Repr idx -> Repr val -> Repr (ArrayType idx val)
- DataRepr :: (IsDatatype dt, Length par ~ Parameters dt) => Datatype dt -> List Repr par -> Repr (DataType dt par)
- ParameterRepr :: Natural p -> Repr (ParameterType p)
- data NumRepr t where
- data FunRepr sig where
- class GetType v where
- class GetFunType fun where
- bw :: KnownNat bw => Proxy bw -> BitWidth bw
- bool :: Repr BoolType
- int :: Repr IntType
- real :: Repr RealType
- bitvec :: BitWidth bw -> Repr (BitVecType bw)
- array :: List Repr idx -> Repr el -> Repr (ArrayType idx el)
- dt :: (IsDatatype dt, Parameters dt ~ Z) => Datatype dt -> Repr (DataType dt '[])
- dt' :: (IsDatatype dt, Length par ~ Parameters dt) => Datatype dt -> List Repr par -> Repr (DataType dt par)
- showBitVec :: Int -> Integer -> Integer -> ShowS
- valueType :: Value tp -> Repr tp
- liftType :: List Repr tps -> List Repr idx -> List Repr (Lifted tps idx)
- numRepr :: NumRepr tp -> Repr tp
- asNumRepr :: Repr tp -> Maybe (NumRepr tp)
- getTypes :: GetType e => List e tps -> List Repr tps
- typeSize :: Maybe (List Repr par) -> Repr tp -> Maybe Integer
- typeFiniteDomain :: Repr tp -> Maybe [Value tp]
- withBW :: KnownNat bw => (Proxy bw -> res (BitVecType bw)) -> res (BitVecType bw)
- bvAdd :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw)
- bvSub :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw)
- bvMul :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw)
- bvDiv :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw)
- bvMod :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw)
- bvNegate :: Value (BitVecType bw) -> Value (BitVecType bw)
- bvSignum :: Value (BitVecType bw) -> Value (BitVecType bw)
- bvSucc :: Value (BitVecType bw) -> Value (BitVecType bw)
- bvPred :: Value (BitVecType bw) -> Value (BitVecType bw)
- bvMinValue :: Bool -> Repr (BitVecType bw) -> Value (BitVecType bw)
- bvMaxValue :: Bool -> Repr (BitVecType bw) -> Value (BitVecType bw)
- bwAdd :: BitWidth bw1 -> BitWidth bw2 -> BitWidth (bw1 + bw2)
- datatypeEq :: (IsDatatype dt1, IsDatatype dt2) => Datatype dt1 -> Datatype dt2 -> Maybe (dt1 :~: dt2)
- datatypeCompare :: (IsDatatype dt1, IsDatatype dt2) => Datatype dt1 -> Datatype dt2 -> GOrdering dt1 dt2
Documentation
Describes the kind of all SMT types.
It is only used in promoted form, for a concrete representation see Repr
.
class (Typeable dt, Ord (Datatype dt), GCompare (Constr dt), GCompare (Field dt)) => IsDatatype dt where Source #
datatypeGet, parameters, datatypeName, constructors, constrName, test, fields, construct, deconstruct, fieldName, fieldType, fieldGet
type Parameters dt :: Nat Source #
type Signature dt :: [[Type]] Source #
data Datatype dt :: * Source #
datatypeGet :: (GetType e, Length par ~ Parameters dt) => dt par e -> (Datatype dt, List Repr par) Source #
Get the data type from a value
parameters :: Datatype dt -> Natural (Parameters dt) Source #
How many polymorphic parameters does this datatype have
datatypeName :: Datatype dt -> String Source #
The name of the datatype. Must be unique.
constructors :: Datatype dt -> List (Constr dt) (Signature dt) Source #
Get all of the constructors of this datatype
constrName :: Constr dt csig -> String Source #
Get the name of a constructor
test :: dt par e -> Constr dt csig -> Bool Source #
Test if a value is constructed using a specific constructor
fields :: Constr dt csig -> List (Field dt) csig Source #
Get all the fields of a constructor
construct :: Length par ~ Parameters dt => List Repr par -> Constr dt csig -> List e (Instantiated csig par) -> dt par e Source #
Construct a value using a constructor
deconstruct :: GetType e => dt par e -> ConApp dt par e Source #
Deconstruct a value into a constructor and a list of arguments
fieldName :: Field dt tp -> String Source #
Get the name of a field
fieldType :: Field dt tp -> Repr tp Source #
Get the type of a field
fieldGet :: dt par e -> Field dt tp -> e (CType tp par) Source #
Extract a field value from a value
(Typeable Nat l, Typeable [[Type]] sig) => IsDatatype (DynamicValue l sig) Source # | |
type family CType (tp :: Type) (par :: [Type]) :: Type where ... Source #
CType BoolType par = BoolType | |
CType IntType par = IntType | |
CType RealType par = RealType | |
CType (BitVecType w) par = BitVecType w | |
CType (ArrayType idx el) par = ArrayType (Instantiated idx par) (CType el par) | |
CType (DataType dt arg) par = DataType dt (Instantiated arg par) | |
CType (ParameterType n) par = Index par n |
type family Instantiated (sig :: [Type]) (par :: [Type]) :: [Type] where ... Source #
Instantiated '[] par = '[] | |
Instantiated (tp ': tps) par = CType tp par ': Instantiated tps par |
Length par ~ Parameters dt => ConApp | |
|
data AnyDatatype Source #
IsDatatype dt => AnyDatatype (Datatype dt) |
IsDatatype dt => AnyConstr (Datatype dt) (Constr dt csig) |
IsDatatype dt => AnyField (Datatype dt) (Field dt tp) |
data TypeRegistry dt con field Source #
TypeRegistry | |
|
emptyTypeRegistry :: TypeRegistry dt con field Source #
:: IsDatatype dt | |
=> Set String | Already registered datatypes |
-> Datatype dt | |
-> (Set String, [[AnyDatatype]]) |
instantiate :: List Repr sig -> List Repr par -> (List Repr (Instantiated sig par), Length sig :~: Length (Instantiated sig par)) Source #
determines :: IsDatatype dt => Datatype dt -> Constr dt sig -> Bool Source #
typeInferences :: List Repr atps -> List Repr ctps -> (forall n ntp. Natural n -> Repr ntp -> a -> Maybe a) -> a -> Maybe a Source #
partialInstantiation :: Repr tp -> (forall n a. Natural n -> (forall ntp. Repr ntp -> a) -> Maybe a) -> (forall rtp. Repr rtp -> a) -> a Source #
partialInstantiations :: List Repr tp -> (forall n a. Natural n -> (forall ntp. Repr ntp -> a) -> Maybe a) -> (forall rtp. Length tp ~ Length rtp => List Repr rtp -> a) -> a Source #
registerType :: (Monad m, IsDatatype tp, Ord dt, Ord con, Ord field) => dt -> (forall sig. Constr tp sig -> m con) -> (forall sig tp'. Field tp tp' -> m field) -> Datatype tp -> TypeRegistry dt con field -> m (TypeRegistry dt con field) Source #
registerTypeName :: IsDatatype dt => Datatype dt -> TypeRegistry String String String -> TypeRegistry String String String Source #
data DynamicDatatype par sig Source #
DynDatatype | |
|
Eq (DynamicDatatype par sig) Source # | |
Ord (DynamicDatatype par sig) Source # | |
data DynamicConstructor sig csig where Source #
DynConstructor :: Natural idx -> String -> List (DynamicField sig) (Index sig idx) -> DynamicConstructor sig (Index sig idx) |
GCompare [Type] (DynamicConstructor sig) Source # | |
GEq [Type] (DynamicConstructor sig) Source # | |
data DynamicField sig tp where Source #
data DynamicValue plen sig par e where Source #
DynValue :: DynamicDatatype (Length par) sig -> List Repr par -> DynamicConstructor sig csig -> List e (Instantiated csig par) -> DynamicValue (Length par) sig par e |
GCompare Type (Field (DynamicValue l sig)) Source # | |
GEq Type (Field (DynamicValue l sig)) Source # | |
Eq (Datatype (DynamicValue l sig)) Source # | |
Ord (Datatype (DynamicValue l sig)) Source # | |
Show (Datatype (DynamicValue l sig)) Source # | |
GCompare [Type] (Constr (DynamicValue l sig)) Source # | |
GEq [Type] (Constr (DynamicValue l sig)) Source # | |
(Typeable Nat l, Typeable [[Type]] sig) => IsDatatype (DynamicValue l sig) Source # | |
type Parameters (DynamicValue l sig) Source # | |
type Signature (DynamicValue l sig) Source # | |
data Datatype (DynamicValue l sig) Source # | |
data Constr (DynamicValue l sig) Source # | |
data Field (DynamicValue l sig) Source # | |
Values that can be used as constants in expressions.
BoolValue :: Bool -> Value BoolType | |
IntValue :: Integer -> Value IntType | |
RealValue :: Rational -> Value RealType | |
BitVecValue :: Integer -> BitWidth bw -> Value (BitVecType bw) | |
DataValue :: (IsDatatype dt, Length par ~ Parameters dt) => dt par Value -> Value (DataType dt par) |
pattern ConstrValue :: forall a. () => forall par dt csig. ((~) Nat (Length Type par) (Parameters dt), (~) Type a (DataType ([Type] -> (Type -> *) -> *) dt par), IsDatatype dt) => List Type Repr par -> Constr dt csig -> List Type Value (Instantiated csig par) -> Value a Source #
A concrete representation of an SMT type.
For aesthetic reasons, it's recommended to use the functions bool
, int
, real
, bitvec
or array
.
BoolRepr :: Repr BoolType | |
IntRepr :: Repr IntType | |
RealRepr :: Repr RealType | |
BitVecRepr :: BitWidth bw -> Repr (BitVecType bw) | |
ArrayRepr :: List Repr idx -> Repr val -> Repr (ArrayType idx val) | |
DataRepr :: (IsDatatype dt, Length par ~ Parameters dt) => Datatype dt -> List Repr par -> Repr (DataType dt par) | |
ParameterRepr :: Natural p -> Repr (ParameterType p) |
GetType Repr Source # | |
GCompare Type Repr Source # | |
GEq Type Repr Source # | |
GShow Type Repr Source # | |
Embed Identity Repr Source # | |
Eq (Repr tp) Source # | |
Ord (Repr tp) Source # | |
Show (Repr t) Source # | |
type EmVar Identity Repr Source # | |
type EmQVar Identity Repr Source # | |
type EmFun Identity Repr Source # | |
type EmFunArg Identity Repr Source # | |
type EmLVar Identity Repr Source # | |
class GetType v where Source #
GetType NumRepr Source # | |
GetType Repr Source # | |
GetType Value Source # | |
GetType NoVar Source # | |
GetFunType fun => GetType (EvalResult fun) Source # | |
GetType (UntypedVar v) Source # | |
GetType (ValueExt m) Source # | |
(GetType var, GetType qvar, GetFunType fun, GetType farg, GetType lvar) => GetType (SMTExpr var qvar fun farg lvar) Source # | |
(GetType v, GetType qv, GetFunType fun, GetType fv, GetType lv, GetType e) => GetType (Expression v qv fun fv lv e) Source # | |
class GetFunType fun where Source #
GetFunType NoFun Source # | |
GetFunType fun => GetFunType (Function fun) Source # | |
GetFunType (UntypedFun v) Source # | |
GetFunType (UserFun m e) Source # | |
A representation of the SMT Int type.
Holds the unbounded positive and negative integers.
Constants can be created using cint
.
real :: Repr RealType Source #
A representation of the SMT Real type.
Holds positive and negative reals x/y where x and y are integers.
Constants can be created using creal
.
:: BitWidth bw | The width of the bitvector |
-> Repr (BitVecType bw) |
A typed representation of the SMT BitVec type.
Holds bitvectors (a vector of booleans) of a certain bitwidth.
Constants can be created using cbv
.
array :: List Repr idx -> Repr el -> Repr (ArrayType idx el) Source #
A representation of the SMT Array type.
Has a list of index types and an element type.
Stores one value of the element type for each combination of the index types.
Constants can be created using constArray
.
dt :: (IsDatatype dt, Parameters dt ~ Z) => Datatype dt -> Repr (DataType dt '[]) Source #
A representation of a user-defined datatype without parameters.
dt' :: (IsDatatype dt, Length par ~ Parameters dt) => Datatype dt -> List Repr par -> Repr (DataType dt par) Source #
A representation of a user-defined datatype with parameters.
typeSize :: Maybe (List Repr par) -> Repr tp -> Maybe Integer Source #
Determine the number of elements a type contains.
Nothing
means the type has infinite elements.
withBW :: KnownNat bw => (Proxy bw -> res (BitVecType bw)) -> res (BitVecType bw) Source #
bvAdd :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvSub :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvMul :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvDiv :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvMod :: Value (BitVecType bw) -> Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvNegate :: Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvSignum :: Value (BitVecType bw) -> Value (BitVecType bw) Source #
bvSucc :: Value (BitVecType bw) -> Value (BitVecType bw) Source #
Get the smallest bitvector value that is bigger than the given one. Also known as the successor.
bvPred :: Value (BitVecType bw) -> Value (BitVecType bw) Source #
Get the largest bitvector value that is smaller than the given one. Also known as the predecessor.
:: Bool | Signed bitvector? |
-> Repr (BitVecType bw) | |
-> Value (BitVecType bw) |
Get the minimal value for a bitvector. If unsigned, the value is 0, otherwise 2^(bw-1).
:: Bool | Signed bitvector? |
-> Repr (BitVecType bw) | |
-> Value (BitVecType bw) |
Get the maximal value for a bitvector. If unsigned, the value is 2^(bw-1)-1, otherwise 2^bw-1.
datatypeEq :: (IsDatatype dt1, IsDatatype dt2) => Datatype dt1 -> Datatype dt2 -> Maybe (dt1 :~: dt2) Source #
datatypeCompare :: (IsDatatype dt1, IsDatatype dt2) => Datatype dt1 -> Datatype dt2 -> GOrdering dt1 dt2 Source #