crucible-0.8.0.0: Crucible is a library for language-agnostic symbolic simulation
Copyright(c) Galois Inc 2015-2016
LicenseBSD3
MaintainerRyan Scott <rscott@galois.com>, Langston Barrett <langston@galois.com>
Stabilityprovisional
Safe HaskellNone
LanguageHaskell2010

Lang.Crucible.Backend.Online

Description

A solver backend (IsSymBackend) that maintains an open connection to an SMT solver (in contrast to Lang.Crucible.Backend.Simple).

The primary intended use-case is to prune unsatisfiable execution traces during simulation using the execution feature provided by Lang.Crucible.Simulator.PathSatisfiability. That execution feature is parameterized over a function argument that can be instantiated with this module's considerSatisfiability.

The online backend also allows override definitions access to a persistent SMT solver connection. This can be useful for some kinds of algorithms that benefit from quickly performing many small solver queries in a tight interaction loop.

The online backend is not currently used to dispatch proof obligations during symbolic execution, see GaloisInc/crucible#369, "Interleave proof with simulation".

Synopsis

Configuration options

enableOnlineBackend :: ConfigOption BaseBoolType Source #

Option for enabling online solver interactions. Defaults to true. If disabled, operations requiring solver connections will be skipped.

onlineBackendOptions :: forall solver scope (st :: Type -> Type) fs. OnlineSolver solver => OnlineBackend solver scope st fs -> [ConfigDesc] Source #

OnlineBackend

data OnlineBackend solver scope (st :: Type -> Type) fs Source #

This represents the state of the backend along a given execution. It contains the current assertions and program location.

Instances

Instances details
HasSymInterface (ExprBuilder t st fs) (OnlineBackend solver t st fs) Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

Methods

backendGetSym :: OnlineBackend solver t st fs -> ExprBuilder t st fs Source #

(IsSymInterface (ExprBuilder scope st fs), OnlineSolver solver) => IsSymBackend (ExprBuilder scope st fs) (OnlineBackend solver scope st fs) Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

Methods

pushAssumptionFrame :: OnlineBackend solver scope st fs -> IO FrameIdentifier Source #

popAssumptionFrame :: OnlineBackend solver scope st fs -> FrameIdentifier -> IO (Assumptions (ExprBuilder scope st fs)) Source #

popUntilAssumptionFrame :: OnlineBackend solver scope st fs -> FrameIdentifier -> IO () Source #

popAssumptionFrameAndObligations :: OnlineBackend solver scope st fs -> FrameIdentifier -> IO (Assumptions (ExprBuilder scope st fs), ProofObligations (ExprBuilder scope st fs)) Source #

addAssumption :: OnlineBackend solver scope st fs -> Assumption (ExprBuilder scope st fs) -> IO () Source #

addAssumptions :: OnlineBackend solver scope st fs -> Assumptions (ExprBuilder scope st fs) -> IO () Source #

getPathCondition :: OnlineBackend solver scope st fs -> IO (Pred (ExprBuilder scope st fs)) Source #

collectAssumptions :: OnlineBackend solver scope st fs -> IO (Assumptions (ExprBuilder scope st fs)) Source #

addProofObligation :: OnlineBackend solver scope st fs -> Assertion (ExprBuilder scope st fs) -> IO () Source #

addDurableProofObligation :: OnlineBackend solver scope st fs -> Assertion (ExprBuilder scope st fs) -> IO () Source #

getProofObligations :: OnlineBackend solver scope st fs -> IO (ProofObligations (ExprBuilder scope st fs)) Source #

clearProofObligations :: OnlineBackend solver scope st fs -> IO () Source #

saveAssumptionState :: OnlineBackend solver scope st fs -> IO (AssumptionState (ExprBuilder scope st fs)) Source #

restoreAssumptionState :: OnlineBackend solver scope st fs -> AssumptionState (ExprBuilder scope st fs) -> IO () Source #

resetAssumptionState :: OnlineBackend solver scope st fs -> IO () Source #

