SBV

SMT Based Verification in Haskell. Express properties about Haskell programs and automatically prove them using SMT solvers.

View the Project on GitHub LeventErkok/sbv

SBV: SMT Based Verification in Haskell

Express properties about Haskell programs and automatically prove them using SMT solvers.

$ ghci -XScopedTypeVariables
ghci> :m Data.SBV
ghci> prove $ \(x::SWord8) -> x `shiftL` 2 .== 4*x
Q.E.D.
ghci> prove $ forAll ["x"] $ \(x::SWord8) -> x `shiftL` 2 .== x
Falsifiable. Counter-example:
x = 128 :: SWord8

The function prove establishes theorem-hood, while sat finds any satisfying model. All satisfying models can be lazily computed using allSat.

Overview

SBV library provides support for dealing with symbolic values in Haskell. It introduces the types:

The user can construct ordinary Haskell programs using these types, which behave like ordinary Haskell values when used concretely. However, when used with symbolic arguments, functions built out of these types can also be:

Picking the SMT solver to use

The SBV library uses third-party SMT solvers via the standard SMT-Lib interface. Use the following import statements to pick the corresponding solver:

If you simply import Data.SBV, then the solver defaults to Microsoft's Z3.

Other SMT solvers can be used with SBV as well, with a relatively easy hook-up mechanism. Please do get in touch if you plan to use SBV with any other solver.

Copyright, License

The SBV library is distributed with the BSD3 license. See COPYRIGHT for details. The LICENSE file contains the BSD3 verbiage.

Thanks

The following people reported bugs, provided comments/feedback, or contributed to the development of SBV in various ways: Ian Blumenfeld, Ian Calvert, Iavor Diatchki, Thomas DuBuisson, John Erickson, Tom Hawkins, Lee Pike, Austin Seipp, Don Stewart, Josef Svenningsson, and Nis Wegmann.