https://github.com/plsyssec/haskell-boolector
Haskell bindings for the Boolector SMT solver
https://github.com/plsyssec/haskell-boolector
Last synced: about 1 year ago
JSON representation
Haskell bindings for the Boolector SMT solver
- Host: GitHub
- URL: https://github.com/plsyssec/haskell-boolector
- Owner: PLSysSec
- License: other
- Created: 2018-03-29T06:33:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-18T21:45:12.000Z (almost 6 years ago)
- Last Synced: 2025-04-19T06:19:59.476Z (about 1 year ago)
- Language: Haskell
- Homepage: http://hackage.haskell.org/package/boolector
- Size: 1.08 MB
- Stars: 5
- Watchers: 6
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://hackage.haskell.org/package/boolector)
# Haskell binding for the Boolector SMT Solver
This is a simple library for writing SMT queries against the Boolector SMT
solver.
## Installing Boolector and this library
1. Install the Boolector library from .
On Arch Linux, you can install Boolector (and the Lingeling SAT solver)
with: `yaourt -S boolector-git`
2. `cabal install boolector`
## Example
This program (`test/API_Usage_Examples.hs`) shows basic API usage:
```haskell
import qualified Boolector as B
import Control.Monad.IO.Class
import Control.Exception (assert)
import Control.Concurrent
main :: IO ()
main = do
-- Create new Boolector state with a 1000ms timeout
bs <- B.newBoolectorState (Just 1000)
B.evalBoolector bs $ do
-- Create a 8-bit bit-vector
u8 <- B.bitvecSort 8
-- Create a constant value and two variables of sort u8
c <- B.unsignedInt 35 u8
x <- B.var u8 "x"
y <- B.var u8 "y"
-- Perofmr some operations on the values
p <- B.mul x y
o <- B.umulo x y
no <- B.not o
e <- B.eq c p
-- Make some assertions
B.assert =<< B.and no e
one <- B.one u8
B.assert =<< B.ugt x one
B.assert =<< B.ugt y one
-- Dump the corresponding SMT Lib 2 to a file
B.dump B.DumpSMT2 "dump_example.smt2"
-- Check satisfiability
B.Sat <- B.sat
-- Get model
mx <- B.unsignedBvAssignment x
my <- B.unsignedBvAssignment y
assert (mx == 7) $ return ()
assert (my == 5) $ return ()
```