diff --git a/.github/workflows/rhd02-family-source.yml b/.github/workflows/rhd02-family-source.yml new file mode 100644 index 00000000..8e063abe --- /dev/null +++ b/.github/workflows/rhd02-family-source.yml @@ -0,0 +1,55 @@ +name: RHD-02 source pin family quantifier audit + +on: + pull_request: + paths: + - 'research/rh_proof_distillation/family_quantifier_source_audit.py' + - 'tests/test_rhd02_family_source.py' + - '.github/workflows/rhd02-family-source.yml' + push: + paths: + - 'research/rh_proof_distillation/family_quantifier_source_audit.py' + - 'tests/test_rhd02_family_source.py' + - '.github/workflows/rhd02-family-source.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + source-quantifier-gates: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + path: mathcan + persist-credentials: false + - uses: actions/checkout@v4 + with: + repository: leanprover-community/riemann-hypothesis + ref: f150e02623b1e2bbe1f1da8eab5ffee5e930a6a3 + path: upstream + persist-credentials: false + sparse-checkout-cone-mode: false + sparse-checkout: | + src/Formalism/SharpRestriction/GlobalSchurBounds/ZetaZeroFreeRegion.lean + src/Formalism/SharpRestriction/GlobalSchurBounds/RamificationTwoAndConjugationAtQAndD.lean + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Mutation tests for source quantifier shapes + working-directory: mathcan + run: python -m unittest tests.test_rhd02_family_source -v + - name: Verify pinned source bytes and quantifier ordering + working-directory: mathcan + run: | + mkdir -p rhd02 + python -m research.rh_proof_distillation.family_quantifier_source_audit \ + --upstream ../upstream --output rhd02/family-quantifier-source-audit.json + - uses: actions/upload-artifact@v4 + if: always() + with: + name: rhd02-family-quantifier-source-receipt + path: mathcan/rhd02/ + if-no-files-found: ignore diff --git a/.github/workflows/rhd02-family-witnesses.yml b/.github/workflows/rhd02-family-witnesses.yml new file mode 100644 index 00000000..71ae53e7 --- /dev/null +++ b/.github/workflows/rhd02-family-witnesses.yml @@ -0,0 +1,48 @@ +name: RHD-02 family witness quantifier proofs + +on: + push: + paths: + - 'MathCan/RHFamilyWitnesses.lean' + - 'MathCan.lean' + - 'research/rh_proof_distillation/FAMILY_WITNESS_QUANTIFIERS.md' + - '.github/workflows/rhd02-family-witnesses.yml' + pull_request: + paths: + - 'MathCan/RHFamilyWitnesses.lean' + - 'MathCan.lean' + - 'research/rh_proof_distillation/FAMILY_WITNESS_QUANTIFIERS.md' + - '.github/workflows/rhd02-family-witnesses.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + family-quantifier-kernel: + runs-on: ubuntu-latest + timeout-minutes: 35 + steps: + - uses: actions/checkout@v4 + - uses: leanprover/lean-action@v1 + with: + auto-config: false + build: true + build-args: MathCan + test: false + lint: false + use-mathlib-cache: false + - name: Audit the independent witness quantifier proofs and axioms + shell: bash + run: | + set -euo pipefail + lake env lean MathCan/RHFamilyWitnesses.lean | tee rh-family-witness-axioms.txt + if grep -Eq 'sorryAx|ofReduceBool|^error:|admit' rh-family-witness-axioms.txt; then + exit 1 + fi + - uses: actions/upload-artifact@v4 + if: always() + with: + name: rh-family-witness-axioms + path: rh-family-witness-axioms.txt + if-no-files-found: ignore diff --git a/MathCan.lean b/MathCan.lean index 398cb7be..654a8d3d 100644 --- a/MathCan.lean +++ b/MathCan.lean @@ -148,3 +148,4 @@ import MathCan.NOR44SessionOrdering import MathCan.NOR45AuthorizedProgram import MathCan.NOR46ExactIntegerTrace import MathCan.RHWindowExponents +import MathCan.RHFamilyWitnesses diff --git a/MathCan/RHFamilyWitnesses.lean b/MathCan/RHFamilyWitnesses.lean new file mode 100644 index 00000000..d0eed10f --- /dev/null +++ b/MathCan/RHFamilyWitnesses.lean @@ -0,0 +1,246 @@ +import Init + +/-! +# RHD-02: family-witness quantifiers and cardinality floors + +Pure logical and integer-arithmetic consequences of the hypothesis shape +in the Alpoge/Claude Dirichlet-GRH/RH Lean source. + +Source: +leanprover-community/riemann-hypothesis +commit f150e02623b1e2bbe1f1da8eab5ffee5e930a6a3 +Formalism/SharpRestriction/GlobalSchurBounds/ZetaZeroFreeRegion.lean +Formalism/SharpRestriction/GlobalSchurBounds/RamificationTwoAndConjugationAtQAndD.lean + +No construction of D7, Scale, Gc, theta, adm5, adm6, or adm7 is asserted. +Time is abstracted to Nat so MathCan can use Lean 4.35 + Init. +-/ + +namespace MathCan.RHFamilyWitnesses + +universe u + +/-- A property holds uniformly for every member of the dependent family +after a *single* eventual threshold. -/ +def EventuallyAll {Ix : Nat → Type u} + (P : (n : Nat) → Ix n → Prop) : Prop := + ∃ cutoff : Nat, ∀ n : Nat, cutoff ≤ n → ∀ i : Ix n, P n i + +/-- There is a valid family index at each sufficiently large scale. +The index is allowed to vary with the scale. -/ +def EventuallyExists {Ix : Nat → Type u} + (P : (n : Nat) → Ix n → Prop) : Prop := + ∃ cutoff : Nat, ∀ n : Nat, cutoff ≤ n → ∃ i : Ix n, P n i + +/-- Uniform adm5, adm6 and size bounds can be combined with an eventual +adm7-selected index. This is the quantified combinatorial step in +proposition_eleven_two_along_family, abstracting away the analytic details. -/ +theorem synchronized_family_witnesses + {Ix : Nat → Type u} + (P5 P6 PSize PTop : (n : Nat) → Ix n → Prop) + (h5 : EventuallyAll P5) + (h6 : EventuallyAll P6) + (hS : EventuallyAll PSize) + (hT : EventuallyExists PTop) : + EventuallyExists (fun n i => P5 n i ∧ P6 n i ∧ + PSize n i ∧ PTop n i) := by + obtain ⟨b5, h5'⟩ := h5 + obtain ⟨b6, h6'⟩ := h6 + obtain ⟨bS, hS'⟩ := hS + obtain ⟨bT, hT'⟩ := hT + refine ⟨b5 + b6 + bS + bT, ?_⟩ + intro n hn + have hn5 : b5 ≤ n := by omega + have hn6 : b6 ≤ n := by omega + have hnS : bS ≤ n := by omega + have hnT : bT ≤ n := by omega + obtain ⟨i, hTi⟩ := hT' n hnT + exact ⟨i, h5' n hn5 i, h6' n hn6 i, hS' n hnS i, hTi⟩ + + +/-- An AllLargeC-style constant is chosen once (for a fixed epsilon), +before universally quantifying over later scales and family indices. -/ +def EventuallyUniformConstant {Ix : Nat → Type u} + (P : Nat → (n : Nat) → Ix n → Prop) : Prop := + ∃ c cutoff : Nat, 0 < c ∧ + ∀ n : Nat, cutoff ≤ n → ∀ i : Ix n, P c n i + +/-- An AllLargeAt-style existential has a single fixed coefficient, +while the suitable index itself may vary with scale. -/ +def EventuallySelectedWithConstant {Ix : Nat → Type u} + (P : Nat → (n : Nat) → Ix n → Prop) : Prop := + ∃ C cutoff : Nat, 0 < C ∧ + ∀ n : Nat, cutoff ≤ n → ∃ i : Ix n, P C n i + +/-- Source-faithful specialization of two uniform character-sum +coefficients to the same eventually selected adm7 index. Both positive +constants are fixed before n, as required by AllLargeC. -/ +theorem uniform_character_constants_on_selected_index + {Ix : Nat → Type u} + (P5 P6 PTop : Nat → (n : Nat) → Ix n → Prop) + (PSize : (n : Nat) → Ix n → Prop) + (h5 : EventuallyUniformConstant P5) + (h6 : EventuallyUniformConstant P6) + (hS : EventuallyAll PSize) + (hT : EventuallySelectedWithConstant PTop) : + ∃ c5 c6 C : Nat, 0 < c5 ∧ 0 < c6 ∧ 0 < C ∧ + EventuallyExists (fun n i => + P5 c5 n i ∧ P6 c6 n i ∧ PSize n i ∧ PTop C n i) := by + obtain ⟨c5, b5, hc5, h5'⟩ := h5 + obtain ⟨c6, b6, hc6, h6'⟩ := h6 + obtain ⟨bS, hS'⟩ := hS + obtain ⟨C, bT, hC, hT'⟩ := hT + refine ⟨c5, c6, C, hc5, hc6, hC, ?_⟩ + exact synchronized_family_witnesses + (fun n i => P5 c5 n i) + (fun n i => P6 c6 n i) + PSize + (fun n i => PTop C n i) + ⟨b5, h5'⟩ ⟨b6, h6'⟩ ⟨bS, hS'⟩ ⟨bT, hT'⟩ + + +/-- A TOPF-like coefficient is chosen before epsilon. The universal +character bounds may choose distinct constants *after* epsilon. +This distinction survives eventual synchronization of the selected +index and the uniform-for-indices hypotheses. -/ +theorem coefficient_fixed_across_epsilon + {Ix : Nat → Nat → Type u} + (P5 P6 PTop : Nat → (eps : Nat) → (n : Nat) → Ix eps n → Prop) + (PSize : (eps : Nat) → (n : Nat) → Ix eps n → Prop) + (h5 : ∀ eps : Nat, ∃ c5 : Nat, 0 < c5 ∧ + EventuallyAll (fun n i => P5 c5 eps n i)) + (h6 : ∀ eps : Nat, ∃ c6 : Nat, 0 < c6 ∧ + EventuallyAll (fun n i => P6 c6 eps n i)) + (hS : ∀ eps : Nat, EventuallyAll (PSize eps)) + (hT : ∃ C : Nat, 0 < C ∧ + ∀ eps : Nat, EventuallyExists (fun n i => PTop C eps n i)) : + ∃ C : Nat, 0 < C ∧ + ∀ eps : Nat, ∃ c5 c6 : Nat, 0 < c5 ∧ 0 < c6 ∧ + EventuallyExists (fun n i => + P5 c5 eps n i ∧ P6 c6 eps n i ∧ + PSize eps n i ∧ PTop C eps n i) := by + obtain ⟨C, hC, hT'⟩ := hT + refine ⟨C, hC, ?_⟩ + intro eps + obtain ⟨c5, hc5, h5'⟩ := h5 eps + obtain ⟨c6, hc6, h6'⟩ := h6 eps + refine ⟨c5, c6, hc5, hc6, ?_⟩ + exact synchronized_family_witnesses + (fun n i => P5 c5 eps n i) + (fun n i => P6 c6 eps n i) + (PSize eps) + (fun n i => PTop C eps n i) + h5' h6' (hS eps) (hT' eps) + +/-- At each sufficiently large scale, an adm7-like witness makes the +family index type inhabited. This rules out a globally empty family +whenever eventual existence has been established. -/ +theorem eventual_selected_index_forces_nonempty + {Ix : Nat → Type u} (P : (n : Nat) → Ix n → Prop) + (h : EventuallyExists P) : + ∃ cutoff : Nat, ∀ n : Nat, cutoff ≤ n → Nonempty (Ix n) := by + obtain ⟨cutoff, hcutoff⟩ := h + refine ⟨cutoff, ?_⟩ + intro n hn + obtain ⟨i, _⟩ := hcutoff n hn + exact ⟨i⟩ + +/-- A universal bound alone is vacuous when its family has no indices. -/ +theorem empty_index_family_satisfies_every_eventual_universal : + EventuallyAll (Ix := fun _ => Empty) (fun _ _ => False) := by + refine ⟨0, ?_⟩ + intro n hn i + exact Empty.elim i + +/-- The existential part of TOPF excludes that empty-index situation. -/ +theorem empty_index_family_fails_eventual_existence : + ¬ EventuallyExists (Ix := fun _ => Empty) (fun _ _ => True) := by + intro h + obtain ⟨cutoff, hcutoff⟩ := h + obtain ⟨i, _⟩ := hcutoff cutoff (Nat.le_refl cutoff) + exact Empty.elim i + + +/-- Availability of a family index at even stages. The original FamCore +only requires nonempty indices on an unbounded window set, so the +distinction between cofinal and eventual existence is material. -/ +def intermittentAvailable (n : Nat) : Prop := n % 2 = 0 + +/-- An unbounded collection of nonempty stages need not contain every +sufficiently large stage. This is the exact logical gap between the +FamCore.Win_unb/Ix_win shape and the stronger TOPF existence requirement. -/ +theorem cofinal_stages_do_not_force_eventual_availability : + (∀ cutoff : Nat, ∃ n : Nat, + cutoff ≤ n ∧ intermittentAvailable n) ∧ + ¬ (∃ cutoff : Nat, ∀ n : Nat, + cutoff ≤ n → intermittentAvailable n) := by + constructor + · intro cutoff + refine ⟨2 * cutoff, ?_, ?_⟩ + · omega + · unfold intermittentAvailable + omega + · rintro ⟨cutoff, h⟩ + have hodd := h (2 * cutoff + 1) (by omega) + unfold intermittentAvailable at hodd + omega + +/-- There can be an appropriate family index for every scale while +no single index remains appropriate at every scale. -/ +def alternatingIndexValid (n index : Nat) : Prop := index = n % 2 + +theorem selected_index_may_depend_on_scale : + ∀ n : Nat, ∃ i : Nat, alternatingIndexValid n i := by + intro n + exact ⟨n % 2, rfl⟩ + +theorem alternating_selection_has_no_fixed_index : + ¬ ∃ i : Nat, ∀ n : Nat, alternatingIndexValid n i := by + rintro ⟨i, h⟩ + have h0 : i = 0 := by simpa [alternatingIndexValid] using h 0 + have h1 : i = 1 := by simpa [alternatingIndexValid] using h 1 + omega + +/-- Scale-wise constants cannot in general be replaced by one +uniform constant that works at all scales. This records a critical +quantifier-order distinction in the upstream AllLargeC predicate. -/ +theorem scale_dependent_constants_are_weaker_than_uniform : + (∀ n : Nat, ∃ C : Nat, n ≤ C) ∧ + ¬ (∃ C : Nat, ∀ n : Nat, n ≤ C) := by + constructor + · intro n + exact ⟨n, Nat.le_refl n⟩ + · rintro ⟨C, h⟩ + have hc := h (C + 1) + omega + +/-- Source SizesAt n >= x^(2+31eps/4), combined with +PlacesAt TT >= n*x^(-eps/8)/2 and T2 >= n*x^(-eps), +forces very large selected subsets. + +Write L=log₂x and q=eps*L, with all logarithms integral. +The premises are the denominator-cleared source inequalities. +The conclusions are lower bounds on 2-adic logarithms of +TT and T2 cardinalities, before any analytic witness is constructed. -/ +theorem character_subsets_inherit_quadratic_scale + (L q nLog nTLog nT2Log : Nat) + (hRank : 8 * L + 31 * q ≤ 4 * nLog) + (hTT : 8 * nLog ≤ 8 * nTLog + q + 8) + (hT2 : nLog ≤ nT2Log + q) : + 16 * L + 61 * q ≤ 8 * nTLog + 8 ∧ + 8 * L + 27 * q ≤ 4 * nT2Log := by + omega + +#print axioms uniform_character_constants_on_selected_index +#print axioms coefficient_fixed_across_epsilon +#print axioms cofinal_stages_do_not_force_eventual_availability +#print axioms synchronized_family_witnesses +#print axioms eventual_selected_index_forces_nonempty +#print axioms empty_index_family_satisfies_every_eventual_universal +#print axioms empty_index_family_fails_eventual_existence +#print axioms selected_index_may_depend_on_scale +#print axioms alternating_selection_has_no_fixed_index +#print axioms scale_dependent_constants_are_weaker_than_uniform +#print axioms character_subsets_inherit_quadratic_scale + +end MathCan.RHFamilyWitnesses diff --git a/research/rh_proof_distillation/FAMILY_WITNESS_QUANTIFIERS.md b/research/rh_proof_distillation/FAMILY_WITNESS_QUANTIFIERS.md new file mode 100644 index 00000000..836fbb08 --- /dev/null +++ b/research/rh_proof_distillation/FAMILY_WITNESS_QUANTIFIERS.md @@ -0,0 +1,76 @@ +# RHD-02: Quantifier audit of the claimed RH family construction + +Pinned original source: [ZetaZeroFreeRegion.lean](https://github.com/leanprover-community/riemann-hypothesis/blob/f150e02623b1e2bbe1f1da8eab5ffee5e930a6a3/src/Formalism/SharpRestriction/GlobalSchurBounds/ZetaZeroFreeRegion.lean), blob \`7746e5a5affe67117d4ba907dbcd2788f539db6e\`. The [family-to-pointwise theorem](https://github.com/leanprover-community/riemann-hypothesis/blob/f150e02623b1e2bbe1f1da8eab5ffee5e930a6a3/src/Formalism/SharpRestriction/GlobalSchurBounds/RamificationTwoAndConjugationAtQAndD.lean#L933) comes from blob \`1c1495ef81c77fa96f3c1a70106c1da9e24c0c5d\`. + +## Actual quantifier structure + +The published \`AllLargeC\` condition fixes \(\varepsilon\), then requires a **single positive constant** \(c\) and a threshold \(x_0\) such that the analytic statement holds for every \(x\ge x_0\) and every family index at that scale. The \`adm5\` and \`adm6\` inputs of \`proposition_eleven_two_along_family\` have this form. Constants can depend on the chosen \(\varepsilon\), but are uniform in scale and family index. + +The source's \`SizesFe\` supplies eventual \`SizesAt\` and \`PlacesAt\` bounds for all indices. The \`TOPF\` predicate uses \`AllLargeAt\`: it fixes a coefficient \(C\), and at every sufficiently large \(x\) there exists *some* index satisfying \`adm7\`. The chosen index may vary with \(x\). + +Together these justify the eventual shared-index step of the family-to-pointwise proof. In [MathCan/RHFamilyWitnesses.lean](../../MathCan/RHFamilyWitnesses.lean), \`synchronized_family_witnesses\` formalizes exactly that logical reduction using Nat scales and dependent index types. It takes the analytic conditions as explicit assumptions. + +## Nonvacuity and constant quantification + +An empty index family satisfies \`EventuallyAll\` vacuously. \`TOPF\` supplies an eventual existential condition, so the *complete* premise implies every sufficiently large index type is inhabited. \`eventual_selected_index_forces_nonempty\` formalizes this consequence; the empty-family lemmas give explicit positive and negative examples. + +\`AllLargeC\` is stronger than scale-wise existence of a suitable constant. The MathCan counterexample uses the elementary relation \(n\le C\): each \(n\) permits \(C=n\), while a single finite \(C\) cannot work for every \(n\). A separate alternating-index example shows that the \`TOPF\` witness may depend on scale. + +## Stronger cardinality floors + +Write \(L=\log_2 x\) and \(q=\varepsilon L\), assuming those quantities and the relevant cardinality logarithms are integers. The upstream \`SizesAt\` lower bound with \(\delta=\varepsilon/4\) gives + +\[ +4\log_2 n \ge 8L+31q. +\] + +The \`PlacesAt\` lower bounds yield + +\[ +8\log_2 n_T+q+8\ge 8\log_2 n, +\qquad +\log_2 n_{T2}+q\ge\log_2 n. +\] + +Combining them, + +\[ +8\log_2 n_T+8\ge16L+61q, +\qquad +4\log_2 n_{T2}\ge8L+27q. +\] + +These are independent, exact arithmetic consequences encoded in \`character_subsets_inherit_quadratic_scale\`. They show that the source's eventual character-set witnesses must be large at the same scales as the auxiliary group. + +## Mathematical scope + +The Lean theorems concern logic and integer exponent inequalities under supplied premises. They do not construct \`FamP\`, \`D7\`, \`Scale\`, \`adm5\`, \`adm6\`, \`adm7\`, \`Gc\`, \`GivenAll\`, or \`TOPineq\`. Consequently, this work verifies conditional steps of the proposed architecture without independently establishing RH. + +The next mathematical target is the compatible joint production of \`adm5\`, \`adm6\`, \`SizesFe\`, and \`TOPF\` from the published geometry and arithmetic constructions. Their uniformity and existential quantifiers need careful source and proof-term tracking. + +## Constants quantified in the correct order + +The additional native Lean theorem `uniform_character_constants_on_selected_index` +encodes the two `AllLargeC` constants directly. For a fixed epsilon, each +positive coefficient is chosen **before** the eventual threshold, scale +and family index. It then specializes both estimates to the index +chosen by `AllLargeAt`, whose own positive coefficient is fixed. + +This proof is a literal logical statement with Nat as the scale +parameter; the upstream Real-valued `adm5`, `adm6`, `adm7` +hypotheses remain explicit and unconstructed. + +## Coefficient scope across epsilon + +The original `TOPF Fm ε0 C` fixes `C` before its universal epsilon quantifier. The original `AllLargeC` chooses the `adm5`/`adm6` constants after epsilon but before x and the family index. `coefficient_fixed_across_epsilon` is an independent Lean 4.35/Init theorem for these nested quantifier scopes. It retains a single positive `C` across all epsilon values while allowing positive `c5` and `c6` to depend on epsilon. The dependent index type may vary with both epsilon and scale. + +This is a proof of logical synchronization, conditional on all the original-shaped premises. It supplies no analytic `adm5`/`adm6`, geometric `adm7`, or eventual family construction. + +## FamCore supplies cofinal availability; TOPF supplies eventual availability + +The source's [FamCore definition](https://github.com/leanprover-community/riemann-hypothesis/blob/f150e02623b1e2bbe1f1da8eab5ffee5e930a6a3/src/Formalism/SharpRestriction/FamCore.lean) (Git blob `44cd54c38881086724fdf7f10f32b7d8e80e35b3`) includes `Win_unb : ∀ y, ∃ x ∈ Win, y ≤ x` and `Ix_win : ∀ x ∈ Win, Nonempty (Ix x)`. Its `FamCore.exists_pt` theorem therefore provides *arbitrarily large* scales carrying an inhabited index family. + +The source's `TOPF = AllLargeAt ... adm7` premise is stronger. It requires an index at **every** sufficiently large x, which makes the eventual pointwise prime-sum theorem meaningful across a tail of the real line. `cofinal_stages_do_not_force_eventual_availability` gives a native Lean counterexample: the even natural scales are unbounded and inhabited, while infinitely many odd scales remain absent. + +The counterexample clarifies why TOPF's existential condition cannot be silently inferred from FamCore's unbounded windows. It does not allege that the original proof makes that inference; TOPF is explicitly supplied in its hypotheses. + diff --git a/research/rh_proof_distillation/family_quantifier_source_audit.py b/research/rh_proof_distillation/family_quantifier_source_audit.py new file mode 100644 index 00000000..223e398e --- /dev/null +++ b/research/rh_proof_distillation/family_quantifier_source_audit.py @@ -0,0 +1,126 @@ +"""Independent pinned-source quantifier-shape audit for RHD-02. + +This reads only the exact upstream theorem statements and definition slices, +retains original byte provenance, and emits metadata. It does not import +upstream proofs or infer that any analytic hypothesis is true. +""" +from __future__ import annotations + +import argparse +import hashlib +import json +from pathlib import Path +import subprocess + +PIN = "f150e02623b1e2bbe1f1da8eab5ffee5e930a6a3" +DEFINITIONS = "src/Formalism/SharpRestriction/GlobalSchurBounds/ZetaZeroFreeRegion.lean" +THEOREMS = "src/Formalism/SharpRestriction/GlobalSchurBounds/RamificationTwoAndConjugationAtQAndD.lean" +BLOBS = { + DEFINITIONS: "7746e5a5affe67117d4ba907dbcd2788f539db6e", + THEOREMS: "1c1495ef81c77fa96f3c1a70106c1da9e24c0c5d", +} +GATES = { + "AllLargeC": ("def AllLargeC ", [ + "∃ C x0 : ℝ", "0 < C", "1 < x0", + "∀ x : ℝ, x0 ≤ x → ∀ i : (Fm ε h0 h1).Ix x,", + ]), + "AllLargeAt": ("def AllLargeAt ", [ + "∃ x0 : ℝ", "1 < x0", + "∀ x : ℝ, x0 ≤ x → ∃ i : (Fm ε h0 h1).Ix x,", + ]), + "SizesFe": ("def SizesFe ", [ + "∀ δ : ℝ, 0 < δ → ∃ x0 : ℝ", "SizesAt ", "PlacesAt ", + ]), + "FamilyPropTwoSix": ("def FamilyPropTwoSix ", ["AllLargeC Fm ε0 adm5"]), + "FamilyCharacterSumBounds": ("def FamilyCharacterSumBounds ", ["AllLargeC Fm ε0 adm6"]), + "TOPF": ("def TOPF ", ["AllLargeAt Fm ε0 adm7 C"]), +} +FAMILY_BRIDGE = ( + "theorem proposition_eleven_two_along_family ", + ("adm5 ", "adm6 ", "SizesAt ", "PlacesAt ", "adm7 ", + "proposition_eleven_two_at_scale", "∃ i : Fm.Ix x,"), +) + + +def git_blob(raw: bytes) -> str: + return hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\x00" + raw).hexdigest() + + +def declaration_slice(text: str, token: str) -> tuple[int, str]: + pos = text.find(token) + if pos < 0: + raise ValueError("declaration not found: " + token) + # Capture exactly the declaration until the next newline-led + # top-level source declaration; this is only a syntactic slice. + rest = text[pos:] + candidates = [ + idx for key in ("\ndef ", "\ntheorem ", "\nlemma ", "\nstructure ") + if (idx := rest.find(key, len(token))) >= 0 + ] + stop = min(candidates) if candidates else len(rest) + return text.count("\n", 0, pos) + 1, rest[:stop] + + +def inspect_text(definitions: str, theorems: str) -> dict: + sites = {} + for symbol, (marker, required) in GATES.items(): + line, source = declaration_slice(definitions, marker) + absent = [needle for needle in required if needle not in source] + if absent: + raise ValueError(f"{symbol} missing source clauses: {absent}") + sites[symbol] = {"path": DEFINITIONS, "line": line, + "text_sha256": hashlib.sha256(source.encode()).hexdigest(), + "required_fragments": required, + "evidence": "source_statement_text"} + marker, required = FAMILY_BRIDGE + line, body = declaration_slice(theorems, marker) + absent = [needle for needle in required if needle not in body] + if absent: + raise ValueError(f"family bridge missing source clauses: {absent}") + sites["proposition_eleven_two_along_family"] = { + "path": THEOREMS, "line": line, + "text_sha256": hashlib.sha256(body.encode()).hexdigest(), + "required_fragments": list(required), "evidence": "source_statement_and_body_text", + } + return sites + + +def audit(root: Path) -> dict: + head = subprocess.check_output( + ["git", "-C", str(root), "rev-parse", "HEAD"], text=True + ).strip() + if head != PIN: + raise ValueError("source checkout is not at the pinned commit") + contents = {} + for path, expected in BLOBS.items(): + raw = (root / path).read_bytes() + if git_blob(raw) != expected: + raise ValueError("source Git blob does not match: " + path) + contents[path] = raw.decode("utf-8") + return { + "source_commit": PIN, "source_blobs": BLOBS, + "sites": inspect_text(contents[DEFINITIONS], contents[THEOREMS]), + "proof_term_data": False, "verified_by": "pinned source text and Git blobs", + "limitations": ( + "This source audit checks quantifier order and named calls, " + "not truth, nonvacuity of every premise, or kernel proof dependencies." + ), + } + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--upstream", required=True, type=Path) + parser.add_argument("--output", required=True, type=Path) + args = parser.parse_args() + report = audit(args.upstream.resolve()) + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n") + print(json.dumps({ + "source_commit": PIN, "verified_blobs": len(BLOBS), + "quantifier_gates": len(report["sites"]), "proof_term_data": False, + }, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/tests/test_rhd02_family_source.py b/tests/test_rhd02_family_source.py new file mode 100644 index 00000000..4a966bc9 --- /dev/null +++ b/tests/test_rhd02_family_source.py @@ -0,0 +1,35 @@ +"""Offline mutation tests for source-derived RH family quantifier ledger.""" +import unittest + +from research.rh_proof_distillation.family_quantifier_source_audit import ( + DEFINITIONS, GATES, FAMILY_BRIDGE, declaration_slice, git_blob, + inspect_text, +) + + +class FamilyQuantifierSourceTests(unittest.TestCase): + def test_git_blob_identity(self): + self.assertEqual(git_blob(b""), "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") + + def test_exact_boundary_fails_on_missing_declaration(self): + with self.assertRaises(ValueError): + declaration_slice("theorem different := by", "def AllLargeC ") + + def test_varying_witness_would_fail_uniform_gate_check(self): + fragments = GATES["AllLargeC"][1] + src = ("def AllLargeC " + " ∧ ".join( + s.replace("∀ x : ℝ, x0 ≤ x → ∀ i : (Fm ε h0 h1).Ix x,", + "∀ x : ℝ, x0 ≤ x → ∃ i : (Fm ε h0 h1).Ix x,") + for s in fragments + ) + "\n") + _, body = declaration_slice(src, "def AllLargeC ") + self.assertNotIn(fragments[-1], body) + + def test_bridge_requirements_are_source_attestable(self): + self.assertIn("TOPF", GATES) + self.assertIn("SizesFe", GATES) + self.assertIn("proposition_eleven_two_at_scale", FAMILY_BRIDGE[1]) + + +if __name__ == "__main__": + unittest.main()