getBackendState :: OnlineBackend solver scope st fs -> IO (AssumptionState (ExprBuilder scope st fs)) Source #

withOnlineBackend :: forall solver m scope (st :: Type -> Type) fs a. (OnlineSolver solver, MonadIO m, MonadMask m) => ExprBuilder scope st fs -> ProblemFeatures -> (OnlineBackend solver scope st fs -> m a) -> m a Source #

Do something with an online backend. The backend is only valid in the continuation.

Solver specific configuration options are not automatically installed by this operation.

newOnlineBackend :: forall solver scope (st :: Type -> Type) fs. OnlineSolver solver => ExprBuilder scope st fs -> ProblemFeatures -> IO (OnlineBackend solver scope st fs) Source #

checkSatisfiable :: SMTReadWriter solver => SolverProcess scope solver -> String -> BoolExpr scope -> IO (SatResult () ()) #

Check if the given formula is satisfiable in the current solver state, without requesting a model. This is done in a fresh frame, which is exited after the check call.

checkSatisfiableWithModel :: SMTReadWriter solver => SolverProcess scope solver -> String -> BoolExpr scope -> (SatResult (GroundEvalFn scope) () -> IO a) -> IO a #

Check if the formula is satisifiable in the current solver state. This is done in a fresh frame, which is exited after the continuation complets. The evaluation function can be used to query the model. The model is valid only in the given continuation.

withSolverProcess Source #

Arguments

:: forall solver scope (st :: Type -> Type) fs a. OnlineSolver solver 
=> OnlineBackend solver scope st fs 
-> IO a

Default value to return if online features are disabled

-> (SolverProcess scope solver -> IO a) 
-> IO a 

Get the solver process. Starts the solver, if that hasn't happened already and apply the given action. If the enableOnlineBackend option is False, the action is skipped instead, and the solver is not started.

resetSolverProcess :: forall solver scope (st :: Type -> Type) fs. OnlineSolver solver => OnlineBackend solver scope st fs -> IO () Source #

Shutdown any currently-active solver process. A fresh solver process will be started on the next call to getSolverProcess.

restoreSolverState :: forall solver scope (st :: Type -> Type) fs. OnlineSolver solver => OnlineBackend solver scope st fs -> GoalCollector (CrucibleAssumptions (Expr scope)) (LabeledPred (BoolExpr scope) SimError) -> IO () Source #

data UnsatFeatures Source #

Constructors

NoUnsatFeatures

Do not compute unsat cores or assumptions

ProduceUnsatCores

Enable named assumptions and unsat-core computations

ProduceUnsatAssumptions

Enable check-with-assumptions commands and unsat-assumptions computations

Branch satisfiability

data BranchResult Source #

Result of attempting to branch on a predicate.

Constructors

IndeterminateBranchResult

The both branches of the predicate might be satisfiable (although satisfiablility of either branch is not guaranteed).

NoBranch !Bool

Commit to the branch where the given predicate is equal to the returned boolean. The opposite branch is unsatisfiable (although the given branch is not necessarily satisfiable).

UnsatisfiableContext

The context before considering the given predicate was already unsatisfiable.

Instances

Instances details
Data BranchResult Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BranchResult -> c BranchResult #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BranchResult #

toConstr :: BranchResult -> Constr #

dataTypeOf :: BranchResult -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BranchResult) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BranchResult) #

gmapT :: (forall b. Data b => b -> b) -> BranchResult -> BranchResult #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BranchResult -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BranchResult -> r #

gmapQ :: (forall d. Data d => d -> u) -> BranchResult -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BranchResult -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BranchResult -> m BranchResult #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BranchResult -> m BranchResult #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BranchResult -> m BranchResult #

Generic BranchResult Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

Associated Types

type Rep BranchResult 
Instance details

Defined in Lang.Crucible.Backend.Online

