hasmtlib-1.3.0: A monad for interfacing with external SMT solvers
Safe HaskellSafe-Inferred
LanguageGHC2021

Language.Hasmtlib.Type.Expr

Synopsis

Documentation

data SMTSort Source #

Sorts in SMTLib2 - used as promoted type (data-kind).

Constructors

BoolSort

Sort of Bool

IntSort

Sort of Int

RealSort

Sort of Real

BvSort Nat

Sort of BitVec with length n

ArraySort SMTSort SMTSort

Sort of Array with indices k and values v

Instances

Instances details
GCompare SSMTSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

gcompare :: forall (a :: k) (b :: k). SSMTSort a -> SSMTSort b -> GOrdering a b #

GEq SSMTSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

geq :: forall (a :: k) (b :: k). SSMTSort a -> SSMTSort b -> Maybe (a :~: b) #

newtype SMTVar (t :: SMTSort) Source #

An internal SMT variable with a phantom-type which holds an Int as it's identifier.

Constructors

SMTVar 

Fields

Instances

Instances details
Show (SMTVar t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

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

show :: SMTVar t -> String #

showList :: [SMTVar t] -> ShowS #

Eq (SMTVar t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

(==) :: SMTVar t -> SMTVar t -> Bool #

(/=) :: SMTVar t -> SMTVar t -> Bool #

Ord (SMTVar t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

compare :: SMTVar t -> SMTVar t -> Ordering #

(<) :: SMTVar t -> SMTVar t -> Bool #

(<=) :: SMTVar t -> SMTVar t -> Bool #

(>) :: SMTVar t -> SMTVar t -> Bool #

(>=) :: SMTVar t -> SMTVar t -> Bool #

max :: SMTVar t -> SMTVar t -> SMTVar t #

min :: SMTVar t -> SMTVar t -> SMTVar t #

Render (SMTVar t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

render :: SMTVar t -> Builder Source #

varId :: forall t t. Iso (SMTVar t) (SMTVar t) Int Int Source #

type family HaskellType (t :: SMTSort) = (r :: Type) | r -> t where ... Source #

Injective type-family that computes the Haskell Type of an SMTSort.

data Value (t :: SMTSort) where Source #

A wrapper for values of SMTSorts.

Instances

Instances details
Show (Value t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

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

show :: Value t -> String #

showList :: [Value t] -> ShowS #

Render (Value t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

render :: Value t -> Builder Source #

unwrapValue :: Value t -> HaskellType t Source #

Unwrap a value from Value.

wrapValue :: forall t. KnownSMTSort t => HaskellType t -> Value t Source #

Wrap a value into Value.

data SSMTSort (t :: SMTSort) where Source #

Singleton for SMTSort.

Instances

Instances details
GCompare SSMTSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

gcompare :: forall (a :: k) (b :: k). SSMTSort a -> SSMTSort b -> GOrdering a b #

GEq SSMTSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

geq :: forall (a :: k) (b :: k). SSMTSort a -> SSMTSort b -> Maybe (a :~: b) #

Show (SSMTSort t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

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

show :: SSMTSort t -> String #

showList :: [SSMTSort t] -> ShowS #

Eq (SSMTSort t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

(==) :: SSMTSort t -> SSMTSort t -> Bool #

(/=) :: SSMTSort t -> SSMTSort t -> Bool #

Ord (SSMTSort t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

compare :: SSMTSort t -> SSMTSort t -> Ordering #

(<) :: SSMTSort t -> SSMTSort t -> Bool #

(<=) :: SSMTSort t -> SSMTSort t -> Bool #

(>) :: SSMTSort t -> SSMTSort t -> Bool #

(>=) :: SSMTSort t -> SSMTSort t -> Bool #

max :: SSMTSort t -> SSMTSort t -> SSMTSort t #

min :: SSMTSort t -> SSMTSort t -> SSMTSort t #

Render (SSMTSort t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

render :: SSMTSort t -> Builder Source #

class KnownSMTSort (t :: SMTSort) where Source #

Compute singleton SSMTSort from it's promoted type SMTSort.

sortSing' :: forall prxy t. KnownSMTSort t => prxy t -> SSMTSort t Source #

Wrapper for sortSing which takes a Proxy

data SomeSMTSort cs f where Source #

An existential wrapper that hides some SMTSort and a list of Constraints holding for it.

Constructors

SomeSMTSort :: forall cs f (t :: SMTSort). AllC cs t => f t -> SomeSMTSort cs f 

type SomeKnownSMTSort f = SomeSMTSort '[KnownSMTSort] f Source #

An existential wrapper that hides some known SMTSort.

type family AllC cs k :: Constraint where ... Source #

AllC ensures that a list of constraints is applied to a poly-kinded Type k

AllC '[]       k = ()
AllC (c ': cs) k = (c k, AllC cs k)

Equations

AllC '[] k = () 
AllC (c ': cs) k = (c k, AllC cs k) 

data Expr (t :: SMTSort) Source #

A SMT expression. For internal use only. For building expressions use the corresponding instances (Num, Boolean, ...).

Instances

Instances details
Bounded (Expr 'BoolSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

KnownNat n => Bounded (Expr ('BvSort n)) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

minBound :: Expr ('BvSort n) #

maxBound :: Expr ('BvSort n) #

Floating (Expr 'RealSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

KnownNat n => Num (Expr ('BvSort n)) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

Methods

(+) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) #

(-) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) #

(*) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) #

negate :: Expr ('BvSort n) -> Expr ('BvSort n) #

abs :: Expr ('BvSort n) -> Expr ('BvSort n) #

signum :: Expr ('BvSort n) -> Expr ('BvSort n) #

fromInteger :: Integer -> Expr ('BvSort n) #

Num (Expr 'IntSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

Num (Expr 'RealSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

Fractional (Expr 'RealSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

Show (Expr t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

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

show :: Expr t -> String #

showList :: [Expr t] -> ShowS #

Boolean (Expr 'BoolSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

KnownNat n => Boolean (Expr ('BvSort n)) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

bool :: Bool -> Expr ('BvSort n) Source #

true :: Expr ('BvSort n) Source #

false :: Expr ('BvSort n) Source #

(&&) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

(||) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

(==>) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

not :: Expr ('BvSort n) -> Expr ('BvSort n) Source #

xor :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

KnownSMTSort t => Codec (Expr t) Source #

Decode and evaluate expressions

Instance details

Defined in Language.Hasmtlib.Codec

Associated Types

type Decoded (Expr t) Source #

Methods

decode :: Solution -> Expr t -> Maybe (Decoded (Expr t)) Source #

encode :: Decoded (Expr t) -> Expr t Source #

(KnownSMTSort t, Eq (HaskellType t)) => Equatable (Expr t) Source # 
Instance details

Defined in Language.Hasmtlib.Equatable

Methods

(===) :: Expr t -> Expr t -> Expr 'BoolSort Source #

(/==) :: Expr t -> Expr t -> Expr 'BoolSort Source #

KnownNat n => Integraled (Expr ('BvSort n)) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

Methods

quot :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

rem :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

div :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

mod :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr ('BvSort n) Source #

quotRem :: Expr ('BvSort n) -> Expr ('BvSort n) -> (Expr ('BvSort n), Expr ('BvSort n)) Source #

divMod :: Expr ('BvSort n) -> Expr ('BvSort n) -> (Expr ('BvSort n), Expr ('BvSort n)) Source #

Integraled (Expr 'IntSort) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr.Num

KnownSMTSort t => Render (Expr t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

render :: Expr t -> Builder Source #

KnownNat n => Orderable (Expr ('BvSort n)) Source # 
Instance details

Defined in Language.Hasmtlib.Orderable

Methods

(<=?) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr 'BoolSort Source #

(>=?) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr 'BoolSort Source #

(<?) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr 'BoolSort Source #

(>?) :: Expr ('BvSort n) -> Expr ('BvSort n) -> Expr 'BoolSort Source #

Orderable (Expr 'IntSort) Source # 
Instance details

Defined in Language.Hasmtlib.Orderable

Orderable (Expr 'RealSort) Source # 
Instance details

Defined in Language.Hasmtlib.Orderable

KnownSMTSort t => Variable (Expr t) Source # 
Instance details

Defined in Language.Hasmtlib.Variable

Methods

variable :: MonadSMT s m => m (Expr t) Source #

Iteable (Expr 'BoolSort) () Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> () -> () -> () Source #

Iteable (Expr 'BoolSort) a => Iteable (Expr 'BoolSort) (Seq a) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> Seq a -> Seq a -> Seq a Source #

Iteable (Expr 'BoolSort) a => Iteable (Expr 'BoolSort) (Tree a) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> Tree a -> Tree a -> Tree a Source #

Iteable (Expr 'BoolSort) (Expr t) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> Expr t -> Expr t -> Expr t Source #

Iteable (Expr 'BoolSort) a => Iteable (Expr 'BoolSort) (Maybe a) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> Maybe a -> Maybe a -> Maybe a Source #

Iteable (Expr 'BoolSort) a => Iteable (Expr 'BoolSort) [a] Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> [a] -> [a] -> [a] Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b) => Iteable (Expr 'BoolSort) (a, b) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b) -> (a, b) -> (a, b) Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b, Iteable (Expr 'BoolSort) c) => Iteable (Expr 'BoolSort) (a, b, c) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b, c) -> (a, b, c) -> (a, b, c) Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b, Iteable (Expr 'BoolSort) c, Iteable (Expr 'BoolSort) d) => Iteable (Expr 'BoolSort) (a, b, c, d) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b, Iteable (Expr 'BoolSort) c, Iteable (Expr 'BoolSort) d, Iteable (Expr 'BoolSort) e) => Iteable (Expr 'BoolSort) (a, b, c, d, e) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b, Iteable (Expr 'BoolSort) c, Iteable (Expr 'BoolSort) d, Iteable (Expr 'BoolSort) e, Iteable (Expr 'BoolSort) f) => Iteable (Expr 'BoolSort) (a, b, c, d, e, f) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b, Iteable (Expr 'BoolSort) c, Iteable (Expr 'BoolSort) d, Iteable (Expr 'BoolSort) e, Iteable (Expr 'BoolSort) f, Iteable (Expr 'BoolSort) g) => Iteable (Expr 'BoolSort) (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

(Iteable (Expr 'BoolSort) a, Iteable (Expr 'BoolSort) b, Iteable (Expr 'BoolSort) c, Iteable (Expr 'BoolSort) d, Iteable (Expr 'BoolSort) e, Iteable (Expr 'BoolSort) f, Iteable (Expr 'BoolSort) g, Iteable (Expr 'BoolSort) h) => Iteable (Expr 'BoolSort) (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Language.Hasmtlib.Iteable

Methods

ite :: Expr 'BoolSort -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source #

type Decoded (Expr t) Source # 
Instance details

Defined in Language.Hasmtlib.Codec

type Decoded (Expr t) = HaskellType t

equal :: (Eq (HaskellType t), KnownSMTSort t, Foldable f) => f (Expr t) -> Expr BoolSort Source #

Test multiple expressions on equality within in the SMT-Problem.

distinct :: (Eq (HaskellType t), KnownSMTSort t, Foldable f) => f (Expr t) -> Expr BoolSort Source #

Test multiple expressions on distinctness within in the SMT-Problem.

bvShL :: KnownNat n => Expr (BvSort n) -> Expr (BvSort n) -> Expr (BvSort n) Source #

Bitvector shift left

bvLShR :: KnownNat n => Expr (BvSort n) -> Expr (BvSort n) -> Expr (BvSort n) Source #

Bitvector logical shift right

bvConcat :: (KnownNat n, KnownNat m) => Expr (BvSort n) -> Expr (BvSort m) -> Expr (BvSort (n + m)) Source #

Concat two bitvectors

bvRotL :: (KnownNat n, KnownNat i, KnownNat (Mod i n)) => Proxy i -> Expr (BvSort n) -> Expr (BvSort n) Source #

Rotate bitvector left

bvRotR :: (KnownNat n, KnownNat i, KnownNat (Mod i n)) => Proxy i -> Expr (BvSort n) -> Expr (BvSort n) Source #

Rotate bitvector right

for_all :: forall t. KnownSMTSort t => (Expr t -> Expr BoolSort) -> Expr BoolSort Source #

A universal quantification for any specific SMTSort. If the type cannot be inferred, apply a type-annotation. Nested quantifiers are also supported.

Usage:

  assert $
     for_all @IntSort $ x ->
        x + 0 === x && 0 + x === x
  

The lambdas x is all-quantified here. It will only be scoped for the lambdas body.

exists :: forall t. KnownSMTSort t => (Expr t -> Expr BoolSort) -> Expr BoolSort Source #

An existential quantification for any specific SMTSort If the type cannot be inferred, apply a type-annotation. Nested quantifiers are also supported.

Usage:

  assert $
     for_all @(BvSort 8) $ x ->
         exists $ y ->
           x - y === 0
  

The lambdas y is existentially quantified here. It will only be scoped for the lambdas body.

select :: (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => Expr (ArraySort k v) -> Expr k -> Expr v Source #

Select a value from an array.

store :: (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => Expr (ArraySort k v) -> Expr k -> Expr v -> Expr (ArraySort k v) Source #

Store a value in an array.