hasmtlib-1.0.1: 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).

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 #

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

Injective type-family that computes the Haskell Type of a 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 #

Eq (Value t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

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

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

Ord (Value t) Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

Methods

compare :: Value t -> Value t -> Ordering #

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

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

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

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

max :: Value t -> Value t -> Value t #

min :: Value t -> Value t -> Value t #

unwrapValue :: Value t -> HaskellType t Source #

Unwrap a value.

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

Wrap a value.

data SSMTSort (t :: SMTSort) where Source #

Singleton for SMTSort.

Instances

Instances details
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.

Instances

Instances details
KnownSMTSort 'BoolSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

KnownSMTSort 'IntSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

KnownSMTSort 'RealSort Source # 
Instance details

Defined in Language.Hasmtlib.Internal.Expr

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

Defined in Language.Hasmtlib.Internal.Expr

data SomeKnownSMTSort f where Source #

An existential wrapper that hides some SMTSort.

Constructors

SomeKnownSMTSort :: forall (t :: SMTSort) f. KnownSMTSort t => f t -> SomeKnownSMTSort f 

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

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.

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