Skip to main content

This library aims to provide implementations of elements commonly used in the development on software in the area of satisfiability solving. The focus of the library is to provide as much ease of use without giving up on performance.

Project description

Build & Test crates.io docs.rs PyPI License

rustsat - A Comprehensive SAT Library for Rust

rustsat is a collection of interfaces and utilities for working with the boolean satisfiability problem in Rust. This library aims to provide implementations of elements commonly used in the development of software in the area of satisfiability solving. The focus of the library is to provide as much ease of use without giving up on performance.

Example

let mut instance: SatInstance = SatInstance::new();
let l1 = instance.new_lit();
let l2 = instance.new_lit();
instance.add_binary(l1, l2);
instance.add_binary(!l1, l2);
instance.add_unit(l1);
let mut solver = rustsat_minisat::core::Minisat::default();
solver.add_cnf(instance.as_cnf().0).unwrap();
let res = solver.solve().unwrap();
assert_eq!(res, SolverResult::Sat);
let sol = solver.full_solution().unwrap();
assert_eq!(sol[l1.var()], TernaryVal::True);
assert_eq!(sol[l2.var()], TernaryVal::True);

Crates

The RustSAT project is split up into multiple crates that are all contained in this repository. These are the crates the project consists of:

Crate Description
rustsat The main library, containing basic types, traits, encodings, parsers, and more.
rustsat-tools A collection of small helpful tools based on RustSAT that can be installed as binaries. For a list of available tools, see this directory with short descriptions of the tools in the headers of the files.
rustsat-<satsolver> Interfaces to SAT solvers that can be used alongside rustsat. Currently interfaces are available for cadical, kissat, glucose, and minisat.

Installation

To use the RustSAT library as a dependency in your project, simply run cargo add rustsat. To use an SAT solver interface in your project, run cargo add rustsat-<satsolver>. Typically, the version of the SAT solver can be selected via crate features, refer to the documentation of the respective SAT solver crate for details.

To install the binary tools in rustsat-tools run cargo install rustsat-tools.

Features

Feature name Description
internals Make some internal data structures for e.g. encodings public. This is useful when basing a more complex encoding on the rustsat implementation of another encoding. Note that the internal API might change between releases.
fxhash Use the faster firefox hash function from rustc-hash in rustsat.
ipasir Include and link the IPASIR solver interface.
optimization Include optimization (MaxSAT) data structures etc.
multiopt Include data structures etc. for multi-objective optimization.
compression Enable parsing and writing compressed input.
bench Enable benchmark tests. Behind feature flag since it requires unstable Rust.
rand Enable randomization features. (Shuffling clauses etc.)

Examples

For example usage refer to the small example tools in the rustsat-tools crate at tools/src/bin. For a bigger example you can look at this multi-objective optimization solver.

For an example of how to use the C-API, see rustsat/examples/capi*.cpp. Similarly, for an example of using the Python API, see rustsat/examples/pyapi*.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rustsat-0.4.3.tar.gz (8.5 MB view hashes)

Uploaded Source

Built Distributions

rustsat-0.4.3-cp37-abi3-win_amd64.whl (229.5 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

rustsat-0.4.3-cp37-abi3-win32.whl (213.9 kB view hashes)

Uploaded CPython 3.7+ Windows x86

rustsat-0.4.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

rustsat-0.4.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.3 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

rustsat-0.4.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

rustsat-0.4.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.1 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

rustsat-0.4.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

rustsat-0.4.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.5+ i686

rustsat-0.4.3-cp37-abi3-macosx_11_0_arm64.whl (342.9 kB view hashes)

Uploaded CPython 3.7+ macOS 11.0+ ARM64

rustsat-0.4.3-cp37-abi3-macosx_10_12_x86_64.whl (352.7 kB view hashes)

Uploaded CPython 3.7+ macOS 10.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page