Datasets:
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
quantum-information
quantum-error-correction
schur-channels
semidefinite-programming
research-artifact
File size: 16,366 Bytes
1f85192 | 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | #!/usr/bin/env python3
"""Finite numerical checks for antipodal erasure-code rigidity.
These checks do not prove the theorem. They independently exercise the exact
identities, sharp constant, phase rounding, and erasure recovery construction.
Only NumPy and the Python standard library are required.
"""
from __future__ import annotations
import argparse
import json
from math import comb
from pathlib import Path
import numpy as np
SEED = 20261102
TOLERANCE = 2.0e-9
def frobenius_squared(matrix: np.ndarray) -> float:
return float(np.vdot(matrix, matrix).real)
def support_data(n: int, support: list[int]) -> dict:
support = sorted(set(support))
mask = (1 << n) - 1
assert len(support) >= 4 and len(support) % 2 == 0
index = {word: position for position, word in enumerate(support)}
assert all((word ^ mask) in index for word in support)
complements = np.array([index[word ^ mask] for word in support])
pairs = [(i, int(j)) for i, j in enumerate(complements) if i < j]
signs = np.array(
[[2 * ((word >> j) & 1) - 1 for j in range(n)] for word in support],
dtype=float,
)
delta = min(
(left ^ right).bit_count()
for i, left in enumerate(support)
for right in support[i + 1 :]
)
return {
"n": n,
"support": support,
"signs": signs,
"complements": complements,
"pairs": pairs,
"dimension": len(support),
"rank": len(pairs),
"delta": delta,
}
def phase_code(data: dict, phases: np.ndarray) -> np.ndarray:
encoding = np.zeros((data["dimension"], data["rank"]), dtype=complex)
for column, ((left, right), phase) in enumerate(zip(data["pairs"], phases)):
encoding[left, column] = 1 / np.sqrt(2)
encoding[right, column] = np.exp(1j * phase) / np.sqrt(2)
return encoding
def nearest_phase_projection(data: dict, projection: np.ndarray) -> np.ndarray:
involution = np.zeros_like(projection)
for left, right in data["pairs"]:
entry = projection[left, right]
phase = entry / abs(entry) if abs(entry) > 0 else 1.0 + 0j
involution[left, right] = phase
involution[right, left] = phase.conjugate()
return (np.eye(data["dimension"]) + involution) / 2
def compression_metrics(data: dict, projection: np.ndarray) -> dict:
dimension, rank = data["dimension"], data["rank"]
involution = 2 * projection - np.eye(dimension)
defect_sum = 0.0
residual_sum = 0.0
maximum_identity_error = 0.0
for j in range(data["n"]):
diagonal = np.diag(data["signs"][:, j])
alpha = float(np.trace(projection @ diagonal).real / rank)
centered = projection @ diagonal @ projection - alpha * projection
defect_squared = frobenius_squared(centered)
residual = involution @ diagonal + diagonal @ involution
residual -= 2 * alpha * np.eye(dimension)
residual_squared = frobenius_squared(residual)
maximum_identity_error = max(
maximum_identity_error, abs(residual_squared - 8 * defect_squared)
)
defect_sum += defect_squared
residual_sum += residual_squared
comp = data["complements"]
complementary_mass = float(
np.sum(np.abs(involution[np.arange(dimension), comp]) ** 2)
)
off_complement_mass = frobenius_squared(involution) - complementary_mass
rounded = nearest_phase_projection(data, projection)
distance_squared = frobenius_squared(projection - rounded)
exact_nearest_formula = rank - 2 * sum(
abs(projection[left, right]) for left, right in data["pairs"]
)
covariance = data["signs"].T @ data["signs"] / dimension
largest_covariance_eigenvalue = float(np.linalg.eigvalsh(covariance)[-1])
return {
"defect_sum": defect_sum,
"residual_sum": residual_sum,
"identity_error": maximum_identity_error,
"off_complement_mass": off_complement_mass,
"distance_squared": distance_squared,
"nearest_formula_error": abs(distance_squared - exact_nearest_formula),
"largest_covariance_eigenvalue": largest_covariance_eigenvalue,
"bound": defect_sum / data["delta"],
}
def assert_rigidity(data: dict, projection: np.ndarray) -> dict:
metrics = compression_metrics(data, projection)
assert metrics["identity_error"] < TOLERANCE
assert metrics["nearest_formula_error"] < TOLERANCE
assert metrics["distance_squared"] <= metrics["bound"] + TOLERANCE
assert metrics["residual_sum"] + TOLERANCE >= (
4 * data["delta"] * metrics["off_complement_mass"]
)
assert 2 * metrics["distance_squared"] <= (
metrics["off_complement_mass"] + TOLERANCE
)
assert metrics["largest_covariance_eigenvalue"] <= (
data["n"] - data["delta"] + TOLERANCE
)
return metrics
def remove_bit(word: int, position: int) -> int:
return (word & ((1 << position) - 1)) | ((word >> (position + 1)) << position)
def verify_erasure_recovery(data: dict, rng: np.random.Generator) -> dict:
encoding = phase_code(data, rng.uniform(-np.pi, np.pi, data["rank"]))
rank = data["rank"]
maximum_kl_error = 0.0
maximum_completeness_error = 0.0
maximum_recovery_error = 0.0
maximum_post_erasure_phase_error = 0.0
density_seed = rng.normal(size=(rank, rank)) + 1j * rng.normal(size=(rank, rank))
density = density_seed @ density_seed.conj().T
density /= np.trace(density)
for position in range(data["n"]):
survivor_words = sorted({remove_bit(w, position) for w in data["support"]})
assert len(survivor_words) == data["dimension"]
survivor_index = {w: i for i, w in enumerate(survivor_words)}
branches = []
for outcome in (0, 1):
branch = np.zeros((len(survivor_words), rank), dtype=complex)
for row, word in enumerate(data["support"]):
if ((word >> position) & 1) == outcome:
branch[survivor_index[remove_bit(word, position)], :] += encoding[row, :]
branches.append(branch)
for left in (0, 1):
for right in (0, 1):
target = np.eye(rank) / 2 if left == right else np.zeros((rank, rank))
maximum_kl_error = max(
maximum_kl_error,
float(np.linalg.norm(branches[left].conj().T @ branches[right] - target)),
)
recovery = [np.sqrt(2) * branch.conj().T for branch in branches]
completeness = sum(kraus.conj().T @ kraus for kraus in recovery)
maximum_completeness_error = max(
maximum_completeness_error,
float(np.linalg.norm(completeness - np.eye(len(survivor_words)))),
)
erased = sum(branch @ density @ branch.conj().T for branch in branches)
recovered = sum(kraus @ erased @ kraus.conj().T for kraus in recovery)
maximum_recovery_error = max(
maximum_recovery_error, float(np.linalg.norm(recovered - density))
)
theta = float(rng.uniform(-10, 10))
phase = np.diag(np.exp(1j * theta * np.array([w.bit_count() for w in survivor_words])))
phase_erased = phase @ erased @ phase.conj().T
phase_recovered = sum(kraus @ phase_erased @ kraus.conj().T for kraus in recovery)
maximum_post_erasure_phase_error = max(
maximum_post_erasure_phase_error,
float(np.linalg.norm(phase_recovered - density)),
)
assert maximum_kl_error < TOLERANCE
assert maximum_completeness_error < TOLERANCE
assert maximum_recovery_error < TOLERANCE
assert maximum_post_erasure_phase_error < TOLERANCE
return {
"n": data["n"],
"rank": rank,
"erasure_locations_checked": data["n"],
"maximum_kl_error": maximum_kl_error,
"maximum_recovery_completeness_error": maximum_completeness_error,
"maximum_density_recovery_error": maximum_recovery_error,
"maximum_post_erasure_collective_phase_error": maximum_post_erasure_phase_error,
}
def run_checks() -> dict:
rng = np.random.default_rng(SEED)
checks = []
supports = []
for n in (4, 6, 8):
supports.append((f"central_{n}", support_data(n, [w for w in range(1 << n) if w.bit_count() == n // 2])))
for n in (4, 6):
supports.append((f"even_parity_{n}", support_data(n, [w for w in range(1 << n) if w.bit_count() % 2 == 0])))
for n, delta in ((4, 2), (6, 2), (6, 3), (8, 2), (8, 4)):
mask, word = (1 << n) - 1, (1 << delta) - 1
supports.append((f"two_orbit_{n}_{delta}", support_data(n, [0, mask, word, word ^ mask])))
central_six = support_data(6, [w for w in range(64) if w.bit_count() == 3])
chosen = rng.choice(len(central_six["pairs"]), size=8, replace=False)
subset = [central_six["support"][i] for p in chosen for i in central_six["pairs"][p]]
supports.append(("paired_random_subset_6", support_data(6, subset)))
for name, data in supports:
assert data["delta"] >= 2
for repetition in range(3):
gaussian = rng.normal(size=(data["dimension"], data["rank"]))
gaussian = gaussian + 1j * rng.normal(size=gaussian.shape)
encoding, _ = np.linalg.qr(gaussian, mode="reduced")
projection = encoding @ encoding.conj().T
metrics = assert_rigidity(data, projection)
rounded = nearest_phase_projection(data, projection)
for _ in range(4):
alternative = phase_code(data, rng.uniform(-np.pi, np.pi, data["rank"]))
candidate = alternative @ alternative.conj().T
assert frobenius_squared(projection - rounded) <= (
frobenius_squared(projection - candidate) + TOLERANCE
)
checks.append({"kind": "random_projection_rigidity", "support": name, "repetition": repetition, **metrics})
for n, delta in ((4, 2), (6, 2), (6, 3), (8, 4)):
mask, word = (1 << n) - 1, (1 << delta) - 1
data = support_data(n, [0, mask, word, word ^ mask])
projection = np.diag([1.0 if w in (0, word) else 0.0 for w in data["support"]]).astype(complex)
metrics = assert_rigidity(data, projection)
assert abs(metrics["defect_sum"] - 2 * delta) < TOLERANCE
assert abs(metrics["distance_squared"] - 2) < TOLERANCE
assert abs(metrics["distance_squared"] - metrics["bound"]) < TOLERANCE
checks.append({"kind": "sharp_constant", "n": n, "delta": delta, **metrics})
for n in (4, 6, 8):
data = support_data(n, [w for w in range(1 << n) if w.bit_count() == n // 2])
checks.append({"kind": "exact_erasure_recovery", **verify_erasure_recovery(data, rng)})
for n in (4, 6, 8):
data = support_data(n, [w for w in range(1 << n) if w.bit_count() == n // 2])
index = {word: row for row, word in enumerate(data["support"])}
involution = np.zeros((data["dimension"], data["dimension"]), dtype=complex)
mask = (1 << n) - 1
for column, word in enumerate(data["support"]):
first_two_differ = (word & 1) != ((word >> 1) & 1)
swapped = word ^ 3 if first_two_differ else word
involution[index[swapped ^ mask], column] = 1
projection = (np.eye(data["dimension"]) + involution) / 2
metrics = assert_rigidity(data, projection)
expected_mass = 2 * comb(n - 2, n // 2 - 1)
assert abs(metrics["defect_sum"] - expected_mass) < TOLERANCE
assert abs(metrics["off_complement_mass"] - expected_mass) < TOLERANCE
assert abs(metrics["distance_squared"] - expected_mass / 2) < TOLERANCE
assert abs(metrics["distance_squared"] - metrics["bound"]) < TOLERANCE
checks.append({"kind": "central_sector_sharp_half_constant", "n": n, "expected_noncomplement_mass": expected_mass, **metrics})
data = support_data(4, [w for w in range(16) if w.bit_count() == 2])
zero_rows = [i for i, w in enumerate(data["support"]) if (w & 1) == 0]
partner_rows = [int(data["complements"][i]) for i in zero_rows]
partner_rows[0], partner_rows[1] = partner_rows[1], partner_rows[0]
encoding = np.zeros((6, 3), dtype=complex)
for column, (left, right) in enumerate(zip(zero_rows, partner_rows)):
encoding[left, column] = encoding[right, column] = 1 / np.sqrt(2)
projection = encoding @ encoding.conj().T
metrics = assert_rigidity(data, projection)
first_compression = encoding.conj().T @ np.diag(data["signs"][:, 0]) @ encoding
assert np.linalg.norm(first_compression) < TOLERANCE
assert metrics["defect_sum"] > 1.0
assert metrics["distance_squared"] > 0.5
checks.append({"kind": "central_four_noncomplement_swap_witness", **metrics})
balanced = np.array([[1, 1, 1], [-1, -1, -1], [1, -1, -1], [-1, 1, 1]], dtype=float)
signature_encoding = np.zeros((4, 2), dtype=complex)
signature_encoding[[0, 1], 0] = 1 / np.sqrt(2)
signature_encoding[[2, 3], 1] = 1 / np.sqrt(2)
maximum = max(float(np.linalg.norm(signature_encoding.conj().T @ np.diag(balanced[:, j]) @ signature_encoding)) for j in range(3))
assert maximum < TOLERANCE
checks.append({"kind": "balanced_joint_signatures", "maximum_scalar_compression_error": maximum, "antipodal_pairs": 2})
imbalanced = np.array([[1, 1, 1], [1, -1, -1], [-1, 1, -1], [-1, -1, 1]], dtype=float)
assert np.all(np.sum(imbalanced, axis=0) == 0)
admissible_entries = sum(bool(np.all(left + right == 0)) for left in imbalanced for right in imbalanced)
assert admissible_entries == 0
checks.append({"kind": "individually_balanced_but_no_antipodal_joint_signature", "anticommuting_matrix_kernel_dimension": admissible_entries, "conclusion": "No nonzero matrix anticommutes with all three signature observables; hence no rank-two zero-compression projector."})
reflection = np.array([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]], dtype=complex)
projection = (np.eye(4) + reflection) / 2
signature_defect_sum = 0.0
signature_identity_error = 0.0
for j in range(3):
observable = np.diag(imbalanced[:, j])
alpha = float(np.trace(projection @ observable).real / 2)
defect_squared = frobenius_squared(projection @ observable @ projection - alpha * projection)
residual = reflection @ observable + observable @ reflection - 2 * alpha * np.eye(4)
signature_defect_sum += defect_squared
signature_identity_error = max(signature_identity_error, abs(frobenius_squared(residual) - 8 * defect_squared))
gamma = min(float(np.sum((left + right) ** 2) / 4) for left in imbalanced for right in imbalanced)
signature_imbalance = 4
obstruction_lower_bound = gamma * signature_imbalance / 2
assert gamma == 1.0
assert abs(signature_defect_sum - 2) < TOLERANCE
assert abs(signature_defect_sum - obstruction_lower_bound) < TOLERANCE
assert signature_identity_error < TOLERANCE
checks.append({"kind": "sharp_joint_signature_imbalance_obstruction", "gamma": gamma, "signature_imbalance_delta": signature_imbalance, "defect_sum": signature_defect_sum, "gamma_delta_over_two": obstruction_lower_bound, "identity_error": signature_identity_error})
identity_errors = [entry.get("identity_error", 0.0) for entry in checks]
violations = [max(0.0, entry.get("distance_squared", 0.0) - entry.get("bound", float("inf"))) for entry in checks]
return {
"label": "Finite numerical checks; not a proof of the theorem or a novelty certificate.",
"seed": SEED,
"numpy_version": np.__version__,
"tolerance": TOLERANCE,
"all_checks_passed": True,
"check_count": len(checks),
"maximum_centered_identity_error": max(identity_errors),
"maximum_rigidity_bound_violation": max(violations),
"checks": checks,
}
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--output", type=Path, default=Path(__file__).with_name("verification_results.json"))
arguments = parser.parse_args()
results = run_checks()
arguments.output.write_text(json.dumps(results, indent=2) + "\n", encoding="utf-8")
print(json.dumps({key: value for key, value in results.items() if key != "checks"}, indent=2))
if __name__ == "__main__":
main()
|