Online Resource 1 (ESM_1)
=========================

Article:      Sharing in Natural-Deduction Proof Graphs: Canonical Folds and the
              Complexity of Assumption Renaming
Journal:      Journal of Automated Reasoning
Author:       Pham Van Khanh
Affiliation:  Institute of Information Technology, Vietnam Academy of Science and
              Technology, Hanoi, Vietnam
E-mail:       khanhvietdm@gmail.com

Contents
--------
  tcih_validate.py      validation script
  expected_output.txt   output of the full run
  README.txt            this file

  SHA-256 checksums
    a695e602aa8cdbea9a84bf3a513fb62ebadad58a971d456c649a274816a53fbc  tcih_validate.py
    5b9c9eb654e4ecc8451fa0244228a8977888b43a9a2c182de8729e7f4555cf54  expected_output.txt

Requirements and usage
----------------------
  Python 3, standard library only.  Tested with CPython 3.12.3 on Linux; a static
  analysis with vermin 1.9.2 finds no language or library feature newer than
  Python 3.2.

      python3 tcih_validate.py            all checks, about 1.5 minutes
      python3 tcih_validate.py --quick    skips the largest exhaustive enumeration
                                          of the depth-two reduction (59049 namings)

  The reference output in expected_output.txt was last reproduced on 14 November 2026
  in a freshly created container, from a directory containing only tcih_validate.py,
  by the command below; the output matched expected_output.txt line for line.

  To reproduce the reference run in a clean environment:

      mkdir clean && cp tcih_validate.py clean/ && cd clean
      env -i PATH=/usr/bin:/bin python3 -I tcih_validate.py > out.txt
      diff out.txt ../expected_output.txt          (no output expected)

  The script prints one line per group of checks, each ending in "OK", a summary
  of the direct checkers and derived criteria, and "ALL CHECKS PASSED" at the end.
  A failed check raises an AssertionError; exit status 0 means that all checks
  passed.  The run is deterministic: the only source of randomness is
  random.Random(20261113).

What is checked
---------------
  Output line                                Statements of the article
  -----------------------------------------  ------------------------------------------
  Theorem 1 / maximal fold / threads         Theorem 3.3, Theorem 3.8, Lemma 2.7
  content-only fold ... rejected             Example 3.5 (quotient violates (U))
  Reduction from 3-terminal multiway cut     Lemmas 4.6, 4.7, Theorem 4.5,
                                             Remark 4.15(3) ("flat" variant)
  Canonical naming optimal                   Proposition 4.4
  Path t1-u-t2                               Example 4.8
  graph with arcs ...  (three lines)         Lemmas 4.12-4.14, Theorem 4.9: numbers of
                                             namings, admissible namings and optima
  Depth-two reduction, exhaustive            Lemmas 4.12-4.14, Theorem 4.9
  Depth-two reduction, random graphs         Lemmas 4.13, 4.14
  Example 3.5, hygiene example, ...          Example 3.5, Section 4.1 (hygiene),
                                             Section 4.2 (interference), Example 5.2
  Separation family Pi_n                     Proposition 5.3, Table 4
  Purely implicational variant               Remark 5.4

  Numbers reported in Section 6 of the article and where they come from:
    60 proof objects, 167 admissible foldings    first output line
    41 random multiway-cut instances             third output line
    40 interference-free trees                   fourth output line
    optimum 23 versus 22                         fifth output line
    729 / 59049 / 4096 namings,
    144 / 2592 / 8 admissible (63874 / 2744),
    optima 32 / 53 / 65                          the three lines "graph with arcs ..."
    7 random graphs, 1337 admissible namings     line "Depth-two reduction, 7 random ..."
    Table 4 and the numbers 12, 35, ..., 179     the two tables at the end

Direct checkers and derived criteria
------------------------------------
  Direct checkers (implement the definitions of the article):
    event_label, tlabel, labels    decide conditions (W1)-(W3) and compute labels
    quotient_is_tcih               decides whether a quotient is a TCIH ((U), (A),
                                   existence of a coherent labelling)
    admissible                     decides Definition 4.2: coherent labelling of the
                                   renamed tree, preservation of the binder map, and
                                   the hygiene condition (iii)
  Derived criteria (implement statements proved in the article):
    is_congruence                  justification congruence (Theorem 3.3)
    conflict_free                  disjointness condition of Lemma 4.13
    closed formulas                cost formulas of Lemmas 4.7 and 4.14 and the optima
                                   of Theorems 4.5 and 4.9
  Every derived criterion is compared with the direct checkers on the instances
  enumerated.  In the exhaustive depth-two check, admissibility is decided from
  Definition 4.2 for every one of the 63874 namings.

Enumeration orders (needed to reproduce the counts exactly)
-----------------------------------------------------------
  * Set partitions of a vertex set: function partitions(xs); the first element is
    inserted into each block of every partition of the remaining elements, then
    as a block of its own.  All partitions are enumerated, so the totals do not
    depend on the order.
  * Namings: itertools.product(pool, repeat=number of non-free leaves), with the
    leaves in the order returned by binders() (left-to-right preorder) or, for the
    depth-two reduction, in the order of roles_Q().  All namings over the stated
    pool are enumerated.
  * Random objects: generated by random_tree() and by the loops in the main
    program from random.Random(20261113), in the order in which the checks are
    printed.
  * The family Pi_n: the subsets S of {1,...,n} are enumerated in increasing order
    of the bitmask sum_{i in S} 2^(i-1); the terms X^S_n are combined pairwise,
    neighbours first (positions 2j and 2j+1), the left term being the first
    argument of the operation *.  The column "distinct judgments" of Table 4
    depends on this order (for n = 2 other orders give 13 instead of 12); the
    other columns and Proposition 5.3 do not.

Scope
-----
  The checks are finite consistency tests of the examples, constructions and
  counting formulas on small instances.  They do not verify the general
  statements, in particular not the hardness results, and do not replace the
  proofs.


