toysolver: Assorted decision procedures for SAT, SMT, Max-SAT, PB, MIP, etc

[ algorithms, bsd3, constraints, formal-methods, library, logic, optimisation, optimization, program, smt, theorem-provers ] [ Propose Tags ] [ Report a vulnerability ]

Toy-level solver implementation of various problems including SAT, SMT, Max-SAT, PBSPBO (Pseudo Boolean SatisfactionOptimization), MILP (Mixed Integer Linear Programming) and non-linear real arithmetic.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
forcechar8

set default encoding to char8 (not to use iconv)

Disabled
linuxstatic

build statically linked binaries

Disabled
withzlib

Use zlib package to support gzipped files

Enabled
buildtoyfmf

build toyfmf command

Disabled
buildforeignlibraries

build foreign libraries

Enabled
buildsampleprograms

build sample programs

Disabled
buildmiscprograms

build misc programs

Disabled
usehaskeline

use haskeline package

Enabled
opencl

use opencl package (deprecated)

Disabled
extraboundschecking

enable extra bounds checking for debugging

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.2, 0.0.3, 0.0.4, 0.0.4.1, 0.0.5, 0.0.6, 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.8.1, 0.9.0, 0.10.0
Change log CHANGELOG.markdown
Dependencies aeson (>=2.0 && <2.3), array (>=0.5.6), attoparsec, base (>=4.18 && <4.23), bytestring (>=0.9.2.1 && <0.13), bytestring-builder, bytestring-encoding (>=0.1.1.0), case-insensitive, clock (>=0.7.1), containers (>=0.5.8), data-default, data-default-class, data-interval (>=2.0.1 && <2.2.0), deepseq, directory, extended-reals (>=0.1 && <1.0), filepath, finite-field (>=0.9.0 && <1.0.0), ghc-prim, hashable (>=1.4.3 && <1.6.0.0), hashtables, haskeline (>=0.7 && <0.9), heaps, integer-logarithms (>=1.0.3.1 && <1.1), intern (>=0.9.1.2 && <1.0.0.0), language-smtlib (>=0.2.0.0 && <0.3.0.0), lattices, log-domain, loop (>=0.3.0 && <1.0.0), megaparsec (>=7 && <10), MIP (>=0.2.0.0 && <0.3), mtl (>=2.1.2), multiset, mwc-random (>=0.13.1 && <0.16), OptDir, optparse-applicative (>=0.18), parsec, pretty (>=1.1.2.0 && <1.2), prettyprinter (>=1), primes, primitive (>=0.6), process (>=1.1.0.2), pseudo-boolean (>=0.1.12.0 && <0.2.0.0), queue, scientific, semigroups (>=0.17), sign (>=0.2.0 && <1.0.0), split, stm (>=2.3), template-haskell, temporary (>=1.2), text (>=1.1.0.0), time (>=1.5.0), toysolver, transformers (>=0.2), transformers-compat (>=0.3), unbounded-delays, unordered-containers (>=0.2.3 && <0.3.0), vector (>=0.11), vector-space (>=0.8.6), xml-conduit, zlib [details]
Tested with ghc ==9.6.7, ghc ==9.8.4, ghc ==9.10.3, ghc ==9.12.4
License BSD-3-Clause
Author Masahiro Sakai (masahiro.sakai@gmail.com)
Maintainer masahiro.sakai@gmail.com
Uploaded by MasahiroSakai at 2026-07-20T23:56:56Z
Category Algorithms, Optimisation, Optimization, Theorem Provers, Constraints, Logic, Formal Methods, SMT
Home page https://github.com/msakai/toysolver/
Bug tracker https://github.com/msakai/toysolver/issues
Source repo head: git clone https://github.com/msakai/toysolver.git
Distributions
Reverse Dependencies 4 direct, 0 indirect [details]
Executables pigeonhole, probsat, survey-propagation, svm2lp, htc, shortest-path, assign, knapsack, numberlink, nqueens, nonogram, sudoku, toysolver-check, toyconvert, toyfmf, toyqbf, toysmt, toysat, toysolver
Downloads 16619 total (100 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-07-21 [all 1 reports]

Readme for toysolver-0.10.0

[back to package description]

toysolver

License Join the chat at https://gitter.im/msakai/toysolver DeepWiki

Hackage: Hackage

Dev: Build Status Coverage Status

It provides solver implementations of various problems, including SAT, SMT, Max-SAT, PBS (Pseudo Boolean Satisfaction), PBO (Pseudo Boolean Optimization), MILP (Mixed Integer Linear Programming), and non-linear real arithmetic.

In particular, it contains a moderately fast pure-Haskell SAT solver toysat.

Installation

See INSTALL.md.

Usage

This package includes several commands.

toysolver

Arithmetic solver for the following problems:

  • Mixed Integer Linear Programming (MILP or MIP)
  • Boolean SATisfiability problem (SAT)
  • PB
    • Pseudo-Boolean Satisfaction (PBS)
    • Pseudo-Boolean Optimization (PBO)
    • Weighted Boolean Optimization (WBO)
  • Max-SAT families
    • Max-SAT
    • Partial Max-SAT
    • Weighted Max-SAT
    • Weighted Partial Max-SAT
  • Real Closed Field

Usage:

toysolver [OPTION...] [file.lp|file.mps]
toysolver --mip [OPTION...] [file.lp|file.mps]
toysolver --sat [OPTION...] [file.cnf]
toysolver --pb [OPTION...] [file.opb]
toysolver --wbo [OPTION...] [file.wbo]
toysolver --maxsat [OPTION...] [file.cnf|file.wcnf]

-h  --help           show help
-v  --version        show version number
    --solver=SOLVER  mip (default), omega-test, cooper, cad, old-mip, ct

toysat

SAT-based solver for the following problems:

  • SAT
    • Boolean SATisfiability problem (SAT)
    • Minimally Unsatisfiable Subset (MUS)
    • Group-Oriented MUS (GMUS)
  • PB
    • Pseudo-Boolean Satisfaction (PBS)
    • Pseudo-Boolean Optimization (PBO)
    • Weighted Boolean Optimization (WBO)
  • Max-SAT families
    • Max-SAT
    • Partial Max-SAT
    • Weighted Max-SAT
    • Weighted Partial Max-SAT
  • Integer Programming (all variables must be bounded)

Usage:

toysat [file.cnf|-]
toysat --sat [file.cnf|-]
toysat --mus [file.gcnf|file.cnf|-]
toysat --pb [file.opb|-]
toysat --wbo [file.wbo|-]
toysat --maxsat [file.cnf|file.wcnf|-]
toysat --mip [file.lp|file.mps|-]

PB'12 competition result:

  • toysat placed 2nd in PARTIAL-BIGINT-LIN and SOFT-BIGINT-LIN categories
  • toysat placed 4th in PARTIAL-SMALLINT-LIN and SOFT-SMALLINT-LIN categories
  • toysat placed 8th in OPT-BIGINT-LIN category

toysmt

SMT solver based on toysat.

Usage:

toysmt [file.smt2]

Currently only QF_UF, QF_RDL, QF_LRA, QF_UFRDL and QF_UFLRA logic are supported.

toyfmf

SAT-based finite model finder for first-order logic (FOL).

Usage:

toyfmf [file.tptp] [size]

toyconvert

Converter between various problem files.

Usage:

toyconvert -o [outputfile] [inputfile]

Supported formats:

Format Name File Extension Input Output Description
DIMACS CNF .cnf Standard file format for SAT instances
WCNF Format .wcnf Standard file format for Max-SAT instances (specification)
OPB Format .opb PBS (Pseudo-Boolean Satisfaction) and PBO (Pseudo-Boolean Optimization) instances (specification)
WBO Format .wbo WBO (Weighted-Boolean Optimization) instances (specification)
Group oriented CNF Input Format .gcnf - Used in Group oriented MUS track of the SAT Competition 2011 (specification)
LP File Format .lp Linear programming (LP) and mixed integer programming (MIP) problems
MPS File Format .mps Linear programming (LP) and mixed integer programming (MIP) problems
LSP Format .lsp - Input format for LocalSolver (only binary variables are supported)
SMP Format .smp - Input format for Nuorium Optimizer (NUOPT) (only binary variables are supported)
SMT-LIB 2 Format .smt2 - Satisfiability Modulo Theories (SMT) problem instances (website)
Yices Input Language .ys - SMT problem instances for SMT solver Yices
qbsolv QUBO Input File Format .qubo Unconstrained quadratic binary optimization problems (specification)

toysolver-check

Solution checker for various problem files. Usage:

toysolver-check [OPTION...] [problem_file] [solution_file]
toysolver-check --mip [OPTION...] [file.lp|file.mps] [file.sol]
toysolver-check --sat [OPTION...] [file.cnf] [file.log]
toysolver-check --pb [OPTION...] [file.opb] [file.log]
toysolver-check --wbo [OPTION...] [file.wbo] [file.log]
toysolver-check --maxsat [OPTION...] [file.cnf|file.wcnf] [file.log]

--encoding ENCODING      file encoding for LP/MPS files
--pb-fast-parser         use attoparsec-based parser instead of
                         megaparsec-based one for speed
--tol-integrality REAL   If a value of integer variable is within this amount
                         from its nearest integer, it is considered feasible.
                         (default: 1.0e-5)
--tol-feasibility REAL   If the amount of violation of constraints is within
                         this amount, it is considered feasible.
                         (default: 1.0e-6)
--tol-optimality REAL    Feasibility tolerance of dual constraints.
                         (default: 1.0e-6)

Bindings

Spin-off projects and packages