@lapxo/obligations 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -3
- package/TARGET.bound +148 -42
- package/contracts/extension-lineage-participation.json +30 -0
- package/contracts/m0-binomial-bridge.json +6 -0
- package/contracts/m0-diagonal-conditional.json +15 -0
- package/contracts/m0-keff-interval.json +27 -0
- package/contracts/m0-moment-identification.json +42 -0
- package/contracts/m1-diagonal-regions.json +45 -0
- package/contracts/m1-generator-binomial.json +26 -0
- package/contracts/m1-offdiag-limit.json +42 -0
- package/contracts/m1-subcauses.json +66 -0
- package/contracts/model-collapse-1a.json +16 -0
- package/contracts/projection-chain.json +20 -0
- package/docs/contracts/experiment1a-public-attribution.md +1 -0
- package/docs/contracts/extension-lineage-participation.md +13 -0
- package/docs/contracts/installation-046-inputs.md +1 -0
- package/docs/contracts/m0-binomial-bridge.md +1 -0
- package/docs/contracts/m0-diagonal-lindeberg.md +1 -0
- package/docs/contracts/m0-diagonal-moments.md +1 -0
- package/docs/contracts/m0-diagonal-symmetric.md +1 -0
- package/docs/contracts/m0-diagonal-threshold.md +1 -0
- package/docs/contracts/m0-keff-floor-refutation.md +1 -0
- package/docs/contracts/m0-keff-interval.md +1 -0
- package/docs/contracts/m0-moment-identification.md +1 -0
- package/docs/contracts/m0-refuted-inverses.md +1 -0
- package/docs/contracts/m0-wf-floor-refutation.md +1 -0
- package/docs/contracts/m1-diagonal-regions.md +1 -0
- package/docs/contracts/m1-generator-binomial.md +1 -0
- package/docs/contracts/m1-offdiag-limit.md +1 -0
- package/docs/contracts/model-collapse-1a.md +11 -0
- package/docs/contracts/projection-chain.md +1 -0
- package/package.json +1 -1
- package/proofs/definitions-046/declaration.json +11 -0
- package/proofs/experiment1a-046/declaration.json +11 -0
- package/proofs/m0-046/BridgeNegatives.lean +23 -0
- package/proofs/m0-046/M0Bridge.lean +300 -0
- package/proofs/m0-046/Obligations045/ConsensusGrid.lean +72 -0
- package/proofs/m0-046/Obligations045/M0Coincidence.lean +39 -0
- package/proofs/m0-046/Obligations045/M0Diagonal.lean +18 -0
- package/proofs/m0-046/Obligations045/M0Limit.lean +134 -0
- package/proofs/m0-046/Obligations045/M0Offdiag.lean +171 -0
- package/proofs/m0-046/Obligations045.lean +5 -0
- package/proofs/m0-046/lake-manifest.json +116 -0
- package/proofs/m0-046/lakefile.toml +14 -0
- package/proofs/m0-046/lean-toolchain +1 -0
- package/proofs/m0-046-diagonal/BridgeNegatives.lean +23 -0
- package/proofs/m0-046-diagonal/M0Bridge.lean +300 -0
- package/proofs/m0-046-diagonal/M0Diagonal046.lean +235 -0
- package/proofs/m0-046-diagonal/M0Lindeberg046.lean +92 -0
- package/proofs/m0-046-diagonal/M0Moments046.lean +295 -0
- package/proofs/m0-046-diagonal/M0Threshold046.lean +278 -0
- package/proofs/m0-046-diagonal/Obligations045/ConsensusGrid.lean +72 -0
- package/proofs/m0-046-diagonal/Obligations045/M0Coincidence.lean +39 -0
- package/proofs/m0-046-diagonal/Obligations045/M0Diagonal.lean +18 -0
- package/proofs/m0-046-diagonal/Obligations045/M0Limit.lean +134 -0
- package/proofs/m0-046-diagonal/Obligations045/M0Offdiag.lean +171 -0
- package/proofs/m0-046-diagonal/Obligations045.lean +5 -0
- package/proofs/m0-046-diagonal/lake-manifest.json +116 -0
- package/proofs/m0-046-diagonal/lakefile.toml +26 -0
- package/proofs/m0-046-diagonal/lean-toolchain +1 -0
- package/proofs/m0-046-identification/M0Identification046.lean +209 -0
- package/proofs/m0-046-identification/Obligations045/M0Coincidence.lean +39 -0
- package/proofs/m0-046-identification/lake-manifest.json +116 -0
- package/proofs/m0-046-identification/lakefile.toml +12 -0
- package/proofs/m0-046-identification/lean-toolchain +1 -0
- package/proofs/m0-046-uncertainty/BridgeNegatives.lean +23 -0
- package/proofs/m0-046-uncertainty/M0BlockCoverage046.lean +163 -0
- package/proofs/m0-046-uncertainty/M0Bridge.lean +300 -0
- package/proofs/m0-046-uncertainty/M0Diagonal046.lean +235 -0
- package/proofs/m0-046-uncertainty/M0FiniteDiscord046.lean +207 -0
- package/proofs/m0-046-uncertainty/M0Interval046.lean +82 -0
- package/proofs/m0-046-uncertainty/M0Lindeberg046.lean +92 -0
- package/proofs/m0-046-uncertainty/M0Moments046.lean +295 -0
- package/proofs/m0-046-uncertainty/M0Threshold046.lean +278 -0
- package/proofs/m0-046-uncertainty/Obligations045/ConsensusGrid.lean +72 -0
- package/proofs/m0-046-uncertainty/Obligations045/M0Coincidence.lean +39 -0
- package/proofs/m0-046-uncertainty/Obligations045/M0Diagonal.lean +18 -0
- package/proofs/m0-046-uncertainty/Obligations045/M0Limit.lean +134 -0
- package/proofs/m0-046-uncertainty/Obligations045/M0Offdiag.lean +171 -0
- package/proofs/m0-046-uncertainty/Obligations045.lean +5 -0
- package/proofs/m0-046-uncertainty/lake-manifest.json +116 -0
- package/proofs/m0-046-uncertainty/lakefile.toml +35 -0
- package/proofs/m0-046-uncertainty/lean-toolchain +1 -0
- package/proofs/m1-046-bridge/M0Bridge.lean +300 -0
- package/proofs/m1-046-bridge/M1Bridge046.lean +359 -0
- package/proofs/m1-046-bridge/Obligations045/M0Limit.lean +134 -0
- package/proofs/m1-046-bridge/Obligations045/M0Offdiag.lean +171 -0
- package/proofs/m1-046-bridge/lake-manifest.json +116 -0
- package/proofs/m1-046-bridge/lakefile.toml +29 -0
- package/proofs/m1-046-bridge/lean-toolchain +1 -0
- package/proofs/m1-046-diagonal/M0Bridge.lean +300 -0
- package/proofs/m1-046-diagonal/M0Diagonal046.lean +235 -0
- package/proofs/m1-046-diagonal/M0Lindeberg046.lean +92 -0
- package/proofs/m1-046-diagonal/M0Moments046.lean +295 -0
- package/proofs/m1-046-diagonal/M0Threshold046.lean +278 -0
- package/proofs/m1-046-diagonal/M1Bridge046.lean +359 -0
- package/proofs/m1-046-diagonal/M1Diagonal046.lean +334 -0
- package/proofs/m1-046-diagonal/M1Offdiag046.lean +270 -0
- package/proofs/m1-046-diagonal/Obligations045/M0Limit.lean +134 -0
- package/proofs/m1-046-diagonal/Obligations045/M0Offdiag.lean +171 -0
- package/proofs/m1-046-diagonal/lake-manifest.json +116 -0
- package/proofs/m1-046-diagonal/lakefile.toml +35 -0
- package/proofs/m1-046-diagonal/lean-toolchain +1 -0
- package/proofs/m1-046-offdiag/M0Bridge.lean +300 -0
- package/proofs/m1-046-offdiag/M0Diagonal046.lean +235 -0
- package/proofs/m1-046-offdiag/M0Moments046.lean +295 -0
- package/proofs/m1-046-offdiag/M1Bridge046.lean +359 -0
- package/proofs/m1-046-offdiag/M1Offdiag046.lean +270 -0
- package/proofs/m1-046-offdiag/Obligations045/M0Limit.lean +134 -0
- package/proofs/m1-046-offdiag/Obligations045/M0Offdiag.lean +171 -0
- package/proofs/m1-046-offdiag/lake-manifest.json +116 -0
- package/proofs/m1-046-offdiag/lakefile.toml +32 -0
- package/proofs/m1-046-offdiag/lean-toolchain +1 -0
- package/proofs/projection-chain.md +11 -0
- package/protocols/model-collapse-1a.json +108 -0
- package/receipts.bound +578 -210
- package/samples/laws/definitions/no/sample.json +26 -0
- package/samples/laws/definitions/yes/sample.json +12 -0
- package/samples/laws/experiment1a/no/sample.json +16 -0
- package/samples/laws/experiment1a/yes/sample.json +8 -0
- package/samples/laws/m0-binomial-bridge/no/pairwise-is-not-joint.json +59 -0
- package/samples/laws/m0-binomial-bridge/no/sample.json +13 -0
- package/samples/laws/m0-binomial-bridge/yes/sample.json +16 -0
- package/samples/laws/m0-binomial-bridge/yes/small-binomial-table.json +100 -0
- package/samples/laws/m0-diagonal-conditional/no/sample.json +5 -0
- package/samples/laws/m0-diagonal-conditional/yes/sample.json +7 -0
- package/samples/laws/m0-keff-interval/no/sample.json +215 -0
- package/samples/laws/m0-keff-interval/yes/api-rows.json +2002 -0
- package/samples/laws/m0-keff-interval/yes/sample.json +70 -0
- package/samples/laws/m0-moment-identification/no/sample.json +47 -0
- package/samples/laws/m0-moment-identification/yes/sample.json +97 -0
- package/samples/laws/m1-diagonal-regions/no/sample.json +44 -0
- package/samples/laws/m1-diagonal-regions/yes/sample.json +45 -0
- package/samples/laws/m1-generator-binomial/no/sample.json +21 -0
- package/samples/laws/m1-generator-binomial/yes/sample.json +290 -0
- package/samples/laws/m1-offdiag-limit/no/sample.json +17 -0
- package/samples/laws/m1-offdiag-limit/yes/sample.json +87 -0
- package/samples/laws/projection-chain/no/sample.json +26 -0
- package/samples/laws/projection-chain/yes/sample.json +25 -0
- package/samples/no/installed-artifact.json +2 -2
- package/samples/yes/installed-artifact.json +2 -2
- package/src/laws/laws.bound +146 -0
- package/vectors/laws/a7-t90.json +72 -0
- package/vectors/laws/a9-t99.json +110 -0
- package/vectors/laws/definitions.native-capture.json +326 -0
- package/vectors/laws/definitions.native.json +82 -0
- package/vectors/laws/experiment1a-protocol.native-capture.json +391 -0
- package/vectors/laws/experiment1a-protocol.native.json +64 -0
- package/vectors/laws/experiment1a-public-input.native-capture.json +224 -0
- package/vectors/laws/m0-binomial-bridge.lean.json +185 -0
- package/vectors/laws/m0-diagonal-lindeberg.lean.json +167 -0
- package/vectors/laws/m0-diagonal-moments.lean.json +185 -0
- package/vectors/laws/m0-diagonal-symmetric.lean.json +188 -0
- package/vectors/laws/m0-diagonal-threshold.lean.json +199 -0
- package/vectors/laws/m0-identification.lean.json +136 -0
- package/vectors/laws/m0-identification.native-capture.json +230 -0
- package/vectors/laws/m0-keff-interval.json +569 -0
- package/vectors/laws/m0-uncertainty-blocks.lean.json +201 -0
- package/vectors/laws/m0-uncertainty-finite-discord.lean.json +194 -0
- package/vectors/laws/m0-uncertainty-interval.lean.json +189 -0
- package/vectors/laws/m0-uncertainty.native-capture.json +651 -0
- package/vectors/laws/m1-diagonal-partial.lean.json +192 -0
- package/vectors/laws/m1-diagonal-partial.native-capture.json +275 -0
- package/vectors/laws/m1-generator-binomial.lean.json +162 -0
- package/vectors/laws/m1-generator-binomial.native-capture.json +245 -0
- package/vectors/laws/m1-offdiag-limit.lean.json +166 -0
- package/vectors/laws/m1-offdiag-limit.native-capture.json +260 -0
- package/vectors/laws/model-collapse-1a.json +12 -0
- package/vectors/laws/projection-chain.json +61 -0
- package/vectors/laws/projection-chain.native-capture.json +311 -0
- package/vectors/laws/projection-chain.native.json +56 -0
- package/vectors/measures/installed-artifact.cli.json +6 -6
- package/CHANGELOG.md +0 -10
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import Obligations045.M0Limit
|
|
2
|
+
import Mathlib.Probability.StrongLaw
|
|
3
|
+
import Mathlib.MeasureTheory.Integral.DominatedConvergence
|
|
4
|
+
open scoped BigOperators
|
|
5
|
+
open Filter Topology MeasureTheory ProbabilityTheory
|
|
6
|
+
noncomputable section
|
|
7
|
+
namespace Obligations045.M0
|
|
8
|
+
|
|
9
|
+
theorem floor_quota_bounds (M : Domain) (N i : ℕ) :
|
|
10
|
+
(∑ j ∈ Finset.range M.K, allocation M.w N j = N) ∧
|
|
11
|
+
(-1 < (allocation M.w N i : ℝ)-(N:ℝ)*M.w i ∧
|
|
12
|
+
(allocation M.w N i : ℝ)-(N:ℝ)*M.w i < 1) :=
|
|
13
|
+
⟨allocation_sum M N, allocation_discrepancy M N i⟩
|
|
14
|
+
|
|
15
|
+
theorem allocation_ratio (M : Domain) (i : ℕ) :
|
|
16
|
+
Tendsto (fun N : ℕ => (allocation M.w N i : ℝ)/(N:ℝ)) atTop (𝓝 (M.w i)) := by
|
|
17
|
+
have hInv : Tendsto (fun N : ℕ => (1:ℝ)/(N:ℝ)) atTop (𝓝 0) :=
|
|
18
|
+
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
|
|
19
|
+
apply tendsto_of_tendsto_of_tendsto_of_le_of_le'
|
|
20
|
+
(by simpa using tendsto_const_nhds.sub hInv)
|
|
21
|
+
(by simpa using tendsto_const_nhds.add hInv)
|
|
22
|
+
· filter_upwards [eventually_ge_atTop 1] with N hN
|
|
23
|
+
have hp : 0 < (N:ℝ) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hN)
|
|
24
|
+
rw [le_div_iff₀ hp, sub_mul, inv_mul_cancel₀ hp.ne']
|
|
25
|
+
linarith [(allocation_discrepancy M N i).1]
|
|
26
|
+
· filter_upwards [eventually_ge_atTop 1] with N hN
|
|
27
|
+
have hp : 0 < (N:ℝ) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hN)
|
|
28
|
+
rw [div_le_iff₀ hp, add_mul, inv_mul_cancel₀ hp.ne']
|
|
29
|
+
linarith [(allocation_discrepancy M N i).2]
|
|
30
|
+
|
|
31
|
+
theorem allocation_zero (M : Domain) (i : ℕ) (hw : M.w i = 0) (N : ℕ) :
|
|
32
|
+
allocation M.w N i = 0 := by
|
|
33
|
+
simp [allocation, prefix_succ, hw]
|
|
34
|
+
|
|
35
|
+
theorem allocation_atTop (M : Domain) (i : ℕ) (hw : 0 < M.w i) :
|
|
36
|
+
Tendsto (fun N => allocation M.w N i) atTop atTop := by
|
|
37
|
+
apply (tendsto_natCast_atTop_iff (R := ℝ)).mp
|
|
38
|
+
apply tendsto_atTop.2
|
|
39
|
+
intro r
|
|
40
|
+
have he : ∀ᶠ N : ℕ in atTop, (r+1)/M.w i ≤ (N:ℝ) :=
|
|
41
|
+
tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop _)
|
|
42
|
+
filter_upwards [he] with N hN
|
|
43
|
+
have hmul := (div_le_iff₀ hw).mp hN
|
|
44
|
+
linarith [(allocation_discrepancy M N i).1]
|
|
45
|
+
|
|
46
|
+
theorem lineage_quota_limit (M : Domain) (i : ℕ) (z : ℕ → ℝ) (q : ℝ)
|
|
47
|
+
(hz0 : z 0 = 0)
|
|
48
|
+
(hz : Tendsto (fun n : ℕ => z n/(n:ℝ)) atTop (𝓝 q)) :
|
|
49
|
+
Tendsto (fun N : ℕ => z (allocation M.w N i)/(N:ℝ)) atTop (𝓝 (M.w i*q)) := by
|
|
50
|
+
by_cases hw : M.w i = 0
|
|
51
|
+
· simp [allocation_zero M i hw, hz0, hw]
|
|
52
|
+
· have hp : 0 < M.w i := lt_of_le_of_ne (M.w_nonneg i) (Ne.symm hw)
|
|
53
|
+
have h := (allocation_ratio M i).mul (hz.comp (allocation_atTop M i hp))
|
|
54
|
+
convert h using 1
|
|
55
|
+
funext N
|
|
56
|
+
by_cases hn : allocation M.w N i = 0
|
|
57
|
+
· simp [hn, hz0]
|
|
58
|
+
· dsimp
|
|
59
|
+
rw [div_mul_div_comm, mul_comm (allocation M.w N i : ℝ), mul_div_mul_right _ _ (by exact_mod_cast hn : (allocation M.w N i : ℝ) ≠ 0)]
|
|
60
|
+
|
|
61
|
+
/-- The imported strong law is applied to actual lineage variables; no convergence certificate. -/
|
|
62
|
+
theorem lineage_lgn {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω)
|
|
63
|
+
(X : ℕ → Ω → ℝ) (q : ℝ)
|
|
64
|
+
(hint : Integrable (X 0) μ)
|
|
65
|
+
(hindep : Pairwise (fun i j : ℕ => IndepFun (X i) (X j) μ))
|
|
66
|
+
(hident : ∀ i, IdentDistrib (X i) (X 0) μ μ)
|
|
67
|
+
(hmean : ∫ ω, X 0 ω ∂μ = q) :
|
|
68
|
+
∀ᵐ ω ∂μ, Tendsto (fun n : ℕ => (∑ j ∈ Finset.range n, X j ω)/(n:ℝ))
|
|
69
|
+
atTop (𝓝 q) := by
|
|
70
|
+
simpa only [hmean] using strong_law_ae_real X hint hindep hident
|
|
71
|
+
|
|
72
|
+
def memberAverage {Ω : Type*} (M : Domain) (X : Fin M.K → ℕ → Ω → ℝ)
|
|
73
|
+
(N : ℕ) (ω : Ω) : ℝ :=
|
|
74
|
+
∑ i : Fin M.K, (∑ j ∈ Finset.range (allocation M.w N i), X i j ω)/(N:ℝ)
|
|
75
|
+
|
|
76
|
+
theorem member_average_lgn {Ω : Type*} [MeasurableSpace Ω]
|
|
77
|
+
(M : Domain) (a : Fin M.K → Bool) (μ : Measure Ω)
|
|
78
|
+
(X : Fin M.K → ℕ → Ω → ℝ)
|
|
79
|
+
(hint : ∀ i, Integrable (X i 0) μ)
|
|
80
|
+
(hindep : ∀ i, Pairwise (fun j k : ℕ => IndepFun (X i j) (X i k) μ))
|
|
81
|
+
(hident : ∀ i j, IdentDistrib (X i j) (X i 0) μ μ)
|
|
82
|
+
(hmean : ∀ i, ∫ ω, X i 0 ω ∂μ = q M (a i)) :
|
|
83
|
+
∀ᵐ ω ∂μ, Tendsto (fun N => memberAverage M X N ω) atTop (𝓝 (score M a)) := by
|
|
84
|
+
have hall : ∀ᵐ ω ∂μ, ∀ i : Fin M.K,
|
|
85
|
+
Tendsto (fun n : ℕ => (∑ j ∈ Finset.range n, X i j ω)/(n:ℝ))
|
|
86
|
+
atTop (𝓝 (q M (a i))) := by
|
|
87
|
+
rw [ae_all_iff]
|
|
88
|
+
intro i
|
|
89
|
+
exact lineage_lgn μ (X i) (q M (a i)) (hint i) (hindep i) (hident i) (hmean i)
|
|
90
|
+
filter_upwards [hall] with ω hω
|
|
91
|
+
unfold memberAverage score
|
|
92
|
+
apply tendsto_finset_sum
|
|
93
|
+
intro i _
|
|
94
|
+
exact lineage_quota_limit M i (fun n => ∑ j ∈ Finset.range n, X i j ω)
|
|
95
|
+
(q M (a i)) (by simp) (hω i)
|
|
96
|
+
|
|
97
|
+
theorem floor_limit_offdiag_scalar {f : ℕ → ℝ} {s : ℝ}
|
|
98
|
+
(hf : Tendsto f atTop (𝓝 s)) (hne : s ≠ (1:ℝ)/2) :
|
|
99
|
+
Tendsto (fun N => limitingLoss (f N)) atTop (𝓝 (limitingLoss s)) := by
|
|
100
|
+
by_cases hs : s < (1:ℝ)/2
|
|
101
|
+
· have he : ∀ᶠ N in atTop, f N < (1:ℝ)/2 := hf.eventually (Iio_mem_nhds hs)
|
|
102
|
+
have hEq : (fun N => limitingLoss (f N)) =ᶠ[atTop] (fun _ => (1:ℝ)) :=
|
|
103
|
+
he.mono (fun N hN => by change limitingLoss (f N) = 1; rw [limitingLoss, if_pos hN])
|
|
104
|
+
rw [limitingLoss, if_pos hs]
|
|
105
|
+
exact tendsto_const_nhds.congr' hEq.symm
|
|
106
|
+
· have hg : (1:ℝ)/2 < s := lt_of_le_of_ne (le_of_not_gt hs) (Ne.symm hne)
|
|
107
|
+
have he : ∀ᶠ N in atTop, (1:ℝ)/2 < f N := hf.eventually (Ioi_mem_nhds hg)
|
|
108
|
+
have hEq : (fun N => limitingLoss (f N)) =ᶠ[atTop] (fun _ => (0:ℝ)) :=
|
|
109
|
+
he.mono (fun N hN => by
|
|
110
|
+
change limitingLoss (f N) = 0
|
|
111
|
+
rw [limitingLoss, if_neg (not_lt.mpr hN.le), if_neg (Ne.symm hN.ne)])
|
|
112
|
+
rw [limitingLoss, if_neg hs, if_neg hne]
|
|
113
|
+
exact tendsto_const_nhds.congr' hEq.symm
|
|
114
|
+
|
|
115
|
+
/-- Off-diagonal passage from actual sample averages to error probabilities.
|
|
116
|
+
Unlike the diagonal, no CLT is needed. The lineage strong laws and quota
|
|
117
|
+
composition must supply haverage for the chosen M0 array. -/
|
|
118
|
+
theorem floor_limit_offdiag {Ω : Type*} [MeasurableSpace Ω]
|
|
119
|
+
(μ : Measure Ω) [IsProbabilityMeasure μ]
|
|
120
|
+
(average : ℕ → Ω → ℝ) (s : ℝ)
|
|
121
|
+
(hmeas : ∀ N, AEStronglyMeasurable (fun ω => limitingLoss (average N ω)) μ)
|
|
122
|
+
(haverage : ∀ᵐ ω ∂μ, Tendsto (fun N => average N ω) atTop (𝓝 s))
|
|
123
|
+
(hne : s ≠ (1:ℝ)/2) :
|
|
124
|
+
Tendsto (fun N => ∫ ω, limitingLoss (average N ω) ∂μ)
|
|
125
|
+
atTop (𝓝 (limitingLoss s)) := by
|
|
126
|
+
have hbound : ∀ N, ∀ᵐ ω ∂μ, ‖limitingLoss (average N ω)‖ ≤ (1:ℝ) := by
|
|
127
|
+
intro N
|
|
128
|
+
filter_upwards [] with ω
|
|
129
|
+
unfold limitingLoss
|
|
130
|
+
split_ifs <;> norm_num
|
|
131
|
+
have hlim : ∀ᵐ ω ∂μ, Tendsto (fun N => limitingLoss (average N ω))
|
|
132
|
+
atTop (𝓝 (limitingLoss s)) := haverage.mono (fun ω hω => floor_limit_offdiag_scalar hω hne)
|
|
133
|
+
simpa using tendsto_integral_of_dominated_convergence (fun _ => (1:ℝ)) hmeas
|
|
134
|
+
(integrable_const (1:ℝ)) hbound hlim
|
|
135
|
+
|
|
136
|
+
/-- M0 off-diagonal probability limit from declared lineage laws and the proved quotas.
|
|
137
|
+
The only extra technical input is measurability of the loss; no asymptotic
|
|
138
|
+
convergence hypothesis and no CLT certificate is assumed. -/
|
|
139
|
+
theorem floor_limit_offdiag_M0 {Ω : Type*} [MeasurableSpace Ω]
|
|
140
|
+
(M : Domain) (a : Fin M.K → Bool) (μ : Measure Ω) [IsProbabilityMeasure μ]
|
|
141
|
+
(X : Fin M.K → ℕ → Ω → ℝ)
|
|
142
|
+
(hint : ∀ i, Integrable (X i 0) μ)
|
|
143
|
+
(hindep : ∀ i, Pairwise (fun j k : ℕ => IndepFun (X i j) (X i k) μ))
|
|
144
|
+
(hident : ∀ i j, IdentDistrib (X i j) (X i 0) μ μ)
|
|
145
|
+
(hmean : ∀ i, ∫ ω, X i 0 ω ∂μ = q M (a i))
|
|
146
|
+
(hmeas : ∀ N, AEStronglyMeasurable (fun ω => limitingLoss (memberAverage M X N ω)) μ)
|
|
147
|
+
(hoff : score M a ≠ (1:ℝ)/2) :
|
|
148
|
+
Tendsto (fun N => ∫ ω, limitingLoss (memberAverage M X N ω) ∂μ)
|
|
149
|
+
atTop (𝓝 (limitingLoss (score M a))) := by
|
|
150
|
+
exact floor_limit_offdiag μ (memberAverage M X) (score M a) hmeas
|
|
151
|
+
(member_average_lgn M a μ X hint hindep hident hmean) hoff
|
|
152
|
+
|
|
153
|
+
theorem floor_limit_offdiag_mixture {Ω : Type*} [MeasurableSpace Ω]
|
|
154
|
+
(M : Domain) (μ : Measure Ω) [IsProbabilityMeasure μ]
|
|
155
|
+
(X : (Fin M.K → Bool) → Fin M.K → ℕ → Ω → ℝ)
|
|
156
|
+
(hint : ∀ a i, Integrable (X a i 0) μ)
|
|
157
|
+
(hindep : ∀ a i, Pairwise (fun j k : ℕ => IndepFun (X a i j) (X a i k) μ))
|
|
158
|
+
(hident : ∀ a i j, IdentDistrib (X a i j) (X a i 0) μ μ)
|
|
159
|
+
(hmean : ∀ a i, ∫ ω, X a i 0 ω ∂μ = q M (a i))
|
|
160
|
+
(hmeas : ∀ a N, AEStronglyMeasurable (fun ω => limitingLoss (memberAverage M (X a) N ω)) μ)
|
|
161
|
+
(hoff : ∀ a, score M a ≠ (1:ℝ)/2) :
|
|
162
|
+
Tendsto (fun N => ∑ a : Fin M.K → Bool, latentMass M a *
|
|
163
|
+
∫ ω, limitingLoss (memberAverage M (X a) N ω) ∂μ)
|
|
164
|
+
atTop (𝓝 (floor M)) := by
|
|
165
|
+
unfold floor
|
|
166
|
+
apply tendsto_finset_sum
|
|
167
|
+
intro a _
|
|
168
|
+
exact tendsto_const_nhds.mul (floor_limit_offdiag_M0 M a μ (X a)
|
|
169
|
+
(hint a) (hindep a) (hident a) (hmean a) (hmeas a) (hoff a))
|
|
170
|
+
|
|
171
|
+
end Obligations045.M0
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.1.0",
|
|
3
|
+
"packagesDir": ".lake/packages",
|
|
4
|
+
"packages": [
|
|
5
|
+
{
|
|
6
|
+
"url": "https://github.com/leanprover-community/plausible",
|
|
7
|
+
"type": "git",
|
|
8
|
+
"subDir": null,
|
|
9
|
+
"scope": "leanprover-community",
|
|
10
|
+
"rev": "77e08eddc486491d7b9e470926b3dbe50319451a",
|
|
11
|
+
"name": "plausible",
|
|
12
|
+
"manifestFile": "lake-manifest.json",
|
|
13
|
+
"inputRev": "main",
|
|
14
|
+
"inherited": true,
|
|
15
|
+
"configFile": "lakefile.toml"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"url": "https://github.com/leanprover-community/LeanSearchClient",
|
|
19
|
+
"type": "git",
|
|
20
|
+
"subDir": null,
|
|
21
|
+
"scope": "leanprover-community",
|
|
22
|
+
"rev": "25078369972d295301f5a1e53c3e5850cf6d9d4c",
|
|
23
|
+
"name": "LeanSearchClient",
|
|
24
|
+
"manifestFile": "lake-manifest.json",
|
|
25
|
+
"inputRev": "main",
|
|
26
|
+
"inherited": true,
|
|
27
|
+
"configFile": "lakefile.toml"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"url": "https://github.com/leanprover-community/import-graph",
|
|
31
|
+
"type": "git",
|
|
32
|
+
"subDir": null,
|
|
33
|
+
"scope": "leanprover-community",
|
|
34
|
+
"rev": "e6a9f0f5ee3ccf7443a0070f92b62f8db12ae82b",
|
|
35
|
+
"name": "importGraph",
|
|
36
|
+
"manifestFile": "lake-manifest.json",
|
|
37
|
+
"inputRev": "main",
|
|
38
|
+
"inherited": true,
|
|
39
|
+
"configFile": "lakefile.toml"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"url": "https://github.com/leanprover-community/ProofWidgets4",
|
|
43
|
+
"type": "git",
|
|
44
|
+
"subDir": null,
|
|
45
|
+
"scope": "leanprover-community",
|
|
46
|
+
"rev": "c4919189477c3221e6a204008998b0d724f49904",
|
|
47
|
+
"name": "proofwidgets",
|
|
48
|
+
"manifestFile": "lake-manifest.json",
|
|
49
|
+
"inputRev": "v0.0.57",
|
|
50
|
+
"inherited": true,
|
|
51
|
+
"configFile": "lakefile.lean"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"url": "https://github.com/leanprover-community/aesop",
|
|
55
|
+
"type": "git",
|
|
56
|
+
"subDir": null,
|
|
57
|
+
"scope": "leanprover-community",
|
|
58
|
+
"rev": "5d50b08dedd7d69b3d9b3176e0d58a23af228884",
|
|
59
|
+
"name": "aesop",
|
|
60
|
+
"manifestFile": "lake-manifest.json",
|
|
61
|
+
"inputRev": "master",
|
|
62
|
+
"inherited": true,
|
|
63
|
+
"configFile": "lakefile.toml"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"url": "https://github.com/leanprover-community/quote4",
|
|
67
|
+
"type": "git",
|
|
68
|
+
"subDir": null,
|
|
69
|
+
"scope": "leanprover-community",
|
|
70
|
+
"rev": "fa4f7f15d97591a9cf3aa7724ba371c7fc6dda02",
|
|
71
|
+
"name": "Qq",
|
|
72
|
+
"manifestFile": "lake-manifest.json",
|
|
73
|
+
"inputRev": "master",
|
|
74
|
+
"inherited": true,
|
|
75
|
+
"configFile": "lakefile.toml"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"url": "https://github.com/leanprover-community/batteries",
|
|
79
|
+
"type": "git",
|
|
80
|
+
"subDir": null,
|
|
81
|
+
"scope": "leanprover-community",
|
|
82
|
+
"rev": "f5d04a9c4973d401c8c92500711518f7c656f034",
|
|
83
|
+
"name": "batteries",
|
|
84
|
+
"manifestFile": "lake-manifest.json",
|
|
85
|
+
"inputRev": "main",
|
|
86
|
+
"inherited": true,
|
|
87
|
+
"configFile": "lakefile.toml"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"url": "https://github.com/leanprover/lean4-cli",
|
|
91
|
+
"type": "git",
|
|
92
|
+
"subDir": null,
|
|
93
|
+
"scope": "leanprover",
|
|
94
|
+
"rev": "02dbd02bc00ec4916e99b04b2245b30200e200d0",
|
|
95
|
+
"name": "Cli",
|
|
96
|
+
"manifestFile": "lake-manifest.json",
|
|
97
|
+
"inputRev": "main",
|
|
98
|
+
"inherited": true,
|
|
99
|
+
"configFile": "lakefile.toml"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"url": "https://github.com/leanprover-community/mathlib4.git",
|
|
103
|
+
"type": "git",
|
|
104
|
+
"subDir": null,
|
|
105
|
+
"scope": "",
|
|
106
|
+
"rev": "c44e0c8ee63ca166450922a373c7409c5d26b00b",
|
|
107
|
+
"name": "mathlib",
|
|
108
|
+
"manifestFile": "lake-manifest.json",
|
|
109
|
+
"inputRev": "c44e0c8ee63ca166450922a373c7409c5d26b00b",
|
|
110
|
+
"inherited": false,
|
|
111
|
+
"configFile": "lakefile.lean"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"name": "obligations_lineage",
|
|
115
|
+
"lakeDir": ".lake"
|
|
116
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
name = "obligations_lineage"
|
|
2
|
+
version = "0.0.0"
|
|
3
|
+
defaultTargets = ["Obligations045"]
|
|
4
|
+
[[require]]
|
|
5
|
+
name = "mathlib"
|
|
6
|
+
git = "https://github.com/leanprover-community/mathlib4.git"
|
|
7
|
+
rev = "c44e0c8ee63ca166450922a373c7409c5d26b00b"
|
|
8
|
+
[[lean_lib]]
|
|
9
|
+
name = "Obligations045"
|
|
10
|
+
|
|
11
|
+
[[lean_lib]]
|
|
12
|
+
name = "M0Bridge"
|
|
13
|
+
[[lean_lib]]
|
|
14
|
+
name = "BridgeNegatives"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
leanprover/lean4:v4.19.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import M0Bridge
|
|
2
|
+
namespace Obligations046.BridgeTests
|
|
3
|
+
|
|
4
|
+
def atoms : List (ℚ × ℚ × ℚ × ℚ) :=
|
|
5
|
+
[(0,0,0,1/16),(0,1,1,3/16),(1,0,1,3/16),(1,1,0,3/16),(1,1,1,6/16)]
|
|
6
|
+
def expect (f : ℚ → ℚ → ℚ → ℚ) : ℚ :=
|
|
7
|
+
(atoms.map (fun (a,b,c,w) => w*f a b c)).sum
|
|
8
|
+
|
|
9
|
+
/-- A normalized binary distribution with Bernoulli(3/4) pairwise marginals,
|
|
10
|
+
but not the jointly independent word law. Exact arithmetic, not simulation. -/
|
|
11
|
+
theorem pairwise_not_joint :
|
|
12
|
+
expect (fun _ _ _ => 1) = 1 ∧
|
|
13
|
+
expect (fun a _ _ => a) = 3/4 ∧
|
|
14
|
+
expect (fun _ b _ => b) = 3/4 ∧
|
|
15
|
+
expect (fun _ _ c => c) = 3/4 ∧
|
|
16
|
+
expect (fun a b _ => a*b) = 9/16 ∧
|
|
17
|
+
expect (fun a _ c => a*c) = 9/16 ∧
|
|
18
|
+
expect (fun _ b c => b*c) = 9/16 ∧
|
|
19
|
+
expect (fun a b c => (1-a)*(1-b)*(1-c)) = 1/16 ∧
|
|
20
|
+
expect (fun a b c => (1-a)*(1-b)*(1-c)) ≠ (1/4:ℚ)^3 := by
|
|
21
|
+
norm_num [expect, atoms]
|
|
22
|
+
|
|
23
|
+
end Obligations046.BridgeTests
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import Obligations045.M0Offdiag
|
|
2
|
+
import Mathlib.Data.Nat.Choose.Sum
|
|
3
|
+
import Mathlib.Probability.ProbabilityMassFunction.Integrals
|
|
4
|
+
import Mathlib.Algebra.BigOperators.Group.Finset.Pi
|
|
5
|
+
|
|
6
|
+
open scoped BigOperators
|
|
7
|
+
open MeasureTheory ProbabilityTheory Filter Topology
|
|
8
|
+
noncomputable section
|
|
9
|
+
open Classical
|
|
10
|
+
namespace Obligations046.Bridge
|
|
11
|
+
|
|
12
|
+
def count {n : ℕ} (s : Finset (Fin n)) : Fin (n+1) :=
|
|
13
|
+
⟨s.card, Nat.lt_succ_of_le (by simpa using s.card_le_univ)⟩
|
|
14
|
+
def mass (p : ℝ) {n : ℕ} (s : Finset (Fin n)) : ℝ :=
|
|
15
|
+
p^s.card*(1-p)^(n-s.card)
|
|
16
|
+
def binMass (p : ℝ) (n : ℕ) (k : Fin (n+1)) : ℝ :=
|
|
17
|
+
(n.choose k : ℝ)*p^(k:ℕ)*(1-p)^(n-(k:ℕ))
|
|
18
|
+
|
|
19
|
+
theorem count_fiber_mass (p : ℝ) (n : ℕ) (k : Fin (n+1)) :
|
|
20
|
+
(∑ s : Finset (Fin n), if count s = k then mass p s else 0) = binMass p n k := by
|
|
21
|
+
have hfilter : Finset.univ.filter (fun s : Finset (Fin n) => count s = k) =
|
|
22
|
+
Finset.powersetCard (k:ℕ) (Finset.univ : Finset (Fin n)) := by
|
|
23
|
+
ext s
|
|
24
|
+
simp [count, Fin.ext_iff, Finset.mem_powersetCard]
|
|
25
|
+
rw [← Finset.sum_filter, hfilter]
|
|
26
|
+
calc
|
|
27
|
+
_ = ∑ _s ∈ Finset.powersetCard (k:ℕ) (Finset.univ : Finset (Fin n)),
|
|
28
|
+
p^(k:ℕ)*(1-p)^(n-(k:ℕ)) := by
|
|
29
|
+
apply Finset.sum_congr rfl
|
|
30
|
+
intro s hs
|
|
31
|
+
simp only [Finset.mem_powersetCard] at hs
|
|
32
|
+
simp [mass, hs.2]
|
|
33
|
+
_ = binMass p n k := by
|
|
34
|
+
simp [binMass, Finset.card_powersetCard, nsmul_eq_mul, mul_assoc]
|
|
35
|
+
|
|
36
|
+
/-- Finite product-law pushforward, before any choice of Bernoulli parameters. -/
|
|
37
|
+
theorem product_pushforward {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
38
|
+
{S T : ι → Type*} [∀ i, Fintype (S i)] [∀ i, Fintype (T i)]
|
|
39
|
+
[∀ i, DecidableEq (T i)] (m : ∀ i, S i → ℝ) (c : ∀ i, S i → T i)
|
|
40
|
+
(f : (∀ i, T i) → ℝ) :
|
|
41
|
+
(∑ x : ∀ i, S i, (∏ i, m i (x i))*f (fun i => c i (x i))) =
|
|
42
|
+
∑ k : ∀ i, T i, (∏ i, ∑ s : S i, if c i s = k i then m i s else 0)*f k := by
|
|
43
|
+
have gate (x : ∀ i, S i) (k : ∀ i, T i) :
|
|
44
|
+
(∏ i, if c i (x i) = k i then m i (x i) else 0) =
|
|
45
|
+
if (fun i => c i (x i)) = k then ∏ i, m i (x i) else 0 := by
|
|
46
|
+
by_cases h : (fun i => c i (x i)) = k
|
|
47
|
+
· subst k
|
|
48
|
+
simp
|
|
49
|
+
· rw [if_neg h]
|
|
50
|
+
have h' : ∃ i, c i (x i) ≠ k i := by
|
|
51
|
+
by_contra hn
|
|
52
|
+
push_neg at hn
|
|
53
|
+
exact h (funext hn)
|
|
54
|
+
obtain ⟨i, hi⟩ := h'
|
|
55
|
+
exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [hi])
|
|
56
|
+
symm
|
|
57
|
+
simp_rw [Fintype.prod_sum, Finset.sum_mul]
|
|
58
|
+
rw [Finset.sum_comm]
|
|
59
|
+
apply Finset.sum_congr rfl
|
|
60
|
+
intro x _
|
|
61
|
+
simp_rw [gate, ite_mul, zero_mul]
|
|
62
|
+
simp
|
|
63
|
+
|
|
64
|
+
/-- Raw individual Bernoulli outcomes are subsets of named member indices. -/
|
|
65
|
+
abbrev World {ι : Type*} (n : ι → ℕ) := ∀ i, Finset (Fin (n i))
|
|
66
|
+
instance worldMeasurableSpace {ι : Type*} (n : ι → ℕ) : MeasurableSpace (World n) := ⊤
|
|
67
|
+
instance worldDiscreteMeasurable {ι : Type*} (n : ι → ℕ) : DiscreteMeasurableSpace (World n) := ⟨fun _ => trivial⟩
|
|
68
|
+
|
|
69
|
+
def jointMass {ι : Type*} [Fintype ι] (n : ι → ℕ) (p : ι → ℝ)
|
|
70
|
+
(x : World n) : ℝ := ∏ i, mass (p i) (x i)
|
|
71
|
+
|
|
72
|
+
theorem joint_count_pushforward {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
73
|
+
(n : ι → ℕ) (p : ι → ℝ) (f : (∀ i, Fin (n i+1)) → ℝ) :
|
|
74
|
+
(∑ x : World n, jointMass n p x*f (fun i => count (x i))) =
|
|
75
|
+
∑ k : ∀ i, Fin (n i+1), (∏ i, binMass (p i) (n i) (k i))*f k := by
|
|
76
|
+
simpa [jointMass, count_fiber_mass] using
|
|
77
|
+
product_pushforward (fun i => mass (p i)) (fun _ => count) f
|
|
78
|
+
|
|
79
|
+
theorem mass_sum (p : ℝ) (n : ℕ) :
|
|
80
|
+
∑ s : Finset (Fin n), mass p s = 1 := by
|
|
81
|
+
have h := Finset.sum_powerset_apply_card (fun k => p^k*(1-p)^(n-k))
|
|
82
|
+
(x := (Finset.univ : Finset (Fin n)))
|
|
83
|
+
simp only [Finset.powerset_univ, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at h
|
|
84
|
+
change (∑ s : Finset (Fin n), p^s.card*(1-p)^(n-s.card)) = 1
|
|
85
|
+
rw [h]
|
|
86
|
+
calc
|
|
87
|
+
_ = (p+(1-p))^n := by
|
|
88
|
+
rw [add_pow]
|
|
89
|
+
apply Finset.sum_congr rfl
|
|
90
|
+
intro k _
|
|
91
|
+
ring
|
|
92
|
+
_ = 1 := by simp
|
|
93
|
+
|
|
94
|
+
theorem mass_nonneg (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1)
|
|
95
|
+
{n : ℕ} (s : Finset (Fin n)) : 0 ≤ mass p s :=
|
|
96
|
+
mul_nonneg (pow_nonneg hp _) (pow_nonneg (sub_nonneg.mpr hp1) _)
|
|
97
|
+
|
|
98
|
+
theorem jointMass_sum {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
99
|
+
(n : ι → ℕ) (p : ι → ℝ) : ∑ x : World n, jointMass n p x = 1 := by
|
|
100
|
+
simp only [jointMass, ← Fintype.prod_sum, mass_sum, Finset.prod_const_one]
|
|
101
|
+
|
|
102
|
+
def memberLaw {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
103
|
+
(n : ι → ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1) :
|
|
104
|
+
PMF (World n) :=
|
|
105
|
+
PMF.ofFintype (fun x => ENNReal.ofReal (jointMass n p x)) (by
|
|
106
|
+
rw [← ENNReal.ofReal_sum_of_nonneg]
|
|
107
|
+
· simp [jointMass_sum]
|
|
108
|
+
· intro x _
|
|
109
|
+
exact Finset.prod_nonneg (fun i _ => mass_nonneg (p i) (hp i) (hp1 i) (x i)))
|
|
110
|
+
|
|
111
|
+
theorem memberLaw_expectation {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
112
|
+
(n : ι → ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1)
|
|
113
|
+
(f : World n → ℝ) :
|
|
114
|
+
(∫ x, f x ∂(memberLaw n p hp hp1).toMeasure) =
|
|
115
|
+
∑ x : World n, jointMass n p x*f x := by
|
|
116
|
+
rw [PMF.integral_eq_sum]
|
|
117
|
+
apply Finset.sum_congr rfl
|
|
118
|
+
intro x _
|
|
119
|
+
simp only [memberLaw, PMF.ofFintype_apply, smul_eq_mul]
|
|
120
|
+
have hm : 0 ≤ jointMass n p x := Finset.prod_nonneg
|
|
121
|
+
(fun i _ => mass_nonneg (p i) (hp i) (hp1 i) (x i))
|
|
122
|
+
rw [ENNReal.toReal_ofReal hm]
|
|
123
|
+
|
|
124
|
+
open Obligations045.M0
|
|
125
|
+
abbrev sizes (M : Domain) (N : ℕ) (i : Fin M.K) := allocation M.w N i
|
|
126
|
+
def modelLaw (M : Domain) (N : ℕ) (a : Fin M.K → Bool) : PMF (World (sizes M N)) :=
|
|
127
|
+
memberLaw (sizes M N) (fun i => q M (a i))
|
|
128
|
+
(fun i => (q_pos M (a i)).le) (fun i => (q_lt_one M (a i)).le)
|
|
129
|
+
def correctCount {ι : Type*} [Fintype ι] {n : ι → ℕ} (x : World n) : ℕ :=
|
|
130
|
+
∑ i, (x i).card
|
|
131
|
+
|
|
132
|
+
/-- Exact finite expectation of individual Bernoulli member outcomes, not an assumed count law. -/
|
|
133
|
+
theorem conditional_error_representation (M : Domain) (N : ℕ) (a : Fin M.K → Bool) :
|
|
134
|
+
(∫ x, fairLoss (correctCount x) N ∂(modelLaw M N a).toMeasure) =
|
|
135
|
+
conditionalError M N a := by
|
|
136
|
+
rw [modelLaw, memberLaw_expectation]
|
|
137
|
+
have h := joint_count_pushforward (sizes M N) (fun i => q M (a i))
|
|
138
|
+
(fun k => fairLoss (∑ i, (k i : ℕ)) N)
|
|
139
|
+
simpa [conditionalError, binMass, count, correctCount, sizes] using h
|
|
140
|
+
|
|
141
|
+
/-- N=0 has fairLoss=1/2; it is not the average bridge. -/
|
|
142
|
+
theorem conditional_error_zero (M : Domain) (a : Fin M.K → Bool) :
|
|
143
|
+
conditionalError M 0 a = 1/2 := by
|
|
144
|
+
rw [← conditional_error_representation]
|
|
145
|
+
have hz : ∀ x : World (sizes M 0), correctCount x = 0 := by
|
|
146
|
+
intro x
|
|
147
|
+
have h : ∀ i, x i = ∅ := by
|
|
148
|
+
intro i
|
|
149
|
+
apply Finset.eq_empty_iff_forall_not_mem.mpr
|
|
150
|
+
intro j _
|
|
151
|
+
have hj := j.isLt
|
|
152
|
+
simp [sizes, allocation] at hj
|
|
153
|
+
simp [correctCount, h]
|
|
154
|
+
simp [hz, fairLoss]
|
|
155
|
+
|
|
156
|
+
theorem fair_loss_average_bridge (total N : ℕ) (hN : 0 < N) :
|
|
157
|
+
fairLoss total N = limitingLoss ((total:ℝ)/(N:ℝ)) := by
|
|
158
|
+
have hn : (0:ℝ) < N := by exact_mod_cast hN
|
|
159
|
+
have hlt : (total:ℝ)/(N:ℝ) < (1:ℝ)/2 ↔ 2*total < N := by
|
|
160
|
+
rw [div_lt_iff₀ hn]
|
|
161
|
+
constructor
|
|
162
|
+
· intro h
|
|
163
|
+
exact_mod_cast (show (2:ℝ)*total < N by linarith)
|
|
164
|
+
· intro h
|
|
165
|
+
have h' : (2:ℝ)*total < N := by exact_mod_cast h
|
|
166
|
+
linarith
|
|
167
|
+
have heq : (total:ℝ)/(N:ℝ) = (1:ℝ)/2 ↔ 2*total = N := by
|
|
168
|
+
rw [div_eq_iff hn.ne']
|
|
169
|
+
constructor
|
|
170
|
+
· intro h
|
|
171
|
+
exact_mod_cast (show (2:ℝ)*total = N by linarith)
|
|
172
|
+
· intro h
|
|
173
|
+
have h' : (2:ℝ)*total = N := by exact_mod_cast h
|
|
174
|
+
linarith
|
|
175
|
+
unfold fairLoss limitingLoss
|
|
176
|
+
simp only [hlt, heq]
|
|
177
|
+
|
|
178
|
+
/-- Probability of every joint count event, derived from raw member product probabilities. -/
|
|
179
|
+
theorem lineage_count_binomial_law {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
180
|
+
(n : ι → ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1)
|
|
181
|
+
(k : ∀ i, Fin (n i+1)) :
|
|
182
|
+
(∫ x, if (fun i => count (x i)) = k then (1:ℝ) else 0
|
|
183
|
+
∂(memberLaw n p hp hp1).toMeasure) = ∏ i, binMass (p i) (n i) (k i) := by
|
|
184
|
+
rw [memberLaw_expectation]
|
|
185
|
+
simpa using joint_count_pushforward n p (fun z => if z = k then (1:ℝ) else 0)
|
|
186
|
+
|
|
187
|
+
/-- The snapshot retains individual named Bernoulli outcomes; it is not a count-law certificate. -/
|
|
188
|
+
def snapshot {Ω : Type*} (M : Domain) (N : ℕ)
|
|
189
|
+
(X : Fin M.K → ℕ → Ω → Bool) (ω : Ω) : World (sizes M N) :=
|
|
190
|
+
fun i => Finset.univ.filter (fun j : Fin (sizes M N i) => X i j ω)
|
|
191
|
+
def indicator {Ω : Type*} {K : ℕ} (X : Fin K → ℕ → Ω → Bool) : Fin K → ℕ → Ω → ℝ :=
|
|
192
|
+
fun i j ω => if X i j ω then 1 else 0
|
|
193
|
+
|
|
194
|
+
theorem snapshot_card {Ω : Type*} (M : Domain) (N : ℕ)
|
|
195
|
+
(X : Fin M.K → ℕ → Ω → Bool) (ω : Ω) (i : Fin M.K) :
|
|
196
|
+
(((snapshot M N X ω) i).card : ℝ) =
|
|
197
|
+
∑ j ∈ Finset.range (allocation M.w N i), indicator X i j ω := by
|
|
198
|
+
simp only [snapshot, Finset.card_filter, Nat.cast_sum, Nat.cast_ite,
|
|
199
|
+
Nat.cast_one, Nat.cast_zero, indicator]
|
|
200
|
+
exact Fin.sum_univ_eq_sum_range (fun j => if X i j ω then (1:ℝ) else 0) _
|
|
201
|
+
|
|
202
|
+
theorem snapshot_average {Ω : Type*} (M : Domain) (N : ℕ)
|
|
203
|
+
(X : Fin M.K → ℕ → Ω → Bool) (ω : Ω) :
|
|
204
|
+
memberAverage M (indicator X) N ω = (correctCount (snapshot M N X ω):ℝ)/(N:ℝ) := by
|
|
205
|
+
simp only [memberAverage, correctCount, Nat.cast_sum, snapshot_card, Finset.sum_div]
|
|
206
|
+
|
|
207
|
+
/-- Transfer from a declared joint Bernoulli MEMBER law on an ambient probability space.
|
|
208
|
+
hproduct names all raw bits, not counts, their expectation, or a tail/convergence law. -/
|
|
209
|
+
theorem ambient_conditional_error_representation {Ω : Type*} [MeasurableSpace Ω]
|
|
210
|
+
(M : Domain) (N : ℕ) (a : Fin M.K → Bool) (μ : Measure Ω)
|
|
211
|
+
(X : Fin M.K → ℕ → Ω → Bool) (hN : 0 < N)
|
|
212
|
+
(hmeas : AEMeasurable (snapshot M N X) μ)
|
|
213
|
+
(hproduct : Measure.map (snapshot M N X) μ = (modelLaw M N a).toMeasure) :
|
|
214
|
+
(∫ ω, limitingLoss (memberAverage M (indicator X) N ω) ∂μ) =
|
|
215
|
+
conditionalError M N a := by
|
|
216
|
+
have hpoint : (fun ω => limitingLoss (memberAverage M (indicator X) N ω)) =
|
|
217
|
+
(fun ω => fairLoss (correctCount (snapshot M N X ω)) N) := by
|
|
218
|
+
funext ω
|
|
219
|
+
rw [snapshot_average, fair_loss_average_bridge _ _ hN]
|
|
220
|
+
rw [hpoint]
|
|
221
|
+
have hf : AEStronglyMeasurable (fun x : World (sizes M N) => fairLoss (correctCount x) N)
|
|
222
|
+
(Measure.map (snapshot M N X) μ) := Measurable.of_discrete.stronglyMeasurable.aestronglyMeasurable
|
|
223
|
+
rw [← integral_map hmeas hf, hproduct, conditional_error_representation]
|
|
224
|
+
|
|
225
|
+
theorem mixture_error_representation {Ω : Type*} [MeasurableSpace Ω]
|
|
226
|
+
(M : Domain) (N : ℕ) (μ : Measure Ω)
|
|
227
|
+
(X : (Fin M.K → Bool) → Fin M.K → ℕ → Ω → Bool) (hN : 0 < N)
|
|
228
|
+
(hmeas : ∀ a, AEMeasurable (snapshot M N (X a)) μ)
|
|
229
|
+
(hproduct : ∀ a, Measure.map (snapshot M N (X a)) μ = (modelLaw M N a).toMeasure) :
|
|
230
|
+
error M N = ∑ a : Fin M.K → Bool, latentMass M a *
|
|
231
|
+
∫ ω, limitingLoss (memberAverage M (indicator (X a)) N ω) ∂μ := by
|
|
232
|
+
unfold error
|
|
233
|
+
apply Finset.sum_congr rfl
|
|
234
|
+
intro a _
|
|
235
|
+
rw [ambient_conditional_error_representation M N a μ (X a) hN (hmeas a) (hproduct a)]
|
|
236
|
+
|
|
237
|
+
/-- The implementation limit follows from the old model theorem and the new representation bridge.
|
|
238
|
+
No CLT, diagonal theorem, count-law certificate, or convergence premise is assumed. -/
|
|
239
|
+
theorem computational_offdiag_limit {Ω : Type*} [MeasurableSpace Ω]
|
|
240
|
+
(M : Domain) (μ : Measure Ω) [IsProbabilityMeasure μ]
|
|
241
|
+
(X : (Fin M.K → Bool) → Fin M.K → ℕ → Ω → Bool)
|
|
242
|
+
(hsnapshot : ∀ a N, AEMeasurable (snapshot M N (X a)) μ)
|
|
243
|
+
(hproduct : ∀ a N, Measure.map (snapshot M N (X a)) μ = (modelLaw M N a).toMeasure)
|
|
244
|
+
(hint : ∀ a i, Integrable (indicator (X a) i 0) μ)
|
|
245
|
+
(hindep : ∀ a i, Pairwise (fun j k : ℕ => IndepFun (indicator (X a) i j) (indicator (X a) i k) μ))
|
|
246
|
+
(hident : ∀ a i j, IdentDistrib (indicator (X a) i j) (indicator (X a) i 0) μ μ)
|
|
247
|
+
(hmean : ∀ a i, ∫ ω, indicator (X a) i 0 ω ∂μ = q M (a i))
|
|
248
|
+
(hmeas : ∀ a N, AEStronglyMeasurable
|
|
249
|
+
(fun ω => limitingLoss (memberAverage M (indicator (X a)) N ω)) μ)
|
|
250
|
+
(hoff : ∀ a, score M a ≠ (1:ℝ)/2) :
|
|
251
|
+
Tendsto (error M) atTop (𝓝 (floor M)) := by
|
|
252
|
+
have h := floor_limit_offdiag_mixture M μ (fun a => indicator (X a))
|
|
253
|
+
hint hindep hident hmean hmeas hoff
|
|
254
|
+
have heq : (fun N => error M N) =ᶠ[atTop]
|
|
255
|
+
(fun N => ∑ a : Fin M.K → Bool, latentMass M a *
|
|
256
|
+
∫ ω, limitingLoss (memberAverage M (indicator (X a)) N ω) ∂μ) := by
|
|
257
|
+
filter_upwards [eventually_ge_atTop 1] with N hN
|
|
258
|
+
exact mixture_error_representation M N μ X (lt_of_lt_of_le Nat.zero_lt_one hN)
|
|
259
|
+
(fun a => hsnapshot a N) (fun a => hproduct a N)
|
|
260
|
+
exact h.congr' heq.symm
|
|
261
|
+
|
|
262
|
+
/-- The starting probability is the product over NAMED INDIVIDUAL bits, with no binomial factor. -/
|
|
263
|
+
theorem mass_eq_individual_product (p : ℝ) {n : ℕ} (s : Finset (Fin n)) :
|
|
264
|
+
mass p s = ∏ j : Fin n, if j ∈ s then p else 1-p := by
|
|
265
|
+
have hc : (Finset.univ.filter (fun j : Fin n => j ∉ s)) = sᶜ := by
|
|
266
|
+
ext j
|
|
267
|
+
simp
|
|
268
|
+
rw [Finset.prod_ite]
|
|
269
|
+
simp [mass, Finset.filter_mem_eq_inter, hc, Finset.card_compl]
|
|
270
|
+
|
|
271
|
+
theorem memberLaw_individual_probability {ι : Type*} [Fintype ι] [DecidableEq ι]
|
|
272
|
+
(n : ι → ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hp1 : ∀ i, p i ≤ 1)
|
|
273
|
+
(x : World n) :
|
|
274
|
+
((memberLaw n p hp hp1) x).toReal =
|
|
275
|
+
∏ i, ∏ j : Fin (n i), if j ∈ x i then p i else 1-p i := by
|
|
276
|
+
simp only [memberLaw, PMF.ofFintype_apply]
|
|
277
|
+
have hm : 0 ≤ jointMass n p x := Finset.prod_nonneg
|
|
278
|
+
(fun i _ => mass_nonneg (p i) (hp i) (hp1 i) (x i))
|
|
279
|
+
rw [ENNReal.toReal_ofReal hm]
|
|
280
|
+
simp only [jointMass, mass_eq_individual_product]
|
|
281
|
+
|
|
282
|
+
theorem zero_average_counterexample : fairLoss 0 0 ≠ limitingLoss ((0:ℝ)/0) := by
|
|
283
|
+
norm_num [fairLoss, limitingLoss]
|
|
284
|
+
|
|
285
|
+
theorem latentMass_sum (M : Domain) : ∑ a : Fin M.K → Bool, latentMass M a = 1 := by
|
|
286
|
+
have h := (Fintype.prod_sum (fun (_i : Fin M.K) (b : Bool) =>
|
|
287
|
+
if b then M.p else 1-M.p)).symm
|
|
288
|
+
simpa [latentMass] using h
|
|
289
|
+
|
|
290
|
+
/-- The finite mixture itself equals the existing implementation for EVERY N,
|
|
291
|
+
including zero. Its product-Bernoulli latent weights sum to one. -/
|
|
292
|
+
theorem model_mixture_error_representation (M : Domain) (N : ℕ) :
|
|
293
|
+
(∑ a : Fin M.K → Bool, latentMass M a *
|
|
294
|
+
∫ x, fairLoss (correctCount x) N ∂(modelLaw M N a).toMeasure) = error M N := by
|
|
295
|
+
unfold error
|
|
296
|
+
apply Finset.sum_congr rfl
|
|
297
|
+
intro a _
|
|
298
|
+
rw [conditional_error_representation]
|
|
299
|
+
|
|
300
|
+
end Obligations046.Bridge
|