#![doc = include_str!("../README.md")]
use std::collections::HashMap;
use proc_macro2::TokenStream;
use serde::{Deserialize, Serialize};
use thiserror::Error;
pub mod check;
pub mod iir;
pub mod ir_common;
mod node_id;
pub use mck::{KnownParamValuation, ParamValuation, ThreeValued};
pub use node_id::{NodeId, StateId};
use crate::check::KnownConclusion;
#[derive(Error, Debug, Serialize, Deserialize, Clone)]
#[non_exhaustive]
pub enum ExecError {
#[error("incomplete verification")]
Incomplete,
#[error("field '{0}' not found")]
FieldNotFound(String),
#[error("index {0} is invalid for the field '{1}'")]
IndexInvalid(u64, String),
#[error("indexing is required for the field '{0}'")]
IndexRequired(String),
#[error("signedness of the use of field '{0}' was not estabilished")]
SignednessNotEstabilished(String),
#[error("property '{0}' could not be constructed: {1}")]
PropertyNotConstructible(String, String),
#[error("inherent panic")]
InherentPanic,
#[error("inherent panic possible depending on parameters")]
InherentPanicDependent,
#[error("non-monotone property")]
NonMonotoneProperty,
#[error("cannot verify inherent property while assuming it")]
VerifiedInherentAssumed,
#[error("GUI error: {0}")]
GuiError(String),
#[error("no result")]
NoResult,
#[error("{0}")]
OtherError(String),
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ExecResult {
pub result: Result<KnownConclusion, ExecError>,
pub stats: ExecStats,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ExecStats {
pub num_refinements: usize,
pub num_generated_states: usize,
pub num_final_states: usize,
pub num_generated_transitions: usize,
pub num_final_transitions: usize,
pub inherent_panic_message: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Signedness {
None,
Unsigned,
Signed,
}
pub type PropertyMacroFn<D> = fn(&D, TokenStream) -> Result<TokenStream, anyhow::Error>;
#[doc(hidden)]
pub struct PropertyMacros<D> {
pub macros: HashMap<String, PropertyMacroFn<D>>,
pub data: D,
}
#[doc(hidden)]
impl PropertyMacros<()> {
pub fn empty() -> Self {
Self {
macros: HashMap::new(),
data: (),
}
}
}