Skip to content

Commit

Permalink
Propogate solver options into synthesizer (#2320)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinheping authored Apr 7, 2023
1 parent f70faac commit 911b8b9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kani-driver/src/call_cbmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl KaniSession {
args
}

fn handle_solver_args(
pub fn handle_solver_args(
&self,
harness_solver: &Option<CbmcSolver>,
args: &mut Vec<OsString>,
Expand Down
12 changes: 10 additions & 2 deletions kani-driver/src/call_goto_synthesizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::util::warning;
use anyhow::Result;
use kani_metadata::HarnessMetadata;
use std::ffi::OsString;
use std::path::Path;
use std::process::Command;
Expand All @@ -14,7 +15,12 @@ impl KaniSession {
/// The synthesizer we use is `goto-synthesizer` built in CBMC codebase, which is an enumerative
/// loop-contracts synthesizer. `goto-synthesizer` enumerates and checks if a candidate can be
/// used to prove some assertions, and applies found invariants when all checks pass.
pub fn synthesize_loop_contracts(&self, input: &Path, output: &Path) -> Result<()> {
pub fn synthesize_loop_contracts(
&self,
input: &Path,
output: &Path,
harness_metadata: &HarnessMetadata,
) -> Result<()> {
if !self.args.quiet {
println!("Running loop contract synthesizer.");
warning("This process may not terminate.");
Expand All @@ -23,12 +29,14 @@ impl KaniSession {
);
}

let args: Vec<OsString> = vec![
let mut args: Vec<OsString> = vec![
"--loop-contracts-no-unwind".into(),
input.to_owned().into_os_string(), // input
output.to_owned().into_os_string(), // output
];

self.handle_solver_args(&harness_metadata.attributes.solver, &mut args)?;

let mut cmd = Command::new("goto-synthesizer");
cmd.args(args);

Expand Down
6 changes: 5 additions & 1 deletion kani-driver/src/harness_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ impl<'sess, 'pr> HarnessRunner<'sess, 'pr> {
)?;

if self.sess.args.synthesize_loop_contracts {
self.sess.synthesize_loop_contracts(&specialized_obj, &specialized_obj)?;
self.sess.synthesize_loop_contracts(
&specialized_obj,
&specialized_obj,
&harness,
)?;
}

let result = self.sess.check_harness(&specialized_obj, &report_dir, harness)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// loop invariants.

#[kani::proof]
#[kani::solver(kissat)]
fn main() {
let mut x: u64 = kani::any_where(|i| *i > 1);

Expand Down

0 comments on commit 911b8b9

Please sign in to comment.