anthem-rs/src/commands/verify_program.rs

69 lines
1.7 KiB
Rust
Raw Normal View History

pub fn run<P>(program_path: P, specification_path: P, proof_direction:
crate::problem::ProofDirection)
2020-05-06 21:30:27 +02:00
where
2020-05-11 03:46:20 +02:00
P: AsRef<std::path::Path>,
2020-05-06 21:30:27 +02:00
{
//let context = crate::translate::verify_properties::Context::new();
let mut problem = crate::Problem::new();
log::info!("reading specification “{}”", specification_path.as_ref().display());
let specification_content = match std::fs::read_to_string(specification_path.as_ref())
{
Ok(specification_content) => specification_content,
Err(error) =>
{
log::error!("could not access specification file: {}", error);
std::process::exit(1)
},
};
// TODO: rename to read_specification
match crate::input::parse_specification(&specification_content, &mut problem)
{
Ok(_) => (),
Err(error) =>
{
log::error!("could not read specification: {}", error);
std::process::exit(1)
}
}
log::info!("read specification “{}”", specification_path.as_ref().display());
log::info!("reading input program “{}”", program_path.as_ref().display());
// TODO: make consistent with specification call (path vs. content)
match crate::translate::verify_properties::Translator::new(&mut problem).translate(program_path)
{
Ok(_) => (),
Err(error) =>
{
log::error!("could not translate input program: {}", error);
std::process::exit(1)
}
}
2020-05-13 07:41:01 +02:00
match problem.restrict_to_output_predicates()
{
Ok(_) => (),
Err(error) =>
{
log::error!("could not restrict problem to output predicates: {}", error);
std::process::exit(1)
}
}
2020-05-07 02:53:48 +02:00
match problem.prove(proof_direction)
2020-05-06 21:30:27 +02:00
{
Ok(()) => (),
Err(error) =>
{
log::error!("could not verify program: {}", error);
std::process::exit(1)
}
}
log::info!("done");
}