crates/kleene-plan/tests/set_numbers.rs
//! A number for each distinct set ([`Aggregate::set_number`] into a table of sets,
//! [`Plan::sets`]): the body's bindings grouped by a key, each group's distinct elements its
//! set, the set's number in the table. Equal sets share a number, across rules and heads;
//! the sets new at a moment are numbered in rising order of their sorted members. Plain
//! use runs as it stands; recursion through the table runs as a group of rounds. Checked
//! on the order's graph, against a subset construction in plain Rust on random graphs (at
//! 1 thread and at 8), for the limit, the proofs, the refusals, a set that grows from
//! round to round, two heads in one table, a continued run, and a machine of more than
//! 20000 states.
use std::collections::{BTreeMap, BTreeSet};
use std::time::Instant;
use kleene_graph::SplitKey;
use kleene_plan::{
Aggregate, Atom, DEFAULT_SET_LIMIT, Engine, Facts, How, Inputs, Literal, Part, Plan, PlanError,
RelId, Term, Trace, Value, Var, plan,
};
use kleene_sparse::{CpuBackend, CpuDevice};
fn v(x: Var) -> Term {
Term::Var(x)
}
fn at(rel: RelId, vars: &[Var]) -> Atom {
Atom {
rel,
terms: vars.iter().map(|&x| v(x)).collect(),
}
}
fn pos(rel: RelId, vars: &[Var]) -> Literal {
Literal::Pos(at(rel, vars))
}
fn rows(out: &kleene_plan::Output, rel: RelId) -> BTreeSet<Vec<Value>> {
out.get(rel).unwrap().rows().collect()
}
fn engine(threads: usize) -> Engine<CpuBackend> {
Engine::new(CpuDevice::new(threads))
}
const A: Value = 1000;
const B: Value = 1001;
/// The rules of the design page's part 2:
/// ```text
/// sets state/2.
/// clo(X, X) :- start(_, X).
/// clo(Z, Z) :- edge(_, _, Z).
/// clo(X, Z) :- clo(X, Y), eps(Y, Z).
/// first(K, N) :- N = set(X) by (K) in state: start(K, S), clo(S, X).
/// step(P, A, N) :- N = set(Y) by (P, A) in state: state(P, X), edge(X, A, Z), clo(Z, Y).
/// rounds first: keep, step: keep, state: keep.
/// ```
struct Machine {
p: Plan,
edge: RelId,
eps: RelId,
start: RelId,
state: RelId,
first: RelId,
step: RelId,
}
fn machine(limit: Option<u64>, rounds: bool) -> Machine {
let mut p = Plan::new();
let edge = p.input("edge", 3);
let eps = p.input("eps", 2);
let start = p.input("start", 2);
let clo = p.derived("clo", 2);
let state = p.sets("state", 2, limit);
let first = p.derived("first", 2);
let step = p.derived("step", 3);
let [k, s, x, y, z, pp, a, n, w, u] =
["K", "S", "X", "Y", "Z", "P", "A", "N", "W", "U"].map(|name| p.var(name));
p.rule(at(clo, &[x, x]), [pos(start, &[w, x])]).unwrap();
p.rule(at(clo, &[z, z]), [pos(edge, &[w, u, z])]).unwrap();
p.rule(at(clo, &[x, z]), [pos(clo, &[x, y]), pos(eps, &[y, z])])
.unwrap();
let r = p
.aggregate(
at(first, &[k, n]),
Aggregate::set_number([k], [x], n, state),
[pos(start, &[k, s]), pos(clo, &[s, x])],
)
.unwrap();
assert_eq!(
p.show_rule(r),
"first(K, N) :- N = set (X) by (K) in state: start(K, S), clo(S, X)."
);
let r = p
.aggregate(
at(step, &[pp, a, n]),
Aggregate::set_number([pp, a], [y], n, state),
[
pos(state, &[pp, x]),
pos(edge, &[x, a, z]),
pos(clo, &[z, y]),
],
)
.unwrap();
assert_eq!(
p.show_rule(r),
"step(P, A, N) :- N = set (Y) by (P, A) in state: state(P, X), edge(X, A, Z), clo(Z, Y)."
);
if rounds {
p.rounds([(first, Part::Keep), (step, Part::Keep), (state, Part::Keep)])
.unwrap();
}
Machine {
p,
edge,
eps,
start,
state,
first,
step,
}
}
fn machine_inputs(
m: &Machine,
edges: &[[Value; 3]],
eps: &[[Value; 2]],
starts: &[[Value; 2]],
) -> Inputs {
let mut inp = Inputs::new();
inp.facts(m.edge, Facts::from_rows(3, edges.iter()).unwrap())
.facts(m.eps, Facts::from_rows(2, eps.iter()).unwrap())
.facts(m.start, Facts::from_rows(2, starts.iter()).unwrap());
inp
}
fn order_graph(m: &Machine) -> Inputs {
machine_inputs(
m,
&[[1, A, 2], [1, A, 3], [3, B, 1], [4, B, 4]],
&[[2, 4]],
&[[0, 1]],
)
}
fn table(sets: &[&[Value]]) -> BTreeSet<Vec<Value>> {
sets.iter()
.enumerate()
.flat_map(|(n, s)| s.iter().map(move |&x| vec![n as Value, x]))
.collect()
}
/// a. The order's graph: 4 states, 5 steps, exactly these numbers.
#[tokio::test]
async fn the_order_s_graph_gives_its_machine() {
let m = machine(None, true);
for threads in [1, 8] {
let out = engine(threads).run(&m.p, &order_graph(&m)).await.unwrap();
assert_eq!(
rows(&out, m.state),
table(&[&[1], &[2, 3, 4], &[1, 4], &[4]])
);
let steps: BTreeSet<Vec<Value>> = [[0, A, 1], [1, B, 2], [2, A, 1], [2, B, 3], [3, B, 3]]
.map(|r| r.to_vec())
.into();
assert_eq!(rows(&out, m.step), steps);
assert_eq!(rows(&out, m.first), BTreeSet::from([vec![0, 0]]));
}
}
/// `member(K, X)` numbered into `tab` as `id(K, N)`; a second head `id2` from `member2`.
struct Plain {
p: Plan,
member: RelId,
member2: RelId,
tab: RelId,
id: RelId,
id2: RelId,
}
fn plain(limit: Option<u64>) -> Plain {
let mut p = Plan::new();
let member = p.input("member", 2);
let member2 = p.input("member2", 2);
let tab = p.sets("tab", 2, limit);
let id = p.derived("id", 2);
let id2 = p.derived("id2", 2);
let (k, x, n) = (p.var("K"), p.var("X"), p.var("N"));
p.aggregate(
at(id, &[k, n]),
Aggregate::set_number([k], [x], n, tab),
[pos(member, &[k, x])],
)
.unwrap();
p.aggregate(
at(id2, &[k, n]),
Aggregate::set_number([k], [x], n, tab),
[pos(member2, &[k, x])],
)
.unwrap();
Plain {
p,
member,
member2,
tab,
id,
id2,
}
}
fn plain_inputs(q: &Plain, member: &[[Value; 2]], member2: &[[Value; 2]]) -> Inputs {
let mut inp = Inputs::new();
inp.facts(q.member, Facts::from_rows(2, member.iter()).unwrap())
.facts(q.member2, Facts::from_rows(2, member2.iter()).unwrap());
inp
}
const MEMBERS: [[Value; 2]; 7] = [
[10, 3],
[10, 1],
[20, 2],
[30, 1],
[30, 3],
[40, 1],
[40, 2],
];
/// b. Plain use, no rounds: equal sets share a number, numbers in sorted-member order.
#[tokio::test]
async fn plain_use_numbers_sets_in_sorted_member_order() {
let q = plain(None);
assert_eq!(q.p.set_limit(q.tab), Some(DEFAULT_SET_LIMIT));
assert_eq!(q.p.set_limit(q.id), None);
// {1, 2} < {1, 3} < {2}
let mut members = MEMBERS.to_vec();
members.push([40, 1]);
for threads in [1, 8] {
let out = engine(threads)
.run(&q.p, &plain_inputs(&q, &members, &[]))
.await
.unwrap();
assert_eq!(
rows(&out, q.id),
[[10, 1], [20, 2], [30, 1], [40, 0]]
.map(|r| r.to_vec())
.into()
);
assert_eq!(rows(&out, q.tab), table(&[&[1, 2], &[1, 3], &[2]]));
assert!(rows(&out, q.id2).is_empty());
}
}
/// h. Two rules with different heads number into one table and share numbers.
#[tokio::test]
async fn two_heads_share_one_table() {
let q = plain(None);
let m1 = [[1, 5], [1, 6], [2, 7]];
let m2 = [[1, 7], [3, 6], [3, 5], [4, 8]];
let out = engine(4)
.run(&q.p, &plain_inputs(&q, &m1, &m2))
.await
.unwrap();
// {5, 6} < {7} < {8}
assert_eq!(rows(&out, q.tab), table(&[&[5, 6], &[7], &[8]]));
assert_eq!(
rows(&out, q.id),
[[1, 0], [2, 1]].map(|r| r.to_vec()).into()
);
assert_eq!(
rows(&out, q.id2),
[[1, 1], [3, 0], [4, 2]].map(|r| r.to_vec()).into()
);
}
/// d. The limit: one set over it stops the run; exactly at it passes.
#[tokio::test]
async fn the_limit_stops_the_run() {
let q = plain(Some(3));
let out = engine(2)
.run(&q.p, &plain_inputs(&q, &MEMBERS, &[]))
.await
.unwrap();
assert_eq!(rows(&out, q.tab).len(), 5);
let q = plain(Some(2));
let err = engine(2)
.run(&q.p, &plain_inputs(&q, &MEMBERS, &[]))
.await
.unwrap_err();
assert!(
matches!(&err, PlanError::SetLimit { table, limit: 2 } if table == "tab"),
"{err}"
);
assert_eq!(err.to_string(), "sets `tab`: more than 2 sets");
// inside rounds too: the order's graph has 4 sets
let m = machine(Some(4), true);
assert!(engine(1).run(&m.p, &order_graph(&m)).await.is_ok());
let m = machine(Some(3), true);
let err = engine(1).run(&m.p, &order_graph(&m)).await.unwrap_err();
assert_eq!(err.to_string(), "sets `state`: more than 3 sets");
}
/// e. Proofs: a step's proof holds its key's member rows and the set's number; a table
/// row names the numbered fact that first gave its set.
#[tokio::test]
async fn proofs_show_members_and_the_first_fact() {
let m = machine(None, true);
let out = engine(2)
.explain(true)
.run(&m.p, &order_graph(&m))
.await
.unwrap();
// step(1, b, 2): state 1 = {2, 3, 4}; b from 3 to 1, from 4 to 4: {1, 4} = set 2
let proof = out.why(&m.p, m.step, &[1, B, 2]).unwrap();
let text = proof.render(&m.p);
let How::Numbered {
members,
table,
number,
..
} = &proof.how
else {
panic!("{text}");
};
assert_eq!((*table, *number), (m.state, 2), "{text}");
assert_eq!(members.len(), 2, "{text}");
for mem in members {
assert_eq!(mem.premises.len(), 3);
assert_eq!(mem.premises[0].rel, m.state);
assert_eq!(mem.premises[0].tuple[0], 1);
// state(1, X) rests on the fact that first gave set 1: step(0, a, 1)
let How::Set { number: 1, first } = &mem.premises[0].how else {
panic!("{text}");
};
assert_eq!((first.rel, first.tuple.clone()), (m.step, vec![0, A, 1]));
assert!(matches!(first.how, How::Numbered { number: 1, .. }));
}
assert!(text.contains("set 2 of `state`"), "{text}");
// first(0, 0) rests on start(0, 1), clo(1, 1)
let proof = out.why(&m.p, m.first, &[0, 0]).unwrap();
let How::Numbered { members, .. } = &proof.how else {
panic!("{}", proof.render(&m.p));
};
assert_eq!(members.len(), 1);
// a table row: state(2, 4) was first given by step(1, b, 2)
let proof = out.why(&m.p, m.state, &[2, 4]).unwrap();
let How::Set { number: 2, first } = &proof.how else {
panic!("{}", proof.render(&m.p));
};
assert_eq!((first.rel, first.tuple.clone()), (m.step, vec![1, B, 2]));
// state(0, 1): first(0, 0)
let proof = out.why(&m.p, m.state, &[0, 1]).unwrap();
let How::Set { first, .. } = &proof.how else {
panic!("{}", proof.render(&m.p));
};
assert_eq!((first.rel, first.tuple.clone()), (m.first, vec![0, 0]));
assert!(out.why(&m.p, m.state, &[2, 2]).is_none());
// plain use: the table's rows and the heads are proven too
let q = plain(None);
let out = engine(1)
.explain(true)
.run(&q.p, &plain_inputs(&q, &MEMBERS, &[]))
.await
.unwrap();
let proof = out.why(&q.p, q.id, &[10, 1]).unwrap();
let How::Numbered {
members, number, ..
} = &proof.how
else {
panic!("{}", proof.render(&q.p));
};
assert_eq!((members.len(), *number), (2, 1));
let proof = out.why(&q.p, q.tab, &[1, 3]).unwrap();
let How::Set { first, .. } = &proof.how else {
panic!("{}", proof.render(&q.p));
};
// the least fact of set 1 at its moment: id(10, 1) before id(30, 1)
assert_eq!(first.tuple, vec![10, 1]);
}
/// f. Refusals, each by its message.
#[tokio::test]
async fn refusals_name_what_is_wrong() {
let mut p = Plan::new();
let member = p.input("member", 2);
let tab = p.sets("tab", 2, None);
let other = p.derived("other", 2);
let id = p.derived("id", 2);
let (k, x, y, n) = (p.var("K"), p.var("X"), p.var("Y"), p.var("N"));
let err = p
.rule(at(tab, &[k, x]), [pos(member, &[k, x])])
.unwrap_err();
assert!(
err.to_string().contains("`tab` is a table of sets"),
"{err}"
);
let err = p
.aggregate(
at(id, &[k, n]),
Aggregate::set_number([k], [x], n, other),
[pos(member, &[k, x])],
)
.unwrap_err();
assert!(
err.to_string()
.contains("`other`, which is not a table of sets"),
"{err}"
);
let err = p
.aggregate(
at(id, &[k, n]),
Aggregate::set_number([k], [x, y], n, tab),
[pos(member, &[k, x]), pos(member, &[x, y])],
)
.unwrap_err();
assert!(err.to_string().contains("whose elements have 1"), "{err}");
let err = p.rounds([(tab, Part::Fresh)]).unwrap_err();
assert!(err.to_string().contains("keep, not fresh"), "{err}");
// recursion through the table without its rounds line
let m = machine(None, false);
let err = plan(&m.p).unwrap_err();
assert!(
err.to_string()
.contains("rounds first: keep, step: keep, state: keep"),
"{err}"
);
// a rounds line without the table
let mut m = machine(None, false);
m.p.rounds([(m.first, Part::Keep), (m.step, Part::Keep)])
.unwrap();
let err = plan(&m.p).unwrap_err();
assert!(err.to_string().contains("`state`"), "{err}");
// a split run
let q = plain(None);
let split: Engine<CpuBackend> = engine(2).split(SplitKey::Hash(2));
let err = split
.run(&q.p, &plain_inputs(&q, &MEMBERS, &[]))
.await
.unwrap_err();
assert!(
matches!(&err, PlanError::NotSplittable(m) if m.contains("tab")),
"{err}"
);
}
/// g. A key whose set grows from round to round: `a` takes one more step along `e` per
/// round, and `g(0, N)` numbers all of `a`.
async fn growing(part: Part) -> (BTreeSet<Vec<Value>>, BTreeSet<Vec<Value>>) {
let mut p = Plan::new();
let s = p.input("s", 1);
let e = p.input("e", 2);
let key = p.input("key", 1);
let a = p.derived("a", 1);
let b = p.derived("b", 1);
let tab = p.sets("tab", 2, None);
let g = p.derived("g", 2);
let (x, y, k, n) = (p.var("X"), p.var("Y"), p.var("K"), p.var("N"));
p.rule(at(a, &[x]), [pos(s, &[x])]).unwrap();
p.rule(at(a, &[y]), [pos(b, &[x]), pos(e, &[x, y])])
.unwrap();
p.rule(at(b, &[x]), [pos(a, &[x])]).unwrap();
p.aggregate(
at(g, &[k, n]),
Aggregate::set_number([k], [x], n, tab),
[pos(key, &[k]), pos(a, &[x])],
)
.unwrap();
p.rounds([
(a, Part::Keep),
(g, part),
(tab, Part::Keep),
(b, Part::Keep),
])
.unwrap();
let mut inp = Inputs::new();
inp.facts(s, Facts::from_rows(1, [[0u64]]).unwrap())
.facts(e, Facts::from_rows(2, [[0u64, 1], [1, 2], [2, 3]]).unwrap())
.facts(key, Facts::from_rows(1, [[0u64]]).unwrap());
let out = engine(3).run(&p, &inp).await.unwrap();
(rows(&out, g), rows(&out, tab))
}
#[tokio::test]
async fn a_growing_set_fresh_holds_the_last_keep_holds_all() {
let all = table(&[&[0], &[0, 1], &[0, 1, 2], &[0, 1, 2, 3]]);
let (g, tab) = growing(Part::Fresh).await;
assert_eq!(g, BTreeSet::from([vec![0, 3]]));
assert_eq!(tab, all);
let (g, tab) = growing(Part::Keep).await;
assert_eq!(
g,
[[0, 0], [0, 1], [0, 2], [0, 3]].map(|r| r.to_vec()).into()
);
assert_eq!(tab, all);
}
struct Lcg(u64);
impl Lcg {
fn below(&mut self, n: u64) -> u64 {
self.0 = self
.0
.wrapping_mul(6364136223846793005)
.wrapping_add(1442695040888963407);
(self.0 >> 33) % n
}
}
/// The subset construction in plain Rust, numbered the same way: the start sets first,
/// then level by level, each level's new sets in rising order of their sorted members.
/// Returns (states, firsts, steps).
#[allow(clippy::type_complexity)]
fn subsets(
edges: &[[Value; 3]],
eps: &[[Value; 2]],
starts: &[[Value; 2]],
) -> (
BTreeSet<Vec<Value>>,
BTreeSet<Vec<Value>>,
BTreeSet<Vec<Value>>,
) {
let clo = |v: Value| -> BTreeSet<Value> {
let mut seen = BTreeSet::from([v]);
let mut todo = vec![v];
while let Some(x) = todo.pop() {
for e in eps.iter().filter(|e| e[0] == x) {
if seen.insert(e[1]) {
todo.push(e[1]);
}
}
}
seen
};
let mut number: BTreeMap<Vec<Value>, Value> = BTreeMap::new();
let give = |new: BTreeSet<Vec<Value>>, number: &mut BTreeMap<Vec<Value>, Value>| {
let mut level = Vec::new();
for s in new {
if !number.contains_key(&s) {
let n = number.len() as Value;
number.insert(s.clone(), n);
level.push(s);
}
}
level
};
let mut start_sets: BTreeMap<Value, BTreeSet<Value>> = BTreeMap::new();
for s in starts {
start_sets.entry(s[0]).or_default().extend(clo(s[1]));
}
let as_vec = |s: &BTreeSet<Value>| s.iter().copied().collect::<Vec<Value>>();
let mut level = give(start_sets.values().map(as_vec).collect(), &mut number);
let mut moves: Vec<(Vec<Value>, Value, Vec<Value>)> = Vec::new();
while !level.is_empty() {
let mut new = BTreeSet::new();
for set in &level {
let mut by: BTreeMap<Value, BTreeSet<Value>> = BTreeMap::new();
for e in edges.iter().filter(|e| set.contains(&e[0])) {
by.entry(e[1]).or_default().extend(clo(e[2]));
}
for (a, to) in by {
let to = as_vec(&to);
new.insert(to.clone());
moves.push((set.clone(), a, to));
}
}
level = give(new, &mut number);
}
let states = number
.iter()
.flat_map(|(s, &n)| s.iter().map(move |&x| vec![n, x]))
.collect();
let firsts = start_sets
.iter()
.map(|(&k, s)| vec![k, number[&as_vec(s)]])
.collect();
let steps = moves
.iter()
.map(|(f, a, t)| vec![number[f], *a, number[t]])
.collect();
(states, firsts, steps)
}
/// c. Random graphs against the subset construction, at 1 thread and at 8.
#[tokio::test]
async fn random_graphs_match_the_subset_construction() {
let m = machine(None, true);
let mut big = 0;
for seed in 1..=12u64 {
let mut g = Lcg(seed);
let nodes = 20 + g.below(30);
let edges: Vec<[Value; 3]> = (0..nodes * 2)
.map(|_| [g.below(nodes), A + g.below(3), g.below(nodes)])
.collect();
let eps: Vec<[Value; 2]> = (0..nodes / 2)
.map(|_| [g.below(nodes), g.below(nodes)])
.collect();
let starts: Vec<[Value; 2]> = (0..4).map(|_| [g.below(3), g.below(nodes)]).collect();
let (states, firsts, steps) = subsets(&edges, &eps, &starts);
big = big.max(steps.len());
for threads in [1, 8] {
let out = engine(threads)
.run(&m.p, &machine_inputs(&m, &edges, &eps, &starts))
.await
.unwrap();
assert_eq!(rows(&out, m.state), states, "seed {seed}");
assert_eq!(rows(&out, m.first), firsts, "seed {seed}");
assert_eq!(rows(&out, m.step), steps, "seed {seed}");
}
}
assert!(big > 50, "some machine is not small ({big} steps)");
}
/// The time and new facts of each round.
struct Rounds {
at: Vec<(u32, usize, std::time::Duration)>,
t: Option<Instant>,
}
impl Trace for Rounds {
fn round(&mut self, _stratum: usize, round: u32, new_facts: usize) {
let t = self.t.get_or_insert_with(Instant::now);
self.at.push((round, new_facts, t.elapsed()));
*t = Instant::now();
}
}
/// i. Size: "the k-th symbol from the end is an a" has 2^k states; k = 15 gives 32768.
#[tokio::test]
async fn a_machine_of_32768_states_finishes() {
let k: Value = 15;
let m = machine(None, true);
let mut edges = vec![[0, A, 0], [0, B, 0], [0, A, 1]];
for i in 1..k {
edges.extend([[i, A, i + 1], [i, B, i + 1]]);
}
let t0 = Instant::now();
let mut trace = Rounds {
at: Vec::new(),
t: Some(Instant::now()),
};
let out = engine(8)
.run_traced(
&m.p,
&machine_inputs(&m, &edges, &[], &[[0, 0]]),
&mut trace,
)
.await
.unwrap();
let secs = t0.elapsed().as_secs_f64();
let states: BTreeSet<Value> = rows(&out, m.state).iter().map(|r| r[0]).collect();
assert_eq!(states.len(), 1 << k);
assert_eq!(rows(&out, m.step).len(), 2 << k);
let report = out
.report
.strata
.iter()
.find(|s| s.kind == "inflationary rounds (column kernels)")
.unwrap();
eprintln!(
"set numbers, size: {} states, {} steps, {} rounds, {secs:.2} s",
states.len(),
2 << k,
report.rounds
);
for (n, new, d) in &trace.at {
eprintln!(" round {n}: {new} new facts, {:.3} s", d.as_secs_f64());
}
}
/// A continued run ([`Engine::continue_from`]): a stratum with a table that read rows
/// gained is computed again, so its numbers are those of a run from scratch; one whose
/// reads stayed is kept, its proofs those of the run before.
#[tokio::test]
async fn a_continued_run_numbers_as_a_run_from_scratch() {
let m = machine(None, true);
let edges = [[1, A, 2], [1, A, 3], [3, B, 1], [4, B, 4]];
let first = machine_inputs(&m, &edges, &[[2, 4]], &[[0, 1]]);
let prev = engine(2).explain(true).run(&m.p, &first).await.unwrap();
// a new edge 4 -a-> 1: a new set {1, 2, 3, 4} comes in between the old ones
let mut more = edges.to_vec();
more.push([4, A, 1]);
let all = machine_inputs(&m, &more, &[[2, 4]], &[[0, 1]]);
let mut added = Inputs::new();
added.facts(m.edge, Facts::from_rows(3, [[4u64, A, 1]]).unwrap());
let cont = engine(2)
.explain(true)
.continue_from(&m.p, &prev, &all, &added)
.await
.unwrap();
let scratch = engine(2).explain(true).run(&m.p, &all).await.unwrap();
for rel in [m.state, m.first, m.step] {
assert_eq!(rows(&cont, rel), rows(&scratch, rel));
}
assert_ne!(rows(&cont, m.step), rows(&prev, m.step));
let proof = cont.why(&m.p, m.state, &[1, 2]).unwrap();
assert!(matches!(proof.how, How::Set { number: 1, .. }));
// plain use: `member2` gains a row nothing reads; then every read as it was
let q = plain(None);
let prev = engine(1)
.explain(true)
.run(&q.p, &plain_inputs(&q, &MEMBERS, &[]))
.await
.unwrap();
let cont = engine(1)
.explain(true)
.continue_from(
&q.p,
&prev,
&plain_inputs(&q, &MEMBERS, &[]),
&Inputs::new(),
)
.await
.unwrap();
assert_eq!(rows(&cont, q.tab), rows(&prev, q.tab));
assert!(cont.report.strata.iter().all(|s| s.continued));
let proof = cont.why(&q.p, q.tab, &[1, 3]).unwrap();
let How::Set { first, .. } = &proof.how else {
panic!("{}", proof.render(&q.p));
};
assert_eq!(first.tuple, vec![10, 1]);
}