#!/usr/bin/env python3 """Exact scope check for the first-step source-torus normalization. This tests the specific first-mutated torus witnesses used in the text. It does NOT exclude normalization by longer source mutation words or by other intrinsic arguments, and does not verify mixed contact counts. """ from pathlib import Path import json ROOT=Path(__file__).resolve().parent cal=json.loads((ROOT/'e7_calibration.json').read_text()) records=[] for row in cal['rows']: if row['choices']: continue beta=row['beta']+[0]*18 mu=row['label']+[0]*8 torus_tests=[] for j,s in enumerate(cal['source_exchanges']): pairing=sum(a*b for a,b in zip(s['first_mutant_leading_exponent'],beta)) defect=min(sum(a*b for a,b in zip(alpha,mu)) for alpha in s['normalized_support']) other=sum(beta)-beta[j] # For g_j=x_j' product_{k != j} x_k, the initial straight # monomial has tropical defect zero, while the correction has # positive weight difference. Any positive powers have the same # obstruction, because pairing >= 0 and at least one other # contact coordinate occurs. assert pairing>=0, (row['target'],s['variable'],pairing) assert defect==0, (row['target'],s['variable'],defect) assert other>0, (row['target'],s['variable'],other) assert pairing+other>0 torus_tests.append({'source_direction':s['variable'], 'first_mutant_leading_pairing':pairing, 'normalized_exchange_defect':defect, 'other_contact_degree':other, 'torus_product_correction_pairing':pairing+other}) records.append({'mirror_direction':row['target'], 'contact_vector':row['beta'], 'first_step_tori':torus_tests}) assert [r['mirror_direction'] for r in records]==[1,5,8,10,11,14,15,18] report={ 'result':'PASS', 'mixed_directions':len(records), 'first_step_torus_tests':sum(len(r['first_step_tori']) for r in records), 'scope':'Only the first-step source-torus witnesses. No statement about longer mutation words; no substitute for the eight mixed-contact counts.', 'records':records, } (ROOT/'remaining_e7_contacts.json').write_text(json.dumps(report,indent=2)+'\n') print('PASS: all eight mixed directions have zero exchange defect and strictly positive correction weight in each of the ten first-step torus witnesses.')