deduxit 0.4.0

A collection of logic suites: decides, checks, proves step by step and exports sequents of linear logic and of classical, intuitionistic and minimal propositional logic, with checked proofs, Kripke countermodels and Rocq certificates.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
// deduxit © Fabian Lukas Grubmüller 2026
// Licensed under the EUPL

//! The read-back of a two-sided derivation of intuitionistic linear
//! logic as a term of the linear or the affine lambda calculus: one
//! construction per inference, in a walk from the root on a stack of its
//! own.
//!
//! Every hypothesis of every sequent stands for a term: a variable bound
//! below, or what a left rule substituted for it (`f M`, `fst(z)`,
//! `derelict(z)`), one node wherever the hypothesis goes. The walk hands
//! each premise the terms of its hypotheses, matched to the conclusion's
//! by member. Equal members are copies of one formula, so any of them may
//! take any copy's term. A context split between two premises gives each
//! term to one of them; an additive rule gives both premises every term.

use super::{Builder, Calculus, NoTerm, Node, Term, TermId, Type, TypeId, VarId, stopped};
use crate::Error;
use crate::hash::HashMap;
use crate::limits::{Limits, Phase, Progress};
use crate::linear::occurrences::{IllConnective, Member, OccId, Reading, Side};
use crate::linear::proofs::{Derivation, InfId, Inference, Rule};

/// What the walk has yet to do.
#[derive(Debug)]
enum Task {
    /// Read an inference back, its hypotheses' terms by position in its
    /// sequent (`None` at the goal).
    Enter(InfId, Vec<Option<TermId>>),
    /// Read an inference back once the hypothesis at a position is the
    /// application of a function to the term read last (`⊸L`'s second
    /// premise).
    Applied {
        /// The premise.
        inference: InfId,
        /// Its hypotheses' terms, the position's to be made.
        terms: Vec<Option<TermId>>,
        /// The position of the hypothesis the application is.
        at: usize,
        /// The function.
        function: TermId,
    },
    /// Make a node of the terms read last.
    Make(Make),
}

/// A node to make of the terms read last, the last read the rightmost.
#[derive(Debug)]
enum Make {
    /// `λx:A. M`
    Lambda(VarId),
    /// `M ⊗ N`
    Tensor,
    /// `let z be x ⊗ y in M`
    LetTensor(TermId, VarId, VarId),
    /// `let z be ∗ in M`
    LetUnit(TermId),
    /// `⟨M, N⟩`
    Pair,
    /// `inl(M)` of the sum given.
    Left(TypeId),
    /// `inr(M)` of the sum given.
    Right(TypeId),
    /// `case z of inl(x) → M ‖ inr(y) → N`
    Case(TermId, VarId, VarId),
    /// `promote M⃗ for x⃗ in N`
    Promote(Box<[TermId]>, Box<[VarId]>),
    /// `discard z in M`
    Discard(TermId),
    /// `copy z as x, y in M`
    Copy(TermId, VarId, VarId),
    /// `(λx:A. N) M` of the cut's two premises, `M` read first.
    Cut(VarId),
}

/// The terms of a conclusion's hypotheses that its premises take, by
/// member.
type Pool = HashMap<Member, Vec<TermId>>;

/// The state of one read-back.
struct ReadBack<'d, 'a> {
    /// The derivation.
    derivation: &'d Derivation<'a>,
    /// Its intuitionistic reading.
    reading: &'d Reading<'a>,
    /// The term being built.
    builder: Builder,
    /// The type of every occurrence met.
    types: HashMap<OccId, TypeId>,
}

/// Reads a two-sided derivation back as a term, or refuses one that has
/// none, asking `stop` once per inference.
///
/// `limits` bounds nothing here, since the term is no larger than the
/// derivation, which was built within its own limits:
/// - the term holds at most two nodes per inference, one per member a
///   structural run of a compact derivation weakens or copies, and one
///   node per variable, each variable bound to a member: never more
///   nodes than the derivation has members;
/// - the tasks waiting hold the terms of the sequents of the premises
///   not yet read, which lie on one branch: never more than the
///   derivation itself.
///
/// The walk counts on no integer but the ids, which count less than the
/// derivation's inferences and members, fewer than 2³² each.
pub(crate) fn read(
    derivation: &Derivation<'_>,
    _limits: &Limits,
    stop: impl FnMut(Progress) -> bool,
) -> Result<Term, Error> {
    let refuse = |reason| Err(Error::NoTerm { reason });
    let inferences = derivation.inferences();
    let mode = derivation.mode();
    if mode.is_some_and(crate::linear::Mode::is_ordered)
        || derivation.reading().is_some_and(Reading::is_ordered)
    {
        return refuse(NoTerm::Ordered);
    }
    if mode.is_some_and(crate::linear::Mode::has_mix)
        || inferences.iter().any(|i| i.rule().rule == Rule::Mix)
    {
        return refuse(NoTerm::Mix);
    }
    if derivation.framing().is_some()
        || derivation.forest().has_binders()
        || inferences
            .iter()
            .any(|i| matches!(i.rule().rule, Rule::Forall | Rule::Exists))
    {
        return refuse(NoTerm::Quantified);
    }
    let Some(reading) = derivation.reading() else {
        return refuse(NoTerm::Classical);
    };
    if inferences.iter().any(|i| i.rule().rule == Rule::Open) {
        return refuse(NoTerm::Open);
    }
    let affine = inferences
        .iter()
        .any(|i| i.rule().rule == Rule::AffineWeakening);
    let mut walk = ReadBack {
        derivation,
        reading,
        builder: Builder::new(),
        types: HashMap::default(),
    };
    walk.run(affine, crate::limits::counting(stop, Phase::ReadBack))
}

impl ReadBack<'_, '_> {
    /// Returns the type of the formula at `o` as the reading reads it,
    /// building its operands' first with a stack of its own.
    fn ty(&mut self, o: OccId) -> TypeId {
        if let Some(&t) = self.types.get(&o) {
            return t;
        }
        let forest = self.reading.forest();
        let mut stack = vec![o];
        while let Some(&top) = stack.last() {
            let operands: Vec<OccId> = match self.reading.connective(top) {
                IllConnective::Lollipop => {
                    let (from, to) = self.reading.implication(top).expect("an implication");
                    vec![from, to]
                }
                IllConnective::Atom
                | IllConnective::One
                | IllConnective::Zero
                | IllConnective::Top
                | IllConnective::Bang
                | IllConnective::Tensor
                | IllConnective::With
                | IllConnective::Plus
                | IllConnective::Under
                | IllConnective::Over
                | IllConnective::Forall
                | IllConnective::Exists => forest.children(top).collect(),
            };
            let missing: Vec<OccId> = operands
                .iter()
                .copied()
                .filter(|p| !self.types.contains_key(p))
                .collect();
            if !missing.is_empty() {
                stack.extend(missing);
                continue;
            }
            stack.pop();
            let of = |i: usize| self.types[&operands[i]];
            let ty = match self.reading.connective(top) {
                IllConnective::Atom => {
                    let atom = forest.atom(top).expect("an atom");
                    Type::Atom {
                        atom: self.builder.atom(forest.sequent().atom_name(atom)),
                    }
                }
                IllConnective::One => Type::One,
                IllConnective::Zero => Type::Zero,
                IllConnective::Top => Type::Top,
                IllConnective::Bang => Type::Bang { of: of(0) },
                IllConnective::Tensor => Type::Tensor {
                    left: of(0),
                    right: of(1),
                },
                IllConnective::With => Type::With {
                    left: of(0),
                    right: of(1),
                },
                IllConnective::Plus => Type::Plus {
                    left: of(0),
                    right: of(1),
                },
                IllConnective::Lollipop => Type::Lollipop {
                    from: of(0),
                    to: of(1),
                },
                // `read` refuses the ordered readings and the quantifiers.
                IllConnective::Under
                | IllConnective::Over
                | IllConnective::Forall
                | IllConnective::Exists => unreachable!("no type of the calculus"),
            };
            let id = self.builder.ty(ty);
            self.types.insert(top, id);
        }
        self.types[&o]
    }

    /// Returns a new variable of the type of the formula at `o`, and the
    /// node that uses it.
    fn variable(&mut self, o: OccId) -> (VarId, TermId) {
        let ty = self.ty(o);
        self.builder.variable(ty)
    }

    /// Returns whether a member is a hypothesis, in input position.
    fn is_input(&self, m: Member) -> bool {
        self.reading.position(m.occ()) == Side::Input
    }

    /// Returns the terms of an inference's hypotheses but the one at
    /// `skip`, by member.
    fn pool(&self, inference: &Inference, terms: &[Option<TermId>], skip: Option<usize>) -> Pool {
        let mut pool = Pool::default();
        for (p, (&m, t)) in inference.sequent().iter().zip(terms).enumerate() {
            if let Some(t) = t
                && Some(p) != skip
            {
                pool.entry(m).or_default().push(*t);
            }
        }
        pool
    }

