Copyright | (c) Brian Schroeder Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Data.SBV.Trans.Control
Description
More generalized alternative to Data.SBV.Control
for advanced client use
Synopsis
- class MonadIO m => ExtractIO (m :: Type -> Type) where
- class Monad m => MonadQuery (m :: Type -> Type) where
- queryState :: m State
- data QueryT (m :: Type -> Type) a
- type Query = QueryT IO
- query :: forall (m :: Type -> Type) a. ExtractIO m => QueryT m a -> SymbolicT m a
- data CheckSatResult
- checkSat :: (MonadIO m, MonadQuery m) => m CheckSatResult
- ensureSat :: (MonadIO m, MonadQuery m) => m ()
- checkSatUsing :: (MonadIO m, MonadQuery m) => String -> m CheckSatResult
- checkSatAssuming :: (MonadIO m, MonadQuery m) => [SBool] -> m CheckSatResult
- checkSatAssumingWithUnsatisfiableSet :: (MonadIO m, MonadQuery m) => [SBool] -> m (CheckSatResult, Maybe [SBool])
- getValue :: (MonadIO m, MonadQuery m, SymVal a) => SBV a -> m a
- getFunction :: (MonadIO m, MonadQuery m, SolverContext m, MonadSymbolic m, SymVal a, SymVal r, SMTFunction fun a r) => fun -> m (Either (String, (Bool, Maybe [String], SExpr)) ([(a, r)], r))
- getUninterpretedValue :: (MonadIO m, MonadQuery m, HasKind a) => SBV a -> m String
- getModel :: (MonadIO m, MonadQuery m) => m SMTModel
- getAssignment :: (MonadIO m, MonadQuery m) => m [(String, Bool)]
- getSMTResult :: (MonadIO m, MonadQuery m) => m SMTResult
- getUnknownReason :: (MonadIO m, MonadQuery m) => m SMTReasonUnknown
- getObservables :: (MonadIO m, MonadQuery m) => m [(Name, CV)]
- getUnsatCore :: (MonadIO m, MonadQuery m) => m [String]
- getProof :: (MonadIO m, MonadQuery m) => m String
- getInterpolantMathSAT :: (MonadIO m, MonadQuery m) => [String] -> m String
- getInterpolantZ3 :: (MonadIO m, MonadQuery m) => [SBool] -> m String
- getAbduct :: (SolverContext m, MonadIO m, MonadQuery m) => Maybe String -> String -> SBool -> m String
- getAbductNext :: (MonadIO m, MonadQuery m) => m String
- getAssertions :: (MonadIO m, MonadQuery m) => m [String]
- data SMTInfoFlag
- data SMTErrorBehavior
- data SMTInfoResponse
- getInfo :: (MonadIO m, MonadQuery m) => SMTInfoFlag -> m SMTInfoResponse
- getOption :: (MonadIO m, MonadQuery m) => (a -> SMTOption) -> m (Maybe SMTOption)
- getAssertionStackDepth :: (MonadIO m, MonadQuery m) => m Int
- push :: (MonadIO m, MonadQuery m) => Int -> m ()
- pop :: (MonadIO m, MonadQuery m) => Int -> m ()
- inNewAssertionStack :: (MonadIO m, MonadQuery m) => m a -> m a
- caseSplit :: (MonadIO m, MonadQuery m) => Bool -> [(String, SBool)] -> m (Maybe (String, SMTResult))
- resetAssertions :: (MonadIO m, MonadQuery m) => m ()
- (|->) :: SymVal a => SBV a -> a -> Assignment
- mkSMTResult :: (MonadIO m, MonadQuery m) => [Assignment] -> m SMTResult
- exit :: (MonadIO m, MonadQuery m) => m ()
- ignoreExitCode :: SMTConfig -> Bool
- timeout :: (MonadIO m, MonadQuery m) => Int -> m a -> m a
- queryDebug :: (MonadIO m, MonadQuery m) => [String] -> m ()
- echo :: (MonadIO m, MonadQuery m) => String -> m ()
- io :: MonadIO m => IO a -> m a
- data SMTOption
- = DiagnosticOutputChannel FilePath
- | ProduceAssertions Bool
- | ProduceAssignments Bool
- | ProduceProofs Bool
- | ProduceInterpolants Bool
- | ProduceUnsatAssumptions Bool
- | ProduceUnsatCores Bool
- | ProduceAbducts Bool
- | RandomSeed Integer
- | ReproducibleResourceLimit Integer
- | SMTVerbosity Integer
- | OptionKeyword String [String]
- | SetLogic Logic
- | SetInfo String [String]
- | SetTimeOut Integer
User queries
class MonadIO m => ExtractIO (m :: Type -> Type) where Source #
Monads which support IO
operations and can extract all IO
behavior for
interoperation with functions like catches
, which takes
an IO
action in negative position. This function can not be implemented
for transformers like ReaderT r
or StateT s
, whose resultant IO
actions are a function of some environment or state.
Instances
ExtractIO IO Source # | Trivial IO extraction for |
ExtractIO m => ExtractIO (MaybeT m) Source # | IO extraction for |
ExtractIO m => ExtractIO (ExceptT e m) Source # | IO extraction for |
(Monoid w, ExtractIO m) => ExtractIO (WriterT w m) Source # | IO extraction for lazy |
(Monoid w, ExtractIO m) => ExtractIO (WriterT w m) Source # | IO extraction for strict |
class Monad m => MonadQuery (m :: Type -> Type) where Source #
Computations which support query operations.
Minimal complete definition
Nothing
Methods
queryState :: m State Source #
default queryState :: forall (t :: (Type -> Type) -> Type -> Type) (m' :: Type -> Type). (MonadTrans t, MonadQuery m', m ~ t m') => m State Source #
Instances
data QueryT (m :: Type -> Type) a Source #
A query is a user-guided mechanism to directly communicate and extract
results from the solver. A generalization of Query
.
Instances
type Query = QueryT IO Source #
A query is a user-guided mechanism to directly communicate and extract results from the solver.
query :: forall (m :: Type -> Type) a. ExtractIO m => QueryT m a -> SymbolicT m a Source #
Run a custom query.
Checking satisfiability
data CheckSatResult Source #
Result of a checkSat
or checkSatAssuming
call.
Constructors
Sat | Satisfiable: A model is available, which can be queried with |
DSat (Maybe String) | Delta-satisfiable: A delta-sat model is available. String is the precision info, if available. |
Unsat | Unsatisfiable: No model is available. Unsat cores might be obtained via |
Unk | Unknown: Use |
Instances
checkSat :: (MonadIO m, MonadQuery m) => m CheckSatResult Source #
Generalization of checkSat
checkSatUsing :: (MonadIO m, MonadQuery m) => String -> m CheckSatResult Source #
Generalization of checkSatUsing
checkSatAssuming :: (MonadIO m, MonadQuery m) => [SBool] -> m CheckSatResult Source #
Generalization of checkSatAssuming
checkSatAssumingWithUnsatisfiableSet :: (MonadIO m, MonadQuery m) => [SBool] -> m (CheckSatResult, Maybe [SBool]) Source #
Generalization of checkSatAssumingWithUnsatisfiableSet
Querying the solver
Extracting values
getFunction :: (MonadIO m, MonadQuery m, SolverContext m, MonadSymbolic m, SymVal a, SymVal r, SMTFunction fun a r) => fun -> m (Either (String, (Bool, Maybe [String], SExpr)) ([(a, r)], r)) Source #
Generalization of getFunction
getUninterpretedValue :: (MonadIO m, MonadQuery m, HasKind a) => SBV a -> m String Source #
Generalization of getUninterpretedValue
getAssignment :: (MonadIO m, MonadQuery m) => m [(String, Bool)] Source #
Generalization of getAssignment
getSMTResult :: (MonadIO m, MonadQuery m) => m SMTResult Source #
Generalization of getSMTResult
getUnknownReason :: (MonadIO m, MonadQuery m) => m SMTReasonUnknown Source #
Generalization of getUnknownReason
getObservables :: (MonadIO m, MonadQuery m) => m [(Name, CV)] Source #
Get observables, i.e., those explicitly labeled by the user with a call to observe
.
Extracting the unsat core
getUnsatCore :: (MonadIO m, MonadQuery m) => m [String] Source #
Generalization of getUnsatCore
Extracting a proof
Extracting interpolants
getInterpolantMathSAT :: (MonadIO m, MonadQuery m) => [String] -> m String Source #
Generalization of getInterpolantMathSAT
. Use this version with MathSAT.
getInterpolantZ3 :: (MonadIO m, MonadQuery m) => [SBool] -> m String Source #
Generalization of getInterpolantZ3
. Use this version with Z3.
Getting abducts
getAbduct :: (SolverContext m, MonadIO m, MonadQuery m) => Maybe String -> String -> SBool -> m String Source #
Generalization of getAbduct
.
getAbductNext :: (MonadIO m, MonadQuery m) => m String Source #
Generalization of getAbductNext
.
Extracting assertions
getAssertions :: (MonadIO m, MonadQuery m) => m [String] Source #
Generalization of getAssertions
Getting solver information
data SMTInfoFlag Source #
Collectable information from the solver.
Constructors
AllStatistics | |
AssertionStackLevels | |
Authors | |
ErrorBehavior | |
Name | |
ReasonUnknown | |
Version | |
InfoKeyword String |
Instances
Show SMTInfoFlag Source # | |
Defined in Data.SBV.Control.Types Methods showsPrec :: Int -> SMTInfoFlag -> ShowS # show :: SMTInfoFlag -> String # showList :: [SMTInfoFlag] -> ShowS # |
data SMTErrorBehavior Source #
Behavior of the solver for errors.
Constructors
ErrorImmediateExit | |
ErrorContinuedExecution |
Instances
Show SMTErrorBehavior Source # | |
Defined in Data.SBV.Control.Types Methods showsPrec :: Int -> SMTErrorBehavior -> ShowS # show :: SMTErrorBehavior -> String # showList :: [SMTErrorBehavior] -> ShowS # |
data SMTInfoResponse Source #
Collectable information from the solver.
Constructors
Resp_Unsupported | |
Resp_AllStatistics [(String, String)] | |
Resp_AssertionStackLevels Integer | |
Resp_Authors [String] | |
Resp_Error SMTErrorBehavior | |
Resp_Name String | |
Resp_ReasonUnknown SMTReasonUnknown | |
Resp_Version String | |
Resp_InfoKeyword String [String] |
Instances
Show SMTInfoResponse Source # | |
Defined in Data.SBV.Control.Types Methods showsPrec :: Int -> SMTInfoResponse -> ShowS # show :: SMTInfoResponse -> String # showList :: [SMTInfoResponse] -> ShowS # |
getInfo :: (MonadIO m, MonadQuery m) => SMTInfoFlag -> m SMTInfoResponse Source #
Generalization of getInfo
getOption :: (MonadIO m, MonadQuery m) => (a -> SMTOption) -> m (Maybe SMTOption) Source #
Generalization of getOption
Entering and exiting assertion stack
getAssertionStackDepth :: (MonadIO m, MonadQuery m) => m Int Source #
Generalization of getAssertionStackDepth
inNewAssertionStack :: (MonadIO m, MonadQuery m) => m a -> m a Source #
Generalization of inNewAssertionStack
Higher level tactics
caseSplit :: (MonadIO m, MonadQuery m) => Bool -> [(String, SBool)] -> m (Maybe (String, SMTResult)) Source #
Generalization of caseSplit
Resetting the solver state
resetAssertions :: (MonadIO m, MonadQuery m) => m () Source #
Generalization of resetAssertions
Constructing assignments
(|->) :: SymVal a => SBV a -> a -> Assignment infix 1 Source #
Make an assignment. The type Assignment
is abstract, the result is typically passed
to mkSMTResult
:
mkSMTResult [ a |-> 332 , b |-> 2.3 , c |-> True ]
End users should use getModel
for automatically constructing models from the current solver state.
However, an explicit Assignment
might be handy in complex scenarios where a model needs to be
created manually.
Terminating the query
mkSMTResult :: (MonadIO m, MonadQuery m) => [Assignment] -> m SMTResult Source #
Generalization of mkSMTResult
NB. This function does not allow users to create interpretations for UI-Funs. But that's
probably not a good idea anyhow. Also, if you use the validateModel
or optimizeValidateConstraints
features, SBV will
fail on models returned via this function.
Controlling the solver behavior
ignoreExitCode :: SMTConfig -> Bool Source #
If true, we shall ignore the exit code upon exit. Otherwise we require ExitSuccess.
timeout :: (MonadIO m, MonadQuery m) => Int -> m a -> m a Source #
Timeout a query action, typically a command call to the underlying SMT solver.
The duration is in microseconds (1/10^6
seconds). If the duration
is negative, then no timeout is imposed. When specifying long timeouts, be careful not to exceed
maxBound :: Int
. (On a 64 bit machine, this bound is practically infinite. But on a 32 bit
machine, it corresponds to about 36 minutes!)
Semantics: The call timeout n q
causes the timeout value to be applied to all interactive calls that take place
as we execute the query q
. That is, each call that happens during the execution of q
gets a separate
time-out value, as opposed to one timeout value that limits the whole query. This is typically the intended behavior.
It is advisable to apply this combinator to calls that involve a single call to the solver for
finer control, as opposed to an entire set of interactions. However, different use cases might call for different scenarios.
If the solver responds within the time-out specified, then we continue as usual. However, if the backend solver times-out using this mechanism, there is no telling what the state of the solver will be. Thus, we raise an error in this case.
Miscellaneous
queryDebug :: (MonadIO m, MonadQuery m) => [String] -> m () Source #
Generalization of queryDebug
Solver options
Option values that can be set in the solver, following the SMTLib specification https://smt-lib.org/language.shtml.
Note that not all solvers may support all of these!
Furthermore, SBV doesn't support the following options allowed by SMTLib.
:interactive-mode
(Deprecated in SMTLib, useProduceAssertions
instead.):print-success
(SBV critically needs this to be True in query mode.):produce-models
(SBV always sets this option so it can extract models.):regular-output-channel
(SBV always requires regular output to come on stdout for query purposes.):global-declarations
(SBV always uses global declarations since definitions are accumulative.)
Note that SetLogic
and SetInfo
are, strictly speaking, not SMTLib options. However, we treat it as such here
uniformly, as it fits better with how options work.
Constructors
DiagnosticOutputChannel FilePath | |
ProduceAssertions Bool | |
ProduceAssignments Bool | |
ProduceProofs Bool | |
ProduceInterpolants Bool | |
ProduceUnsatAssumptions Bool | |
ProduceUnsatCores Bool | |
ProduceAbducts Bool | |
RandomSeed Integer | |
ReproducibleResourceLimit Integer | |
SMTVerbosity Integer | |
OptionKeyword String [String] | |
SetLogic Logic | |
SetInfo String [String] | |
SetTimeOut Integer |