#!/usr/bin/env python3 """Does the verifier re-check that the abstract domain covers the source domain? The producer's partition() requires the abstract box to include the source box. If verify() does not repeat that check, a certificate built for a valid pair can be rebound to a pair whose abstract box is a strict subinterval — the one direction that turns a sound transfer into a false one, because the abstract is then only bad on a smaller domain than the source. Verifier, not producer: the certificate is only re-bound by hash, and the abstract graph is edited after the fact. """ import json from copy import deepcopy from fractions import Fraction as Q from cell_cover import build from cover_fixtures import interior_tie from graph_model import parse from verify_cover import verify out = {"probe": "verifier-side domain inclusion"} def run() -> dict: s, t = interior_tie() produced = build(s, t) cert = deepcopy(produced["certificate"]) baseline = verify(s, t, cert) out["baseline"] = baseline["status"] out["baseline_theta"] = baseline.get("theta") out["source_box"] = s["box"] out["abstract_box"] = t["box"] # Shrink the abstract box to a strict subinterval of the source box, rebind the hash. narrow = deepcopy(t) narrow["box"] = [[str(Q(1, 3)), "1"]] cert_shrunk = deepcopy(cert) cert_shrunk["abstract_hash"] = parse(narrow).hash shrunk = verify(s, narrow, cert_shrunk) out["shrunk_abstract_box"] = narrow["box"] out["verifier_on_shrunk"] = shrunk # Widen the abstract box: the source domain still sits inside, so this must stay accepted if # the check is a containment test and not an equality test. wide = deepcopy(t) wide["box"] = [["-3", "3"]] cert_wide = deepcopy(cert) cert_wide["abstract_hash"] = parse(wide).hash out["verifier_on_widened"] = verify(s, wide, cert_wide) # And the certificate's own declared domain versus the source box. wrong = deepcopy(cert) wrong["domain"] = ["-3", "3"] out["verifier_on_wrong_declared_domain"] = verify(s, t, wrong) return out if __name__ == "__main__": print(json.dumps(run(), indent=2, sort_keys=True, default=str))