pub use crate::logic::{Decl, Expr, Formula, Multiplicity, Quantifier, Variable};
pub use crate::{Action, Command, Model, Options, Report, Step, Verdict};
const NAMES: [&str; 6] = ["x", "y", "z", "u", "v", "w"];
fn quantified<const N: usize>(
q: Quantifier,
sets: [&Expr; N],
body: impl FnOnce([Expr; N]) -> Formula,
) -> Formula {
let vars: [Variable; N] = std::array::from_fn(|i| {
Variable::new(
NAMES
.get(i)
.map_or_else(|| format!("x{i}"), |n| (*n).to_string()),
)
});
let exprs: [Expr; N] = std::array::from_fn(|i| Expr::variable(&vars[i]));
let decls = vars
.iter()
.zip(sets)
.map(|(v, s)| Decl::new(v, s))
.collect();
Formula::quantified(q, decls, &body(exprs))
}
pub fn all<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
quantified(Quantifier::All, sets, body)
}
pub fn some<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
quantified(Quantifier::Some, sets, body)
}
pub fn no<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
quantified(Quantifier::No, sets, body)
}
pub fn one<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
quantified(Quantifier::One, sets, body)
}
pub fn lone<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
quantified(Quantifier::Lone, sets, body)
}
pub fn always(f: Formula) -> Formula {
f.always()
}
pub fn eventually(f: Formula) -> Formula {
f.eventually()
}