pub mod agg;
mod claim;
pub mod effects;
pub mod eval;
mod eval_expr;
mod eval_match;
pub mod float;
mod fm;
pub mod infer;
mod infer_uses;
mod obligation;
pub mod poly;
mod poly_div;
pub mod prove;
pub mod report;
mod roots;
pub mod search;
pub mod smt;
pub mod sym;
mod sym_agg;
mod sym_call;
mod sym_effects;
mod sym_expr;
mod sym_if;
mod sym_match;
pub mod sym_ops;
pub mod term;
pub mod ty;
#[cfg(test)]
mod tests;
use crate::ast::{FnDef, ItemKind, Module};
use crate::parser::{ENSURES_PREFIX, LAW_ATTR, REQUIRES_PREFIX};
use claim::check;
use eval::{Eval, Stop, Val};
use infer::Sigs;
use obligation::{prove_symbolic, run_concrete};
use std::collections::HashMap;
use sym::Sym;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Kind {
Law,
Ensures,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Verdict {
Proved { engine: String },
Refuted {
input: Vec<(String, String)>,
why: String,
},
Unknown { reason: String },
Inconsistent { input: Vec<(String, String)> },
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Traps {
NoneExhaustive,
NoneSampled,
Witness {
input: Vec<(String, String)>,
why: String,
},
}
#[derive(Clone, Debug)]
pub struct Outcome {
pub kind: Kind,
pub name: String,
pub verdict: Verdict,
pub traps: Traps,
pub inputs_run: usize,
}
const FUEL: u64 = 200_000;
pub fn verify_module(module: &Module) -> Vec<Outcome> {
let mut fns: HashMap<String, &FnDef> = HashMap::new();
let mut laws = Vec::new();
for item in &module.items {
if let ItemKind::Function(f) = &item.kind {
fns.insert(f.name.name.to_string(), f);
let is_law = item
.attrs
.iter()
.any(|a| a.path.segments.len() == 1 && &*a.path.segments[0].ident.name == LAW_ATTR);
if is_law {
laws.push(f.name.name.to_string());
}
}
}
let sigs = Sigs::from_module(&module.items);
let mut out = Vec::new();
for law in &laws {
out.push(check(&fns, &sigs, Kind::Law, law));
}
let mut contracted: Vec<String> = fns
.keys()
.filter_map(|k| k.strip_prefix(ENSURES_PREFIX).map(str::to_string))
.collect();
contracted.sort();
for f in contracted {
out.push(check(&fns, &sigs, Kind::Ensures, &f));
}
out
}