Download data/lean/OAI/Probability/LogConcave/Numerics/CompileDeclaredRootShift.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.93 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Numerics/CompileDeclaredRootShift.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/Numerics/CompileDeclaredRootShift.lean
-
curl -L -o CompileDeclaredRootShift.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/Numerics/CompileDeclaredRootShift.lean
5.93 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.Numerics.Cost | |
| namespace OAI | |
| section | |
| noncomputable section | |
| namespace LogConcaveSampling.MeanTree | |
| open MeasureTheory OracleCompiler OracleCompiler.Expression SeedCompiler | |
| open scoped Classical BigOperators | |
| variable {X : Type*} [MeasurableSpace X] {d : β} | |
| def compileDeclaredRootShift (D A Af : β) (Mf Mi : β β β β SeedProgram d) : | |
| (E : MeanTree X d) β (n : β) β DriftData E β Fin (compileDeclaredRoot D A Af Mf Mi E n).slots β β | |
| | .node k b hb a r C,n,p => | |
| compileTermsShift D k a (fun i => compileDeclared D A Mi (C i) (r i/(2*D))) | |
| (fun i => Mf (r i) (declaredNoise n Af)) (.noise b hb (declaredReserve n Af a)) | |
| (fun i => compileDeclaredShift D A Mi (C i) (r i/(2*D)) (p.2 i)) | |
| (fun i => inverseChildShift D (r i) ((p.2 i).root (C i)) (Mf (r i) (declaredNoise n Af))) | |
| (fun _ => 0) | |
| def RootShiftReady (D A Af : β) (Pf Pi : β β β β Prop) : MeanTree X d β β β Prop | |
| | .node _ _ _ _ r C,n => βi,r iβ 0 β§ Pf (r i) (declaredNoise n Af) β§ ShiftReady D A Pi (C i) (r i/(2*D)) | |
| theorem compileDeclaredRoot_equivariant (D A Af : β) (hD : 0<D) | |
| (P : Bool β β β β β Prop) (M : Bool β β β β β SeedProgram d) | |
| (hv : βs r Ο,P s r Ο β (βj,(M s r Ο).shift j^2) β€ D^2) | |
| (hM : βs r Ο,P s r Ο β βΞ,(M s r Ο).program.Equivariant | |
| (moveSeed (fun x => x+r β’ Ξ) (M s r Ο).shift Ξ) id) | |
| (f : Point d β X β X) (E : MeanTree X d) (n : β) (p : DriftData E) | |
| (hp : DriftValid f E p) (hr : RootShiftReady D A Af (P true) (P false) E n) : | |
| βΞ,(compileDeclaredRoot D A Af (M true) (M false) E n).compile.Equivariant | |
| (moveSeed (f Ξ) (compileDeclaredRootShift D A Af (M true) (M false) E n p) Ξ) | |
| (fun y => y+p.root E β’ Ξ) := by | |
| cases E with | node k b hb a r C => | |
| intro Ξ | |
| apply compileTerms_equivariant | |
| Β· intro i | |
| exact compileDeclared_equivariant D A hD (P false) (M false) (hv false) (hM false) | |
| f (C i) (r i/(2*D)) (p.2 i) (hp.2 i) (hr i).2.2 Ξ | |
| Β· intro i | |
| exact transformed_mean_equivariant (M true (r i) (declaredNoise n Af)).program | |
| (hr i).1 _ _ ((normalized_shift_bound hD _ (hv _ _ _ (hr i).2.1)).trans_lt (by norm_num)) | |
| (hM _ _ _ (hr i).2.1) ((p.2 i).root (C i)) Ξ | |
| Β· exact noise_equivariant b hb _ p.1 (f Ξ) Ξ (hp.1 Ξ) | |
| theorem compileDeclaredRoot_size (D A Af : β) | |
| (P : Bool β β β β β Prop) (M : Bool β β β β β SeedProgram d) | |
| (S Q : β) (hM : βs r Ο,P s r Ο β (M s r Ο).slots β€ S β§ (M s r Ο).calls β€ Q) | |
| (E : MeanTree X d) (n : β) (hr : RootShiftReady D A Af (P true) (P false) E n) : | |
| (compileDeclaredRoot D A Af (M true) (M false) E n).slots β€ 1+cost E*(S+1) β§ | |
| (compileDeclaredRoot D A Af (M true) (M false) E n).calls β€ cost E*Q := by | |
| cases E with | node k b hb a r C => | |
| have hc (i) := compileDeclared_size D A (P false) (M false) S Q (hM false) (C i) (r i/(2*D)) (hr i).2.2 | |
| have hm (i) := hM true (r i) (declaredNoise n Af) (hr i).2.1 | |
| constructor | |
| Β· simp only [compileDeclaredRoot,slots_compileTerms,Expression.slots,cost] | |
| apply Nat.add_le_add_left | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| have hβ := (hc i).1 | |
| have hβ := (hm i).1 | |
| nlinarith | |
| Β· simp only [compileDeclaredRoot,calls_compileTerms,Expression.calls,zero_add,cost,Finset.sum_mul] | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| have hβ := (hc i).2 | |
| have hβ := (hm i).2 | |
| nlinarith | |
| theorem compileDeclaredRootShift_energy_bound {D A Af R B : β} (hD : 0<D) (hR : 0β€R) (hB : 0β€B) | |
| (P : Bool β β β β β Prop) (M : Bool β β β β β SeedProgram d) | |
| (hv : βs r Ο,P s r Ο β (βj,(M s r Ο).shift j^2) β€ D^2) | |
| (hBv : βs r Ο,P s r Ο β (βj,(M s r Ο).shift j^2) β€ B) | |
| (E : MeanTree X d) (n : β) (p : DriftData E) | |
| (hr : RootShiftReady D A Af (P true) (P false) E n) (hg : DriftBound R E p) : | |
| (βj,compileDeclaredRootShift D A Af (M true) (M false) E n p j^2) β€ (cost E:β)*(4*R^2*B) := by | |
| cases E with | node k b hb a r C => | |
| change (βj,compileTermsShift D k a (fun i => compileDeclared D A (M false) (C i) (r i/(2*D))) | |
| (fun i => M true (r i) (declaredNoise n Af)) (.noise b hb (declaredReserve n Af a)) | |
| (fun i => compileDeclaredShift D A (M false) (C i) (r i/(2*D)) (p.2 i)) | |
| (fun i => inverseChildShift D (r i) ((p.2 i).root (C i)) (M true (r i) (declaredNoise n Af))) | |
| (fun _ => 0) j^2) β€ _ | |
| rw [compileTermsShift_energy] | |
| simp only [zero_pow (by decide : (2:β)β 0),Finset.sum_const_zero,zero_add,cost,Nat.cast_sum,Nat.cast_add,Nat.cast_one,Finset.sum_mul] | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| have hc := compileDeclaredShift_energy_bound hD hR hB (P false) (M false) (hv false) (hBv false) | |
| (C i) (r i/(2*D)) (p.2 i) (hr i).2.2 (hg i).2 | |
| have hi := inverse_shift_energy (fun j => (M true (r i) (declaredNoise n Af)).shift j/(2*D)) | |
| (M true (r i) (declaredNoise n Af)).shift (normalized_shift_bound hD _ (hv _ _ _ (hr i).2.1)) | |
| (((p.2 i).root (C i))/(r i)) | |
| have hs := hBv _ _ _ (hr i).2.1 | |
| have hh : (((p.2 i).root (C i))/(r i))^2 β€ R^2 := by | |
| simpa only [sq_abs] using pow_le_pow_leftβ (abs_nonneg _) (hg i).1 2 | |
| have hm := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hh (by norm_num : (0:β)β€4)) hB | |
| have hv' := mul_le_mul_of_nonneg_left hs (show 0β€4*(((p.2 i).root (C i))/(r i))^2 by positivity) | |
| change (βj,compileDeclaredShift D A (M false) (C i) (r i/(2*D)) (p.2 i) j^2)+ | |
| (βj,inverseChildShift D (r i) ((p.2 i).root (C i)) (M true (r i) (declaredNoise n Af)) j^2) β€ _ | |
| change (βj,inverseChildShift D (r i) ((p.2 i).root (C i)) (M true (r i) (declaredNoise n Af)) j^2) β€ _ at hi | |
| nlinarith | |
| end LogConcaveSampling.MeanTree | |
| end | |
| end | |
| end OAI | |