| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Language.Hasmtlib.Type.Solver
Synopsis
- class WithSolver a where
- withSolver :: Solver -> a
- solveWith :: (Monad m, Default s, Codec a) => Solver s m -> StateT s m a -> m (Result, Maybe (Decoded a))
- interactiveWith :: (MonadIO m, WithSolver s) => (Solver, Handle) -> StateT s m () -> m ()
Documentation
class WithSolver a where Source #
Data that can have a Solver
Methods
withSolver :: Solver -> a Source #
Instances
| WithSolver Pipe Source # | |
Defined in Language.Hasmtlib.Type.Solver Methods withSolver :: Solver -> Pipe Source # | |
solveWith :: (Monad m, Default s, Codec a) => Solver s m -> StateT s m a -> m (Result, Maybe (Decoded a)) Source #
solves a SMT problem solveWith solver probprob with the given
solver. It returns a pair consisting of:
- A
Resultthat indicates ifprobis satisfiable (Sat), unsatisfiable (Unsat), or if the solver could not determine any results (Unknown). - A
Decodedanswer that was decoded using the solution toprob. Note that this answer is only meaningful if theResultis 'Satisfied or Unknown' and the answer value is in aJust.
Here is a small example of how to use solveWith:
import Language.Hasmtlib
main :: IO ()
main = do
res <- solveWith (solver cvc5) $ do
setLogic QF_LIA
x <- var @IntSort
assert $ x >? 0
return x
print res
interactiveWith :: (MonadIO m, WithSolver s) => (Solver, Handle) -> StateT s m () -> m () Source #
Pipes an SMT-problem interactively to the solver. Enables incremental solving by default. Here is a small example of how to use it for solving a problem utilizing the solvers incremental stack:
import Language.Hasmtlib
import Data.Proxy
import Control.Monad.IO.Class
main :: IO ()
main = do
cvc5Living <- interactiveSolver cvc5
interactiveWith cvc5Living $ do
setLogic QF_LIA
x <- var IntSort
assert $ x >? 0
(res, sol) <- solve
liftIO $ print res
liftIO $ print $ decode sol x
push
y <- var IntSort
assert $ y <? 0
assert $ x === y
res' <- checkSat
liftIO $ print res'
pop
res'' <- checkSat
liftIO $ print res''
return ()