elinvar_engine/
prelude.rs1pub use crate::logic::{Decl, Expr, Formula, Multiplicity, Quantifier, Variable};
25pub use crate::{Action, Command, Model, Options, Report, Step, Verdict};
26
27const NAMES: [&str; 6] = ["x", "y", "z", "u", "v", "w"];
28
29fn quantified<const N: usize>(
30 q: Quantifier,
31 sets: [&Expr; N],
32 body: impl FnOnce([Expr; N]) -> Formula,
33) -> Formula {
34 let vars: [Variable; N] = std::array::from_fn(|i| {
35 Variable::new(
36 NAMES
37 .get(i)
38 .map_or_else(|| format!("x{i}"), |n| (*n).to_string()),
39 )
40 });
41 let exprs: [Expr; N] = std::array::from_fn(|i| Expr::variable(&vars[i]));
42 let decls = vars
43 .iter()
44 .zip(sets)
45 .map(|(v, s)| Decl::new(v, s))
46 .collect();
47 Formula::quantified(q, decls, &body(exprs))
48}
49
50pub fn all<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
52 quantified(Quantifier::All, sets, body)
53}
54
55pub fn some<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
57 quantified(Quantifier::Some, sets, body)
58}
59
60pub fn no<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
62 quantified(Quantifier::No, sets, body)
63}
64
65pub fn one<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
67 quantified(Quantifier::One, sets, body)
68}
69
70pub fn lone<const N: usize>(sets: [&Expr; N], body: impl FnOnce([Expr; N]) -> Formula) -> Formula {
72 quantified(Quantifier::Lone, sets, body)
73}
74
75pub fn always(f: Formula) -> Formula {
77 f.always()
78}
79
80pub fn eventually(f: Formula) -> Formula {
82 f.eventually()
83}