2020-02-02 19:20:16 +01:00
|
|
|
use structopt::StructOpt as _;
|
|
|
|
|
|
|
|
#[derive(Debug, structopt::StructOpt)]
|
|
|
|
#[structopt(name = "anthem", about = "Use first-order theorem provers with answer set programs.")]
|
2020-02-03 22:20:13 +01:00
|
|
|
enum Command
|
2020-02-02 19:20:16 +01:00
|
|
|
{
|
2020-02-03 22:20:13 +01:00
|
|
|
#[structopt(about = "Verifies a logic program against a specification")]
|
|
|
|
VerifyProgram
|
|
|
|
{
|
2020-02-03 22:50:53 +01:00
|
|
|
/// ASP input program (one or multiple files)
|
2020-02-03 22:50:33 +01:00
|
|
|
#[structopt(parse(from_os_str), required(true))]
|
2020-02-03 22:20:13 +01:00
|
|
|
input: Vec<std::path::PathBuf>,
|
2020-02-03 22:51:19 +01:00
|
|
|
|
|
|
|
/// Output format (human-readable, tptp)
|
|
|
|
#[structopt(long, default_value = "human-readable")]
|
|
|
|
output_format: anthem::output::Format,
|
2020-02-05 01:10:33 +01:00
|
|
|
|
2020-02-05 19:42:53 +01:00
|
|
|
/// Input predicates (examples: p, q/2)
|
2020-02-05 01:10:33 +01:00
|
|
|
#[structopt(long, parse(try_from_str = anthem::parse_predicate_declaration))]
|
|
|
|
input_predicates: Vec<std::rc::Rc<foliage::PredicateDeclaration>>,
|
2020-02-05 19:40:21 +01:00
|
|
|
|
|
|
|
/// Input constants (example: c, integer(n))
|
|
|
|
#[structopt(long, parse(try_from_str = anthem::parse_constant_declaration))]
|
|
|
|
input_constants: Vec<
|
|
|
|
(std::rc::Rc<foliage::FunctionDeclaration>, anthem::Domain)>,
|
2020-02-03 22:20:13 +01:00
|
|
|
}
|
2020-02-02 19:20:16 +01:00
|
|
|
}
|
|
|
|
|
2020-02-01 17:13:43 +01:00
|
|
|
fn main()
|
2020-01-24 13:32:43 +01:00
|
|
|
{
|
2020-01-31 17:19:44 +01:00
|
|
|
pretty_env_logger::init();
|
|
|
|
|
2020-02-03 22:20:13 +01:00
|
|
|
let command = Command::from_args();
|
2020-02-01 19:20:46 +01:00
|
|
|
|
2020-02-03 22:20:13 +01:00
|
|
|
match command
|
2020-02-02 17:57:27 +01:00
|
|
|
{
|
2020-02-03 22:51:19 +01:00
|
|
|
Command::VerifyProgram
|
|
|
|
{
|
|
|
|
input,
|
|
|
|
output_format,
|
2020-02-05 01:10:33 +01:00
|
|
|
input_predicates,
|
2020-02-05 19:40:21 +01:00
|
|
|
input_constants,
|
2020-02-03 22:51:19 +01:00
|
|
|
}
|
|
|
|
=>
|
2020-02-03 22:20:13 +01:00
|
|
|
{
|
2020-02-04 00:27:04 +01:00
|
|
|
if let Err(error) = anthem::translate::verify_properties::translate(&input,
|
2020-02-05 01:10:33 +01:00
|
|
|
input_predicates.into_iter().collect::<foliage::PredicateDeclarations>(),
|
2020-02-05 19:40:21 +01:00
|
|
|
input_constants.into_iter().collect::<std::collections::BTreeMap<_, _>>(),
|
2020-02-04 00:27:04 +01:00
|
|
|
output_format)
|
2020-02-03 22:20:13 +01:00
|
|
|
{
|
|
|
|
log::error!("could not translate input program: {}", error);
|
|
|
|
std::process::exit(1)
|
|
|
|
}
|
|
|
|
},
|
2020-02-02 17:57:27 +01:00
|
|
|
}
|
2020-01-24 13:32:43 +01:00
|
|
|
}
|