Download data/lean/OAI/Probability/LogConcave/OraclePrograms/ReservedProgram.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.58 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/OraclePrograms/ReservedProgram.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LogConcave/OraclePrograms/ReservedProgram.lean
-
curl -L -o ReservedProgram.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LogConcave/OraclePrograms/ReservedProgram.lean
5.58 kB
| import Mathlib | |
| import OAI.Probability.LogConcave.OraclePrograms.Expression | |
| import OAI.Probability.LogConcave.OraclePrograms.SeedProgram | |
| namespace OAI | |
| section | |
| noncomputable section | |
| namespace LogConcaveSampling.OracleCompiler | |
| open MeasureTheory Program Expression | |
| open scoped Classical BigOperators | |
| variable {d : β} | |
| structure ReservedProgram (d : β) where | |
| slots : β | |
| calls : β | |
| pre : Program (Point d Γ (Fin slots β Point d)) d calls (Point d) | |
| shift : Fin slots β β | |
| reserve : β | |
| namespace ReservedProgram | |
| def full (S : ReservedProgram d) : SeedProgram d where | |
| slots := S.slots+1 | |
| calls := S.calls | |
| program := (S.pre.seedMap (fun z : Point d Γ (Fin (S.slots+1) β Point d) => | |
| (z.1,fun i => z.2 (Fin.castAdd 1 i))) (by fun_prop)).map | |
| (fun z => z.2+S.reserve β’ z.1.2 (Fin.natAdd S.slots 0)) (by fun_prop) | |
| shift := Fin.append S.shift (fun _ => 0) | |
| lemma full_run (S : ReservedProgram d) (V : Point d β β) | |
| (x : Point d) (g : Fin (S.slots+1) β Point d) : | |
| S.full.program.run V (x,g)= | |
| S.pre.run V (x,fun i => g (Fin.castAdd 1 i))+S.reserve β’ g (Fin.natAdd S.slots 0) := by | |
| change ((S.pre.seedMap (fun z : Point d Γ (Fin (S.slots+1) β Point d) => | |
| (z.1,fun i => z.2 (Fin.castAdd 1 i))) (by fun_prop)).map | |
| (fun z => z.2+S.reserve β’ z.1.2 (Fin.natAdd S.slots 0)) (by fun_prop)).run V (x,g)=_ | |
| rw [Program.map_run,Program.seedMap_run] | |
| def extraShift (S : ReservedProgram d) (c : β) : Fin (S.slots+1) β β := | |
| Fin.append S.shift (fun _ => c) | |
| lemma full_equivariant (S : ReservedProgram d) (r c : β) (Ξ : Point d) | |
| (hS : S.pre.Equivariant (moveSeed (fun x => x+r β’ Ξ) S.shift Ξ) (fun y => y-Ξ)) : | |
| S.full.program.Equivariant | |
| (moveSeed (fun x => x+r β’ Ξ) (S.extraShift c) Ξ) | |
| (fun y => y-Ξ+(S.reserve*c) β’ Ξ) := by | |
| dsimp only [full] | |
| apply Program.Equivariant.map | |
| (hS.seedMap _ (by fun_prop) _ ?_) _ (by fun_prop) _ | |
| Β· intro z y | |
| simp only [moveSeed,extraShift,shiftSlots,Fin.append_right] | |
| simp only [smul_add,smul_smul] | |
| abel | |
| Β· intro z | |
| apply Prod.ext | |
| Β· rfl | |
| Β· funext i | |
| simp [moveSeed,extraShift,shiftSlots] | |
| lemma extraShift_energy (S : ReservedProgram d) (c : β) : | |
| (βi,S.extraShift c i^2)=(βi,S.shift i^2)+c^2 := by | |
| simp [extraShift,Fin.sum_univ_add] | |
| end ReservedProgram | |
| def sampleParent (E : Expression (Point d Γ Point d) d) (v : Fin E.slots β β) | |
| (T Ξ· : β) : ReservedProgram d where | |
| slots := 1+E.slots | |
| calls := E.calls | |
| pre := E.compile.seedMap (fun z : Point d Γ (Fin (1+E.slots) β Point d) => | |
| ((z.1,z.2 (Fin.castAdd E.slots 0)),fun i => z.2 (Fin.natAdd 1 i))) (by fun_prop) | |
| shift := Fin.append (fun _ => -T) v | |
| reserve := Ξ·/2 | |
| lemma sampleParent_run (E : Expression (Point d Γ Point d) d) (v : Fin E.slots β β) | |
| (T Ξ· : β) (V : Point d β β) (x : Point d) (g : Fin (1+E.slots) β Point d) : | |
| (sampleParent E v T Ξ·).pre.run V (x,g)= | |
| E.eval V (x,g (Fin.castAdd E.slots 0)) (fun i => g (Fin.natAdd 1 i)) := by | |
| change (E.compile.seedMap (fun z : Point d Γ (Fin (1+E.slots) β Point d) => | |
| ((z.1,z.2 (Fin.castAdd E.slots 0)),fun i => z.2 (Fin.natAdd 1 i))) (by fun_prop)).run V (x,g)=_ | |
| rw [Program.seedMap_run,Expression.compile_run] | |
| def meanParent (S : SeedProgram d) | |
| (E : Expression (Point d Γ (Point d Γ Point d)) d) | |
| (u : Fin S.slots β β) (v : Fin E.slots β β) (T : β) : SeedProgram d where | |
| slots := S.slots+(1+E.slots) | |
| calls := S.calls+E.calls | |
| program := | |
| (S.program.seedMap (fun z : Point d Γ (Fin (S.slots+(1+E.slots)) β Point d) => | |
| (z.1,leftBlock z.2)) (by unfold leftBlock; fun_prop)).seq | |
| (E.compile.seedMap (fun z => | |
| ((z.1.1,(T β’ z.2,middleBlock z.1.2 0)),rightBlock z.1.2)) (by unfold middleBlock rightBlock; fun_prop)) | |
| shift := Fin.append u (Fin.append (fun _ => 0) v) | |
| lemma meanParent_run (S : SeedProgram d) | |
| (E : Expression (Point d Γ (Point d Γ Point d)) d) | |
| (u : Fin S.slots β β) (v : Fin E.slots β β) (T : β) | |
| (V : Point d β β) (x : Point d) (g : Fin (S.slots+(1+E.slots)) β Point d) : | |
| (meanParent S E u v T).program.run V (x,g)= | |
| E.eval V (x,(T β’ S.program.run V (x,leftBlock g),middleBlock g 0)) (rightBlock g) := by | |
| change ((S.program.seedMap _ _).seq (E.compile.seedMap _ _)).run V (x,g)=_ | |
| rw [Program.seq_run,Program.seedMap_run,Program.seedMap_run,Expression.compile_run] | |
| lemma meanParent_shift_energy (S : SeedProgram d) | |
| (E : Expression (Point d Γ (Point d Γ Point d)) d) | |
| (u : Fin S.slots β β) (v : Fin E.slots β β) (T : β) : | |
| (βi,(meanParent S E u v T).shift i^2)=(βi,u i^2)+(βi,v i^2) := by | |
| change (βi : Fin (S.slots+(1+E.slots)), (Fin.append u (Fin.append (fun _ => 0) v)) i^2)=_ | |
| simp [Fin.sum_univ_add] | |
| lemma sampleParent_shift_energy (E : Expression (Point d Γ Point d) d) | |
| (v : Fin E.slots β β) (T Ξ· : β) : | |
| (βi,(sampleParent E v T Ξ·).shift i^2)=T^2+(βi,v i^2) := by | |
| change (βi : Fin (1+E.slots), (Fin.append (fun _ => -T) v) i^2)=_ | |
| simp [Fin.sum_univ_add] | |
| lemma mean_anchor_shift_identity {T R : β} (hT : Tβ 0) (he : T^2+R^2=1) | |
| (y Ξ : Point d) : | |
| T β’ (y-Ξ+(R/(2*T)*(-2*R/T)) β’ Ξ)=T β’ y-Tβ»ΒΉ β’ Ξ := by | |
| have ha : T*(-1+R/(2*T)*(-2*R/T))=-Tβ»ΒΉ := by | |
| field_simp | |
| nlinarith | |
| simp only [smul_add,smul_sub,smul_smul] | |
| have hb : T*(R/(2*T)*(-2*R/T))-T=-Tβ»ΒΉ := by nlinarith [ha] | |
| calc | |
| _ = T β’ y+(T*(R/(2*T)*(-2*R/T))-T) β’ Ξ := by module | |
| _ = _ := by rw [hb]; module | |
| end LogConcaveSampling.OracleCompiler | |
| end | |
| end | |
| end OAI | |