#!/usr/bin/env python3 """ PROVENANCE: PROOF PST Computation 140, Robustness of the emergence chain to the form of T(C) =========================================================================== Advances the T(C)-underdetermination open item (Comp 126) by formalising and verifying the robustness claim of sec:asymmetric-tension: the downstream structural derivations read the tension functional T(C) only through (i) the DESCENDING ORDER of the magnitudes |T(C)| (the instantiation sequence), and (ii) the single global bias direction tau_hat = T(D)/|T(D)|, and nothing else, so the remaining freedom in T(C) is inert. Formalisation. Let phi be any strictly increasing reparametrisation of the magnitude scale with phi(0)=0, and let T' have |T'(C)| = phi(|T(C)|) with the same directions (so tau_hat' = tau_hat). Then at matched threshold tau' = phi(tau): (R1) the instantiation sequence (configs by descending magnitude) is identical; (R2) the phase sign(|T(C)| - tau) of every configuration is identical (each config is instantiated iff it was before); (R3) tau_hat is identical. A NON-order-preserving reassignment of the magnitudes DOES change the sequence, confirming the ORDINAL content is the load-bearing part. Exact invariance (monotone maps preserve order and sign) -> PROVENANCE PROOF. SCOPE: this proves the reads IDENTIFIED in the body factor through (i)+(ii); a complete closure would audit every derivation, for which this fixes the exact invariance criterion, it does not derive a canonical T(C) (still open, Comp 126). """ import numpy as np rng = np.random.default_rng(0) def sequence(mag): return tuple(np.argsort(-mag, kind="stable")) # descending-magnitude order def phase(mag, tau): return np.sign(mag - tau) nD = 6 dim = 2 ** nD all_ok = True for _ in range(300): mag = rng.random(dim) # |T(C)| on P(D) tau = float(np.quantile(mag, rng.uniform(0.2, 0.8))) v = rng.standard_normal(7) tau_hat = v / np.linalg.norm(v) # global bias direction # strictly increasing reparametrisation phi, phi(0)=0 (order-preserving) a = rng.uniform(0.5, 3.0) c = rng.uniform(0.2, 2.0) phi = lambda x: np.expm1(c * x ** a) mag2 = phi(mag) tau2 = phi(tau) r1 = sequence(mag) == sequence(mag2) r2 = np.array_equal(phase(mag, tau), phase(mag2, tau2)) # (R3) is NOT tested here, and the earlier np.allclose(tau_hat, tau_hat) was a # value compared with itself dressed up as a check. phi reparametrises the # MAGNITUDES |T(C)|; tau_hat is built from the directions v(a), which phi does # not act on at all. So (R3) holds by construction rather than by measurement, # and it is reported as structural below instead of being counted as verified. all_ok &= (r1 and r2) # counter-check: reassigning magnitudes across configs (a permutation, NOT a # reparametrisation of the same values) changes the sequence for essentially all perms diffs = 0 for _ in range(300): mag = rng.random(dim) perm = rng.permutation(dim) if sequence(mag) != sequence(mag[perm]): diffs += 1 counter_ok = diffs > 295 print(f"300 random (T, phi): (R1) sequence and (R2) phase invariant under monotone " f"reparametrisation: {all_ok}") print(" (R3) tau_hat: structural, not measured. phi reparametrises the magnitudes") print(" |T(C)|; tau_hat is built from the directions v(a), which phi does not act on,") print(" so there is nothing for a reparametrisation to move. It is stated here rather") print(" than counted among the verified invariances.") print(f"counter-check: reassigning magnitudes changes the sequence in {diffs}/300 trials " f"(ordinal content is load-bearing): {counter_ok}") print("\nRESULT:", "PASS (the reads AUDITED HERE depend only on |T| ordering + tau_hat. This does " "NOT cover the Born-consistency comparison of eq:tau-i-explicit, which tests " "tau_0 against Born weights carrying their own normalisation and is therefore " "a CARDINAL read; see comp 143.)" if (all_ok and counter_ok) else "FAIL")