== (a) Lemma 3.1 for d=2:  d_inf(A,B)^2 <= 8 D_1(A,B)
OK   Lemma 3.1 (d=2) holds on all 42 exact pairs; max of d_inf^2/(8 D_1) = 0.0625 at ('M', 'W', '1/2', '1/2')
OK   power test: the FALSE inequality d_inf <= D_1 is violated on 10 pairs (must be > 0)
OK   power test: the FALSE inequality d_inf^2 <= D_1/32 is violated on 38 pairs (must be > 0)
   local perturbation: Pi vs Pi with an M/W swap on a k x k block of the K-grid (exact)
   K= 4: d_inf = 1/16, D_1 = 1/32, d_inf^2/D_1 = 0.1250, d_inf/D_1 = 2.00
   K= 8: d_inf = 1/64, D_1 = 1/256, d_inf^2/D_1 = 0.0625, d_inf/D_1 = 4.00
   K=16: d_inf = 1/256, D_1 = 1/2048, d_inf^2/D_1 = 0.0312, d_inf/D_1 = 8.00
   K=32: d_inf = 1/1024, D_1 = 1/16384, d_inf^2/D_1 = 0.0156, d_inf/D_1 = 16.00
== (b) per-x estimate int_0^1 |P_N H_A(x,y) - H_BN(x,y)| dy <= (d-1)/N = 1/N
OK   per-x estimate holds at all 360 exact (A, N, x) tests; max of N*integral = 0.6140 (bound 1) at (25, 3, '18/499')
== (c) adversarial search: maximise D_1(A,B_N) / (||H_A-P_N H_A||_1 + 1/N)
OK   no counterexample in 60 random (A,N); max ratio 0.5728 at ('shuffle', 5, 0.23675925925925925, 0.21333333333333335)
OK   A = W, N=1: D_1(W,B_N) = 1/2 (hand value 1/(2N))
OK   A = W, N=2: D_1(W,B_N) = 1/4 (hand value 1/(2N))
OK   A = W, N=3: D_1(W,B_N) = 1/6 (hand value 1/(2N))
OK   A = W, N=5: D_1(W,B_N) = 1/10 (hand value 1/(2N))
OK   A = W, N=8: D_1(W,B_N) = 1/16 (hand value 1/(2N))
OK   A = M, N=1: B_N(M) = M (D_1 = 0)
OK   A = M, N=3: B_N(M) = M (D_1 = 0)
OK   A = M, N=6: B_N(M) = M (D_1 = 0)
== (d) deliberately wrong inputs
OK   (d1) B_N built from TRANSPOSED cell masses: D_1 = 7081/64800 != 1/(3N) = 1/18 -> DETECTED
OK   (d2) perturbed weights: y-margin no longer uniform -> DETECTED
OK   (d3) wrong claimed value 1/(2N) for D_1(Pi,B_N) is rejected -> DETECTED
OK   (d4) non-copula checkerboard rejected by the margin assertion -> DETECTED
   (d5) atoms at cell centres instead of diagonals is not a copula: its x-margin is discrete; not representable -> skipped
== failures: 0   (time 1.8 s)
