Download data/lean/OAI/Computability/MinUncut/Games/LabelBound.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 12.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MinUncut/Games/LabelBound.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MinUncut/Games/LabelBound.lean
-
curl -L -o LabelBound.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MinUncut/Games/LabelBound.lean
12.8 kB
Lean 4 Β· 24
declarations fullstatements
| import Mathlib | |
| import OAI.Computability.MinUncut.Games.Basic | |
| namespace OAI | |
| namespace MinUncutGames.Foundations.CorrelatedSampling | |
| noncomputable section | |
| variable {Ο Ξ± : Type*} [Fintype Ο] [DecidableEq Ο] [DecidableEq Ξ±] | |
| def localSample (accept : Ο β Bool) (decode : Ο β Ξ±) (fallback : Ξ±) | |
| (proposals : List Ο) : Ξ± := | |
| ((firstAccepted accept proposals).map decode).getD fallback | |
| def localDiagonal (left right : Ο β Bool) (decode : Ο β Ξ±) (fallback a : Ξ±) | |
| (proposals : List Ο) : β := | |
| if localSample left decode fallback proposals = a β§ | |
| localSample right decode fallback proposals = a then 1 else 0 | |
| def goodLabel (left right : Ο β Bool) (decode : Ο β Ξ±) (a : Ξ±) (s : Ο) : Bool := | |
| (left s && right s) && decide (decode s = a) | |
| omit [Fintype Ο] [DecidableEq Ο] in | |
| theorem common_first_label_lower (left right : Ο β Bool) (decode : Ο β Ξ±) | |
| (fallback a : Ξ±) (proposals : List Ο) : | |
| goodFirstIndicator (fun s => left s || right s) (goodLabel left right decode a) proposals β€ | |
| localDiagonal left right decode fallback a proposals := by | |
| cases hfirst : firstAccepted (fun s => left s || right s) proposals with | |
| | none => | |
| simp only [goodFirstIndicator, hfirst] | |
| unfold localDiagonal | |
| split_ifs <;> norm_num | |
| | some s => | |
| by_cases hc : goodLabel left right decode a s = true | |
| Β· have hparts : (left s = true β§ right s = true) β§ decode s = a := by | |
| simpa [goodLabel] using hc | |
| have h := first_union_common left right proposals s hfirst hparts.1.1 hparts.1.2 | |
| simp [goodFirstIndicator, hfirst, hc, localDiagonal, localSample, h.1, h.2, hparts.2] | |
| Β· have hn : 0 β€ localDiagonal left right decode fallback a proposals := by | |
| unfold localDiagonal | |
| split_ifs <;> norm_num | |
| simpa [goodFirstIndicator, hfirst, hc] using hn | |
| omit [DecidableEq Ο] in theorem union_goodLabel_mass | |
| (w : Ο β β) (left right : Ο β Bool) (decode : Ο β Ξ±) (a : Ξ±) : | |
| eventMass w (fun s => (left s || right s) && goodLabel left right decode a s) = | |
| eventMass w (goodLabel left right decode a) := by | |
| unfold eventMass | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| cases hl : left s <;> cases hr : right s <;> simp [goodLabel, hl, hr] | |
| theorem finite_label_diagonal_bound (w : Ο β β) (left right : Ο β Bool) | |
| (decode : Ο β Ξ±) (fallback a : Ξ±) (hw : β s, 0 β€ w s) | |
| (hw_sum : β s, w s = 1) (hu : 0 < eventMass w (fun s => left s || right s)) (n : Nat) : | |
| eventMass w (goodLabel left right decode a) / eventMass w (fun s => left s || right s) * | |
| (1 - eventMass w (fun s => !(left s || right s)) ^ n) β€ | |
| traceAverage w n (localDiagonal left right decode fallback a) := by | |
| have h := traceAverage_mono w hw n _ _ (common_first_label_lower left right decode fallback a) | |
| rw [goodFirstIndicator_law w _ _ hw_sum n, | |
| goodFirstMass_exact w _ _ hw_sum (ne_of_gt hu) n, | |
| union_goodLabel_mass] at h | |
| exact h | |
| variable [Fintype Ξ±] [Nonempty Ξ±] | |
| theorem rectangle_label_diagonal_bound (thresholds : List β) (p q : Ξ± β β) | |
| (fallback a : Ξ±) | |
| (hpm : β x, p x β thresholds) (hqm : β x, q x β thresholds) | |
| (hp0 : β x, 0 β€ p x) (hq0 : β x, 0 β€ q x) | |
| (hp1 : β x, p x β€ 1) (hq1 : β x, q x β€ 1) | |
| (hpsum : β x, p x = 1) (hqsum : β x, q x = 1) (n : Nat) : | |
| min (p a) (q a) / (1 + totalVariation p q) * | |
| (1 - eventMass (rectangleWeight thresholds) | |
| (fun s => !(rectangleAccept thresholds p s || rectangleAccept thresholds q s)) ^ n) β€ | |
| traceAverage (rectangleWeight thresholds) n | |
| (localDiagonal (rectangleAccept thresholds p) (rectangleAccept thresholds q) | |
| Prod.fst fallback a) := by | |
| have hc : 0 < (Fintype.card Ξ± : β) := by exact_mod_cast Fintype.card_pos | |
| have hU : 0 < unionMass p q := by | |
| rw [unionMass_eq p q hpsum hqsum] | |
| linarith [totalVariation_nonneg p q] | |
| have hmass := rectangle_union_mass thresholds p q hpm hqm hp0 hq0 hp1 hq1 | |
| have hu : 0 < eventMass (rectangleWeight thresholds) | |
| (fun s => rectangleAccept thresholds p s || rectangleAccept thresholds q s) := by | |
| rw [hmass] | |
| exact div_pos hU hc | |
| have h := finite_label_diagonal_bound (rectangleWeight thresholds) | |
| (rectangleAccept thresholds p) (rectangleAccept thresholds q) Prod.fst fallback a | |
| (rectangleWeight_nonnegative thresholds) (rectangleWeight_normalized thresholds) hu n | |
| unfold goodLabel at h | |
| rw [rectangle_common_label_mass thresholds p q a hpm hqm hp0 hq0 hp1 hq1, hmass] at h | |
| have hratio : (min (p a) (q a) / (Fintype.card Ξ± : β)) / | |
| (unionMass p q / (Fintype.card Ξ± : β)) = min (p a) (q a) / unionMass p q := by | |
| field_simp | |
| rw [hratio, unionMass_eq p q hpsum hqsum] at h | |
| exact h | |
| end | |
| open scoped BigOperators | |
| noncomputable section | |
| def profileThresholds {ΞΊ S : Type*} [Fintype ΞΊ] [Fintype S] | |
| (P : ΞΊ β S β β) : List β := by | |
| classical | |
| exact (Finset.univ.toList : List (ΞΊ Γ S)).map (fun ks => P ks.1 ks.2) | |
| theorem mem_profileThresholds {ΞΊ S : Type*} [Fintype ΞΊ] [Fintype S] | |
| (P : ΞΊ β S β β) (k : ΞΊ) (s : S) : P k s β profileThresholds P := by | |
| classical | |
| exact List.mem_map.mpr β¨(k, s), by simp, rflβ© | |
| theorem distribution_weight_le_one {S : Type*} [Fintype S] | |
| (ΞΌ : Games.FiniteDistribution S) (s : S) : ΞΌ.weight s β€ 1 := by | |
| calc | |
| ΞΌ.weight s β€ β t, ΞΌ.weight t := | |
| Finset.single_le_sum (fun t _ => ΞΌ.nonnegative t) (Finset.mem_univ s) | |
| _ = 1 := ΞΌ.normalized | |
| variable {Qβ Qβ S : Type*} [Fintype Qβ] [Fintype Qβ] [Fintype S] | |
| def sharedProfileThresholds (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) : List β := | |
| profileThresholds (fun (k : Qβ β Qβ) s => (Sum.elim L R k).weight s) | |
| theorem left_mem_sharedProfileThresholds (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) (x : Qβ) (s : S) : | |
| (L x).weight s β sharedProfileThresholds L R := by | |
| exact mem_profileThresholds _ (Sum.inl x) s | |
| theorem right_mem_sharedProfileThresholds (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) (y : Qβ) (s : S) : | |
| (R y).weight s β sharedProfileThresholds L R := by | |
| exact mem_profileThresholds _ (Sum.inr y) s | |
| abbrev SharedProfileSeed (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) := | |
| RectangleSeed (sharedProfileThresholds L R) S | |
| def sharedProfileLeft (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) (x : Qβ) : SharedProfileSeed L R β Bool := | |
| rectangleAccept (sharedProfileThresholds L R) (L x).weight | |
| def sharedProfileRight (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) (y : Qβ) : SharedProfileSeed L R β Bool := | |
| rectangleAccept (sharedProfileThresholds L R) (R y).weight | |
| def sharedProfileReject (L : Qβ β Games.FiniteDistribution S) | |
| (R : Qβ β Games.FiniteDistribution S) (x : Qβ) (y : Qβ) : β := | |
| eventMass (rectangleWeight (sharedProfileThresholds L R)) | |
| (fun s => !(sharedProfileLeft L R x s || sharedProfileRight L R y s)) | |
| def uniformRejectionRate (S : Type*) [Fintype S] : β := | |
| 1 - 1 / (Fintype.card S : β) | |
| theorem uniformRejectionRate_nonnegative (S : Type*) [Fintype S] [Nonempty S] : | |
| 0 β€ uniformRejectionRate S := by | |
| have hc : (0 : β) < Fintype.card S := by | |
| exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S) | |
| have hcβ : (1 : β) β€ Fintype.card S := by | |
| exact_mod_cast (Nat.succ_le_of_lt (Fintype.card_pos : 0 < Fintype.card S)) | |
| apply sub_nonneg.mpr | |
| exact (div_le_iffβ hc).2 (by simpa using hcβ) | |
| theorem uniformRejectionRate_lt_one (S : Type*) [Fintype S] [Nonempty S] : | |
| uniformRejectionRate S < 1 := by | |
| have hc : (0 : β) < Fintype.card S := by | |
| exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S) | |
| have hp : (0 : β) < 1 / (Fintype.card S : β) := div_pos (by norm_num) hc | |
| dsimp [uniformRejectionRate] | |
| linarith | |
| theorem sharedProfileReject_nonnegative [Nonempty S] | |
| (L : Qβ β Games.FiniteDistribution S) (R : Qβ β Games.FiniteDistribution S) | |
| (x : Qβ) (y : Qβ) : 0 β€ sharedProfileReject L R x y := by | |
| exact eventMass_nonneg _ _ | |
| (rectangleDistribution (Ξ± := S) (sharedProfileThresholds L R)).nonnegative | |
| theorem sharedProfile_reject_le_rate [Nonempty S] | |
| (L : Qβ β Games.FiniteDistribution S) (R : Qβ β Games.FiniteDistribution S) | |
| (x : Qβ) (y : Qβ) : sharedProfileReject L R x y β€ uniformRejectionRate S := by | |
| let thresholds := sharedProfileThresholds L R | |
| have hsum : (β s : RectangleSeed thresholds S, rectangleWeight thresholds s) = 1 := | |
| (rectangleDistribution (Ξ± := S) thresholds).normalized | |
| have hcomp := eventMass_complement (rectangleWeight thresholds) | |
| (fun s => sharedProfileLeft L R x s || sharedProfileRight L R y s) hsum | |
| have hu : eventMass (rectangleWeight thresholds) | |
| (fun s => sharedProfileLeft L R x s || sharedProfileRight L R y s) = | |
| (1 + totalVariation (L x).weight (R y).weight) / (Fintype.card S : β) := by | |
| change eventMass (rectangleWeight thresholds) | |
| (fun s => rectangleAccept thresholds (L x).weight s || | |
| rectangleAccept thresholds (R y).weight s) = _ | |
| rw [rectangle_union_mass thresholds (L x).weight (R y).weight | |
| (left_mem_sharedProfileThresholds L R x) | |
| (right_mem_sharedProfileThresholds L R y) | |
| (L x).nonnegative (R y).nonnegative | |
| (distribution_weight_le_one (L x)) (distribution_weight_le_one (R y))] | |
| rw [unionMass_eq (L x).weight (R y).weight (L x).normalized (R y).normalized] | |
| have hc : (0 : β) < Fintype.card S := by | |
| exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S) | |
| have htv := totalVariation_nonneg (L x).weight (R y).weight | |
| have hquot : 1 / (Fintype.card S : β) β€ | |
| (1 + totalVariation (L x).weight (R y).weight) / (Fintype.card S : β) := | |
| (div_le_div_iff_of_pos_right hc).2 (by linarith) | |
| rw [hu] at hcomp | |
| change eventMass (rectangleWeight thresholds) | |
| (fun s => !(sharedProfileLeft L R x s || sharedProfileRight L R y s)) β€ | |
| 1 - 1 / (Fintype.card S : β) | |
| linarith | |
| private theorem nonnegative_powers_mono (a b : β) (ha : 0 β€ a) (hab : a β€ b) | |
| (n : β) : a ^ n β€ b ^ n := by | |
| have hb : 0 β€ b := le_trans ha hab | |
| induction n with | |
| | zero => simp | |
| | succ n ih => | |
| rw [pow_succ, pow_succ] | |
| exact mul_le_mul ih hab ha (pow_nonneg hb n) | |
| theorem sharedProfile_label_diagonal_bound [Nonempty S] [DecidableEq S] | |
| (L : Qβ β Games.FiniteDistribution S) (R : Qβ β Games.FiniteDistribution S) | |
| (x : Qβ) (y : Qβ) (fallback a : S) (n : β) : | |
| min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) * | |
| (1 - uniformRejectionRate S ^ n) β€ | |
| traceAverage (rectangleWeight (sharedProfileThresholds L R)) n | |
| (localDiagonal (sharedProfileLeft L R x) (sharedProfileRight L R y) | |
| Prod.fst fallback a) := by | |
| have hp := nonnegative_powers_mono (sharedProfileReject L R x y) | |
| (uniformRejectionRate S) (sharedProfileReject_nonnegative L R x y) | |
| (sharedProfile_reject_le_rate L R x y) n | |
| have htv := totalVariation_nonneg (L x).weight (R y).weight | |
| have hm : 0 β€ min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) := | |
| div_nonneg (le_min ((L x).nonnegative a) ((R y).nonnegative a)) (by linarith) | |
| have hsurv : | |
| min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) * | |
| (1 - uniformRejectionRate S ^ n) β€ | |
| min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) * | |
| (1 - sharedProfileReject L R x y ^ n) := | |
| mul_le_mul_of_nonneg_left (by linarith) hm | |
| refine hsurv.trans ?_ | |
| simpa only [sharedProfileReject, sharedProfileLeft, sharedProfileRight] using | |
| rectangle_label_diagonal_bound (sharedProfileThresholds L R) | |
| (L x).weight (R y).weight fallback a | |
| (left_mem_sharedProfileThresholds L R x) | |
| (right_mem_sharedProfileThresholds L R y) | |
| (L x).nonnegative (R y).nonnegative | |
| (distribution_weight_le_one (L x)) (distribution_weight_le_one (R y)) | |
| (L x).normalized (R y).normalized n | |
| theorem exists_uniformRejectionRate_pow_lt (S : Type*) [Fintype S] [Nonempty S] | |
| (Ξ· : β) (hΞ· : 0 < Ξ·) : β n : β, uniformRejectionRate S ^ n < Ξ· := by | |
| have ht := tendsto_pow_atTop_nhds_zero_of_lt_one | |
| (uniformRejectionRate_nonnegative S) (uniformRejectionRate_lt_one S) | |
| exact (ht.eventually (gt_mem_nhds hΞ·)).exists | |
| end | |
| end MinUncutGames.Foundations.CorrelatedSampling | |
| end OAI | |
Outline
- def
localSample12 - def
localDiagonal16 - def
goodLabel21 - theorem
common_first_label_lower25 - theorem
finite_label_diagonal_bound54 - theorem
rectangle_label_diagonal_bound68 - def
profileThresholds106 - theorem
mem_profileThresholds111 - theorem
distribution_weight_le_one116 - def
sharedProfileThresholds125 - theorem
left_mem_sharedProfileThresholds129 - theorem
right_mem_sharedProfileThresholds134 - abbrev
SharedProfileSeed139 - def
sharedProfileLeft143 - def
sharedProfileRight147 - def
sharedProfileReject151 - def
uniformRejectionRate156 - theorem
uniformRejectionRate_nonnegative159 - theorem
uniformRejectionRate_lt_one168 - theorem
sharedProfileReject_nonnegative176 - theorem
sharedProfile_reject_le_rate182 - theorem
nonnegative_powers_mono214 - theorem
sharedProfile_label_diagonal_bound223 - theorem
exists_uniformRejectionRate_pow_lt257