Skip to content

Commit

Permalink
Add cadical to the list of available solvers (#2217)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhassan-aws authored Mar 3, 2023
1 parent 33bdc6d commit c408045
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kani-driver/src/call_cbmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ impl KaniSession {
};

match solver {
CbmcSolver::Cadical => {
args.push("--sat-solver".into());
args.push("cadical".into());
}
CbmcSolver::Kissat => {
args.push("--external-sat-solver".into());
args.push("kissat".into());
Expand Down
3 changes: 3 additions & 0 deletions kani_metadata/src/cbmc_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use strum_macros::{AsRefStr, EnumString, EnumVariantNames};
)]
#[strum(serialize_all = "snake_case")]
pub enum CbmcSolver {
/// CaDiCaL which is available in CBMC as of version 5.77.0
Cadical,

/// The kissat solver that is included in the Kani bundle
Kissat,

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/solver-attribute/cadical/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Solving with CaDiCaL
VERIFICATION:- SUCCESSFUL
14 changes: 14 additions & 0 deletions tests/ui/solver-attribute/cadical/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! Checks that `cadical` is a valid argument to `kani::solver`
#[kani::proof]
#[kani::solver(cadical)]
fn check() {
let mut a = [2, 3, 1];
a.sort();
assert_eq!(a[0], 1);
assert_eq!(a[1], 2);
assert_eq!(a[2], 3);
}
2 changes: 2 additions & 0 deletions tests/ui/solver-option/cadical/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Solving with CaDiCaL
VERIFICATION:- SUCCESSFUL
12 changes: 12 additions & 0 deletions tests/ui/solver-option/cadical/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: --solver cadical

//! Checks that the `cadical` is supported as an argument to `--solver`
#[kani::proof]
fn check_solver_option() {
let v = vec![kani::any(), 2];
let v_copy = v.clone();
assert_eq!(v, v_copy);
}

0 comments on commit c408045

Please sign in to comment.