grisette-0.5.0.0: Symbolic evaluation as a library
Copyright(c) Sirui Lu 2021-2024
LicenseBSD-3-Clause (see the LICENSE file)
Maintainersiruilu@cs.washington.edu
StabilityExperimental
PortabilityGHC only
Safe HaskellTrustworthy
LanguageHaskell2010

Grisette.Core

Description

 
Synopsis

Note for the examples

The examples may assume a z3 solver available in PATH.

Symbolic values

Grisette is a tool for performing symbolic evaluation on programs. Symbolic evaluation is a technique that allows us to analyze all possible runs of a program by representing inputs (or the program itself) as symbolic values and evaluating the program to produce symbolic constraints over these values. These constraints can then be used to find concrete assignments to the symbolic values that meet certain criteria, such as triggering a bug in a verification task or satisfying a specification in a synthesis task.

One of the challenges of symbolic evaluation is the well-known path explosion problem, which occurs when traditions symbolic evaluation techniques evaluate and reason about the possible paths one-by-one. This can lead to exponential growth in the number of paths that need to be analyzed, making the process impractical for many tasks. To address this issue, Grisette uses a technique called "path merging". In path merging, symbolic values are merged together in order to reduce the number of paths that need to be explored simultaneously. This can significantly improve the performance of symbolic evaluation, especially for tasks such as program synthesis that are prone to the path explosion problem.

In Grisette, we make a distinction between two kinds of symbolic values: solvable types and unsolvable types. These two types of values are merged differently.

Solvable types are types that are directly supported by the underlying solver and are represented as symbolic formulas. Examples include symbolic Booleans, integers and bit vectors. The values of solvable types can be fully merged into a single value, which can significantly reduce the number of paths that need to be explored.

For example, there are three symbolic Booleans a, b and c, in the following code, and a symbolic Boolean x is defined to be the result of a conditional expression:

x = if a then b else c -- pseudo code, not real Grisette code

The result would be a single symbolic Boolean formula:

-- result: x is (ite a b c)

If we further add 1 to x, we will not have to split to two paths, but we can directly construct a formula with the merged state:

x + 1
-- result (+ 1 (ite a b c))

Unsolvable types, on the other hand, are types that are not directly supported by the solver and cannot be fully merged into a single formula. Examples include lists, algebraic data types, and concrete Haskell integer types. To symbolically evaluate values in unsolvable types, Grisette provides a symbolic union container, which is a set of values guarded by their path conditions. The values of unsolvable types are partially merged in a symbolic union, which is essentially an if-then-else tree.

For example, assume that the lists have the type [SymBool]. In the following example, the result shows that [b] and [c] can be merged together in the same symbolic union because they have the same length:

x = if a then [b] else [c] -- pseudo code, not real Grisette code
-- result: Single [(ite a b c)]

The second example shows that [b] and [c,d] cannot be merged together because they have different lengths:

if a then [b] else [c, d] -- pseudo code, not real Grisette code
-- result: If a (Single [b]) (Single [c,d])

The following example is more complicated. To make the merging efficient, Grisette would maintain a representation invariant of the symbolic unions. In this case, the lists with length 1 should be placed at the then branch, and the lists with length 2 should be placed at the else branch.

if a1 then [b] else if a2 then [c, d] else [f] -- pseudo code, not real Grisette code
-- result: If (|| a1 (! a2)) (Single [(ite a1 b f)]) (Single [c,d])

When we further operate on this partially merged values, we will need to split into multiple paths. For example, when we apply head onto the last result, we will distribute head among the branches:

head (if a1 then [b] else if a2 then [c, d] else [f]) -- pseudo code, not real Grisette code
-- intermediate result: If (|| a1 (! a2)) (Single (head [(ite a1 b f)])) (Single (head [c,d]))
-- intermediate result: If (|| a1 (! a2)) (Single (ite a1 b f)) (Single c)

Then the result would be further merged into a single value:

-- final result: Single (ite (|| a1 (! a2)) (ite a1 b f) c)

Generally, merging the possible branches in a symbolic union can reduce the number of paths to be explored in the future, but can make the path conditions larger and harder to solve. To have a good balance between this, Grisette has built a hierarchical merging algorithm, which is configurable via MergingStrategy. For algebraic data types, we have prebuilt merging strategies via the derivation of the Mergeable type class. You only need to know the details of the merging algorithm if you are going to work with non-algebraic data types.

Solvable types

A solvable type is a type that can be represented as a formula and is directly supported by the underlying constraint solvers. Grisette currently provides an implementation for the following solvable types:

  • SymBool (symbolic Booleans)
  • SymInteger (symbolic unbounded integers)
  • SymIntN n (symbolic signed bit vectors of length n)
  • SymWordN n (symbolic unsigned bit vectors of length n)

The two bit vector types has their lengths checked at compile time. Grisette also provides runtime-checked versions of these types: SomeSymIntN and SomeSymWordN.

Values of a solvable type can consist of concrete values, symbolic constants (placeholders for concrete values that can be assigned by a solver to satisfy a formula), and complex symbolic formulas with symbolic operations. The Solvable type class provides a way to construct concrete values and symbolic constants.

Examples:

>>> import Grisette
>>> con True :: SymBool -- a concrete value
true
>>> ssym "a" :: SymBool -- a symbolic constant
a

With the OverloadedStrings GHC extension enabled, symbolic constants can also be constructed from strings.

>>> :set -XOverloadedStrings
>>> "a" :: SymBool
a

Symbolic operations are provided through a set of type classes, such as SEq, SOrd, and Num. Please check out the documentation for more details.

Examples:

>>> let a = "a" :: SymInteger
>>> let b = "b" :: SymInteger
>>> a .== b
(= a b)

Creation of solvable type values

class IsString t => Solvable c t | t -> c where Source #

The class defines the creation and pattern matching of solvable type values.

Minimal complete definition

con, conView, sym

Methods

con :: c -> t Source #

Wrap a concrete value in a symbolic value.

>>> con True :: SymBool
true

conView :: t -> Maybe c Source #

Extract the concrete value from a symbolic value.

>>> conView (con True :: SymBool)
Just True
>>> conView (ssym "a" :: SymBool)
Nothing

sym :: Symbol -> t Source #

Generate symbolic constants.

Two symbolic constants with the same symbol are the same symbolic constant, and will always be assigned with the same value by the solver.

>>> sym "a" :: SymBool
a
>>> (sym "a" :: SymBool) == sym "a"
True
>>> (sym "a" :: SymBool) == sym "b"
False
>>> (sym "a" :: SymBool) .&& sym "a"
a
>>> (sym "a" :: SymBool) == isym "a" 1
False

ssym :: Identifier -> t Source #

Generate simply-named symbolic constants.

Two symbolic constants with the same identifier are the same symbolic constant, and will always be assigned with the same value by the solver.

>>> ssym "a" :: SymBool
a
>>> (ssym "a" :: SymBool) == ssym "a"
True
>>> (ssym "a" :: SymBool) == ssym "b"
False
>>> (ssym "a" :: SymBool) .&& ssym "a"
a

isym :: Identifier -> Int -> t Source #

Generate indexed symbolic constants.

Two symbolic constants with the same identifier but different indices are not the same symbolic constants.

>>> isym "a" 1 :: SymBool
a@1

Instances

Instances details
Solvable Integer SymInteger Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymInteger

Solvable Bool SymBool Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBool

