TFPT scientific source excerpt Original repository path: experiments/theory-contracts/native-arc-charge-source-interface-20261026/algorithmic_source_probe.py Original file SHA-256: d3b0feaef1b73b7a9839bd4173e133bb04a88e731ae94f35861e87fb70264927 Inclusive original lines: 1-132 Line numbers below refer to the original source. This bounded excerpt is source evidence; it is not a new proof/checker run. Conversation metadata and personal execution details are omitted where indicated. 000001 | #!/usr/bin/env python3 000002 | """Reconstruct known native TFPT objects against a fixed quantum-information map. 000003 | 000004 | This is a source-comparison probe, not a physical runtime or a new model. 000005 | All identities below use bounded Gaussian/integer or rational arithmetic. 000006 | """ 000007 | import hashlib 000008 | import itertools as it 000009 | import json 000010 | import math 000011 | from fractions import Fraction 000012 | from pathlib import Path 000013 | import sys 000014 | 000015 | import numpy as np 000016 | 000017 | [OMITTED: non-scientific conversation or execution metadata] 000018 | sys.path.insert(0, str(REPO)) 000019 | from tfpt_explorer.process import _code_basis 000020 | from tfpt_explorer.cartan_source import _roots, _rays 000021 | 000022 | 000023 | def need(ok, message): 000024 | if not bool(ok): 000025 | raise RuntimeError(message) 000026 | 000027 | 000028 | def main(): 000029 | _, supports = _code_basis() 000030 | words = list(it.product(range(4), repeat=4)) 000031 | index = {word: i for i, word in enumerate(words)} 000032 | pc24 = np.zeros((256, 256), dtype=np.int64) 000033 | for support in supports: 000034 | ids = [index[word] for word in support] 000035 | pc24[np.ix_(ids, ids)] = 24 // len(support) 000036 | ps24 = np.zeros_like(pc24) 000037 | orbits = {} 000038 | for i, word in enumerate(words): 000039 | orbits.setdefault(tuple(sorted(word)), []).append(i) 000040 | for ids in orbits.values(): 000041 | ps24[np.ix_(ids, ids)] = 24 // len(ids) 000042 | 000043 | # Q = (1/16) sum_{a,b in F2^2} W_ab tensor4, in the ORIGINAL frame. 000044 | # W_ab = i^(a.b) X^a Z^b. Its phase disappears in four tensor factors. 000045 | # This signed-permutation formula uses int64 only, no complex tolerance. 000046 | q16 = np.zeros_like(pc24) 000047 | for a, b in it.product(range(4), repeat=2): 000048 | for col, word in enumerate(words): 000049 | row = index[tuple(x ^ a for x in word)] 000050 | parity = sum((b & x).bit_count() for x in word) % 2 000051 | q16[row, col] += 1 if parity == 0 else -1 000052 | need(np.array_equal(q16.T, q16), 'Pauli average is Hermitian') 000053 | need(np.array_equal(q16 @ q16, 16*q16), 'Full Pauli projector') 000054 | need(np.array_equal(q16 @ ps24, 16*pc24), 'Literal symmetric Pauli section is native code') 000055 | need(np.array_equal(ps24 @ q16, 16*pc24), 'Reverse ordered product agrees') 000056 | need(np.trace(q16) == 256, 'Full Pauli fixed rank is 16, not 5') 000057 | need(np.trace(pc24) == 120, 'Symmetric code rank is 5') 000058 | need(np.trace(ps24) == 840, 'Symmetric fourth tensor rank is 35') 000059 | wrong_pc24 = pc24.copy() 000060 | wrong_pc24[0, 0] += 1 000061 | need(not np.array_equal(q16 @ ps24, 16*wrong_pc24), 'Changed code negative control') 000062 | 000063 | # A standard external non-Clifford algorithmic gate is NOT declared physical. 000064 | # U=diag(1,1,exp(i*pi/4),exp(i*pi/4)); in four slots every code support 000065 | # has even first-bit occupation, so phases are exactly 1,i,-1,-i. 000066 | # The unchanged source code has literal compression diag(0,0,i,i,i). 000067 | nonclifford_compression = [] 000068 | for support in supports: 000069 | real = imag = 0 000070 | for word in support: 000071 | count = sum((x >> 1) & 1 for x in word) 000072 | need(count % 2 == 0, 'Even code occupation') 000073 | dr, di = [(1,0),(0,1),(-1,0),(0,-1)][(count//2) % 4] 000074 | real += dr 000075 | imag += di 000076 | nonclifford_compression.append((Fraction(real,len(support)),Fraction(imag,len(support)))) 000077 | need(nonclifford_compression == [(0,0),(0,0),(0,1),(0,1),(0,1)], 'Fixed non-Clifford control leaks exactly two code directions') 000078 | 000079 | # Direct erased-register error detection, independently of a dimension match. 000080 | # Pi_C (|a>