Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propogate solver options into synthesizer #2320

Merged
merged 2 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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