"""Checks one new conditional three-merge Hall trigger, not D51 coverability.""" import json,hashlib,itertools,time,resource from pathlib import Path started=time.process_time() raw=Path('coherence974-input.json').read_bytes() assert hashlib.sha256(raw).hexdigest()=='b173e69b99916a9562cfab59223359984c629f5845a68a265d4ef3dbc3f162c1' old_raw=Path('small1121.json').read_bytes() assert hashlib.sha256(old_raw).hexdigest()=='afe289696ac21fa0836bb3ce2071aa2beb6f500846d29fca11bb61880b45ed32' frozen=json.loads(raw);old=json.loads(old_raw);D=frozen['slots'];Q=frozen['Q'] pairs=((1,11),(3,12),(17,26)) assert len(set(itertools.chain.from_iterable(pairs)))==6 used=set(itertools.chain.from_iterable(pairs)) blocks=list(pairs)+[(i,) for i in range(len(D)) if i not in used] def phase_set(block,q): out=set(range(q)) for i in block:out.intersection_update({(-D[i])%q,(-D[i]-2)%q}) return out E=[{q:phase_set(block,q) for q in Q if phase_set(block,q)} for block in blocks] assert all(set(E[i])=={101,151} for i in range(3)) assert all(D[b]-D[a]==606 for a,b in pairs) # The three merged blocks cannot share a prime phase, so their separation # edges are arithmetic consequences. No extra separation decision is assumed. adj=[set() for _ in blocks] for i,j in itertools.combinations(range(len(blocks)),2): if not any(E[i].get(q,set()) & E[j].get(q,set()) for q in Q): adj[i].add(j);adj[j].add(i) assert all(j in adj[i] for i,j in itertools.combinations(range(3),2)) union=set().union(*(set(E[i]) for i in range(3))) assert len(union)==2<3 # A domain value carries both prime and phase. Different prime owners are # compatible; equal primes must use the same phase and cannot cross an edge. values=[[(q,b) for q,bs in e.items() for b in sorted(bs)] for e in E] def compatible(i,a,j,b): return a[0]!=b[0] or (j not in adj[i] and a==b) for i in range(len(blocks)): for a in values[i]: for j in range(len(blocks)): if i!=j:assert any(compatible(i,a,j,b) for b in values[j]) # Reuse475's colour witness on the remaining singletons and give the three # merged blocks fresh abstract colours. This certifies that a cardinality # clique >19 cannot explain this branch's Hall failure. colors=[16,17,18]+[old['greedy_color_vector'][block[0]] for block in blocks[3:]] assert len(set(colors))<=19 assert all(colors[i]!=colors[j] for i in range(len(blocks)) for j in adj[i]) out={'scope':'conditional branch: require each of the three pairs to share its prime owner; no unconditionedD51 verdict', 'source_input_sha256':hashlib.sha256(raw).hexdigest(),'source_color_receipt_sha256':hashlib.sha256(old_raw).hexdigest(), 'pair_indices':[list(z) for z in pairs],'pair_slots':[[D[i] for i in z] for z in pairs], 'pair_differences':[606]*3,'three_merged_block_phases':[{str(q):sorted(bs) for q,bs in e.items()} for e in E[:3]], 'hall_block_ids':[0,1,2],'hall_prime_union':sorted(union),'forced_separation_triangle':True, 'binary_prime_phase_arc_consistent':True,'partial_blocks':len(blocks), 'relaxed_color_vector':colors,'relaxed_color_count':len(set(colors)), 'cardinality_clique_gt19_impossible':True,'branch_has_no_owner_cover_extension':True} Path('witness1122.json').write_text(json.dumps(out,sort_keys=True,indent=2)+'\n') Path('witness1122-resource.json').write_text(json.dumps({'cpu_seconds':time.process_time()-started,'peak_rss_bytes':resource.getrusage(resource.RUSAGE_SELF).ru_maxrss},indent=2)+'\n') print('PASS1122')