Download data/lean/OAI/Probability/Contingency/OuterAccuracy.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 28.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Contingency/OuterAccuracy.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Contingency/OuterAccuracy.lean
-
curl -L -o OuterAccuracy.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Contingency/OuterAccuracy.lean
28.3 kB
| import Mathlib | |
| import OAI.Probability.Contingency.Unpadding | |
| namespace OAI | |
| /-! Outer Accuracy. -/ | |
| noncomputable section | |
| open scoped BigOperators | |
| open scoped BigOperators | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| open FiniteChain | |
| variable {m n a c' : β} (d b k C : β) (r : Fin m β β) (c : Fin n β β) | |
| (er : Fin a β {i // d^20 β€ r i}) (ec : Fin c' β {j // d^20 β€ c j}) (iβ : Fin a) (jβ : Fin c') | |
| (hrc : (β i,r i)=β j,c j) (hd : 14 β€ d) (hm : m β€ d) (hn : n β€ d) (hmn : m*n β€ d) | |
| [Nonempty (GraphState (d^20) r c)] | |
| local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) | |
| local instance outerAccuracyDrawCompletionFintype (X : GraphState (d^20) r c) : | |
| Fintype (Comp X) := Fintype.ofFinite _ | |
| local instance outerAccuracyDrawTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ | |
| include hd hm hn hmn hrc in | |
| omit [Nonempty (GraphState (d^20) r c)] in | |
| theorem stationary_failure_power (J : β) : | |
| letI := tables_nonempty r c hrc | |
| (stationaryTrial r c (d^20) (d^12)).mass none^Jβ€Real.exp (-((J:β)/(2*(1+(d:β)^2)))) := by | |
| let := tables_nonempty r c hrc | |
| have hf := stationary_success_probability d r c hd hm hn hmn hrc | |
| have hh : (stationaryTrial r c (d^20) (d^12)).mass noneβ€Real.exp (-(1/(2*(1+(d:β)^2)))) := by | |
| rw [stationaryTrial_none] | |
| have he := Real.add_one_le_exp (-(1/(2*(1+(d:β)^2)))) | |
| linarith | |
| have hp := pow_le_pow_leftβ ((stationaryTrial r c (d^20) (d^12)).nonneg none) hh J | |
| rw [β Real.exp_nat_mul] at hp | |
| convert hp using 1 | |
| congr 1 | |
| ring | |
| def outerDraw (ΞΌ : β X,DyadicLaw (Comp X)) (S : β) (hS : β X,(ΞΌ X).bits=S) | |
| (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : DyadicLaw (Tables r c) := by | |
| classical | |
| exact stoppedLaw (implementedTrial (d^20) (d^12) d r c er ec iβ jβ (smallDim_one d hd) hmn ΞΌ S hS Xβ (Schedule.T d b k)) fallback (Schedule.Jo d k) | |
| omit [Nonempty (GraphState (d^20) r c)] in | |
| theorem outerDraw_bits (ΞΌ : β X,DyadicLaw (Comp X)) (hS : β X,(ΞΌ X).bits=Schedule.RD d b k) | |
| (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : | |
| (outerDraw d b k r c er ec iβ jβ hd hmn ΞΌ (Schedule.RD d b k) hS Xβ fallback).bits=Schedule.R d b k := by | |
| classical | |
| change (implementedTrial _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _).bits*Schedule.Jo d k=_ | |
| rw [implementedTrial_bits] | |
| unfold Schedule.R Schedule.RT Schedule.qs | |
| ring | |
| include hm hn in | |
| theorem outerDraw_tv (hb : d β€ b) (hk : 1 β€ k) (hC2 : 2 β€ C) (hU : d^20 β€ C) | |
| (hC : β i,paddedRow (d^20) (d^12) r c i β€ C) (hCb : C+1 β€ 2^b) | |
| (ΞΌ : β X,DyadicLaw (Comp X)) (S : β) (hS : β X,(ΞΌ X).bits=S) | |
| (hΞΌ : β X,(ΞΌ X).toLaw.tv (idealCompletion (d^20) (d^12) r c hrc X) β€ (2:β)^(-(Schedule.h d b k:β€))) | |
| (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : | |
| letI := tables_nonempty r c hrc | |
| (outerDraw d b k r c er ec iβ jβ hd hmn ΞΌ S hS Xβ fallback).toLaw.tv (Law.uniform (Tables r c))β€(2:β)^(-(k:β€)) := by | |
| classical | |
| let := tables_nonempty r c hrc | |
| let p := implementedTrial (d^20) (d^12) d r c er ec iβ jβ (smallDim_one d hd) hmn ΞΌ S hS Xβ (Schedule.T d b k) | |
| let s := stationaryTrial r c (d^20) (d^12) | |
| have ht := implementedTrial_tv (d^20) (d^12) d r c er ec iβ jβ (smallDim_one d hd) hmn hrc ΞΌ S hS _ hΞΌ Xβ (Schedule.T d b k) | |
| have hmix := small_mixing d C r c er ec iβ jβ hrc hd hm hn hmn hC2 hU hC (Schedule.T d b k) Xβ | |
| have hfirst := Law.first_tv p.toLaw s fallback (Schedule.Jo d k) | |
| have hideal := Law.first_ideal_tv s fallback (Law.uniform (Tables r c)) (stationaryTrial_uniform r c (d^20) (d^12)) (Schedule.Jo d k) | |
| have hfail := stationary_failure_power d r c hrc hd hm hn hmn (Schedule.Jo d k) | |
| have htri := Law.tv_triangle (Law.first p.toLaw fallback (Schedule.Jo d k)) (Law.first s fallback (Schedule.Jo d k)) (Law.uniform (Tables r c)) | |
| have hmul := mul_le_mul_of_nonneg_left ht (Nat.cast_nonneg (Schedule.Jo d k)) | |
| have hmm := mul_le_mul_of_nonneg_left hmix (Nat.cast_nonneg (Schedule.Jo d k)) | |
| have htotal := Schedule.outer_error_schedule d b k hd hb hk C hCb | |
| unfold outerDraw | |
| rw [stoppedLaw_toLaw] | |
| change (Law.first p.toLaw fallback (Schedule.Jo d k)).tv _ β€ _ | |
| change _β€_ at hfail | |
| dsimp only [p,s] at hfirst hideal htri | |
| dsimp only [p] | |
| rw [neg_div] at hmm | |
| nlinarith only [hfirst,hideal,hfail,htri,hmul,hmm,htotal] | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| variable {m n a c' : β} (d b k C : β) (r : Fin m β β) (c : Fin n β β) | |
| (er : Fin (a+1) β {i // d^20 β€ r i}) (ec : Fin (c'+1) β {j // d^20 β€ c j}) | |
| (hrc : (β i,r i)=β j,c j) (hd : 14 β€ d) (hm : m β€ d) (hn : n β€ d) (hmn : m*n β€ d) | |
| [Nonempty (GraphState (d^20) r c)] | |
| local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) | |
| local instance outerAccuracyLiteralCompletionFintype (X : GraphState (d^20) r c) : | |
| Fintype (Comp X) := Fintype.ofFinite _ | |
| local instance outerAccuracyLiteralTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ | |
| def literalOuter (hC : β i,paddedRow (d^20) (d^12) r c i β€ C) (hCb : C β€ 2^b) | |
| (fallbacks : β X,Comp X) (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : DyadicLaw (Tables r c) := | |
| outerDraw d b k r c er ec 0 0 hd hmn | |
| (fun X => blockDraw d b k C r c er ec hrc hd hm hn hmn hC hCb X (fallbacks X)) | |
| (Schedule.RD d b k) | |
| (fun X => blockDraw_bits d b k C r c er ec hrc hd hm hn hmn hC hCb X (fallbacks X)) Xβ fallback | |
| omit [Nonempty (GraphState (d^20) r c)] in | |
| theorem literalOuter_bits (hC : β i,paddedRow (d^20) (d^12) r c i β€ C) (hCb : C β€ 2^b) | |
| (fallbacks : β X,Comp X) (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : | |
| (literalOuter d b k C r c er ec hrc hd hm hn hmn hC hCb fallbacks Xβ fallback).bits = Schedule.R d b k := by | |
| apply outerDraw_bits | |
| theorem literalOuter_tv (hb : d β€ b) (hk : 1 β€ k) (hC2 : 2 β€ C) (hU : d^20 β€ C) | |
| (hC : β i,paddedRow (d^20) (d^12) r c i β€ C) (hCb : C+1 β€ 2^b) | |
| (fallbacks : β X,Comp X) (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : | |
| letI := tables_nonempty r c hrc | |
| (literalOuter d b k C r c er ec hrc hd hm hn hmn hC (by omega) fallbacks Xβ fallback).toLaw.tv | |
| (Law.uniform (Tables r c)) β€ (2:β)^(-(k:β€)) := by | |
| apply outerDraw_tv d b k C r c er ec 0 0 hrc hd hm hn hmn hb hk hC2 hU hC hCb | |
| intro X | |
| exact blockDraw_tv d b k C r c er ec hrc hd hm hn hmn hC (by omega) hk X (fallbacks X) | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| open FiniteChain | |
| variable {m n : β} (U L d C : β) (r : Fin m β β) (c : Fin n β β) | |
| def EmptyBlock : Prop := β w : Cell m n, IsSmall U r c w | |
| theorem empty_completion_subsingleton (h : EmptyBlock U r c) (X : State m n) : | |
| Subsingleton (Completion U L r c X) := by | |
| constructor | |
| intro A B | |
| apply Subtype.ext | |
| funext w | |
| rw [A.property.2.1 w (h w),B.property.2.1 w (h w)] | |
| theorem empty_weight (h : EmptyBlock U r c) (hrc : (β i,r i)=β j,c j) | |
| (X : GraphState U r c) : weight U L r c (graphUnderlying U r c X)=1 := by | |
| let := empty_completion_subsingleton U L r c h (graphUnderlying U r c X) | |
| let := completion_nonempty U L r c X hrc | |
| rw [weight,ite_eq_left (graph_feasible U r c X)] | |
| exact Nat.card_unique | |
| def emptyCount (X Y : GraphState U r c) : β := if GraphAdj U r c X Y then 1 else 0 | |
| theorem emptyCount_nonneg (X Y : GraphState U r c) : 0 β€ emptyCount U r c X Y := by | |
| unfold emptyCount; split_ifs <;> norm_num | |
| def emptyData (h : EmptyBlock U r c) (hrc : (β i,r i)=β j,c j) | |
| (hd : 1 β€ d) (hmn : m*n β€ d) : AcceptedData (GraphState U r c) where | |
| f X := weight U L r c (graphUnderlying U r c X) | |
| fpos X := by exact_mod_cast graph_weight_pos U L r c X hrc | |
| count := emptyCount U r c | |
| nonneg := emptyCount_nonneg U r c | |
| symmetric X Y := by | |
| unfold emptyCount | |
| have he : GraphAdj U r c X Y β GraphAdj U r c Y X := β¨GraphAdj.symm U r c,GraphAdj.symm U r cβ© | |
| simp only [he] | |
| diagonal X := by simp [emptyCount,GraphAdj.irrefl] | |
| q := proposalRate (32*d^2) | |
| qpos := by unfold proposalRate; positivity | |
| hold X := by | |
| rw [empty_weight U L r c h hrc X] | |
| have hs : (β Y,emptyCount U r c X Y) β€ 5*(d:β)^2+1 := by | |
| simp only [emptyCount,β Finset.sum_filter] | |
| simpa using (show ((Finset.univ.filter (GraphAdj U r c X)).card:β) β€ 5*(d:β)^2+1 by | |
| exact_mod_cast graph_degree U r c d hmn X) | |
| have hp : 0 β€ proposalRate (32*d^2) := by unfold proposalRate; positivity | |
| exact (mul_le_mul_of_nonneg_left hs hp).trans (by simpa using proposal_hold d hd) | |
| theorem graphEnergy_le_empty (h : EmptyBlock U r c) (hrc : (β i,r i)=β j,c j) | |
| (hC : β i,paddedRow U L r c i β€ C) (H : GraphState U r c β β) : | |
| graphEnergy U L C r c (extendGraph U r c H) β€ | |
| 2*(β X,β Y,emptyCount U r c X Y*(H X-H Y)^2) := by | |
| apply (graphEnergy_le_ordered U L C r c hrc hC H).trans | |
| simp only [empty_weight U L r c h hrc,Nat.cast_one,min_self,one_mul] | |
| have he : (β X,β Y,if GraphAdj U r c X Y then (H X-H Y)^2 else 0) = | |
| β X,β Y,emptyCount U r c X Y*(H X-H Y)^2 := by | |
| simp [emptyCount,ite_mul] | |
| rw [he] | |
| have hn : 0 β€ β X,β Y,emptyCount U r c X Y*(H X-H Y)^2 := Finset.sum_nonneg | |
| (fun X _ => Finset.sum_nonneg (fun Y _ => mul_nonneg (emptyCount_nonneg U r c X Y) (sq_nonneg _))) | |
| linarith | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| open FiniteChain | |
| variable {m n : β} (d C : β) (r : Fin m β β) (c : Fin n β β) | |
| (hempty : EmptyBlock (d^20) r c) | |
| (hrc : (β i,r i)=β j,c j) (hd : 14β€d) (hm : m β€ d) (hn : n β€ d) (hmn : m*nβ€d) | |
| [Nonempty (GraphState (d^20) r c)] | |
| local notation "A" => emptyData (d^20) (d^12) d r c hempty hrc (smallDim_one d hd) hmn | |
| theorem empty_poincare (hC2 : 2β€C) (hC : β i,paddedRow (d^20) (d^12) r c iβ€C) | |
| (H : GraphState (d^20) r c β β) : | |
| (A).chain.variance H β€ (d:β)^160*(A).chain.energy H := by | |
| have hd' : (1:β)β€d := by exact_mod_cast (smallDim_one d hd) | |
| have hd0 : (0:β)<d := by linarith | |
| have hU : 2β€d^20 := by | |
| calc | |
| 2 β€ 14^20 := by norm_num | |
| _ β€ d^20 := Nat.pow_le_pow_left hd _ | |
| have hv := graph_poincare (d^20) (d^12) C d r c hU hC2 (by omega) hmn hrc hC | |
| (extendGraph (d^20) r c H) | |
| have he := graphEnergy_le_empty (d^20) (d^12) C r c hempty hrc hC H | |
| let S : β := β X,β Y,emptyCount (d^20) r c X Y*(H X-H Y)^2 | |
| have hs : 0β€S := Finset.sum_nonneg (fun X _ => Finset.sum_nonneg (fun Y _ => | |
| mul_nonneg (emptyCount_nonneg (d^20) r c X Y) (sq_nonneg _))) | |
| have hvar : (A).chain.variance H=graphVariance (d^20) (d^12) r c (extendGraph (d^20) r c H)/(A).total := by | |
| rw [AcceptedData.variance_formula] | |
| congr 1 | |
| unfold graphVariance | |
| have hh : extendGraph (d^20) r c H β graphUnderlying (d^20) r c=H := by | |
| funext X; exact extendGraph_apply (d^20) r c H X | |
| rw [hh]; rfl | |
| have hEn : (A).chain.energy H=(proposalRate (32*d^2)/(A).total)*S/2 := by | |
| rw [AcceptedData.energy_formula]; rfl | |
| have hq := (smallProposal_bounds d (by omega)).1 | |
| have hrate : S/(A).total β€128*(d:β)^2*(A).chain.energy H := by | |
| rw [hEn] | |
| have hsum := mul_le_mul_of_nonneg_right hq hs | |
| apply (div_le_iffβ (A).total_pos).mpr | |
| field_simp [(A).total_pos.ne'] | |
| have hh : Sβ€64*(d:β)^2*(proposalRate (32*d^2)*S) := by | |
| have hh := hsum | |
| rw [one_div_mul_eq_div,div_le_iffβ (by positivity : 0<64*(d:β)^2)] at hh | |
| nlinarith only [hh] | |
| nlinarith only [hh] | |
| have hpow : 770*(d:β)^4*((d^20:β):β)^6*2=1540*(d:β)^124 := by | |
| push_cast | |
| rw [β pow_mul] | |
| ring | |
| have hvarS : (A).chain.variance H β€1540*(d:β)^124*(S/(A).total) := by | |
| rw [hvar] | |
| apply (div_le_iffβ (A).total_pos).mpr | |
| have hh := hv.trans (mul_le_mul_of_nonneg_left he (by positivity)) | |
| change graphVariance (d^20) (d^12) r c (extendGraph (d^20) r c H) β€ _ at hh | |
| calc | |
| _ β€ 770*(d:β)^4*((d^20:β):β)^6*(2*S) := hh | |
| _ = (1540*(d:β)^124)*S := by rw [β mul_assoc,hpow] | |
| _ = _ := by field_simp [(A).total_pos.ne'] | |
| have hconst : 197120*(d:β)^126β€(d:β)^160 := by | |
| have hh : (197120:β)β€(d:β)^34 := by | |
| calc | |
| _ β€ (14:β)^34 := by norm_num | |
| _ β€ _ := pow_le_pow_leftβ (by norm_num) (by exact_mod_cast hd) _ | |
| have hh' := mul_le_mul_of_nonneg_right hh (pow_nonneg hd0.le 126) | |
| calc | |
| _ β€ (d:β)^34*(d:β)^126 := hh' | |
| _ = _ := by rw [β pow_add] | |
| calc | |
| _ β€ 1540*(d:β)^124*(S/(A).total) := hvarS | |
| _ β€ 1540*(d:β)^124*(128*(d:β)^2*(A).chain.energy H) := mul_le_mul_of_nonneg_left hrate (by positivity) | |
| _ = (197120*(d:β)^126)*(A).chain.energy H := by ring | |
| _ β€ _ := mul_le_mul_of_nonneg_right hconst (by rw [hEn]; have hp : 0 β€ proposalRate (32*d^2) := le_trans (by positivity) hq; exact div_nonneg (mul_nonneg (div_nonneg hp (A).total_pos.le) hs) (by norm_num)) | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| open FiniteChain | |
| variable {m n : β} (d C : β) (r : Fin m β β) (c : Fin n β β) | |
| (hempty : EmptyBlock (d^20) r c) | |
| (hrc : (β i,r i)=β j,c j) (hd : 14β€d) (hm : mβ€d) (hn : nβ€d) (hmn : m*nβ€d) | |
| [Nonempty (GraphState (d^20) r c)] | |
| local notation "A" => emptyData (d^20) (d^12) d r c hempty hrc (smallDim_one d hd) hmn | |
| omit [Nonempty (GraphState (d^20) r c)] in | |
| theorem empty_total : (A).total=(graphMass (d^20) (d^12) r c:β) := by | |
| simp [AcceptedData.total,emptyData,graphMass,Nat.cast_sum] | |
| theorem empty_mixing (hC2 : 2β€C) (hU : d^20β€C) | |
| (hC : β i,paddedRow (d^20) (d^12) r c iβ€C) (t : β) (X : GraphState (d^20) r c) : | |
| ((A).chain.walk X t).tv (A).chain.invariantβ€ | |
| (C+1:β)^(2*d)*Real.exp (-(t:β)/(d:β)^160) := by | |
| rw [Chain.walk_tv] | |
| have hk : (1:β)β€(d:β)^160 := one_le_powβ (by exact_mod_cast smallDim_one d hd) | |
| have hvar := empty_poincare d C r c hempty hrc hd hmn hC2 hC | |
| have hmin (Y : GraphState (d^20) r c) : 1/(C+1:β)^(2*d)β€(A).chain.Ο Y := by | |
| change _β€(weight (d^20) (d^12) r c (graphUnderlying (d^20) r c Y):β)/(A).total | |
| rw [empty_total d r c hempty hrc hd hmn] | |
| exact stationary_lower (d^20) (d^12) C r c d hrc hmn hU hC Y | |
| have hh := (A).chain.mixing_bound_min ((d:β)^160) hk hvar | |
| (1/(C+1:β)^(2*d)) (by positivity) hmin t X | |
| simpa only [one_div,inv_inv] using hh | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency | |
| noncomputable section | |
| namespace DyadicLaw | |
| open FiniteChain | |
| variable {Ξ± : Type*} [Fintype Ξ±] [DecidableEq Ξ±] | |
| theorem walk_toLaw_chain (q : Ξ± β DyadicLaw Ξ±) (S : β) (hS : β x,(q x).bits=S) | |
| (C : Chain Ξ±) (hq : β x,(q x).toLaw=C.transition x) (xβ : Ξ±) (t : β) : | |
| (walk q S hS xβ t).toLaw=C.walk xβ t := by | |
| induction t with | |
| | zero => exact toLaw_pure _ _ | |
| | succ t ih => | |
| rw [walk,toLaw_bind,Chain.walk,ih] | |
| congr 1 | |
| funext x | |
| exact hq x | |
| end DyadicLaw | |
| end | |
| end Contingency | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| open FiniteChain | |
| variable {m n : β} (U L d : β) (r : Fin m β β) (c : Fin n β β) | |
| (hempty : EmptyBlock U r c) (hrc : (β i,r i)=β j,c j) | |
| (hd : 1 β€ d) (hmn : m*n β€ d) | |
| local notation "Comp" => fun X : GraphState U r c => Completion U L r c (graphUnderlying U r c X) | |
| local instance outerAccuracyEmptyTrialCompletionFintype (X : GraphState U r c) : | |
| Fintype (Comp X) := Fintype.ofFinite _ | |
| local instance (X : GraphState U r c) : DecidableEq (Comp X) := Classical.decEq _ | |
| local instance outerAccuracyEmptyTrialTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ | |
| theorem smallProposal_bits (X : GraphState U r c) : | |
| (smallProposal U d r c hd hmn X).bits=Nat.clog 2 (32*d^2) := rfl | |
| theorem proposal_pad_bound (S : β) (X : GraphState U r c) : | |
| (smallProposal U d r c hd hmn X).bits β€ Nat.clog 2 (32*d^2)+S := by | |
| rw [smallProposal_bits] | |
| omega | |
| theorem completion_pure_bits (S : β) (X : GraphState U r c) (A : Comp X) : | |
| (DyadicLaw.pure A S).bits=S := rfl | |
| def emptyTransition (S : β) (X : GraphState U r c) : DyadicLaw (GraphState U r c) := | |
| (smallProposal U d r c hd hmn X).pad (Nat.clog 2 (32*d^2)+S) (proposal_pad_bound U d r c hd hmn S X) | |
| theorem emptyTransition_bits (S : β) (X : GraphState U r c) : | |
| (emptyTransition U d r c hd hmn S X).bits=Nat.clog 2 (32*d^2)+S := rfl | |
| variable [Nonempty (GraphState U r c)] | |
| theorem emptyTransition_toLaw (S : β) (X : GraphState U r c) : | |
| (emptyTransition U d r c hd hmn S X).toLaw = (emptyData U L d r c hempty hrc hd hmn).chain.transition X := by | |
| classical | |
| rw [emptyTransition,DyadicLaw.toLaw_pad] | |
| apply Law.ext_offdiag _ _ X | |
| intro Y hXY | |
| rw [DyadicLaw.neighborProposal_offdiag] | |
| simp only [Chain.transition,AcceptedData.chain_P,AcceptedData.kernel,ite_eq_right hXY] | |
| change _=(proposalRate (32*d^2)*emptyCount U r c X Y)/weight U L r c (graphUnderlying U r c X) | |
| rw [empty_weight U L r c hempty hrc X] | |
| simp only [Nat.cast_one,div_one,emptyCount,proposalRate] | |
| ring | |
| exact hXY | |
| def emptyWalk (S : β) (Xβ : GraphState U r c) (t : β) : DyadicLaw (GraphState U r c) := by | |
| classical | |
| exact DyadicLaw.walk (emptyTransition U d r c hd hmn S) (Nat.clog 2 (32*d^2)+S) (emptyTransition_bits U d r c hd hmn S) Xβ t | |
| theorem emptyWalk_toLaw (S : β) (Xβ : GraphState U r c) (t : β) : | |
| (emptyWalk U d r c hd hmn S Xβ t).toLaw=(emptyData U L d r c hempty hrc hd hmn).chain.walk Xβ t := by | |
| classical | |
| exact DyadicLaw.walk_toLaw_chain _ _ _ _ (emptyTransition_toLaw U L d r c hempty hrc hd hmn S) Xβ t | |
| theorem empty_invariant_joint : | |
| letI := tables_nonempty r c hrc | |
| letI : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance | |
| (emptyData U L d r c hempty hrc hd hmn).chain.invariant.sigma | |
| (idealCompletion U L r c hrc)=Law.uniform (Joint U L r c) := by | |
| classical | |
| let := tables_nonempty r c hrc | |
| let : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance | |
| apply Law.ext; funext β¨X,Aβ© | |
| simp only [Law.sigma,Chain.invariant,AcceptedData.chain,emptyData,idealCompletion,Law.uniform] | |
| have htotal : (β X : GraphState U r c,(weight U L r c (graphUnderlying U r c X):β))=(graphMass U L r c:β) := by | |
| simp [graphMass,Nat.cast_sum] | |
| change (weight U L r c (graphUnderlying U r c X):β)/ | |
| (β X : GraphState U r c,(weight U L r c (graphUnderlying U r c X):β)) * | |
| (1/(Fintype.card (Comp X):β)) = 1/(Fintype.card (Joint U L r c):β) | |
| rw [htotal,β Nat.card_eq_fintype_card,β Nat.card_eq_fintype_card,joint_card] | |
| have he : weight U L r c (graphUnderlying U r c X)=Nat.card (Comp X) := by | |
| rw [weight,ite_eq_left (graph_feasible U r c X)] | |
| rw [β he] | |
| have hp : (weight U L r c (graphUnderlying U r c X):β)β 0 := by | |
| exact_mod_cast (graph_weight_pos U L r c X hrc).ne' | |
| field_simp | |
| def emptyTrial (S : β) (fallbacks : β X,Comp X) (Xβ : GraphState U r c) (t : β) : DyadicLaw (Option (Tables r c)) := by | |
| classical | |
| exact ((emptyWalk U d r c hd hmn S Xβ t).sigma (fun X => DyadicLaw.pure (fallbacks X) S) S (fun X => completion_pure_bits U L r c S X (fallbacks X))).map (decodeJoint r c U L) | |
| omit [Nonempty (GraphState U r c)] in | |
| theorem emptyTrial_bits (S : β) (fallbacks : β X,Comp X) (Xβ : GraphState U r c) (t : β) : | |
| (emptyTrial U L d r c hd hmn S fallbacks Xβ t).bits=t*(Nat.clog 2 (32*d^2)+S)+S := by | |
| classical | |
| simp only [emptyTrial,DyadicLaw.map_bits,DyadicLaw.sigma_bits,emptyWalk,DyadicLaw.walk_bits] | |
| include hempty in | |
| omit [Nonempty (GraphState U r c)] in | |
| theorem empty_completion_law (S : β) (X : GraphState U r c) (fallback : Comp X) : | |
| (DyadicLaw.pure fallback S).toLaw=idealCompletion U L r c hrc X := by | |
| let := empty_completion_subsingleton U L r c hempty (graphUnderlying U r c X) | |
| let := completion_nonempty U L r c X hrc | |
| rw [DyadicLaw.toLaw_pure] | |
| apply Law.ext | |
| funext x | |
| have hx : x=fallback := Subsingleton.elim _ _ | |
| subst x | |
| simp only [Law.pure,idealCompletion,Law.uniform] | |
| rw [β Nat.card_eq_fintype_card,Nat.card_unique] | |
| norm_num | |
| theorem emptyTrial_tv (S : β) (fallbacks : β X,Comp X) (Xβ : GraphState U r c) (t : β) : | |
| letI := tables_nonempty r c hrc | |
| (emptyTrial U L d r c hd hmn S fallbacks Xβ t).toLaw.tv (stationaryTrial r c U L) β€ | |
| ((emptyData U L d r c hempty hrc hd hmn).chain.walk Xβ t).tv (emptyData U L d r c hempty hrc hd hmn).chain.invariant := by | |
| classical | |
| let := tables_nonempty r c hrc | |
| unfold emptyTrial stationaryTrial | |
| rw [DyadicLaw.toLaw_map,DyadicLaw.toLaw_sigma,emptyWalk_toLaw U L d r c hempty hrc hd hmn, | |
| β empty_invariant_joint U L d r c hempty hrc hd hmn] | |
| simp only [empty_completion_law U L r c hempty hrc] | |
| apply (Law.tv_map _ _ _).trans | |
| have hh := Law.tv_sigma ((emptyData U L d r c hempty hrc hd hmn).chain.walk Xβ t) | |
| (emptyData U L d r c hempty hrc hd hmn).chain.invariant (idealCompletion U L r c hrc) | |
| (idealCompletion U L r c hrc) 0 (fun _ => by simp [Law.tv_self]) | |
| simpa using hh | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency.PaddedGraph | |
| noncomputable section | |
| open FiniteChain | |
| variable {m n : β} (d b k C : β) (r : Fin m β β) (c : Fin n β β) | |
| (hempty : EmptyBlock (d^20) r c) (hrc : (β i,r i)=β j,c j) | |
| (hd : 14 β€ d) (hm : m β€ d) (hn : n β€ d) (hmn : m*n β€ d) | |
| [Nonempty (GraphState (d^20) r c)] | |
| local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) | |
| local instance outerAccuracyEmptyOuterCompletionFintype (X : GraphState (d^20) r c) : | |
| Fintype (Comp X) := Fintype.ofFinite _ | |
| local instance outerAccuracyEmptyOuterTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ | |
| def emptyOuter (fallbacks : β X,Comp X) (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : DyadicLaw (Tables r c) := by | |
| classical | |
| exact stoppedLaw (emptyTrial (d^20) (d^12) d r c (smallDim_one d hd) hmn (Schedule.RD d b k) | |
| fallbacks Xβ (Schedule.T d b k)) fallback (Schedule.Jo d k) | |
| omit [Nonempty (GraphState (d^20) r c)] in | |
| theorem emptyOuter_bits (fallbacks : β X,Comp X) (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : | |
| (emptyOuter d b k r c hd hmn fallbacks Xβ fallback).bits=Schedule.R d b k := by | |
| classical | |
| change (emptyTrial _ _ _ _ _ _ _ _ _ _ _).bits*Schedule.Jo d k=_ | |
| rw [emptyTrial_bits] | |
| unfold Schedule.R Schedule.RT Schedule.qs | |
| ring | |
| include hempty hm hn in | |
| theorem emptyOuter_tv (hb : d β€ b) (hk : 1 β€ k) (hC2 : 2 β€ C) (hU : d^20 β€ C) | |
| (hC : β i,paddedRow (d^20) (d^12) r c i β€ C) (hCb : C+1 β€ 2^b) | |
| (fallbacks : β X,Comp X) (Xβ : GraphState (d^20) r c) (fallback : Tables r c) : | |
| letI := tables_nonempty r c hrc | |
| (emptyOuter d b k r c hd hmn fallbacks Xβ fallback).toLaw.tv (Law.uniform (Tables r c)) β€ (2:β)^(-(k:β€)) := by | |
| classical | |
| let := tables_nonempty r c hrc | |
| let p := emptyTrial (d^20) (d^12) d r c (smallDim_one d hd) hmn (Schedule.RD d b k) fallbacks Xβ (Schedule.T d b k) | |
| let s := stationaryTrial r c (d^20) (d^12) | |
| have ht := emptyTrial_tv (d^20) (d^12) d r c hempty hrc (smallDim_one d hd) hmn (Schedule.RD d b k) fallbacks Xβ (Schedule.T d b k) | |
| have hmix := empty_mixing d C r c hempty hrc hd hmn hC2 hU hC (Schedule.T d b k) Xβ | |
| have hfirst := Law.first_tv p.toLaw s fallback (Schedule.Jo d k) | |
| have hideal := Law.first_ideal_tv s fallback (Law.uniform (Tables r c)) (stationaryTrial_uniform r c (d^20) (d^12)) (Schedule.Jo d k) | |
| have hfail := stationary_failure_power d r c hrc hd hm hn hmn (Schedule.Jo d k) | |
| have htri := Law.tv_triangle (Law.first p.toLaw fallback (Schedule.Jo d k)) (Law.first s fallback (Schedule.Jo d k)) (Law.uniform (Tables r c)) | |
| have hmul := mul_le_mul_of_nonneg_left (ht.trans hmix) (Nat.cast_nonneg (Schedule.Jo d k)) | |
| have htotal := Schedule.outer_error_schedule d b k hd hb hk C hCb | |
| have hnerr : 0 β€ (Schedule.Jo d k:β)*((Schedule.T d b k:β)+1)*(2:β)^(-(Schedule.h d b k:β€)) := by positivity | |
| unfold emptyOuter | |
| rw [stoppedLaw_toLaw] | |
| change (Law.first p.toLaw fallback (Schedule.Jo d k)).tv _ β€ _ | |
| change _β€_ at hfail | |
| dsimp only [p,s] at hfirst hideal htri | |
| dsimp only [p] | |
| rw [neg_div] at hmul | |
| nlinarith only [hfirst,hideal,hfail,htri,hmul,htotal,hnerr] | |
| end | |
| end Contingency.PaddedGraph | |
| open scoped BigOperators | |
| namespace Contingency | |
| namespace Parameters | |
| def dim (m n : β) : β := 10+(m+1)*(n+1) | |
| def L (m n : β) : β := dim m n^12 | |
| def U (m n : β) : β := dim m n^20 | |
| def cap (m n N : β) : β := N+dim m n*L m n+U m n+2 | |
| def bits (m n N : β) : β := dim m n+Nat.clog 2 (cap m n N+2) | |
| theorem dimensions {m n : β} (hm : 0 < m) (hn : 0 < n) : | |
| 14 β€ dim m n β§ m β€ dim m n β§ n β€ dim m n β§ m*n β€ dim m n := by | |
| unfold dim | |
| have hh : 4 β€ (m+1)*(n+1) := by nlinarith | |
| refine β¨by omega, ?_, ?_, ?_β© <;> nlinarith | |
| theorem cap_pos (m n N : β) : 2 β€ cap m n N := by unfold cap; omega | |
| theorem threshold_le_cap (m n N : β) : U m n β€ cap m n N := by unfold cap; omega | |
| theorem dimension_le_bits (m n N : β) : dim m n β€ bits m n N := by unfold bits; omega | |
| theorem cap_pow_bits (m n N : β) : cap m n N+1 β€ 2^bits m n N := by | |
| have h := Nat.le_pow_clog (by norm_num : 1 < 2) (cap m n N+2) | |
| apply (show cap m n N+1 β€ cap m n N+2 by omega).trans | |
| apply h.trans | |
| exact Nat.pow_le_pow_right (by norm_num) (by unfold bits; omega) | |
| theorem paddedRow_le_cap {m n : β} (r : Fin m β β) (c : Fin n β β) (i : Fin m) : | |
| PaddedGraph.paddedRow (U m n) (L m n) r c i β€ cap m n (β i,r i) := by | |
| have hi : r i β€ β i,r i := Finset.single_le_sum (fun j _ => Nat.zero_le (r j)) (Finset.mem_univ i) | |
| have hn : n β€ dim m n := by unfold dim; nlinarith | |
| have hp : PaddedGraph.rowPadding (U m n) (L m n) r c i β€ (n:β€)*(L m n:β€) := by | |
| unfold PaddedGraph.rowPadding | |
| calc | |
| _ β€ β _j : Fin n,(L m n:β€) := Finset.sum_le_sum (fun j _ => by split_ifs <;> simp) | |
| _ = _ := by simp | |
| have hn' : (n:β€) β€ dim m n := by exact_mod_cast hn | |
| have hi' : (r i:β€) β€ (β i,r i:β) := by exact_mod_cast hi | |
| have hx := mul_le_mul_of_nonneg_right hn' (Int.natCast_nonneg (L m n)) | |
| unfold PaddedGraph.paddedRow cap | |
| push_cast at hi' β’ | |
| omega | |
| end Parameters | |
| end Contingency | |
| namespace Contingency.Parameters | |
| theorem bits_le (m n N : β) : bits m n N β€ 21*dim m n+Nat.log2 (N+1)+4 := by | |
| let d := dim m n | |
| let B := 20*d+Nat.log2 (N+1)+1 | |
| have hd : d β€ 2^d := Nat.lt_two_pow_self.le | |
| have h13 : d^13 β€ 2^(20*d) := by | |
| calc | |
| _ β€ (2^d)^13 := Nat.pow_le_pow_left hd _ | |
| _ = 2^(d*13) := (pow_mul _ _ _).symm | |
| _ β€ _ := Nat.pow_le_pow_right (by norm_num) (by omega) | |
| have h20 : d^20 β€ 2^(20*d) := by | |
| calc | |
| _ β€ (2^d)^20 := Nat.pow_le_pow_left hd _ | |
| _ = 2^(20*d) := by rw [β pow_mul]; congr 1; omega | |
| have hN : N β€ 2^(Nat.log2 (N+1)+1) := by | |
| have hh := Nat.lt_pow_succ_log_self (by norm_num : 1<2) (N+1) | |
| rw [β Nat.log2_eq_log_two] at hh | |
| omega | |
| have hpow : 2^(20*d) β€ 2^B := Nat.pow_le_pow_right (by norm_num) (by dsimp [B]; omega) | |
| have hpow' : 2^(Nat.log2 (N+1)+1) β€ 2^B := Nat.pow_le_pow_right (by norm_num) (by dsimp [B]; omega) | |
| have hpos : 1 β€ 2^B := Nat.one_le_pow _ _ (by norm_num) | |
| have hcap : cap m n N+2 β€ 2^(B+3) := by | |
| have h := h13.trans hpow | |
| have h' := h20.trans hpow | |
| have h'' := hN.trans hpow' | |
| have he : cap m n N+2=N+d^13+d^20+4 := by | |
| unfold cap L U | |
| dsimp only [d] | |
| rw [pow_succ] | |
| ring | |
| rw [he,pow_add] | |
| norm_num | |
| omega | |
| have hc : Nat.clog 2 (cap m n N+2) β€ B+3 := | |
| (Nat.clog_le_iff_le_pow (by norm_num)).mpr hcap | |
| unfold bits | |
| dsimp [B,d] at hc | |
| omega | |
| theorem dim_le_size_square (m n N : β) : dim m n β€ (inputSize m n N+3)^2 := by | |
| unfold dim inputSize | |
| nlinarith [Nat.zero_le (Nat.log2 (N+1))] | |
| end Contingency.Parameters | |
| end | |
| end OAI | |