diff --git a/formal/MEASURE_BRIDGE.md b/formal/MEASURE_BRIDGE.md new file mode 100644 index 000000000..822710dc0 --- /dev/null +++ b/formal/MEASURE_BRIDGE.md @@ -0,0 +1,81 @@ +# Same-law measure-theoretic transfer companions + +Scientific effect: NONE. Author: Dylan Roy — delegated AI work; actual performer +OpenAI / GPT-6 Astra Pro, ChatGPT session of 2026-10-05. These are new companions, +not edits to GP-FOR-192, its original modules, or an existing analytic proof. +Statement alignment is PENDING_INDEPENDENT_REVIEW. A supplied proof is not a claim +of successful Lean execution; only the actual exact-commit receipt can establish it. + +## Source and dependency identity + +The informal interface is P02-LM-008, LCR-CAP-024-v1.0, §§2–3 and §§6–8: +`d6g8k5htny-coder/Math-`, commit +`22876edaaec054d3ab8b0b16668ce3ff8cbf8c73`, path +`imports/hardening_ebedb780/P02-LM-008/proof.md.export.txt`. +This is a read-only correspondence reference, not a newly authenticated historical +review. The new source module consumes the unchanged scalar companions, whose +SHA-256 remains `338452a0c2ba24d016059354d543cc995b8cb29c9d4a41d98bb93499f5f8cb8f`. +Lean stays at `leanprover/lean4:v4.34.1`; mathlib stays at +`d13f23b723b8a846827a245b89c10fc7d3f11612`. Its +`MeasureTheory.integral_mul_le_Lp_mul_Lq_of_nonneg` in +`Mathlib/MeasureTheory/Integral/Bochner/Basic.lean` is specialized to exponents 2,2. + +## Exact mathematical interface + +Let μ be one probability measure, W an almost-everywhere nonnegative real function +with `MemLp W 2 μ`, and A a measurable event. Write + + q = (μ A).toReal, n = ∫_A W dμ, z = ∫ W dμ, M₂ = ∫ W² dμ. + +The new declarations have the following coverage: + +| Declaration suffix | Established implication | +|---|---| +| `p02_lm008_integral_cs` | Actual Bochner-integral Cauchy–Schwarz for nonnegative L² functions on a measure space, with no probability-measure restriction. | +| `p02_lm008_event_cs` | n ≤ √M₂ √q, using the measurable event indicator under the identical μ. | +| `p02_lm008_event_numerator` | M₂ ≤ cW r⁴ and cW ≥ 0 imply n ≤ √cW r² √q. | +| `p02_lm008_measure_transfer` | With r > 0, cZ > 0, cW ≥ 0, M₂ ≤ cW r⁴ and cZ r² ≤ z, derive z > 0 and n/z ≤ (√cW/cZ)√q. | +| `p02_lm009_measure_transfer_r8_to_r3` | Also q ≤ K r⁸, K ≥ 0 and r ≤ 1 imply n/z ≤ ((√cW/cZ)√K)r³, via the stronger intermediate fourth-order bound. | +| `p02_lm008_sqrt_counterexample` | Exact scalar sharpness/negative witness for omitting √q. | +| `p02_lm008_upper_normalizer_counterexample` | Exact scalar witness showing an upper normalizer bound cannot replace the required lower one. | + +The common μ and W occur in the theorem types, not just in documentation. No +independence of A and W is assumed. Null/full events and zero weights on A are +allowed; the positive-normalizer hypothesis excludes the identically zero weight +from the ratio theorem. `MemLp` supplies genuine square-integrability rather than +using Lean's totalized integral to interpret a divergent second moment as zero. + +## Deliberate remaining obligations + +These are pointwise-in-r theorems. They do not construct a random field, a +conditioned law, a normalized `withDensity` probability measure, or a typed Palm +law. In particular PT1 (construction of the reweighted probability law) in the +informal source is not formalized here. The ratio is the interface being bounded. + +A concrete application must still prove its own L²/measurability assumptions, +second-moment estimate, lower normalizer and event tail under this exact law and +weight, together with constant uniformity. GP214's upper bound supplies none of +the lower-normalizer premise. No Gaussian or GT5 assertion, family asymptotic, +exponential/super-polynomial corollary, P02-LM-006, P02-LM-007, P0.2, or parent +persistence theorem is closed by these companions. Historical source labels and +reviews are preserved, not promoted or transferred to this new code. + +## Controls and execution + +The existing gate is unchanged. It builds the complete registered package, +rechecks it with leanchecker, prints types and transitive axioms for all 20 +declarations, and runs its original five rejection controls. All seven new +declarations are included in the same target/axiom inventory; the two counterexample +declarations are additional kernel propositions, not two extra rejection runs. + +`tests/test_measure_bridge.py` adds 11 focused tests. Its 216 exact three-point +cases check the squared Cauchy–Schwarz and normalized bounds, dependent events, +zero weights and null/full events. Separate rational models expose removal of the +event square root, upper-for-lower normalization, first-for-second-moment and +cross-law substitution. These tests check finite models and source wiring only; +they cannot replace Lean execution or a semantic alignment review. + +Review requests must identify the actual provider/family/agent and the exact new +manifest/scope. An OpenAI author replay or same-account commentary is not an +independent alignment acceptance. Existing gate/schema/toolchain and all original +proof bytes remain unchanged. diff --git a/formal/README.md b/formal/README.md index 251502ed4..f56e9c5d5 100644 --- a/formal/README.md +++ b/formal/README.md @@ -14,16 +14,20 @@ cd .. python formal/gate.py --execute ``` -The source-only command does not run Lean. The execute command fails unless the pinned project builds, `leanchecker` rechecks the package, all 13 declarations have transitive axiom reports restricted to propext/Classical.choice/Quot.sound, and five executable negative controls are rejected. It writes logs and a receipt in `.lake/formal-evidence/`; the workflow uploads them even on failure. A receipt from arbitrary input is not trusted evidence: use the successful read-only workflow and checked Git commit. +The source-only command does not run Lean. The execute command fails unless the pinned project builds, `leanchecker` rechecks the package, all 20 declarations have transitive axiom reports restricted to propext/Classical.choice/Quot.sound, and five executable negative controls are rejected. It writes logs and a receipt in `.lake/formal-evidence/`; the workflow uploads them even on failure. A receipt from arbitrary input is not trusted evidence: use the successful read-only workflow and checked Git commit. Sources: [scope](SCOPE.md), [glossary](GLOSSARY.md), [manifest](manifest.json), [blueprint source](blueprint/src/content.tex). The original GP-FOR-192 bytes are preserved under originals/*.lean.txt; separately named V2 companions carry the documented compiler-only repairs in [COMPATIBILITY.md](COMPATIBILITY.md). No historical Status.lean or claimed status is imported. [Alignment contract](SCOPE.md#review-contract) remains distinct from kernel evidence. ## Formal progress versus scientific status -`none`: no formal source; `specified`: statement only; `proved`: proof text supplied but no successful trusted run yet; `kernel-checked`: successful exact-commit build, recheck, axiom audit and negative controls. Alignment is separately pending/accepted/stale. The pilot's manifest records `proved` as source progress; the actual run receipt reports kernel evidence. No workflow edits a scientific register or retroactively changes old ACCEPT/AMEND dispositions. This workflow is not claimed to be a globally required branch-protection check. +`none`: no formal source; `specified`: statement only; `proved`: proof text supplied but no successful trusted run yet; `kernel-checked`: successful exact-commit build, recheck, axiom audit and negative controls. Alignment is separately pending/accepted/stale. The pilot's manifest records `proved` as source progress; the actual run receipt reports kernel evidence. No workflow edits a scientific register or retroactively changes old ACCEPT/AMEND dispositions. The existing required-check aggregate consumes this workflow as described in [required formal checks](../docs/FORMAL_REQUIRED_CHECKS.md); the workflow alone is not a scientific-acceptance gate. + +## Measure-theoretic bridge + +The additive [MeasureBridge](MEASURE_BRIDGE.md) contributes five same-law measure-theoretic/conditional-transfer declarations and two scalar counterexamples. It supplies the actual Cauchy–Schwarz numerator step, while the concrete moment estimate, lower normalizer and input event tail remain explicit premises. The original 13 scalar declarations, toolchain and gate are unchanged. The two counterexamples are audited declarations, not extra rejection runs. ## Next agents -Read main #95 and the exact PR head first. A non-OpenAI alignment reviewer should inspect all assumptions, the source correspondence and the explicit nonclaims. An independent engineering reviewer should attack omitted targets, imports carrying custom axioms, stale scope/hash/review records and altered toolchains. A probability formalizer should next establish an actual measure-theoretic Cauchy–Schwarz interface and its lower-normalizer dependency, without importing GP214's upper bound as the lower bound. Coordinate before editing; a review request is not a claim that a reviewer is active. +Read the current source-bound PR and exact head first; main #95 is historical rollout context. A non-OpenAI alignment reviewer should inspect all assumptions, the source correspondence and the explicit nonclaims. An independent engineering reviewer should attack omitted targets, imports carrying custom axioms, stale scope/hash/review records and altered toolchains. A probability formalizer should next construct the normalized reweighted probability measure and then discharge a concrete same-law moment/lower-normalizer interface. Do not import GP214's upper bound as the lower bound. The MeasureBridge source is supplied but has no self-awarded kernel or alignment status. Coordinate before editing; a review request is not a claim that a reviewer is active. Blueprint declaration links are checked against the target inventory and compiled declarations, not by semantic equivalence. The full plasTeX/LaTeX website is not installed in this pilot. Optional independent checkers or AI proof generators may be added with pinned versions/budgets; their availability and execution must be separately recorded. Never treat AlphaProof as an assumed publicly callable CI service or a generator's success as an independent alignment review. diff --git a/formal/ResearchFormalCoreR1.lean b/formal/ResearchFormalCoreR1.lean index 46f9f1122..772d991c0 100644 --- a/formal/ResearchFormalCoreR1.lean +++ b/formal/ResearchFormalCoreR1.lean @@ -1,2 +1,3 @@ import ResearchFormalCoreR1.AlgebraV2 import ResearchFormalCoreR1.ProbabilityCompanionsV2 +import ResearchFormalCoreR1.MeasureBridge diff --git a/formal/ResearchFormalCoreR1/MeasureBridge.lean b/formal/ResearchFormalCoreR1/MeasureBridge.lean new file mode 100644 index 000000000..11843e558 --- /dev/null +++ b/formal/ResearchFormalCoreR1/MeasureBridge.lean @@ -0,0 +1,145 @@ +import ResearchFormalCoreR1.ProbabilityCompanionsV2 + +/-! +# Measure-theoretic companions to P02-LM-008 + +These declarations use one measure and one weight throughout. They supply the +Cauchy-Schwarz step rather than assuming its numerator estimate. The concrete +second-moment and lower-normalizer estimates remain hypotheses. No Gaussian +field, typed Palm measure, uniform family of constants, or parent theorem is +constructed here. See ../MEASURE_BRIDGE.md for the exact source correspondence. +-/ + +namespace ResearchFormalCoreR1 + +open MeasureTheory +open scoped ENNReal + +set_option autoImplicit false + +variable {Ω : Type*} [MeasurableSpace Ω] + +/-- Actual Bochner-integral Cauchy-Schwarz for nonnegative square-integrable +functions, obtained from the pinned mathlib Holder theorem with exponents 2,2. -/ +theorem p02_lm008_integral_cs + (μ : Measure Ω) (f g : Ω → ℝ) + (hf : MemLp f 2 μ) (hg : MemLp g 2 μ) + (hf0 : 0 ≤ᵐ[μ] f) (hg0 : 0 ≤ᵐ[μ] g) : + (∫ x, f x * g x ∂μ) ≤ + Real.sqrt (∫ x, f x ^ 2 ∂μ) * Real.sqrt (∫ x, g x ^ 2 ∂μ) := by + have h := integral_mul_le_Lp_mul_Lq_of_nonneg + Real.HolderConjugate.two_two hf0 hg0 + (by simpa using hf) (by simpa using hg) + simpa only [Real.rpow_two, ← Real.sqrt_eq_rpow] using h + +/-- The event may depend arbitrarily on W. Its indicator's second moment is +its probability under this same μ; no independence assumption is used. -/ +theorem p02_lm008_event_cs + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : Ω → ℝ) (A : Set Ω) + (hW : MemLp W 2 μ) (hW0 : 0 ≤ᵐ[μ] W) (hA : MeasurableSet A) : + (∫ x in A, W x ∂μ) ≤ + Real.sqrt (∫ x, W x ^ 2 ∂μ) * Real.sqrt ((μ A).toReal) := by + classical + have hI : MemLp (A.indicator (fun _ : Ω => (1 : ℝ))) 2 μ := + (memLp_const (1 : ℝ)).indicator hA + have hI0 : 0 ≤ᵐ[μ] A.indicator (fun _ : Ω => (1 : ℝ)) := by + apply Filter.Eventually.of_forall + intro x + by_cases hx : x ∈ A <;> simp [hx] + have hcs := p02_lm008_integral_cs μ W + (A.indicator (fun _ : Ω => (1 : ℝ))) hW hI hW0 hI0 + have hprod : (fun x => W x * A.indicator (fun _ : Ω => (1 : ℝ)) x) = + A.indicator W := by + funext x + by_cases hx : x ∈ A <;> simp [hx] + have hsquare : (fun x => (A.indicator (fun _ : Ω => (1 : ℝ)) x) ^ 2) = + A.indicator (fun _ : Ω => (1 : ℝ)) := by + funext x + by_cases hx : x ∈ A <;> simp [hx] + rw [hprod, integral_indicator hA, hsquare, integral_indicator hA] at hcs + simpa [MeasureTheory.measureReal_def] using hcs + +/-- The r^4 second-moment premise supplies the previously assumed r^2 +numerator bound. This theorem does not establish that premise for a model. -/ +theorem p02_lm008_event_numerator + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : Ω → ℝ) (A : Set Ω) + (hW : MemLp W 2 μ) (hW0 : 0 ≤ᵐ[μ] W) (hA : MeasurableSet A) + (r cW : ℝ) (hcW : 0 ≤ cW) + (hsecond : (∫ x, W x ^ 2 ∂μ) ≤ cW * r ^ 4) : + (∫ x in A, W x ∂μ) ≤ Real.sqrt cW * r ^ 2 * Real.sqrt ((μ A).toReal) := by + have hsqrt : Real.sqrt (∫ x, W x ^ 2 ∂μ) ≤ Real.sqrt cW * r ^ 2 := by + calc + Real.sqrt (∫ x, W x ^ 2 ∂μ) ≤ Real.sqrt (cW * r ^ 4) := + Real.sqrt_le_sqrt hsecond + _ = Real.sqrt cW * r ^ 2 := by + rw [Real.sqrt_mul hcW] + rw [show r ^ 4 = (r ^ 2) ^ 2 by ring, Real.sqrt_sq (sq_nonneg r)] + exact (p02_lm008_event_cs μ W A hW hW0 hA).trans + (mul_le_mul_of_nonneg_right hsqrt (Real.sqrt_nonneg _)) + +/-- Same-law integral-ratio transfer. Positivity of the actual normalizer +is derived from its explicit lower bound, never from an upper bound. -/ +theorem p02_lm008_measure_transfer + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : Ω → ℝ) (A : Set Ω) + (hW : MemLp W 2 μ) (hW0 : 0 ≤ᵐ[μ] W) (hA : MeasurableSet A) + (r cW cZ : ℝ) (hr : 0 < r) (hcW : 0 ≤ cW) (hcZ : 0 < cZ) + (hsecond : (∫ x, W x ^ 2 ∂μ) ≤ cW * r ^ 4) + (hlower : cZ * r ^ 2 ≤ ∫ x, W x ∂μ) : + (∫ x in A, W x ∂μ) / (∫ x, W x ∂μ) ≤ + (Real.sqrt cW / cZ) * Real.sqrt ((μ A).toReal) := by + have hzpos : 0 < ∫ x, W x ∂μ := + lt_of_lt_of_le (mul_pos hcZ (sq_pos_of_pos hr)) hlower + exact p02_lm008_quotient_bound + (∫ x in A, W x ∂μ) (∫ x, W x ∂μ) r cW cZ ((μ A).toReal) + hr hcW hcZ ENNReal.toReal_nonneg hzpos hlower + (p02_lm008_event_numerator μ W A hW hW0 hA r cW hcW hsecond) + +/-- An explicitly supplied eighth-order event bound transfers to a cubic +bound on 0 < r ≤ 1. Uniformity in r and the input tail remain unproved here. -/ +theorem p02_lm009_measure_transfer_r8_to_r3 + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : Ω → ℝ) (A : Set Ω) + (hW : MemLp W 2 μ) (hW0 : 0 ≤ᵐ[μ] W) (hA : MeasurableSet A) + (r cW cZ K : ℝ) (hr : 0 < r) (hr1 : r ≤ 1) + (hcW : 0 ≤ cW) (hcZ : 0 < cZ) (hK : 0 ≤ K) + (hsecond : (∫ x, W x ^ 2 ∂μ) ≤ cW * r ^ 4) + (hlower : cZ * r ^ 2 ≤ ∫ x, W x ∂μ) + (htail : (μ A).toReal ≤ K * r ^ 8) : + (∫ x in A, W x ∂μ) / (∫ x, W x ∂μ) ≤ + ((Real.sqrt cW / cZ) * Real.sqrt K) * r ^ 3 := by + have hcoef : 0 ≤ Real.sqrt cW / cZ := + div_nonneg (Real.sqrt_nonneg _) hcZ.le + have hsqrt : Real.sqrt ((μ A).toReal) ≤ Real.sqrt K * r ^ 4 := by + calc + Real.sqrt ((μ A).toReal) ≤ Real.sqrt (K * r ^ 8) := Real.sqrt_le_sqrt htail + _ = Real.sqrt K * r ^ 4 := by + rw [Real.sqrt_mul hK] + rw [show r ^ 8 = (r ^ 4) ^ 2 by ring, Real.sqrt_sq (pow_nonneg hr.le 4)] + have hfourth : (∫ x in A, W x ∂μ) / (∫ x, W x ∂μ) ≤ + ((Real.sqrt cW / cZ) * Real.sqrt K) * r ^ 4 := by + calc + (∫ x in A, W x ∂μ) / (∫ x, W x ∂μ) ≤ + (Real.sqrt cW / cZ) * Real.sqrt ((μ A).toReal) := + p02_lm008_measure_transfer μ W A hW hW0 hA r cW cZ hr hcW hcZ hsecond hlower + _ ≤ (Real.sqrt cW / cZ) * (Real.sqrt K * r ^ 4) := + mul_le_mul_of_nonneg_left hsqrt hcoef + _ = ((Real.sqrt cW / cZ) * Real.sqrt K) * r ^ 4 := by ring + exact p02_lm009_palm_r4_to_r3 _ _ r + (mul_nonneg hcoef (Real.sqrt_nonneg _)) hr.le hr1 hfourth + +/-- Scalar data realized by W=4 on an event of probability 1/4 and W=0 +elsewhere. Cauchy-Schwarz is sharp; omitting the event square root is false. +The realization is checked separately by exact finite-model Python tests. -/ +theorem p02_lm008_sqrt_counterexample : + (1 : ℝ) = Real.sqrt 4 * Real.sqrt (1 / 4 : ℝ) ∧ + ¬ (1 : ℝ) ≤ Real.sqrt 4 * (1 / 4 : ℝ) := by + norm_num + +/-- Scalar data realized by W=1 on a one-point probability space, r=1, +cW=1, cZ=2. The upper bound on z holds but the proposed ratio bound fails. +This does not assert that the required lower bound holds. -/ +theorem p02_lm008_upper_normalizer_counterexample : + (1 : ℝ) ≤ 2 * 1 ^ 2 ∧ + (1 : ℝ) / 1 > (Real.sqrt 1 / 2) * Real.sqrt 1 := by + norm_num + +end ResearchFormalCoreR1 diff --git a/formal/SCOPE.md b/formal/SCOPE.md index e5094ac38..014919e8e 100644 --- a/formal/SCOPE.md +++ b/formal/SCOPE.md @@ -1,6 +1,6 @@ # Exact formal scope and alignment review -Scientific effect: NONE. The package offers 13 scalar companion statements from recovered GP-FOR-192. Its original archive has SHA256 a6440511fc259706457b18227734013966251105d538fdeabe633bb73f168631 (10,644 bytes). The two recovered source modules are preserved byte-identically under originals/*.lean.txt. The separately named AlgebraV2 and ProbabilityCompanionsV2 execution successors apply only the three documented compiler repairs in COMPATIBILITY.md; their thirteen theorem statements are unchanged. Neither version is a transcription of the full research theorem. Original Status.lean and metadata are deliberately not imported: labels for EC-012, EC-013 and Theorem-B-Jacobian did not supply those theorems. +Scientific effect: NONE. The original pilot offers 13 scalar companion statements from recovered GP-FOR-192. Its original archive has SHA256 a6440511fc259706457b18227734013966251105d538fdeabe633bb73f168631 (10,644 bytes). The two recovered source modules are preserved byte-identically under originals/*.lean.txt. The separately named AlgebraV2 and ProbabilityCompanionsV2 execution successors apply only the three documented compiler repairs in COMPATIBILITY.md; their thirteen theorem statements are unchanged. Neither version is a transcription of the full research theorem. Original Status.lean and metadata are deliberately not imported: labels for EC-012, EC-013 and Theorem-B-Jacobian did not supply those theorems. | Targets | Exact coverage | Not established | |---|---|---| @@ -16,6 +16,27 @@ Scientific effect: NONE. The package offers 13 scalar companion statements from GP214's upper bound Z_r <= 15 r^2 cannot discharge the required lower bound cZ r^2 <= z. None of these targets is the SIDE24 coefficient enclosure, the elder-rule selection theorem, or the joint extremum/merging-saddle law. Some algebraic assumptions are stronger than necessary; preserving them is intentional. Reducing them requires a separately scoped change, not silent strengthening of a parent theorem. +## Additive measure-theoretic bridge (seven new declarations) + +The package now registers 20 declarations: the original 13 above and seven in +`ResearchFormalCoreR1/MeasureBridge.lean`. The exact statement mapping and retained +hypotheses are in the hash-bound [bridge scope](MEASURE_BRIDGE.md). + +| Targets | Exact coverage | Not established | +|---|---|---| +| p02_lm008_integral_cs | Bochner-integral Cauchy–Schwarz for nonnegative L² functions under one measure | Any concrete model moment estimate | +| p02_lm008_event_cs | Indicator specialization under one probability measure, with measurable event and nonnegative L² weight | Independence is neither assumed nor concluded | +| p02_lm008_event_numerator | Derives the r² numerator bound from the actual integral second-moment premise | Validity or uniformity of that premise in a field model | +| p02_lm008_measure_transfer | Bounds the same-law integral ratio using the explicit positive lower normalizer and second-moment premises | Construction of the reweighted/Palm probability measure or proof of its lower normalizer | +| p02_lm009_measure_transfer_r8_to_r3 | Transfers a supplied eighth-order event bound to a cubic ratio bound on 0 < r <= 1 | An event-tail theorem, uniform family of constants, P0.2 or parent closure | +| p02_lm008_sqrt_counterexample, p02_lm008_upper_normalizer_counterexample | Exact scalar witnesses excluding missing-square-root and reversed-normalizer mutations | Kernel construction of the finite probability-space realizations | + +All new statements remain conditional at their displayed hypotheses. They do not +transfer historical reviews to new bytes. The original two modules, their proofs, +the gate and its five executable rejection controls remain unchanged. The two +new counterexamples are included in the normal target/axiom inventory. The changed +manifest and scope require a fresh separately authenticated alignment review. + ## Review contract The source manifest is an evidence sidecar, not another scientific register. A trusted successful workflow establishes kernel evidence only for these target declarations and their displayed hypotheses, relative to Lean's kernel/standard foundations/toolchain. Independent review must compare each Lean statement and definition to this scope note and the source actually cited. Review author, provider, family and agent must be explicit. Validate an authenticated record with `python formal/gate.py --alignment review.json`; then the existing controlling gate must decide whether its wider requirements are met. The validator does not authenticate a review merely because a JSON string names a reviewer. diff --git a/formal/blueprint/src/content.tex b/formal/blueprint/src/content.tex index 62911d509..50a971584 100644 --- a/formal/blueprint/src/content.tex +++ b/formal/blueprint/src/content.tex @@ -34,3 +34,25 @@ \section{Scalar formalization pilot} Then $p\le Cr^3$. This supplies no new probabilistic bound on $p$. \end{lemma} \begin{proof}Use $r^4\le r^3$ and multiply by nonnegative $C$.\end{proof} + +\section{Same-law measure-theoretic bridge} +\begin{lemma}[Event Cauchy--Schwarz] +\label{lem:event-cs} +\lean{ResearchFormalCoreR1.p02_lm008_event_cs} +Let $\mu$ be a probability measure, $W\in L^2(\mu)$ nonnegative almost +surely and $A$ measurable. Then +$\int_A W\,d\mu\le\sqrt{\int W^2\,d\mu}\sqrt{\mu(A)}$. +No independence between $A$ and $W$ is assumed. +\end{lemma} +\begin{proof}Apply Holder with exponents $2,2$ to $W$ and $1_A$.\end{proof} +\begin{lemma}[Same-law ratio transfer] +\label{lem:measure-transfer} +\lean{ResearchFormalCoreR1.p02_lm008_measure_transfer} +\uses{lem:event-cs,lem:quotient} +Under the preceding assumptions, also suppose $r>0$, $c_W\ge0$, $c_Z>0$, +$\int W^2\,d\mu\le c_Wr^4$ and $c_Zr^2\le\int W\,d\mu$. +Then $(\int_A W\,d\mu)/(\int W\,d\mu)\le(\sqrt{c_W}/c_Z)\sqrt{\mu(A)}$. +The two model bounds remain premises; no Palm measure is constructed here. +\end{lemma} +\begin{proof}Bound the numerator, derive a positive normalizer, and use +the unchanged scalar quotient theorem.\end{proof} diff --git a/formal/manifest.json b/formal/manifest.json index c0782d01c..8bb1c8959 100644 --- a/formal/manifest.json +++ b/formal/manifest.json @@ -21,7 +21,8 @@ }, "source_modules": [ "ResearchFormalCoreR1/AlgebraV2.lean", - "ResearchFormalCoreR1/ProbabilityCompanionsV2.lean" + "ResearchFormalCoreR1/ProbabilityCompanionsV2.lean", + "ResearchFormalCoreR1/MeasureBridge.lean" ], "targets": [ "ResearchFormalCoreR1.ec005_fold_gap", @@ -36,18 +37,25 @@ "ResearchFormalCoreR1.p02_lm009_bad_event_threshold", "ResearchFormalCoreR1.p02_lm009_power40_identity", "ResearchFormalCoreR1.p02_lm009_r4_le_r3", - "ResearchFormalCoreR1.p02_lm009_palm_r4_to_r3" + "ResearchFormalCoreR1.p02_lm009_palm_r4_to_r3", + "ResearchFormalCoreR1.p02_lm008_integral_cs", + "ResearchFormalCoreR1.p02_lm008_event_cs", + "ResearchFormalCoreR1.p02_lm008_event_numerator", + "ResearchFormalCoreR1.p02_lm008_measure_transfer", + "ResearchFormalCoreR1.p02_lm009_measure_transfer_r8_to_r3", + "ResearchFormalCoreR1.p02_lm008_sqrt_counterexample", + "ResearchFormalCoreR1.p02_lm008_upper_normalizer_counterexample" ], "files": { ".gitignore": "b34af236d1df9e39ed4f98fca51702530ce76bdee4e1a69512f6caed933c3374", "COMPATIBILITY.md": "33721aad32f82131a6956a06b58c5bc41f5d28f26efe840a99a4d51ad60cf247", "GLOSSARY.md": "6bdda2ce054915efc26e8db462dbe8fd9d0c1db30e02328857bebc6568e05ce9", - "README.md": "0ff3f68d79369b681691c93f0bc99fbff2ac75460a6946d7f7d1a146de499cf9", + "README.md": "6f6f5d235d913b3fdcbfa6c08f739ca34629da7d02d86fb6abcb0684f5ba46f1", "ResearchFormalCoreR1/AlgebraV2.lean": "4480708263c40a2f7f03f12ef7e15f0eb4f8193c2dccbb253921a7ec251863c3", "ResearchFormalCoreR1/ProbabilityCompanionsV2.lean": "338452a0c2ba24d016059354d543cc995b8cb29c9d4a41d98bb93499f5f8cb8f", - "ResearchFormalCoreR1.lean": "f905b97411b4a8a5e0ba046ba0805dd9889e2276eac072a0e44c0e9b6ee5fe3f", - "SCOPE.md": "350732d7a501fd37d15632b13bd2ac30b8a6d87259b9a3b0931639041a1cfb84", - "blueprint/src/content.tex": "3e86863669d164bbf1e78347b6d027889c27adb660deebce47706d16694bb90c", + "ResearchFormalCoreR1.lean": "d091b1dc7c7d7551040092781ac80afc827109330fdccfb4e1381879df7526e5", + "SCOPE.md": "e303550bdd71aa969703fd33dc9808383db13b08072437577d192a7f149a3edb", + "blueprint/src/content.tex": "e00ee78344ed27c097bccb8c6360f6bb86a223ab06319a407de2dd0104fd2e28", "evidence/initial-build-failure.log": "43393d2e2b3148a2453e3092a1ff04e257dbd4a6dc97eb2853a8bc0451002591", "gate.py": "4f14a78bbc6e9b7f929648b13ad3a9ae467256db4be9792e3667680e697a5c94", "lake-manifest.json": "d63753befccc21923783a5085148e3ff028d97134ea52f5a08bd87ecf1b0b043", @@ -55,6 +63,9 @@ "lean-toolchain": "d5edba4e4b8faad9c1baeadb265716d20d03be4d1a2647dc5e35b0c0325bea7b", "originals/Algebra.lean.txt": "4c196820c4db8fafc288dd35642828ba577e3544d60aba7d1d6d24f14ad1e8ae", "originals/ProbabilityCompanions.lean.txt": "4ace6600a476859982c8851ae9097c89b082d3c96291b3c8330bd4cc00bae65d", - "tests/test_gate.py": "5df769901bbf53a7a434c2794c8685242ecfdc32f15d72fae8c2030dff7a9aa2" + "tests/test_gate.py": "5df769901bbf53a7a434c2794c8685242ecfdc32f15d72fae8c2030dff7a9aa2", + "ResearchFormalCoreR1/MeasureBridge.lean": "28ac130db490c3c3e2fbfabf3ac5be43c854ab1468bf573bf5a8c0dd2c50955f", + "MEASURE_BRIDGE.md": "bdb6c06f359f17d493d6057adbed61edb20236b7a3a3ca4880ae0b33d8a7200e", + "tests/test_measure_bridge.py": "4df86de602d7beffb988b398fe8090b3bb11d0a3dde44685edd584f4864ebe25" } } diff --git a/formal/tests/test_measure_bridge.py b/formal/tests/test_measure_bridge.py new file mode 100644 index 000000000..76eaf915a --- /dev/null +++ b/formal/tests/test_measure_bridge.py @@ -0,0 +1,113 @@ +"""Source wiring and exact finite-model controls; these do not run the Lean kernel.""" +from fractions import Fraction as F +import hashlib +import itertools +import json +from pathlib import Path +import re +import unittest + +ROOT = Path(__file__).resolve().parents[1] +MODULE = 'ResearchFormalCoreR1/MeasureBridge.lean' +NAMES = [ + 'p02_lm008_integral_cs', + 'p02_lm008_event_cs', + 'p02_lm008_event_numerator', + 'p02_lm008_measure_transfer', + 'p02_lm009_measure_transfer_r8_to_r3', + 'p02_lm008_sqrt_counterexample', + 'p02_lm008_upper_normalizer_counterexample', +] +ORIGINALS = { + 'ResearchFormalCoreR1/AlgebraV2.lean': '4480708263c40a2f7f03f12ef7e15f0eb4f8193c2dccbb253921a7ec251863c3', + 'ResearchFormalCoreR1/ProbabilityCompanionsV2.lean': '338452a0c2ba24d016059354d543cc995b8cb29c9d4a41d98bb93499f5f8cb8f', +} + + +def moments(probabilities, weights, event): + q = sum((p for p, inside in zip(probabilities, event) if inside), F(0)) + n = sum((p*w for p, w, inside in zip(probabilities, weights, event) if inside), F(0)) + z = sum((p*w for p, w in zip(probabilities, weights)), F(0)) + second = sum((p*w*w for p, w in zip(probabilities, weights)), F(0)) + return q, n, z, second + + +class MeasureBridgeSourceTests(unittest.TestCase): + def test_bridge_module_present(self): + self.assertTrue((ROOT/MODULE).is_file(), 'measure-theoretic bridge not supplied') + + def test_exact_new_inventory(self): + manifest = json.loads((ROOT/'manifest.json').read_text()) + targets = ['ResearchFormalCoreR1.'+name for name in NAMES] + self.assertEqual(manifest['targets'][13:], targets) + self.assertEqual(len(manifest['targets']), 20) + self.assertIn(MODULE, manifest['source_modules']) + + def test_module_and_scope_bound(self): + manifest = json.loads((ROOT/'manifest.json').read_text()) + for path in (MODULE, 'MEASURE_BRIDGE.md', 'tests/test_measure_bridge.py'): + self.assertIn(path, manifest['files']) + self.assertEqual(hashlib.sha256((ROOT/path).read_bytes()).hexdigest(), + manifest['files'][path]) + + def test_registered_declarations_and_import(self): + self.assertTrue((ROOT/MODULE).exists(), 'measure-theoretic bridge not supplied') + source = (ROOT/MODULE).read_text() + self.assertEqual(re.findall(r'^(?:theorem|lemma)\s+([A-Za-z_][A-Za-z0-9_]*)', source, re.M), NAMES) + self.assertIn('import ResearchFormalCoreR1.MeasureBridge\n', + (ROOT/'ResearchFormalCoreR1.lean').read_text()) + + def test_original_companion_identities_retained(self): + manifest = json.loads((ROOT/'manifest.json').read_text()) + for path, digest in ORIGINALS.items(): + self.assertEqual(manifest['files'][path], digest) + self.assertEqual(manifest['scientific_effect'], 'NONE') + self.assertEqual(manifest['alignment_status'], 'PENDING_INDEPENDENT_REVIEW') + + +class MeasureBridgeFiniteModelTests(unittest.TestCase): + def test_dependent_events_and_zero_edges(self): + # Includes null/full events, zero weights, and events depending on W. + probabilities = [F(1, 4), F(1, 4), F(1, 2)] + for weights in itertools.product([F(0), F(1, 2), F(2)], repeat=3): + for event in itertools.product([False, True], repeat=3): + q, n, z, second = moments(probabilities, weights, event) + self.assertLessEqual(n*n, second*q) + if z > 0: + # Square both nonnegative sides of the exact-normalizer bound. + self.assertLessEqual((n/z)**2, second*q/(z*z)) + if q == 0: + self.assertEqual(n, 0) + + def test_omitted_square_root_is_false_and_cs_is_sharp(self): + q, n, z, second = moments([F(1, 4), F(3, 4)], [F(4), F(0)], [True, False]) + self.assertEqual((q, n, z, second), (F(1, 4), F(1), F(1), F(4))) + self.assertEqual(n*n, second*q) + self.assertGreater(n*n, second*q*q) + + def test_upper_normalizer_bound_does_not_replace_lower(self): + q, n, z, second = moments([F(1)], [F(1)], [True]) + r, cW, cZ = F(1), F(1), F(2) + self.assertLessEqual(second, cW*r**4) + self.assertLessEqual(z, cZ*r**2) # deliberately wrong direction + self.assertGreater((n/z)**2, cW*q/cZ**2) + + def test_second_moment_cannot_be_replaced_by_first(self): + q, n, z, second = moments([F(1, 16), F(15, 16)], [F(16), F(0)], [True, False]) + self.assertEqual(z, 1) + self.assertGreater(n*n, z*q) + self.assertEqual(n*n, second*q) + + def test_cross_law_substitution_fails(self): + _, n, _, second = moments([F(1, 4), F(3, 4)], [F(4), F(0)], [True, False]) + wrong_q = F(1, 16) + self.assertGreater(n*n, second*wrong_q) + + def test_eighth_order_tail_ledger(self): + for r in [F(1), F(1, 2), F(1, 4), F(1, 8)]: + self.assertEqual((r**4)**2, r**8) + self.assertLessEqual(r**4, r**3) + + +if __name__ == '__main__': + unittest.main()