type Rep BranchResult = D1 ('MetaData "BranchResult" "Lang.Crucible.Backend.Online" "crucible-0.8.0.0-4NPuSrI5sD835MFtwnvz2a" 'False) (C1 ('MetaCons "IndeterminateBranchResult" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoBranch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "UnsatisfiableContext" 'PrefixI 'False) (U1 :: Type -> Type)))
Eq BranchResult Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

Ord BranchResult Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

type Rep BranchResult Source # 
Instance details

Defined in Lang.Crucible.Backend.Online

type Rep BranchResult = D1 ('MetaData "BranchResult" "Lang.Crucible.Backend.Online" "crucible-0.8.0.0-4NPuSrI5sD835MFtwnvz2a" 'False) (C1 ('MetaCons "IndeterminateBranchResult" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoBranch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "UnsatisfiableContext" 'PrefixI 'False) (U1 :: Type -> Type)))

considerSatisfiability :: forall solver scope (st :: Type -> Type) fs. OnlineSolver solver => OnlineBackend solver scope st fs -> Maybe ProgramLoc -> BoolExpr scope -> IO BranchResult Source #

Backends for different solvers

Yices

type YicesOnlineBackend scope (st :: Type -> Type) fs = OnlineBackend Connection scope st fs Source #

withYicesOnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> UnsatFeatures -> ProblemFeatures -> (YicesOnlineBackend scope st fs -> m a) -> m a Source #

Do something with a Yices online backend. The backend is only valid in the continuation.

The Yices configuration options will be automatically installed into the backend configuration object.

Z3

type Z3OnlineBackend scope (st :: Type -> Type) fs = OnlineBackend (Writer Z3) scope st fs Source #

withZ3OnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> UnsatFeatures -> ProblemFeatures -> (Z3OnlineBackend scope st fs -> m a) -> m a Source #

Do something with a Z3 online backend. The backend is only valid in the continuation.

The Z3 configuration options will be automatically installed into the backend configuration object.

Bitwuzla

type BitwuzlaOnlineBackend scope (st :: Type -> Type) fs = OnlineBackend (Writer Bitwuzla) scope st fs Source #

withBitwuzlaOnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> UnsatFeatures -> ProblemFeatures -> (BitwuzlaOnlineBackend scope st fs -> m a) -> m a Source #

Do something with a Bitwuzla online backend. The backend is only valid in the continuation.

The Bitwuzla configuration options will be automatically installed into the backend configuration object.

Boolector

type BoolectorOnlineBackend scope (st :: Type -> Type) fs = OnlineBackend (Writer Boolector) scope st fs Source #

withBoolectorOnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> UnsatFeatures -> (BoolectorOnlineBackend scope st fs -> m a) -> m a Source #

Do something with a Boolector online backend. The backend is only valid in the continuation.

The Boolector configuration options will be automatically installed into the backend configuration object.

CVC4

type CVC4OnlineBackend scope (st :: Type -> Type) fs = OnlineBackend (Writer CVC4) scope st fs Source #

withCVC4OnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> UnsatFeatures -> ProblemFeatures -> (CVC4OnlineBackend scope st fs -> m a) -> m a Source #

Do something with a CVC4 online backend. The backend is only valid in the continuation.

The CVC4 configuration options will be automatically installed into the backend configuration object.

CVC5

type CVC5OnlineBackend scope (st :: Type -> Type) fs = OnlineBackend (Writer CVC5) scope st fs Source #

withCVC5OnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> UnsatFeatures -> ProblemFeatures -> (CVC5OnlineBackend scope st fs -> m a) -> m a Source #

Do something with a CVC5 online backend. The backend is only valid in the continuation.

The CVC5 configuration options will be automatically installed into the backend configuration object.

STP

type STPOnlineBackend scope (st :: Type -> Type) fs = OnlineBackend (Writer STP) scope st fs Source #

withSTPOnlineBackend :: forall m scope (st :: Type -> Type) fs a. (MonadIO m, MonadMask m) => ExprBuilder scope st fs -> (STPOnlineBackend scope st fs -> m a) -> m a Source #

Do something with a STP online backend. The backend is only valid in the continuation.

The STO configuration options will be automatically installed into the backend configuration object.