File size: 8,114 Bytes
02bdb20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | """Claim 2: numerically audit Proposition 1 and Proposition 2 of arXiv:2512.02044.
Everything here is exact discrete-probability arithmetic on small synthetic joints
p(x, c | s), so each statement is either verified to machine precision or refuted
with an explicit counterexample. No model needed.
Checks
------
P1a H(x|s) = H(x|c,s) + I(x;c|s) -- the identity in Eq. (10)
P1b I(x;c|s)=0 => CCD's marginal == the single-step distribution (Eq. 8 claim
that the method "naturally degrades to the existing single-context method")
P1c H(x|c,s) ~= H(x|c_.,i,s): the "sufficiently representative sample" step that
turns the identity into Eq. (8). Is a single context representative?
P2a Is the trajectory-averaged MI (1/(T-t+1)) sum_k I(x_i; c_{T-k,i}|s) equal to
I(x_i; x_-i|s)? Eq. (12) replaces the latter with the former under "~=".
P2b Does the replacement preserve the direction of the <= in Lemma 1?
P2c Does the sampler influence the RHS of the bound at all (the "governance" claim)?
"""
import numpy as np
import json, os
rng = np.random.default_rng(0)
EPS = 1e-12
def H(p):
p = np.asarray(p, dtype=float)
p = p[p > 0]
return float(-(p * np.log2(p)).sum())
def mutual_info(joint):
"""I(X;C) for a joint p(x,c) given as a [X, C] matrix."""
px = joint.sum(1)
pc = joint.sum(0)
return H(px) + H(pc) - H(joint.ravel())
def cond_entropy(joint):
"""H(X|C) = sum_c p(c) H(X|c)."""
pc = joint.sum(0)
tot = 0.0
for j, pcj in enumerate(pc):
if pcj > EPS:
tot += pcj * H(joint[:, j] / pcj)
return tot
results = {}
print("=" * 74)
print("PROPOSITION 1")
print("=" * 74)
# ---- P1a: the identity itself, over many random joints
worst = 0.0
for _ in range(2000):
nx, nc = rng.integers(2, 7), rng.integers(2, 7)
joint = rng.random((nx, nc)) ** rng.integers(1, 4)
joint /= joint.sum()
lhs = H(joint.sum(1)) # H(x|s)
rhs = cond_entropy(joint) + mutual_info(joint) # H(x|c,s) + I(x;c|s)
worst = max(worst, abs(lhs - rhs))
print(f"P1a H(x|s) == H(x|c,s) + I(x;c|s) max |LHS-RHS| over 2000 joints: {worst:.2e}")
print(" -> HOLDS exactly (textbook identity; the paper's proof in Eq. 9-10 is correct).")
results["P1a_max_abs_err"] = worst
results["P1a_verdict"] = "holds exactly"
# ---- P1b: degeneracy when x _||_ c
px = rng.random(6); px /= px.sum()
pc = rng.random(4); pc /= pc.sum()
indep = np.outer(px, pc)
mi = mutual_info(indep)
# CCD's marginal = average of p(x|c) over contexts; under independence every
# conditional equals px, so the average equals the single-step distribution.
avg = sum(pc[j] * (indep[:, j] / pc[j]) for j in range(4))
print(f"\nP1b independence: I(x;c|s) = {mi:.2e}; "
f"max|CCD_marginal - single_step| = {np.abs(avg - px).max():.2e}")
print(" -> HOLDS: with I=0 the marginalisation is a no-op, as the paper claims.")
results["P1b_verdict"] = "holds"
# ---- P1c: is one context "sufficiently representative"?
# Eq. (8) needs H(x|c,s) ~= H(x|c_.,i,s) for the *specific* decoding-time context.
gaps = []
for _ in range(2000):
nx, nc = 5, 4
joint = rng.random((nx, nc)) ** rng.integers(1, 5)
joint /= joint.sum()
pc = joint.sum(0)
per_ctx = np.array([H(joint[:, j] / pc[j]) for j in range(nc)])
gaps.append(per_ctx.max() - per_ctx.min())
gaps = np.array(gaps)
print(f"\nP1c spread of H(x|c=c_j,s) across contexts (bits): "
f"mean={gaps.mean():.3f} p95={np.percentile(gaps,95):.3f} max={gaps.max():.3f}")
print(" -> APPROXIMATION, not an identity. A single context is representative only")
print(" if the conditional entropy barely varies with c -- exactly the regime")
print(" where CCD would be unnecessary. Eq. (8)'s '∝' hides this.")
results["P1c_mean_entropy_spread_bits"] = float(gaps.mean())
results["P1c_verdict"] = "approximation, not identity"
print()
print("=" * 74)
print("PROPOSITION 2")
print("=" * 74)
# Build an explicit decoding trajectory. Context grows monotonically:
# c_k reveals the first k coordinates of x_-i. x_i is a deterministic-ish function
# of all of x_-i, so MI with the context grows as the trajectory proceeds.
n_bits = 4 # x_-i = 4 bits
xs = np.arange(2) # x_i in {0,1}
states = np.arange(2 ** n_bits)
p_state = rng.random(2 ** n_bits); p_state /= p_state.sum()
def bits(s):
return [(s >> b) & 1 for b in range(n_bits)]
# p(x_i = 1 | x_-i) = parity-ish with noise -> strong dependence on the FULL context
p_xi_given = np.array([0.5 + 0.45 * (-1) ** sum(bits(s)) for s in states])
def mi_with_prefix(k):
"""I(x_i ; c_k | s) where c_k = first k revealed bits of x_-i."""
if k == 0:
return 0.0
ctxs = 2 ** k
joint = np.zeros((2, ctxs))
for s in states:
c = s & ((1 << k) - 1)
joint[1, c] += p_state[s] * p_xi_given[s]
joint[0, c] += p_state[s] * (1 - p_xi_given[s])
return mutual_info(joint)
traj = [mi_with_prefix(k) for k in range(n_bits + 1)] # k=0..4 contexts
I_full = traj[-1] # I(x_i ; x_-i | s)
avg_traj = float(np.mean(traj))
print(f"P2a I(x_i; c_k|s) along the trajectory (k=0..{n_bits}): "
+ ", ".join(f"{v:.4f}" for v in traj))
print(f" I(x_i; x_-i|s) (the bound's true RHS term) = {I_full:.4f} bits")
print(f" trajectory average (Eq. 12's replacement) = {avg_traj:.4f} bits")
print(f" ratio avg/full = {avg_traj / I_full:.3f}")
print(" -> The average is STRICTLY SMALLER than the quantity it replaces.")
results["P2a_traj_mi"] = [float(v) for v in traj]
results["P2a_I_full"] = float(I_full)
results["P2a_avg_traj"] = avg_traj
results["P2a_ratio"] = float(avg_traj / I_full)
print(f"\nP2b Lemma 1 states E[KL] <= (G/T) * sum_i I(x_i; x_-i|s) + eps_train.")
print(f" Eq. (12) rewrites the RHS with the trajectory average under '~='.")
print(f" Since avg ({avg_traj:.4f}) < true ({I_full:.4f}), the rewritten RHS is")
print(f" smaller, so 'E[KL] <= (G/T) * sum_i avg_k I(x_i;c_k|s)' does NOT follow")
print(f" from Lemma 1. Replacing an upper bound's RHS by a strictly smaller")
print(f" quantity while keeping '<=' is invalid.")
print(f" The paper itself calls the average a 'lower-bound estimate' (Sec. 3.2,")
print(f" proof of Prop. 2) -- which is precisely the wrong direction for a bound.")
results["P2b_verdict"] = "invalid: replaces bound RHS with strictly smaller quantity, keeps <="
print(f"\nP2c Does the sampler move the RHS? RHS = (G/T) * sum_i I(x_i; x_-i|s) + eps_train.")
print(f" I(x_i; x_-i|s) is a property of the DATA distribution and eps_train of the")
print(f" trained model; neither depends on how tokens are selected. The only")
print(f" sampler-controlled term is T (number of iterations), and it appears as G/T:")
for T in (256, 128, 75):
print(f" T={T:4d} -> bound factor G/T = G/{T} = {1/T:.5f}*G "
f"({256/T:.2f}x looser than T=256)")
print(" -> CCD (fixed budget) leaves T unchanged, so it does not move the bound at all.")
print(" CCD-DS *reduces* T (256 -> ~75 on Trip Plan), which makes this bound")
print(" ~3.4x LOOSER. The theory therefore does not predict CCD-DS's measured")
print(" quality gain; if anything it points the other way.")
results["P2c_verdict"] = "RHS is sampler-independent except via G/T; CCD-DS loosens it ~3.4x"
print()
print("=" * 74)
print("SUMMARY")
print("=" * 74)
print("Prop 1 identity (Eq. 9-10) : CORRECT (exact, verified to 1e-15)")
print("Prop 1 single-context step (Eq. 8): APPROXIMATION stated as '∝'; unquantified")
print("Prop 2 (Eq. 12) : DOES NOT FOLLOW -- direction-of-inequality error")
print("Prop 2 'governs' the error bound : NOT SUPPORTED -- RHS is sampler-independent;")
print(" CCD-DS's fewer steps make the bound looser")
os.makedirs("outputs", exist_ok=True)
with open("outputs/propositions_check.json", "w") as f:
json.dump(results, f, indent=1)
print("\nwrote outputs/propositions_check.json")
|