Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class MonadState s m => MonadSMT s m where
- var :: forall t s m. (KnownSMTSort t, MonadSMT s m) => m (Expr t)
- smtvar :: forall t s m. (KnownSMTSort t, MonadSMT s m) => m (SMTVar t)
- constant :: KnownSMTSort t => HaskellType t -> Expr t
- assertMaybe :: MonadSMT s m => Maybe (Expr BoolSort) -> m ()
- quantify :: MonadSMT s m => Expr t -> m (Expr t)
- class MonadSMT s m => MonadIncrSMT s m | m -> s where
- solve :: (MonadIncrSMT s m, MonadIO m) => m (Result, Solution)
- class MonadSMT s m => MonadOMT s m where
- assertSoftWeighted :: MonadOMT s m => Expr BoolSort -> Double -> m ()
Documentation
class MonadState s m => MonadSMT s m where Source #
A MonadState
that holds an SMT-Problem.
smtvar' :: forall t. KnownSMTSort t => Proxy t -> m (SMTVar t) Source #
Construct a variable.
This is mainly intended for internal use.
In the API use var'
instead.
x :: SMTVar RealType <- smtvar' (Proxy @RealType)
var' :: forall t. KnownSMTSort t => Proxy t -> m (Expr t) Source #
Construct a variable as expression.
x :: Expr RealType <- var' (Proxy @RealType)
assert :: Expr BoolSort -> m () Source #
Assert a boolean expression.
x :: Expr IntType <- var @IntType assert $ x + 5 === 42
setOption :: SMTOption -> m () Source #
Set an SMT-Solver-Option.
setOption $ Incremental True
setLogic :: String -> m () Source #
Set the logic for the SMT-Solver to use.
setLogic "QF_LRA"
Instances
MonadState OMT m => MonadSMT OMT m Source # | |
Defined in Language.Hasmtlib.Type.OMT | |
(MonadState Pipe m, MonadIO m) => MonadSMT Pipe m Source # | |
Defined in Language.Hasmtlib.Type.Pipe | |
MonadState SMT m => MonadSMT SMT m Source # | |
Defined in Language.Hasmtlib.Type.SMT |
constant :: KnownSMTSort t => HaskellType t -> Expr t Source #
Create a constant.
>>>
constant True
Constant (BoolValue True)
>>>
let x :: Integer = 10 ; constant x
Constant (IntValue 10)
>>>
constant @IntType 5
Constant (IntValue 5)
>>>
constant @(BvType 8) 5
Constant (BvValue 0000101)
quantify :: MonadSMT s m => Expr t -> m (Expr t) Source #
Assign quantified variables to all quantified subexpressions of an expression. This shall only be used internally. Usually before rendering an assert.
class MonadSMT s m => MonadIncrSMT s m | m -> s where Source #
A MonadSMT
that allows incremental solving.
Push a new context (one) to the solvers context-stack.
Pop the solvers context-stack by one.
Run check-sat on the current problem.
getModel :: m Solution Source #
Run get-model on the current problem. This can be used to decode temporary models within the SMT-Problem.
x <- var @RealSort y <- var assert $ x >? y && y <? (-1) res <- checkSat case res of Unsat -> print "Unsat. Cannot get model." r -> do model <- getModel liftIO $ print $ decode model x
getValue :: KnownSMTSort t => Expr t -> m (Maybe (Decoded (Expr t))) Source #
Instances
(MonadState Pipe m, MonadIO m) => MonadIncrSMT Pipe m Source # | |
class MonadSMT s m => MonadOMT s m where Source #
A MonadState
that holds an OMT-Problem.
An OMT-Problem is a 'SMT-Problem' with additional optimization targets.
minimize :: (KnownSMTSort t, Num (Expr t)) => Expr t -> m () Source #
Minimizes a numerical expression within the OMT-Problem.
For example, below minimization:
x <- var @IntSort assert $ x >? -2 minimize x
will give x := -1
as solution.
maximize :: (KnownSMTSort t, Num (Expr t)) => Expr t -> m () Source #
Maximizes a numerical expression within the OMT-Problem.
For example, below maximization:
x <- var @(BvSort 8) maximize x
will give x := 11111111
as solution.
assertSoft :: Expr BoolSort -> Maybe Double -> Maybe String -> m () Source #
Asserts a soft boolean expression. May take a weight and an identifier for grouping.
For example, below a soft constraint with weight 2.0 and identifier "myId" for grouping:
x <- var @BoolSort assertSoft x (Just 2.0) (Just "myId")
Omitting the weight will default it to 1.0.
x <- var BoolSort
y <- var
BoolSort
assertSoft x
assertSoft y (Just "myId")
assertSoftWeighted :: MonadOMT s m => Expr BoolSort -> Double -> m () Source #
Like assertSoft
but forces a weight and omits the group-id.