luteberget / minisat-rs

Rust crate which compiles minisat and provides an interface (C/C++ compiler required)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MiniSat Rust interface. Solves a boolean satisfiability problem given in conjunctive normal form.

extern crate minisat;
use std::iter::once;
fn main() {
    let mut sat = minisat::Solver::new();
    let a = sat.new_lit();
    let b = sat.new_lit();

    // Solves ((a OR not b) AND b)
    sat.add_clause(vec![a, !b]);
    sat.add_clause(vec![b]);

    match sat.solve() {
        Ok(m) => {
            assert_eq!(m.value(&a), true);
            assert_eq!(m.value(&b), true);
        },
        Err(()) => panic!("UNSAT"),
    }
}

This crate compiles the MiniSat sources directly and binds through the minisat-c-bindings interface. The low-level C bindings are available through the sys module.

About

Rust crate which compiles minisat and provides an interface (C/C++ compiler required)

License:MIT License


Languages

Language:C++ 71.9%Language:C 21.8%Language:Rust 4.5%Language:Makefile 1.8%