back to table · edit · history · where entries came from · files · download
2542 bytes, as of the version from 2026-10-28 22:35 (current). Recorded here, not run.
"""Reproduce T457's prose repair without network writes.
Usage: python3 repair_T457.py T457-before.json T457-proposed.json
The input is an ordered JSON document fetched from GET /api/table?id=T457.
This preserves all parameters, numbers, precision and rigour metadata.
"""
import copy, difflib, json, sys
from pathlib import Path
def repair(before):
doc = copy.deepcopy(before)
props = doc['Data properties']
props['complete-note'] = props['complete-note'].removesuffix(', with a rigorous method capable of 100 significant digits')
comments = doc['Comments']
old = comments['comment-convention']
assert old.startswith('The table stores lower-tail probabilities. ')
assert 'In particular, ' in old
comments['comment-convention'] = 'The quantiles use the lower-tail probability convention. ' + old[old.index('In particular, '):]
old = comments['comment-probabilities']
assert old.startswith('The parameters are exact rational probabilities in lowest terms.')
comments['comment-probabilities'] = old.replace('The parameters are exact rational probabilities in lowest terms.', 'The probabilities $p$ are exact rationals in lowest terms.', 1)
old = comments['comment-scope']
sentence = 'These cases permit certified 100-digit inversion through one-dimensional formulas. '
assert sentence in old
comments['comment-scope'] = old.replace(sentence, '', 1)
doc['Formulas']['formula-upper-tail'] += ' If $Q^{\\mathrm{upper}}_{k,\\nu}(\\alpha)$ denotes the upper-tail critical value satisfying $\\Pr(Q_{k,\\nu}>Q^{\\mathrm{upper}}_{k,\\nu}(\\alpha))=\\alpha$, then $q_{k,\\nu,p}=Q^{\\mathrm{upper}}_{k,\\nu}(1-p)$.'
assert list(doc) == list(before)
for field in ['Parameters', 'Numbers', 'Definition', 'Display properties']:
assert doc[field] == before[field]
for field in ['type', 'digits', 'rigour', 'rigour details']:
assert props[field] == before['Data properties'][field]
return doc
if __name__ == '__main__':
before = json.loads(Path(sys.argv[1]).read_text())
after = repair(before)
Path(sys.argv[2]).write_text(json.dumps(after, ensure_ascii=False, indent=2)+'\n')
before_prose = {k:v for k,v in before.items() if k != 'Numbers'}
after_prose = {k:v for k,v in after.items() if k != 'Numbers'}
print(''.join(difflib.unified_diff(json.dumps(before_prose,ensure_ascii=False,indent=2).splitlines(True), json.dumps(after_prose,ensure_ascii=False,indent=2).splitlines(True), fromfile='live document',tofile='proposed document')))