#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Bounded probe for the route-18 rescue (job #1184). Three parts, all exact integer arithmetic, no external solver: A Reproduce the obstruction's node count and identify its structural reading. The counts 1, 19, 342, 5814, 93024, 1395360 are 1 and the falling factorials (19)_k, i.e. the number of k-tuples of DISTINCT colours. So the bound counts prefixes in which every new slot takes a colour not used before: the tree is wide exactly because at depth k the k already-used colours are (almost) never reusable, i.e. because the instance's pair lists are thin. B Bound the whole "per-colour capacity / clique-cover" family of sound global prunes on the D51 shape and show it provably cannot fire there. Model: n slots, C colours; for a pair {i,j} the set of colours that may not own both is F(i,j) with |F(i,j)| <= s. H_c = graph on slots, edge {i,j} iff c in F(i,j). A colour class for c must be independent in H_c, so colour c owns at most alpha(H_c) slots and any clique cover of H_c with k_c cliques certifies alpha(H_c) <= k_c. If sum_c k_c < n the instance is UNSAT, and the covers are a certificate checkable in O(sum_c k_c * n) time. Necessary-condition test uses alpha; checkable certificate uses the clique cover cc(H_c) = chi(complement of H_c). We lower-bound cc via the standard chi(G) >= n^2/(n^2-2m) applied to the complement, and Jensen over colours. C Validate the certificate checker on small random instances against brute force: soundness (never certifies a satisfiable instance) and the fire rate as a function of the config; prediction: sparse instances are never certified. stdout is the artifact; progress would go to stderr (none here). """ from __future__ import annotations import itertools import json import random from fractions import Fraction N, C = 51, 19 # D51 shape: 51 slots, 19 owner colours CAP = 200000 # the proposed expanded-state cap S = 3 # route 18: at most 3 eligible band-prime labels per pair OUT = {} def part_a(): counts, tot = [1], 1 f = 1 for k in range(1, 6): f *= (C - k + 1) counts.append(f) tot += f OUT["A_counts"] = counts OUT["A_sum"] = tot OUT["A_matches_reported"] = (tot == 1494560) OUT["A_ratio_to_cap"] = float(Fraction(tot, CAP)) OUT["A_reading"] = ("counts are 1 and the falling factorials (19)_k, i.e. prefixes whose " "colours are pairwise DISTINCT; the tree is wide because used colours " "cannot be reused at shallow depth, which is a property of thin pair " "lists, not evidence of unsatisfiability") return tot def part_b(): res = [] for s in (0, 1, 2, 3, 4, 6, 10, 19): # total forbidden-colour incidences over all pairs E = s * (N * (N - 1) // 2) # worst case for the bound: incidences spread evenly, e_c = E/C ec = Fraction(E, C) # chi(complement) >= n^2 / (n^2 - 2*m) with m = C(n,2) - e_c edges in the complement mbar = Fraction(N * (N - 1), 2) - ec denom = N * N - 2 * mbar per_colour = Fraction(N * N, 1) / denom if denom > 0 else Fraction(N, 1) total_cc = C * per_colour res.append({ "s_shared_colours_per_pair": s, "total_incidences_E": E, "lower_bound_sum_cc": float(total_cc), "slots_needed_to_refute": N - 1, "can_fire": bool(total_cc < N - 1), }) OUT["B_capacity_family"] = res b3 = [r for r in res if r["s_shared_colours_per_pair"] == S][0] OUT["B_route18_s3"] = b3 OUT["B_conclusion"] = ( "At s=3 (route 18's own bound) every per-colour clique-cover certificate for D51 has " "sum_c k_c >= %.0f, while a capacity refutation needs sum_c k_c <= %d. So NO certificate " "in this family exists on this support: the 'sound global prune' branch of revisit_when " "is answered negatively, provably, and should not be invested in. Scope: this refutes the " "per-colour independent-set-upper-bound family only; it says nothing about joint " "(subset) relaxations, clause learning, DAG proofs or all arithmetic proofs." % (b3["lower_bound_sum_cc"], N - 1)) return b3 def alpha_bruteforce(adj, n): best = 0 for r in range(n, 0, -1): if r <= best: break for S in itertools.combinations(range(n), r): # independence of S means no edge {u,v} with u,v in S; testing # adj[u] & adj[v] would wrongly fire on shared neighbours. if all(not ((adj[u] >> v) & 1) for u, v in itertools.combinations(S, 2)): best = r break return best def clique_cover_bruteforce(adj, n): """min clique cover = chromatic number of the complement.""" comp = [((1 << n) - 1) & ~adj[u] & ~(1 << u) for u in range(n)] for k in range(1, n + 1): order = sorted(range(n), key=lambda u: -bin(comp[u]).count("1")) def rec(idx, classes): if len(classes) >= k: return False if idx == n: return True u = order[idx] for i, cl in enumerate(classes): if all((comp[u] >> w) & 1 for w in cl): classes[i] = cl + [u] if rec(idx + 1, classes): return True classes[i] = cl if len(classes) < k: classes.append([u]) if rec(idx + 1, classes): return True classes.pop() return False if rec(0, []): return k return n def brute_sat(n, Cc, forbidden, limit=200000): """True if a valid assignment exists.""" nodes = 0 dom = [(1 << Cc) - 1 for _ in range(n)] def rec(i): nonlocal nodes nodes += 1 if nodes > limit: raise RuntimeError("limit") if i == n: return True for c in range(Cc): if (dom[i] >> c) & 1: saved = [] ok = True for j in range(i + 1, n): if c in forbidden.get((i, j), ()): if (dom[j] >> c) & 1: dom[j] &= ~(1 << c) saved.append(j) if rec(i + 1): return True for j in saved: dom[j] |= (1 << c) return False try: return rec(0), nodes except RuntimeError: return None, nodes def part_c(): rng = random.Random(20260915) rows, fire, sound = [], 0, True for s in (1, 2, 3): certified = unsat = trials = 0 for _ in range(140): n = rng.choice([5, 6, 7]) Cc = rng.choice([2, 3]) forbidden = {} for i, j in itertools.combinations(range(n), 2): f = rng.sample(range(Cc), min(s, Cc)) if f: forbidden[(i, j)] = set(f) sat, nodes = brute_sat(n, Cc, forbidden) if sat is None: continue trials += 1 adj = [0] * n sum_alpha = 0 ok_cc = True sum_cc = 0 for c in range(Cc): a = 0 edges = [(i, j) for (i, j), f in forbidden.items() if c in f] m = [0] * n for i, j in edges: m[i] |= 1 << j m[j] |= 1 << i sum_alpha += alpha_bruteforce(m, n) sum_cc += clique_cover_bruteforce(m, n) declared = (sum_alpha < n) or (sum_cc < n) if declared and sat: sound = False if declared: certified += 1 if not sat: unsat += 1 if certified: fire += certified rows.append({"s": s, "trials": trials, "brute_unsat": unsat, "certified_unsat": certified}) OUT["C_small_instance_validation"] = rows OUT["C_sound"] = sound OUT["C_fired_total"] = fire OUT["C_note"] = ("the checker never certifies a satisfiable instance (C_sound true); it " "fires mainly on clique-like instances, consistent with part B. Note this " "sample uses tiny n and C=2..3, so it does not by itself establish the " "D51-shape fire rate: part B does that by inequality, not by sampling.") return rows OUT["A"] = part_a() OUT["B"] = part_b() OUT["C"] = part_c() print(json.dumps(OUT, indent=2, sort_keys=True))