Download data/lean/OAI/Combinatorics/ContingencyTables/Counting/CompanionConcentration.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.46 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Counting/CompanionConcentration.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/ContingencyTables/Counting/CompanionConcentration.lean
-
curl -L -o CompanionConcentration.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Counting/CompanionConcentration.lean
8.46 kB
| import OAI.Combinatorics.ContingencyTables.Counting.CompanionMultiplierUpdate | |
| import OAI.Combinatorics.ContingencyTables.Transport.ObservableTrajectory | |
| namespace OAI | |
| /-! # Concentration of the literal companion phase observables -/ | |
| namespace ContingencyTables.CompanionConcentration | |
| open scoped BigOperators Classical | |
| open CommonBasesFPRAS CompanionFactorialApplication CompanionAnnealing CompanionMultiplierUpdate | |
| open TwoLiftStates BinaryContraction DegreeCompletion ObservableBounds | |
| variable {I J : Type*} [Fintype I] [Fintype J] | |
| private lemma observable_constant_nonnegative (p q : β) (hp : 0 β€ p) (hq : 0 β€ q) : | |
| 0 β€ observableConstant p q := by | |
| unfold observableConstant | |
| positivity | |
| private lemma bounded_variance_factor (p K v N : β) (hK : 0 β€ K) | |
| (hN : 0 β€ N) (hv : v β€ 1) : | |
| 2*(10*p^2)*K*v/N β€ 20*p^2*K/N := by | |
| apply div_le_div_of_nonneg_right _ hN | |
| nlinarith [mul_le_mul_of_nonneg_left hv (show 0 β€ 2*(10*p^2)*K by positivity)] | |
| lemma pairs_ne_nil (A : Instance I J) (hp : 0< Fintype.card (Labels A)) : | |
| (pairs : List ((Labels AΓBool)Γ(Labels AΓBool)))β [] := by | |
| apply List.ne_nil_of_length_pos | |
| simpa only [PairedLabels.length] using hp | |
| lemma actual_degree (A : Instance I J) (j : β) : | |
| DegreePositive (weight A j) (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))).length β§ | |
| OmissionProperty (weight A j) (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))).length := by | |
| have hs := first_properties A ((j:β)/scale A) (div_nonneg (Nat.cast_nonneg j) (scale_positive A).le) | |
| simpa only [weight,PairedLabels.length] using hs | |
| lemma square_width_one_le (A : Instance I J) : (1:β)β€(A.W:β)^2 := by | |
| have hW : (2:β)β€ A.W := by exact_mod_cast A.hW | |
| nlinarith | |
| /-- Every actual phase observable has the source's mean-square bound | |
| 20 pΒ² Kobs/N under a 10 pΒ²-warm start of its original labelled chain. -/ | |
| theorem bounded_MSE (A : Instance I J) (j : β) (hp : 0< Fintype.card (Labels A)) | |
| (w : ((Labels AΓBool)Γ(Labels AΓBool)) β ((Labels AΓBool)Γ(Labels AΓBool)) β β) | |
| (hw : GoodMultipliers pairs (weight A j) w) (o : PhaseObservables (pairs : List ((Labels AΓBool)Γ(Labels AΓBool)))) | |
| (nu : ChainIndex (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))) β β) | |
| (hwarm : β S,nu Sβ€(10*(Fintype.card (Labels A):β)^2)* | |
| chainWeight pairs w (weight A j) S.val/chainTotal pairs w (weight A j)) | |
| (N : β) (hN : 0< N) : | |
| let C := metropolisChain pairs PairedLabels.fresh (pairs_ne_nil A hp) PairedLabels.cover w | |
| (completeDegree (weight A j) (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))).length) | |
| hw.positive (completeDegree_positive _ _ (actual_degree A j).1) | |
| let G := fun S : ChainIndex (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))) => | |
| phaseObservable pairs (ratio A j) o S.val | |
| (β S,nu S*C.squareMoment (fun S => G S-C.mean G) N S)/(N:β)^2β€ | |
| 20*(Fintype.card (Labels A):β)^2* | |
| ObservableBounds.observableConstant (Fintype.card (Labels A)) ((A.W:β)^2)/N := by | |
| let gs : List ((Labels AΓBool)Γ(Labels AΓBool)) := pairs | |
| let F := completeDegree (weight A j) gs.length | |
| have hF := completeDegree_positive (weight A j) gs.length (actual_degree A j).1 | |
| let C := metropolisChain gs PairedLabels.fresh (pairs_ne_nil A hp) PairedLabels.cover w F hw.positive hF | |
| let G : Set (Labels AΓBool) β β := phaseObservable gs (ratio A j) o | |
| have hG : β S,0β€ G S β§ G Sβ€1 := by | |
| intro S | |
| exact phaseObservable_bounded gs (ratio A j) | |
| (fun T _ => β¨by linarith [(ratio_bounds A j T).1],(ratio_bounds A j T).2β©) o S | |
| have h := ObservableTrajectory.omission_chain_timeAverage gs PairedLabels.fresh (pairs_ne_nil A hp) | |
| PairedLabels.cover w (weight A j) G hw.positive (actual_degree A j).1 (actual_degree A j).2 | |
| ((A.W:β)^2) (square_width_one_le A) (phaseObservable_class gs (ratio A j) o) | |
| hw.lower hw.upper (10*(Fintype.card (Labels A):β)^2) (by positivity) nu hwarm N hN | |
| have hv := C.variance_le_one (fun S => G S.val) (fun S => hG S.val) | |
| change C.variance (fun S => G S.val)β€1 at hv | |
| rw [metropolisChain_variance,chainVariance_completion gs (weight A j) G w | |
| PairedLabels.fresh PairedLabels.cover] at hv | |
| have hm : C.mean (fun S => G S.val)=chainMean gs w (weight A j) G := by | |
| rw [metropolisChain_mean,chainMean_completion gs (weight A j) G w | |
| PairedLabels.fresh PairedLabels.cover] | |
| change (β S,nu S*C.squareMoment (fun S => G S.val-C.mean (fun T => G T.val)) N S)/(N:β)^2β€ _ | |
| rw [hm] | |
| calc | |
| _ β€ 2*(10*(Fintype.card (Labels A):β)^2)*ObservableBounds.observableConstant gs.length ((A.W:β)^2)* | |
| chainVariance gs w (weight A j) G/N := h | |
| _ β€ 20*(Fintype.card (Labels A):β)^2*observableConstant gs.length ((A.W:β)^2)/N := | |
| bounded_variance_factor _ _ _ _ | |
| (observable_constant_nonnegative _ _ (Nat.cast_nonneg _) (sq_nonneg _)) (Nat.cast_nonneg _) hv | |
| _ = _ := by simp only [gs,PairedLabels.length] | |
| /-- The source's finite union bound for all actual phase observables. | |
| The warm-start hypothesis is the restart endpoint condition, rather than | |
| an independent phase-concentration assumption. -/ | |
| theorem phase_failure (A : Instance I J) (j : β) (hp : 0< Fintype.card (Labels A)) | |
| (w : ((Labels AΓBool)Γ(Labels AΓBool)) β ((Labels AΓBool)Γ(Labels AΓBool)) β β) | |
| (hw : GoodMultipliers pairs (weight A j) w) | |
| (nu : ChainIndex (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))) β β) | |
| (hnu : β S,0β€ nu S) | |
| (hwarm : β S,nu Sβ€(10*(Fintype.card (Labels A):β)^2)* | |
| chainWeight pairs w (weight A j) S.val/chainTotal pairs w (weight A j)) | |
| (N : β) (hN : 0< N) (eta : β) (heta : 0< eta) : | |
| let C := metropolisChain pairs PairedLabels.fresh (pairs_ne_nil A hp) PairedLabels.cover w | |
| (completeDegree (weight A j) (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))).length) | |
| hw.positive (completeDegree_positive _ _ (actual_degree A j).1) | |
| C.pathProbability nu (N-1) (fun l => β o : PhaseObservables (pairs : List ((Labels AΓBool)Γ(Labels AΓBool))), | |
| eta*C.mean (fun S => phaseObservable pairs (ratio A j) o S.val)< | |
| |FiniteChain.pathSum (fun S => phaseObservable pairs (ratio A j) o S.val) l/(N:β)- | |
| C.mean (fun S => phaseObservable pairs (ratio A j) o S.val)|)β€ | |
| 16000*(Fintype.card (Labels A):β)^8* | |
| ObservableBounds.observableConstant (Fintype.card (Labels A)) ((A.W:β)^2)/((N:β)*eta^2) := by | |
| let gs : List ((Labels AΓBool)Γ(Labels AΓBool)) := pairs | |
| let F := completeDegree (weight A j) gs.length | |
| have hF := completeDegree_positive (weight A j) gs.length (actual_degree A j).1 | |
| let C := metropolisChain gs PairedLabels.fresh (pairs_ne_nil A hp) PairedLabels.cover w F hw.positive hF | |
| let p : β := Fintype.card (Labels A) | |
| let K := ObservableBounds.observableConstant (Fintype.card (Labels A)) ((A.W:β)^2) | |
| have hpR : 0< p := by dsimp only [p]; exact_mod_cast hp | |
| have hK : 0β€ K := observable_constant_nonnegative _ _ (Nat.cast_nonneg _) (sq_nonneg _) | |
| have hNR : (0:β)< N := by exact_mod_cast hN | |
| have hmean (o : PhaseObservables gs) : | |
| 1/(20*p^2)β€ C.mean (fun S => phaseObservable gs (ratio A j) o S.val) := by | |
| rw [metropolisChain_mean,chainMean_completion gs (weight A j) | |
| (phaseObservable gs (ratio A j) o) w PairedLabels.fresh PairedLabels.cover] | |
| have hh := phaseObservable_mean_lower gs PairedLabels.fresh (pairs_ne_nil A hp) PairedLabels.cover | |
| w (weight A j) (ratio A j) hw.positive (weight_positive A j) | |
| (fun S _ => (ratio_bounds A j S).1) hw.lower hw.upper o | |
| simpa only [p,gs,PairedLabels.length] using hh | |
| have hb := C.relative_union_bound nu hnu | |
| (fun o S => phaseObservable gs (ratio A j) o S.val) | |
| (1/(20*p^2)) eta (20*p^2*K/N) (by positivity) heta (by positivity) hmean N hN | |
| (fun o => bounded_MSE A j hp w hw o nu hwarm N hN) | |
| have hJ : (Fintype.card (PhaseObservables gs):β)β€2*p^2 := by | |
| have hc := phaseObservables_card gs PairedLabels.fresh (pairs_ne_nil A hp) | |
| simp only [gs,PairedLabels.length] at hc | |
| dsimp only [p,gs] | |
| exact_mod_cast hc | |
| apply hb.trans | |
| calc | |
| _ β€ (2*p^2)*(20*p^2*K/N)/(eta*(1/(20*p^2)))^2 := | |
| div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hJ (by positivity)) (sq_nonneg _) | |
| _ = 16000*p^8*K/((N:β)*eta^2) := by | |
| field_simp [hpR.ne',heta.ne',hNR.ne'] | |
| ring | |
| end ContingencyTables.CompanionConcentration | |
| end OAI | |