Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dopamane/subpar
Haskell SMT interface :golf:
https://github.com/dopamane/subpar
haskell smt
Last synced: 5 days ago
JSON representation
Haskell SMT interface :golf:
- Host: GitHub
- URL: https://github.com/dopamane/subpar
- Owner: dopamane
- License: bsd-3-clause
- Created: 2022-01-25T06:20:29.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T09:55:02.000Z (10 months ago)
- Last Synced: 2024-10-10T22:35:08.482Z (26 days ago)
- Topics: haskell, smt
- Language: Haskell
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# subpar :golf:
[![Haskell CI](https://github.com/dopamane/subpar/actions/workflows/haskell.yml/badge.svg?branch=main)](https://github.com/dopamane/subpar/actions/workflows/haskell.yml)
[![Hackage][hackage-badge]][hackage]
[![Hackage Dependencies][hackage-deps-badge]][hackage-deps]Haskell [SMT](https://smtlib.cs.uiowa.edu/) interface.
## Build
```
git clone https://github.com/dopamane/subpar# SMT-LIB-benchmarks submodule; skip if not running tests and benchmarks
git submodule update --init --recursivecabal build
# documentation
cabal haddock# test
cabal test# benchmark
cabal bench
```## Usage
### Obtain handle to SMT process:
```haskell
withSmtProcess
:: FilePath -- ^ Executable
-> [String] -- ^ Arguments
-> (SmtHandle -> IO a) -- ^ Smt action
-> IO a
```Example:
```haskell
withSmtProcess "z3" ["-smt2", "-in"] $ \smtHandle -> do
hSetBinaryMode (smtIn smtHandle) True
hSetBinaryMode (smtOut smtHandle) True
hSetBuffering (smtIn smtHandle) LineBuffering
hSetBuffering (smtOut smtHandle) LineBuffering
someIOAction
```### Construct SMT-LIB v2.6 commands:
```haskell
let setSmtLibVer = setInfo
"smt-lib-version"
(Just $
AttributeValueSymbol $
symbolSimpleSymbol "2.6"
)
setLogic = SetLogic $ symbolSimpleSymbol "QF_LIA"
declareConst sym srt = DeclareConst
(symbolSimpleSymbol sym)
(Sort
(IdentifierSymbol $
symbolSimpleSymbol srt
)
[]
)
```### Send commands and receive responses:
```haskell
xfer :: SmtHandle -> Command -> IO (Result GeneralResponse)
xferM :: SmtHandle -> Command -> IO (Maybe (Result GeneralResponse))
send :: SmtHandle -> Command -> IO ()
```Example:
```haskell
do
mapM (xfer smtHandle) [setOptionPrintSuccess True, setSmtLibVer] >>= mapM_ printResult
send smtHandle Exit
```### Read and write script files:
```haskell
readScript :: FilePath -> IO (Result Script)
writeScript :: FilePath -> Script -> IO ()
```## References
[SMT-LIB](https://smtlib.cs.uiowa.edu/standard.shtml)
[hackage]:
[hackage-badge]:
[hackage-deps-badge]:
[hackage-deps]: