ch:bunched-implications: ch:bunched-implications
Problem, result, and invariant. Implement the finite BI checker and resource evaluator specified by the seminar project. The finished program distinguishes additive and multiplicative bunch constructors both proof theoretically and semantically. Maintain these invariants:
additive and multiplicative ACU comparison never crosses an alternation boundary;
weakening and contraction are accepted only where a one-hole context displays an additive child;
And-R combines its premise antecedents with semicolon, while Star-R combines them with comma; and
forcing reuses one world for
, searches decompositions for , tests accessible worlds for , and tests composed resources for .
The observable result is an exact thirteen-line report and one summary line. The inline oracle compares the complete output and requires exit status zero.
Representation. Use ordinary Kappa datatypes for formulas, bunches, one-hole contexts, derivation trees, validation results, finite worlds, and finite models. Bunch contexts have four recursive constructors, one for each side of semicolon and comma; plug makes the scope of a structural rule explicit. Represent inference by either Invalid or
Explicit rule trees are preferable here to proof search. Search would obscure whether a rejected specimen failed because of its proposed rule shape or because another branch was chosen. Negative multiplicative structural proposals are therefore checked by a separate function; they are not constructors masquerading as rules of
First complete version. Start with atoms, bunch leaves, one-hole contexts, atomic identity, and additive weakening. Implement plug structurally. The first end-to-end specimen is DWeak Hole (Leaf P) (Leaf Q) (DId P). The checker infers
Implement ACU equality next. Simplify only a matching unit, flatten every maximal node of one constructor, and compare its recursively normalized children as a multiset. The recursion into multiset elements preserves every alternation boundary. The specimen
Structural and logical cases. Add contraction by checking that the premise antecedent contains
Add And-R and Star-R. Their distinction is load bearing and follows the live calculus exactly: DAndR therefore returns AddB leftBunch rightBunch; DStarR returns the corresponding MulB.
Add And-L, Star-L, Imp-R, and Wand-R. These reconstruct the mixed formula: weaken the two atomic branches, combine them with Star-R, package both additive subtrees with And-L, then apply Wand-R and Imp-R. Replacing either bunch constructor makes that named case fail.
Finite forcing. Use the numeric fuel only as an internal work bound. Atomic forcing, accessibility, and composition are finite model tables. Additive conjunction evaluates both operands at one world. Multiplicative conjunction enumerates two resources, checks the operands separately, composes the resources, and compares the composition with the target. Additive implication enumerates accessible worlds; the wand enumerates every resource forcing its antecedent and checks the consequent after composition.
The truncated-addition model supplies the four positive semantic distinctions. At world
Fuel exhaustion must return a conservative failure in the finite program, but it is not a logical counterexample. The fixed value 240 is accepted only for the permanent named corpus; this tutorial makes no decision-procedure claim for arbitrary external input.
Three failing versions. Keep each defect at one Boolean mutation point:
enabling multiplicative weakening makes its permanent rejection fail;
identifying the two bunch constructors erases the alternation tree and makes the interchange specimen congruent; and
interpreting
by same-world conjunction makes the split and finite countermodel cases fail.
Each mutant still parses and typechecks. The unchanged stdout oracle fails, and main raises the typed acceptance error because the conjunction of case booleans is false.
Acceptance test. The restored source reports, in order: purely additive conjunction; nested additive weakening; nested additive contraction; rejection of multiplicative weakening; rejection of multiplicative contraction; a valid multiplicative split; rejected interchange; the mixed derivation; the two conjunction semantics; the two implication semantics; and the finite weakening countermodel. The final line is
All 13 Chapter 43 corpus cases passed.
After testing all three mutations separately, restore the accepted source and repeat check, test, run, and audit. Appendix E records the current pin, commands, concise oracle, and evidence boundary.
Mathematical boundary. The rule-tree checker illustrates definition 43.5; ACU comparison illustrates definition 43.3; finite evaluation illustrates definition 43.26, proposition 43.30. Thirteen finite cases do not prove congruence completeness, identity expansion, cut elimination, soundness, elementary completeness, or decidability of BI. The chapter proves only its stated disjunction-free completeness theorem locally; full disjunctive completeness remains the external boundary of convention 43.41. It also does not implement Moore closure, the universal BI algebra, algebraic soundness, reflection, or the semantic cut certificate of section 43.5; those are proof objects and mathematical constructions, not finite execution claims.