#smt-solver #smt #yices

sys yices2-sys

Low level Rust bindings to the Yices 2 SMT solver

3 releases (1 stable)

2.6.4 Aug 20, 2023
2.6.4-patch.1 Sep 1, 2023
0.1.0 Aug 17, 2023

#1106 in Algorithms

47 downloads per month
Used in yices2

GPL-3.0 license

6.5MB
10K SLoC

Yices2

Low and high-level Rust bindings to the Yices2 SMT solver.

Example

Linear Real Arithmetic

let config = Config::with_defaults_for_logics([Logic::QF_LRA])?;
let ctx = Context::with_config(&config)?;
let x = Uninterpreted::with_name(Real::new()?.into(), "x")?;
let y = Uninterpreted::with_name(Real::new()?.into(), "y")?;
let t1 = Add::new(x.into(), y.into())?;
let t2 = ArithmeticGreaterThanAtom::new(t1.into(), ArithmeticConstant::zero()?.into())?;
let t3 = Or::new([
    ArithmeticLessThanAtom::new(x.into(), ArithmeticConstant::zero()?.into())?.into(),
    ArithmeticLessThanAtom::new(y.into(), ArithmeticConstant::zero()?.into())?.into(),
])?;
ctx.assert([t2.into(), t3.into()])?;
let status = ctx.check()?;
assert_eq!(status, Status::STATUS_SAT);
let xv = ctx.model()?.double(&x.into())?;
let yv = ctx.model()?.double(&y.into())?;
assert_eq!(xv, 2.0);
assert_eq!(yv, -1.0);

BitVectors

let config = Config::with_defaults_for_logics([Logic::QF_BV])?;
let ctx = Context::with_config(&config)?;
let bv = BitVector::new(32)?;
let bvc = BitVectorConstant::from_hex_with_name("00000000", "c")?;
let x = Uninterpreted::with_name(bv.into(), "x")?;
let y = Uninterpreted::with_name(bv.into(), "y")?;
let a1 = BitVectorSignedGreaterThanAtom::new(x.into(), bvc.into())?;
let a2 = BitVectorSignedGreaterThanAtom::new(y.into(), bvc.into())?;
let a3 = BitVectorSignedLessThanAtom::new(
    BitVectorAdd::new(x.into(), y.into())?.into(),
    x.into(),
)?;
ctx.assert([a1.into(), a2.into(), a3.into()])?;

assert_eq!(ctx.check()?, Status::STATUS_SAT);

Usage

You can add this crate to your project by running:

cargo add yices2

Or by adding this line to your Cargo.toml:

yices2 = { version = "2.6.4" }

Features

By default, yices2 enables the ctor feature, which calls yices_init at program initialization and yices_exit at program exit. If you'd like to disable this behavior, you can use the default-features = false flag in your Cargo.toml.

yices2 = { version = "2.6.4", default-features = false }

No runtime deps