SMT Based Verification in Haskell. Express properties about Haskell programs and automatically prove them using SMT solvers.
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.

SBV library provides support for dealing with symbolic values in Haskell. It introduces the types:
SBool: Symbolic Booleans (bits).SWord8, SWord16, SWord32, SWord64: Symbolic Words (unsigned).SInt8, SInt16, SInt32, SInt64: Symbolic Ints (signed).SInteger: Symbolic unbounded integers (signed).SReal: Symbolic infinite precision algebraic reals (signed).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:
prove function),sat, and allSat functions),sat function with existentials),optimize, maximize, and minimize functions),genTest function),compileToC and compileToCLib functions).The SBV library uses third-party SMT solvers via the standard SMT-Lib interface. Use the following import statements to pick the corresponding solver:
import Data.SBV.Bridge.Boolectorimport Data.SBV.Bridge.CVC4import Data.SBV.Bridge.Yicesimport Data.SBV.Bridge.Z3If 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.
The SBV library is distributed with the BSD3 license. See COPYRIGHT for details. The LICENSE file contains the BSD3 verbiage.
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.