GithubHelp home page GithubHelp logo

themattchan / haskell-boolector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from plsyssec/haskell-boolector

0.0 2.0 0.0 1.09 MB

Haskell bindings for the Boolector SMT solver

Home Page: http://hackage.haskell.org/package/boolector

License: Other

Haskell 100.00%

haskell-boolector's Introduction

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 https://github.com/Boolector/boolector.

    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:

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 ()

haskell-boolector's People

Contributors

deian avatar jwaldmann avatar cdisselkoen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.