diff --git a/formal/MOMENT_TAIL.md b/formal/MOMENT_TAIL.md new file mode 100644 index 000000000..d45f52591 --- /dev/null +++ b/formal/MOMENT_TAIL.md @@ -0,0 +1,102 @@ +# Actual moment-to-event-tail composition + +Scientific effect: NONE. Dylan Roy — delegated AI work; actual performer OpenAI / +GPT-6 Astra Pro, 2026-10-05. This is an additive successor to the frozen 29-target +package in Math-#273, not a claim that the stack is merged or this new scope aligned. + +## Source identity and design + +Consumed predecessor: `d6g8k5htny-coder/Math-` at +`dce1b197be3431673289905259be38b450e9b898`. The original four Lean modules, all +29 theorem statements/proofs, gate and toolchain remain unchanged. +`WeightedLaw.lean` SHA256 is +`f31dfd2cd048cc0c0446c54c46d89c9cdd5d7bb9d76e9d8d16b7c034f351d736`. + +The scalar P02-LM-009 source is the preserved fifth-power threshold, exponent40 +identity and fourth-to-cubic ledger in `formal/ResearchFormalCoreR1/ProbabilityCompanionsV2.lean` +at that predecessor, SHA256 +`338452a0c2ba24d016059354d543cc995b8cb29c9d4a41d98bb93499f5f8cb8f`. +The actual measure inequality is mathlib's +`MeasureTheory.mul_meas_ge_le_integral_of_nonneg` in +`Mathlib/MeasureTheory/Integral/Bochner/Basic.lean`, pinned mathlib +`d13f23b723b8a846827a245b89c10fc7d3f11612`; Lean remains v4.34.1. +This note gives a new explicit composition of those statements. It does not claim +a recovered full P02-LM-009 probability proof or a Gaussian supremum theorem. + +## Exact derivation + +For positive r and epsilon, define A = {x : epsilon < r R(x)^5}. +Its measurable-set property is proved from Measurable R. On A, + + 0 < epsilon/r < R^5, hence (epsilon/r)^8 <= R^40. + +A genuinely integrable fortieth power with integral at most M gives, by Markov, + + mu(A) <= M / (epsilon/r)^8 = (M/epsilon^8) r^8. + +No nonnegativity of R is needed: membership in A supplies the positive threshold; +the fortieth power is nonnegative everywhere. Strict-boundary and negative-R +examples are tested. The generic Markov lemma is on a finite measure, not only +a probability; finite measure makes conversion of event masses to real numbers +monotone without turning an infinite mass into zero. + +If the same probability measure and weight additionally satisfy W in L2, +W >= 0 almost everywhere, integral W^2 <= cW r^4, and cZ r^2 <= integral W, +with cW >= 0 and cZ > 0, the already constructed weighted probability law obeys + + P_W(A) <= C r^4, C = (sqrt(cW)/cZ) sqrt(M/epsilon^8). + +On 0 < r <= 1 this implies P_W(A) <= C r^3. Probability of P_W is proved as +part of each conclusion. W may depend arbitrarily on R and A; no independence +or replacement of a conditioned law by another law is introduced. + +## Seven new audited targets (36 total) + +| Suffix in ResearchFormalCoreR1 | Exact coverage | +|---|---| +| p02_lm009_markov_event | Event-contained-in-threshold Markov bound under actual integrability/nonnegativity and finite measure. | +| p02_lm009_badJet_measurable | Measurability of the strict bad event. | +| p02_lm009_badJet_subset | Event implies the fortieth-power threshold, including signed R. | +| p02_lm009_moment40_tail | Supplied integral fortieth-moment bound yields the actual eighth-order event tail. | +| p02_lm009_moment40_weighted_r4 | Actual weighted-law probability property and the stronger fourth-order bound. | +| p02_lm009_moment40_weighted_r3 | Cubic consequence on 0 < r <= 1. | +| p02_lm009_moment40_family_r3 | A single nonnegative C for 0 < r <= r0, only from uniformly supplied family premises with 0 < r0 <= 1. | + +The family theorem explicitly quantifies possibly different mu_r,W_r,R_r under a +common measurable space, with the SAME mu_r for every moment/normalizer/event +at each r. M,cW,cZ,epsilon are fixed outside the r quantifier. It does not deduce +uniformity from unrelated pointwise constants. The witness C is displayed above. + +## Retained open obligations + +The input moment bound M, the weight second-moment bound, lower normalizer, +measurability/model construction and their constant uniformity must still be +proved for the concrete Gaussian field and typed Palm interpretation. No bound +on a derivative supremum, GT5 repair, Kac-Rice identification, full good event, +P0.2 or parent persistence theorem is supplied. The bad event here is exactly +one strict scalar threshold, not every component of the program's good event. +The older modules' exclusion notes remain true descriptions of those modules; +this new module supplies only the explicit moment-to-event implication. + +## Verification and audit + +The unchanged gate must build/recheck/audit all36 targets and its five existing +negative controls. A proof file or Python pass is not a kernel receipt. Twelve +focused tests include243 exact finite tail cases and972 weighted-event cases. +Countermodels expose omission of epsilon^-8, substitution of the20th for40th +moment, an incorrect r^16 rate, and strict-boundary/null-atom cases. They are +falsification checks, not continuum proof or an independent alignment review. +The prior weighted-law test now binds precisely targets20:29; the extension +binds targets29:36 and total36, with the unchanged gate still enforcing complete +source inventory. Every old proof byte remains frozen. Any successful audit +must state actual identity/exposure and exact new manifest/scope, not silently +transfer a previous29-target review to36 targets. + +## Initial compiler readback + +The first hosted run37315764990 failed before kernel evidence. The threshold +subset proof needed an explicit `change` from set membership to its inequality +goal; a `simpa only` list did not reduce that membership. The compiler-only +repair states this goal explicitly and removes a redundant `ring` after +`field_simp`. Every theorem type is unchanged. The original output is preserved +in `evidence/moment-tail-initial-build-failure.log`; it is not a success receipt. diff --git a/formal/README.md b/formal/README.md index ae1712d5b..b31052eaf 100644 --- a/formal/README.md +++ b/formal/README.md @@ -14,7 +14,7 @@ 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 29 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 36 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. @@ -30,6 +30,10 @@ The additive [MeasureBridge](MEASURE_BRIDGE.md) contributes five same-law measur The additive [WeightedLaw](WEIGHTED_LAW.md) contributes nine declarations. It constructs the normalized nonnegative density measure, proves total mass one and the event-ratio identity, and applies the retained transfer bounds to its actual event probabilities. It also proves absolute continuity, almost-everywhere invariance, and zero/unit-weight controls. The original 20 theorem statements and proofs are unchanged; concrete Palm-model identification and field estimates remain separate. +## Moment-to-tail composition + +The additive [MomentTail](MOMENT_TAIL.md) contributes seven declarations. It proves the actual Markov step from an integrable fortieth-moment bound to the strict fifth-power event's eighth-order probability bound, then the constructed weighted law's fourth-order and cubic bounds. A family theorem supplies one constant only when the model premises are explicitly uniform. Concrete Gaussian/Palm moments and normalizers are not proved by this implication. + ## Next agents 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 identify the constructed weighted law with the concrete typed Palm model and discharge its 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. diff --git a/formal/ResearchFormalCoreR1.lean b/formal/ResearchFormalCoreR1.lean index 9c1547f7a..ad533b601 100644 --- a/formal/ResearchFormalCoreR1.lean +++ b/formal/ResearchFormalCoreR1.lean @@ -2,3 +2,4 @@ import ResearchFormalCoreR1.AlgebraV2 import ResearchFormalCoreR1.ProbabilityCompanionsV2 import ResearchFormalCoreR1.MeasureBridge import ResearchFormalCoreR1.WeightedLaw +import ResearchFormalCoreR1.MomentTail diff --git a/formal/ResearchFormalCoreR1/MomentTail.lean b/formal/ResearchFormalCoreR1/MomentTail.lean new file mode 100644 index 000000000..c8282f297 --- /dev/null +++ b/formal/ResearchFormalCoreR1/MomentTail.lean @@ -0,0 +1,151 @@ +import ResearchFormalCoreR1.WeightedLaw + +/-! +# From a genuine fortieth moment to a weighted bad-event bound + +This module supplies Markov's measure-theoretic step. It does not prove a +fortieth-moment estimate for a Gaussian jet, or a concrete Palm normalizer. +All law/weight/jet objects and uniform family premises remain explicit. +-/ + +namespace ResearchFormalCoreR1 + +open MeasureTheory +open scoped ENNReal + +set_option autoImplicit false + +variable {Ω : Type*} [MeasurableSpace Ω] + +/-- The exact strict threshold event used by the fifth-power jet ledger. -/ +def badJetEvent (R : Ω → ℝ) (r ε : ℝ) : Set Ω := + {x | ε < r * R x ^ 5} + +/-- Markov for any event contained in a positive superlevel set, on a finite +measure. Integrability prevents totalized divergent integrals from being used. -/ +theorem p02_lm009_markov_event + (μ : Measure Ω) [IsFiniteMeasure μ] (Y : Ω → ℝ) (A : Set Ω) + (hY : Integrable Y μ) (hY0 : 0 ≤ᵐ[μ] Y) + (a : ℝ) (ha : 0 < a) (hsub : A ⊆ {x | a ≤ Y x}) : + (μ A).toReal ≤ (∫ x, Y x ∂μ) / a := by + have hm : (μ A).toReal ≤ (μ {x | a ≤ Y x}).toReal := + ENNReal.toReal_mono (by finiteness) (measure_mono hsub) + have hmarkov := mul_meas_ge_le_integral_of_nonneg hY0 hY a + apply (le_div_iff₀ ha).2 + calc + (μ A).toReal * a = a * (μ A).toReal := by ring + _ ≤ a * (μ {x | a ≤ Y x}).toReal := mul_le_mul_of_nonneg_left hm ha.le + _ ≤ ∫ x, Y x ∂μ := by simpa only [measureReal_def] using hmarkov + +/-- Actual measurability of the bad event from measurability of the jet norm. -/ +theorem p02_lm009_badJet_measurable + (R : Ω → ℝ) (hR : Measurable R) (r ε : ℝ) : + MeasurableSet (badJetEvent R r ε) := by + unfold badJetEvent + exact measurableSet_lt measurable_const (by fun_prop) + +/-- The event itself implies the needed positive fifth-power threshold, even +for signed R; no global sign assumption on R is necessary. -/ +theorem p02_lm009_badJet_subset + (R : Ω → ℝ) (r ε : ℝ) (hr : 0 < r) (hε : 0 < ε) : + badJetEvent R r ε ⊆ {x | (ε / r) ^ 8 ≤ R x ^ 40} := by + intro x hx + change ε < r * R x ^ 5 at hx + change (ε / r) ^ 8 ≤ R x ^ 40 + have ht := p02_lm009_bad_event_threshold r (R x) ε hr hx + have hp := pow_le_pow_left₀ (le_of_lt (div_pos hε hr)) ht.le 8 + simpa only [p02_lm009_power40_identity] using hp + +/-- A supplied integrable fortieth-moment bound gives the actual eighth-order +event tail, with the exact epsilon denominator and no independence hypothesis. -/ +theorem p02_lm009_moment40_tail + (μ : Measure Ω) [IsProbabilityMeasure μ] (R : Ω → ℝ) + (r ε M : ℝ) (hr : 0 < r) (hε : 0 < ε) + (hRi : Integrable (fun x => R x ^ 40) μ) + (hMbound : (∫ x, R x ^ 40 ∂μ) ≤ M) : + (μ (badJetEvent R r ε)).toReal ≤ (M / ε ^ 8) * r ^ 8 := by + have hnonneg : 0 ≤ᵐ[μ] (fun x => R x ^ 40) := by + apply Filter.Eventually.of_forall + intro x + positivity + have ha : 0 < (ε / r) ^ 8 := pow_pos (div_pos hε hr) 8 + calc + (μ (badJetEvent R r ε)).toReal ≤ (∫ x, R x ^ 40 ∂μ) / (ε / r) ^ 8 := + p02_lm009_markov_event μ (fun x => R x ^ 40) (badJetEvent R r ε) + hRi hnonneg ((ε / r) ^ 8) ha (p02_lm009_badJet_subset R r ε hr hε) + _ ≤ M / (ε / r) ^ 8 := div_le_div_of_nonneg_right hMbound ha.le + _ = (M / ε ^ 8) * r ^ 8 := by + field_simp [ne_of_gt hr, ne_of_gt hε] + +/-- The constructed weighted probability law satisfies the stronger fourth- +order tail. The model's moment and positive lower-normalizer bounds are premises. -/ +theorem p02_lm009_moment40_weighted_r4 + (μ : Measure Ω) [IsProbabilityMeasure μ] (W R : Ω → ℝ) + (hW : MemLp W 2 μ) (hW0 : 0 ≤ᵐ[μ] W) (hR : Measurable R) + (r ε M cW cZ : ℝ) (hr : 0 < r) (hε : 0 < ε) + (hM : 0 ≤ M) (hcW : 0 ≤ cW) (hcZ : 0 < cZ) + (hRi : Integrable (fun x => R x ^ 40) μ) + (hMbound : (∫ x, R x ^ 40 ∂μ) ≤ M) + (hsecond : (∫ x, W x ^ 2 ∂μ) ≤ cW * r ^ 4) + (hlower : cZ * r ^ 2 ≤ ∫ x, W x ∂μ) : + IsProbabilityMeasure (weightedLaw μ W) ∧ + (weightedLaw μ W (badJetEvent R r ε)).toReal ≤ + ((Real.sqrt cW / cZ) * Real.sqrt (M / ε ^ 8)) * r ^ 4 := by + have hA := p02_lm009_badJet_measurable R hR r ε + have ht := p02_lm009_moment40_tail μ R r ε M hr hε hRi hMbound + have hK : 0 ≤ M / ε ^ 8 := by positivity + have hs : Real.sqrt ((μ (badJetEvent R r ε)).toReal) ≤ + Real.sqrt (M / ε ^ 8) * r ^ 4 := by + calc + _ ≤ Real.sqrt ((M / ε ^ 8) * r ^ 8) := Real.sqrt_le_sqrt ht + _ = _ := by + rw [Real.sqrt_mul hK] + rw [show r ^ 8 = (r ^ 4) ^ 2 by ring, Real.sqrt_sq (pow_nonneg hr.le 4)] + obtain ⟨hp, hb⟩ := p02_lm008_probability_transfer μ W (badJetEvent R r ε) + hW hW0 hA r cW cZ hr hcW hcZ hsecond hlower + refine ⟨hp, hb.trans ?_⟩ + calc + _ ≤ (Real.sqrt cW / cZ) * (Real.sqrt (M / ε ^ 8) * r ^ 4) := + mul_le_mul_of_nonneg_left hs (by positivity) + _ = _ := by ring + +/-- Cubic consequence on the explicit domain 0 < r ≤ 1. -/ +theorem p02_lm009_moment40_weighted_r3 + (μ : Measure Ω) [IsProbabilityMeasure μ] (W R : Ω → ℝ) + (hW : MemLp W 2 μ) (hW0 : 0 ≤ᵐ[μ] W) (hR : Measurable R) + (r ε M cW cZ : ℝ) (hr : 0 < r) (hr1 : r ≤ 1) (hε : 0 < ε) + (hM : 0 ≤ M) (hcW : 0 ≤ cW) (hcZ : 0 < cZ) + (hRi : Integrable (fun x => R x ^ 40) μ) + (hMbound : (∫ x, R x ^ 40 ∂μ) ≤ M) + (hsecond : (∫ x, W x ^ 2 ∂μ) ≤ cW * r ^ 4) + (hlower : cZ * r ^ 2 ≤ ∫ x, W x ∂μ) : + IsProbabilityMeasure (weightedLaw μ W) ∧ + (weightedLaw μ W (badJetEvent R r ε)).toReal ≤ + ((Real.sqrt cW / cZ) * Real.sqrt (M / ε ^ 8)) * r ^ 3 := by + obtain ⟨hp, hb⟩ := p02_lm009_moment40_weighted_r4 μ W R hW hW0 hR + r ε M cW cZ hr hε hM hcW hcZ hRi hMbound hsecond hlower + exact ⟨hp, p02_lm009_palm_r4_to_r3 _ _ r (by positivity) hr.le hr1 hb⟩ + +/-- A uniform family conclusion only when all law-specific bounds are supplied +uniformly. This proves the quantifier assembly, not the existence of model bounds. -/ +theorem p02_lm009_moment40_family_r3 + (μ : ℝ → Measure Ω) [∀ r, IsProbabilityMeasure (μ r)] + (W R : ℝ → Ω → ℝ) (r0 ε M cW cZ : ℝ) + (hr0 : 0 < r0 ∧ r0 ≤ 1) (hε : 0 < ε) + (hM : 0 ≤ M) (hcW : 0 ≤ cW) (hcZ : 0 < cZ) + (hdata : ∀ r, 0 < r → r ≤ r0 → + MemLp (W r) 2 (μ r) ∧ (0 ≤ᵐ[μ r] W r) ∧ Measurable (R r) ∧ + Integrable (fun x => R r x ^ 40) (μ r) ∧ + (∫ x, R r x ^ 40 ∂(μ r)) ≤ M ∧ + (∫ x, W r x ^ 2 ∂(μ r)) ≤ cW * r ^ 4 ∧ + cZ * r ^ 2 ≤ ∫ x, W r x ∂(μ r)) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ r, 0 < r → r ≤ r0 → + IsProbabilityMeasure (weightedLaw (μ r) (W r)) ∧ + (weightedLaw (μ r) (W r) (badJetEvent (R r) r ε)).toReal ≤ C * r ^ 3 := by + refine ⟨(Real.sqrt cW / cZ) * Real.sqrt (M / ε ^ 8), by positivity, ?_⟩ + intro r hr hrr0 + obtain ⟨hW, hW0, hR, hRi, hMb, hsecond, hlower⟩ := hdata r hr hrr0 + exact p02_lm009_moment40_weighted_r3 (μ r) (W r) (R r) hW hW0 hR + r ε M cW cZ hr (hrr0.trans hr0.2) hε hM hcW hcZ hRi hMb hsecond hlower + +end ResearchFormalCoreR1 diff --git a/formal/SCOPE.md b/formal/SCOPE.md index 7fc346b8d..a892d5609 100644 --- a/formal/SCOPE.md +++ b/formal/SCOPE.md @@ -39,7 +39,7 @@ manifest and scope require a fresh separately authenticated alignment review. ## Additive weighted probability law (nine further declarations) -The total inventory is now 29 theorem targets. [WEIGHTED_LAW.md](WEIGHTED_LAW.md) +This retained layer has 29 theorem targets. [WEIGHTED_LAW.md](WEIGHTED_LAW.md) is the hash-bound exact scope for the new `WeightedLaw.lean` module. It consumes all earlier formal source unchanged and supplies the abstract PT1 construction excluded by MeasureBridge: an integrable a.e.-nonnegative weight with positive @@ -55,6 +55,20 @@ construction alone is added here. The executable gate and five negative controls are unchanged, and all nine new targets enter its transitive axiom inventory. No existing review is silently rebound to the changed manifest or scope. +## Additive moment-to-tail composition (seven further declarations) + +The current total is 36 theorem targets. [MOMENT_TAIL.md](MOMENT_TAIL.md) is the +hash-bound scope for `MomentTail.lean`: actual finite-measure Markov inequality, +strict-event measurability/threshold inclusion, the fortieth-moment-to-eighth-order +event tail, fourth-order and cubic weighted probability bounds, and an explicit +uniform-family assembly. The event is exactly {epsilon < r R^5}, not the entire +research good-event complement. Its moment bound, the weight's second moment, +positive lower normalizer and uniform-family premises remain assumptions. +No concrete Gaussian jet/Palm construction, derivative-supremum bound, P0.2 or +parent theorem is established. All earlier29 proof bytes, the executable gate +and its five rejection controls are unchanged. Existing package-level alignment +records do not automatically cover these new targets or changed scope. + ## 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/evidence/moment-tail-initial-build-failure.log b/formal/evidence/moment-tail-initial-build-failure.log new file mode 100644 index 000000000..3d87b46c0 --- /dev/null +++ b/formal/evidence/moment-tail-initial-build-failure.log @@ -0,0 +1,33 @@ +⚠ [8924/8930] Built ResearchFormalCoreR1.ProbabilityCompanionsV2 (4.8s) +warning: ResearchFormalCoreR1/ProbabilityCompanionsV2.lean:22:18: Variable name `hcW` is not explicitly referenced. + +Hint: The binding can be removed (if unused) or named `_` (if used implicitly). Alternatively, prefix the name with `_` to silence this warning: + [apply] _hcW + +Note: This linter can be disabled with `set_option linter.unusedVariables false` +warning: ResearchFormalCoreR1/ProbabilityCompanionsV2.lean:22:48: Variable name `hq` is not explicitly referenced. + +Hint: The binding can be removed (if unused) or named `_` (if used implicitly). Alternatively, prefix the name with `_` to silence this warning: + [apply] _hq + +Note: This linter can be disabled with `set_option linter.unusedVariables false` +✔ [8925/8930] Built ResearchFormalCoreR1.AlgebraV2 (5.0s) +✔ [8926/8930] Built ResearchFormalCoreR1.MeasureBridge (4.1s) +✔ [8927/8930] Built ResearchFormalCoreR1.WeightedLaw (3.0s) +✖ [8928/8930] Building ResearchFormalCoreR1.MomentTail (3.9s) +trace: .> LEAN_PATH=/home/runner/work/Math-/Math-/formal/.lake/packages/Cli/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/batteries/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/Qq/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/aesop/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/proofwidgets/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/importGraph/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/plausible/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/packages/mathlib/.lake/build/lib/lean:/home/runner/work/Math-/Math-/formal/.lake/build/lib/lean /home/runner/.elan/toolchains/leanprover--lean4---v4.34.1/bin/lean /home/runner/work/Math-/Math-/formal/ResearchFormalCoreR1/MomentTail.lean -o /home/runner/work/Math-/Math-/formal/.lake/build/lib/lean/ResearchFormalCoreR1/MomentTail.olean -i /home/runner/work/Math-/Math-/formal/.lake/build/lib/lean/ResearchFormalCoreR1/MomentTail.ilean -c /home/runner/work/Math-/Math-/formal/.lake/build/ir/ResearchFormalCoreR1/MomentTail.c --setup /home/runner/work/Math-/Math-/formal/.lake/build/ir/ResearchFormalCoreR1/MomentTail.setup.json --json +error: ResearchFormalCoreR1/MomentTail.lean:56:2: Type mismatch: After simplification, term + hp + has type + (ε / r) ^ 8 ≤ R x ^ 40 +but is expected to have type + x ∈ {x | (ε / r) ^ 8 ≤ R x ^ 40} +warning: ResearchFormalCoreR1/MomentTail.lean:77:48: this tactic is never executed + +Note: This linter can be disabled with `set_option linter.unreachableTactic false` +warning: ResearchFormalCoreR1/MomentTail.lean:77:48: Unused tactic linter: `ring` does nothing + +Note: This linter can be disabled with `set_option linter.unusedTactic false` +Some required targets logged failures: +- ResearchFormalCoreR1.MomentTail +error: build failed diff --git a/formal/manifest.json b/formal/manifest.json index cf8894a2d..025074f1e 100644 --- a/formal/manifest.json +++ b/formal/manifest.json @@ -23,7 +23,8 @@ "ResearchFormalCoreR1/AlgebraV2.lean", "ResearchFormalCoreR1/ProbabilityCompanionsV2.lean", "ResearchFormalCoreR1/MeasureBridge.lean", - "ResearchFormalCoreR1/WeightedLaw.lean" + "ResearchFormalCoreR1/WeightedLaw.lean", + "ResearchFormalCoreR1/MomentTail.lean" ], "targets": [ "ResearchFormalCoreR1.ec005_fold_gap", @@ -54,17 +55,24 @@ "ResearchFormalCoreR1.weightedLaw_zero", "ResearchFormalCoreR1.weightedLaw_one", "ResearchFormalCoreR1.p02_lm008_probability_transfer", - "ResearchFormalCoreR1.p02_lm009_probability_transfer_r8_to_r3" + "ResearchFormalCoreR1.p02_lm009_probability_transfer_r8_to_r3", + "ResearchFormalCoreR1.p02_lm009_markov_event", + "ResearchFormalCoreR1.p02_lm009_badJet_measurable", + "ResearchFormalCoreR1.p02_lm009_badJet_subset", + "ResearchFormalCoreR1.p02_lm009_moment40_tail", + "ResearchFormalCoreR1.p02_lm009_moment40_weighted_r4", + "ResearchFormalCoreR1.p02_lm009_moment40_weighted_r3", + "ResearchFormalCoreR1.p02_lm009_moment40_family_r3" ], "files": { ".gitignore": "b34af236d1df9e39ed4f98fca51702530ce76bdee4e1a69512f6caed933c3374", "COMPATIBILITY.md": "33721aad32f82131a6956a06b58c5bc41f5d28f26efe840a99a4d51ad60cf247", "GLOSSARY.md": "6bdda2ce054915efc26e8db462dbe8fd9d0c1db30e02328857bebc6568e05ce9", - "README.md": "638d8d9e8354462f5e309d6b249def1f0ed0b38ca83a36521106ab5c69bfca81", + "README.md": "dec5318053317dde0f0b1158d1359804a64d23b72199a4fc0e8dd89d33fb1d02", "ResearchFormalCoreR1/AlgebraV2.lean": "4480708263c40a2f7f03f12ef7e15f0eb4f8193c2dccbb253921a7ec251863c3", "ResearchFormalCoreR1/ProbabilityCompanionsV2.lean": "338452a0c2ba24d016059354d543cc995b8cb29c9d4a41d98bb93499f5f8cb8f", - "ResearchFormalCoreR1.lean": "b6077abc3522043216eface2da88a1d0f7a2c54a7519229b6f5d1ceb67bbb4a9", - "SCOPE.md": "e8ef291bb7daa334812451a675788b4ee902c0974d9bcd3197407b6b56b63548", + "ResearchFormalCoreR1.lean": "ffe0de34c8d3830357d6952d150a21ff12cef27e750cde8950362b92b4f285fb", + "SCOPE.md": "21c4ce34ff1e7536c88de86661c796a0751ad8572b034650631052ad0791f4a1", "blueprint/src/content.tex": "e00ee78344ed27c097bccb8c6360f6bb86a223ab06319a407de2dd0104fd2e28", "evidence/initial-build-failure.log": "43393d2e2b3148a2453e3092a1ff04e257dbd4a6dc97eb2853a8bc0451002591", "gate.py": "4f14a78bbc6e9b7f929648b13ad3a9ae467256db4be9792e3667680e697a5c94", @@ -79,6 +87,10 @@ "tests/test_measure_bridge.py": "0e54b2ed7c2e197967180993b4c0c1ece1e63576ad34fd74ac232a4d507628a2", "ResearchFormalCoreR1/WeightedLaw.lean": "f31dfd2cd048cc0c0446c54c46d89c9cdd5d7bb9d76e9d8d16b7c034f351d736", "WEIGHTED_LAW.md": "a530dc957923c4c9111b734d8fcc0f4cd3cdba45b08480cfc2e241ecefc5fba4", - "tests/test_weighted_law.py": "3367e505664cbcd1626b175f1c211d74241803113dbca909e2e71fae38776785" + "tests/test_weighted_law.py": "a65005e48c356175592cdc24c02270825dcf11d80975134c072775c693667607", + "ResearchFormalCoreR1/MomentTail.lean": "87fe3ee90afc52d8c2652881f1ae195d1b0b15a2ffc18c84d6166d1a4d0de2aa", + "MOMENT_TAIL.md": "20ecddcd830c41935dc4b366882db4d0432240932af6632d025b981f90e044bd", + "tests/test_moment_tail.py": "a75c575bc0e1853f3a597c338085932aefe05b52e8ea3bcf3277f5cc3753ec81", + "evidence/moment-tail-initial-build-failure.log": "61bee2d55d0dd548b0bccc4d2e40970f654fca8ab1385af7f371592d45c0ab08" } } diff --git a/formal/tests/test_moment_tail.py b/formal/tests/test_moment_tail.py new file mode 100644 index 000000000..4234e2478 --- /dev/null +++ b/formal/tests/test_moment_tail.py @@ -0,0 +1,126 @@ +"""Exact finite-model falsification and source wiring; not a Lean kernel replay.""" +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/MomentTail.lean' +NAMES = [ + 'p02_lm009_markov_event', + 'p02_lm009_badJet_measurable', + 'p02_lm009_badJet_subset', + 'p02_lm009_moment40_tail', + 'p02_lm009_moment40_weighted_r4', + 'p02_lm009_moment40_weighted_r3', + 'p02_lm009_moment40_family_r3', +] + + +def statistics(p, values, weights, r, eps): + event = [eps < r*x**5 for x in values] + q = sum((a for a, yes in zip(p, event) if yes), F(0)) + moment = sum(a*x**40 for a, x in zip(p, values)) + z = sum(a*w for a, w in zip(p, weights)) + second = sum(a*w*w for a, w in zip(p, weights)) + n = sum((a*w for a, w, yes in zip(p, weights, event) if yes), F(0)) + return event, q, moment, z, second, n + + +class MomentTailSourceTests(unittest.TestCase): + def test_new_source_and_exact_declarations(self): + self.assertTrue((ROOT/MODULE).is_file(), 'moment-tail formalization absent') + source = (ROOT/MODULE).read_text() + self.assertEqual(re.findall(r'^theorem\s+([A-Za-z_][A-Za-z0-9_]*)', source, re.M), NAMES) + + def test_exact_inventory(self): + m = json.loads((ROOT/'manifest.json').read_text()) + self.assertEqual(m['targets'][29:], ['ResearchFormalCoreR1.'+n for n in NAMES]) + self.assertEqual(len(m['targets']), 36) + self.assertIn(MODULE, m['source_modules']) + + def test_source_scope_and_tests_bound(self): + m = json.loads((ROOT/'manifest.json').read_text()) + for name in (MODULE, 'MOMENT_TAIL.md', 'tests/test_moment_tail.py'): + self.assertIn(name, m['files']) + self.assertEqual(hashlib.sha256((ROOT/name).read_bytes()).hexdigest(), m['files'][name]) + + def test_root_import(self): + self.assertIn('import ResearchFormalCoreR1.MomentTail\n', + (ROOT/'ResearchFormalCoreR1.lean').read_text()) + + def test_retained_control_and_proof_pins(self): + m = json.loads((ROOT/'manifest.json').read_text()) + pins = { + 'ResearchFormalCoreR1/MeasureBridge.lean': '28ac130db490c3c3e2fbfabf3ac5be43c854ab1468bf573bf5a8c0dd2c50955f', + 'ResearchFormalCoreR1/WeightedLaw.lean': 'f31dfd2cd048cc0c0446c54c46d89c9cdd5d7bb9d76e9d8d16b7c034f351d736', + 'gate.py': '4f14a78bbc6e9b7f929648b13ad3a9ae467256db4be9792e3667680e697a5c94', + } + for name, digest in pins.items(): + self.assertEqual(m['files'][name], digest) + self.assertEqual(m['scientific_effect'], 'NONE') + self.assertEqual(m['alignment_status'], 'PENDING_INDEPENDENT_REVIEW') + + +class MomentTailFiniteModelTests(unittest.TestCase): + def test_markov_tail_and_threshold_inclusion(self): + p = (F(1,4), F(1,4), F(1,2)) + count = 0 + for values in itertools.product((F(-2), F(0), F(2)), repeat=3): + for r, eps in itertools.product((F(1), F(1,2), F(1,16)), (F(1), F(1,4), F(16))): + event, q, m, _, _, _ = statistics(p, values, (F(1),)*3, r, eps) + for value, inside in zip(values, event): + if inside: + self.assertLessEqual((eps/r)**8, value**40) + self.assertLessEqual(q, (m/eps**8)*r**8) + count += 1 + self.assertEqual(count, 243) + + def test_actual_weighted_probabilities_and_cubic_composition(self): + p = (F(1,4), F(1,4), F(1,2)) + choices = ((F(1),)*3, (F(0),F(4),F(0)), (F(1,2),F(2),F(0)), (F(2),F(0),F(3))) + count = 0 + for values in itertools.product((F(-2), F(0), F(2)), repeat=3): + for weights in choices: + for r, eps in itertools.product((F(1), F(1,2), F(1,16)), (F(1), F(1,4), F(16))): + _, q, m, z, second, n = statistics(p, values, weights, r, eps) + self.assertGreater(z, 0) + pw = n/z + coef_squared = second/z**2 * (m/eps**8) + self.assertLessEqual(pw**2, coef_squared*r**8) + self.assertLessEqual(pw**2, coef_squared*r**6) + count += 1 + self.assertEqual(count, 972) + + def test_epsilon_factor_cannot_be_omitted(self): + r, eps = F(1,2), F(1,4) + _, q, m, _, _, _ = statistics((F(1),), (F(1),), (F(1),), r, eps) + self.assertGreater(q, m*r**8) + self.assertLessEqual(q, m/eps**8*r**8) + + def test_twentieth_moment_cannot_replace_fortieth(self): + r, eps, value = F(1), F(16), F(2) + self.assertLess(eps, r*value**5) + self.assertGreater(F(1), value**20/eps**8*r**8) + self.assertLessEqual(F(1), value**40/eps**8*r**8) + + def test_wrong_r_sixteen_power_fails(self): + r, value = F(1,16), F(2) + self.assertLess(F(1), r*value**5) + self.assertGreater(F(1), value**40*r**16) + + def test_strict_boundary_and_signed_jet(self): + event, q, _, _, _, _ = statistics((F(1,2),F(1,2)), (F(1),F(-1)), (F(1),F(1)), F(1), F(1)) + self.assertEqual(event, [False,False]) + self.assertEqual(q, 0) + + def test_zero_moment_null_atom_and_dependent_weight(self): + _, q, m, z, _, n = statistics((F(0),F(1)), (F(100),F(0)), (F(100),F(1)), F(1), F(1)) + self.assertEqual((q,m,z,n), (0,0,1,0)) + + +if __name__ == '__main__': + unittest.main() diff --git a/formal/tests/test_weighted_law.py b/formal/tests/test_weighted_law.py index 1045f0af3..030951deb 100644 --- a/formal/tests/test_weighted_law.py +++ b/formal/tests/test_weighted_law.py @@ -40,8 +40,8 @@ def test_module_and_declarations(self): def test_exact_target_inventory(self): m = json.loads((ROOT/'manifest.json').read_text()) - self.assertEqual(m['targets'][20:], ['ResearchFormalCoreR1.'+n for n in NAMES]) - self.assertEqual(len(m['targets']), 29) + self.assertEqual(m['targets'][20:29], ['ResearchFormalCoreR1.'+n for n in NAMES]) + self.assertGreaterEqual(len(m['targets']), 29) def test_bound_source_scope_and_tests(self): m = json.loads((ROOT/'manifest.json').read_text())