"""Bind the numbers a paper prints to the code that computes them. Copied into each paper folder by `ourotrix paper init`; do not edit it (the paper gate compares it with the bundled copy). Standard library only, so `python3 recompute.py` runs anywhere. import claimcheck as cc cc.check('cut-10', 'height $#$ cuts exactly $#$ open unit cubes', lambda height, count: cells(10, (9, 9, 10), height) == count) cc.equal('tri-4', 'verifies $T(#)=#$', 4, tri(4)) A template is text copied from the .tex with every number replaced by `#`. Its literal text holds no digit, so every number in a matched span is read. Each `#` reads one number as an int, or as an exact Fraction when it has a decimal point. Every occurrence of the template in the paper's .tex files (the main file and its \\input files) is checked, and a template that matches nothing fails. `check` calls `fn(*numbers)`, which must return True; `equal` compares the numbers with the values given. A failing claim stops the script with exit status 1 and a message naming the claim. Under the paper gate `FAST` is True: keep heavy certificate replays under `if not cc.FAST:`; the claims themselves always run. The reader's model of TeX: a % starts a comment exactly when an even run of backslashes (zero included) precedes it, so `\\\\%` is a line break and then a comment, while `\\%` and `\\\\\\%` print a percent sign. A comment is blanked to the end of its line; the backslashes and every offset stay the file's. The body of a verbatim environment (verbatim, Verbatim, BVerbatim, LVerbatim, each with or without *, lstlisting, minted) prints as written and is kept as written. Of the verbatim-like commands, \\path, \\url, \\nolinkurl and \\href are read only when a {...} follows the name at once, closes on its line and holds no comment-starting %; the argument is then text. Any other form of them, and \\verb, \\Verb, \\lstinline, \\mintinline, \\DeclareUrlCommand and short-verb declarations, is refused with a named error wherever it is active: the reader does not parse verbatim delimiters or options. The model binds the manuscript as written and honest edits to it, not TeX written to hide text from it (\\iffalse, catcode changes, ^^ notation). """ # Standard Library import json import os from fractions import Fraction from pathlib import Path import re import sys VERSION = 1 HERE = Path(__file__).resolve().parent FAST = os.environ.get('OUROTRIX_CLAIMS_FAST') == '1' REPORT = os.environ.get('OUROTRIX_CLAIMS_REPORT') GENERATED = ('trust-boundary.gen.tex', ) SLOT = (r'(?}. VERBATIM_ENV_RE = re.compile( r'(?