(Solvable c t, Mergeable t) => Solvable c (UnionM t) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(KnownNat n, 1 <= n) => Solvable (IntN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

(KnownNat n, 1 <= n) => Solvable (WordN n) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

(SupportedPrim ca, SupportedPrim cb, LinkedRep ca sa, LinkedRep cb sb, SupportedPrim (ca --> cb)) => Solvable (ca --> cb) (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymGeneralFun

Methods

con :: (ca --> cb) -> sa -~> sb Source #

conView :: (sa -~> sb) -> Maybe (ca --> cb) Source #

sym :: Symbol -> sa -~> sb Source #

ssym :: Identifier -> sa -~> sb Source #

isym :: Identifier -> Int -> sa -~> sb Source #

(SupportedPrim ca, SupportedPrim cb, LinkedRep ca sa, LinkedRep cb sb, SupportedPrim (ca =-> cb)) => Solvable (ca =-> cb) (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymTabularFun

Methods

con :: (ca =-> cb) -> sa =~> sb Source #

conView :: (sa =~> sb) -> Maybe (ca =-> cb) Source #

sym :: Symbol -> sa =~> sb Source #

ssym :: Identifier -> sa =~> sb Source #

isym :: Identifier -> Int -> sa =~> sb Source #

pattern Con :: Solvable c t => c -> t Source #

Extract the concrete value from a solvable value with conView.

>>> case con True :: SymBool of Con v -> v
True

data Identifier where Source #

Identifier type used for GenSym

The constructor is hidden intentionally. You can construct an identifier by:

  • a raw identifier

The following two expressions will refer to the same identifier (the solver won't distinguish them and would assign the same value to them). The user may need to use unique names to avoid unintentional identifier collision.

>>> identifier "a"
a
>>> "a" :: Identifier -- available when OverloadedStrings is enabled
a
  • bundle the identifier with some user provided information

Identifiers created with different name or different additional information will not be the same.

>>> withInfo "a" (1 :: Int)
a:1
  • bundle the calling file location with the identifier to ensure global uniqueness

Identifiers created at different locations will not be the same. The identifiers created at the same location will be the same.

>>> $$(withLoc "a") -- a sample result could be "a:<interactive>:18:4-18"
a:<interactive>:...

Constructors

Identifier :: Text -> Identifier 
IdentifierWithInfo :: (Typeable a, Ord a, Lift a, NFData a, Show a, Hashable a) => Identifier -> a -> Identifier 

data Symbol where Source #

Symbol types for a symbolic variable.

The symbols can be indexed with an integer.

Instances

Instances details
IsString Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Methods

fromString :: String -> Symbol #

Generic Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Associated Types

type Rep Symbol :: Type -> Type #

Methods

from :: Symbol -> Rep Symbol x #

to :: Rep Symbol x -> Symbol #

Show Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

NFData Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Methods

rnf :: Symbol -> () #

Eq Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Methods

(==) :: Symbol -> Symbol -> Bool #

(/=) :: Symbol -> Symbol -> Bool #

Ord Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Hashable Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Methods

hashWithSalt :: Int -> Symbol -> Int #

hash :: Symbol -> Int #

Lift Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

Methods

lift :: Quote m => Symbol -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Symbol -> Code m Symbol #

type Rep Symbol Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Symbol

type Rep Symbol = D1 ('MetaData "Symbol" "Grisette.Internal.Core.Data.Symbol" "grisette-0.5.0.0-2ZDAuzWdzg48yPrBcRstUR" 'False) (C1 ('MetaCons "SimpleSymbol" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Identifier)) :+: C1 ('MetaCons "IndexedSymbol" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Identifier) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

identifier :: Text -> Identifier Source #

Simple identifier. The same identifier refers to the same symbolic variable in the whole program.

The user may need to use unique identifiers to avoid unintentional identifier collision.

withInfo :: (Typeable a, Ord a, Lift a, NFData a, Show a, Hashable a) => Identifier -> a -> Identifier Source #

Identifier with extra information.

The same identifier with the same information refers to the same symbolic variable in the whole program.

The user may need to use unique identifiers or additional information to avoid unintentional identifier collision.

withLoc :: Identifier -> SpliceQ Identifier Source #

Identifier with the current location as extra information.

>>> $$(withLoc "a") -- a sample result could be "a:<interactive>:18:4-18"
a:<interactive>:...

The uniqueness is ensured for the call to identifier at different location.

slocsym :: Solvable c s => Identifier -> SpliceQ s Source #

Generate simply-named symbolic variables. The file location will be attached to the identifier.

>>> $$(slocsym "a") :: SymBool
a:<interactive>:...

Calling slocsym with the same name at different location will always generate different symbolic constants. Calling slocsym at the same location for multiple times will generate the same symbolic constants.

>>> ($$(slocsym "a") :: SymBool) == $$(slocsym "a")
False
>>> let f _ = $$(slocsym "a") :: SymBool
>>> f () == f ()
True

ilocsym :: Solvable c s => Identifier -> Int -> SpliceQ s Source #

Generate indexed symbolic variables. The file location will be attached to identifier.

>>> $$(ilocsym "a" 1) :: SymBool
a:<interactive>:...@1

Calling ilocsym with the same name and index at different location will always generate different symbolic constants. Calling slocsym at the same location for multiple times will generate the same symbolic constants.

simple :: Identifier -> Symbol Source #

Create a simple symbol.

indexed :: Identifier -> Int -> Symbol Source #

Create an indexed symbol.

Symbolic operators

class LogicalOp b where Source #

Symbolic logical operators for symbolic booleans.

>>> let t = con True :: SymBool
>>> let f = con False :: SymBool
>>> let a = "a" :: SymBool
>>> let b = "b" :: SymBool
>>> t .|| f
true
>>> a .|| t
true
>>> a .|| f
a
>>> a .|| b
(|| a b)
>>> t .&& f
false
>>> a .&& t
a
>>> a .&& f
false
>>> a .&& b
(&& a b)
>>> symNot t
false
>>> symNot f
true
>>> symNot a
(! a)
>>> t `symXor` f
true
>>> t `symXor` t
false
>>> a `symXor` t
(! a)
>>> a `symXor` f
a
>>> a `symXor` b
(|| (&& (! a) b) (&& a (! b)))

Minimal complete definition

(.||), symNot | (.&&), symNot

Methods

(.||) :: b -> b -> b infixr 2 Source #

Symbolic disjunction

(.&&) :: b -> b -> b infixr 3 Source #

Symbolic conjunction

symNot :: b -> b Source #

Symbolic negation

symXor :: b -> b -> b Source #

Symbolic exclusive disjunction

symImplies :: b -> b -> b Source #

Symbolic implication

class ITEOp v where Source #

ITE operator for solvable (see Grisette.Core)s, including symbolic boolean, integer, etc.

>>> let a = "a" :: SymBool
>>> let b = "b" :: SymBool
>>> let c = "c" :: SymBool
>>> symIte a b c
(ite a b c)

Methods

symIte :: SymBool -> v -> v -> v Source #

Instances

Instances details
ITEOp SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ITEOp

ITEOp SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ITEOp

(ITEOp a, Mergeable a) => ITEOp (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

symIte :: SymBool -> UnionM a -> UnionM a -> UnionM a Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => ITEOp (bv n)) => ITEOp (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

symIte :: SymBool -> SomeBV bv -> SomeBV bv -> SomeBV bv Source #

(KnownNat n, 1 <= n) => ITEOp (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ITEOp

Methods

symIte :: SymBool -> SymIntN n -> SymIntN n -> SymIntN n Source #

(KnownNat n, 1 <= n) => ITEOp (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ITEOp

Methods

symIte :: SymBool -> SymWordN n -> SymWordN n -> SymWordN n Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => ITEOp (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ITEOp

Methods

symIte :: SymBool -> (sa -~> sb) -> (sa -~> sb) -> sa -~> sb Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => ITEOp (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ITEOp

Methods

symIte :: SymBool -> (sa =~> sb) -> (sa =~> sb) -> sa =~> sb Source #

class SEq a where Source #

Symbolic equality. Note that we can't use Haskell's Eq class since symbolic comparison won't necessarily return a concrete Bool value.

>>> let a = 1 :: SymInteger
>>> let b = 2 :: SymInteger
>>> a .== b
false
>>> a ./= b
true
>>> let a = "a" :: SymInteger
>>> let b = "b" :: SymInteger
>>> a ./= b
(! (= a b))
>>> a ./= b
(! (= a b))

Note: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ... deriving Generic deriving SEq via (Default X)

Minimal complete definition

(.==) | (./=)

Methods

(.==) :: a -> a -> SymBool infix 4 Source #

(./=) :: a -> a -> SymBool infix 4 Source #

Instances

Instances details
SEq Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: () -> () -> SymBool Source #

(./=) :: () -> () -> SymBool Source #

SEq Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: Int -> Int -> SymBool Source #

(./=) :: Int -> Int -> SymBool Source #

SEq Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq a => SEq (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

(Generic a, SEq' (Rep a)) => SEq (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

(Mergeable a, SEq a) => SEq (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(.==) :: UnionM a -> UnionM a -> SymBool Source #

(./=) :: UnionM a -> UnionM a -> SymBool Source #

(KnownNat n, 1 <= n) => SEq (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: IntN n -> IntN n -> SymBool Source #

(./=) :: IntN n -> IntN n -> SymBool Source #

(KnownNat n, 1 <= n) => SEq (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: WordN n -> WordN n -> SymBool Source #

(./=) :: WordN n -> WordN n -> SymBool Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => SEq (bv n)) => SEq (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

(.==) :: SomeBV bv -> SomeBV bv -> SymBool Source #

(./=) :: SomeBV bv -> SomeBV bv -> SymBool Source #

(KnownNat n, 1 <= n) => SEq (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

(KnownNat n, 1 <= n) => SEq (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SEq a => SEq (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: Maybe a -> Maybe a -> SymBool Source #

(./=) :: Maybe a -> Maybe a -> SymBool Source #

SEq a => SEq [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: [a] -> [a] -> SymBool Source #

(./=) :: [a] -> [a] -> SymBool Source #

(SEq e, SEq a) => SEq (Either e a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: Either e a -> Either e a -> SymBool Source #

(./=) :: Either e a -> Either e a -> SymBool Source #

(SEq e, SEq a) => SEq (CBMCEither e a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

SEq (m (Maybe a)) => SEq (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: MaybeT m a -> MaybeT m a -> SymBool Source #

(./=) :: MaybeT m a -> MaybeT m a -> SymBool Source #

(SEq a, SEq b) => SEq (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b) -> (a, b) -> SymBool Source #

(./=) :: (a, b) -> (a, b) -> SymBool Source #

SEq (m (CBMCEither e a)) => SEq (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

(.==) :: CBMCExceptT e m a -> CBMCExceptT e m a -> SymBool Source #

(./=) :: CBMCExceptT e m a -> CBMCExceptT e m a -> SymBool Source #

SEq (m (Either e a)) => SEq (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: ExceptT e m a -> ExceptT e m a -> SymBool Source #

(./=) :: ExceptT e m a -> ExceptT e m a -> SymBool Source #

SEq (m a) => SEq (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: IdentityT m a -> IdentityT m a -> SymBool Source #

(./=) :: IdentityT m a -> IdentityT m a -> SymBool Source #

SEq (m (a, s)) => SEq (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(./=) :: WriterT s m a -> WriterT s m a -> SymBool Source #

SEq (m (a, s)) => SEq (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(./=) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(SEq a, SEq b, SEq c) => SEq (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b, c) -> (a, b, c) -> SymBool Source #

(./=) :: (a, b, c) -> (a, b, c) -> SymBool Source #

(SEq (f a), SEq (g a)) => SEq (Sum f g a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: Sum f g a -> Sum f g a -> SymBool Source #

(./=) :: Sum f g a -> Sum f g a -> SymBool Source #

(SEq a, SEq b, SEq c, SEq d) => SEq (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b, c, d) -> (a, b, c, d) -> SymBool Source #

(./=) :: (a, b, c, d) -> (a, b, c, d) -> SymBool Source #

(SEq a, SEq b, SEq c, SEq d, SEq e) => SEq (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b, c, d, e) -> (a, b, c, d, e) -> SymBool Source #

(./=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> SymBool Source #

(SEq a, SEq b, SEq c, SEq d, SEq e, SEq f) => SEq (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SymBool Source #

(./=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SymBool Source #

(SEq a, SEq b, SEq c, SEq d, SEq e, SEq f, SEq g) => SEq (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SymBool Source #

(./=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SymBool Source #

(SEq a, SEq b, SEq c, SEq d, SEq e, SEq f, SEq g, SEq h) => SEq (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

Methods

(.==) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> SymBool Source #

(./=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> SymBool Source #

class SEq a => SOrd a where Source #

Symbolic total order. Note that we can't use Haskell's Ord class since symbolic comparison won't necessarily return a concrete Bool or Ordering value.

>>> let a = 1 :: SymInteger
>>> let b = 2 :: SymInteger
>>> a .< b
true
>>> a .> b
false
>>> let a = "a" :: SymInteger
>>> let b = "b" :: SymInteger
>>> a .< b
(< a b)
>>> a .<= b
(<= a b)
>>> a .> b
(< b a)
>>> a .>= b
(<= b a)

For symCompare, Ordering is not a solvable type, and the result would be wrapped in a union-like monad. See UnionMBase and PlainUnion for more information.

>>> a `symCompare` b :: UnionM Ordering -- UnionM is UnionMBase specialized with SymBool
{If (< a b) LT (If (= a b) EQ GT)}

Note: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ... deriving Generic deriving SOrd via (Default X)

Minimal complete definition

(.<=)

Methods

(.<) :: a -> a -> SymBool infix 4 Source #

(.<=) :: a -> a -> SymBool infix 4 Source #

(.>) :: a -> a -> SymBool infix 4 Source #

(.>=) :: a -> a -> SymBool infix 4 Source #

symCompare :: a -> a -> UnionM Ordering Source #

Instances

Instances details
SOrd Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: () -> () -> SymBool Source #

(.<=) :: () -> () -> SymBool Source #

(.>) :: () -> () -> SymBool Source #

(.>=) :: () -> () -> SymBool Source #

symCompare :: () -> () -> UnionM Ordering Source #

SOrd Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd a => SOrd (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

(SEq a, Generic a, SOrd' (Rep a)) => SOrd (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

(SOrd a, Mergeable a) => SOrd (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

(KnownNat n, 1 <= n) => SOrd (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: IntN n -> IntN n -> SymBool Source #

(.<=) :: IntN n -> IntN n -> SymBool Source #

(.>) :: IntN n -> IntN n -> SymBool Source #

(.>=) :: IntN n -> IntN n -> SymBool Source #

symCompare :: IntN n -> IntN n -> UnionM Ordering Source #

(KnownNat n, 1 <= n) => SOrd (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

(forall (n :: Nat). (KnownNat n, 1 <= n) => SOrd (bv n)) => SOrd (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

(KnownNat n, 1 <= n) => SOrd (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

(KnownNat n, 1 <= n) => SOrd (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd a => SOrd (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd a => SOrd [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: [a] -> [a] -> SymBool Source #

(.<=) :: [a] -> [a] -> SymBool Source #

(.>) :: [a] -> [a] -> SymBool Source #

(.>=) :: [a] -> [a] -> SymBool Source #

symCompare :: [a] -> [a] -> UnionM Ordering Source #

(SOrd a, SOrd b) => SOrd (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: Either a b -> Either a b -> SymBool Source #

(.<=) :: Either a b -> Either a b -> SymBool Source #

(.>) :: Either a b -> Either a b -> SymBool Source #

(.>=) :: Either a b -> Either a b -> SymBool Source #

symCompare :: Either a b -> Either a b -> UnionM Ordering Source #

(SOrd a, SOrd b) => SOrd (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

SOrd (m (Maybe a)) => SOrd (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: MaybeT m a -> MaybeT m a -> SymBool Source #

(.<=) :: MaybeT m a -> MaybeT m a -> SymBool Source #

(.>) :: MaybeT m a -> MaybeT m a -> SymBool Source #

(.>=) :: MaybeT m a -> MaybeT m a -> SymBool Source #

symCompare :: MaybeT m a -> MaybeT m a -> UnionM Ordering Source #

(SOrd a, SOrd b) => SOrd (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b) -> (a, b) -> SymBool Source #

(.<=) :: (a, b) -> (a, b) -> SymBool Source #

(.>) :: (a, b) -> (a, b) -> SymBool Source #

(.>=) :: (a, b) -> (a, b) -> SymBool Source #

symCompare :: (a, b) -> (a, b) -> UnionM Ordering Source #

SOrd (m (CBMCEither e a)) => SOrd (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

SOrd (m (Either e a)) => SOrd (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: ExceptT e m a -> ExceptT e m a -> SymBool Source #

(.<=) :: ExceptT e m a -> ExceptT e m a -> SymBool Source #

(.>) :: ExceptT e m a -> ExceptT e m a -> SymBool Source #

(.>=) :: ExceptT e m a -> ExceptT e m a -> SymBool Source #

symCompare :: ExceptT e m a -> ExceptT e m a -> UnionM Ordering Source #

SOrd (m a) => SOrd (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SOrd (m (a, s)) => SOrd (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(.<=) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(.>) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(.>=) :: WriterT s m a -> WriterT s m a -> SymBool Source #

symCompare :: WriterT s m a -> WriterT s m a -> UnionM Ordering Source #

SOrd (m (a, s)) => SOrd (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(.<=) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(.>) :: WriterT s m a -> WriterT s m a -> SymBool Source #

(.>=) :: WriterT s m a -> WriterT s m a -> SymBool Source #

symCompare :: WriterT s m a -> WriterT s m a -> UnionM Ordering Source #

(SOrd a, SOrd b, SOrd c) => SOrd (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b, c) -> (a, b, c) -> SymBool Source #

(.<=) :: (a, b, c) -> (a, b, c) -> SymBool Source #

(.>) :: (a, b, c) -> (a, b, c) -> SymBool Source #

(.>=) :: (a, b, c) -> (a, b, c) -> SymBool Source #

symCompare :: (a, b, c) -> (a, b, c) -> UnionM Ordering Source #

(SOrd (f a), SOrd (g a)) => SOrd (Sum f g a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: Sum f g a -> Sum f g a -> SymBool Source #

(.<=) :: Sum f g a -> Sum f g a -> SymBool Source #

(.>) :: Sum f g a -> Sum f g a -> SymBool Source #

(.>=) :: Sum f g a -> Sum f g a -> SymBool Source #

symCompare :: Sum f g a -> Sum f g a -> UnionM Ordering Source #

(SOrd a, SOrd b, SOrd c, SOrd d) => SOrd (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b, c, d) -> (a, b, c, d) -> SymBool Source #

(.<=) :: (a, b, c, d) -> (a, b, c, d) -> SymBool Source #

(.>) :: (a, b, c, d) -> (a, b, c, d) -> SymBool Source #

(.>=) :: (a, b, c, d) -> (a, b, c, d) -> SymBool Source #

symCompare :: (a, b, c, d) -> (a, b, c, d) -> UnionM Ordering Source #

(SOrd a, SOrd b, SOrd c, SOrd d, SOrd e) => SOrd (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b, c, d, e) -> (a, b, c, d, e) -> SymBool Source #

(.<=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> SymBool Source #

(.>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> SymBool Source #

(.>=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> SymBool Source #

symCompare :: (a, b, c, d, e) -> (a, b, c, d, e) -> UnionM Ordering Source #

(SOrd a, SOrd b, SOrd c, SOrd d, SOrd e, SOrd f) => SOrd (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SymBool Source #

(.<=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SymBool Source #

(.>) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SymBool Source #

(.>=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> SymBool Source #

symCompare :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> UnionM Ordering Source #

(SOrd a, SOrd b, SOrd c, SOrd d, SOrd e, SOrd f, SOrd g) => SOrd (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SymBool Source #

(.<=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SymBool Source #

(.>) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SymBool Source #

(.>=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> SymBool Source #

symCompare :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> UnionM Ordering Source #

(SOrd a, SOrd b, SOrd c, SOrd d, SOrd e, SOrd f, SOrd g, SOrd h) => SOrd (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Methods

(.<) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> SymBool Source #

(.<=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> SymBool Source #

(.>) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> SymBool Source #

(.>=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> SymBool Source #

symCompare :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> UnionM Ordering Source #

symMax :: (SOrd a, ITEOp a) => a -> a -> a Source #

symMin :: (SOrd a, ITEOp a) => a -> a -> a Source #

mrgMax :: (SOrd a, Mergeable a, UnionMergeable1 m, Applicative m) => a -> a -> m a Source #

mrgMin :: (SOrd a, Mergeable a, UnionMergeable1 m, Applicative m) => a -> a -> m a Source #

class BV bv where Source #

Bit vector operations. Including concatenation (bvConcat), extension (bvZext, bvSext, bvExt), and selection (bvSelect).

Methods

bvConcat :: bv -> bv -> bv Source #

Concatenation of two bit vectors.

>>> bvConcat (SomeSymWordN (0b101 :: SymWordN 3)) (SomeSymWordN (0b010 :: SymWordN 3))
0b101010

bvZext Source #

Arguments

:: Int

Desired output length

-> bv

Bit vector to extend

-> bv 

Zero extension of a bit vector.

>>> bvZext 6 (SomeSymWordN (0b101 :: SymWordN 3))
0b000101

bvSext Source #

Arguments

:: Int

Desired output length

-> bv

Bit vector to extend

-> bv 

Sign extension of a bit vector.

>>> bvSext 6 (SomeSymWordN (0b101 :: SymWordN 3))
0b111101

bvExt Source #

Arguments

:: Int

Desired output length

-> bv

Bit vector to extend

-> bv 

Extension of a bit vector. Signedness is determined by the input bit vector type.

>>> bvExt 6 (SomeSymIntN (0b101 :: SymIntN 3))
0b111101
>>> bvExt 6 (SomeSymIntN (0b001 :: SymIntN 3))
0b000001
>>> bvExt 6 (SomeSymWordN (0b101 :: SymWordN 3))
0b000101
>>> bvExt 6 (SomeSymWordN (0b001 :: SymWordN 3))
0b000001

bvSelect Source #

Arguments

:: Int

Index of the least significant bit of the slice

-> Int

Desired output width, ix + w <= n must hold where n is the size of the input bit vector

-> bv

Bit vector to select from

-> bv 

Slicing out a smaller bit vector from a larger one, selecting a slice with width w starting from index ix.

The least significant bit is indexed as 0.

>>> bvSelect 1 3 (SomeSymIntN (0b001010 :: SymIntN 6))
0b101

bv Source #

Arguments

:: Integral a 
=> Int

Bit width

-> a

Integral value

-> bv 

Create a bit vector from an integer. The bit-width is the first argument, which should not be zero.

>>> bv 12 21 :: SomeSymIntN
0x015

Instances

Instances details
SizedBV bv => BV (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

bvConcat :: SomeBV bv -> SomeBV bv -> SomeBV bv Source #

bvZext :: Int -> SomeBV bv -> SomeBV bv Source #

bvSext :: Int -> SomeBV bv -> SomeBV bv Source #

bvExt :: Int -> SomeBV bv -> SomeBV bv Source #

bvSelect :: Int -> Int -> SomeBV bv -> SomeBV bv Source #

bv :: Integral a => Int -> a -> SomeBV bv Source #

bvExtract Source #

Arguments

:: BV bv 
=> Int

The start position to extract from, i < n must hold where n is the size of the output bit vector

-> Int

The end position to extract from, j <= i must hold

-> bv

Bit vector to extract from

-> bv 

Slicing out a smaller bit vector from a larger one, extract a slice from bit i down to j.

The least significant bit is indexed as 0.

>>> bvExtract 4 2 (SomeSymIntN (0b010100 :: SymIntN 6))
0b101

class SizedBV bv where Source #

Sized bit vector operations. Including concatenation (sizedBVConcat), extension (sizedBVZext, sizedBVSext, sizedBVExt), and selection (sizedBVSelect).

Methods

sizedBVConcat :: (KnownNat l, KnownNat r, 1 <= l, 1 <= r) => bv l -> bv r -> bv (l + r) Source #

Concatenation of two bit vectors.

>>> sizedBVConcat (0b101 :: SymIntN 3) (0b010 :: SymIntN 3)
0b101010

sizedBVZext Source #

Arguments

:: (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) 
=> proxy r

Desired output width

-> bv l

Bit vector to extend

-> bv r 

Zero extension of a bit vector.

>>> sizedBVZext (Proxy @6) (0b101 :: SymIntN 3)
0b000101

sizedBVSext Source #

Arguments

:: (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) 
=> proxy r

Desired output width

-> bv l

Bit vector to extend

-> bv r 

Signed extension of a bit vector.

>>> sizedBVSext (Proxy @6) (0b101 :: SymIntN 3)
0b111101

sizedBVExt Source #

Arguments

:: (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) 
=> proxy r

Desired output width

-> bv l

Bit vector to extend

-> bv r 

Extension of a bit vector. Signedness is determined by the input bit vector type.

>>> sizedBVExt (Proxy @6) (0b101 :: SymIntN 3)
0b111101
>>> sizedBVExt (Proxy @6) (0b001 :: SymIntN 3)
0b000001
>>> sizedBVExt (Proxy @6) (0b101 :: SymWordN 3)
0b000101
>>> sizedBVExt (Proxy @6) (0b001 :: SymWordN 3)
0b000001

sizedBVSelect Source #

Arguments

:: (KnownNat n, KnownNat ix, KnownNat w, 1 <= n, 1 <= w, (ix + w) <= n) 
=> p ix

Index of the least significant bit of the slice

-> q w

Desired output width, ix + w <= n must hold where n is the size of the input bit vector

-> bv n

Bit vector to select from

-> bv w 

Slicing out a smaller bit vector from a larger one, selecting a slice with width w starting from index ix.

The least significant bit is indexed as 0.

>>> sizedBVSelect (Proxy @2) (Proxy @3) (con 0b010100 :: SymIntN 6)
0b101

sizedBVFromIntegral :: (Integral a, KnownNat n, 1 <= n) => a -> bv n Source #

default sizedBVFromIntegral :: (Num (bv n), Integral a, KnownNat n, 1 <= n) => a -> bv n Source #

Instances

Instances details
SizedBV IntN Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

sizedBVConcat :: forall (l :: Nat) (r :: Nat). (KnownNat l, KnownNat r, 1 <= l, 1 <= r) => IntN l -> IntN r -> IntN (l + r) Source #

sizedBVZext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> IntN l -> IntN r Source #

sizedBVSext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> IntN l -> IntN r Source #

sizedBVExt :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> IntN l -> IntN r Source #

sizedBVSelect :: forall (n :: Nat) (ix :: Nat) (w :: Nat) p q. (KnownNat n, KnownNat ix, KnownNat w, 1 <= n, 1 <= w, (ix + w) <= n) => p ix -> q w -> IntN n -> IntN w Source #

sizedBVFromIntegral :: forall a (n :: Nat). (Integral a, KnownNat n, 1 <= n) => a -> IntN n Source #

SizedBV WordN Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

sizedBVConcat :: forall (l :: Nat) (r :: Nat). (KnownNat l, KnownNat r, 1 <= l, 1 <= r) => WordN l -> WordN r -> WordN (l + r) Source #

sizedBVZext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> WordN l -> WordN r Source #

sizedBVSext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> WordN l -> WordN r Source #

sizedBVExt :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> WordN l -> WordN r Source #

sizedBVSelect :: forall (n :: Nat) (ix :: Nat) (w :: Nat) p q. (KnownNat n, KnownNat ix, KnownNat w, 1 <= n, 1 <= w, (ix + w) <= n) => p ix -> q w -> WordN n -> WordN w Source #

sizedBVFromIntegral :: forall a (n :: Nat). (Integral a, KnownNat n, 1 <= n) => a -> WordN n Source #

SizedBV SymIntN Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

Methods

sizedBVConcat :: forall (l :: Nat) (r :: Nat). (KnownNat l, KnownNat r, 1 <= l, 1 <= r) => SymIntN l -> SymIntN r -> SymIntN (l + r) Source #

sizedBVZext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> SymIntN l -> SymIntN r Source #

sizedBVSext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> SymIntN l -> SymIntN r Source #

sizedBVExt :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> SymIntN l -> SymIntN r Source #

sizedBVSelect :: forall (n :: Nat) (ix :: Nat) (w :: Nat) p q. (KnownNat n, KnownNat ix, KnownNat w, 1 <= n, 1 <= w, (ix + w) <= n) => p ix -> q w -> SymIntN n -> SymIntN w Source #

sizedBVFromIntegral :: forall a (n :: Nat). (Integral a, KnownNat n, 1 <= n) => a -> SymIntN n Source #

SizedBV SymWordN Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

Methods

sizedBVConcat :: forall (l :: Nat) (r :: Nat). (KnownNat l, KnownNat r, 1 <= l, 1 <= r) => SymWordN l -> SymWordN r -> SymWordN (l + r) Source #

sizedBVZext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> SymWordN l -> SymWordN r Source #

sizedBVSext :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> SymWordN l -> SymWordN r Source #

sizedBVExt :: forall (l :: Nat) (r :: Nat) proxy. (KnownNat l, KnownNat r, 1 <= l, KnownNat r, l <= r) => proxy r -> SymWordN l -> SymWordN r Source #

sizedBVSelect :: forall (n :: Nat) (ix :: Nat) (w :: Nat) p q. (KnownNat n, KnownNat ix, KnownNat w, 1 <= n, 1 <= w, (ix + w) <= n) => p ix -> q w -> SymWordN n -> SymWordN w Source #

sizedBVFromIntegral :: forall a (n :: Nat). (Integral a, KnownNat n, 1 <= n) => a -> SymWordN n Source #

sizedBVExtract Source #

Arguments

:: forall p i q j n bv. (SizedBV bv, KnownNat n, KnownNat i, KnownNat j, 1 <= n, (i + 1) <= n, j <= i) 
=> p i

The start position to extract from, i < n must hold where n is the size of the output bit vector

-> q j

The end position to extract from, j <= i must hold

-> bv n

Bit vector to extract from

-> bv ((i - j) + 1) 

Slicing out a smaller bit vector from a larger one, extract a slice from bit i down to j.

The least significant bit is indexed as 0.

>>> sizedBVExtract (Proxy @4) (Proxy @2) (con 0b010100 :: SymIntN 6)
0b101

class SignConversion ubv sbv | ubv -> sbv, sbv -> ubv where Source #

Convert values between signed and unsigned.

Methods

toSigned :: ubv -> sbv Source #

Convert unsigned value to the corresponding signed value.

toUnsigned :: sbv -> ubv Source #

Convert signed value to the corresponding unsigned value.

Instances

Instances details
SignConversion Word16 Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SignConversion

SignConversion Word32 Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SignConversion

SignConversion Word64 Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SignConversion

SignConversion Word8 Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SignConversion

SignConversion Word Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SignConversion

(KnownNat n, 1 <= n) => SignConversion (WordN n) (IntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

toSigned :: WordN n -> IntN n Source #

toUnsigned :: IntN n -> WordN n Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => SignConversion (ubv n) (sbv n), SignConversion (ubv 1) (sbv 1)) => SignConversion (SomeBV ubv) (SomeBV sbv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

toSigned :: SomeBV ubv -> SomeBV sbv Source #

toUnsigned :: SomeBV sbv -> SomeBV ubv Source #

(KnownNat n, 1 <= n) => SignConversion (SymWordN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

class (MonadError e m, TryMerge m, Mergeable a) => SafeDivision e a m where Source #

Safe division with monadic error handling in multi-path execution. These procedures throw an exception when the divisor is zero. The result should be able to handle errors with MonadError.

Minimal complete definition

(safeDiv, safeMod | safeDivMod), (safeQuot, safeRem | safeQuotRem)

Methods

safeDiv :: a -> a -> m a Source #

Safe signed div with monadic error handling in multi-path execution.

>>> safeDiv (ssym "a") (ssym "b") :: ExceptT ArithException UnionM SymInteger
ExceptT {If (= b 0) (Left divide by zero) (Right (div a b))}

safeMod :: a -> a -> m a Source #

Safe signed mod with monadic error handling in multi-path execution.

>>> safeMod (ssym "a") (ssym "b") :: ExceptT ArithException UnionM SymInteger
ExceptT {If (= b 0) (Left divide by zero) (Right (mod a b))}

safeDivMod :: a -> a -> m (a, a) Source #

Safe signed divMod with monadic error handling in multi-path execution.

>>> safeDivMod (ssym "a") (ssym "b") :: ExceptT ArithException UnionM (SymInteger, SymInteger)
ExceptT {If (= b 0) (Left divide by zero) (Right ((div a b),(mod a b)))}

safeQuot :: a -> a -> m a Source #

Safe signed quot with monadic error handling in multi-path execution.

safeRem :: a -> a -> m a Source #

Safe signed rem with monadic error handling in multi-path execution.

safeQuotRem :: a -> a -> m (a, a) Source #

Safe signed quotRem with monadic error handling in multi-path execution.

Instances

Instances details
(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Int16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Int32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Int64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Int8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Word16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Word32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Word64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Word8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadUnion m, MonadError ArithException m) => SafeDivision ArithException SymInteger m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Integer m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Int m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

Methods

safeDiv :: Int -> Int -> m Int Source #

safeMod :: Int -> Int -> m Int Source #

safeDivMod :: Int -> Int -> m (Int, Int) Source #

safeQuot :: Int -> Int -> m Int Source #

safeRem :: Int -> Int -> m Int Source #

safeQuotRem :: Int -> Int -> m (Int, Int) Source #

(MonadError ArithException m, TryMerge m) => SafeDivision ArithException Word m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeDivision ArithException (IntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

Methods

safeDiv :: IntN n -> IntN n -> m (IntN n) Source #

safeMod :: IntN n -> IntN n -> m (IntN n) Source #

safeDivMod :: IntN n -> IntN n -> m (IntN n, IntN n) Source #

safeQuot :: IntN n -> IntN n -> m (IntN n) Source #

safeRem :: IntN n -> IntN n -> m (IntN n) Source #

safeQuotRem :: IntN n -> IntN n -> m (IntN n, IntN n) Source #

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeDivision ArithException (WordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

Methods

safeDiv :: WordN n -> WordN n -> m (WordN n) Source #

safeMod :: WordN n -> WordN n -> m (WordN n) Source #

safeDivMod :: WordN n -> WordN n -> m (WordN n, WordN n) Source #

safeQuot :: WordN n -> WordN n -> m (WordN n) Source #

safeRem :: WordN n -> WordN n -> m (WordN n) Source #

safeQuotRem :: WordN n -> WordN n -> m (WordN n, WordN n) Source #

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeDivision ArithException (SymIntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

Methods

safeDiv :: SymIntN n -> SymIntN n -> m (SymIntN n) Source #

safeMod :: SymIntN n -> SymIntN n -> m (SymIntN n) Source #

safeDivMod :: SymIntN n -> SymIntN n -> m (SymIntN n, SymIntN n) Source #

safeQuot :: SymIntN n -> SymIntN n -> m (SymIntN n) Source #

safeRem :: SymIntN n -> SymIntN n -> m (SymIntN n) Source #

safeQuotRem :: SymIntN n -> SymIntN n -> m (SymIntN n, SymIntN n) Source #

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeDivision ArithException (SymWordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeDivision

(forall (n :: Nat). (KnownNat n, 1 <= n) => SafeDivision e (bv n) (ExceptT e m), MonadError (Either BitwidthMismatch e) m, TryMerge m, Mergeable e) => SafeDivision (Either BitwidthMismatch e) (SomeBV bv) m Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

safeDiv :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeMod :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeDivMod :: SomeBV bv -> SomeBV bv -> m (SomeBV bv, SomeBV bv) Source #

safeQuot :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeRem :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeQuotRem :: SomeBV bv -> SomeBV bv -> m (SomeBV bv, SomeBV bv) Source #

class (MonadError e m, TryMerge m, Mergeable a) => SafeLinearArith e a m where Source #

Safe division with monadic error handling in multi-path execution. These procedures throw an exception when overflow or underflow happens. The result should be able to handle errors with MonadError.

Methods

safeAdd :: a -> a -> m a Source #

Safe + with monadic error handling in multi-path execution. Overflows or underflows are treated as errors.

>>> safeAdd (ssym "a") (ssym "b") :: ExceptT ArithException UnionM SymInteger
ExceptT {Right (+ a b)}
>>> safeAdd (ssym "a") (ssym "b") :: ExceptT ArithException UnionM (SymIntN 4)
ExceptT {If (ite (< 0x0 a) (&& (< 0x0 b) (< (+ a b) 0x0)) (&& (< a 0x0) (&& (< b 0x0) (<= 0x0 (+ a b))))) (If (< 0x0 a) (Left arithmetic overflow) (Left arithmetic underflow)) (Right (+ a b))}

safeNeg :: a -> m a Source #

Safe negate with monadic error handling in multi-path execution. Overflows or underflows are treated as errors.

>>> safeNeg (ssym "a") :: ExceptT ArithException UnionM SymInteger
ExceptT {Right (- a)}
>>> safeNeg (ssym "a") :: ExceptT ArithException UnionM (SymIntN 4)
ExceptT {If (= a 0x8) (Left arithmetic overflow) (Right (- a))}

safeSub :: a -> a -> m a Source #

Safe - with monadic error handling in multi-path execution. Overflows or underflows are treated as errors.

>>> safeSub (ssym "a") (ssym "b") :: ExceptT ArithException UnionM SymInteger
ExceptT {Right (+ a (- b))}
>>> safeSub (ssym "a") (ssym "b") :: ExceptT ArithException UnionM (SymIntN 4)
ExceptT {If (ite (<= 0x0 a) (&& (< b 0x0) (< (+ a (- b)) 0x0)) (&& (< a 0x0) (&& (< 0x0 b) (< 0x0 (+ a (- b)))))) (If (<= 0x0 a) (Left arithmetic overflow) (Left arithmetic underflow)) (Right (+ a (- b)))}

Instances

Instances details
(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Int16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Int32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Int64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Int8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: Int8 -> Int8 -> m Int8 Source #

safeNeg :: Int8 -> m Int8 Source #

safeSub :: Int8 -> Int8 -> m Int8 Source #

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Word16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Word32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Word64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Word8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException SymInteger m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Integer m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Int m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: Int -> Int -> m Int Source #

safeNeg :: Int -> m Int Source #

safeSub :: Int -> Int -> m Int Source #

(MonadError ArithException m, TryMerge m) => SafeLinearArith ArithException Word m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: Word -> Word -> m Word Source #

safeNeg :: Word -> m Word Source #

safeSub :: Word -> Word -> m Word Source #

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeLinearArith ArithException (IntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: IntN n -> IntN n -> m (IntN n) Source #

safeNeg :: IntN n -> m (IntN n) Source #

safeSub :: IntN n -> IntN n -> m (IntN n) Source #

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeLinearArith ArithException (WordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: WordN n -> WordN n -> m (WordN n) Source #

safeNeg :: WordN n -> m (WordN n) Source #

safeSub :: WordN n -> WordN n -> m (WordN n) Source #

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeLinearArith ArithException (SymIntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: SymIntN n -> SymIntN n -> m (SymIntN n) Source #

safeNeg :: SymIntN n -> m (SymIntN n) Source #

safeSub :: SymIntN n -> SymIntN n -> m (SymIntN n) Source #

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeLinearArith ArithException (SymWordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeLinearArith

Methods

safeAdd :: SymWordN n -> SymWordN n -> m (SymWordN n) Source #

safeNeg :: SymWordN n -> m (SymWordN n) Source #

safeSub :: SymWordN n -> SymWordN n -> m (SymWordN n) Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => SafeLinearArith e (bv n) (ExceptT e m), MonadError (Either BitwidthMismatch e) m, TryMerge m, Mergeable e) => SafeLinearArith (Either BitwidthMismatch e) (SomeBV bv) m Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

safeAdd :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeNeg :: SomeBV bv -> m (SomeBV bv) Source #

safeSub :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

class Function f arg ret | f -> arg ret where Source #

Abstraction for function-like types.

Methods

(#) :: f -> arg -> ret infixl 9 Source #

Function application operator.

The operator is not right associated (like ($)). It is left associated, and you can provide many arguments with this operator once at a time.

>>> (+1) # 2
3
>>> (+) # 2 # 3
5

Instances

Instances details
(Function f arg ret, Mergeable f, Mergeable ret) => Function (UnionM f) arg (UnionM ret) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(#) :: UnionM f -> arg -> UnionM ret Source #

(LinkedRep a sa, LinkedRep b sb) => Function (a --> b) sa sb Source # 
Instance details

Defined in Grisette.Internal.SymPrim.GeneralFun

Methods

(#) :: (a --> b) -> sa -> sb Source #

(SupportedNonFuncPrim ca, SupportedPrim cb, LinkedRep ca sa, LinkedRep cb sb, SupportedPrim (ca --> cb)) => Function (sa -~> sb) sa sb Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymGeneralFun

Methods

(#) :: (sa -~> sb) -> sa -> sb Source #

(SupportedPrim ca, SupportedPrim cb, LinkedRep ca sa, LinkedRep cb sb, SupportedPrim (ca =-> cb)) => Function (sa =~> sb) sa sb Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymTabularFun

Methods

(#) :: (sa =~> sb) -> sa -> sb Source #

Eq a => Function (a =-> b) a b Source # 
Instance details

Defined in Grisette.Internal.SymPrim.TabularFun

Methods

(#) :: (a =-> b) -> a -> b Source #

Function (a -> b) a b Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Function

Methods

(#) :: (a -> b) -> a -> b Source #

class Apply uf where Source #

Applying an uninterpreted function.

>>> let f = "f" :: SymInteger =~> SymInteger =~> SymInteger
>>> apply f "a" "b"
(apply (apply f a) b)

Note that for implementation reasons, you can also use apply function on a non-function symbolic value. In this case, the function is treated as an id function.

Associated Types

type FunType uf Source #

Methods

apply :: uf -> FunType uf Source #

Instances

Instances details
Apply SymBool Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBool

Associated Types

type FunType SymBool Source #

Apply SymInteger Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymInteger

Associated Types

type FunType SymInteger Source #

(KnownNat n, 1 <= n) => Apply (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

Associated Types

type FunType (SymIntN n) Source #

Methods

apply :: SymIntN n -> FunType (SymIntN n) Source #

(KnownNat n, 1 <= n) => Apply (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

Associated Types

type FunType (SymWordN n) Source #

Methods

apply :: SymWordN n -> FunType (SymWordN n) Source #

(LinkedRep ca sa, LinkedRep ct st, Apply st, SupportedNonFuncPrim ca, SupportedPrim ct, SupportedPrim (ca --> ct)) => Apply (sa -~> st) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymGeneralFun

Associated Types

type FunType (sa -~> st) Source #

Methods

apply :: (sa -~> st) -> FunType (sa -~> st) Source #

(LinkedRep ca sa, LinkedRep ct st, Apply st, SupportedPrim ca, SupportedPrim ct, SupportedPrim (ca =-> ct)) => Apply (sa =~> st) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymTabularFun

Associated Types

type FunType (sa =~> st) Source #

Methods

apply :: (sa =~> st) -> FunType (sa =~> st) Source #

Apply b => Apply (a -> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Function

Associated Types

type FunType (a -> b) Source #

Methods

apply :: (a -> b) -> FunType (a -> b) Source #

class Bits a => SymShift a where Source #

A class for shifting operations.

The symShift function shifts the value to the left if the shift amount is positive, and to the right if the shift amount is negative. If shifting beyond the bit width of the value, the result is the same as shifting with the bit width.

The symShiftNegated function shifts the value to the right if the shift amount is positive, and to the left if the shift amount is negative. This function is introduced to handle the asymmetry of the range of values.

Methods

symShift :: a -> a -> a Source #

symShiftNegated :: a -> a -> a Source #

Instances

Instances details
SymShift Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

SymShift Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

(Integral a, FiniteBits a) => SymShift (DefaultFiniteBitsSymShift a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymShift

(KnownNat n, 1 <= n) => SymShift (IntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

symShift :: IntN n -> IntN n -> IntN n Source #

symShiftNegated :: IntN n -> IntN n -> IntN n Source #

(KnownNat n, 1 <= n) => SymShift (WordN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

symShift :: WordN n -> WordN n -> WordN n Source #

symShiftNegated :: WordN n -> WordN n -> WordN n Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => SymShift (bv n)) => SymShift (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

symShift :: SomeBV bv -> SomeBV bv -> SomeBV bv Source #

symShiftNegated :: SomeBV bv -> SomeBV bv -> SomeBV bv Source #

(KnownNat n, 1 <= n) => SymShift (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

(KnownNat n, 1 <= n) => SymShift (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

class (MonadError e m, TryMerge m, Mergeable a) => SafeSymShift e a m where Source #

Safe version for shiftL or shiftR.

The safeSymShiftL and safeSymShiftR are defined for all non-negative shift amounts.

  • Shifting by negative shift amounts is an error.
  • The result is defined to be 0 when shifting left by more than or equal to the bit size of the number.
  • The result is defined to be 0 when shifting right by more than or equal to the bit size of the number and the number is unsigned or signed non-negative.
  • The result is defined to be -1 when shifting right by more than or equal to the bit size of the number and the number is signed negative.

The safeSymStrictShiftL and safeSymStrictShiftR are defined for all non-negative shift amounts that is less than the bit size. Shifting by more than or equal to the bit size is an error, otherwise they are the same as the non-strict versions.

Methods

safeSymShiftL :: a -> a -> m a Source #

safeSymShiftR :: a -> a -> m a Source #

safeSymStrictShiftL :: a -> a -> m a Source #

safeSymStrictShiftR :: a -> a -> m a Source #

Instances

Instances details
(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Int16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Int32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Int64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Int8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Word16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Word32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Word64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Word8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Int m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m) => SafeSymShift ArithException Word m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeSymShift ArithException (IntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

Methods

safeSymShiftL :: IntN n -> IntN n -> m (IntN n) Source #

safeSymShiftR :: IntN n -> IntN n -> m (IntN n) Source #

safeSymStrictShiftL :: IntN n -> IntN n -> m (IntN n) Source #

safeSymStrictShiftR :: IntN n -> IntN n -> m (IntN n) Source #

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeSymShift ArithException (WordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

Methods

safeSymShiftL :: WordN n -> WordN n -> m (WordN n) Source #

safeSymShiftR :: WordN n -> WordN n -> m (WordN n) Source #

safeSymStrictShiftL :: WordN n -> WordN n -> m (WordN n) Source #

safeSymStrictShiftR :: WordN n -> WordN n -> m (WordN n) Source #

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeSymShift ArithException (SymIntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeSymShift ArithException (SymWordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymShift

(forall (n :: Nat). (KnownNat n, 1 <= n) => SafeSymShift e (bv n) (ExceptT e m), MonadError (Either BitwidthMismatch e) m, TryMerge m, Mergeable e) => SafeSymShift (Either BitwidthMismatch e) (SomeBV bv) m Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

safeSymShiftL :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeSymShiftR :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeSymStrictShiftL :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeSymStrictShiftR :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

class Bits a => SymRotate a where Source #

The symRotate is similar to rotate, but accepts the type itself instead of Int for the rotate amount. The function works on all inputs, including the rotate amounts that are beyond the bit width of the value.

The symRotateNegated function rotates to the opposite direction of symRotate. This function is introduced to handle the asymmetry of the range of values.

Methods

symRotate :: a -> a -> a Source #

symRotateNegated :: a -> a -> a Source #

Instances

Instances details
SymRotate Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

SymRotate Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

(Integral a, FiniteBits a) => SymRotate (DefaultFiniteBitsSymRotate a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SymRotate

(KnownNat n, 1 <= n) => SymRotate (IntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

symRotate :: IntN n -> IntN n -> IntN n Source #

symRotateNegated :: IntN n -> IntN n -> IntN n Source #

(KnownNat n, 1 <= n) => SymRotate (WordN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.BV

Methods

symRotate :: WordN n -> WordN n -> WordN n Source #

symRotateNegated :: WordN n -> WordN n -> WordN n Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => SymRotate (bv n)) => SymRotate (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

symRotate :: SomeBV bv -> SomeBV bv -> SomeBV bv Source #

symRotateNegated :: SomeBV bv -> SomeBV bv -> SomeBV bv Source #

(KnownNat n, 1 <= n) => SymRotate (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

(KnownNat n, 1 <= n) => SymRotate (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SymBV

class (MonadError e m, TryMerge m, Mergeable a) => SafeSymRotate e a m where Source #

Safe rotation operations. The operators will reject negative shift amounts.

Methods

safeSymRotateL :: a -> a -> m a Source #

safeSymRotateR :: a -> a -> m a Source #

Instances

Instances details
(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Int16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Int32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Int64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Int8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Word16 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Word32 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Word64 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Word8 m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Int m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m) => SafeSymRotate ArithException Word m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeSymRotate ArithException (IntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

Methods

safeSymRotateL :: IntN n -> IntN n -> m (IntN n) Source #

safeSymRotateR :: IntN n -> IntN n -> m (IntN n) Source #

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeSymRotate ArithException (WordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

Methods

safeSymRotateL :: WordN n -> WordN n -> m (WordN n) Source #

safeSymRotateR :: WordN n -> WordN n -> m (WordN n) Source #

(MonadError ArithException m, MonadUnion m, KnownNat n, 1 <= n) => SafeSymRotate ArithException (SymIntN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(MonadError ArithException m, TryMerge m, KnownNat n, 1 <= n) => SafeSymRotate ArithException (SymWordN n) m Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SafeSymRotate

(forall (n :: Nat). (KnownNat n, 1 <= n) => SafeSymRotate e (bv n) (ExceptT e m), MonadError (Either BitwidthMismatch e) m, TryMerge m, Mergeable e) => SafeSymRotate (Either BitwidthMismatch e) (SomeBV bv) m Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

safeSymRotateL :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

safeSymRotateR :: SomeBV bv -> SomeBV bv -> m (SomeBV bv) Source #

Unsolvable types

There are types that cannot be directly represented as SMT formulas and therefore not supported by the SMT solvers. These types are referred to as unsolvable types. To symbolically evaluate such types, we represent them with symbolic unions. A symbolic union is a set of multiple values from different execution paths, each guarded with a corresponding path condition. The value of a union can be determined by an SMT solver based on the truth value of the path conditions.

In Grisette, the symbolic union type is UnionM. Two constructs are useful in constructing symbolic union values: mrgIf and mrgSingle. mrgSingle unconditionally wraps a value in a symbolic union container, while mrgIf models branching control flow semantics with symbolic conditions. Here are some examples of using mrgSingle and mrgIf:

>>> mrgSingle ["a"] :: UnionM [SymInteger]
{[a]}
>>> mrgIf "a" (mrgSingle ["b"]) (mrgSingle ["c", "d"]) :: UnionM [SymInteger]
{If a [b] [c,d]}

UnionM is a monad, and its bind operation is similar to tree substitution. This means you can then use monadic constructs to model sequential programs. For example, the following pseudo code can be modeled in Grisette with the combinators provided by Grisette, and the do-notation:

x = if a then [b] else [b,c] -- pseudo code, not Grisette code
y = if d then [e] else [e,f]
return (x ++ y :: [SymInteger])
>>> :{
  ret :: UnionM [SymInteger]
  ret = do x <- mrgIf "a" (return ["b"]) (return ["b","c"])
           y <- mrgIf "d" (return ["e"]) (return ["e","f"])
           mrgReturn $ x ++ y -- we will explain mrgReturn later
:}

When this code is evaluated, the result would be as follows:

>>> ret
{If (&& a d) [b,e] (If (|| a d) [b,(ite a e c),(ite a f e)] [b,c,e,f])}

In the result, we can see that the results are reorganized and the two lists with the same length are merged together. This is important for scaling symbolic evaluation to real-world problems.

The mrgReturn function is crucial for ensuring that the results are merged. It resolves the Mergeable constraint, and retrieves a merging strategy for the contained type from the constraint. The merging strategy is then cached in the UnionMBase container to help merge the result of the entire do-block. This is necessary due to the constrained-monad problem, as the return function from the Monad type class cannot resolve extra constraints. Our solution to this problem with merging strategy caching is inspired by the knowledge propagation technique introduced in the blog post by Oleg Kiselyov.

In addition to mrgReturn, Grisette provides many combinators with the mrg prefix. You should use these combinators and always have the result cache the merging strategy. Consider the following code:

>>> return 1 :: UnionM Integer
<1>
>>> mrgReturn 1 :: UnionM Integer
{1}
>>> mrgIf "a" (return 1) (return 2) :: UnionM Integer
{If a 1 2}

In the first example, using return instead of mrgReturn results in a UAny container (printed as <...>), which means that no merging strategy is cached. In the second and third example, using mrgReturn or mrgIf results in a UMrg container (printed as {...}), which means that the merging strategy is cached.

When working with UnionM, it is important to always use the mrg prefixed combinators to ensure that the merging strategy is properly cached. This will enable Grisette to properly merge the results of the entire do-block and scale symbolic evaluation to real-world problems. Those functions that merges the results can also further propagate the cached merging strategy, note that the result is merged:

>>> f x y = mrgIf "f" (return x) (return y)
>>> do; a <- mrgIf "a" (return 1) (return 2); f a (a + 1) :: UnionM Integer
{If (&& a f) 1 (If (|| a f) 2 3)}

For more details of this, see the documentation for UnionMBase and MergingStrategy.

To make a type compatible with the symbolic evaluation and merging in Grisette, you need to implement the Mergeable type class. If you are only working with algebraic data types, you can derive the Mergeable instance automatically For example:

>>> :set -XDerivingStrategies
>>> :set -XDerivingVia
>>> :set -XDeriveGeneric
>>> import GHC.Generics
>>> :{
  data X = X SymInteger Integer
    deriving (Generic, Show)
    deriving (Mergeable) via (Default X)
:}

This allows you to use the UnionM type to represent values of type X, and have them merged with the mrgIf combinator:

>>> mrgIf "c1" (mrgSingle $ X "b" 1) (mrgIf "c2" (mrgSingle $ X "c" 2) (mrgSingle $ X "d" 1)) :: UnionM X
{If (|| c1 (! c2)) (X (ite c1 b d) 1) (X c 2)}

It is also possible to apply monad transformers onto UnionM to extend it with various mechanisms. For example, by applying ExceptT, you can symbolically evaluate a program with error handling. To do this, you will need to define an error type and derive the Mergeable instance for it. Then, you can use the combinators provided by MonadError (and the mrg* variants of them) for error handling, and the mrgIf combinator will also work with transformed UnionM containers.

Here's an example using the ExceptT transformer to model error handling in Grisette:

>>> import Control.Monad.Except
>>> :{
  data Error = Fail
    deriving (Show, Generic)
    deriving (Mergeable) via (Default Error)
:}
>>> mrgIf "a" (throwError Fail) (return "x") :: ExceptT Error UnionM SymInteger
ExceptT {If a (Left Fail) (Right x)}

This will return a symbolic union value representing a program that throws an error in the then branch and returns a value in the else branch.

The following is the details of the merging algorithm. If you are not going to manually configure the system by writing a MergingStrategy and will only use the derived strategies, you can safely ignore the following contents in this section.

In Grisette, the symbolic union has the Ordered Guards (ORG) representation, which can be viewed as a nested if-then-else with some representation invariant.

For example, the following symbolic union represents a symbolic list of symbolic integers with length 1, 2 or 3. The values are kept sorted in the container: the list with length 1 is placed at the first place, the list with length 2 is placed at the second place, and so on.

\[ \left\{\begin{aligned} &\texttt{[a]}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{[b,b]}&&\mathrm{else~if}&&\texttt{c2}\\& \texttt{[a,b,c]}&&\mathrm{otherwise} \end{aligned}\right. \]

In Haskell syntax, the container is represented as the following nested if-then-else tree

If c1 [a] (If c2 [b,b] [a,b,c])

The representations means that when c1 is true, then the value is a list [a], or when c1 is false and c2 is true, the value is a list [b,b], or otherwise the value is [a,b,c].

This representation allows you to use the constructs that are not supported by the underlying solvers freely. For example, when applying head on this structure, we can just distribute the head function through the three branches, and get

\[ \left\{\begin{aligned} &\texttt{head [a]}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{head [b,b]}&&\mathrm{else~if}&&\texttt{c2}\\ &\texttt{head [a,b,c]}&&\mathrm{otherwise} \end{aligned}\right. \]

or, equivalently

\[ \left\{\begin{aligned} &\texttt{a}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{b}&&\mathrm{else~if}&&\texttt{c2}\\ &\texttt{a}&&\mathrm{otherwise} \end{aligned}\right. \]

Further symbolic evaluation will also distribute computations over the branches in this result, and the identical branches will cause redundant computation. To mitigate this, Grisette would try to merge the branches, and the previous result would become

\[ \left\{\begin{aligned} &\texttt{a}&&\mathrm{if}&&\texttt{c1}\vee\neg\texttt{c2}\\ &\texttt{b}&&\mathrm{otherwise}\\ \end{aligned}\right. \]

Note that if the contained type is symbolic Boolean, we may further merge the values into a single formula.

\[ \left\{\begin{aligned}&\texttt{(ite c1 a (ite c2 b a))}&&\mathrm{unconditional}\end{aligned}\right. \]

In Grisette, such merging happens in the mrgIf or unionIf functions, which model the symbolic conditional branching semantics. To keep the merging efficient and generate small constraints, we enforce that the symbolic union maintains the values in a sorted way, and merge the unions with a mergesort-style merging algorithm. In the following example, the two ORG containers passed to the mrgIf are sorted with the natural ordering on the integers. In the result, the values are also organized in a sorted way, and the path conditions are correctly maintained.

\[ \texttt{mrgIf}\left[ \texttt{c}, \left\{\begin{aligned} &\texttt{1}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{3}&&\mathrm{else~if}&&\texttt{c2}\\ &\texttt{4}&&\mathrm{otherwise} \end{aligned}\right., \left\{\begin{aligned} &\texttt{1}&&\mathrm{if}&&\texttt{c3}\\ &\texttt{2}&&\mathrm{else~if}&&\texttt{c4}\\ &\texttt{4}&&\mathrm{otherwise} \end{aligned}\right. \right] =\left\{\begin{aligned} &\texttt{1}&&\mathrm{if}&&\texttt{(ite c c1 c3)}\\ &\texttt{2}&&\mathrm{else~if}&&\texttt{(&& (! c) c3)}\\ &\texttt{3}&&\mathrm{else~if}&&\texttt{(&& c c2)}\\ &\texttt{4}&&\mathrm{otherwise} \end{aligned}\right. \]

So far, we have described ORG as a flat list of values. When the list is long, it is beneficial to partition the values and merge (some or all) partitions into nested ORG values. This hierarchical ORG representation is particularly useful for complex data types, such as tuples, which tend to yield long lists.

In the following example, v* are values, while t* are ORG containers. The values in the containers are first partitioned into three groups: {v11, v12, v13}, {v2}, and {v13}. In each group, the values share some common features, (e.g., they are constructed with the same data constructor). The values in each group are organized in a subtree, e.g., the first group is organized in the subtree t1. The hierarchical representation also keeps a representation invariant: at each level in the hierarchy, the values (or the subtrees) are also sorted by some criteria. Here, in the first level, the values are sorted by the constructor declaration order, and in the second level, the values are sorted by the concrete field in the constructor A. This criteria is given by the MergingStrategy in the Mergeable class, called the root merging strategy of the type.

data X = A Integer SymInteger | B | C

\[ \left\{\begin{aligned} &\texttt{t1}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{B}&&\mathrm{else if}&&\texttt{c2}\\ &\texttt{C}&&\mathrm{otherwise}&& \end{aligned}\right. \hspace{2em}\mathrm{where}\hspace{2em} \texttt{t1} = \left\{\begin{aligned} &\texttt{A 1 a}&&\mathrm{if}&&\texttt{c11}\\ &\texttt{A 3 b}&&\mathrm{else if}&&\texttt{c12}\\ &\texttt{A 4 (&& x y)}&&\mathrm{otherwise}&& \end{aligned}\right. \]

In Haskell syntax, it can be represented as follows:

If      c1    (If c11 (A 1 a) (If c12 (A 3 b) (A 4 (&& x y))))
  (If   c2    B
              C)

All the symbolic unions in Grisette should maintain the hierarchical sorted invariant, and are sorted in the same way, with respect to the same merging strategy (the root merging strategy for the type). We can then merge the containers with a hierarchical merging algorithm: at each level, we align the values and subtrees, and merge the aligned ones. In the following example, mrgIf resolves the root merging strategy s, and calls the function mrgIf', which accepts the merging strategy as an argument. The symbolic union operands to the mrgIf' function must be sorted with the merging strategy passed to the function.

Here we use the name of the subtrees and values to indicate the order of them:

  • t1 should be placed before v3 in the then branch,
  • t1 and v4 can be aligned with t1' and v4', respectively.

The aligned subtrees will be merged recursively with mrgIf', with a sub-strategy given by the merging strategy s for the subtrees. For example, t1 and t1' will be merged with the sub-strategy s'. The aligned values will be merged with a merging function, also given by the merging strategy s. For example, v4 and v4' will be merged with the merging function f'.

The ordering and the sub-strategies are abstracted with SortedStrategy, and the merging functions will be wrapped in SimpleStrategy. The merging algorithm can then be configured by implementing the merging strategies for the types contained in a symbolic union. See the documentation for MergingStrategy for details.

\[ \begin{aligned} & \texttt{mrgIf}\left[ \texttt{c}, \left\{\begin{aligned} &\texttt{t1}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{v3}&&\mathrm{else~if}&&\texttt{c2}\\ &\texttt{v4}&&\mathrm{otherwise} \end{aligned}\right., \left\{\begin{aligned} &\texttt{t1'}&&\mathrm{if}&&\texttt{c3}\\ &\texttt{t2'}&&\mathrm{else~if}&&\texttt{c4}\\ &\texttt{v4'}&&\mathrm{otherwise} \end{aligned}\right. \right]\\ =~ & \texttt{mrgIf'}\left[ \texttt{s}, \texttt{c}, \left\{\begin{aligned} &\texttt{t1}&&\mathrm{if}&&\texttt{c1}\\ &\texttt{v3}&&\mathrm{else~if}&&\texttt{c2}\\ &\texttt{v4}&&\mathrm{otherwise} \end{aligned}\right., \left\{\begin{aligned} &\texttt{t1'}&&\mathrm{if}&&\texttt{c3}\\ &\texttt{t2'}&&\mathrm{else~if}&&\texttt{c4}\\ &\texttt{v4'}&&\mathrm{otherwise} \end{aligned}\right. \right]\\ =~ & \left\{\begin{aligned} &\texttt{mrgIf' s' c t1 t1'}&&\mathrm{if}&&\texttt{(ite c c1 c3)}\\ &\texttt{t2'}&&\mathrm{else~if}&&\texttt{(&& (! c) c4)}\\ &\texttt{v3}&&\mathrm{else~if}&&\texttt{(&& c c2)}\\ &\texttt{f' c v4 v4'}&&\mathrm{otherwise} \end{aligned}\right. \end{aligned} \]

For more details of the algorithm, please refer to Grisette's paper.

UnionM Monad

data UnionM a Source #

UnionM is the Union container (hidden) enhanced with MergingStrategy knowledge propagation.

The Union models the underlying semantics evaluation semantics for unsolvable types with the nested if-then-else tree semantics, and can be viewed as the following structure:

data Union a
  = Single a
  | If bool (Union a) (Union a)

The Single constructor is for a single value with the path condition true, and the If constructor is the if operator in an if-then-else tree. For clarity, when printing a UnionM value, we will omit the Single constructor. The following two representations has the same semantics.

If      c1    (If c11 v11 (If c12 v12 v13))
  (If   c2    v2
              v3)

\[ \left\{\begin{aligned}&t_1&&\mathrm{if}&&c_1\\&v_2&&\mathrm{else if}&&c_2\\&v_3&&\mathrm{otherwise}&&\end{aligned}\right.\hspace{2em}\mathrm{where}\hspace{2em}t_1 = \left\{\begin{aligned}&v_{11}&&\mathrm{if}&&c_{11}\\&v_{12}&&\mathrm{else if}&&c_{12}\\&v_{13}&&\mathrm{otherwise}&&\end{aligned}\right. \]

To reduce the size of the if-then-else tree to reduce the number of paths to execute, Grisette would merge the branches in a Union container and maintain a representation invariant for them. To perform this merging procedure, Grisette relies on a type class called Mergeable and the merging strategy defined by it.

Union is a monad, so we can easily write code with the do-notation and monadic combinators. However, the standard monadic operators cannot resolve any extra constraints, including the Mergeable constraint (see The constrained-monad problem by Sculthorpe et al.). This prevents the standard do-notations to merge the results automatically, and would result in bad performance or very verbose code.

To reduce this boilerplate, Grisette provide another monad, UnionM that would try to cache the merging strategy. The UnionM has two data constructors (hidden intentionally), UAny and UMrg. The UAny data constructor (printed as <...>) wraps an arbitrary (probably unmerged) Union. It is constructed when no Mergeable knowledge is available (for example, when constructed with Haskell's return). The UMrg data constructor (printed as {...}) wraps a merged UnionM along with the Mergeable constraint. This constraint can be propagated to the contexts without Mergeable knowledge, and helps the system to merge the resulting Union.

Examples:

return cannot resolve the Mergeable constraint.

>>> return 1 :: UnionM Integer
<1>

mrgReturn can resolve the Mergeable constraint.

>>> import Grisette.Lib.Base
>>> mrgReturn 1 :: UnionM Integer
{1}

mrgIfPropagatedStrategy does not try to Mergeable constraint.

>>> mrgIfPropagatedStrategy "a" (return 1) (mrgIfPropagatedStrategy "b" (return 1) (return 2)) :: UnionM Integer
<If a 1 (If b 1 2)>

But mrgIfPropagatedStrategy is able to merge the result if some of the branches are merged and have a cached merging strategy:

>>> mrgIfPropagatedStrategy "a" (return 1) (mrgIfPropagatedStrategy "b" (mrgReturn 1) (return 2)) :: UnionM Integer
{If (|| a b) 1 2}

The >>= operator uses mrgIfPropagatedStrategy internally. When the final statement in a do-block merges the values, the system can then merge the final result.

>>> :{
  do
    x <- mrgIfPropagatedStrategy (ssym "a") (return 1) (mrgIfPropagatedStrategy (ssym "b") (return 1) (return 2))
    mrgSingle $ x + 1 :: UnionM Integer
:}
{If (|| a b) 2 3}

Calling a function that merges a result at the last line of a do-notation will also merge the whole block. If you stick to these mrg* combinators and all the functions will merge the results, the whole program can be symbolically evaluated efficiently.

>>> f x y = mrgIf "c" x y
>>> :{
  do
    x <- mrgIfPropagatedStrategy (ssym "a") (return 1) (mrgIfPropagatedStrategy (ssym "b") (return 1) (return 2))
    f x (x + 1) :: UnionM Integer
:}
{If (&& c (|| a b)) 1 (If (|| a (|| b c)) 2 3)}

In Grisette.Lib.Base, Grisette.Lib.Mtl, we also provided more mrg* variants of other combinators. You should stick to these combinators to ensure efficient merging by Grisette.

Instances

Instances details
Eq1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

liftEq :: (a -> b -> Bool) -> UnionM a -> UnionM b -> Bool #

Show1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> UnionM a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [UnionM a] -> ShowS #

Applicative UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

pure :: a -> UnionM a #

(<*>) :: UnionM (a -> b) -> UnionM a -> UnionM b #

liftA2 :: (a -> b -> c) -> UnionM a -> UnionM b -> UnionM c #

(*>) :: UnionM a -> UnionM b -> UnionM b #

(<*) :: UnionM a -> UnionM b -> UnionM a #

Functor UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

fmap :: (a -> b) -> UnionM a -> UnionM b #

(<$) :: a -> UnionM b -> UnionM a #

Monad UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(>>=) :: UnionM a -> (a -> UnionM b) -> UnionM b #

(>>) :: UnionM a -> UnionM b -> UnionM b #

return :: a -> UnionM a #

NFData1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

liftRnf :: (a -> ()) -> UnionM a -> () #

MonadParallelUnion UnionM Source # 
Instance details

Defined in Grisette.Experimental.MonadParallelUnion

Methods

parBindUnion :: (Mergeable b, NFData b) => UnionM a -> (a -> UnionM b) -> UnionM b Source #

Mergeable1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

PlainUnion UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

SimpleMergeable1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> UnionM a -> UnionM a -> UnionM a Source #

UnionMergeable1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

TryMerge UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(GenSym spec a, Mergeable a) => GenSym spec (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => spec -> m (UnionM (UnionM a)) Source #

GenSym spec a => GenSymSimple spec (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => spec -> m (UnionM a) Source #

(Solvable c t, Mergeable t) => Solvable c (UnionM t) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(ToSym a b, Mergeable b) => ToSym a (UnionM b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: a -> UnionM b Source #

Lift a => Lift (UnionM a :: Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

lift :: Quote m => UnionM a -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => UnionM a -> Code m (UnionM a) #

(IsString a, Mergeable a) => IsString (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

fromString :: String -> UnionM a #

(Num a, Mergeable a) => Num (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(+) :: UnionM a -> UnionM a -> UnionM a #

(-) :: UnionM a -> UnionM a -> UnionM a #

(*) :: UnionM a -> UnionM a -> UnionM a #

negate :: UnionM a -> UnionM a #

abs :: UnionM a -> UnionM a #

signum :: UnionM a -> UnionM a #

fromInteger :: Integer -> UnionM a #

Show a => Show (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

showsPrec :: Int -> UnionM a -> ShowS #

show :: UnionM a -> String #

showList :: [UnionM a] -> ShowS #

NFData a => NFData (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

rnf :: UnionM a -> () #

Eq a => Eq (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(==) :: UnionM a -> UnionM a -> Bool #

(/=) :: UnionM a -> UnionM a -> Bool #

(Mergeable a, EvaluateSym a) => EvaluateSym (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

evaluateSym :: Bool -> Model -> UnionM a -> UnionM a Source #

ExtractSymbolics a => ExtractSymbolics (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

GPretty a => GPretty (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

gpretty :: UnionM a -> Doc ann Source #

gprettyPrec :: Int -> UnionM a -> Doc ann Source #

gprettyList :: [UnionM a] -> Doc ann Source #

(ITEOp a, Mergeable a) => ITEOp (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

symIte :: SymBool -> UnionM a -> UnionM a -> UnionM a Source #

(LogicalOp a, Mergeable a) => LogicalOp (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(.||) :: UnionM a -> UnionM a -> UnionM a Source #

(.&&) :: UnionM a -> UnionM a -> UnionM a Source #

symNot :: UnionM a -> UnionM a Source #

symXor :: UnionM a -> UnionM a -> UnionM a Source #

symImplies :: UnionM a -> UnionM a -> UnionM a Source #

Mergeable a => Mergeable (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(Mergeable a, SEq a) => SEq (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(.==) :: UnionM a -> UnionM a -> SymBool Source #

(./=) :: UnionM a -> UnionM a -> SymBool Source #

(SOrd a, Mergeable a) => SOrd (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

Mergeable a => SimpleMergeable (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

mrgIte :: SymBool -> UnionM a -> UnionM a -> UnionM a Source #

(Mergeable a, SubstituteSym a) => SubstituteSym (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> UnionM a -> UnionM a Source #

AllSyms a => AllSyms (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Hashable a => Hashable (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

hashWithSalt :: Int -> UnionM a -> Int #

hash :: UnionM a -> Int #

(GenSym a a, Mergeable a) => GenSym (UnionM a) a Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => UnionM a -> m (UnionM a) Source #

(ToCon a b, Mergeable a) => ToCon (UnionM a) b Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toCon :: UnionM a -> Maybe b Source #

ToSym (UnionM Integer) SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

ToSym (UnionM Bool) SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

UnionWithExcept (UnionM (Either e v)) UnionM e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

UnionWithExcept (UnionM (CBMCEither e v)) UnionM e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Function f arg ret, Mergeable f, Mergeable ret) => Function (UnionM f) arg (UnionM ret) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

(#) :: UnionM f -> arg -> UnionM ret Source #

(ToCon a b, Mergeable a, Mergeable b) => ToCon (UnionM a) (UnionM b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toCon :: UnionM a -> Maybe (UnionM b) Source #

(KnownNat n, 1 <= n) => ToSym (UnionM (IntN n)) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (IntN n) -> SymIntN n Source #

(KnownNat n, 1 <= n) => ToSym (UnionM (WordN n)) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (WordN n) -> SymWordN n Source #

(ToSym a b, Mergeable b) => ToSym (UnionM a) (UnionM b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM a -> UnionM b Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => ToSym (UnionM (ca --> cb)) (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (ca --> cb) -> sa -~> sb Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => ToSym (UnionM (ca =-> cb)) (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (ca =-> cb) -> sa =~> sb Source #

(IsConcrete k, Mergeable t) => Mergeable (HashMap k (UnionM (Maybe t))) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(IsConcrete k, Mergeable t) => SimpleMergeable (HashMap k (UnionM (Maybe t))) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

mrgIte :: SymBool -> HashMap k (UnionM (Maybe t)) -> HashMap k (UnionM (Maybe t)) -> HashMap k (UnionM (Maybe t)) Source #

class (Eq t, Ord t, Hashable t) => IsConcrete t Source #

Tag for concrete types. Useful for specifying the merge strategy for some parametrized types where we should have different merge strategy for symbolic and concrete ones.

Instances

Instances details
IsConcrete Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

IsConcrete Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

unionMUnaryOp :: (Mergeable a, Mergeable b) => (a -> b) -> UnionM a -> UnionM b Source #

unionMBinOp :: (Mergeable a, Mergeable b, Mergeable c) => (a -> b -> c) -> UnionM a -> UnionM b -> UnionM c Source #

liftUnionM :: (Mergeable a, UnionMergeable1 u, Applicative u) => UnionM a -> u a Source #

Lift the UnionM to any Applicative UnionMergeable1.

liftToMonadUnion :: (Mergeable a, MonadUnion u) => UnionM a -> u a Source #

Alias for liftUnionM, but for monads.

unionSize :: UnionM a -> Int Source #

The size of a union is defined as the number of branches. For example,

>>> unionSize (return True)
1
>>> unionSize (mrgIf "a" (return 1) (return 2) :: UnionM Integer)
2
>>> unionSize (choose [1..7] "a" :: UnionM Integer)
7

Merging

Mergeable

class Mergeable a where Source #

Each type is associated with a root merge strategy given by rootStrategy. The root merge strategy should be able to merge every value of the type. Grisette will use the root merge strategy to merge the values of the type in a union.

Note 1: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ... deriving Generic deriving Mergeable via (Default X)

Methods

rootStrategy :: MergingStrategy a Source #

The root merging strategy for the type.

Instances

Instances details
Mergeable ArithException Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Ordering Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable CEGISCondition Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.CEGISSolver

Mergeable FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Mergeable BitwidthMismatch Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable a => Mergeable (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable a => Mergeable (Sum a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Generic a, Mergeable' (Rep a)) => Mergeable (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable a => Mergeable (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Mergeable a => Mergeable (Union a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

(KnownNat n, 1 <= n) => Mergeable (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(KnownNat n, 1 <= n) => Mergeable (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(forall (n :: Nat). (KnownNat n, 1 <= n) => Mergeable (bv n)) => Mergeable (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

(KnownNat n, 1 <= n) => Mergeable (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(KnownNat n, 1 <= n) => Mergeable (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable a => Mergeable (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable a => Mergeable [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable e, Mergeable a) => Mergeable (Either e a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable (U1 x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable (V1 x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable e, Mergeable a) => Mergeable (CBMCEither e a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Mergeable a, Mergeable1 m) => Mergeable (FreshT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => Mergeable (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => Mergeable (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 m, Mergeable a) => Mergeable (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(IsConcrete k, Mergeable t) => Mergeable (HashMap k (UnionM (Maybe t))) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(Mergeable a, Mergeable b) => Mergeable (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable b => Mergeable (a -> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 m, Mergeable e, Mergeable a) => Mergeable (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Mergeable1 m, Mergeable e, Mergeable a) => Mergeable (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 m, Mergeable a) => Mergeable (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable a, Mergeable1 m) => Mergeable (ReaderT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable a, Mergeable1 m) => Mergeable (StateT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable a, Mergeable1 m) => Mergeable (StateT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable a, Mergeable1 m) => Mergeable (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable a, Mergeable1 m) => Mergeable (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable a, Mergeable b, Mergeable c) => Mergeable (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (a, b, c) Source #

(Mergeable1 l, Mergeable1 r, Mergeable x) => Mergeable (Sum l r x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable (a x), Mergeable (b x)) => Mergeable ((a :*: b) x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable (a x), Mergeable (b x)) => Mergeable ((a :+: b) x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable c => Mergeable (K1 i c x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 m, Mergeable r) => Mergeable (ContT r m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable a, Mergeable b, Mergeable c, Mergeable d) => Mergeable (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (a, b, c, d) Source #

Mergeable (a x) => Mergeable (M1 i c a x) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (M1 i c a x) Source #

(Mergeable s, Mergeable w, Mergeable a, Mergeable1 m) => Mergeable (RWST r w s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (RWST r w s m a) Source #

(Mergeable s, Mergeable w, Mergeable a, Mergeable1 m) => Mergeable (RWST r w s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (RWST r w s m a) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e) => Mergeable (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (a, b, c, d, e) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f) => Mergeable (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (a, b, c, d, e, f) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f, Mergeable g) => Mergeable (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (a, b, c, d, e, f, g) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f, Mergeable g, Mergeable h) => Mergeable (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

rootStrategy :: MergingStrategy (a, b, c, d, e, f, g, h) Source #

class Mergeable1 (u :: Type -> Type) where Source #

Lifting of the Mergeable class to unary type constructors.

Methods

liftRootStrategy :: MergingStrategy a -> MergingStrategy (u a) Source #

Lift merge strategy through the type constructor.

Instances

Instances details
Mergeable1 Identity Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable1 Sum Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Mergeable1 Union Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

Mergeable1 Maybe Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable1 List Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable e => Mergeable1 (Either e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Generic1 u, Mergeable1' (Rep1 u)) => Mergeable1 (Default1 u) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable e => Mergeable1 (CBMCEither e) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Mergeable1 m => Mergeable1 (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Mergeable1 m => Mergeable1 (MaybeT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable a => Mergeable1 ((,) a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 m, Mergeable e) => Mergeable1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Mergeable1 m, Mergeable e) => Mergeable1 (ExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable1 m => Mergeable1 (IdentityT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable1 m => Mergeable1 (ReaderT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable1 m) => Mergeable1 (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable1 m) => Mergeable1 (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable1 m) => Mergeable1 (WriterT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable1 m) => Mergeable1 (WriterT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable a, Mergeable b) => Mergeable1 ((,,) a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 l, Mergeable1 r) => Mergeable1 (Sum l r) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable1 m, Mergeable r) => Mergeable1 (ContT r m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable a, Mergeable b, Mergeable c) => Mergeable1 ((,,,) a b c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Mergeable1 ((->) a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable w, Mergeable1 m) => Mergeable1 (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable s, Mergeable w, Mergeable1 m) => Mergeable1 (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Mergeable a, Mergeable b, Mergeable c, Mergeable d) => Mergeable1 ((,,,,) a b c d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

liftRootStrategy :: MergingStrategy a0 -> MergingStrategy (a, b, c, d, a0) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e) => Mergeable1 ((,,,,,) a b c d e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

liftRootStrategy :: MergingStrategy a0 -> MergingStrategy (a, b, c, d, e, a0) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f) => Mergeable1 ((,,,,,,) a b c d e f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

liftRootStrategy :: MergingStrategy a0 -> MergingStrategy (a, b, c, d, e, f, a0) Source #

(Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f, Mergeable g) => Mergeable1 ((,,,,,,,) a b c d e f g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

liftRootStrategy :: MergingStrategy a0 -> MergingStrategy (a, b, c, d, e, f, g, a0) Source #

rootStrategy1 :: (Mergeable a, Mergeable1 u) => MergingStrategy (u a) Source #

Lift the root merge strategy through the unary type constructor.

class Mergeable2 (u :: Type -> Type -> Type) where Source #

Lifting of the Mergeable class to binary type constructors.

Methods

liftRootStrategy2 :: MergingStrategy a -> MergingStrategy b -> MergingStrategy (u a b) Source #

Lift merge strategy through the type constructor.

rootStrategy2 :: (Mergeable a, Mergeable b, Mergeable2 u) => MergingStrategy (u a b) Source #

Lift the root merge strategy through the binary type constructor.

class Mergeable3 (u :: Type -> Type -> Type -> Type) where Source #

Lifting of the Mergeable class to ternary type constructors.

Methods

liftRootStrategy3 :: MergingStrategy a -> MergingStrategy b -> MergingStrategy c -> MergingStrategy (u a b c) Source #

Lift merge strategy through the type constructor.

Instances

Instances details
Mergeable3 (,,) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

rootStrategy3 :: (Mergeable a, Mergeable b, Mergeable c, Mergeable3 u) => MergingStrategy (u a b c) Source #

Lift the root merge strategy through the binary type constructor.

Merging strategy

data MergingStrategy a where Source #

Merging strategies.

You probably do not need to know the details of this type if you are only going to use algebraic data types. You can get merging strategies for them with type derivation.

In Grisette, a merged union (if-then-else tree) follows the hierarchical sorted representation invariant with regards to some merging strategy.

A merging strategy encodes how to merge a subset of the values of a given type. We have three types of merging strategies:

  • Simple strategy
  • Sorted strategy
  • No strategy

The SimpleStrategy merges values with a simple merge function. For example,

  • the symbolic boolean values can be directly merged with symIte.
  • the set {1}, which is a subset of the values of the type Integer, can be simply merged as the set contains only a single value.
  • all the Just values of the type Maybe SymBool can be simply merged by merging the wrapped symbolic boolean with symIte.

The SortedStrategy merges values by first grouping the values with an indexing function, and the values with the same index will be organized as a sub-tree in the if-then-else structure of UnionBase. Each group (sub-tree) will be further merged with a sub-strategy for the index. The index type should be a totally ordered type (with the Ord type class). Grisette will use the indexing function to partition the values into sub-trees, and organize them in a sorted way. The sub-trees will further be merged with the sub-strategies. For example,

  • all the integers can be merged with SortedStrategy by indexing with the identity function and use the SimpleStrategy shown before as the sub-strategies.
  • all the Maybe SymBool values can be merged with SortedStrategy by indexing with isJust, the Nothing and Just values can then then be merged with different simple strategies as sub-strategies.

The NoStrategy does not perform any merging. For example, we cannot merge values with function types that returns concrete lists.

For ADTs, we can automatically derive the Mergeable type class, which provides a merging strategy.

If the derived version does not work for you, you should determine if your type can be directly merged with a merging function. If so, you can implement the merging strategy as a SimpleStrategy. If the type cannot be directly merged with a merging function, but could be partitioned into subsets of values that can be simply merged with a function, you should implement the merging strategy as a SortedStrategy. For easier building of the merging strategies, check out the combinators like wrapStrategy.

For more details, please see the documents of the constructors, or refer to Grisette's paper.

Constructors

SimpleStrategy

Simple mergeable strategy.

For symbolic booleans, we can implement its merge strategy as follows:

SimpleStrategy symIte :: MergingStrategy SymBool

Fields

SortedStrategy

Sorted mergeable strategy.

For Integers, we can implement its merge strategy as follows:

SortedStrategy id (\_ -> SimpleStrategy $ \_ t _ -> t)

For Maybe SymBool, we can implement its merge strategy as follows:

SortedStrategy
  (\case; Nothing -> False; Just _ -> True)
  (\idx ->
     if idx
       then SimpleStrategy $ \_ t _ -> t
       else SimpleStrategy $ \cond (Just l) (Just r) -> Just $ symIte cond l r)

Fields

NoStrategy :: MergingStrategy a

For preventing the merging intentionally. This could be useful for keeping some value concrete and may help generate more efficient formulas.

See Grisette's paper for details.

derivedRootStrategy :: (Generic a, Mergeable' (Rep a)) => MergingStrategy a Source #

Generic derivation for the Mergeable class.

Usually you can derive the merging strategy with the DerivingVia and DerivingStrategies extension.

data X = ... deriving (Generic) deriving Mergeable via (Default X)

Manual merging strategy construction

wrapStrategy Source #

Arguments

:: MergingStrategy a

The merge strategy to be wrapped

-> (a -> b)

The wrap function

-> (b -> a)

The unwrap function, which does not have to be defined for every value

-> MergingStrategy b 

Useful utility function for building merge strategies manually.

For example, to build the merge strategy for the just branch of Maybe a, one could write

wrapStrategy Just fromMaybe rootStrategy :: MergingStrategy (Maybe a)

product2Strategy Source #

Arguments

:: (a -> b -> r)

The wrap function

-> (r -> (a, b))

The unwrap function, which does not have to be defined for every value

-> MergingStrategy a

The first merge strategy to be wrapped

-> MergingStrategy b

The second merge strategy to be wrapped

-> MergingStrategy r 

Useful utility function for building merge strategies for product types manually.

For example, to build the merge strategy for the following product type, one could write

data X = X { x1 :: Int, x2 :: Bool }
product2Strategy X (\(X a b) -> (a, b)) rootStrategy rootStrategy
  :: MergingStrategy X

data StrategyList container where Source #

Helper type for building efficient merge strategy for list-like containers.

Constructors

StrategyList :: forall a container. container [DynamicSortedIdx] -> container (MergingStrategy a) -> StrategyList container 

Instances

Instances details
Show1 container => Show (StrategyList container) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

showsPrec :: Int -> StrategyList container -> ShowS #

show :: StrategyList container -> String #

showList :: [StrategyList container] -> ShowS #

Eq1 container => Eq (StrategyList container) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

(==) :: StrategyList container -> StrategyList container -> Bool #

(/=) :: StrategyList container -> StrategyList container -> Bool #

Ord1 container => Ord (StrategyList container) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Methods

compare :: StrategyList container -> StrategyList container -> Ordering #

(<) :: StrategyList container -> StrategyList container -> Bool #

(<=) :: StrategyList container -> StrategyList container -> Bool #

(>) :: StrategyList container -> StrategyList container -> Bool #

(>=) :: StrategyList container -> StrategyList container -> Bool #

max :: StrategyList container -> StrategyList container -> StrategyList container #

min :: StrategyList container -> StrategyList container -> StrategyList container #

buildStrategyList :: forall a container. Functor container => MergingStrategy a -> container a -> StrategyList container Source #

Helper function for building efficient merge strategy for list-like containers.

resolveStrategy :: forall x. MergingStrategy x -> x -> ([DynamicSortedIdx], MergingStrategy x) Source #

Resolves the indices and the terminal merge strategy for a value of some Mergeable type.

resolveStrategy' :: forall x. x -> MergingStrategy x -> ([DynamicSortedIdx], MergingStrategy x) Source #

Resolves the indices and the terminal merge strategy for a value given a merge strategy for its type.

Simple mergeable types

class Mergeable a => SimpleMergeable a where Source #

This class indicates that a type has a simple root merge strategy.

Note: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ...
  deriving Generic
  deriving (Mergeable, SimpleMergeable) via (Default X)

Methods

mrgIte :: SymBool -> a -> a -> a Source #

Performs if-then-else with the simple root merge strategy.

>>> mrgIte "a" "b" "c" :: SymInteger
(ite a b c)

Instances

Instances details
SimpleMergeable AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

SimpleMergeable CEGISCondition Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.CEGISSolver

SimpleMergeable FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

SimpleMergeable SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

SimpleMergeable SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

SimpleMergeable () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> () -> () -> () Source #

SimpleMergeable a => SimpleMergeable (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> Identity a -> Identity a -> Identity a Source #

(Generic a, Mergeable' (Rep a), SimpleMergeable' (Rep a)) => SimpleMergeable (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> Default a -> Default a -> Default a Source #

Mergeable a => SimpleMergeable (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

mrgIte :: SymBool -> UnionM a -> UnionM a -> UnionM a Source #

Mergeable a => SimpleMergeable (Union a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

Methods

mrgIte :: SymBool -> Union a -> Union a -> Union a Source #

(KnownNat n, 1 <= n) => SimpleMergeable (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> SymIntN n -> SymIntN n -> SymIntN n Source #

(KnownNat n, 1 <= n) => SimpleMergeable (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> SymWordN n -> SymWordN n -> SymWordN n Source #

(UnionMergeable1 m, Mergeable a) => SimpleMergeable (FreshT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

mrgIte :: SymBool -> FreshT m a -> FreshT m a -> FreshT m a Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => SimpleMergeable (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (sa -~> sb) -> (sa -~> sb) -> sa -~> sb Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => SimpleMergeable (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (sa =~> sb) -> (sa =~> sb) -> sa =~> sb Source #

(UnionMergeable1 m, Mergeable a) => SimpleMergeable (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a Source #

(IsConcrete k, Mergeable t) => SimpleMergeable (HashMap k (UnionM (Maybe t))) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

mrgIte :: SymBool -> HashMap k (UnionM (Maybe t)) -> HashMap k (UnionM (Maybe t)) -> HashMap k (UnionM (Maybe t)) Source #

(SimpleMergeable a, SimpleMergeable b) => SimpleMergeable (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a, b) -> (a, b) -> (a, b) Source #

SimpleMergeable b => SimpleMergeable (a -> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a -> b) -> (a -> b) -> a -> b Source #

(UnionMergeable1 m, Mergeable e, Mergeable a) => SimpleMergeable (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

mrgIte :: SymBool -> CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a Source #

(UnionMergeable1 m, Mergeable e, Mergeable a) => SimpleMergeable (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

(UnionMergeable1 m, Mergeable a) => SimpleMergeable (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a Source #

(Mergeable a, UnionMergeable1 m) => SimpleMergeable (ReaderT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a Source #

(Mergeable s, Mergeable a, UnionMergeable1 m) => SimpleMergeable (StateT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

(Mergeable s, Mergeable a, UnionMergeable1 m) => SimpleMergeable (StateT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

(Mergeable s, Mergeable a, UnionMergeable1 m, Monoid s) => SimpleMergeable (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

(Mergeable s, Mergeable a, UnionMergeable1 m, Monoid s) => SimpleMergeable (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c) => SimpleMergeable (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a, b, c) -> (a, b, c) -> (a, b, c) Source #

(UnionMergeable1 m, Mergeable r) => SimpleMergeable (ContT r m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> ContT r m a -> ContT r m a -> ContT r m a Source #

(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c, SimpleMergeable d) => SimpleMergeable (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

(Mergeable s, Mergeable w, Monoid w, Mergeable a, UnionMergeable1 m) => SimpleMergeable (RWST r w s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

(Mergeable s, Mergeable w, Monoid w, Mergeable a, UnionMergeable1 m) => SimpleMergeable (RWST r w s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c, SimpleMergeable d, SimpleMergeable e) => SimpleMergeable (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c, SimpleMergeable d, SimpleMergeable e, SimpleMergeable f) => SimpleMergeable (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c, SimpleMergeable d, SimpleMergeable e, SimpleMergeable f, SimpleMergeable g) => SimpleMergeable (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c, SimpleMergeable d, SimpleMergeable e, SimpleMergeable f, SimpleMergeable g, SimpleMergeable h) => SimpleMergeable (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> (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 #

class Mergeable1 u => SimpleMergeable1 u where Source #

Lifting of the SimpleMergeable class to unary type constructors.

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> u a -> u a -> u a Source #

Lift mrgIte through the type constructor.

>>> liftMrgIte mrgIte "a" (Identity "b") (Identity "c") :: Identity SymInteger
Identity (ite a b c)

Instances

Instances details
SimpleMergeable1 Identity Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> Identity a -> Identity a -> Identity a Source #

SimpleMergeable1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> UnionM a -> UnionM a -> UnionM a Source #

SimpleMergeable1 Union Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> Union a -> Union a -> Union a Source #

UnionMergeable1 m => SimpleMergeable1 (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> FreshT m a -> FreshT m a -> FreshT m a Source #

UnionMergeable1 m => SimpleMergeable1 (MaybeT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a Source #

SimpleMergeable a => SimpleMergeable1 ((,) a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a0 -> a0 -> a0) -> SymBool -> (a, a0) -> (a, a0) -> (a, a0) Source #

(UnionMergeable1 m, Mergeable e) => SimpleMergeable1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a Source #

(UnionMergeable1 m, Mergeable e) => SimpleMergeable1 (ExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

UnionMergeable1 m => SimpleMergeable1 (IdentityT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a Source #

UnionMergeable1 m => SimpleMergeable1 (ReaderT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a Source #

(Mergeable s, UnionMergeable1 m) => SimpleMergeable1 (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

(Mergeable s, UnionMergeable1 m) => SimpleMergeable1 (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

(Mergeable s, UnionMergeable1 m, Monoid s) => SimpleMergeable1 (WriterT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

(Mergeable s, UnionMergeable1 m, Monoid s) => SimpleMergeable1 (WriterT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

(UnionMergeable1 m, Mergeable r) => SimpleMergeable1 (ContT r m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> ContT r m a -> ContT r m a -> ContT r m a Source #

SimpleMergeable1 ((->) a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a0 -> a0 -> a0) -> SymBool -> (a -> a0) -> (a -> a0) -> a -> a0 Source #

(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) => SimpleMergeable1 (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) => SimpleMergeable1 (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

mrgIte1 :: (SimpleMergeable1 u, SimpleMergeable a) => SymBool -> u a -> u a -> u a Source #

Lift the standard mrgIte function through the type constructor.

>>> mrgIte1 "a" (Identity "b") (Identity "c") :: Identity SymInteger
Identity (ite a b c)

class Mergeable2 u => SimpleMergeable2 u where Source #

Lifting of the SimpleMergeable class to binary type constructors.

Methods

liftMrgIte2 :: (SymBool -> a -> a -> a) -> (SymBool -> b -> b -> b) -> SymBool -> u a b -> u a b -> u a b Source #

Lift mrgIte through the type constructor.

>>> liftMrgIte2 mrgIte mrgIte "a" ("b", "c") ("d", "e") :: (SymInteger, SymBool)
((ite a b d),(ite a c e))

Instances

Instances details
SimpleMergeable2 (,) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

liftMrgIte2 :: (SymBool -> a -> a -> a) -> (SymBool -> b -> b -> b) -> SymBool -> (a, b) -> (a, b) -> (a, b) Source #

mrgIte2 :: (SimpleMergeable2 u, SimpleMergeable a, SimpleMergeable b) => SymBool -> u a b -> u a b -> u a b Source #

Lift the standard mrgIte function through the type constructor.

>>> mrgIte2 "a" ("b", "c") ("d", "e") :: (SymInteger, SymBool)
((ite a b d),(ite a c e))

class (SimpleMergeable1 u, TryMerge u) => UnionMergeable1 (u :: Type -> Type) where Source #

Special case of the Mergeable1 and SimpleMergeable1 class for type constructors that are SimpleMergeable when applied to any Mergeable types.

This type class is used to generalize the mrgIf function to other containers, for example, monad transformer transformed Unions.

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> u a -> u a -> u a Source #

Symbolic if control flow with the result merged with some merge strategy.

>>> mrgIfWithStrategy rootStrategy "a" (mrgSingle "b") (return "c") :: UnionM SymInteger
{(ite a b c)}

Note: Be careful to call this directly in your code. The supplied merge strategy should be consistent with the type's root merge strategy, or some internal invariants would be broken and the program can crash.

This function is to be called when the Mergeable constraint can not be resolved, e.g., the merge strategy for the contained type is given with Mergeable1. In other cases, mrgIf is usually a better alternative.

mrgIfPropagatedStrategy :: SymBool -> u a -> u a -> u a Source #

Instances

Instances details
UnionMergeable1 UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

UnionMergeable1 Union Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

UnionMergeable1 m => UnionMergeable1 (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

UnionMergeable1 m => UnionMergeable1 (MaybeT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

(UnionMergeable1 m, Mergeable e) => UnionMergeable1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(UnionMergeable1 m, Mergeable e) => UnionMergeable1 (ExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

mrgIfPropagatedStrategy :: SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

UnionMergeable1 m => UnionMergeable1 (IdentityT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

UnionMergeable1 m => UnionMergeable1 (ReaderT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a Source #

mrgIfPropagatedStrategy :: SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a Source #

(Mergeable s, UnionMergeable1 m) => UnionMergeable1 (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

mrgIfPropagatedStrategy :: SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

(Mergeable s, UnionMergeable1 m) => UnionMergeable1 (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

mrgIfPropagatedStrategy :: SymBool -> StateT s m a -> StateT s m a -> StateT s m a Source #

(Mergeable s, UnionMergeable1 m, Monoid s) => UnionMergeable1 (WriterT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

mrgIfPropagatedStrategy :: SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

(Mergeable s, UnionMergeable1 m, Monoid s) => UnionMergeable1 (WriterT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

mrgIfPropagatedStrategy :: SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a Source #

(UnionMergeable1 m, Mergeable r) => UnionMergeable1 (ContT r m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> ContT r m a -> ContT r m a -> ContT r m a Source #

mrgIfPropagatedStrategy :: SymBool -> ContT r m a -> ContT r m a -> ContT r m a Source #

(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) => UnionMergeable1 (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

mrgIfPropagatedStrategy :: SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) => UnionMergeable1 (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIfWithStrategy :: MergingStrategy a -> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

mrgIfPropagatedStrategy :: SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a Source #

mrgIf :: (UnionMergeable1 u, Mergeable a) => SymBool -> u a -> u a -> u a Source #

Symbolic if control flow with the result merged with the type's root merge strategy.

Equivalent to mrgIfWithStrategy rootStrategy.

>>> mrgIf "a" (return "b") (return "c") :: UnionM SymInteger
{(ite a b c)}

merge :: (UnionMergeable1 m, Mergeable a) => m a -> m a Source #

Try to merge the container with the root strategy.

TryMerge operations

type MonadTryMerge f = (TryMerge f, Monad f) Source #

Alias for a monad type that has TryMerge.

class TryMerge m where Source #

A class for containers that may or may not be merged.

If the container is capable of multi-path execution, then the tryMergeWithStrategy function should merge the paths according to the supplied strategy.

If the container is not capable of multi-path execution, then the tryMergeWithStrategy function should be equivalent to id.

Note that this will not necessarily do a recursive merge for the elements.

Methods

tryMergeWithStrategy :: MergingStrategy a -> m a -> m a Source #

Instances

Instances details
TryMerge Identity Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge Sum Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

TryMerge Union Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

TryMerge Maybe Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge List Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a -> [a] -> [a] Source #

TryMerge (Either a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge m => TryMerge (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

TryMerge m => TryMerge (MaybeT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge ((,) a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, a0) -> (a, a0) Source #

(TryMerge m, Mergeable e) => TryMerge (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Mergeable e, TryMerge m) => TryMerge (ExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge m => TryMerge (IdentityT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge m => TryMerge (ReaderT r m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

(Mergeable s, TryMerge m) => TryMerge (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

(Mergeable s, TryMerge m) => TryMerge (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

(Monoid w, Mergeable w, TryMerge m) => TryMerge (WriterT w m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

(Monoid w, Mergeable w, TryMerge m) => TryMerge (WriterT w m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

TryMerge ((,,) a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, a0) -> (a, b, a0) Source #

(TryMerge f, TryMerge g) => TryMerge (Sum f g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a -> Sum f g a -> Sum f g a Source #

(TryMerge m, Mergeable r) => TryMerge (ContT r m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a -> ContT r m a -> ContT r m a Source #

TryMerge ((,,,) a b c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, c, a0) -> (a, b, c, a0) Source #

(Monoid w, Mergeable w, Mergeable s, TryMerge m) => TryMerge (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a -> RWST r w s m a -> RWST r w s m a Source #

(Monoid w, Mergeable w, Mergeable s, TryMerge m) => TryMerge (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a -> RWST r w s m a -> RWST r w s m a Source #

TryMerge ((,,,,) a b c d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, c, d, a0) -> (a, b, c, d, a0) Source #

TryMerge ((,,,,,) a b c d e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, c, d, e, a0) -> (a, b, c, d, e, a0) Source #

TryMerge ((,,,,,,) a b c d e f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, c, d, e, f, a0) -> (a, b, c, d, e, f, a0) Source #

TryMerge ((,,,,,,,) a b c d e f g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, c, d, e, f, g, a0) -> (a, b, c, d, e, f, g, a0) Source #

TryMerge ((,,,,,,,,) a b c d e f g h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.TryMerge

Methods

tryMergeWithStrategy :: MergingStrategy a0 -> (a, b, c, d, e, f, g, h, a0) -> (a, b, c, d, e, f, g, h, a0) Source #

mrgSingle :: (TryMerge m, Applicative m, Mergeable a) => a -> m a Source #

Wrap a value in the applicative functor and propagate the type's root merge strategy.

Equivalent to mrgSingleWithStrategy rootStrategy.

>>> mrgSingle "a" :: UnionM SymInteger
{a}

mrgSingleWithStrategy :: (TryMerge m, Applicative m) => MergingStrategy a -> a -> m a Source #

Wrap a value in the applicative functor and capture the Mergeable knowledge.

>>> mrgSingleWithStrategy rootStrategy "a" :: UnionM SymInteger
{a}

Note: Be careful to call this directly from your code. The supplied merge strategy should be consistent with the type's root merge strategy, or some internal invariants would be broken and the program can crash.

This function is to be called when the Mergeable constraint can not be resolved, e.g., the merge strategy for the contained type is given with Mergeable1. In other cases, mrgPure is usually a better alternative.

tryMerge :: (TryMerge m, Mergeable a) => m a -> m a Source #

Try to merge the container with the root strategy.

PlainUnion operations

class (Applicative u, UnionMergeable1 u) => PlainUnion (u :: Type -> Type) where Source #

Plain union containers that can be projected back into single value or if-guarded values.

Minimal complete definition

singleView, ifView

Methods

singleView :: u a -> Maybe a Source #

Pattern match to extract single values.

>>> singleView (return 1 :: UnionM Integer)
Just 1
>>> singleView (mrgIfPropagatedStrategy "a" (return 1) (return 2) :: UnionM Integer)
Nothing

ifView :: u a -> Maybe (SymBool, u a, u a) Source #

Pattern match to extract if values.

>>> ifView (return 1 :: UnionM Integer)
Nothing
>>> ifView (mrgIfPropagatedStrategy "a" (return 1) (return 2) :: UnionM Integer)
Just (a,<1>,<2>)
>>> ifView (mrgIf "a" (return 1) (return 2) :: UnionM Integer)
Just (a,{1},{2})

toGuardedList :: u a -> [(SymBool, a)] Source #

Convert the union to a guarded list.

>>> toGuardedList (mrgIf "a" (return 1) (mrgIf "b" (return 2) (return 3)) :: UnionM Integer)
[(a,1),((&& b (! a)),2),((! (|| b a)),3)]

Instances

Instances details
PlainUnion UnionM Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

PlainUnion Union Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

pattern Single :: (PlainUnion u, Mergeable a) => a -> u a Source #

Pattern match to extract single values with singleView.

>>> case (return 1 :: UnionM Integer) of Single v -> v
1

pattern If :: (PlainUnion u, Mergeable a) => SymBool -> u a -> u a -> u a Source #

Pattern match to extract guard values with ifView >>> case (mrgIfPropagatedStrategy "a" (return 1) (return 2) :: UnionM Integer) of If c t f -> (c,t,f) (a,1,2)

simpleMerge :: forall u a. (SimpleMergeable a, PlainUnion u) => u a -> a Source #

Merge the simply mergeable values in a union, and extract the merged value.

In the following example, mrgIfPropagatedStrategy will not merge the results, and simpleMerge will merge it and extract the single merged value.

>>> mrgIfPropagatedStrategy (ssym "a") (return $ ssym "b") (return $ ssym "c") :: UnionM SymBool
<If a b c>
>>> simpleMerge $ (mrgIfPropagatedStrategy (ssym "a") (return $ ssym "b") (return $ ssym "c") :: UnionM SymBool)
(ite a b c)

(.#) :: (Function f a r, SimpleMergeable r, PlainUnion u) => f -> u a -> r infixl 9 Source #

Helper for applying functions on UnionLike and SimpleMergeable.

>>> let f :: Integer -> UnionM Integer = \x -> mrgIf (ssym "a") (mrgSingle $ x + 1) (mrgSingle $ x + 2)
>>> f .# (mrgIf (ssym "b" :: SymBool) (mrgSingle 0) (mrgSingle 2) :: UnionM Integer)
{If (&& b a) 1 (If b 2 (If a 3 4))}

onUnion :: forall u a r. (SimpleMergeable r, UnionMergeable1 u, PlainUnion u, Mergeable a) => (a -> r) -> u a -> r Source #

Lift a function to work on union values.

>>> sumU = onUnion sum
>>> sumU (mrgIfPropagatedStrategy "cond" (return ["a"]) (return ["b","c"]) :: UnionM [SymInteger])
(ite cond a (+ b c))

onUnion2 :: forall u a b r. (SimpleMergeable r, UnionMergeable1 u, PlainUnion u, Mergeable a, Mergeable b) => (a -> b -> r) -> u a -> u b -> r Source #

Lift a function to work on union values.

onUnion3 :: forall u a b c r. (SimpleMergeable r, UnionMergeable1 u, PlainUnion u, Mergeable a, Mergeable b, Mergeable c) => (a -> b -> c -> r) -> u a -> u b -> u c -> r Source #

Lift a function to work on union values.

onUnion4 :: forall u a b c d r. (SimpleMergeable r, UnionMergeable1 u, PlainUnion u, Mergeable a, Mergeable b, Mergeable c, Mergeable d) => (a -> b -> c -> d -> r) -> u a -> u b -> u c -> u d -> r Source #

Lift a function to work on union values.

type MonadUnion u = (UnionMergeable1 u, Monad u) Source #

Class for monads that support union-like operations and Mergeable knowledge propagation.

Conversion between Concrete and Symbolic values

class ToCon a b where Source #

Convert a symbolic value to concrete value if possible.

Methods

toCon :: a -> Maybe b Source #

Convert a symbolic value to concrete value if possible. If the symbolic value cannot be converted to concrete, the result will be Nothing.

>>> toCon (ssym "a" :: SymInteger) :: Maybe Integer
Nothing
>>> toCon (con 1 :: SymInteger) :: Maybe Integer
Just 1

toCon works on complex types too.

>>> toCon ([con 1, con 2] :: [SymInteger]) :: Maybe [Integer]
Just [1,2]
>>> toCon ([con 1, ssym "a"] :: [SymInteger]) :: Maybe [Integer]
Nothing

Instances

Instances details
ToCon Int16 Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Int16 -> Maybe Int16 Source #

ToCon Int32 Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Int32 -> Maybe Int32 Source #

ToCon Int64 Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Int64 -> Maybe Int64 Source #

ToCon Int8 Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Int8 -> Maybe Int8 Source #

ToCon Word16 Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon Word32 Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon Word64 Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon Word8 Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Word8 -> Maybe Word8 Source #

ToCon ByteString ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon AssertionError AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon VerificationConditions VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon SymBool SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon SymBool Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon SymInteger SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon SymInteger Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon Text Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Text -> Maybe Text Source #

ToCon Integer Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToCon () () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: () -> Maybe () Source #

ToCon Bool Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Bool -> Maybe Bool Source #

ToCon Char Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Char -> Maybe Char Source #

ToCon Int Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Int -> Maybe Int Source #

ToCon Word Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Word -> Maybe Word Source #

(Generic a, Generic b, ToCon' (Rep a) (Rep b)) => ToCon a (Default b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: a -> Maybe (Default b) Source #

ToCon v (Identity v) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: v -> Maybe (Identity v) Source #

ToCon (Identity v) v Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Identity v -> Maybe v Source #

(ToCon a b, Mergeable a) => ToCon (UnionM a) b Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toCon :: UnionM a -> Maybe b Source #

ToCon (SymIntN 8) Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN 8 -> Maybe Int8 Source #

ToCon (SymIntN 16) Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN 16 -> Maybe Int16 Source #

ToCon (SymIntN 32) Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN 32 -> Maybe Int32 Source #

ToCon (SymIntN 64) Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN 64 -> Maybe Int64 Source #

ToCon (SymIntN 64) Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN 64 -> Maybe Int Source #

ToCon (SymWordN 8) Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN 8 -> Maybe Word8 Source #

ToCon (SymWordN 16) Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN 16 -> Maybe Word16 Source #

ToCon (SymWordN 32) Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN 32 -> Maybe Word32 Source #

ToCon (SymWordN 64) Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN 64 -> Maybe Word64 Source #

ToCon (SymWordN 64) Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN 64 -> Maybe Word Source #

ToCon a b => ToCon (Identity a) (Identity b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Identity a -> Maybe (Identity b) Source #

(ToCon a b, Mergeable a, Mergeable b) => ToCon (UnionM a) (UnionM b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toCon :: UnionM a -> Maybe (UnionM b) Source #

(KnownNat n, 1 <= n) => ToCon (IntN n) (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: IntN n -> Maybe (IntN n) Source #

(KnownNat n, 1 <= n) => ToCon (WordN n) (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: WordN n -> Maybe (WordN n) Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => ToCon (sbv n) (cbv n)) => ToCon (SomeBV sbv) (SomeBV cbv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

toCon :: SomeBV sbv -> Maybe (SomeBV cbv) Source #

(KnownNat n, 1 <= n) => ToCon (SymIntN n) (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN n -> Maybe (IntN n) Source #

(KnownNat n, 1 <= n) => ToCon (SymIntN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymIntN n -> Maybe (SymIntN n) Source #

(KnownNat n, 1 <= n) => ToCon (SymWordN n) (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN n -> Maybe (WordN n) Source #

(KnownNat n, 1 <= n) => ToCon (SymWordN n) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: SymWordN n -> Maybe (SymWordN n) Source #

ToCon a1 a2 => ToCon (Maybe a1) (Maybe a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Maybe a1 -> Maybe (Maybe a2) Source #

ToCon a b => ToCon [a] [b] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: [a] -> Maybe [b] Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (Either e1 a1) (Either e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Either e1 a1 -> Maybe (Either e2 a2) Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (Either e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: Either e1 a1 -> Maybe (CBMCEither e2 a2) Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (CBMCEither e1 a1) (Either e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCEither e1 a1 -> Maybe (Either e2 a2) Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (CBMCEither e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCEither e1 a1 -> Maybe (CBMCEither e2 a2) Source #

(SupportedPrim a, SupportedPrim b) => ToCon (a -~> b) (a -~> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a -~> b) -> Maybe (a -~> b) Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => ToCon (sa -~> sb) (ca --> cb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (sa -~> sb) -> Maybe (ca --> cb) Source #

(SupportedPrim a, SupportedPrim b) => ToCon (a =~> b) (a =~> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a =~> b) -> Maybe (a =~> b) Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => ToCon (sa =~> sb) (ca =-> cb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (sa =~> sb) -> Maybe (ca =-> cb) Source #

ToCon (m1 (Maybe a)) (m2 (Maybe b)) => ToCon (MaybeT m1 a) (MaybeT m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: MaybeT m1 a -> Maybe (MaybeT m2 b) Source #

(ToCon a1 a2, ToCon b1 b2) => ToCon (a1, b1) (a2, b2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1) -> Maybe (a2, b2) Source #

ToCon (m1 (CBMCEither e1 a)) (Either e2 b) => ToCon (CBMCExceptT e1 m1 a) (Either e2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCExceptT e1 m1 a -> Maybe (Either e2 b) Source #

ToCon (m1 (Either e1 a)) (Either e2 b) => ToCon (ExceptT e1 m1 a) (Either e2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: ExceptT e1 m1 a -> Maybe (Either e2 b) Source #

ToCon (m1 (CBMCEither e1 a)) (m2 (CBMCEither e2 b)) => ToCon (CBMCExceptT e1 m1 a) (CBMCExceptT e2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCExceptT e1 m1 a -> Maybe (CBMCExceptT e2 m2 b) Source #

ToCon (m1 (Either e1 a)) (m2 (Either e2 b)) => ToCon (ExceptT e1 m1 a) (ExceptT e2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: ExceptT e1 m1 a -> Maybe (ExceptT e2 m2 b) Source #

ToCon (m a) (m1 b) => ToCon (IdentityT m a) (IdentityT m1 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: IdentityT m a -> Maybe (IdentityT m1 b) Source #

ToCon (m1 (a, s1)) (m2 (b, s2)) => ToCon (WriterT s1 m1 a) (WriterT s2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: WriterT s1 m1 a -> Maybe (WriterT s2 m2 b) Source #

ToCon (m1 (a, s1)) (m2 (b, s2)) => ToCon (WriterT s1 m1 a) (WriterT s2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: WriterT s1 m1 a -> Maybe (WriterT s2 m2 b) Source #

(ToCon a1 a2, ToCon b1 b2, ToCon c1 c2) => ToCon (a1, b1, c1) (a2, b2, c2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1, c1) -> Maybe (a2, b2, c2) Source #

(ToCon (f a) (f1 a1), ToCon (g a) (g1 a1)) => ToCon (Sum f g a) (Sum f1 g1 a1) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: Sum f g a -> Maybe (Sum f1 g1 a1) Source #

(ToCon a1 a2, ToCon b1 b2, ToCon c1 c2, ToCon d1 d2) => ToCon (a1, b1, c1, d1) (a2, b2, c2, d2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1, c1, d1) -> Maybe (a2, b2, c2, d2) Source #

(ToCon a1 a2, ToCon b1 b2, ToCon c1 c2, ToCon d1 d2, ToCon e1 e2) => ToCon (a1, b1, c1, d1, e1) (a2, b2, c2, d2, e2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1, c1, d1, e1) -> Maybe (a2, b2, c2, d2, e2) Source #

(ToCon a1 a2, ToCon b1 b2, ToCon c1 c2, ToCon d1 d2, ToCon e1 e2, ToCon f1 f2) => ToCon (a1, b1, c1, d1, e1, f1) (a2, b2, c2, d2, e2, f2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1, c1, d1, e1, f1) -> Maybe (a2, b2, c2, d2, e2, f2) Source #

(ToCon a1 a2, ToCon b1 b2, ToCon c1 c2, ToCon d1 d2, ToCon e1 e2, ToCon f1 f2, ToCon g1 g2) => ToCon (a1, b1, c1, d1, e1, f1, g1) (a2, b2, c2, d2, e2, f2, g2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1, c1, d1, e1, f1, g1) -> Maybe (a2, b2, c2, d2, e2, f2, g2) Source #

(ToCon a1 a2, ToCon b1 b2, ToCon c1 c2, ToCon d1 d2, ToCon e1 e2, ToCon f1 f2, ToCon g1 g2, ToCon h1 h2) => ToCon (a1, b1, c1, d1, e1, f1, g1, h1) (a2, b2, c2, d2, e2, f2, g2, h2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: (a1, b1, c1, d1, e1, f1, g1, h1) -> Maybe (a2, b2, c2, d2, e2, f2, g2, h2) Source #

class ToSym a b where Source #

Convert a concrete value to symbolic value.

Methods

toSym :: a -> b Source #

Convert a concrete value to symbolic value.

>>> toSym False :: SymBool
false
>>> toSym [False, True] :: [SymBool]
[false,true]

Instances

Instances details
ToSym Int16 Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int16 -> Int16 Source #

ToSym Int32 Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int32 -> Int32 Source #

ToSym Int64 Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int64 -> Int64 Source #

ToSym Int8 Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int8 -> Int8 Source #

ToSym Word16 Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word16 -> Word16 Source #

ToSym Word32 Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word32 -> Word32 Source #

ToSym Word64 Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word64 -> Word64 Source #

ToSym Word8 Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word8 -> Word8 Source #

ToSym ByteString ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym AssertionError AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym VerificationConditions VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym SymBool SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym SymInteger SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym Text Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Text -> Text Source #

ToSym Integer SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym Integer Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

ToSym () () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: () -> () Source #

ToSym Bool SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Bool -> SymBool Source #

ToSym Bool Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Bool -> Bool Source #

ToSym Char Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Char -> Char Source #

ToSym Int Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int -> Int Source #

ToSym Word Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word -> Word Source #

ToSym Int16 (SymIntN 16) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int16 -> SymIntN 16 Source #

ToSym Int32 (SymIntN 32) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int32 -> SymIntN 32 Source #

ToSym Int64 (SymIntN 64) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int64 -> SymIntN 64 Source #

ToSym Int8 (SymIntN 8) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int8 -> SymIntN 8 Source #

ToSym Word16 (SymWordN 16) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word16 -> SymWordN 16 Source #

ToSym Word32 (SymWordN 32) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word32 -> SymWordN 32 Source #

ToSym Word64 (SymWordN 64) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word64 -> SymWordN 64 Source #

ToSym Word8 (SymWordN 8) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word8 -> SymWordN 8 Source #

ToSym Int (SymIntN 64) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Int -> SymIntN 64 Source #

ToSym Word (SymWordN 64) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Word -> SymWordN 64 Source #

(Generic a, Generic b, ToSym' (Rep a) (Rep b)) => ToSym a (Default b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: a -> Default b Source #

(ToSym a b, Mergeable b) => ToSym a (UnionM b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: a -> UnionM b Source #

ToSym (UnionM Integer) SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

ToSym (UnionM Bool) SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

ToSym a b => ToSym (Identity a) (Identity b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Identity a -> Identity b Source #

(KnownNat n, 1 <= n) => ToSym (UnionM (IntN n)) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (IntN n) -> SymIntN n Source #

(KnownNat n, 1 <= n) => ToSym (UnionM (WordN n)) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (WordN n) -> SymWordN n Source #

(ToSym a b, Mergeable b) => ToSym (UnionM a) (UnionM b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM a -> UnionM b Source #

(KnownNat n, 1 <= n) => ToSym (IntN n) (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: IntN n -> IntN n Source #

(KnownNat n, 1 <= n) => ToSym (IntN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: IntN n -> SymIntN n Source #

(KnownNat n, 1 <= n) => ToSym (WordN n) (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: WordN n -> WordN n Source #

(KnownNat n, 1 <= n) => ToSym (WordN n) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: WordN n -> SymWordN n Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => ToSym (cbv n) (sbv n)) => ToSym (SomeBV cbv) (SomeBV sbv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

toSym :: SomeBV cbv -> SomeBV sbv Source #

(KnownNat n, 1 <= n) => ToSym (SymIntN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: SymIntN n -> SymIntN n Source #

(KnownNat n, 1 <= n) => ToSym (SymWordN n) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: SymWordN n -> SymWordN n Source #

ToSym a b => ToSym (Maybe a) (Maybe b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Maybe a -> Maybe b Source #

ToSym a b => ToSym [a] [b] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: [a] -> [b] Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => ToSym (UnionM (ca --> cb)) (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (ca --> cb) -> sa -~> sb Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => ToSym (UnionM (ca =-> cb)) (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

toSym :: UnionM (ca =-> cb) -> sa =~> sb Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (Either e1 a1) (Either e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Either e1 a1 -> Either e2 a2 Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (Either e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: Either e1 a1 -> CBMCEither e2 a2 Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (CBMCEither e1 a1) (Either e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: CBMCEither e1 a1 -> Either e2 a2 Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (CBMCEither e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: CBMCEither e1 a1 -> CBMCEither e2 a2 Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => ToSym (ca --> cb) (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (ca --> cb) -> sa -~> sb Source #

(SupportedPrim a, SupportedPrim b) => ToSym (a -~> b) (a -~> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a -~> b) -> a -~> b Source #

(SupportedPrim a, SupportedPrim b) => ToSym (a =~> b) (a =~> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a =~> b) -> a =~> b Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => ToSym (ca =-> cb) (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (ca =-> cb) -> sa =~> sb Source #

ToSym (m1 (Maybe a)) (m2 (Maybe b)) => ToSym (MaybeT m1 a) (MaybeT m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: MaybeT m1 a -> MaybeT m2 b Source #

(ToSym a1 b1, ToSym a2 b2) => ToSym (a1, a2) (b1, b2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, a2) -> (b1, b2) Source #

ToSym a b => ToSym (v -> a) (v -> b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (v -> a) -> v -> b Source #

ToSym (m1 (CBMCEither e1 a)) (m2 (CBMCEither e2 b)) => ToSym (CBMCExceptT e1 m1 a) (CBMCExceptT e2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: CBMCExceptT e1 m1 a -> CBMCExceptT e2 m2 b Source #

ToSym (m1 (Either e1 a)) (m2 (Either e2 b)) => ToSym (ExceptT e1 m1 a) (ExceptT e2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: ExceptT e1 m1 a -> ExceptT e2 m2 b Source #

ToSym (m a) (m1 b) => ToSym (IdentityT m a) (IdentityT m1 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: IdentityT m a -> IdentityT m1 b Source #

ToSym (s1 -> m1 a1) (s2 -> m2 a2) => ToSym (ReaderT s1 m1 a1) (ReaderT s2 m2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: ReaderT s1 m1 a1 -> ReaderT s2 m2 a2 Source #

ToSym (s1 -> m1 (a1, s1)) (s2 -> m2 (a2, s2)) => ToSym (StateT s1 m1 a1) (StateT s2 m2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: StateT s1 m1 a1 -> StateT s2 m2 a2 Source #

ToSym (s1 -> m1 (a1, s1)) (s2 -> m2 (a2, s2)) => ToSym (StateT s1 m1 a1) (StateT s2 m2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: StateT s1 m1 a1 -> StateT s2 m2 a2 Source #

ToSym (m1 (a1, s1)) (m2 (a2, s2)) => ToSym (WriterT s1 m1 a1) (WriterT s2 m2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: WriterT s1 m1 a1 -> WriterT s2 m2 a2 Source #

ToSym (m1 (a1, s1)) (m2 (a2, s2)) => ToSym (WriterT s1 m1 a1) (WriterT s2 m2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: WriterT s1 m1 a1 -> WriterT s2 m2 a2 Source #

(ToSym a1 b1, ToSym a2 b2, ToSym a3 b3) => ToSym (a1, a2, a3) (b1, b2, b3) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, a2, a3) -> (b1, b2, b3) Source #

(ToSym (f a) (f1 a1), ToSym (g a) (g1 a1)) => ToSym (Sum f g a) (Sum f1 g1 a1) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: Sum f g a -> Sum f1 g1 a1 Source #

(ToSym a1 a2, ToSym b1 b2, ToSym c1 c2, ToSym d1 d2) => ToSym (a1, b1, c1, d1) (a2, b2, c2, d2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, b1, c1, d1) -> (a2, b2, c2, d2) Source #

(ToSym a1 a2, ToSym b1 b2, ToSym c1 c2, ToSym d1 d2, ToSym e1 e2) => ToSym (a1, b1, c1, d1, e1) (a2, b2, c2, d2, e2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, b1, c1, d1, e1) -> (a2, b2, c2, d2, e2) Source #

(ToSym a1 a2, ToSym b1 b2, ToSym c1 c2, ToSym d1 d2, ToSym e1 e2, ToSym f1 f2) => ToSym (a1, b1, c1, d1, e1, f1) (a2, b2, c2, d2, e2, f2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, b1, c1, d1, e1, f1) -> (a2, b2, c2, d2, e2, f2) Source #

(ToSym a1 a2, ToSym b1 b2, ToSym c1 c2, ToSym d1 d2, ToSym e1 e2, ToSym f1 f2, ToSym g1 g2) => ToSym (a1, b1, c1, d1, e1, f1, g1) (a2, b2, c2, d2, e2, f2, g2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, b1, c1, d1, e1, f1, g1) -> (a2, b2, c2, d2, e2, f2, g2) Source #

(ToSym a1 a2, ToSym b1 b2, ToSym c1 c2, ToSym d1 d2, ToSym e1 e2, ToSym f1 f2, ToSym g1 g2, ToSym h1 h2) => ToSym (a1, b1, c1, d1, e1, f1, g1, h1) (a2, b2, c2, d2, e2, f2, g2, h2) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: (a1, b1, c1, d1, e1, f1, g1, h1) -> (a2, b2, c2, d2, e2, f2, g2, h2) Source #

Pretty printing

class GPretty a where Source #

Minimal complete definition

gpretty | gprettyPrec

Methods

gpretty :: a -> Doc ann Source #

gprettyPrec :: Int -> a -> Doc ann Source #

gprettyList :: [a] -> Doc ann Source #

Instances

Instances details
GPretty Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Int16 -> Doc ann Source #

gprettyPrec :: Int -> Int16 -> Doc ann Source #

gprettyList :: [Int16] -> Doc ann Source #

GPretty Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Int32 -> Doc ann Source #

gprettyPrec :: Int -> Int32 -> Doc ann Source #

gprettyList :: [Int32] -> Doc ann Source #

GPretty Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Int64 -> Doc ann Source #

gprettyPrec :: Int -> Int64 -> Doc ann Source #

gprettyList :: [Int64] -> Doc ann Source #

GPretty Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Int8 -> Doc ann Source #

gprettyPrec :: Int -> Int8 -> Doc ann Source #

gprettyList :: [Int8] -> Doc ann Source #

GPretty Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Word16 -> Doc ann Source #

gprettyPrec :: Int -> Word16 -> Doc ann Source #

gprettyList :: [Word16] -> Doc ann Source #

GPretty Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Word32 -> Doc ann Source #

gprettyPrec :: Int -> Word32 -> Doc ann Source #

gprettyList :: [Word32] -> Doc ann Source #

GPretty Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Word64 -> Doc ann Source #

gprettyPrec :: Int -> Word64 -> Doc ann Source #

gprettyList :: [Word64] -> Doc ann Source #

GPretty Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Word8 -> Doc ann Source #

gprettyPrec :: Int -> Word8 -> Doc ann Source #

gprettyList :: [Word8] -> Doc ann Source #

GPretty ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

GPretty SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

GPretty SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

GPretty Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Text -> Doc ann Source #

gprettyPrec :: Int -> Text -> Doc ann Source #

gprettyList :: [Text] -> Doc ann Source #

GPretty Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

GPretty () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: () -> Doc ann Source #

gprettyPrec :: Int -> () -> Doc ann Source #

gprettyList :: [()] -> Doc ann Source #

GPretty Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Bool -> Doc ann Source #

gprettyPrec :: Int -> Bool -> Doc ann Source #

gprettyList :: [Bool] -> Doc ann Source #

GPretty Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Char -> Doc ann Source #

gprettyPrec :: Int -> Char -> Doc ann Source #

gprettyList :: [Char] -> Doc ann Source #

GPretty Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Int -> Doc ann Source #

gprettyPrec :: Int -> Int -> Doc ann Source #

gprettyList :: [Int] -> Doc ann Source #

GPretty Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Word -> Doc ann Source #

gprettyPrec :: Int -> Word -> Doc ann Source #

gprettyList :: [Word] -> Doc ann Source #

GPretty a => GPretty (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Identity a -> Doc ann Source #

gprettyPrec :: Int -> Identity a -> Doc ann Source #

gprettyList :: [Identity a] -> Doc ann Source #

(Generic a, GPretty' (Rep a)) => GPretty (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Default a -> Doc ann Source #

gprettyPrec :: Int -> Default a -> Doc ann Source #

gprettyList :: [Default a] -> Doc ann Source #

GPretty a => GPretty (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

gpretty :: UnionM a -> Doc ann Source #

gprettyPrec :: Int -> UnionM a -> Doc ann Source #

gprettyList :: [UnionM a] -> Doc ann Source #

GPretty a => GPretty (Union a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Union

Methods

gpretty :: Union a -> Doc ann Source #

gprettyPrec :: Int -> Union a -> Doc ann Source #

gprettyList :: [Union a] -> Doc ann Source #

(KnownNat n, 1 <= n) => GPretty (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: IntN n -> Doc ann Source #

gprettyPrec :: Int -> IntN n -> Doc ann Source #

gprettyList :: [IntN n] -> Doc ann Source #

(KnownNat n, 1 <= n) => GPretty (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: WordN n -> Doc ann Source #

gprettyPrec :: Int -> WordN n -> Doc ann Source #

gprettyList :: [WordN n] -> Doc ann Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => GPretty (bv n)) => GPretty (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

gpretty :: SomeBV bv -> Doc ann Source #

gprettyPrec :: Int -> SomeBV bv -> Doc ann Source #

gprettyList :: [SomeBV bv] -> Doc ann Source #

(KnownNat n, 1 <= n) => GPretty (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: SymIntN n -> Doc ann Source #

gprettyPrec :: Int -> SymIntN n -> Doc ann Source #

gprettyList :: [SymIntN n] -> Doc ann Source #

(KnownNat n, 1 <= n) => GPretty (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: SymWordN n -> Doc ann Source #

gprettyPrec :: Int -> SymWordN n -> Doc ann Source #

gprettyList :: [SymWordN n] -> Doc ann Source #

GPretty a => GPretty (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Maybe a -> Doc ann Source #

gprettyPrec :: Int -> Maybe a -> Doc ann Source #

gprettyList :: [Maybe a] -> Doc ann Source #

GPretty a => GPretty [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: [a] -> Doc ann Source #

gprettyPrec :: Int -> [a] -> Doc ann Source #

gprettyList :: [[a]] -> Doc ann Source #

(GPretty a, GPretty b) => GPretty (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Either a b -> Doc ann Source #

gprettyPrec :: Int -> Either a b -> Doc ann Source #

gprettyList :: [Either a b] -> Doc ann Source #

(SupportedPrim ca, SupportedPrim cb, LinkedRep ca sa, LinkedRep cb sb) => GPretty (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (sa -~> sb) -> Doc ann Source #

gprettyPrec :: Int -> (sa -~> sb) -> Doc ann Source #

gprettyList :: [sa -~> sb] -> Doc ann Source #

(SupportedPrim ca, SupportedPrim cb, LinkedRep ca sa, LinkedRep cb sb) => GPretty (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (sa =~> sb) -> Doc ann Source #

gprettyPrec :: Int -> (sa =~> sb) -> Doc ann Source #

gprettyList :: [sa =~> sb] -> Doc ann Source #

GPretty (m (Maybe a)) => GPretty (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: MaybeT m a -> Doc ann Source #

gprettyPrec :: Int -> MaybeT m a -> Doc ann Source #

gprettyList :: [MaybeT m a] -> Doc ann Source #

(GPretty a, GPretty b) => GPretty (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b) -> Doc ann Source #

gprettyPrec :: Int -> (a, b) -> Doc ann Source #

gprettyList :: [(a, b)] -> Doc ann Source #

GPretty (m (Either e a)) => GPretty (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: ExceptT e m a -> Doc ann Source #

gprettyPrec :: Int -> ExceptT e m a -> Doc ann Source #

gprettyList :: [ExceptT e m a] -> Doc ann Source #

GPretty (m a) => GPretty (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: IdentityT m a -> Doc ann Source #

gprettyPrec :: Int -> IdentityT m a -> Doc ann Source #

gprettyList :: [IdentityT m a] -> Doc ann Source #

GPretty (m (a, w)) => GPretty (WriterT w m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: WriterT w m a -> Doc ann Source #

gprettyPrec :: Int -> WriterT w m a -> Doc ann Source #

gprettyList :: [WriterT w m a] -> Doc ann Source #

GPretty (m (a, w)) => GPretty (WriterT w m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: WriterT w m a -> Doc ann Source #

gprettyPrec :: Int -> WriterT w m a -> Doc ann Source #

gprettyList :: [WriterT w m a] -> Doc ann Source #

(GPretty a, GPretty b, GPretty c) => GPretty (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b, c) -> Doc ann Source #

gprettyPrec :: Int -> (a, b, c) -> Doc ann Source #

gprettyList :: [(a, b, c)] -> Doc ann Source #

(GPretty (f a), GPretty (g a)) => GPretty (Sum f g a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Sum f g a -> Doc ann Source #

gprettyPrec :: Int -> Sum f g a -> Doc ann Source #

gprettyList :: [Sum f g a] -> Doc ann Source #

(GPretty a, GPretty b, GPretty c, GPretty d) => GPretty (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b, c, d) -> Doc ann Source #

gprettyPrec :: Int -> (a, b, c, d) -> Doc ann Source #

gprettyList :: [(a, b, c, d)] -> Doc ann Source #

(GPretty a, GPretty b, GPretty c, GPretty d, GPretty e) => GPretty (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b, c, d, e) -> Doc ann Source #

gprettyPrec :: Int -> (a, b, c, d, e) -> Doc ann Source #

gprettyList :: [(a, b, c, d, e)] -> Doc ann Source #

(GPretty a, GPretty b, GPretty c, GPretty d, GPretty e, GPretty f) => GPretty (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b, c, d, e, f) -> Doc ann Source #

gprettyPrec :: Int -> (a, b, c, d, e, f) -> Doc ann Source #

gprettyList :: [(a, b, c, d, e, f)] -> Doc ann Source #

(GPretty a, GPretty b, GPretty c, GPretty d, GPretty e, GPretty f, GPretty g) => GPretty (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b, c, d, e, f, g) -> Doc ann Source #

gprettyPrec :: Int -> (a, b, c, d, e, f, g) -> Doc ann Source #

gprettyList :: [(a, b, c, d, e, f, g)] -> Doc ann Source #

(GPretty a, GPretty b, GPretty c, GPretty d, GPretty e, GPretty f, GPretty g, GPretty h) => GPretty (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: (a, b, c, d, e, f, g, h) -> Doc ann Source #

gprettyPrec :: Int -> (a, b, c, d, e, f, g, h) -> Doc ann Source #

gprettyList :: [(a, b, c, d, e, f, g, h)] -> Doc ann Source #

Symbolic Generation

It is usually useful to generate complex symbolic values. For example, in program synthesis task, we may want to generate symbolic programs to represent the search space given some specification.

To help with this, we provide a set of classes and functions. The core of the symbolic generation is the Fresh monad, the GenSymSimple class, and the GenSym class.

The Fresh monad is a combination of specialized state and reader monads. It keeps an identifier, and an index. The generated symbolic constants would be constructed with both the identifier and the index. Each time a new symbolic constant is generated, the index would be incremented. This keeps that the generated symbolic constants are unique.

The GenSymSimple class helps generate symbolic values that do not require a symbolic union, for example, symbolic Booleans. It provides the simpleFresh function, which accepts a specification for the symbolic values to generate.

We do not need any specification to generate a symbolic Boolean, so we provide a unit value as the specification:

>>> runFresh (simpleFresh ()) "x" :: SymBool
x@0

We can generate a list of symbolic Booleans by specifying the length of the list, and the specification for the elements. The two elements in the generated list are unique as they have different indices.

>>> runFresh (simpleFresh (SimpleListSpec 2 ())) "x" :: [SymBool]
[x@0,x@1]
>>> runFresh (simpleFresh (SimpleListSpec 2 (SimpleListSpec 1 ()))) "x" :: [[SymBool]]
[[x@0],[x@1]]

The GenSym class helps generate symbolic values that require a symbolic union, for example, lists with different lengths. It provides the fresh function, which accepts a specification for the symbolic values to generate.

We can generate a list of length 0, 1, or 2 by specifying the minimum and maximum lengths, and the specification for the elements:

>>> runFresh (fresh (ListSpec 0 2 ())) "x" :: UnionM [SymBool]
{If x@2 [] (If x@3 [x@1] [x@0,x@1])}

We can generate many symbolic values at once with the Fresh monad. The symbolic constants are ensured to be unique:

>>> :set -XScopedTypeVariables
>>> :{
  flip runFresh "x" $ do
    a :: SymBool <- simpleFresh ()
    b :: UnionM [SymBool] <- fresh (ListSpec 0 2 ())
    return (a, b)
:}
(x@0,{If x@3 [] (If x@4 [x@2] [x@1,x@2])})

When you are just generating a symbolic value, and do not need to compose multiple simpleFresh or fresh calls, you can use the genSym and genSymSimple functions instead.

>>> genSymSimple (SimpleListSpec 2 ()) "x" :: [SymBool]
[x@0,x@1]
>>> genSym (ListSpec 0 2 ()) "x" :: UnionM [SymBool]
{If x@2 [] (If x@3 [x@1] [x@0,x@1])}

Symbolic choices from a list of symbolic values is very useful. With the chooseFresh function, we can generate a symbolic value by choosing from a list of alternative values. Grisette would generate symbolic Boolean guards to perform the symbolic choice.

>>> :{
  (flip runFresh "x" $ do
    a <- simpleFresh ()
    b <- simpleFresh ()
    chooseFresh [[a],[a,b],[a,a,b]]) :: UnionM [SymBool]
:}
{If x@2 [x@0] (If x@3 [x@0,x@1] [x@0,x@0,x@1])}

Symbolic Generation Context

newtype FreshIndex Source #

Index type used for GenSym.

To generate fresh variables, a monadic stateful context will be maintained. The index should be increased every time a new symbolic constant is generated.

Constructors

FreshIndex Int 

Instances

Instances details
Num FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Show FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Eq FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Ord FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Mergeable FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

SimpleMergeable FreshIndex Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Symbolic Generation Monad

class Monad m => MonadFresh m where Source #

Monad class for fresh symbolic value generation.

The monad should be a reader monad for the Identifier and a state monad for the FreshIndex.

Methods

getFreshIndex :: m FreshIndex Source #

Get the current index for fresh variable generation.

setFreshIndex :: FreshIndex -> m () Source #

Set the current index for fresh variable generation.

getIdentifier :: m Identifier Source #

Get the identifier.

localIdentifier :: (Identifier -> Identifier) -> m a -> m a Source #

Change the identifier locally and use a new index from 0 locally.

Instances

Instances details
Monad m => MonadFresh (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

MonadFresh m => MonadFresh (ExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

MonadFresh m => MonadFresh (ReaderT r m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

MonadFresh m => MonadFresh (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

MonadFresh m => MonadFresh (StateT s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(MonadFresh m, Monoid w) => MonadFresh (WriterT w m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(MonadFresh m, Monoid w) => MonadFresh (WriterT w m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(MonadFresh m, Monoid w) => MonadFresh (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(MonadFresh m, Monoid w) => MonadFresh (RWST r w s m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

nextFreshIndex :: MonadFresh m => m FreshIndex Source #

Get the next fresh index and increase the current index.

liftFresh :: MonadFresh m => Fresh a -> m a Source #

Lifts an Fresh a into any MonadFresh.

type Fresh = FreshT Identity Source #

FreshT specialized with Identity.

newtype FreshT m a Source #

A symbolic generation monad transformer.

It is a reader monad transformer for an identifier and a state monad transformer for indices.

Each time a fresh symbolic variable is generated, the index should be increased.

Constructors

FreshT 

Instances

Instances details
MonadTrans FreshT Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

lift :: Monad m => m a -> FreshT m a #

MonadRWS r w s m => MonadRWS r w s (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

MonadError e m => MonadError e (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

throwError :: e -> FreshT m a #

catchError :: FreshT m a -> (e -> FreshT m a) -> FreshT m a #

MonadReader r m => MonadReader r (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

ask :: FreshT m r #

local :: (r -> r) -> FreshT m a -> FreshT m a #

reader :: (r -> a) -> FreshT m a #

MonadState s m => MonadState s (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

get :: FreshT m s #

put :: s -> FreshT m () #

state :: (s -> (a, s)) -> FreshT m a #

MonadWriter w m => MonadWriter w (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

writer :: (a, w) -> FreshT m a #

tell :: w -> FreshT m () #

listen :: FreshT m a -> FreshT m (a, w) #

pass :: FreshT m (a, w -> w) -> FreshT m a #

(Applicative m, Monad m) => Applicative (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

pure :: a -> FreshT m a #

(<*>) :: FreshT m (a -> b) -> FreshT m a -> FreshT m b #

liftA2 :: (a -> b -> c) -> FreshT m a -> FreshT m b -> FreshT m c #

(*>) :: FreshT m a -> FreshT m b -> FreshT m b #

(<*) :: FreshT m a -> FreshT m b -> FreshT m a #

Functor f => Functor (FreshT f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fmap :: (a -> b) -> FreshT f a -> FreshT f b #

(<$) :: a -> FreshT f b -> FreshT f a #

Monad m => Monad (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

(>>=) :: FreshT m a -> (a -> FreshT m b) -> FreshT m b #

(>>) :: FreshT m a -> FreshT m b -> FreshT m b #

return :: a -> FreshT m a #

Monad m => MonadFresh (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Mergeable1 m => Mergeable1 (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

UnionMergeable1 m => SimpleMergeable1 (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> FreshT m a -> FreshT m a -> FreshT m a Source #

UnionMergeable1 m => UnionMergeable1 (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

TryMerge m => TryMerge (FreshT m) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(Mergeable a, Mergeable1 m) => Mergeable (FreshT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(UnionMergeable1 m, Mergeable a) => SimpleMergeable (FreshT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

mrgIte :: SymBool -> FreshT m a -> FreshT m a -> FreshT m a Source #

runFresh :: Fresh a -> Identifier -> a Source #

Run the symbolic generation with the given identifier and 0 as the initial index.

runFreshT :: Monad m => FreshT m a -> Identifier -> m a Source #

Run the symbolic generation with the given identifier and 0 as the initial index.

freshString :: (MonadFresh m, IsString s) => String -> m s Source #

Generate a fresh string with the given postfix.

>>> runFresh (freshString "b") "a" :: String
"a@0[b]"

Symbolic Generation Class

class Mergeable a => GenSym spec a where Source #

Class of types in which symbolic values can be generated with respect to some specification.

The result will be wrapped in a union-like monad. This ensures that we can generate those types with complex merging rules.

The uniqueness of symbolic constants is managed with the a monadic context. Fresh and FreshT can be useful.

Minimal complete definition

Nothing

Methods

fresh :: MonadFresh m => spec -> m (UnionM a) Source #

Generate a symbolic value given some specification. Within a single MonadFresh context, calls to fresh would generate unique symbolic constants.

The following example generates a symbolic boolean. No specification is needed.

>>> runFresh (fresh ()) "a" :: UnionM SymBool
{a@0}

The following example generates booleans, which cannot be merged into a single value with type Bool. No specification is needed.

>>> runFresh (fresh ()) "a" :: UnionM Bool
{If a@0 False True}

The following example generates Maybe Bools. There are more than one symbolic constants introduced, and their uniqueness is ensured. No specification is needed.

>>> runFresh (fresh ()) "a" :: UnionM (Maybe Bool)
{If a@0 Nothing (If a@1 (Just False) (Just True))}

The following example generates lists of symbolic booleans with length 1 to 2.

>>> runFresh (fresh (ListSpec 1 2 ())) "a" :: UnionM [SymBool]
{If a@2 [a@1] [a@0,a@1]}

When multiple symbolic values are generated, there will not be any identifier collision

>>> runFresh (do; a <- fresh (); b <- fresh (); return (a, b)) "a" :: (UnionM SymBool, UnionM SymBool)
({a@0},{a@1})

default fresh :: GenSymSimple spec a => MonadFresh m => spec -> m (UnionM a) Source #

Instances

Instances details
GenSym Int16 Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Int16 -> m (UnionM Int16) Source #

GenSym Int32 Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Int32 -> m (UnionM Int32) Source #

GenSym Int64 Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Int64 -> m (UnionM Int64) Source #

GenSym Int8 Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Int8 -> m (UnionM Int8) Source #

GenSym Word16 Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Word16 -> m (UnionM Word16) Source #

GenSym Word32 Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Word32 -> m (UnionM Word32) Source #

GenSym Word64 Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Word64 -> m (UnionM Word64) Source #

GenSym Word8 Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Word8 -> m (UnionM Word8) Source #

GenSym ByteString ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSym SymBool SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => SymBool -> m (UnionM SymBool) Source #

GenSym SymInteger SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSym Text Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Text -> m (UnionM Text) Source #

GenSym Integer Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Integer -> m (UnionM Integer) Source #

GenSym () SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM SymBool) Source #

GenSym () SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM SymInteger) Source #

GenSym () () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM ()) Source #

GenSym () Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM Bool) Source #

GenSym Bool Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Bool -> m (UnionM Bool) Source #

GenSym Char Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Char -> m (UnionM Char) Source #

GenSym Int Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Int -> m (UnionM Int) Source #

GenSym Word Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Word -> m (UnionM Word) Source #

(GenSym () a, Mergeable a) => GenSym Integer [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Integer -> m (UnionM [a]) Source #

(KnownNat n, 1 <= n) => GenSym () (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (SymIntN n)) Source #

(KnownNat n, 1 <= n) => GenSym () (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (SymWordN n)) Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => GenSym () (bv n), Mergeable (SomeBV bv)) => GenSym Int (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

fresh :: MonadFresh m => Int -> m (UnionM (SomeBV bv)) Source #

(GenSym aspec a, Mergeable a) => GenSym aspec (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => aspec -> m (UnionM (Maybe a)) Source #

(GenSym spec a, Mergeable a) => GenSym spec (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => spec -> m (UnionM (UnionM a)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b) => GenSym () (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (Either a b)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b) => GenSym () (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m => () -> m (UnionM (CBMCEither a b)) Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSym () (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (sa -~> sb)) Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSym () (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (sa =~> sb)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b) => GenSym () (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b)) Source #

(GenSym spec (m (Maybe a)), Mergeable1 m, Mergeable a) => GenSym spec (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m0 => spec -> m0 (UnionM (MaybeT m a)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b, GenSym () c, Mergeable c) => GenSym () (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b, c)) Source #

(GenSym spec (m (CBMCEither a b)), Mergeable1 m, Mergeable a, Mergeable b) => GenSym spec (CBMCExceptT a m b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m0 => spec -> m0 (UnionM (CBMCExceptT a m b)) Source #

(GenSym spec (m (Either a b)), Mergeable1 m, Mergeable a, Mergeable b) => GenSym spec (ExceptT a m b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m0 => spec -> m0 (UnionM (ExceptT a m b)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b, GenSym () c, Mergeable c, GenSym () d, Mergeable d) => GenSym () (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b, c, d)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b, GenSym () c, Mergeable c, GenSym () d, Mergeable d, GenSym () e, Mergeable e) => GenSym () (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b, c, d, e)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b, GenSym () c, Mergeable c, GenSym () d, Mergeable d, GenSym () e, Mergeable e, GenSym () f, Mergeable f) => GenSym () (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b, c, d, e, f)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b, GenSym () c, Mergeable c, GenSym () d, Mergeable d, GenSym () e, Mergeable e, GenSym () f, Mergeable f, GenSym () g, Mergeable g) => GenSym () (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b, c, d, e, f, g)) Source #

(GenSym () a, Mergeable a, GenSym () b, Mergeable b, GenSym () c, Mergeable c, GenSym () d, Mergeable d, GenSym () e, Mergeable e, GenSym () f, Mergeable f, GenSym () g, Mergeable g, GenSym () h, Mergeable h) => GenSym () (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => () -> m (UnionM (a, b, c, d, e, f, g, h)) Source #

(GenSym a a, Mergeable a) => GenSym (UnionM a) a Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => UnionM a -> m (UnionM a) Source #

(Enum v, Mergeable v) => GenSym (EnumGenBound v) v Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => EnumGenBound v -> m (UnionM v) Source #

(Enum v, Mergeable v) => GenSym (EnumGenUpperBound v) v Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => EnumGenUpperBound v -> m (UnionM v) Source #

(GenSym spec a, Mergeable a) => GenSym (ListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => ListSpec spec -> m (UnionM [a]) Source #

(GenSym spec a, Mergeable a) => GenSym (SimpleListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => SimpleListSpec spec -> m (UnionM [a]) Source #

(KnownNat n, 1 <= n) => GenSym (IntN n) (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => IntN n -> m (UnionM (IntN n)) Source #

(KnownNat n, 1 <= n) => GenSym (WordN n) (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => WordN n -> m (UnionM (WordN n)) Source #

(forall (m :: Nat). (KnownNat m, 1 <= m) => GenSym () (bv m), Mergeable (SomeBV bv)) => GenSym (SomeBV bv) (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

fresh :: MonadFresh m => SomeBV bv -> m (UnionM (SomeBV bv)) Source #

(KnownNat n, 1 <= n) => GenSym (SymIntN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => SymIntN n -> m (UnionM (SymIntN n)) Source #

(KnownNat n, 1 <= n) => GenSym (SymWordN n) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => SymWordN n -> m (UnionM (SymWordN n)) Source #

(GenSym aspec a, Mergeable a) => GenSym (Maybe aspec) (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Maybe aspec -> m (UnionM (Maybe a)) Source #

(GenSym a a, Mergeable a) => GenSym [a] [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => [a] -> m (UnionM [a]) Source #

(KnownNat n, 1 <= n, forall (m :: Nat). (KnownNat m, 1 <= m) => GenSym () (bv m), Mergeable (SomeBV bv)) => GenSym (Proxy n) (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

fresh :: MonadFresh m => Proxy n -> m (UnionM (SomeBV bv)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b) => GenSym (Either aspec bspec) (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => Either aspec bspec -> m (UnionM (Either a b)) Source #

(GenSymSimple a a, Mergeable a, GenSymSimple b b, Mergeable b) => GenSym (CBMCEither a b) (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m => CBMCEither a b -> m (UnionM (CBMCEither a b)) Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSym (sa -~> sb) (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (sa -~> sb) -> m (UnionM (sa -~> sb)) Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSym (sa =~> sb) (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (sa =~> sb) -> m (UnionM (sa =~> sb)) Source #

(GenSymSimple (m (Maybe a)) (m (Maybe a)), Mergeable1 m, Mergeable a) => GenSym (MaybeT m a) (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m0 => MaybeT m a -> m0 (UnionM (MaybeT m a)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b) => GenSym (aspec, bspec) (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec) -> m (UnionM (Either a b)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b) => GenSym (aspec, bspec) (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec) -> m (UnionM (a, b)) Source #

(GenSymSimple (m (CBMCEither e a)) (m (CBMCEither e a)), Mergeable1 m, Mergeable e, Mergeable a) => GenSym (CBMCExceptT e m a) (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m0 => CBMCExceptT e m a -> m0 (UnionM (CBMCExceptT e m a)) Source #

(GenSymSimple (m (Either e a)) (m (Either e a)), Mergeable1 m, Mergeable e, Mergeable a) => GenSym (ExceptT e m a) (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m0 => ExceptT e m a -> m0 (UnionM (ExceptT e m a)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b, GenSym cspec c, Mergeable c) => GenSym (aspec, bspec, cspec) (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec, cspec) -> m (UnionM (a, b, c)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b, GenSym cspec c, Mergeable c, GenSym dspec d, Mergeable d) => GenSym (aspec, bspec, cspec, dspec) (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec, cspec, dspec) -> m (UnionM (a, b, c, d)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b, GenSym cspec c, Mergeable c, GenSym dspec d, Mergeable d, GenSym espec e, Mergeable e) => GenSym (aspec, bspec, cspec, dspec, espec) (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec) -> m (UnionM (a, b, c, d, e)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b, GenSym cspec c, Mergeable c, GenSym dspec d, Mergeable d, GenSym espec e, Mergeable e, GenSym fspec f, Mergeable f) => GenSym (aspec, bspec, cspec, dspec, espec, fspec) (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec, fspec) -> m (UnionM (a, b, c, d, e, f)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b, GenSym cspec c, Mergeable c, GenSym dspec d, Mergeable d, GenSym espec e, Mergeable e, GenSym fspec f, Mergeable f, GenSym gspec g, Mergeable g) => GenSym (aspec, bspec, cspec, dspec, espec, fspec, gspec) (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec, fspec, gspec) -> m (UnionM (a, b, c, d, e, f, g)) Source #

(GenSym aspec a, Mergeable a, GenSym bspec b, Mergeable b, GenSym cspec c, Mergeable c, GenSym dspec d, Mergeable d, GenSym espec e, Mergeable e, GenSym fspec f, Mergeable f, GenSym gspec g, Mergeable g, GenSym hspec h, Mergeable h) => GenSym (aspec, bspec, cspec, dspec, espec, fspec, gspec, hspec) (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec, fspec, gspec, hspec) -> m (UnionM (a, b, c, d, e, f, g, h)) Source #

class GenSymSimple spec a where Source #

Class of types in which symbolic values can be generated with respect to some specification.

The result will not be wrapped in a union-like monad.

The uniqueness of symbolic constants is managed with the a monadic context. Fresh and FreshT can be useful.

Methods

simpleFresh :: MonadFresh m => spec -> m a Source #

Generate a symbolic value given some specification. The uniqueness is ensured.

The following example generates a symbolic boolean. No specification is needed.

>>> runFresh (simpleFresh ()) "a" :: SymBool
a@0

The following code generates list of symbolic boolean with length 2. As the length is fixed, we don't have to wrap the result in unions.

>>> runFresh (simpleFresh (SimpleListSpec 2 ())) "a" :: [SymBool]
[a@0,a@1]

Instances

Instances details
GenSymSimple Int16 Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Int32 Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Int64 Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Int8 Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Int8 -> m Int8 Source #

GenSymSimple Word16 Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Word32 Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Word64 Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Word8 Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple ByteString ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple SymBool SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple SymInteger SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple Text Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Text -> m Text Source #

GenSymSimple Integer Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

GenSymSimple () SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m SymBool Source #

GenSymSimple () SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m SymInteger Source #

GenSymSimple () () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m () Source #

GenSymSimple Bool Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Bool -> m Bool Source #

GenSymSimple Char Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Char -> m Char Source #

GenSymSimple Int Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Int -> m Int Source #

GenSymSimple Word Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Word -> m Word Source #

(KnownNat n, 1 <= n) => GenSymSimple () (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (SymIntN n) Source #

(KnownNat n, 1 <= n) => GenSymSimple () (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (SymWordN n) Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => GenSymSimple () (bv n), Mergeable (SomeBV bv)) => GenSymSimple Int (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

simpleFresh :: MonadFresh m => Int -> m (SomeBV bv) Source #

GenSym spec a => GenSymSimple spec (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => spec -> m (UnionM a) Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSymSimple () (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (sa -~> sb) Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSymSimple () (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (sa =~> sb) Source #

(GenSymSimple () a, GenSymSimple () b) => GenSymSimple () (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b) Source #

GenSymSimple spec (m (Maybe a)) => GenSymSimple spec (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m0 => spec -> m0 (MaybeT m a) Source #

(GenSymSimple () a, GenSymSimple () b, GenSymSimple () c) => GenSymSimple () (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b, c) Source #

GenSymSimple spec (m (CBMCEither a b)) => GenSymSimple spec (CBMCExceptT a m b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

simpleFresh :: MonadFresh m0 => spec -> m0 (CBMCExceptT a m b) Source #

GenSymSimple spec (m (Either a b)) => GenSymSimple spec (ExceptT a m b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m0 => spec -> m0 (ExceptT a m b) Source #

(GenSymSimple () a, GenSymSimple () b, GenSymSimple () c, GenSymSimple () d) => GenSymSimple () (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b, c, d) Source #

(GenSymSimple () a, GenSymSimple () b, GenSymSimple () c, GenSymSimple () d, GenSymSimple () e) => GenSymSimple () (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b, c, d, e) Source #

(GenSymSimple () a, GenSymSimple () b, GenSymSimple () c, GenSymSimple () d, GenSymSimple () e, GenSymSimple () f) => GenSymSimple () (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b, c, d, e, f) Source #

(GenSymSimple () a, GenSymSimple () b, GenSymSimple () c, GenSymSimple () d, GenSymSimple () e, GenSymSimple () f, GenSymSimple () g) => GenSymSimple () (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b, c, d, e, f, g) Source #

(GenSymSimple () a, GenSymSimple () b, GenSymSimple () c, GenSymSimple () d, GenSymSimple () e, GenSymSimple () f, GenSymSimple () g, GenSymSimple () h) => GenSymSimple () (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => () -> m (a, b, c, d, e, f, g, h) Source #

GenSymSimple spec a => GenSymSimple (SimpleListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => SimpleListSpec spec -> m [a] Source #

(KnownNat n, 1 <= n) => GenSymSimple (IntN n) (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => IntN n -> m (IntN n) Source #

(KnownNat n, 1 <= n) => GenSymSimple (WordN n) (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => WordN n -> m (WordN n) Source #

(forall (m :: Nat). (KnownNat m, 1 <= m) => GenSymSimple () (bv m), Mergeable (SomeBV bv)) => GenSymSimple (SomeBV bv) (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

simpleFresh :: MonadFresh m => SomeBV bv -> m (SomeBV bv) Source #

(KnownNat n, 1 <= n) => GenSymSimple (SymIntN n) (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => SymIntN n -> m (SymIntN n) Source #

(KnownNat n, 1 <= n) => GenSymSimple (SymWordN n) (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => SymWordN n -> m (SymWordN n) Source #

GenSymSimple aspec a => GenSymSimple (Maybe aspec) (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Maybe aspec -> m (Maybe a) Source #

GenSymSimple a a => GenSymSimple [a] [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => [a] -> m [a] Source #

(KnownNat n, 1 <= n, forall (m :: Nat). (KnownNat m, 1 <= m) => GenSymSimple () (bv m), Mergeable (SomeBV bv)) => GenSymSimple (Proxy n) (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

simpleFresh :: MonadFresh m => Proxy n -> m (SomeBV bv) Source #

(GenSymSimple aspec a, GenSymSimple bspec b) => GenSymSimple (Either aspec bspec) (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => Either aspec bspec -> m (Either a b) Source #

(GenSymSimple a a, GenSymSimple b b) => GenSymSimple (CBMCEither a b) (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

simpleFresh :: MonadFresh m => CBMCEither a b -> m (CBMCEither a b) Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSymSimple (sa -~> sb) (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (sa -~> sb) -> m (sa -~> sb) Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => GenSymSimple (sa =~> sb) (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (sa =~> sb) -> m (sa =~> sb) Source #

GenSymSimple (m (Maybe a)) (m (Maybe a)) => GenSymSimple (MaybeT m a) (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m0 => MaybeT m a -> m0 (MaybeT m a) Source #

(GenSymSimple aspec a, GenSymSimple bspec b) => GenSymSimple (aspec, bspec) (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec) -> m (a, b) Source #

GenSymSimple (m (CBMCEither e a)) (m (CBMCEither e a)) => GenSymSimple (CBMCExceptT e m a) (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

simpleFresh :: MonadFresh m0 => CBMCExceptT e m a -> m0 (CBMCExceptT e m a) Source #

GenSymSimple (m (Either e a)) (m (Either e a)) => GenSymSimple (ExceptT e m a) (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m0 => ExceptT e m a -> m0 (ExceptT e m a) Source #

(GenSymSimple aspec a, GenSymSimple bspec b, GenSymSimple cspec c) => GenSymSimple (aspec, bspec, cspec) (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec, cspec) -> m (a, b, c) Source #

(GenSymSimple aspec a, GenSymSimple bspec b, GenSymSimple cspec c, GenSymSimple dspec d) => GenSymSimple (aspec, bspec, cspec, dspec) (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec, cspec, dspec) -> m (a, b, c, d) Source #

(GenSymSimple aspec a, GenSymSimple bspec b, GenSymSimple cspec c, GenSymSimple dspec d, GenSymSimple espec e) => GenSymSimple (aspec, bspec, cspec, dspec, espec) (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec) -> m (a, b, c, d, e) Source #

(GenSymSimple aspec a, GenSymSimple bspec b, GenSymSimple cspec c, GenSymSimple dspec d, GenSymSimple espec e, GenSymSimple fspec f) => GenSymSimple (aspec, bspec, cspec, dspec, espec, fspec) (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec, fspec) -> m (a, b, c, d, e, f) Source #

(GenSymSimple aspec a, GenSymSimple bspec b, GenSymSimple cspec c, GenSymSimple dspec d, GenSymSimple espec e, GenSymSimple fspec f, GenSymSimple gspec g) => GenSymSimple (aspec, bspec, cspec, dspec, espec, fspec, gspec) (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec, fspec, gspec) -> m (a, b, c, d, e, f, g) Source #

(GenSymSimple aspec a, GenSymSimple bspec b, GenSymSimple cspec c, GenSymSimple dspec d, GenSymSimple espec e, GenSymSimple fspec f, GenSymSimple gspec g, GenSymSimple hspec h) => GenSymSimple (aspec, bspec, cspec, dspec, espec, fspec, gspec, hspec) (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => (aspec, bspec, cspec, dspec, espec, fspec, gspec, hspec) -> m (a, b, c, d, e, f, g, h) Source #

genSym :: GenSym spec a => spec -> Identifier -> UnionM a Source #

Generate a symbolic variable wrapped in a Union without the monadic context. A globally unique identifier should be supplied to ensure the uniqueness of symbolic constants in the generated symbolic values.

>>> genSym (ListSpec 1 2 ()) "a" :: UnionM [SymBool]
{If a@2 [a@1] [a@0,a@1]}

genSymSimple :: forall spec a. GenSymSimple spec a => spec -> Identifier -> a Source #

Generate a simple symbolic variable wrapped in a Union without the monadic context. A globally unique identifier should be supplied to ensure the uniqueness of symbolic constants in the generated symbolic values.

>>> genSymSimple (SimpleListSpec 2 ()) "a" :: [SymBool]
[a@0,a@1]

Symbolic Generation Class Derivation

derivedNoSpecFresh :: forall a m. (Generic a, GenSymNoSpec (Rep a), Mergeable a, MonadFresh m) => () -> m (UnionM a) Source #

We cannot provide DerivingVia style derivation for GenSym, while you can use this fresh implementation to implement GenSym for your own types.

This fresh implementation is for the types that does not need any specification. It will generate product types by generating each fields with () as specification, and generate all possible values for a sum type.

Note: Never use on recursive types.

derivedNoSpecSimpleFresh :: forall a m. (Generic a, GenSymSimpleNoSpec (Rep a), MonadFresh m) => () -> m a Source #

We cannot provide DerivingVia style derivation for GenSymSimple, while you can use this simpleFresh implementation to implement GenSymSimple fo your own types.

This simpleFresh implementation is for the types that does not need any specification. It will generate product types by generating each fields with () as specification. It will not work on sum types.

Note: Never use on recursive types.

derivedSameShapeSimpleFresh :: forall a m. (Generic a, GenSymSameShape (Rep a), MonadFresh m) => a -> m a Source #

We cannot provide DerivingVia style derivation for GenSymSimple, while you can use this simpleFresh implementation to implement GenSymSimple fo your own types.

This simpleFresh implementation is for the types that can be generated with a reference value of the same type.

For sum types, it will generate the result with the same data constructor. For product types, it will generate the result by generating each field with the corresponding reference value.

Note: Can be used on recursive types.

Symbolic choice

chooseFresh :: forall a m. (Mergeable a, MonadFresh m) => [a] -> m (UnionM a) Source #

Symbolically chooses one of the provided values. The procedure creates n - 1 fresh symbolic boolean variables every time it is evaluated, and use these variables to conditionally select one of the n provided expressions.

The result will be wrapped in a union-like monad, and also a monad maintaining the MonadFresh context.

>>> runFresh (chooseFresh [1,2,3]) "a" :: UnionM Integer
{If a@0 1 (If a@1 2 3)}

chooseSimpleFresh :: forall a m. (SimpleMergeable a, MonadFresh m) => [a] -> m a Source #

Symbolically chooses one of the provided values. The procedure creates n - 1 fresh symbolic boolean variables every time it is evaluated, and use these variables to conditionally select one of the n provided expressions.

The result will not be wrapped in a union-like monad, but will be wrapped in a monad maintaining the Fresh context.

>>> import Data.Proxy
>>> runFresh (chooseSimpleFresh [ssym "b", ssym "c", ssym "d"]) "a" :: SymInteger
(ite a@0 b (ite a@1 c d))

chooseUnionFresh :: forall a m. (Mergeable a, MonadFresh m) => [UnionM a] -> m (UnionM a) Source #

Symbolically chooses one of the provided values wrapped in union-like monads. The procedure creates n - 1 fresh symbolic boolean variables every time it is evaluated, and use these variables to conditionally select one of the n provided expressions.

The result will be wrapped in a union-like monad, and also a monad maintaining the Fresh context.

>>> let a = runFresh (chooseFresh [1, 2]) "a" :: UnionM Integer
>>> let b = runFresh (chooseFresh [2, 3]) "b" :: UnionM Integer
>>> runFresh (chooseUnionFresh [a, b]) "c" :: UnionM Integer
{If (&& c@0 a@0) 1 (If (|| c@0 b@0) 2 3)}

choose :: forall a. Mergeable a => [a] -> Identifier -> UnionM a Source #

A wrapper for chooseFresh that executes the MonadFresh context. A globally unique identifier should be supplied to ensure the uniqueness of symbolic constants in the generated symbolic values.

chooseSimple :: forall a. SimpleMergeable a => [a] -> Identifier -> a Source #

A wrapper for chooseSimpleFresh that executes the MonadFresh context. A globally unique identifier should be supplied to ensure the uniqueness of symbolic constants in the generated symbolic values.

chooseUnion :: forall a. Mergeable a => [UnionM a] -> Identifier -> UnionM a Source #

A wrapper for chooseUnionFresh that executes the MonadFresh context. A globally unique identifier should be supplied to ensure the uniqueness of symbolic constants in the generated symbolic values.

Useful specifications

data EnumGenBound a Source #

Specification for numbers with lower bound (inclusive) and upper bound (exclusive)

>>> runFresh (fresh (EnumGenBound @Integer 0 4)) "c" :: UnionM Integer
{If c@0 0 (If c@1 1 (If c@2 2 3))}

Constructors

EnumGenBound a a 

Instances

Instances details
(Enum v, Mergeable v) => GenSym (EnumGenBound v) v Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => EnumGenBound v -> m (UnionM v) Source #

newtype EnumGenUpperBound a Source #

Specification for enum values with upper bound (exclusive). The result would chosen from [0 .. upperbound].

>>> runFresh (fresh (EnumGenUpperBound @Integer 4)) "c" :: UnionM Integer
{If c@0 0 (If c@1 1 (If c@2 2 3))}

Constructors

EnumGenUpperBound a 

Instances

Instances details
(Enum v, Mergeable v) => GenSym (EnumGenUpperBound v) v Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => EnumGenUpperBound v -> m (UnionM v) Source #

data ListSpec spec Source #

Specification for list generation.

>>> runFresh (fresh (ListSpec 0 2 ())) "c" :: UnionM [SymBool]
{If c@2 [] (If c@3 [c@1] [c@0,c@1])}
>>> runFresh (fresh (ListSpec 0 2 (SimpleListSpec 1 ()))) "c" :: UnionM [[SymBool]]
{If c@2 [] (If c@3 [[c@1]] [[c@0],[c@1]])}

Constructors

ListSpec 

Fields

Instances

Instances details
Show spec => Show (ListSpec spec) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

showsPrec :: Int -> ListSpec spec -> ShowS #

show :: ListSpec spec -> String #

showList :: [ListSpec spec] -> ShowS #

(GenSymConstrained spec a, Mergeable a) => GenSymConstrained (ListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Experimental.GenSymConstrained

Methods

freshConstrained :: (MonadFresh m, MonadError e m, MonadUnion m) => e -> ListSpec spec -> m (UnionM [a]) Source #

(GenSym spec a, Mergeable a) => GenSym (ListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => ListSpec spec -> m (UnionM [a]) Source #

data SimpleListSpec spec Source #

Specification for list generation of a specific length.

>>> runFresh (simpleFresh (SimpleListSpec 2 ())) "c" :: [SymBool]
[c@0,c@1]

Constructors

SimpleListSpec 

Fields

Instances

Instances details
Show spec => Show (SimpleListSpec spec) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

(GenSymConstrained spec a, Mergeable a) => GenSymConstrained (SimpleListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Experimental.GenSymConstrained

Methods

freshConstrained :: (MonadFresh m, MonadError e m, MonadUnion m) => e -> SimpleListSpec spec -> m (UnionM [a]) Source #

GenSymSimpleConstrained spec a => GenSymSimpleConstrained (SimpleListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Experimental.GenSymConstrained

Methods

simpleFreshConstrained :: (MonadFresh m, MonadError e m, MonadUnion m) => e -> SimpleListSpec spec -> m [a] Source #

(GenSym spec a, Mergeable a) => GenSym (SimpleListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

fresh :: MonadFresh m => SimpleListSpec spec -> m (UnionM [a]) Source #

GenSymSimple spec a => GenSymSimple (SimpleListSpec spec) [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GenSym

Methods

simpleFresh :: MonadFresh m => SimpleListSpec spec -> m [a] Source #

Error Handling

Grisette supports using ExceptT to handle errors, and provides the mrg* variants for the combinators in Grisette.Lib.Mtl, for example, mrgThrowError.

>>> import Control.Monad.Except
>>> import Grisette.Lib.Control.Monad.Except
>>> mrgThrowError AssertionError :: ExceptT AssertionError UnionM ()
ExceptT {Left AssertionError}

You can define your own error types, and reason about them with the solver APIs.

>>> :set -XDerivingVia -XDeriveGeneric -XDerivingStrategies -XLambdaCase
>>> import GHC.Generics
>>> import Grisette.Backend
>>> :{
  data Error = Error1 | Error2 | Error3
    deriving (Show, Generic)
    deriving (Mergeable) via Default Error
:}
>>> let [a,b,c] = ["a","b","c"] :: [SymBool]
>>> res = mrgIf a (throwError Error1) (mrgIf b (return c) (throwError Error2)) :: ExceptT Error UnionM SymBool
>>> res
ExceptT {If (|| a (! b)) (If a (Left Error1) (Left Error2)) (Right c)}
>>> solveExcept (precise z3) (\case Left _ -> con False; Right x -> x) res
Right (Model {a -> False :: Bool, b -> True :: Bool, c -> True :: Bool})

The solver call in the above example means that we want the solver to find the conditions under which no error is thrown, and the result is true. For more details, please refer to the documentation of the solver APIs.

For those who prefer to encode errors as assertions and assumptions, we provide the symAssert and symAssume functions. These functions relies on the TransformError type class to transform the assertions and assumptions to the user-defined error type. See their documentation for details.

Predefined errors

data AssertionError Source #

Assertion error.

Constructors

AssertionError 

Instances

Instances details
Generic AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

Associated Types

type Rep AssertionError :: Type -> Type #

Show AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

NFData AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

Methods

rnf :: AssertionError -> () #

Eq AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

Ord AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

EvaluateSym AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

ExtractSymbolics AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Mergeable AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

SEq AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SOrd AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

SimpleMergeable AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

AllSyms AssertionError Source # 
Instance details

Defined in Grisette.Internal.SymPrim.AllSyms

TransformError ArithException AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Error

TransformError ArrayException AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Error

TransformError AssertionError AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Error

TransformError AssertionError VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Error

ToCon AssertionError AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToSym AssertionError AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

type Rep AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

type Rep AssertionError = D1 ('MetaData "AssertionError" "Grisette.Internal.Core.Control.Exception" "grisette-0.5.0.0-2ZDAuzWdzg48yPrBcRstUR" 'False) (C1 ('MetaCons "AssertionError" 'PrefixI 'False) (U1 :: Type -> Type))

data VerificationConditions Source #

Verification conditions. A crashed program path can terminate with either assertion violation errors or assumption violation errors.

Instances

Instances details
Generic VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

Associated Types

type Rep VerificationConditions :: Type -> Type #

Show VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

NFData VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

Methods

rnf :: VerificationConditions -> () #

Eq VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

Ord VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

EvaluateSym VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

ExtractSymbolics VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Mergeable VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

SEq VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

SOrd VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

AllSyms VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.SymPrim.AllSyms

TransformError AssertionError VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Error

TransformError VerificationConditions VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Error

ToCon VerificationConditions VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

ToSym VerificationConditions VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

type Rep VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Exception

type Rep VerificationConditions = D1 ('MetaData "VerificationConditions" "Grisette.Internal.Core.Control.Exception" "grisette-0.5.0.0-2ZDAuzWdzg48yPrBcRstUR" 'False) (C1 ('MetaCons "AssertionViolation" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AssumptionViolation" 'PrefixI 'False) (U1 :: Type -> Type))

Error transformation

class TransformError from to where Source #

This class indicates that the error type to can always represent the error type from.

This is useful in implementing generic procedures that may throw errors. For example, we support symbolic division and modulo operations. These operations should throw an error when the divisor is zero, and we use the standard error type ArithException for this purpose. However, the user may use other type to represent errors, so we need this type class to transform the ArithException to the user-defined types.

Another example of these generic procedures is the symAssert and symAssume functions. They can be used with any error types that are compatible with the AssertionError and VerificationConditions types, respectively.

Methods

transformError :: from -> to Source #

Transforms an error with type from to an error with type to.

symAssert :: (TransformError AssertionError to, Mergeable to, MonadError to erm, MonadUnion erm) => SymBool -> erm () Source #

Used within a monadic multi path computation to begin exception processing.

Checks the condition passed to the function. The current execution path will be terminated with assertion error if the condition is false.

If the condition is symbolic, Grisette will split the execution into two paths based on the condition. The symbolic execution will continue on the then-branch, where the condition is true. For the else branch, where the condition is false, the execution will be terminated.

The resulting monadic environment should be compatible with the AssertionError error type. See TransformError type class for details.

Examples:

Terminates the execution if the condition is false. Note that we may lose the Mergeable knowledge here if no possible execution path is viable. This may affect the efficiency in theory, but in practice this should not be a problem as all paths are terminated and no further evaluation would be performed.

>>> symAssert (con False) :: ExceptT AssertionError UnionM ()
ExceptT {Left AssertionError}
>>> do; symAssert (con False); mrgReturn 1 :: ExceptT AssertionError UnionM Integer
ExceptT <Left AssertionError>

No effect if the condition is true:

>>> symAssert (con True) :: ExceptT AssertionError UnionM ()
ExceptT {Right ()}
>>> do; symAssert (con True); mrgReturn 1 :: ExceptT AssertionError UnionM Integer
ExceptT {Right 1}

Splitting the path and terminate one of them when the condition is symbolic.

>>> symAssert (ssym "a") :: ExceptT AssertionError UnionM ()
ExceptT {If (! a) (Left AssertionError) (Right ())}
>>> do; symAssert (ssym "a"); mrgReturn 1 :: ExceptT AssertionError UnionM Integer
ExceptT {If (! a) (Left AssertionError) (Right 1)}

AssertionError is compatible with VerificationConditions:

>>> symAssert (ssym "a") :: ExceptT VerificationConditions UnionM ()
ExceptT {If (! a) (Left AssertionViolation) (Right ())}

symAssume :: (TransformError VerificationConditions to, Mergeable to, MonadError to erm, MonadUnion erm) => SymBool -> erm () Source #

Used within a monadic multi path computation to begin exception processing.

Similar to symAssert, but terminates the execution path with AssumptionViolation error.

Examples:

>>> symAssume (ssym "a") :: ExceptT VerificationConditions UnionM ()
ExceptT {If (! a) (Left AssumptionViolation) (Right ())}

symAssertWith :: (Mergeable e, MonadError e erm, MonadUnion erm) => e -> SymBool -> erm () Source #

symAssertTransformableError :: (Mergeable to, TransformError from to, MonadError to erm, MonadUnion erm) => from -> SymBool -> erm () Source #

Used within a monadic multi path computation for exception processing.

Terminate the current execution path with the specified error if the condition does not hold. Compatible error can be transformed.

>>> let assert = symAssertTransformableError AssertionError
>>> assert "a" :: ExceptT AssertionError UnionM ()
ExceptT {If (! a) (Left AssertionError) (Right ())}

symThrowTransformableError :: (Mergeable to, Mergeable a, TransformError from to, MonadError to erm, MonadUnion erm) => from -> erm a Source #

Used within a monadic multi path computation to begin exception processing.

Terminate the current execution path with the specified error. Compatible errors can be transformed.

>>> symThrowTransformableError Overflow :: ExceptT AssertionError UnionM ()
ExceptT {Left AssertionError}

Simulate CBMC error handling

newtype CBMCEither a b Source #

A wrapper type for Either. Uses different merging strategies.

Constructors

CBMCEither 

Fields

Instances

Instances details
(GenSym () a, Mergeable a, GenSym () b, Mergeable b) => GenSym () (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m => () -> m (UnionM (CBMCEither a b)) Source #

(Lift a, Lift b) => Lift (CBMCEither a b :: Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

lift :: Quote m => CBMCEither a b -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => CBMCEither a b -> Code m (CBMCEither a b) #

Eq a => Eq1 (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftEq :: (a0 -> b -> Bool) -> CBMCEither a a0 -> CBMCEither a b -> Bool #

Ord a => Ord1 (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftCompare :: (a0 -> b -> Ordering) -> CBMCEither a a0 -> CBMCEither a b -> Ordering #

Read a => Read1 (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (CBMCEither a a0) #

liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [CBMCEither a a0] #

liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (CBMCEither a a0) #

liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [CBMCEither a a0] #

Show a => Show1 (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> CBMCEither a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [CBMCEither a a0] -> ShowS #

Applicative (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

pure :: a0 -> CBMCEither a a0 #

(<*>) :: CBMCEither a (a0 -> b) -> CBMCEither a a0 -> CBMCEither a b #

liftA2 :: (a0 -> b -> c) -> CBMCEither a a0 -> CBMCEither a b -> CBMCEither a c #

(*>) :: CBMCEither a a0 -> CBMCEither a b -> CBMCEither a b #

(<*) :: CBMCEither a a0 -> CBMCEither a b -> CBMCEither a a0 #

Functor (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fmap :: (a0 -> b) -> CBMCEither a a0 -> CBMCEither a b #

(<$) :: a0 -> CBMCEither a b -> CBMCEither a a0 #

Monad (CBMCEither a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

(>>=) :: CBMCEither a a0 -> (a0 -> CBMCEither a b) -> CBMCEither a b #

(>>) :: CBMCEither a a0 -> CBMCEither a b -> CBMCEither a b #

return :: a0 -> CBMCEither a a0 #

Mergeable e => Mergeable1 (CBMCEither e) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

UnionWithExcept (UnionM (CBMCEither e v)) UnionM e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Generic (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Associated Types

type Rep (CBMCEither a b) :: Type -> Type #

Methods

from :: CBMCEither a b -> Rep (CBMCEither a b) x #

to :: Rep (CBMCEither a b) x -> CBMCEither a b #

(Read a, Read b) => Read (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Show a, Show b) => Show (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

showsPrec :: Int -> CBMCEither a b -> ShowS #

show :: CBMCEither a b -> String #

showList :: [CBMCEither a b] -> ShowS #

(NFData a, NFData b) => NFData (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

rnf :: CBMCEither a b -> () #

(Eq a, Eq b) => Eq (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

(==) :: CBMCEither a b -> CBMCEither a b -> Bool #

(/=) :: CBMCEither a b -> CBMCEither a b -> Bool #

(Ord a, Ord b) => Ord (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

compare :: CBMCEither a b -> CBMCEither a b -> Ordering #

(<) :: CBMCEither a b -> CBMCEither a b -> Bool #

(<=) :: CBMCEither a b -> CBMCEither a b -> Bool #

(>) :: CBMCEither a b -> CBMCEither a b -> Bool #

(>=) :: CBMCEither a b -> CBMCEither a b -> Bool #

max :: CBMCEither a b -> CBMCEither a b -> CBMCEither a b #

min :: CBMCEither a b -> CBMCEither a b -> CBMCEither a b #

(EvaluateSym a, EvaluateSym b) => EvaluateSym (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

evaluateSym :: Bool -> Model -> CBMCEither a b -> CBMCEither a b Source #

(ExtractSymbolics a, ExtractSymbolics b) => ExtractSymbolics (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Mergeable e, Mergeable a) => Mergeable (CBMCEither e a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(SEq e, SEq a) => SEq (CBMCEither e a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(SOrd a, SOrd b) => SOrd (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Hashable a, Hashable b) => Hashable (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

hashWithSalt :: Int -> CBMCEither a b -> Int #

hash :: CBMCEither a b -> Int #

(GenSymSimple a a, Mergeable a, GenSymSimple b b, Mergeable b) => GenSym (CBMCEither a b) (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m => CBMCEither a b -> m (UnionM (CBMCEither a b)) Source #

(GenSymSimple a a, GenSymSimple b b) => GenSymSimple (CBMCEither a b) (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

simpleFresh :: MonadFresh m => CBMCEither a b -> m (CBMCEither a b) Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (Either e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: Either e1 a1 -> Maybe (CBMCEither e2 a2) Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (CBMCEither e1 a1) (Either e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCEither e1 a1 -> Maybe (Either e2 a2) Source #

(ToCon e1 e2, ToCon a1 a2) => ToCon (CBMCEither e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCEither e1 a1 -> Maybe (CBMCEither e2 a2) Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (Either e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: Either e1 a1 -> CBMCEither e2 a2 Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (CBMCEither e1 a1) (Either e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: CBMCEither e1 a1 -> Either e2 a2 Source #

(ToSym e1 e2, ToSym a1 a2) => ToSym (CBMCEither e1 a1) (CBMCEither e2 a2) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: CBMCEither e1 a1 -> CBMCEither e2 a2 Source #

type Rep (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

type Rep (CBMCEither a b) = D1 ('MetaData "CBMCEither" "Grisette.Internal.Core.Control.Monad.CBMCExcept" "grisette-0.5.0.0-2ZDAuzWdzg48yPrBcRstUR" 'True) (C1 ('MetaCons "CBMCEither" 'PrefixI 'True) (S1 ('MetaSel ('Just "runCBMCEither") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Either a b))))

newtype CBMCExceptT e m a Source #

Similar to ExceptT, but with different error handling mechanism.

Constructors

CBMCExceptT 

Fields

Instances

Instances details
Functor m => Generic1 (CBMCExceptT e m :: Type -> Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Associated Types

type Rep1 (CBMCExceptT e m) :: k -> Type #

Methods

from1 :: forall (a :: k). CBMCExceptT e m a -> Rep1 (CBMCExceptT e m) a #

to1 :: forall (a :: k). Rep1 (CBMCExceptT e m) a -> CBMCExceptT e m a #

Monad m => MonadError e (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

throwError :: e -> CBMCExceptT e m a #

catchError :: CBMCExceptT e m a -> (e -> CBMCExceptT e m a) -> CBMCExceptT e m a #

(GenSym spec (m (CBMCEither a b)), Mergeable1 m, Mergeable a, Mergeable b) => GenSym spec (CBMCExceptT a m b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m0 => spec -> m0 (UnionM (CBMCExceptT a m b)) Source #

GenSymSimple spec (m (CBMCEither a b)) => GenSymSimple spec (CBMCExceptT a m b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

simpleFresh :: MonadFresh m0 => spec -> m0 (CBMCExceptT a m b) Source #

MonadTrans (CBMCExceptT e) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

lift :: Monad m => m a -> CBMCExceptT e m a #

MonadFail m => MonadFail (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fail :: String -> CBMCExceptT e m a #

MonadFix m => MonadFix (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

mfix :: (a -> CBMCExceptT e m a) -> CBMCExceptT e m a #

MonadIO m => MonadIO (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftIO :: IO a -> CBMCExceptT e m a #

MonadZip m => MonadZip (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

mzip :: CBMCExceptT e m a -> CBMCExceptT e m b -> CBMCExceptT e m (a, b) #

mzipWith :: (a -> b -> c) -> CBMCExceptT e m a -> CBMCExceptT e m b -> CBMCExceptT e m c #

munzip :: CBMCExceptT e m (a, b) -> (CBMCExceptT e m a, CBMCExceptT e m b) #

Foldable f => Foldable (CBMCExceptT e f) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fold :: Monoid m => CBMCExceptT e f m -> m #

foldMap :: Monoid m => (a -> m) -> CBMCExceptT e f a -> m #

foldMap' :: Monoid m => (a -> m) -> CBMCExceptT e f a -> m #

foldr :: (a -> b -> b) -> b -> CBMCExceptT e f a -> b #

foldr' :: (a -> b -> b) -> b -> CBMCExceptT e f a -> b #

foldl :: (b -> a -> b) -> b -> CBMCExceptT e f a -> b #

foldl' :: (b -> a -> b) -> b -> CBMCExceptT e f a -> b #

foldr1 :: (a -> a -> a) -> CBMCExceptT e f a -> a #

foldl1 :: (a -> a -> a) -> CBMCExceptT e f a -> a #

toList :: CBMCExceptT e f a -> [a] #

null :: CBMCExceptT e f a -> Bool #

length :: CBMCExceptT e f a -> Int #

elem :: Eq a => a -> CBMCExceptT e f a -> Bool #

maximum :: Ord a => CBMCExceptT e f a -> a #

minimum :: Ord a => CBMCExceptT e f a -> a #

sum :: Num a => CBMCExceptT e f a -> a #

product :: Num a => CBMCExceptT e f a -> a #

(Eq e, Eq1 m) => Eq1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftEq :: (a -> b -> Bool) -> CBMCExceptT e m a -> CBMCExceptT e m b -> Bool #

(Ord e, Ord1 m) => Ord1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftCompare :: (a -> b -> Ordering) -> CBMCExceptT e m a -> CBMCExceptT e m b -> Ordering #

(Read e, Read1 m) => Read1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (CBMCExceptT e m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [CBMCExceptT e m a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (CBMCExceptT e m a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [CBMCExceptT e m a] #

(Show e, Show1 m) => Show1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> CBMCExceptT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [CBMCExceptT e m a] -> ShowS #

Contravariant m => Contravariant (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

contramap :: (a' -> a) -> CBMCExceptT e m a -> CBMCExceptT e m a' #

(>$) :: b -> CBMCExceptT e m b -> CBMCExceptT e m a #

Traversable f => Traversable (CBMCExceptT e f) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

traverse :: Applicative f0 => (a -> f0 b) -> CBMCExceptT e f a -> f0 (CBMCExceptT e f b) #

sequenceA :: Applicative f0 => CBMCExceptT e f (f0 a) -> f0 (CBMCExceptT e f a) #

mapM :: Monad m => (a -> m b) -> CBMCExceptT e f a -> m (CBMCExceptT e f b) #

sequence :: Monad m => CBMCExceptT e f (m a) -> m (CBMCExceptT e f a) #

(Functor m, Monad m, Monoid e) => Alternative (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

empty :: CBMCExceptT e m a #

(<|>) :: CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a #

some :: CBMCExceptT e m a -> CBMCExceptT e m [a] #

many :: CBMCExceptT e m a -> CBMCExceptT e m [a] #

(Functor m, Monad m) => Applicative (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

pure :: a -> CBMCExceptT e m a #

(<*>) :: CBMCExceptT e m (a -> b) -> CBMCExceptT e m a -> CBMCExceptT e m b #

liftA2 :: (a -> b -> c) -> CBMCExceptT e m a -> CBMCExceptT e m b -> CBMCExceptT e m c #

(*>) :: CBMCExceptT e m a -> CBMCExceptT e m b -> CBMCExceptT e m b #

(<*) :: CBMCExceptT e m a -> CBMCExceptT e m b -> CBMCExceptT e m a #

Functor m => Functor (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fmap :: (a -> b) -> CBMCExceptT e m a -> CBMCExceptT e m b #

(<$) :: a -> CBMCExceptT e m b -> CBMCExceptT e m a #

Monad m => Monad (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

(>>=) :: CBMCExceptT e m a -> (a -> CBMCExceptT e m b) -> CBMCExceptT e m b #

(>>) :: CBMCExceptT e m a -> CBMCExceptT e m b -> CBMCExceptT e m b #

return :: a -> CBMCExceptT e m a #

(Monad m, Monoid e) => MonadPlus (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

mzero :: CBMCExceptT e m a #

mplus :: CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a #

(Mergeable1 m, Mergeable e) => Mergeable1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(UnionMergeable1 m, Mergeable e) => SimpleMergeable1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a Source #

(UnionMergeable1 m, Mergeable e) => UnionMergeable1 (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(TryMerge m, Mergeable e) => TryMerge (CBMCExceptT e m) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Generic (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Associated Types

type Rep (CBMCExceptT e m a) :: Type -> Type #

Methods

from :: CBMCExceptT e m a -> Rep (CBMCExceptT e m a) x #

to :: Rep (CBMCExceptT e m a) x -> CBMCExceptT e m a #

(Read e, Read1 m, Read a) => Read (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Show e, Show1 m, Show a) => Show (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

showsPrec :: Int -> CBMCExceptT e m a -> ShowS #

show :: CBMCExceptT e m a -> String #

showList :: [CBMCExceptT e m a] -> ShowS #

(Eq e, Eq1 m, Eq a) => Eq (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

(==) :: CBMCExceptT e m a -> CBMCExceptT e m a -> Bool #

(/=) :: CBMCExceptT e m a -> CBMCExceptT e m a -> Bool #

(Ord e, Ord1 m, Ord a) => Ord (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

compare :: CBMCExceptT e m a -> CBMCExceptT e m a -> Ordering #

(<) :: CBMCExceptT e m a -> CBMCExceptT e m a -> Bool #

(<=) :: CBMCExceptT e m a -> CBMCExceptT e m a -> Bool #

(>) :: CBMCExceptT e m a -> CBMCExceptT e m a -> Bool #

(>=) :: CBMCExceptT e m a -> CBMCExceptT e m a -> Bool #

max :: CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a #

min :: CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a #

EvaluateSym (m (CBMCEither e a)) => EvaluateSym (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

evaluateSym :: Bool -> Model -> CBMCExceptT e m a -> CBMCExceptT e m a Source #

ExtractSymbolics (m (CBMCEither e a)) => ExtractSymbolics (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Mergeable1 m, Mergeable e, Mergeable a) => Mergeable (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

SEq (m (CBMCEither e a)) => SEq (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

(.==) :: CBMCExceptT e m a -> CBMCExceptT e m a -> SymBool Source #

(./=) :: CBMCExceptT e m a -> CBMCExceptT e m a -> SymBool Source #

SOrd (m (CBMCEither e a)) => SOrd (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(UnionMergeable1 m, Mergeable e, Mergeable a) => SimpleMergeable (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

mrgIte :: SymBool -> CBMCExceptT e m a -> CBMCExceptT e m a -> CBMCExceptT e m a Source #

(Monad u, TryMerge u, Mergeable e, Mergeable v) => UnionWithExcept (CBMCExceptT e u v) u e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

extractUnionExcept :: CBMCExceptT e u v -> u (Either e v) Source #

ToCon (m1 (CBMCEither e1 a)) (Either e2 b) => ToCon (CBMCExceptT e1 m1 a) (Either e2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCExceptT e1 m1 a -> Maybe (Either e2 b) Source #

(GenSymSimple (m (CBMCEither e a)) (m (CBMCEither e a)), Mergeable1 m, Mergeable e, Mergeable a) => GenSym (CBMCExceptT e m a) (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

fresh :: MonadFresh m0 => CBMCExceptT e m a -> m0 (UnionM (CBMCExceptT e m a)) Source #

GenSymSimple (m (CBMCEither e a)) (m (CBMCEither e a)) => GenSymSimple (CBMCExceptT e m a) (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

simpleFresh :: MonadFresh m0 => CBMCExceptT e m a -> m0 (CBMCExceptT e m a) Source #

ToCon (m1 (CBMCEither e1 a)) (m2 (CBMCEither e2 b)) => ToCon (CBMCExceptT e1 m1 a) (CBMCExceptT e2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toCon :: CBMCExceptT e1 m1 a -> Maybe (CBMCExceptT e2 m2 b) Source #

ToSym (m1 (CBMCEither e1 a)) (m2 (CBMCEither e2 b)) => ToSym (CBMCExceptT e1 m1 a) (CBMCExceptT e2 m2 b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

toSym :: CBMCExceptT e1 m1 a -> CBMCExceptT e2 m2 b Source #

type Rep1 (CBMCExceptT e m :: Type -> Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

type Rep1 (CBMCExceptT e m :: Type -> Type) = D1 ('MetaData "CBMCExceptT" "Grisette.Internal.Core.Control.Monad.CBMCExcept" "grisette-0.5.0.0-2ZDAuzWdzg48yPrBcRstUR" 'True) (C1 ('MetaCons "CBMCExceptT" 'PrefixI 'True) (S1 ('MetaSel ('Just "runCBMCExceptT") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (m :.: Rec1 (CBMCEither e))))
type Rep (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

type Rep (CBMCExceptT e m a) = D1 ('MetaData "CBMCExceptT" "Grisette.Internal.Core.Control.Monad.CBMCExcept" "grisette-0.5.0.0-2ZDAuzWdzg48yPrBcRstUR" 'True) (C1 ('MetaCons "CBMCExceptT" 'PrefixI 'True) (S1 ('MetaSel ('Just "runCBMCExceptT") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (m (CBMCEither e a)))))

cbmcExcept :: Monad m => Either e a -> CBMCExceptT e m a Source #

Wrap an Either value in CBMCExceptT

mapCBMCExceptT :: (m (Either e a) -> n (Either e' b)) -> CBMCExceptT e m a -> CBMCExceptT e' n b Source #

Map the error and values in a CBMCExceptT

withCBMCExceptT :: Functor m => (e -> e') -> CBMCExceptT e m a -> CBMCExceptT e' m a Source #

Map the error in a CBMCExceptT

Solver backend

Grisette abstracts the solver backend with the Solver type class, and the most basic solver call is the solve function.

In the following code, we will search for the integer solutions to two equation systems. The first equation system, as shown below, has the solution (x, y) = (13, -7).

\[ \left\{ \begin{aligned} x + y &= 6 \\ x - y &= 20 \end{aligned} \right. \]

The second equation system, as shown below, has no integer solutions.

\[ \left\{ \begin{aligned} x + y &= 6 \\ x - y &= 19 \end{aligned} \right. \]

>>> import Grisette.SymPrim
>>> import Grisette.Backend
>>> let x = "x" :: SymInteger
>>> let y = "y" :: SymInteger
>>> solve (precise z3) (x + y .== 6 .&& x - y .== 20)
Right (Model {x -> 13 :: Integer, y -> -7 :: Integer})
>>> solve (precise z3) (x + y .== 6 .&& x - y .== 19)
Left Unsat

The first parameter of solve is the solver configuration. Here it means that we should not perform any approximation, and should use the Z3 solver.

The second parameter is the formula to be solved. It have the type SymBool.

The solve function would return a model if the formula is satisfiable. The model is a mapping from symbolic variables to concrete values, as shown in the following example.

Right (Model {x -> 13 :: Integer, y -> -7 :: Integer})

This model maps x to 13, and y to -7. With this model, we can then evaluate symbolic values. The following code evaluates the product of x and y under the solution of the equation system.

>>> Right m <- solve (precise z3) (x + y .== 6 .&& x - y .== 20)
>>> evaluateSym False m (x * y)
-91

You may notice that the first argument to the evaluateSym function is a Boolean value False. This argument controls whether the evaluation should assign a default value to the symbolic constants that does not appear in the model. When the argument is False, the evaluation would preserve any symbolic constants that does not appear in the model, and partially evaluate the expression. When the argument is True, the evaluation would assign a default value to the symbolic constants that does not appear in the model, e.g., 0 for integers, and the evaluation result would become a concrete value -91.

>>> let z = "z" :: SymInteger
>>> evaluateSym False m (x * y + z)
(+ -91 z)
>>> evaluateSym True m (x * y + z)
-91

Grisette also provides convenient functions to solve problems with error handling. The lambda case function used in the following code means that we would like the solver to find path that would not lead to an error. This is done by mapping left values (failed paths) to false, and right values (successful paths) to true.

The following example finds bugs in a program in the hard way. It is an overkill for such a simple program, but it is a good example to show how to use Grisette to solve problems with error handling.

We can first define the error type used in the program.

>>> :set -XLambdaCase -XDeriveGeneric -XDerivingStrategies -XDerivingVia
>>> import Control.Monad.Except
>>> import Grisette.Lib.Control.Monad.Trans.Except
>>> import Control.Exception
>>> import GHC.Generics
>>> :{
data Error = Arith | Assert
  deriving (Show, Generic)
  deriving (Mergeable, SEq) via (Default Error)
:}

Then we can perform the symbolic evaluation. The divs function throws ArithException when the divisor is 0, which would be transformed to Arith, and the symAssert function would throw AssertionError when the condition is false, which would be transformed to Assert.

>>> let x = "x" :: SymInteger
>>> let y = "y" :: SymInteger
>>> assert = symAssertWith Assert
>>> sdiv l r = mrgWithExceptT (\(_::ArithException) -> Arith) $ safeDiv l r
>>> :{
  -- equivalent concrete program:
  -- let x = x `div` y
  -- if z > 0 then assert (x >= y) else return ()
  res :: ExceptT Error UnionM ()
  res = do
    z <- x `sdiv` y
    mrgIf (z .> 0) (assert (x .>= y)) (return ())
:}

Then we can ask the solver to find a counter-example that would lead to an assertion violation error, but do not trigger the division by zero error. This can be done by asking the solver to find a path that produce Left Assert.

>>> res
ExceptT {If (|| (= y 0) (&& (< 0 (div x y)) (! (<= y x)))) (If (= y 0) (Left Arith) (Left Assert)) (Right ())}
>>> solveExcept (UnboundedReasoning z3) (.== Left Assert) res
Right (Model {x -> -6 :: Integer, y -> -3 :: Integer}) -- possible output

Grisette also provide implementation for counter-example guided inductive synthesis (CEGIS) algorithm. See the documentation for CEGISSolver for more details.

Solver interfaces

data SolvingFailure Source #

The current failures that can be returned by the solver.

Constructors

Unsat

Unsatisfiable: No model is available.

Unk

Unknown: The solver cannot determine whether the formula is satisfiable.

ResultNumLimitReached

The solver has reached the maximum number of models to return.

SolvingError SomeException

The solver has encountered an error.

Terminated

The solver has been terminated.

Instances

Instances details
Show SolvingFailure Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Solver

class MonadicSolver m where Source #

A monadic solver interface.

This interface abstract the monadic interface of a solver. All the operations performed in the monad are using a single solver instance. The solver instance is management by the monad's run function.

data SolverCommand Source #

The commands that can be sent to a solver.

class Solver handle => ConfigurableSolver config handle | config -> handle where Source #

A class that abstracts the creation of a solver instance based on a configuration.

The solver instance will need to be terminated by the user, with the solver interface.

Methods

newSolver :: config -> IO handle Source #

class Solver handle where Source #

A class that abstracts the solver interface.

Methods

solverRunCommand :: (handle -> IO (Either SolvingFailure a)) -> handle -> SolverCommand -> IO (Either SolvingFailure a) Source #

Run a solver command.

solverSolve :: handle -> SymBool -> IO (Either SolvingFailure Model) Source #

Solve a formula.

solverPush :: handle -> Int -> IO (Either SolvingFailure ()) Source #

Push n levels.

solverPop :: handle -> Int -> IO (Either SolvingFailure ()) Source #

Pop n levels.

solverTerminate :: handle -> IO () Source #

Terminate the solver, wait until the last command is finished.

solverForceTerminate :: handle -> IO () Source #

Force terminate the solver, do not wait for the last command to finish.

withSolver :: ConfigurableSolver config handle => config -> (handle -> IO a) -> IO a Source #

Start a solver, run a computation with the solver, and terminate the solver after the computation finishes.

solve Source #

Arguments

:: ConfigurableSolver config handle 
=> config

solver configuration

-> SymBool

formula to solve, the solver will try to make it true

-> IO (Either SolvingFailure Model) 

Solve a single formula. Find an assignment to it to make it true.

>>> solve (precise z3) ("a" .&& ("b" :: SymInteger) .== 1)
Right (Model {a -> True :: Bool, b -> 1 :: Integer})
>>> solve (precise z3) ("a" .&& symNot "a")
Left Unsat

solveMulti Source #

Arguments

:: ConfigurableSolver config handle 
=> config

solver configuration

-> Int

maximum number of models to return

-> SymBool

formula to solve, the solver will try to make it true

-> IO ([Model], SolvingFailure) 

Solve a single formula while returning multiple models to make it true. The maximum number of desired models are given.

>>> solveMulti (precise z3) 4 ("a" .|| "b")
[Model {a -> True :: Bool, b -> False :: Bool},Model {a -> False :: Bool, b -> True :: Bool},Model {a -> True :: Bool, b -> True :: Bool}]

Union with exceptions

class UnionWithExcept t u e v | t -> u e v where Source #

A class that abstracts the union-like structures that contains exceptions.

Methods

extractUnionExcept :: t -> u (Either e v) Source #

Extract a union of exceptions and values from the structure.

Instances

Instances details
UnionWithExcept (UnionM (Either e v)) UnionM e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

UnionWithExcept (UnionM (CBMCEither e v)) UnionM e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(Monad u, TryMerge u, Mergeable e, Mergeable v) => UnionWithExcept (CBMCExceptT e u v) u e v Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

extractUnionExcept :: CBMCExceptT e u v -> u (Either e v) Source #

UnionWithExcept (ExceptT e u v) u e v Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Solver

Methods

extractUnionExcept :: ExceptT e u v -> u (Either e v) Source #

solveExcept Source #

Arguments

:: (UnionWithExcept t u e v, PlainUnion u, Functor u, ConfigurableSolver config handle) 
=> config

solver configuration

-> (Either e v -> SymBool)

mapping the results to symbolic boolean formulas, the solver would try to find a model to make the formula true

-> t

the program to be solved, should be a union of exception and values

-> IO (Either SolvingFailure Model) 

Solver procedure for programs with error handling.

>>> :set -XLambdaCase
>>> import Control.Monad.Except
>>> let x = "x" :: SymInteger
>>> :{
  res :: ExceptT AssertionError UnionM ()
  res = do
    symAssert $ x .> 0       -- constrain that x is positive
    symAssert $ x .< 2       -- constrain that x is less than 2
:}
>>> :{
  translate (Left _) = con False -- errors are not desirable
  translate _ = con True         -- non-errors are desirable
:}
>>> solveExcept (precise z3) translate res
Right (Model {x -> 1 :: Integer})

solveMultiExcept Source #

Arguments

:: (UnionWithExcept t u e v, PlainUnion u, Functor u, ConfigurableSolver config handle) 
=> config

solver configuration

-> Int

maximum number of models to return

-> (Either e v -> SymBool)

mapping the results to symbolic boolean formulas, the solver would try to find a model to make the formula true

-> t

the program to be solved, should be a union of exception and values

-> IO ([Model], SolvingFailure) 

Solver procedure for programs with error handling. Would return multiple models if possible.

Generic Counter-example Guided Inductive Synthesis (CEGIS) interface

type SynthesisConstraintFun input = Int -> input -> IO SymBool Source #

Synthesis constraint function.

The first argument is the iteration number, for angelic programs, you can use it to instantiate the angelic variables in the program.

The second argument is the counter-example generated by the verifier.

The synthesizer will try to find a program that is true for all the synthesis constraints.

data VerifierResult input exception Source #

The result of the verifier.

type StatefulVerifierFun state input exception = state -> Model -> IO (state, VerifierResult input exception) Source #

The verifier function.

The first argument is the state of the verifier.

The second argument is the candidate model proposed by the synthesizer.

data CEGISResult exception Source #

The result of the CEGIS procedure.

Instances

Instances details
Show exception => Show (CEGISResult exception) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.CEGISSolver

Methods

showsPrec :: Int -> CEGISResult exception -> ShowS #

show :: CEGISResult exception -> String #

showList :: [CEGISResult exception] -> ShowS #

genericCEGIS Source #

Arguments

:: ConfigurableSolver config handle 
=> config

Configuration of the solver.

-> SymBool

The initial synthesis constraint.

-> SynthesisConstraintFun input

The synthesis constraint function.

-> verifierState

The initial state of the verifier.

-> StatefulVerifierFun verifierState input exception

The verifier function.

-> IO ([input], CEGISResult exception) 

Generic CEGIS procedure.

The CEGIS procedure will try to find a model that satisfies the initial synthesis constraint, and satisfies all the inputs generated by the verifier.

CEGIS interfaces with pre/post conditions

data CEGISCondition Source #

The condition for CEGIS to solve.

The first argument is the pre-condition, and the second argument is the post-condition.

The CEGIS procedures would try to find a model for the formula

\[ \forall P. (\exists I. \mathrm{pre}(P, I)) \wedge (\forall I. \mathrm{pre}(P, I)\implies \mathrm{post}(P, I)) \]

In program synthesis tasks, \(P\) is the symbolic constants in the symbolic program, and \(I\) is the input. The pre-condition is used to restrict the search space of the program. The procedure would only return programs that meets the pre-conditions on every possible inputs, and there are at least one possible input. The post-condition is used to specify the desired program behaviors.

cegisPostCond :: SymBool -> CEGISCondition Source #

Construct a CEGIS condition with only a post-condition. The pre-condition would be set to true, meaning that all programs in the program space are allowed.

cegisPrePost :: SymBool -> SymBool -> CEGISCondition Source #

Construct a CEGIS condition with both pre- and post-conditions.

cegisMultiInputs :: (EvaluateSym input, ExtractSymbolics input, ConfigurableSolver config handle) => config -> [input] -> (input -> CEGISCondition) -> IO ([input], CEGISResult SolvingFailure) Source #

CEGIS with multiple (possibly symbolic) inputs. Solves the following formula (see CEGISCondition for details).

\[ \forall P. (\exists I\in\mathrm{inputs}. \mathrm{pre}(P, I)) \wedge (\forall I\in\mathrm{inputs}. \mathrm{pre}(P, I)\implies \mathrm{post}(P, I)) \]

For simpler queries, where the inputs are representable by a single symbolic value, you may want to use cegis or cegisExcept instead. We have an example for the cegis call.

cegis Source #

Arguments

:: (ConfigurableSolver config handle, EvaluateSym inputs, ExtractSymbolics inputs, SEq inputs) 
=> config

The configuration of the solver

-> inputs

Initial symbolic inputs. The solver will try to find a program that works on all the inputs representable by it (see CEGISCondition).

-> (inputs -> CEGISCondition)

The condition for the solver to solve. All the symbolic constants that are not in the inputs will be considered as part of the symbolic program.

-> IO ([inputs], CEGISResult SolvingFailure)

The counter-examples generated during the CEGIS loop, and the model found by the solver.

CEGIS with a single symbolic input to represent a set of inputs.

The following example tries to find the value of c such that for all positive x, x * c && c -2. The c .> -2 clause is used to make the solution unique.

>>> :set -XOverloadedStrings
>>> let [x,c] = ["x","c"] :: [SymInteger]
>>> cegis (precise z3) x (\x -> cegisPrePost (x .> 0) (x * c .< 0 .&& c .> -2))
(...,CEGISSuccess (Model {c -> -1 :: Integer}))

cegisExcept :: (UnionWithExcept t u e v, PlainUnion u, Functor u, EvaluateSym inputs, ExtractSymbolics inputs, ConfigurableSolver config handle, SEq inputs) => config -> inputs -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, using a single symbolic input to represent a set of inputs.

cegisExcept is particularly useful when custom error types are used. With cegisExcept, you define how the errors are interpreted to the CEGIS conditions after the symbolic evaluation. This could increase the readability and modularity of the code.

The following example tries to find the value of c such that for all positive x, x * c && c -2. The c .> -2 assertion is used to make the solution unique.

>>> :set -XOverloadedStrings
>>> let [x,c] = ["x","c"] :: [SymInteger]
>>> import Control.Monad.Except
>>> :{
  res :: SymInteger -> ExceptT VerificationConditions UnionM ()
  res x = do
    symAssume $ x .> 0
    symAssert $ x * c .< 0
    symAssert $ c .> -2
:}
>>> :{
  translation (Left AssumptionViolation) = cegisPrePost (con False) (con True)
  translation (Left AssertionViolation) = cegisPostCond (con False)
  translation _ = cegisPostCond (con True)
:}
>>> cegisExcept (precise z3) x translation res
([...],CEGISSuccess (Model {c -> -1 :: Integer}))

cegisExceptStdVC :: (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvaluateSym inputs, ExtractSymbolics inputs, ConfigurableSolver config handle, SEq inputs) => config -> inputs -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, using a single symbolic input to represent a set of inputs. This function saves the efforts to implement the translation function for the standard error type VerificationConditions, and the standard result type ().

This function translates assumption violations to failed pre-conditions, and translates assertion violations to failed post-conditions. The () result will not fail any conditions.

The following example tries to find the value of c such that for all positive x, x * c && c -2. The c .> -2 assertion is used to make the solution unique.

>>> :set -XOverloadedStrings
>>> let [x,c] = ["x","c"] :: [SymInteger]
>>> import Control.Monad.Except
>>> :{
  res :: SymInteger -> ExceptT VerificationConditions UnionM ()
  res x = do
    symAssume $ x .> 0
    symAssert $ x * c .< 0
    symAssert $ c .> -2
:}
>>> cegisExceptStdVC (precise z3) x res
([...],CEGISSuccess (Model {c -> -1 :: Integer}))

cegisExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvaluateSym inputs, ExtractSymbolics inputs, ConfigurableSolver config handle, SEq inputs) => config -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, using a single symbolic input to represent a set of inputs.

The errors should be translated to assertion or assumption violations.

cegisExceptMultiInputs :: (ConfigurableSolver config handle, EvaluateSym inputs, ExtractSymbolics inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => config -> [inputs] -> (Either e v -> CEGISCondition) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs.

cegisExceptStdVCMultiInputs :: (ConfigurableSolver config handle, EvaluateSym inputs, ExtractSymbolics inputs, UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u) => config -> [inputs] -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs. This function saves the efforts to implement the translation function for the standard error type VerificationConditions, and the standard result type ().

This function translates assumption violations to failed pre-conditions, and translates assertion violations to failed post-conditions. The () result will not fail any conditions.

cegisExceptVCMultiInputs :: (ConfigurableSolver config handle, EvaluateSym inputs, ExtractSymbolics inputs, UnionWithExcept t u e v, PlainUnion u, Monad u) => config -> [inputs] -> (Either e v -> u (Either VerificationConditions ())) -> (inputs -> t) -> IO ([inputs], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, using multiple (possibly symbolic) inputs to represent a set of inputs.

The errors should be translated to assertion or assumption violations.

cegisForAll Source #

Arguments

:: (ExtractSymbolics forallInput, ConfigurableSolver config handle) 
=> config 
-> forallInput

A symbolic value. All the symbolic constants in the value are treated as for-all variables.

-> CEGISCondition 
-> IO ([Model], CEGISResult SolvingFailure)

First output are the counter-examples for all the for-all variables, and the second output is the model for all other variables if CEGIS succeeds.

CEGIS with a single symbolic input to represent a set of inputs.

The following example tries to find the value of c such that for all positive x, x * c && c -2. The c .> -2 clause is used to make the solution unique.

>>> :set -XOverloadedStrings
>>> let [x,c] = ["x","c"] :: [SymInteger]
>>> cegisForAll (precise z3) x $ cegisPrePost (x .> 0) (x * c .< 0 .&& c .> -2)
(...,CEGISSuccess (Model {c -> -1 :: Integer}))

cegisForAllExcept :: (UnionWithExcept t u e v, PlainUnion u, Functor u, EvaluateSym inputs, ExtractSymbolics inputs, ConfigurableSolver config handle, SEq inputs) => config -> inputs -> (Either e v -> CEGISCondition) -> t -> IO ([Model], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, with a forall variable.

See cegisForAll and cegisExcept.

cegisForAllExceptStdVC :: (UnionWithExcept t u VerificationConditions (), PlainUnion u, Monad u, EvaluateSym inputs, ExtractSymbolics inputs, ConfigurableSolver config handle, SEq inputs) => config -> inputs -> t -> IO ([Model], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, with a forall variable.

See cegisForAll and cegisExceptStdVC.

cegisForAllExceptVC :: (UnionWithExcept t u e v, PlainUnion u, Monad u, EvaluateSym inputs, ExtractSymbolics inputs, ConfigurableSolver config handle, SEq inputs) => config -> inputs -> (Either e v -> u (Either VerificationConditions ())) -> t -> IO ([Model], CEGISResult SolvingFailure) Source #

CEGIS for symbolic programs with error handling, with a forall variable.

See cegisForAll and cegisExceptVC.

Symbolic constant extraction

class Monoid symbolSet => SymbolSetOps symbolSet (typedSymbol :: Type -> Type) | symbolSet -> typedSymbol where Source #

The operations on symbolic constant sets

Note that symbolic constants with different types are considered different.

>>> let aBool = "a" :: TypedSymbol Bool
>>> let bBool = "b" :: TypedSymbol Bool
>>> let cBool = "c" :: TypedSymbol Bool
>>> let aInteger = "a" :: TypedSymbol Integer
>>> emptySet :: SymbolSet
SymbolSet {}
>>> containsSymbol aBool (buildSymbolSet aBool :: SymbolSet)
True
>>> containsSymbol bBool (buildSymbolSet aBool :: SymbolSet)
False
>>> insertSymbol aBool (buildSymbolSet aBool :: SymbolSet)
SymbolSet {a :: Bool}
>>> insertSymbol aInteger (buildSymbolSet aBool :: SymbolSet)
SymbolSet {a :: Bool, a :: Integer}
>>> let abSet = buildSymbolSet (aBool, bBool) :: SymbolSet
>>> let acSet = buildSymbolSet (aBool, cBool) :: SymbolSet
>>> intersectionSet abSet acSet
SymbolSet {a :: Bool}
>>> unionSet abSet acSet
SymbolSet {a :: Bool, b :: Bool, c :: Bool}
>>> differenceSet abSet acSet
SymbolSet {b :: Bool}

Methods

emptySet :: symbolSet Source #

Construct an empty set

isEmptySet :: symbolSet -> Bool Source #

Check if the set is empty

containsSymbol :: forall a. typedSymbol a -> symbolSet -> Bool Source #

Check if the set contains the given symbol

insertSymbol :: forall a. typedSymbol a -> symbolSet -> symbolSet Source #

Insert a symbol into the set

intersectionSet :: symbolSet -> symbolSet -> symbolSet Source #

Set intersection

unionSet :: symbolSet -> symbolSet -> symbolSet Source #

Set union

differenceSet :: symbolSet -> symbolSet -> symbolSet Source #

Set difference

class SymbolSetOps symbolSet typedSymbol => SymbolSetRep rep symbolSet (typedSymbol :: Type -> Type) where Source #

A type class for building a symbolic constant set manually from a symbolic constant set representation

>>> buildSymbolSet ("a" :: TypedSymbol Bool, "b" :: TypedSymbol Bool) :: SymbolSet
SymbolSet {a :: Bool, b :: Bool}

Methods

buildSymbolSet :: rep -> symbolSet Source #

Build a symbolic constant set

Instances

Instances details
SymbolSetRep (TypedSymbol t) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b, TypedSymbol c) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b, TypedSymbol c, TypedSymbol d) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b, TypedSymbol c, TypedSymbol d, TypedSymbol e) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b, TypedSymbol c, TypedSymbol d, TypedSymbol e, TypedSymbol f) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b, TypedSymbol c, TypedSymbol d, TypedSymbol e, TypedSymbol f, TypedSymbol g) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol a, TypedSymbol b, TypedSymbol c, TypedSymbol d, TypedSymbol e, TypedSymbol f, TypedSymbol g, TypedSymbol h) SymbolSet TypedSymbol Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

class ExtractSymbolics a where Source #

Extracts all the symbolic variables that are transitively contained in the given value.

>>> extractSymbolics ("a" :: SymBool) :: SymbolSet
SymbolSet {a :: Bool}
>>> extractSymbolics (mrgIf "a" (mrgReturn ["b"]) (mrgReturn ["c", "d"]) :: UnionM [SymBool]) :: SymbolSet
SymbolSet {a :: Bool, b :: Bool, c :: Bool, d :: Bool}

Note 1: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ... deriving Generic deriving ExtractSymbolics via (Default X)

Instances

Instances details
ExtractSymbolics Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics a => ExtractSymbolics (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(Generic a, ExtractSymbolics' (Rep a)) => ExtractSymbolics (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics a => ExtractSymbolics (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

(KnownNat n, 1 <= n) => ExtractSymbolics (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(KnownNat n, 1 <= n) => ExtractSymbolics (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(forall (n :: Nat). (KnownNat n, 1 <= n) => ExtractSymbolics (bv n)) => ExtractSymbolics (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

(KnownNat n, 1 <= n) => ExtractSymbolics (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(KnownNat n, 1 <= n) => ExtractSymbolics (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics a => ExtractSymbolics (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics a => ExtractSymbolics [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(ExtractSymbolics a, ExtractSymbolics b) => ExtractSymbolics (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(ExtractSymbolics a, ExtractSymbolics b) => ExtractSymbolics (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => ExtractSymbolics (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (sa -~> sb) -> SymbolSet Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => ExtractSymbolics (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (sa =~> sb) -> SymbolSet Source #

ExtractSymbolics (m (Maybe a)) => ExtractSymbolics (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(ExtractSymbolics a, ExtractSymbolics b) => ExtractSymbolics (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b) -> SymbolSet Source #

ExtractSymbolics (m (CBMCEither e a)) => ExtractSymbolics (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

ExtractSymbolics (m (Either e a)) => ExtractSymbolics (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics (m a) => ExtractSymbolics (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics (m (a, s)) => ExtractSymbolics (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

ExtractSymbolics (m (a, s)) => ExtractSymbolics (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c) => ExtractSymbolics (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b, c) -> SymbolSet Source #

(ExtractSymbolics (f a), ExtractSymbolics (g a)) => ExtractSymbolics (Sum f g a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c, ExtractSymbolics d) => ExtractSymbolics (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b, c, d) -> SymbolSet Source #

(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c, ExtractSymbolics d, ExtractSymbolics e) => ExtractSymbolics (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b, c, d, e) -> SymbolSet Source #

(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c, ExtractSymbolics d, ExtractSymbolics e, ExtractSymbolics f) => ExtractSymbolics (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b, c, d, e, f) -> SymbolSet Source #

(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c, ExtractSymbolics d, ExtractSymbolics e, ExtractSymbolics f, ExtractSymbolics g) => ExtractSymbolics (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b, c, d, e, f, g) -> SymbolSet Source #

(ExtractSymbolics a, ExtractSymbolics b, ExtractSymbolics c, ExtractSymbolics d, ExtractSymbolics e, ExtractSymbolics f, ExtractSymbolics g, ExtractSymbolics h) => ExtractSymbolics (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

Methods

extractSymbolics :: (a, b, c, d, e, f, g, h) -> SymbolSet Source #

Evaluation with a model

When given a satisfiable formula, a solver can return a model that specifies the concrete assignments of the variables in the formula to make the formula true. We can use this model to evaluate some symbolic values by substituting the symbolic constants with the concrete assignments.

class SymbolSetOps symbolSet typedSymbol => ModelOps model symbolSet typedSymbol | model -> symbolSet typedSymbol where Source #

The operations on Models.

Note that symbolic constants with different types are considered different.

>>> let aBool = "a" :: TypedSymbol Bool
>>> let bBool = "b" :: TypedSymbol Bool
>>> let cBool = "c" :: TypedSymbol Bool
>>> let aInteger = "a" :: TypedSymbol Integer
>>> emptyModel :: Model
Model {}
>>> valueOf aBool (buildModel (aBool ::= True) :: Model)
Just True
>>> valueOf bBool (buildModel (aBool ::= True) :: Model)
Nothing
>>> insertValue bBool False (buildModel (aBool ::= True) :: Model)
Model {a -> True :: Bool, b -> False :: Bool}
>>> let abModel = buildModel (aBool ::= True, bBool ::= False) :: Model
>>> let acSet = buildSymbolSet (aBool, cBool) :: SymbolSet
>>> exceptFor acSet abModel
Model {b -> False :: Bool}
>>> restrictTo acSet abModel
Model {a -> True :: Bool}
>>> extendTo acSet abModel
Model {a -> True :: Bool, b -> False :: Bool, c -> False :: Bool}
>>> exact acSet abModel
Model {a -> True :: Bool, c -> False :: Bool}

Methods

emptyModel :: model Source #

Construct an empty model

isEmptyModel :: model -> Bool Source #

Check if the model is empty

modelContains :: typedSymbol a -> model -> Bool Source #

Check if the model contains the given symbol

valueOf :: typedSymbol t -> model -> Maybe t Source #

Extract the assigned value for a given symbolic constant

insertValue :: typedSymbol t -> t -> model -> model Source #

Insert an assignment into the model

exceptFor :: symbolSet -> model -> model Source #

Returns a model that removed all the assignments for the symbolic constants in the set

exceptFor' :: typedSymbol t -> model -> model Source #

Returns a model that removed the assignments for the symbolic constants

restrictTo :: symbolSet -> model -> model Source #

Returns a model that only keeps the assignments for the symbolic constants in the set

extendTo :: symbolSet -> model -> model Source #

Returns a model that extends the assignments for the symbolic constants in the set by assigning default values to them

exact :: symbolSet -> model -> model Source #

Returns a model that contains the assignments for exactly the symbolic constants in the set by removing assignments for the symbolic constants that are not in the set and add assignments for the missing symbolic constants by assigning default values to them.

class ModelRep rep model | rep -> model where Source #

A type class for building a model manually from a model representation

Methods

buildModel :: rep -> model Source #

Build a model

>>> let aBool = "a" :: TypedSymbol Bool
>>> let bBool = "b" :: TypedSymbol Bool
>>> buildModel (aBool ::= True, bBool ::= False) :: Model
Model {a -> True :: Bool, b -> False :: Bool}

Instances

Instances details
ModelRep (ModelValuePair t) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

ModelRep (ModelSymPair ct st) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.ModelRep

Methods

buildModel :: ModelSymPair ct st -> Model Source #

(ModelRep a Model, ModelRep b Model) => ModelRep (a, b) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model) => ModelRep (a, b, c) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model) => ModelRep (a, b, c, d) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model) => ModelRep (a, b, c, d, e) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model, ModelRep f Model) => ModelRep (a, b, c, d, e, f) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e, f) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model, ModelRep f Model, ModelRep g Model) => ModelRep (a, b, c, d, e, f, g) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e, f, g) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model, ModelRep f Model, ModelRep g Model, ModelRep h Model) => ModelRep (a, b, c, d, e, f, g, h) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e, f, g, h) -> Model Source #

class EvaluateSym a where Source #

Evaluating symbolic values with some model.

>>> let model = insertValue "a" (1 :: Integer) emptyModel :: Model
>>> evaluateSym False model ([ssym "a", ssym "b"] :: [SymInteger])
[1,b]

If we set the first argument true, the missing variables will be filled in with some default values:

>>> evaluateSym True model ([ssym "a", ssym "b"] :: [SymInteger])
[1,0]

Note 1: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ... deriving Generic deriving EvaluateSym via (Default X)

Methods

evaluateSym :: Bool -> Model -> a -> a Source #

Evaluate a symbolic variable with some model, possibly fill in values for the missing variables.

Instances

Instances details
EvaluateSym Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Int16 -> Int16 Source #

EvaluateSym Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Int32 -> Int32 Source #

EvaluateSym Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Int64 -> Int64 Source #

EvaluateSym Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Int8 -> Int8 Source #

EvaluateSym Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Word8 -> Word8 Source #

EvaluateSym ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym AssertionError Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym VerificationConditions Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym CEGISCondition Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.CEGISSolver

EvaluateSym SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Text -> Text Source #

EvaluateSym Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

EvaluateSym () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> () -> () Source #

EvaluateSym Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Bool -> Bool Source #

EvaluateSym Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Char -> Char Source #

EvaluateSym Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Int -> Int Source #

EvaluateSym Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Word -> Word Source #

EvaluateSym a => EvaluateSym (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Identity a -> Identity a Source #

(Generic a, EvaluateSym' (Rep a)) => EvaluateSym (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Default a -> Default a Source #

(Mergeable a, EvaluateSym a) => EvaluateSym (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

evaluateSym :: Bool -> Model -> UnionM a -> UnionM a Source #

(KnownNat n, 1 <= n) => EvaluateSym (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> IntN n -> IntN n Source #

(KnownNat n, 1 <= n) => EvaluateSym (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> WordN n -> WordN n Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => EvaluateSym (bv n)) => EvaluateSym (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

evaluateSym :: Bool -> Model -> SomeBV bv -> SomeBV bv Source #

(KnownNat n, 1 <= n) => EvaluateSym (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> SymIntN n -> SymIntN n Source #

(KnownNat n, 1 <= n) => EvaluateSym (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> SymWordN n -> SymWordN n Source #

EvaluateSym a => EvaluateSym (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Maybe a -> Maybe a Source #

EvaluateSym a => EvaluateSym [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> [a] -> [a] Source #

(EvaluateSym a, EvaluateSym b) => EvaluateSym (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Either a b -> Either a b Source #

(EvaluateSym a, EvaluateSym b) => EvaluateSym (CBMCEither a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

evaluateSym :: Bool -> Model -> CBMCEither a b -> CBMCEither a b Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => EvaluateSym (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (sa -~> sb) -> sa -~> sb Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => EvaluateSym (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (sa =~> sb) -> sa =~> sb Source #

EvaluateSym (m (Maybe a)) => EvaluateSym (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> MaybeT m a -> MaybeT m a Source #

(EvaluateSym a, EvaluateSym b) => EvaluateSym (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b) -> (a, b) Source #

EvaluateSym (m (CBMCEither e a)) => EvaluateSym (CBMCExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.CBMCExcept

Methods

evaluateSym :: Bool -> Model -> CBMCExceptT e m a -> CBMCExceptT e m a Source #

EvaluateSym (m (Either e a)) => EvaluateSym (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> ExceptT e m a -> ExceptT e m a Source #

EvaluateSym (m a) => EvaluateSym (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> IdentityT m a -> IdentityT m a Source #

EvaluateSym (m (a, s)) => EvaluateSym (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> WriterT s m a -> WriterT s m a Source #

EvaluateSym (m (a, s)) => EvaluateSym (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> WriterT s m a -> WriterT s m a Source #

(EvaluateSym a, EvaluateSym b, EvaluateSym c) => EvaluateSym (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b, c) -> (a, b, c) Source #

(EvaluateSym (f a), EvaluateSym (g a)) => EvaluateSym (Sum f g a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Sum f g a -> Sum f g a Source #

(EvaluateSym a, EvaluateSym b, EvaluateSym c, EvaluateSym d) => EvaluateSym (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b, c, d) -> (a, b, c, d) Source #

(EvaluateSym a, EvaluateSym b, EvaluateSym c, EvaluateSym d, EvaluateSym e) => EvaluateSym (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

(EvaluateSym a, EvaluateSym b, EvaluateSym c, EvaluateSym d, EvaluateSym e, EvaluateSym f) => EvaluateSym (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

(EvaluateSym a, EvaluateSym b, EvaluateSym c, EvaluateSym d, EvaluateSym e, EvaluateSym f, EvaluateSym g) => EvaluateSym (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

(EvaluateSym a, EvaluateSym b, EvaluateSym c, EvaluateSym d, EvaluateSym e, EvaluateSym f, EvaluateSym g, EvaluateSym h) => EvaluateSym (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source #

evaluateSymToCon :: (ToCon a b, EvaluateSym a) => Model -> a -> b Source #

Evaluate a symbolic variable with some model, fill in values for the missing variables, and transform to concrete ones

>>> let model = insertValue "a" (1 :: Integer) emptyModel :: Model
>>> evaluateSymToCon model ([ssym "a", ssym "b"] :: [SymInteger]) :: [Integer]
[1,0]

Substitution of a symbol

class SubstituteSym a where Source #

Substitution of symbolic constants.

>>> a = "a" :: TypedSymbol Bool
>>> v = "x" .&& "y" :: SymBool
>>> substituteSym a v (["a" .&& "b", "a"] :: [SymBool])
[(&& (&& x y) b),(&& x y)]

Note 1: This type class can be derived for algebraic data types. You may need the DerivingVia and DerivingStrategies extensions.

data X = ... deriving Generic deriving SubstituteSym via (Default X)

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> a -> a Source #

Instances

Instances details
SubstituteSym Int16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Int16 -> Int16 Source #

SubstituteSym Int32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Int32 -> Int32 Source #

SubstituteSym Int64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Int64 -> Int64 Source #

SubstituteSym Int8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Int8 -> Int8 Source #

SubstituteSym Word16 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Word16 -> Word16 Source #

SubstituteSym Word32 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Word32 -> Word32 Source #

SubstituteSym Word64 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Word64 -> Word64 Source #

SubstituteSym Word8 Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Word8 -> Word8 Source #

SubstituteSym ByteString Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> ByteString -> ByteString Source #

SubstituteSym SymBool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> SymBool -> SymBool Source #

SubstituteSym SymInteger Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> SymInteger -> SymInteger Source #

SubstituteSym Text Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Text -> Text Source #

SubstituteSym Integer Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Integer -> Integer Source #

SubstituteSym () Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> () -> () Source #

SubstituteSym Bool Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Bool -> Bool Source #

SubstituteSym Char Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Char -> Char Source #

SubstituteSym Int Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Int -> Int Source #

SubstituteSym Word Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Word -> Word Source #

SubstituteSym a => SubstituteSym (Identity a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Identity a -> Identity a Source #

(Generic a, SubstituteSym' (Rep a)) => SubstituteSym (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Default a -> Default a Source #

(Mergeable a, SubstituteSym a) => SubstituteSym (UnionM a) Source # 
Instance details

Defined in Grisette.Internal.Core.Control.Monad.UnionM

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> UnionM a -> UnionM a Source #

(KnownNat n, 1 <= n) => SubstituteSym (IntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> IntN n -> IntN n Source #

(KnownNat n, 1 <= n) => SubstituteSym (WordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> WordN n -> WordN n Source #

(forall (n :: Nat). (KnownNat n, 1 <= n) => SubstituteSym (bv n)) => SubstituteSym (SomeBV bv) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.SomeBV

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> SomeBV bv -> SomeBV bv Source #

(KnownNat n, 1 <= n) => SubstituteSym (SymIntN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> SymIntN n -> SymIntN n Source #

(KnownNat n, 1 <= n) => SubstituteSym (SymWordN n) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> SymWordN n -> SymWordN n Source #

SubstituteSym a => SubstituteSym (Maybe a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Maybe a -> Maybe a Source #

SubstituteSym a => SubstituteSym [a] Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> [a] -> [a] Source #

(SubstituteSym a, SubstituteSym b) => SubstituteSym (Either a b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Either a b -> Either a b Source #

(SupportedPrim (ca --> cb), LinkedRep ca sa, LinkedRep cb sb) => SubstituteSym (sa -~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb0 => TypedSymbol cb -> sb0 -> (sa -~> sb) -> sa -~> sb Source #

(SupportedPrim (ca =-> cb), LinkedRep ca sa, LinkedRep cb sb) => SubstituteSym (sa =~> sb) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb0 => TypedSymbol cb -> sb0 -> (sa =~> sb) -> sa =~> sb Source #

SubstituteSym (m (Maybe a)) => SubstituteSym (MaybeT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> MaybeT m a -> MaybeT m a Source #

(SubstituteSym a, SubstituteSym b) => SubstituteSym (a, b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b) -> (a, b) Source #

SubstituteSym (m (Either e a)) => SubstituteSym (ExceptT e m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> ExceptT e m a -> ExceptT e m a Source #

SubstituteSym (m a) => SubstituteSym (IdentityT m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> IdentityT m a -> IdentityT m a Source #

SubstituteSym (m (a, s)) => SubstituteSym (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> WriterT s m a -> WriterT s m a Source #

SubstituteSym (m (a, s)) => SubstituteSym (WriterT s m a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> WriterT s m a -> WriterT s m a Source #

(SubstituteSym a, SubstituteSym b, SubstituteSym c) => SubstituteSym (a, b, c) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b, c) -> (a, b, c) Source #

(SubstituteSym (f a), SubstituteSym (g a)) => SubstituteSym (Sum f g a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Sum f g a -> Sum f g a Source #

(SubstituteSym a, SubstituteSym b, SubstituteSym c, SubstituteSym d) => SubstituteSym (a, b, c, d) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b, c, d) -> (a, b, c, d) Source #

(SubstituteSym a, SubstituteSym b, SubstituteSym c, SubstituteSym d, SubstituteSym e) => SubstituteSym (a, b, c, d, e) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

(SubstituteSym a, SubstituteSym b, SubstituteSym c, SubstituteSym d, SubstituteSym e, SubstituteSym f) => SubstituteSym (a, b, c, d, e, f) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

(SubstituteSym a, SubstituteSym b, SubstituteSym c, SubstituteSym d, SubstituteSym e, SubstituteSym f, SubstituteSym g) => SubstituteSym (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

(SubstituteSym a, SubstituteSym b, SubstituteSym c, SubstituteSym d, SubstituteSym e, SubstituteSym f, SubstituteSym g, SubstituteSym h) => SubstituteSym (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source #

class SubstituteSym' a where Source #

Auxiliary class for SubstituteSym instance derivation

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> a c -> a c Source #

Auxiliary function for substituteSym derivation

Instances

Instances details
SubstituteSym' (U1 :: Type -> Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> U1 c -> U1 c Source #

SubstituteSym' (V1 :: Type -> Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> V1 c -> V1 c Source #

(SubstituteSym' a, SubstituteSym' b) => SubstituteSym' (a :*: b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a :*: b) c -> (a :*: b) c Source #

(SubstituteSym' a, SubstituteSym' b) => SubstituteSym' (a :+: b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> (a :+: b) c -> (a :+: b) c Source #

SubstituteSym c => SubstituteSym' (K1 i c :: Type -> Type) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> K1 i c c0 -> K1 i c c0 Source #

SubstituteSym' a => SubstituteSym' (M1 i c a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym' :: LinkedRep cb sb => TypedSymbol cb -> sb -> M1 i c a c0 -> M1 i c a c0 Source #

Type Class Derivation

newtype Default a #

This newtype wrapper can be used to derive default instances for classes taking an argument of kind Type.

Constructors

Default 

Fields

Instances

Instances details
(Generic a, Generic b, ToCon' (Rep a) (Rep b)) => ToCon a (Default b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToCon

Methods

toCon :: a -> Maybe (Default b) Source #

(Generic a, Generic b, ToSym' (Rep a) (Rep b)) => ToSym a (Default b) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ToSym

Methods

toSym :: a -> Default b Source #

(Generic a, GEq a, Enum' (Rep a)) => GEnum (Default a)

The Enum class in base is slightly different; it comprises toEnum and fromEnum. Generics.Deriving.Enum provides functions toEnumDefault and fromEnumDefault.

Instance details

Defined in Generics.Deriving.Default

Methods

genum :: [Default a] #

(Generic a, GEq' (Rep a)) => GEq (Default a) 
Instance details

Defined in Generics.Deriving.Default

Methods

geq :: Default a -> Default a -> Bool #

(Generic a, GMonoid' (Rep a)) => GMonoid (Default a) 
Instance details

Defined in Generics.Deriving.Default

Methods

gmempty :: Default a #

gmappend :: Default a -> Default a -> Default a #

gmconcat :: [Default a] -> Default a #

(Generic a, GSemigroup' (Rep a)) => GSemigroup (Default a)

Semigroups often have many sensible implementations of <> / gsappend, and therefore no sensible default. Indeed, there is no GSemigroup' instance for representations of sum types.

In other cases, one may wish to use the existing wrapper newtypes in base, such as the following (using First):

newtype FirstSemigroup = FirstSemigroup Bool
  deriving stock (Eq, Show)
  deriving (GSemigroup) via (First Bool)
Instance details

Defined in Generics.Deriving.Default

Methods

gsappend :: Default a -> Default a -> Default a #

gstimes :: Integral b => b -> Default a -> Default a #

gsconcat :: NonEmpty (Default a) -> Default a #

(Generic a, GShow' (Rep a)) => GShow (Default a)

For example, with this type:

newtype TestShow = TestShow Bool
  deriving (GShow) via (Default Bool)

gshow for TestShow would produce the same string as gshow for Bool.

In this example, TestShow requires no Generic instance, as the constraint on gshowsPrec from Default Bool is Generic Bool.

In general, when using a newtype wrapper, the instance can be derived via the wrapped type, as here (via Default Bool rather than Default TestShow).

Instance details

Defined in Generics.Deriving.Default

(Generic a, Uniplate' (Rep a) a, Context' (Rep a) a) => Uniplate (Default a) 
Instance details

Defined in Generics.Deriving.Default

Methods

children :: Default a -> [Default a] #

context :: Default a -> [Default a] -> Default a #

descend :: (Default a -> Default a) -> Default a -> Default a #

descendM :: Monad m => (Default a -> m (Default a)) -> Default a -> m (Default a) #

transform :: (Default a -> Default a) -> Default a -> Default a #

transformM :: Monad m => (Default a -> m (Default a)) -> Default a -> m (Default a) #

(Generic a, EvaluateSym' (Rep a)) => EvaluateSym (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.EvaluateSym

Methods

evaluateSym :: Bool -> Model -> Default a -> Default a Source #

(Generic a, ExtractSymbolics' (Rep a)) => ExtractSymbolics (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.ExtractSymbolics

(Generic a, GPretty' (Rep a)) => GPretty (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.GPretty

Methods

gpretty :: Default a -> Doc ann Source #

gprettyPrec :: Int -> Default a -> Doc ann Source #

gprettyList :: [Default a] -> Doc ann Source #

(Generic a, Mergeable' (Rep a)) => Mergeable (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

(Generic a, SEq' (Rep a)) => SEq (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SEq

(SEq a, Generic a, SOrd' (Rep a)) => SOrd (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SOrd

(Generic a, Mergeable' (Rep a), SimpleMergeable' (Rep a)) => SimpleMergeable (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SimpleMergeable

Methods

mrgIte :: SymBool -> Default a -> Default a -> Default a Source #

(Generic a, SubstituteSym' (Rep a)) => SubstituteSym (Default a) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.SubstituteSym

Methods

substituteSym :: LinkedRep cb sb => TypedSymbol cb -> sb -> Default a -> Default a Source #

(Generic a, AllSyms' (Rep a)) => AllSyms (Default a) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.AllSyms

newtype Default1 (f :: Type -> Type) a #

This newtype wrapper can be used to derive default instances for classes taking an argument of kind Type -> Type.

Constructors

Default1 

Fields

Instances

Instances details
(Generic1 f, GCopoint' (Rep1 f)) => GCopoint (Default1 f) 
Instance details

Defined in Generics.Deriving.Default

Methods

gcopoint :: Default1 f a -> a #

(Generic1 t, GFoldable' (Rep1 t)) => GFoldable (Default1 t) 
Instance details

Defined in Generics.Deriving.Default

Methods

gfoldMap :: Monoid m => (a -> m) -> Default1 t a -> m #

gfold :: Monoid m => Default1 t m -> m #

gfoldr :: (a -> b -> b) -> b -> Default1 t a -> b #

gfoldr' :: (a -> b -> b) -> b -> Default1 t a -> b #

gfoldl :: (a -> b -> a) -> a -> Default1 t b -> a #

gfoldl' :: (a -> b -> a) -> a -> Default1 t b -> a #

gfoldr1 :: (a -> a -> a) -> Default1 t a -> a #

gfoldl1 :: (a -> a -> a) -> Default1 t a -> a #

(Generic1 f, GFunctor' (Rep1 f)) => GFunctor (Default1 f) 
Instance details

Defined in Generics.Deriving.Default

Methods

gmap :: (a -> b) -> Default1 f a -> Default1 f b #

(Generic1 t, GFunctor' (Rep1 t), GFoldable' (Rep1 t), GTraversable' (Rep1 t)) => GTraversable (Default1 t) 
Instance details

Defined in Generics.Deriving.Default

Methods

gtraverse :: Applicative f => (a -> f b) -> Default1 t a -> f (Default1 t b) #

gsequenceA :: Applicative f => Default1 t (f a) -> f (Default1 t a) #

gmapM :: Monad m => (a -> m b) -> Default1 t a -> m (Default1 t b) #

gsequence :: Monad m => Default1 t (m a) -> m (Default1 t a) #

(Generic1 u, Mergeable1' (Rep1 u)) => Mergeable1 (Default1 u) Source # 
Instance details

Defined in Grisette.Internal.Core.Data.Class.Mergeable

Utilities

Memoization

htmemo :: (Eq k, Hashable k) => (k -> a) -> k -> a Source #

Function memoizer with mutable hash table.

htmemo2 :: (Eq k1, Hashable k1, Eq k2, Hashable k2) => (k1 -> k2 -> a) -> k1 -> k2 -> a Source #

Function memoizer with mutable hash table. Works on binary functions.

htmemo3 :: (Eq k1, Hashable k1, Eq k2, Hashable k2, Eq k3, Hashable k3) => (k1 -> k2 -> k3 -> a) -> k1 -> k2 -> k3 -> a Source #

Function memoizer with mutable hash table. Works on ternary functions.

htmup :: (Eq k, Hashable k) => (b -> c) -> (k -> b) -> k -> c Source #

Lift a memoizer to work with one more argument.

htmemoFix :: (Eq k, Hashable k) => ((k -> a) -> k -> a) -> k -> a Source #

Memoizing recursion. Use like fix.

Template Haskell

mkMergeConstructor Source #

Arguments

:: String

Prefix for generated wrappers

-> Name

The type to generate the wrappers for

-> Q [Dec] 

Generate constructor wrappers that wraps the result in a container with TryMerge.

mkMergeConstructor "mrg" ''Maybe

generates

mrgJust :: (Mergeable (Maybe a), Applicative m, TryMerge m) => m (Maybe a)
mrgNothing = mrgSingle Nothing
mrgJust :: (Mergeable (Maybe a), Applicative m, TryMerge m) => a -> m (Maybe a)
mrgJust = \x -> mrgSingle (Just x)

mkMergeConstructor' Source #

Arguments

:: [String]

Names for generated wrappers

-> Name

The type to generate the wrappers for

-> Q [Dec] 

Generate constructor wrappers that wraps the result in a container with TryMerge with provided names.

mkMergeConstructor' ["mrgTuple2"] ''(,)

generates

mrgTuple2 :: (Mergeable (a, b), Applicative m, TryMerge m) => a -> b -> u (a, b)
mrgTuple2 = \v1 v2 -> mrgSingle (v1, v2)