@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,235 @@
|
|
|
1
|
+
import M0Bridge
|
|
2
|
+
import Lean.Elab.Tactic.Omega
|
|
3
|
+
open scoped BigOperators
|
|
4
|
+
open Filter Topology
|
|
5
|
+
noncomputable section
|
|
6
|
+
open Classical Obligations045.M0
|
|
7
|
+
namespace Obligations046.Diagonal
|
|
8
|
+
|
|
9
|
+
/-- Deterministic mean and Bernoulli variance of the declared product law.
|
|
10
|
+
The probabilistic CLT is not an assumption of either definition. -/
|
|
11
|
+
def mean (M : Domain) (a : Fin M.K → Bool) (N : ℕ) : ℝ :=
|
|
12
|
+
∑ i : Fin M.K, (allocation M.w N i : ℝ) * q M (a i)
|
|
13
|
+
def variance (M : Domain) (a : Fin M.K → Bool) (N : ℕ) : ℝ :=
|
|
14
|
+
∑ i : Fin M.K, (allocation M.w N i : ℝ) * (q M (a i) * (1-q M (a i)))
|
|
15
|
+
def varianceRate (M : Domain) (a : Fin M.K → Bool) : ℝ :=
|
|
16
|
+
∑ i : Fin M.K, M.w i * (q M (a i) * (1-q M (a i)))
|
|
17
|
+
def varianceLower (M : Domain) : ℝ := (1-M.c)^2 * M.p * (1-M.p)
|
|
18
|
+
|
|
19
|
+
theorem weights_fin_sum (M : Domain) : ∑ i : Fin M.K, M.w i = 1 := by
|
|
20
|
+
simpa only [Fin.sum_univ_eq_sum_range] using M.weights_sum
|
|
21
|
+
|
|
22
|
+
theorem variance_lower_pos (M : Domain) : 0 < varianceLower M := by
|
|
23
|
+
have hp : 0 < M.p := by linarith [M.p_half]
|
|
24
|
+
unfold varianceLower
|
|
25
|
+
exact mul_pos (mul_pos (sq_pos_of_pos (by linarith [M.c_lt_one])) hp)
|
|
26
|
+
(by linarith [M.p_lt_one])
|
|
27
|
+
|
|
28
|
+
theorem bernoulli_variance_lower (M : Domain) (b : Bool) :
|
|
29
|
+
varianceLower M ≤ q M b * (1-q M b) := by
|
|
30
|
+
have hc : 0 ≤ 1-M.c := by linarith [M.c_lt_one]
|
|
31
|
+
have hp : 0 ≤ M.p := by linarith [M.p_half]
|
|
32
|
+
have hprod : 0 ≤ (1-M.c)*M.p := mul_nonneg hc hp
|
|
33
|
+
have hprod' : 0 ≤ (1-M.c)*(1-M.p) := mul_nonneg hc (by linarith [M.p_lt_one])
|
|
34
|
+
cases b <;> simp only [q, Bool.false_eq_true, ite_false, add_zero, ite_true]
|
|
35
|
+
· unfold varianceLower
|
|
36
|
+
nlinarith [mul_nonneg hprod M.c_nonneg]
|
|
37
|
+
· unfold varianceLower
|
|
38
|
+
nlinarith [mul_nonneg hprod' M.c_nonneg]
|
|
39
|
+
|
|
40
|
+
theorem variance_rate_pos (M : Domain) (a : Fin M.K → Bool) :
|
|
41
|
+
0 < varianceRate M a := by
|
|
42
|
+
have h : varianceLower M ≤ varianceRate M a := by
|
|
43
|
+
calc
|
|
44
|
+
varianceLower M = ∑ i : Fin M.K, M.w i * varianceLower M := by
|
|
45
|
+
rw [← Finset.sum_mul, weights_fin_sum, one_mul]
|
|
46
|
+
_ ≤ varianceRate M a := Finset.sum_le_sum (fun i _ =>
|
|
47
|
+
mul_le_mul_of_nonneg_left (bernoulli_variance_lower M (a i)) (M.w_nonneg i))
|
|
48
|
+
exact lt_of_lt_of_le (variance_lower_pos M) h
|
|
49
|
+
|
|
50
|
+
theorem finite_variance_lower (M : Domain) (a : Fin M.K → Bool) (N : ℕ) :
|
|
51
|
+
(N:ℝ)*varianceLower M ≤ variance M a N := by
|
|
52
|
+
have hsum : ∑ i : Fin M.K, (allocation M.w N i : ℝ) = (N:ℝ) := by
|
|
53
|
+
exact_mod_cast (by simpa only [Fin.sum_univ_eq_sum_range] using allocation_sum M N)
|
|
54
|
+
calc
|
|
55
|
+
(N:ℝ)*varianceLower M = ∑ i : Fin M.K,
|
|
56
|
+
(allocation M.w N i : ℝ)*varianceLower M := by rw [← Finset.sum_mul, hsum]
|
|
57
|
+
_ ≤ variance M a N := Finset.sum_le_sum (fun i _ =>
|
|
58
|
+
mul_le_mul_of_nonneg_left (bernoulli_variance_lower M (a i)) (by positivity))
|
|
59
|
+
|
|
60
|
+
theorem mean_rounding_bound (M : Domain) (a : Fin M.K → Bool) (N : ℕ) :
|
|
61
|
+
|mean M a N - (N:ℝ)*score M a| ≤ (M.K:ℝ) := by
|
|
62
|
+
have heq : mean M a N - (N:ℝ)*score M a =
|
|
63
|
+
∑ i : Fin M.K, ((allocation M.w N i : ℝ)-(N:ℝ)*M.w i)*q M (a i) := by
|
|
64
|
+
simp only [mean, score, Finset.mul_sum, ← Finset.sum_sub_distrib]
|
|
65
|
+
apply Finset.sum_congr rfl
|
|
66
|
+
intro i _
|
|
67
|
+
ring
|
|
68
|
+
rw [heq]
|
|
69
|
+
calc
|
|
70
|
+
_ ≤ ∑ i : Fin M.K, |((allocation M.w N i : ℝ)-(N:ℝ)*M.w i)*q M (a i)| :=
|
|
71
|
+
Finset.abs_sum_le_sum_abs _ _
|
|
72
|
+
_ ≤ ∑ _i : Fin M.K, (1:ℝ) := by
|
|
73
|
+
apply Finset.sum_le_sum
|
|
74
|
+
intro i _
|
|
75
|
+
rw [abs_mul, abs_of_pos (q_pos M (a i))]
|
|
76
|
+
have hdis : |(allocation M.w N i : ℝ)-(N:ℝ)*M.w i| ≤ 1 :=
|
|
77
|
+
abs_le.mpr ⟨le_of_lt (allocation_discrepancy M N i).1,
|
|
78
|
+
le_of_lt (allocation_discrepancy M N i).2⟩
|
|
79
|
+
exact (mul_le_mul_of_nonneg_right hdis (le_of_lt (q_pos M (a i)))).trans
|
|
80
|
+
(by simpa using le_of_lt (q_lt_one M (a i)))
|
|
81
|
+
_ = (M.K:ℝ) := by simp
|
|
82
|
+
|
|
83
|
+
theorem diagonal_mean_bound (M : Domain) (a : Fin M.K → Bool)
|
|
84
|
+
(hdiag : score M a = (1:ℝ)/2) (N : ℕ) :
|
|
85
|
+
|mean M a N - (N:ℝ)/2| ≤ (M.K:ℝ) := by
|
|
86
|
+
simpa only [hdiag, mul_one_div] using mean_rounding_bound M a N
|
|
87
|
+
|
|
88
|
+
theorem variance_rate_limit (M : Domain) (a : Fin M.K → Bool) :
|
|
89
|
+
Tendsto (fun N : ℕ => variance M a N / (N:ℝ)) atTop (𝓝 (varianceRate M a)) := by
|
|
90
|
+
have h := tendsto_finset_sum Finset.univ (fun (i : Fin M.K) _ =>
|
|
91
|
+
(allocation_ratio M i).mul_const (q M (a i)*(1-q M (a i))))
|
|
92
|
+
convert h using 1
|
|
93
|
+
funext N
|
|
94
|
+
simp only [variance, Finset.sum_div, div_mul_eq_mul_div]
|
|
95
|
+
|
|
96
|
+
/-- Variance really diverges for this fixed domain, including zero-weight lineages. -/
|
|
97
|
+
theorem variance_atTop (M : Domain) (a : Fin M.K → Bool) :
|
|
98
|
+
Tendsto (variance M a) atTop atTop := by
|
|
99
|
+
apply tendsto_atTop_mono (fun N => finite_variance_lower M a N)
|
|
100
|
+
exact tendsto_natCast_atTop_atTop.atTop_mul_const (variance_lower_pos M)
|
|
101
|
+
|
|
102
|
+
/-- On the diagonal the bounded quota drift is negligible compared with variance.
|
|
103
|
+
This is a CLT prerequisite, not a CLT or a probability-tail certificate. -/
|
|
104
|
+
theorem diagonal_drift_squared_limit (M : Domain) (a : Fin M.K → Bool)
|
|
105
|
+
(hdiag : score M a = (1:ℝ)/2) :
|
|
106
|
+
Tendsto (fun N : ℕ => (mean M a N - (N:ℝ)/2)^2 / variance M a N)
|
|
107
|
+
atTop (𝓝 0) := by
|
|
108
|
+
have hupper : Tendsto (fun N : ℕ => (M.K:ℝ)^2 / variance M a N)
|
|
109
|
+
atTop (𝓝 0) := tendsto_const_nhds.div_atTop (variance_atTop M a)
|
|
110
|
+
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hupper
|
|
111
|
+
· filter_upwards [(variance_atTop M a).eventually (eventually_ge_atTop 1)] with N hN
|
|
112
|
+
exact div_nonneg (sq_nonneg _) (by linarith)
|
|
113
|
+
· filter_upwards [(variance_atTop M a).eventually (eventually_ge_atTop 1)] with N hN
|
|
114
|
+
apply div_le_div_of_nonneg_right _ (by linarith)
|
|
115
|
+
have habs := diagonal_mean_bound M a hdiag N
|
|
116
|
+
nlinarith [sq_abs (mean M a N - (N:ℝ)/2), abs_nonneg (mean M a N - (N:ℝ)/2)]
|
|
117
|
+
|
|
118
|
+
open Obligations046.Bridge
|
|
119
|
+
|
|
120
|
+
def complement {ι : Type*} [Fintype ι] {n : ι → ℕ} (x : World n) : World n :=
|
|
121
|
+
fun i => (x i)ᶜ
|
|
122
|
+
|
|
123
|
+
theorem complement_involutive {ι : Type*} [Fintype ι] {n : ι → ℕ} (x : World n) :
|
|
124
|
+
complement (complement x) = x := by funext i; simp [complement]
|
|
125
|
+
|
|
126
|
+
theorem unbiased_mass_complement (n : ℕ) (x : Finset (Fin n)) :
|
|
127
|
+
mass (1/2 : ℝ) xᶜ = mass (1/2 : ℝ) x := by
|
|
128
|
+
have hx : x.card ≤ n := by simpa using x.card_le_univ
|
|
129
|
+
simp only [mass, Finset.card_compl, Fintype.card_fin]
|
|
130
|
+
norm_num
|
|
131
|
+
rw [Nat.sub_sub_self hx, mul_comm]
|
|
132
|
+
|
|
133
|
+
theorem unbiased_joint_complement {ι : Type*} [Fintype ι] (n : ι → ℕ)
|
|
134
|
+
(x : World n) :
|
|
135
|
+
jointMass n (fun _ => (1/2 : ℝ)) (complement x) =
|
|
136
|
+
jointMass n (fun _ => (1/2 : ℝ)) x := by
|
|
137
|
+
apply Finset.prod_congr rfl
|
|
138
|
+
intro i _
|
|
139
|
+
exact unbiased_mass_complement (n i) (x i)
|
|
140
|
+
|
|
141
|
+
theorem count_complement (M : Domain) (N : ℕ) (x : World (sizes M N)) :
|
|
142
|
+
correctCount (complement x) + correctCount x = N := by
|
|
143
|
+
have hsum : ∑ i : Fin M.K, sizes M N i = N := by
|
|
144
|
+
simpa only [Fin.sum_univ_eq_sum_range] using allocation_sum M N
|
|
145
|
+
unfold correctCount
|
|
146
|
+
rw [← Finset.sum_add_distrib]
|
|
147
|
+
convert hsum using 1
|
|
148
|
+
apply Finset.sum_congr rfl
|
|
149
|
+
intro i _
|
|
150
|
+
simp only [complement, Finset.card_compl, Fintype.card_fin]
|
|
151
|
+
exact Nat.sub_add_cancel (by simpa using (x i).card_le_univ)
|
|
152
|
+
|
|
153
|
+
theorem fair_loss_reflection (b d N : ℕ) (h : b+d=N) :
|
|
154
|
+
fairLoss b N + fairLoss d N = 1 := by
|
|
155
|
+
unfold fairLoss
|
|
156
|
+
split_ifs <;> norm_num <;> omega
|
|
157
|
+
|
|
158
|
+
/-- Genuine diagonal subdomain, exact for every N (even N=0).
|
|
159
|
+
It is not asserted for arbitrary diagonal scores with unequal q_i. -/
|
|
160
|
+
theorem unbiased_conditional_exact (M : Domain) (a : Fin M.K → Bool)
|
|
161
|
+
(hunbiased : ∀ i, q M (a i) = (1:ℝ)/2) (N : ℕ) :
|
|
162
|
+
conditionalError M N a = (1:ℝ)/2 := by
|
|
163
|
+
let f : World (sizes M N) → ℝ := fun x =>
|
|
164
|
+
jointMass (sizes M N) (fun _ => (1/2:ℝ)) x * fairLoss (correctCount x) N
|
|
165
|
+
have hrep : conditionalError M N a = ∑ x, f x := by
|
|
166
|
+
rw [← conditional_error_representation, modelLaw, memberLaw_expectation]
|
|
167
|
+
simp only [f, hunbiased]
|
|
168
|
+
have hsym : ∑ x, f (complement x) = ∑ x, f x :=
|
|
169
|
+
Fintype.sum_bijective complement
|
|
170
|
+
⟨fun x y h => by simpa only [complement_involutive] using congrArg complement h,
|
|
171
|
+
fun x => ⟨complement x, complement_involutive x⟩⟩ _ _ (fun _ => rfl)
|
|
172
|
+
have hpair : ∀ x, f (complement x) + f x =
|
|
173
|
+
jointMass (sizes M N) (fun _ => (1/2:ℝ)) x := by
|
|
174
|
+
intro x
|
|
175
|
+
simp only [f, unbiased_joint_complement, ← mul_add]
|
|
176
|
+
rw [fair_loss_reflection _ _ _ (count_complement M N x), mul_one]
|
|
177
|
+
have htotal : (∑ x, f (complement x)) + (∑ x, f x) = 1 := by
|
|
178
|
+
rw [← Finset.sum_add_distrib]
|
|
179
|
+
simp only [hpair]
|
|
180
|
+
exact jointMass_sum _ _
|
|
181
|
+
rw [hrep]
|
|
182
|
+
linarith
|
|
183
|
+
|
|
184
|
+
theorem floor_limit_diag_unbiased (M : Domain) (a : Fin M.K → Bool)
|
|
185
|
+
(hunbiased : ∀ i, q M (a i) = (1:ℝ)/2) :
|
|
186
|
+
Tendsto (fun N => conditionalError M N a) atTop (𝓝 ((1:ℝ)/2)) := by
|
|
187
|
+
simpa only [unbiased_conditional_exact M a hunbiased] using
|
|
188
|
+
(tendsto_const_nhds : Tendsto (fun _ : ℕ => (1:ℝ)/2) atTop (𝓝 ((1:ℝ)/2)))
|
|
189
|
+
|
|
190
|
+
/-- c=1 lies outside Domain: cumulative-floor quotas alone do not preserve ties.
|
|
191
|
+
With two equal-weight deterministic lineages (false,true), odd sizes favor true. -/
|
|
192
|
+
theorem deterministic_quota_even (m : ℕ) :
|
|
193
|
+
fairLoss ((2*m) - (2*m)/2) (2*m) = (1:ℝ)/2 := by
|
|
194
|
+
have h : (2*m)/2 = m := by omega
|
|
195
|
+
rw [h]
|
|
196
|
+
have hsub : 2*m-m = m := by omega
|
|
197
|
+
rw [hsub]
|
|
198
|
+
simp [fairLoss, Nat.not_lt.mpr (le_refl (2*m))]
|
|
199
|
+
|
|
200
|
+
theorem deterministic_quota_odd (m : ℕ) :
|
|
201
|
+
fairLoss ((2*m+1) - (2*m+1)/2) (2*m+1) = 0 := by
|
|
202
|
+
have h : (2*m+1)/2 = m := by omega
|
|
203
|
+
rw [h]
|
|
204
|
+
have hl : ¬ 2*(2*m+1-m) < 2*m+1 := by omega
|
|
205
|
+
have he : ¬ 2*(2*m+1-m) = 2*m+1 := by omega
|
|
206
|
+
simp only [fairLoss, if_neg hl, if_neg he]
|
|
207
|
+
|
|
208
|
+
/-- A legal heterogeneous diagonal; score=1/2 does not imply every q_i=1/2. -/
|
|
209
|
+
def heterogeneous : Domain where
|
|
210
|
+
K := 2
|
|
211
|
+
K_pos := by norm_num
|
|
212
|
+
p := 3/4
|
|
213
|
+
c := 1/2
|
|
214
|
+
p_half := by norm_num
|
|
215
|
+
p_lt_one := by norm_num
|
|
216
|
+
c_nonneg := by norm_num
|
|
217
|
+
c_lt_one := by norm_num
|
|
218
|
+
w := fun i => if i=0 then 3/4 else if i=1 then 1/4 else 0
|
|
219
|
+
w_nonneg := by intro i; split_ifs <;> norm_num
|
|
220
|
+
weights_sum := by norm_num [Finset.sum_range_succ]
|
|
221
|
+
|
|
222
|
+
def heterogeneousA : Fin 2 → Bool := fun i => i.val == 1
|
|
223
|
+
|
|
224
|
+
theorem heterogeneous_diagonal : score heterogeneous heterogeneousA = (1:ℝ)/2 := by
|
|
225
|
+
change (∑ i : Fin 2, (if (i:ℕ)=0 then (3:ℝ)/4 else if (i:ℕ)=1 then 1/4 else 0) *
|
|
226
|
+
((1-(1:ℝ)/2)*(3/4) + if (i:ℕ)==1 then (1:ℝ)/2 else 0)) = 1/2
|
|
227
|
+
norm_num [Fin.sum_univ_succ]
|
|
228
|
+
|
|
229
|
+
theorem heterogeneous_not_unbiased :
|
|
230
|
+
¬ (∀ i, q heterogeneous (heterogeneousA i) = (1:ℝ)/2) := by
|
|
231
|
+
intro h
|
|
232
|
+
have h0 := h ⟨0, by norm_num [heterogeneous]⟩
|
|
233
|
+
norm_num [q, heterogeneous, heterogeneousA] at h0
|
|
234
|
+
|
|
235
|
+
end Obligations046.Diagonal
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import M0BlockCoverage046
|
|
2
|
+
import M0Moments046
|
|
3
|
+
import Obligations045.M0Coincidence
|
|
4
|
+
import Mathlib.Tactic.FieldSimp
|
|
5
|
+
open scoped BigOperators
|
|
6
|
+
noncomputable section
|
|
7
|
+
namespace Obligations046.FiniteDiscord
|
|
8
|
+
open Obligations046.Moments Obligations045.M0Coincidence
|
|
9
|
+
|
|
10
|
+
def discord (N k : ℕ) : ℝ := 2*(k:ℝ)*((N:ℝ)-(k:ℝ))/((N:ℝ)*((N:ℝ)-1))
|
|
11
|
+
|
|
12
|
+
theorem discord_bounds (N k : ℕ) (hN : 2 ≤ N) (hk : k ≤ N) :
|
|
13
|
+
0 ≤ discord N k ∧ discord N k ≤ 1 := by
|
|
14
|
+
have hN2 : (2:ℝ) ≤ N := by exact_mod_cast hN
|
|
15
|
+
have hkN : (k:ℝ) ≤ N := by exact_mod_cast hk
|
|
16
|
+
have hk0 : (0:ℝ) ≤ k := by positivity
|
|
17
|
+
have hn0 : (0:ℝ) < N := by linarith
|
|
18
|
+
have hn1 : (0:ℝ) < (N:ℝ)-1 := by linarith
|
|
19
|
+
have hd : 0 < (N:ℝ)*((N:ℝ)-1) := mul_pos hn0 hn1
|
|
20
|
+
unfold discord
|
|
21
|
+
constructor
|
|
22
|
+
· exact div_nonneg (mul_nonneg (by positivity) (sub_nonneg.mpr hkN)) (le_of_lt hd)
|
|
23
|
+
· apply (div_le_one hd).mpr
|
|
24
|
+
nlinarith [sq_nonneg (2*(k:ℝ)-(N:ℝ)), mul_nonneg (sub_nonneg.mpr hN2) (le_of_lt hn0)]
|
|
25
|
+
|
|
26
|
+
theorem conditional_discord_mean (q : ℝ) (N : ℕ) (hN : 2 ≤ N) :
|
|
27
|
+
binExpect q N (discord N) = 2*q*(1-q) := by
|
|
28
|
+
have hf : discord N = (fun k : ℕ => ((k:ℝ)*(N:ℝ)-(k:ℝ)^2)*(2/((N:ℝ)*((N:ℝ)-1)))) := by
|
|
29
|
+
funext k
|
|
30
|
+
unfold discord
|
|
31
|
+
ring
|
|
32
|
+
have hsub : binExpect q N (fun k : ℕ => (k:ℝ)*(N:ℝ)-(k:ℝ)^2) =
|
|
33
|
+
binExpect q N (fun k : ℕ => (k:ℝ)*(N:ℝ))-binExpect q N (fun k : ℕ => (k:ℝ)^2) := by
|
|
34
|
+
simp [binExpect, mul_sub, Finset.sum_sub_distrib]
|
|
35
|
+
rw [hf, binExpect_mul_const, hsub, binExpect_mul_const, binExpect_mean, binExpect_second]
|
|
36
|
+
have hN2 : (2:ℝ) ≤ N := by exact_mod_cast hN
|
|
37
|
+
have hN0 : (N:ℝ) ≠ 0 := by linarith
|
|
38
|
+
have hN1 : (N:ℝ)-1 ≠ 0 := by linarith
|
|
39
|
+
field_simp
|
|
40
|
+
ring
|
|
41
|
+
|
|
42
|
+
theorem finite_M0_discord_mean (p c : ℝ) (ws : List ℝ) (hw : ws.sum = 1)
|
|
43
|
+
(N : ℕ) (hN : 2 ≤ N) :
|
|
44
|
+
expect p ws (fun x => binExpect ((1-c)*p+c*x) N (discord N)) =
|
|
45
|
+
2*p*(1-p)*(1-c^2*squares ws) := by
|
|
46
|
+
simp_rw [conditional_discord_mean _ N hN]
|
|
47
|
+
have hf : (fun x : ℝ => 2*((1-c)*p+c*x)*(1-((1-c)*p+c*x))) =
|
|
48
|
+
(fun x => (-2*c^2)*x^2+(2*c*(1-2*(1-c)*p))*x+2*(1-c)*p*(1-(1-c)*p)) := by
|
|
49
|
+
funext x
|
|
50
|
+
ring
|
|
51
|
+
rw [hf, expect_quadratic, hw]
|
|
52
|
+
ring
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
theorem expect_mul (p : ℝ) (ws : List ℝ) (f : ℝ → ℝ) (a : ℝ) :
|
|
56
|
+
expect p ws (fun x => f x*a) = expect p ws f*a := by
|
|
57
|
+
induction ws generalizing f with
|
|
58
|
+
| nil => rfl
|
|
59
|
+
| cons w ws ih => simp only [Obligations045.M0Coincidence.expect, ih]; ring
|
|
60
|
+
|
|
61
|
+
theorem expect_sum {ι : Type*} [Fintype ι] (p : ℝ) (ws : List ℝ) (f : ι → ℝ → ℝ) :
|
|
62
|
+
expect p ws (fun x => ∑ i, f i x) = ∑ i, expect p ws (f i) := by
|
|
63
|
+
induction ws generalizing f with
|
|
64
|
+
| nil => rfl
|
|
65
|
+
| cons w ws ih =>
|
|
66
|
+
simp only [Obligations045.M0Coincidence.expect, ih, Finset.mul_sum, Finset.sum_add_distrib]
|
|
67
|
+
|
|
68
|
+
theorem expect_const_one (p : ℝ) (ws : List ℝ) : expect p ws (fun _ => 1) = 1 := by
|
|
69
|
+
simpa using expect_quadratic p ws 0 0 1
|
|
70
|
+
|
|
71
|
+
theorem expect_support_nonneg (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1)
|
|
72
|
+
(ws : List ℝ) (hw : ∀ w ∈ ws, 0 ≤ w) (f : ℝ → ℝ)
|
|
73
|
+
(hf : ∀ x, 0 ≤ x → x ≤ ws.sum → 0 ≤ f x) : 0 ≤ expect p ws f := by
|
|
74
|
+
induction ws generalizing f with
|
|
75
|
+
| nil => exact hf 0 (by norm_num) (by simp)
|
|
76
|
+
| cons w ws ih =>
|
|
77
|
+
have hw0 := hw w (by simp)
|
|
78
|
+
have htail : ∀ a ∈ ws, 0 ≤ a := fun a ha => hw a (by simp [ha])
|
|
79
|
+
have h1 : 0 ≤ expect p ws f := ih htail f (fun x hx hxs =>
|
|
80
|
+
hf x hx (by simp only [List.sum_cons]; linarith))
|
|
81
|
+
have h2 : 0 ≤ expect p ws (fun x => f (w+x)) := ih htail _ (fun x hx hxs =>
|
|
82
|
+
hf (w+x) (by linarith) (by simp only [List.sum_cons]; linarith))
|
|
83
|
+
exact add_nonneg (mul_nonneg (by linarith) h1) (mul_nonneg hp h2)
|
|
84
|
+
|
|
85
|
+
def memberQ (p c x : ℝ) := (1-c)*p+c*x
|
|
86
|
+
|
|
87
|
+
def cellMass (p c : ℝ) (ws : List ℝ) (N : ℕ) (k : Fin (N+1)) : ℝ :=
|
|
88
|
+
expect p ws (fun x => (N.choose k.val : ℝ)*(memberQ p c x)^k.val*(1-memberQ p c x)^(N-k.val))
|
|
89
|
+
|
|
90
|
+
theorem cellMass_nonneg (p c : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1)
|
|
91
|
+
(hc : 0 ≤ c) (hc1 : c ≤ 1) (ws : List ℝ) (hw : ws.sum = 1)
|
|
92
|
+
(hws : ∀ w ∈ ws, 0 ≤ w) (N : ℕ) (k : Fin (N+1)) : 0 ≤ cellMass p c ws N k := by
|
|
93
|
+
apply expect_support_nonneg p hp hp1 ws hws
|
|
94
|
+
intro x hx hxs
|
|
95
|
+
have hx1 : x ≤ 1 := by simpa only [hw] using hxs
|
|
96
|
+
have hq : 0 ≤ memberQ p c x := add_nonneg (mul_nonneg (by linarith) hp) (mul_nonneg hc hx)
|
|
97
|
+
have hq1 : 0 ≤ 1-memberQ p c x := by
|
|
98
|
+
have h := add_nonneg (mul_nonneg (by linarith : 0 ≤ 1-c) (by linarith : 0 ≤ 1-p))
|
|
99
|
+
(mul_nonneg hc (by linarith : 0 ≤ 1-x))
|
|
100
|
+
unfold memberQ
|
|
101
|
+
nlinarith
|
|
102
|
+
exact mul_nonneg (mul_nonneg (by positivity) (pow_nonneg hq _)) (pow_nonneg hq1 _)
|
|
103
|
+
|
|
104
|
+
theorem cellMass_normalized (p c : ℝ) (ws : List ℝ) (N : ℕ) :
|
|
105
|
+
(∑ k : Fin (N+1), cellMass p c ws N k) = 1 := by
|
|
106
|
+
unfold cellMass
|
|
107
|
+
rw [← expect_sum]
|
|
108
|
+
have hf : (fun x : ℝ => ∑ k : Fin (N+1),
|
|
109
|
+
(N.choose k.val : ℝ)*(memberQ p c x)^k.val*(1-memberQ p c x)^(N-k.val)) = (fun _ => 1) := by
|
|
110
|
+
funext x
|
|
111
|
+
rw [Fin.sum_univ_eq_sum_range (fun k : ℕ => (N.choose k:ℝ)*(memberQ p c x)^k*(1-memberQ p c x)^(N-k)) (N+1)]
|
|
112
|
+
simpa only [binExpect, mul_one] using binExpect_one (memberQ p c x) N
|
|
113
|
+
rw [hf, expect_const_one]
|
|
114
|
+
|
|
115
|
+
theorem cellMass_discord_mean (p c : ℝ) (ws : List ℝ) (hw : ws.sum = 1)
|
|
116
|
+
(N : ℕ) (hN : 2 ≤ N) :
|
|
117
|
+
(∑ k : Fin (N+1), cellMass p c ws N k*discord N k.val) =
|
|
118
|
+
2*p*(1-p)*(1-c^2*squares ws) := by
|
|
119
|
+
unfold cellMass
|
|
120
|
+
simp_rw [← expect_mul]
|
|
121
|
+
rw [← expect_sum]
|
|
122
|
+
have hf : (fun x : ℝ => ∑ k : Fin (N+1),
|
|
123
|
+
((N.choose k.val : ℝ)*(memberQ p c x)^k.val*(1-memberQ p c x)^(N-k.val))*discord N k.val) =
|
|
124
|
+
(fun x => binExpect ((1-c)*p+c*x) N (discord N)) := by
|
|
125
|
+
funext x
|
|
126
|
+
rw [Fin.sum_univ_eq_sum_range (fun k : ℕ => ((N.choose k:ℝ)*(memberQ p c x)^k*(1-memberQ p c x)^(N-k))*discord N k) (N+1)]
|
|
127
|
+
rfl
|
|
128
|
+
rw [hf, finite_M0_discord_mean p c ws hw N hN]
|
|
129
|
+
|
|
130
|
+
-- Actual binary M0: p=3/4,c=1/2,K=1,N=4. Pair indicators share observations.
|
|
131
|
+
def witnessMass (k : Fin 5) : ℚ :=
|
|
132
|
+
(1/4)*(Nat.choose 4 k.val : ℚ)*(3/8)^k.val*(5/8)^(4-k.val)+
|
|
133
|
+
(3/4)*(Nat.choose 4 k.val : ℚ)*(7/8)^k.val*(1/8)^(4-k.val)
|
|
134
|
+
def witnessScore (k : Fin 5) : ℚ := ((2*k.val*(4-k.val):ℕ):ℚ)/12
|
|
135
|
+
|
|
136
|
+
theorem witness_normalized : (∑ k : Fin 5, witnessMass k) = 1 := by
|
|
137
|
+
norm_num [witnessMass, Fin.sum_univ_succ, Nat.choose]
|
|
138
|
+
|
|
139
|
+
theorem witness_mean : (∑ k : Fin 5, witnessMass k*witnessScore k) = 9/32 := by
|
|
140
|
+
norm_num [witnessMass, witnessScore, Fin.sum_univ_succ, Nat.choose]
|
|
141
|
+
|
|
142
|
+
theorem witness_variance :
|
|
143
|
+
(∑ k : Fin 5, witnessMass k*(witnessScore k-9/32)^2) = 157/2048 := by
|
|
144
|
+
norm_num [witnessMass, witnessScore, Fin.sum_univ_succ, Nat.choose]
|
|
145
|
+
|
|
146
|
+
theorem pairs_not_iid : (157/2048:ℚ) > 1/(4*6) := by norm_num
|
|
147
|
+
theorem repeated_cells_not_iid : (157/2048:ℚ) > 1/(4*100) := by norm_num
|
|
148
|
+
|
|
149
|
+
theorem fixed_quota_negative : (3/8:ℚ) ≠ 21/64 := by norm_num
|
|
150
|
+
|
|
151
|
+
theorem finite_M0_tail (p c : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1)
|
|
152
|
+
(hc : 0 ≤ c) (hc1 : c ≤ 1) (ws : List ℝ) (hw : ws.sum = 1)
|
|
153
|
+
(hws : ∀ w ∈ ws, 0 ≤ w) (N T : ℕ) (hN : 2 ≤ N) (hT : 0 < T)
|
|
154
|
+
(eps : ℝ) (heps : 0 < eps) :
|
|
155
|
+
BlockCoverage.iidSum (cellMass p c ws N) (fun k => discord N k.val) T
|
|
156
|
+
(BlockCoverage.bad T (2*p*(1-p)*(1-c^2*squares ws)) eps) ≤
|
|
157
|
+
min 1 (1/(4*(T:ℝ)*eps^2)) := by
|
|
158
|
+
have hm : BlockCoverage.avg (cellMass p c ws N) (fun k => discord N k.val) =
|
|
159
|
+
2*p*(1-p)*(1-c^2*squares ws) := cellMass_discord_mean p c ws hw N hN
|
|
160
|
+
rw [← hm]
|
|
161
|
+
apply BlockCoverage.clipped_block_tail
|
|
162
|
+
· exact cellMass_nonneg p c hp hp1 hc hc1 ws hw hws N
|
|
163
|
+
· exact cellMass_normalized p c ws N
|
|
164
|
+
· intro k
|
|
165
|
+
exact discord_bounds N k.val hN (Nat.lt_succ_iff.mp k.isLt)
|
|
166
|
+
· exact hT
|
|
167
|
+
· exact heps
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
theorem squares_nonneg (ws : List ℝ) : 0 ≤ squares ws := by
|
|
171
|
+
exact List.sum_nonneg (fun a ha => by obtain ⟨w, _, rfl⟩ := List.mem_map.mp ha; positivity)
|
|
172
|
+
|
|
173
|
+
theorem squares_zero_sum (ws : List ℝ) (h : squares ws = 0) : ws.sum = 0 := by
|
|
174
|
+
induction ws with
|
|
175
|
+
| nil => rfl
|
|
176
|
+
| cons w ws ih =>
|
|
177
|
+
have hs : w^2+squares ws = 0 := by simpa [squares] using h
|
|
178
|
+
have hw : w = 0 := by nlinarith [squares_nonneg ws, sq_nonneg w]
|
|
179
|
+
have ht : squares ws = 0 := by nlinarith
|
|
180
|
+
simp [hw, ih ht]
|
|
181
|
+
|
|
182
|
+
theorem squares_le_total_square (ws : List ℝ) (hws : ∀ w ∈ ws, 0 ≤ w) :
|
|
183
|
+
squares ws ≤ ws.sum^2 := by
|
|
184
|
+
induction ws with
|
|
185
|
+
| nil => simp [squares]
|
|
186
|
+
| cons w ws ih =>
|
|
187
|
+
have htail : ∀ a ∈ ws, 0 ≤ a := fun a ha => hws a (by simp [ha])
|
|
188
|
+
have hi := ih htail
|
|
189
|
+
have hsum : 0 ≤ ws.sum := List.sum_nonneg htail
|
|
190
|
+
have hw0 : 0 ≤ w := hws w (by simp)
|
|
191
|
+
simp only [squares, List.map_cons, List.sum_cons]
|
|
192
|
+
change w^2+squares ws ≤ (w+ws.sum)^2
|
|
193
|
+
nlinarith [mul_nonneg hw0 hsum]
|
|
194
|
+
|
|
195
|
+
theorem participation_ge_one (ws : List ℝ) (hw : ws.sum = 1)
|
|
196
|
+
(hws : ∀ w ∈ ws, 0 ≤ w) : 0 < squares ws ∧ 1 ≤ 1/squares ws := by
|
|
197
|
+
have hp : 0 < squares ws := by
|
|
198
|
+
have h0 := squares_nonneg ws
|
|
199
|
+
have hn : squares ws ≠ 0 := by intro h; have hz := squares_zero_sum ws h; linarith
|
|
200
|
+
exact lt_of_le_of_ne h0 (Ne.symm hn)
|
|
201
|
+
have hsq := squares_le_total_square ws hws
|
|
202
|
+
refine ⟨hp, ?_⟩
|
|
203
|
+
apply (le_div_iff₀ hp).mpr
|
|
204
|
+
rw [hw] at hsq
|
|
205
|
+
nlinarith
|
|
206
|
+
|
|
207
|
+
end Obligations046.FiniteDiscord
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import Mathlib.Data.Real.Basic
|
|
2
|
+
import Mathlib.Tactic.Linarith
|
|
3
|
+
import Mathlib.Tactic.Positivity
|
|
4
|
+
import Mathlib.Tactic.Ring
|
|
5
|
+
import Mathlib.Tactic.FieldSimp
|
|
6
|
+
|
|
7
|
+
namespace Obligations046.Interval
|
|
8
|
+
|
|
9
|
+
def noise (p : ℝ) := 2*p*(1-p)
|
|
10
|
+
|
|
11
|
+
theorem noise_bounds (pL p pU : ℝ) (hhalf : 1/2 < pL)
|
|
12
|
+
(hL : pL ≤ p) (hU : p ≤ pU) (hone : pU < 1) :
|
|
13
|
+
0 < noise pU ∧ noise pU ≤ noise p ∧ noise p ≤ noise pL := by
|
|
14
|
+
have h0 : 0 < pU := by linarith
|
|
15
|
+
have h1 : 0 < 1-pU := sub_pos.mpr hone
|
|
16
|
+
have ha : 0 < noise pU := by unfold noise; positivity
|
|
17
|
+
refine ⟨ha, ?_, ?_⟩
|
|
18
|
+
· have h := mul_nonneg (sub_nonneg.mpr hU) (by linarith : 0 ≤ pU+p-1)
|
|
19
|
+
unfold noise
|
|
20
|
+
nlinarith
|
|
21
|
+
· have h := mul_nonneg (sub_nonneg.mpr hL) (by linarith : 0 ≤ p+pL-1)
|
|
22
|
+
unfold noise
|
|
23
|
+
nlinarith
|
|
24
|
+
|
|
25
|
+
theorem denominator_box (DL D DU aL a aU : ℝ) (hDL0 : 0 ≤ DL)
|
|
26
|
+
(hDL : DL ≤ D) (hDU : D ≤ DU) (haL : 0 < aL)
|
|
27
|
+
(ha : aL ≤ a) (haU : a ≤ aU) :
|
|
28
|
+
1-DU/aL ≤ 1-D/a ∧ 1-D/a ≤ 1-DL/aU := by
|
|
29
|
+
have ha0 : 0 < a := by linarith
|
|
30
|
+
have haU0 : 0 < aU := by linarith
|
|
31
|
+
have hD0 : 0 ≤ D := by linarith
|
|
32
|
+
have h1 : DL/aU ≤ D/a := by
|
|
33
|
+
apply (div_le_div_iff₀ haU0 ha0).mpr
|
|
34
|
+
nlinarith [mul_nonneg (sub_nonneg.mpr hDL) (le_of_lt haU0),
|
|
35
|
+
mul_nonneg hDL0 (sub_nonneg.mpr haU)]
|
|
36
|
+
have h2 : D/a ≤ DU/aL := by
|
|
37
|
+
apply (div_le_div_iff₀ ha0 haL).mpr
|
|
38
|
+
nlinarith [mul_nonneg (sub_nonneg.mpr hDU) (le_of_lt ha0),
|
|
39
|
+
mul_nonneg hD0 (sub_nonneg.mpr ha)]
|
|
40
|
+
constructor <;> linarith
|
|
41
|
+
|
|
42
|
+
theorem ratio_box (cL c cU BL B BU : ℝ) (hcL : 0 ≤ cL)
|
|
43
|
+
(hc : cL ≤ c) (hcU : c ≤ cU) (hBL : 0 < BL)
|
|
44
|
+
(hB : BL ≤ B) (hBU : B ≤ BU) :
|
|
45
|
+
cL^2/BU ≤ c^2/B ∧ c^2/B ≤ cU^2/BL := by
|
|
46
|
+
have hB0 : 0 < B := by linarith
|
|
47
|
+
have hBU0 : 0 < BU := by linarith
|
|
48
|
+
have hlow : 0 ≤ c^2-cL^2 := by
|
|
49
|
+
nlinarith [mul_nonneg (sub_nonneg.mpr hc) (by linarith : 0 ≤ c+cL)]
|
|
50
|
+
have hhi : 0 ≤ cU^2-c^2 := by
|
|
51
|
+
nlinarith [mul_nonneg (sub_nonneg.mpr hcU) (by linarith : 0 ≤ cU+c)]
|
|
52
|
+
constructor
|
|
53
|
+
· apply (div_le_div_iff₀ hBU0 hB0).mpr
|
|
54
|
+
nlinarith [mul_nonneg hlow (le_of_lt hBU0),
|
|
55
|
+
mul_nonneg (sq_nonneg cL) (sub_nonneg.mpr hBU)]
|
|
56
|
+
· apply (div_le_div_iff₀ hB0 hBL).mpr
|
|
57
|
+
nlinarith [mul_nonneg hhi (le_of_lt hB0),
|
|
58
|
+
mul_nonneg (sq_nonneg c) (sub_nonneg.mpr hB)]
|
|
59
|
+
|
|
60
|
+
theorem pair_identity_inverse (D p c Q K : ℝ) (ha : noise p ≠ 0)
|
|
61
|
+
(hQ : Q ≠ 0) (hc : c ≠ 0) (hD : D = noise p*(1-c^2*Q))
|
|
62
|
+
(hK : K = 1/Q) : K = c^2/(1-D/noise p) := by
|
|
63
|
+
have hb : 1-D/noise p = c^2*Q := by rw [hD]; field_simp
|
|
64
|
+
rw [hb,hK]
|
|
65
|
+
field_simp
|
|
66
|
+
|
|
67
|
+
-- The reciprocal has no finite upper enclosure when its denominator may approach zero.
|
|
68
|
+
theorem unbounded_reciprocal (c M : ℝ) (hc : 0 < c) (hM : 0 < M) :
|
|
69
|
+
∃ B : ℝ, 0 < B ∧ c^2/B > M := by
|
|
70
|
+
refine ⟨c^2/(M+1), by positivity, ?_⟩
|
|
71
|
+
have h : c^2/(c^2/(M+1)) = M+1 := by field_simp
|
|
72
|
+
rw [h]
|
|
73
|
+
linarith
|
|
74
|
+
|
|
75
|
+
-- No independence of calibration/data failures is needed for this deterministic union bound.
|
|
76
|
+
theorem three_budget_union (d p c : ℝ) (_hd : 0 ≤ d) (_hp : 0 ≤ p) (_hc : 0 ≤ c)
|
|
77
|
+
(i j k : ℝ) (_hi : 0 ≤ i) (_hj : 0 ≤ j) (_hk : 0 ≤ k)
|
|
78
|
+
(hdi : i ≤ d) (hpj : j ≤ p) (hck : k ≤ c) : i+j+k ≤ d+p+c := by linarith
|
|
79
|
+
theorem physical_cap_clip (L K U cap : ℝ) (hL : L ≤ K) (hU : K ≤ U)
|
|
80
|
+
(hK : 1 ≤ K) (hcap : K ≤ cap) : max 1 L ≤ K ∧ K ≤ min U cap :=
|
|
81
|
+
⟨max_le hK hL, le_min hU hcap⟩
|
|
82
|
+
end Obligations046.Interval
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import M0Moments046
|
|
2
|
+
import Mathlib.Data.Real.Sqrt
|
|
3
|
+
open scoped BigOperators
|
|
4
|
+
open Filter Topology MeasureTheory
|
|
5
|
+
noncomputable section
|
|
6
|
+
open Classical Obligations045.M0 Obligations046.Bridge Obligations046.Diagonal
|
|
7
|
+
namespace Obligations046.Lindeberg
|
|
8
|
+
|
|
9
|
+
/-- The exact truncated centered second moment of one Bernoulli member.
|
|
10
|
+
Squared cutoff is ε² times the total variance; ε>0 is required below. -/
|
|
11
|
+
def bernoulliTail (q cutoff : ℝ) : ℝ :=
|
|
12
|
+
q*(if cutoff < (1-q)^2 then (1-q)^2 else 0) +
|
|
13
|
+
(1-q)*(if cutoff < q^2 then q^2 else 0)
|
|
14
|
+
|
|
15
|
+
def ratio (M : Domain) (a : Fin M.K → Bool) (N : ℕ) (ε : ℝ) : ℝ :=
|
|
16
|
+
(∑ i : Fin M.K, (allocation M.w N i:ℝ) *
|
|
17
|
+
bernoulliTail (q M (a i)) (ε^2 * Obligations046.Diagonal.variance M a N)) /
|
|
18
|
+
Obligations046.Diagonal.variance M a N
|
|
19
|
+
|
|
20
|
+
theorem centered_square_le_one (q : ℝ) (hq : 0 ≤ q) (hq1 : q ≤ 1) :
|
|
21
|
+
q^2 ≤ 1 ∧ (1-q)^2 ≤ 1 := by constructor <;> nlinarith
|
|
22
|
+
|
|
23
|
+
theorem bernoulli_tail_zero (q cutoff : ℝ) (hq : 0 ≤ q) (hq1 : q ≤ 1)
|
|
24
|
+
(hc : 1 ≤ cutoff) : bernoulliTail q cutoff = 0 := by
|
|
25
|
+
have h := centered_square_le_one q hq hq1
|
|
26
|
+
simp only [bernoulliTail, if_neg (not_lt.mpr (h.2.trans hc)),
|
|
27
|
+
if_neg (not_lt.mpr (h.1.trans hc)), mul_zero, add_zero]
|
|
28
|
+
|
|
29
|
+
theorem cutoff_eventually_large (M : Domain) (a : Fin M.K → Bool)
|
|
30
|
+
(ε : ℝ) (hε : 0 < ε) :
|
|
31
|
+
∀ᶠ N : ℕ in atTop, 1 ≤ ε^2*Obligations046.Diagonal.variance M a N := by
|
|
32
|
+
have hs : 0 < ε^2 := sq_pos_of_pos hε
|
|
33
|
+
have hv := (variance_atTop M a).eventually (eventually_ge_atTop (1/ε^2))
|
|
34
|
+
filter_upwards [hv] with N hN
|
|
35
|
+
simpa only [mul_comm] using (div_le_iff₀ hs).mp hN
|
|
36
|
+
|
|
37
|
+
theorem lindeberg_eventually_zero (M : Domain) (a : Fin M.K → Bool)
|
|
38
|
+
(ε : ℝ) (hε : 0 < ε) :
|
|
39
|
+
∀ᶠ N : ℕ in atTop, ratio M a N ε = 0 := by
|
|
40
|
+
filter_upwards [cutoff_eventually_large M a ε hε] with N hN
|
|
41
|
+
have hz : ∀ i : Fin M.K,
|
|
42
|
+
bernoulliTail (q M (a i)) (ε^2*Obligations046.Diagonal.variance M a N) = 0 :=
|
|
43
|
+
fun i => bernoulli_tail_zero _ _ (q_pos M (a i)).le (q_lt_one M (a i)).le hN
|
|
44
|
+
simp only [ratio, hz, mul_zero, Finset.sum_const_zero, zero_div]
|
|
45
|
+
|
|
46
|
+
theorem lindeberg_limit (M : Domain) (a : Fin M.K → Bool)
|
|
47
|
+
(ε : ℝ) (hε : 0 < ε) :
|
|
48
|
+
Tendsto (fun N => ratio M a N ε) atTop (𝓝 0) := by
|
|
49
|
+
have he : (fun N => ratio M a N ε) =ᶠ[atTop] (fun _ => 0) :=
|
|
50
|
+
lindeberg_eventually_zero M a ε hε
|
|
51
|
+
exact tendsto_const_nhds.congr' he.symm
|
|
52
|
+
|
|
53
|
+
/-- Explicit two-atom expectation, to prevent treating the cutoff expression as a certificate. -/
|
|
54
|
+
theorem bernoulli_tail_expectation (q cutoff : ℝ) :
|
|
55
|
+
(∑ b : Bool, (if b then q else 1-q) *
|
|
56
|
+
(if cutoff < ((if b then (1:ℝ) else 0)-q)^2
|
|
57
|
+
then ((if b then (1:ℝ) else 0)-q)^2 else 0)) = bernoulliTail q cutoff := by
|
|
58
|
+
simp only [Fintype.sum_bool, Bool.false_eq_true, ite_false, zero_sub, neg_sq, ite_true,
|
|
59
|
+
bernoulliTail]
|
|
60
|
+
|
|
61
|
+
theorem bernoulli_zero_cutoff (q : ℝ) (hq : 0 < q) (hq1 : q < 1) :
|
|
62
|
+
bernoulliTail q 0 = q*(1-q) := by
|
|
63
|
+
have h1 : 0 < (1-q)^2 := sq_pos_of_pos (by linarith)
|
|
64
|
+
have h0 : 0 < q^2 := sq_pos_of_pos hq
|
|
65
|
+
rw [bernoulliTail, if_pos h1, if_pos h0]
|
|
66
|
+
ring
|
|
67
|
+
|
|
68
|
+
/-- Negative boundary: ε=0 gives ratio 1 at every positive sample size, not 0. -/
|
|
69
|
+
theorem zero_epsilon_ratio (M : Domain) (a : Fin M.K → Bool) (N : ℕ) (hN : 0 < N) :
|
|
70
|
+
ratio M a N 0 = 1 := by
|
|
71
|
+
have hv : 0 < Obligations046.Diagonal.variance M a N :=
|
|
72
|
+
lt_of_lt_of_le (mul_pos (by exact_mod_cast hN) (variance_lower_pos M))
|
|
73
|
+
(finite_variance_lower M a N)
|
|
74
|
+
have hz : ∀ i : Fin M.K, bernoulliTail (q M (a i)) 0 = q M (a i)*(1-q M (a i)) :=
|
|
75
|
+
fun i => bernoulli_zero_cutoff _ (q_pos M (a i)) (q_lt_one M (a i))
|
|
76
|
+
simp only [ratio, zero_pow (by decide : (2:ℕ)≠0), zero_mul, hz]
|
|
77
|
+
change Obligations046.Diagonal.variance M a N / Obligations046.Diagonal.variance M a N = 1
|
|
78
|
+
exact div_self hv.ne'
|
|
79
|
+
|
|
80
|
+
/-- Centering at the majority threshold or at the actual probabilistic mean differs
|
|
81
|
+
by o(standard deviation), with the published quota rule and c<1. -/
|
|
82
|
+
theorem actual_mean_standardized_drift (M : Domain) (a : Fin M.K → Bool)
|
|
83
|
+
(hdiag : score M a = (1:ℝ)/2) :
|
|
84
|
+
Tendsto (fun N : ℕ =>
|
|
85
|
+
|(∫ x, (correctCount x:ℝ) ∂(modelLaw M N a).toMeasure) - (N:ℝ)/2| /
|
|
86
|
+
Real.sqrt (ProbabilityTheory.variance (fun x => (correctCount x:ℝ))
|
|
87
|
+
(modelLaw M N a).toMeasure)) atTop (𝓝 0) := by
|
|
88
|
+
simpa only [Obligations046.Moments.model_mean, Obligations046.Moments.model_variance,
|
|
89
|
+
Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, Real.sqrt_zero] using
|
|
90
|
+
(diagonal_drift_squared_limit M a hdiag).sqrt
|
|
91
|
+
|
|
92
|
+
end Obligations046.Lindeberg
|