satoxid

Crates.iosatoxid
lib.rssatoxid
version0.1.2
sourcesrc
created_at2021-05-22 21:42:07.380942
updated_at2021-05-24 17:56:23.701066
descriptionBoolean satisfiability problem encoding library written in rust.
homepage
repositoryhttps://github.com/neuring/satoxid
max_upload_size
id400931
size150,484
(neuring)

documentation

README

Satoxid, a SATisfiability encoding library

Satoxid is a library to help with encoding SAT problems with a focus on ergonomics and debugability.

Features

  • Predefined common constraints
  • Variables are values of a user defined type instead of integers
  • Modular, you can implement your own constraints and backends

Example

use satoxid::{CadicalEncoder, constraints::ExactlyK};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Var {
    A, B, C
}

use Var::*;

fn main() {
    let mut encoder = CadicalEncoder::new();

    let constraint = ExactlyK {
        k: 1,
        lits: [A, B, C].iter().copied()
    };

    encoder.add_constraint(constraint);

    if let Some(model) = encoder.solve() {

        let true_vars = model.vars()
                             .filter(|v| v.is_pos())
                             .count();

        assert_eq!(true_vars, 1);
    }
}

For a more complex example see this rummy solver.

Commit count: 59

cargo fmt