# Question: are conditional three-pair Hall triads enriched in frozen D51 # against the registered product whole-prime row-permutation benchmark? # A motif is conditional on three same-owner merges, not full-list UNSAT. import collections, hashlib, itertools, json, pathlib, resource, sys, time ROOT = pathlib.Path(__file__).parent SOURCE_SHA = 'b173e69b99916a9562cfab59223359984c629f5845a68a265d4ef3dbc3f162c1' class Stream: def __init__(self): self.counter = 0; self.buf = b'' def below(self, m): lim = 256 // m * m while True: if not self.buf: self.buf = hashlib.sha256(('hall-triad-1124:' + str(self.counter)).encode('ascii')).digest() self.counter += 1 b, self.buf = self.buf[0], self.buf[1:] if b < lim: return b % m def permutation(self, n): a = list(range(n)) for j in range(n-1, 0, -1): k = self.below(j+1); a[j], a[k] = a[k], a[j] return a def layers(slots, primes): out = [] for q in primes: masks = [(1 << (-s % q)) | (1 << ((-s-2) % q)) for s in slots] out.append([(i,j,masks[i]&masks[j]) for i,j in itertools.combinations(range(len(slots)),2) if masks[i]&masks[j]]) return out def statistic(edges, permutations, witness=False): pairs = collections.defaultdict(list) for t, (layer, order) in enumerate(zip(edges, permutations)): inverse = [0] * len(order) for new, old in enumerate(order): inverse[old] = new for i,j,mask in layer: a,b = sorted((inverse[i],inverse[j])); pairs[a,b].append((t,mask)) groups = collections.defaultdict(list) for pair, eligible in pairs.items(): if len(eligible) == 2: groups[tuple(t for t,_ in eligible)].append((pair, tuple(mask for _,mask in eligible))) count = 0; motifs = [] for palette, group in sorted(groups.items()): group.sort(); size = len(group); adj = [0]*size # Forward-only triangle intersections count each unordered triple once. for a in range(size): e, x = group[a] for b in range(a+1,size): f,y = group[b] if len(set(e+f)) == 4 and not (x[0]&y[0] or x[1]&y[1]): adj[a] |= 1<=h for x in values) if h == 0 or h*999 <= total: return 'falsified' if h>=4 and h*999>=2*(999+total) and 1+tail<=10: return 'success' return 'inconclusive' def main(): start=time.process_time(); raw=(ROOT/'coherence974-input.json').read_bytes() assert hashlib.sha256(raw).hexdigest()==SOURCE_SHA d=json.loads(raw); slots,primes=d['slots'],d['Q']; n=len(slots) edges=layers(slots,primes); identity=list(range(n)) h,motifs=statistic(edges,[identity]*len(primes),True) rng=Stream(); values=[] for draw in range(999): if time.process_time()-start>100 or resource.getrusage(resource.RUSAGE_SELF).ru_maxrss>950_000_000: print('CAP1124 producer; no complete target'); return 2 orders=[identity]+[rng.permutation(n) for _ in primes[1:]] values.append(statistic(edges,orders)[0]) target={'schema':'hall-triads-1124-v1','source_sha256':SOURCE_SHA,'reference':h,'motifs':motifs, 'controls':values,'frequency':{str(k):v for k,v in sorted(collections.Counter(values).items())}, 'control_sum':sum(values),'upper_count':sum(x>=h for x in values),'outcome':decision(h,values)} out=json.dumps(target,sort_keys=True,separators=(',',':'))+'\n' if len(out.encode())>2_000_000: print('CAP1124 target'); return 2 (ROOT/'target1124.json').write_text(out) print('H1124',h,'CONTROL_SUM',sum(values),'UPPER',target['upper_count'],'OUTCOME',target['outcome']) receipt={'cpu_seconds':time.process_time()-start,'maxrss_bytes':resource.getrusage(resource.RUSAGE_SELF).ru_maxrss} (ROOT/'producer-receipt1124.json').write_text(json.dumps(receipt,sort_keys=True)+'\n') return 0 if __name__=='__main__': sys.exit(main())