# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-separates-a-disposable-scratchpad-calculation-from-a-binding-mathematical-lemma.md # Remnant Warrant: https://corpusfetch.com/c/what-separates-a-disposable-scratchpad-calculation-from-a-binding-mathematical-lemma.warrant.json # Markdown SHA-256: 0bf088f4e0eb00da4d0ec821656cbda977fe88788f6c9efb8bcbdb810f1bdafd # Code AST SHA-256: 98f68c18ccd8af4cbc6069a8ede881fc558fb26fb073c5cec7d3cd503f0e0a40 # Verified Classes: ProofType, MathClaim, LemmaBoundary, MathematicalRigorGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class ProofType(Enum): DEDUCTIVE_PROOF = auto() EXHAUSTIVE_VERIFICATION = auto() EMPIRICAL_SAMPLING = auto() @dataclass(frozen=True) class MathClaim: claim_id: str symbolic_statement: str domain_of_validity: str proof_type: ProofType proof_receipt: str | None @dataclass(frozen=True) class LemmaBoundary: claim_id: str statement: str domain: str is_binding: bool eviction_directive: str boundary_digest: str class MathematicalRigorGuard: """ Evaluates mathematical claims to separate disposable empirical calculations from binding, proof-carrying lemmas. """ @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_claim(cls, claim: MathClaim) -> LemmaBoundary: # Gate 1: Empirical sampling cannot be promoted to a binding lemma if claim.proof_type is ProofType.EMPIRICAL_SAMPLING: return LemmaBoundary( claim_id=claim.claim_id, statement=claim.symbolic_statement, domain=claim.domain_of_validity, is_binding=False, eviction_directive="DISCARD: Empirical sampling is a scratchpad calculation, not a lemma.", boundary_digest=cls._hash(f"EMPIRICAL:{claim.claim_id}"), ) # Gate 2: Deductive/Exhaustive proof without a receipt is invalid if not claim.proof_receipt or not claim.proof_receipt.strip(): return LemmaBoundary( claim_id=claim.claim_id, statement=claim.symbolic_statement, domain=claim.domain_of_validity, is_binding=False, eviction_directive="DISCARD: Proof receipt missing. Cannot promote to binding lemma.", boundary_digest=cls._hash(f"UNPROVEN:{claim.claim_id}"), ) # Gate 3: Valid lemma requires an explicit domain if not claim.domain_of_validity.strip(): return LemmaBoundary( claim_id=claim.claim_id, statement=claim.symbolic_statement, domain="UNDEFINED", is_binding=False, eviction_directive="HALT: Lemma lacks a domain of validity. Application unsafe.", boundary_digest=cls._hash(f"NO_DOMAIN:{claim.claim_id}"), ) # Gate 4: Promote to binding lemma digest_payload = { "claim": claim.symbolic_statement, "domain": claim.domain_of_validity, "proof_type": claim.proof_type.name, "proof_hash": cls._hash(claim.proof_receipt), } digest = cls._hash( json.dumps(digest_payload, sort_keys=True, separators=(",", ":")) ) return LemmaBoundary( claim_id=claim.claim_id, statement=claim.symbolic_statement, domain=claim.domain_of_validity, is_binding=True, eviction_directive="PRESERVE: Binding lemma sealed with proof receipt and domain.", boundary_digest=digest, ) @classmethod def assert_lemma_applicability( cls, boundary: LemmaBoundary, target_domain: str ) -> tuple[bool, str]: """ Fetching-time check: ensures the target domain falls within the lemma's proven domain of validity before application. """ if not boundary.is_binding: return False, f"REJECTED: {boundary.eviction_directive}" if boundary.domain == "UNDEFINED" or target_domain != boundary.domain: return False, ( f"DOMAIN_VIOLATION: Lemma valid for '{boundary.domain}', " f"but target is '{target_domain}'. Re-verify before applying." ) return True, "LEMMA_APPLICABLE: Domain matches proof boundary."