ramanujan-challenge/optional/certificates/p28_mutation_sensitivity.py
allaun 1d5273264d feat: add optional enhancements for Ramanujan Problem 2.8
- Positive-cone transport certificates (p28_positive_cone.py, POSITIVE_CONE_CERTIFICATE.md, POSITIVE_CONE_MANUSCRIPT_SECTION.tex)
- Optimized differential gauge (p28_optimized_gauge.py, OPTIMIZED_GAUGE_CERTIFICATE.md)
- Adversarial provenance supplements (p28_mutation_sensitivity.py, solution_pre_positive_cone.tex)
- FAMM SCARS advisory records (FAMM_SCARS.md, p28_famm_scars.json, p28_famm_scars_validator.py)
- Overview documentation (OPTIONAL_IMPROVEMENTS.md, ADVERSARIAL_AUDIT.md)

These are independent, replayable supplements developed after the original exact closure.
They can be verified independently with 'bash run_checks.sh' in the certificates directory.
2026-07-31 05:04:48 -05:00

60 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Adversarial non-vacuity replay for the two optimized certificates.
Each valid checker is run separately by ``run_checks.sh``. Here one
authoritative coefficient is changed in an isolated temporary copy of each
checker. A PASS requires both corrupted copies to fail at the intended exact
identity, demonstrating that the coefficient tests are sensitive rather than
vacuous.
"""
from pathlib import Path
import subprocess
import sys
import tempfile
HERE = Path(__file__).resolve().parent
def rejected_mutant(filename, old, new, expected_failure):
source = (HERE / filename).read_text(encoding="utf-8")
assert old in source
mutant = source.replace(old, new, 1)
assert mutant != source
with tempfile.TemporaryDirectory(prefix="p28_mutation_") as directory:
target = Path(directory) / filename
target.write_text(mutant, encoding="utf-8")
completed = subprocess.run(
[sys.executable, str(target)],
capture_output=True,
text=True,
timeout=120,
check=False,
)
combined = completed.stdout + completed.stderr
assert completed.returncode != 0, f"mutant unexpectedly passed: {filename}"
assert expected_failure in combined, (
f"mutant failed outside the intended obligation: {filename}\n{combined}"
)
rejected_mutant(
"p28_positive_cone.py",
"[209067, 62208]",
"[209068, 62208]",
"failed obligation in group: 16 transfer identities",
)
print("PASS: positive-cone coefficient mutant rejected")
rejected_mutant(
"p28_optimized_gauge.py",
"-99*u**5 + 333*u**4",
"-98*u**5 + 333*u**4",
"D*M=J0+x*J1+x^2*J2, entry (1,1)",
)
print("PASS: optimized-gauge coefficient mutant rejected")
print("PASS: adversarial mutation sensitivity")