TFPT scientific source excerpt Original repository path: experiments/theory-contracts/seam-positive-kernel-search-20261015/source_charge_checks.py Original file SHA-256: c5f5d7704dfc283b577e0aeee31d9875d4d90b1c7b6e4596037920b7d3cf5902 Inclusive original lines: 1-200 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 | """Scoped all-word charge obstruction and original finite source controls. 000002 | 000003 | The obstruction assumes the explicitly stated primitive field inventory and 000004 | symmetry action. It is not a universal no-go for the original P1 source. 000005 | """ 000006 | from __future__ import annotations 000007 | import argparse 000008 | import hashlib 000009 | import importlib.util 000010 | import json 000011 | from pathlib import Path 000012 | import sys 000013 | import numpy as np 000014 | 000015 | ROOT = Path(__file__).resolve().parents[3] 000016 | VERIFICATION = ROOT/'verification' 000017 | 000018 | 000019 | def need(condition, label, checks): 000020 | if not bool(condition): 000021 | raise ArithmeticError('Failed: '+label) 000022 | checks.append(label) 000023 | 000024 | 000025 | def load_original(name): 000026 | path = VERIFICATION/(name+'.py') 000027 | sys.path.insert(0, str(VERIFICATION)) 000028 | spec = importlib.util.spec_from_file_location('_source_'+name, path) 000029 | module = importlib.util.module_from_spec(spec) 000030 | spec.loader.exec_module(module) 000031 | return module, {'path':str(path.relative_to(ROOT)), 000032 | 'sha256':hashlib.sha256(path.read_bytes()).hexdigest()} 000033 | 000034 | 000035 | def add(a,b): 000036 | return ((a[0]+b[0])%2,(a[1]+b[1])%2) 000037 | 000038 | 000039 | def assess_expression(expr): 000040 | """Assess a JSON expression under the declared source inventory. 000041 | 000042 | Nodes use {op: primitive, name: ...}, {op: proposed_sector_insertion, 000043 | source_ref: ...}, {op: product|sum, args: [...]}, or 000044 | {op: adjoint|derivative, arg: ...}. This only checks tags and types. 000045 | """ 000046 | primitive_tags = {'matter_spinor': (1, 1), 'tensor_boson': (0, 0), 000047 | 'scalar_quarter_current': (0, 0)} 000048 | count = 0 000049 | 000050 | def visit(node, depth): 000051 | nonlocal count 000052 | count += 1 000053 | if count > 100 or depth > 24 or type(node) is not dict: 000054 | raise ValueError('invalid expression or complexity limit') 000055 | op = node.get('op') 000056 | if type(op) is not str: 000057 | raise ValueError('operation must be a string') 000058 | if op == 'primitive': 000059 | if set(node) != {'op', 'name'} or type(node['name']) is not str: 000060 | raise ValueError('malformed primitive') 000061 | name = node['name'] 000062 | if name == 'clifford_vector': 000063 | raise ValueError('Clifford vector is an internal operator, not a local field') 000064 | if name not in primitive_tags: 000065 | raise ValueError('unknown primitive') 000066 | return {primitive_tags[name]}, True 000067 | if op == 'proposed_sector_insertion': 000068 | if (set(node) != {'op', 'source_ref'} or type(node['source_ref']) is not str 000069 | or not node['source_ref'].strip()): 000070 | raise ValueError('proposed sector requires a nonempty source_ref string') 000071 | # Its type is not established by its name. Overapproximate all 000072 | # four tags so composition cannot create a false exclusion. 000073 | return {(0, 0), (0, 1), (1, 0), (1, 1)}, False 000074 | if op in ('adjoint', 'derivative'): 000075 | if set(node) != {'op', 'arg'}: 000076 | raise ValueError('malformed unary expression') 000077 | return visit(node['arg'], depth + 1) 000078 | if op in ('product', 'sum'): 000079 | if set(node) != {'op', 'args'} or type(node['args']) is not list or not node['args']: 000080 | raise ValueError('malformed composite expression') 000081 | tags, bound = ({(0, 0)} if op == 'product' else set()), True 000082 | for item in node['args']: 000083 | child_tags, child_bound = visit(item, depth + 1) 000084 | bound = bound and child_bound 000085 | tags = ({add(a, b) for a in tags for b in child_tags} 000086 | if op == 'product' else tags | child_tags) 000087 | return tags, bound 000088 | raise ValueError('unknown operation') 000089 | 000090 | try: 000091 | tags, bound = visit(expr, 1) 000092 | except (ValueError, RecursionError) as error: 000093 | return {'possible_target_tag': False, 'source_binding_verified': False, 000094 | 'verdict': 'typing_error', 'reason': str(error), 000095 | 'candidate_physical_proof': False} 000096 | possible = (0, 1) in tags 000097 | return {'possible_target_tag': possible, 'source_binding_verified': False, 000098 | 'tags': [list(tag) for tag in sorted(tags)], 000099 | 'sector_insertion_status': None if bound else 'unverified_original_binding', 000100 | 'verdict': ('excluded_scoped' if not possible else 'needs_original_source'), 000101 | 'candidate_physical_proof': False} 000102 | 000103 | 000104 | def pauli_clifford_10(): 000105 | """Exact 0/±1/±i Clifford action on the 32-dimensional spinor space.""" 000106 | identity=np.eye(2,dtype=complex) 000107 | x=np.array([[0,1],[1,0]],complex) 000108 | y=np.array([[0,-1j],[1j,0]],complex) 000109 | z=np.diag([1,-1]).astype(complex) 000110 | output=[] 000111 | for j in range(5): 000112 | for a in (x,y): 000113 | factors=[z if k