use ascent::ascent;
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct Instr(&'static str);
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct Context(&'static str);
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub enum Res {
Ok,
Err,
}
ascent! {
relation succ(Instr, Context, Instr, Context);
relation flow(Instr, Context, Instr, Context);
flow(i1, c1, i2, c2) <-- succ(i1, c1, i2, c2);
flow(i1, c1, i3, c3) <-- flow(i1, c1, i2, c2), flow(i2, c2, i3, c3);
relation res(Res);
res(Res::Ok) <-- flow(Instr("w1"), Context("c1"), Instr("r2"), Context("c1"));
res(Res::Err) <-- flow(Instr("w1"), Context("c1"), Instr("r2"), Context("c2"));
}
fn main() {
let mut prog = AscentProgram::default();
prog.succ = vec![
(Instr("w1"), Context("c1"), Instr("w2"), Context("c1")),
(Instr("w2"), Context("c1"), Instr("r1"), Context("c1")),
(Instr("r1"), Context("c1"), Instr("r2"), Context("c1")),
(Instr("w1"), Context("c2"), Instr("w2"), Context("c2")),
(Instr("w2"), Context("c2"), Instr("r1"), Context("c2")),
(Instr("r1"), Context("c2"), Instr("r2"), Context("c2")),
];
prog.run();
let AscentProgram { res, .. } = prog;
assert_eq!(res, vec![(Res::Ok,),]);
}