    /// Returns the terms of a premise's hypotheses: each of `new` once,
    /// for a member the rule added, and the others taken from the pool.
    /// A member the pool lacks has no term yet (`None`), which only a
    /// position the caller fills next may be.
    fn premise(&self, id: InfId, pool: &mut Pool, new: &[(Member, TermId)]) -> Vec<Option<TermId>> {
        let mut new = new.to_vec();
        self.derivation
            .inference(id)
            .sequent()
            .iter()
            .map(|&m| {
                if !self.is_input(m) {
                    return None;
                }
                if let Some(i) = new.iter().position(|&(n, _)| n == m) {
                    return Some(new.swap_remove(i).1);
                }
                pool.get_mut(&m).and_then(Vec::pop)
            })
            .collect()
    }

    /// Reads the derivation back from its root.
    fn run(&mut self, affine: bool, mut stop: impl FnMut() -> bool) -> Result<Term, Error> {
        let d = self.derivation;
        let root = d.root();
        let mut context = Vec::new();
        let mut terms = Vec::new();
        let mut goal = None;
        for &m in d.inference(root).sequent() {
            let ty = self.ty(m.occ());
            if self.is_input(m) {
                let (v, t) = self.builder.variable(ty);
                context.push(v);
                terms.push(Some(t));
            } else {
                goal = Some(ty);
                terms.push(None);
            }
        }
        let goal = goal.expect("a two-sided sequent has its goal");
        let mut tasks = vec![Task::Enter(root, terms)];
        let mut results: Vec<TermId> = Vec::new();
        while let Some(task) = tasks.pop() {
            match task {
                Task::Enter(id, terms) => {
                    if stop() {
                        return Err(stopped());
                    }
                    self.enter(id, &terms, &mut tasks, &mut results);
                }
                Task::Applied {
                    inference,
                    mut terms,
                    at,
                    function,
                } => {
                    let argument = results.pop().expect("the first premise's term");
                    let applied = self.builder.node(Node::Apply { function, argument });
                    terms[at] = Some(applied);
                    tasks.push(Task::Enter(inference, terms));
                }
                Task::Make(make) => {
                    let node = self.make(make, &mut results);
                    let t = self.builder.node(node);
                    results.push(t);
                }
            }
        }
        let root = results.pop().expect("the root's term");
        let calculus = if affine {
            Calculus::Affine
        } else {
            Calculus::Linear
        };
        let builder = std::mem::replace(&mut self.builder, Builder::new());
        Ok(builder.finish(calculus, context, goal, root))
    }

    /// Returns the node a `Make` makes of the terms read last.
    fn make(&mut self, make: Make, results: &mut Vec<TermId>) -> Node {
        let mut pop = || results.pop().expect("a premise's term");
        match make {
            Make::Lambda(variable) => Node::Lambda {
                variable,
                body: pop(),
            },
            Make::Tensor => {
                let right = pop();
                Node::Tensor { left: pop(), right }
            }
            Make::LetTensor(term, left, right) => Node::LetTensor {
                term,
                left,
                right,
                body: pop(),
            },
            Make::LetUnit(term) => Node::LetUnit { term, body: pop() },
            Make::Pair => {
                let right = pop();
                Node::Pair { left: pop(), right }
            }
            Make::Left(sum) => Node::Left { term: pop(), sum },
            Make::Right(sum) => Node::Right { term: pop(), sum },
            Make::Case(term, left, right) => {
                let right_body = pop();
                Node::Case {
                    term,
                    left,
                    left_body: pop(),
                    right,
                    right_body,
                }
            }
            Make::Promote(terms, variables) => Node::Promote {
                terms,
                variables,
                body: pop(),
            },
            Make::Discard(term) => Node::Discard { term, body: pop() },
            Make::Copy(term, left, right) => Node::Copy {
                term,
                left,
                right,
                body: pop(),
            },
            Make::Cut(variable) => {
                let body = pop();
                let argument = pop();
                let function = self.builder.node(Node::Lambda { variable, body });
                Node::Apply { function, argument }
            }
        }
    }

    /// Reads one inference back: pushes what its premises and its node
    /// need, or the term of a rule without premises.
    #[expect(
        clippy::too_many_lines,
        reason = "one arm per rule of the calculus, each a few lines"
    )]
    fn enter(
        &mut self,
        id: InfId,
        terms: &[Option<TermId>],
        tasks: &mut Vec<Task>,
        results: &mut Vec<TermId>,
    ) {
        use Side::{Input, Output};
        let d = self.derivation;
        let forest = self.reading.forest();
        let inference = d.inference(id);
        let named = inference.rule();
        let premises = inference.premises();
        let at = inference.principal();
        let principal = at.map(|p| inference.sequent()[p]);
        let o = principal.map(Member::occ);
        let z = at.and_then(|p| terms[p]);
        // The principal occurrence's operands, and their members.
        let left = o.and_then(|o| forest.left(o));
        let right = o.and_then(|o| forest.right(o));
        let member = |o: Option<OccId>| Member::from(o.expect("the rule's operand"));
        let mut pool = self.pool(inference, terms, at);
        let z = || z.expect("the principal hypothesis has its term");
        match (named.rule, named.side) {
            (Rule::Ax, _) => {
                let t = terms
                    .iter()
                    .flatten()
                    .next()
                    .expect("the axiom's hypothesis");
                results.push(*t);
            }
            (Rule::Par, Some(Output)) => {
                let (from, _) = self.reading.implication(o.expect("⊸R")).expect("⊸R");
                let (x, xt) = self.variable(from);
                let terms = self.premise(premises[0], &mut pool, &[(Member::from(from), xt)]);
                tasks.push(Task::Make(Make::Lambda(x)));
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Tensor, Some(Input)) => {
                let (_, to) = self.reading.implication(o.expect("⊸L")).expect("⊸L");
                let first = self.premise(premises[0], &mut pool, &[]);
                let second = self.premise(premises[1], &mut pool, &[]);
                let to = Member::from(to);
                let at = d
                    .inference(premises[1])
                    .sequent()
                    .iter()
                    .zip(&second)
                    .position(|(&m, t)| m == to && t.is_none())
                    .expect("the consequent is a hypothesis of the second premise");
                tasks.push(Task::Applied {
                    inference: premises[1],
                    terms: second,
                    at,
                    function: z(),
                });
                tasks.push(Task::Enter(premises[0], first));
            }
            (Rule::Par, Some(Input)) => {
                let (x, xt) = self.variable(left.expect("⊗L"));
                let (y, yt) = self.variable(right.expect("⊗L"));
                let new = [(member(left), xt), (member(right), yt)];
                let terms = self.premise(premises[0], &mut pool, &new);
                tasks.push(Task::Make(Make::LetTensor(z(), x, y)));
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Tensor, Some(Output)) => {
                let first = self.premise(premises[0], &mut pool, &[]);
                let second = self.premise(premises[1], &mut pool, &[]);
                tasks.push(Task::Make(Make::Tensor));
                tasks.push(Task::Enter(premises[1], second));
                tasks.push(Task::Enter(premises[0], first));
            }
            (Rule::One, _) => {
                let t = self.builder.node(Node::Unit);
                results.push(t);
            }
            (Rule::Bot, _) => {
                let terms = self.premise(premises[0], &mut pool, &[]);
                tasks.push(Task::Make(Make::LetUnit(z())));
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::With, Some(Output)) => {
                let first = self.premise(premises[0], &mut pool.clone(), &[]);
                let second = self.premise(premises[1], &mut pool, &[]);
                tasks.push(Task::Make(Make::Pair));
                tasks.push(Task::Enter(premises[1], second));
                tasks.push(Task::Enter(premises[0], first));
            }
            (Rule::PlusLeft | Rule::PlusRight, Some(Input)) => {
                let (kept, node) = if named.rule == Rule::PlusLeft {
                    (left, Node::First { term: z() })
                } else {
                    (right, Node::Second { term: z() })
                };
                let t = self.builder.node(node);
                let terms = self.premise(premises[0], &mut pool, &[(member(kept), t)]);
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::With, Some(Input)) => {
                let (x, xt) = self.variable(left.expect("⊕L"));
                let (y, yt) = self.variable(right.expect("⊕L"));
                let first = self.premise(premises[0], &mut pool.clone(), &[(member(left), xt)]);
                let second = self.premise(premises[1], &mut pool, &[(member(right), yt)]);
                tasks.push(Task::Make(Make::Case(z(), x, y)));
                tasks.push(Task::Enter(premises[1], second));
                tasks.push(Task::Enter(premises[0], first));
            }
            (Rule::PlusLeft | Rule::PlusRight, Some(Output)) => {
                let sum = self.ty(o.expect("⊕R"));
                let terms = self.premise(premises[0], &mut pool, &[]);
                tasks.push(Task::Make(if named.rule == Rule::PlusLeft {
                    Make::Left(sum)
                } else {
                    Make::Right(sum)
                }));
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Top, Some(Output)) => {
                let context = terms.iter().flatten().copied().collect();
                let t = self.builder.node(Node::True { context });
                results.push(t);
            }
            (Rule::Top, Some(Input)) => {
                let at = at.expect("0L");
                let context = terms
                    .iter()
                    .enumerate()
                    .filter(|&(p, _)| p != at)
                    .filter_map(|(_, t)| *t)
                    .collect();
                let goal = inference
                    .sequent()
                    .iter()
                    .find(|&&m| !self.is_input(m))
                    .expect("a two-sided sequent has its goal");
                let goal = self.ty(goal.occ());
                let t = self.builder.node(Node::False {
                    context,
                    term: z(),
                    goal,
                });
                results.push(t);
            }
            (Rule::Dereliction, _) => {
                let t = self.builder.node(Node::Derelict { term: z() });
                let terms = self.premise(premises[0], &mut pool, &[(member(left), t)]);
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Promotion, _) => {
                let mut bound = Vec::new();
                let mut variables = Vec::new();
                let mut promoted = Vec::new();
                for (&m, t) in inference.sequent().iter().zip(terms) {
                    if let Some(t) = t {
                        let (v, vt) = self.variable(m.occ());
                        promoted.push(*t);
                        variables.push(v);
                        bound.push((m, vt));
                    }
                }
                let terms = self.premise(premises[0], &mut Pool::default(), &bound);
                tasks.push(Task::Make(Make::Promote(
                    promoted.into_boxed_slice(),
                    variables.into_boxed_slice(),
                )));
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Weakening | Rule::AffineWeakening, _) => {
                let mut pool = self.pool(inference, terms, None);
                let terms = self.premise(premises[0], &mut pool, &[]);
                // What the premise did not take is weakened: discarded
                // under `!`, unused in the affine calculus.
                if named.rule == Rule::Weakening {
                    let mut left: Vec<TermId> = pool.into_values().flatten().collect();
                    left.sort_unstable();
                    for t in left {
                        tasks.push(Task::Make(Make::Discard(t)));
                    }
                }
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Contraction, _) => {
                let mut pool = self.pool(inference, terms, None);
                let premise = d.inference(premises[0]);
                let mut needed: HashMap<Member, usize> = HashMap::default();
                for &m in premise.sequent() {
                    if self.is_input(m) {
                        *needed.entry(m).or_default() += 1;
                    }
                }
                let mut copies = Vec::new();
                let mut members: Vec<(Member, usize)> = needed.into_iter().collect();
                members.sort_unstable();
                for (m, count) in members {
                    let have = pool.get(&m).map_or(0, Vec::len);
                    if count <= have {
                        continue;
                    }
                    let entry = pool
                        .get_mut(&m)
                        .expect("a contracted formula is in the conclusion");
                    let mut current = entry.pop().expect("a contracted formula has its term");
                    let ty = self.ty(m.occ());
                    for _ in have..count {
                        let (x, xt) = self.builder.variable(ty);
                        let (y, yt) = self.builder.variable(ty);
                        copies.push(Make::Copy(current, x, y));
                        let entry = pool.get_mut(&m).expect("present");
                        entry.push(xt);
                        current = yt;
                    }
                    pool.get_mut(&m).expect("present").push(current);
                }
                let terms = self.premise(premises[0], &mut pool, &[]);
                for copy in copies {
                    tasks.push(Task::Make(copy));
                }
                tasks.push(Task::Enter(premises[0], terms));
            }
            (Rule::Cut, _) => {
                let a = inference.cut().expect("a cut names its formula").occ();
                let dual = forest.dual(a).expect("a cut formula has its dual");
                let (x, xt) = self.variable(dual);
                let first = self.premise(premises[0], &mut pool, &[]);
                let second = self.premise(premises[1], &mut pool, &[(Member::from(dual), xt)]);
                tasks.push(Task::Make(Make::Cut(x)));
                tasks.push(Task::Enter(premises[1], second));
                tasks.push(Task::Enter(premises[0], first));
            }
            // `read` refuses these, and a two-sided derivation names every
            // other rule with its side.
            (Rule::Mix | Rule::Forall | Rule::Exists | Rule::Open, _)
            | (
                Rule::Par
                | Rule::Tensor
                | Rule::With
                | Rule::PlusLeft
                | Rule::PlusRight
                | Rule::Top,
                None,
            ) => unreachable!("no rule of a two-sided derivation the read-back takes"),
        }
    }
}