Download data/lean/OAI/Probability/Perceptron/Variational/AtomicBranches.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.87 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Variational/AtomicBranches.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Perceptron/Variational/AtomicBranches.lean
-
curl -L -o AtomicBranches.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Variational/AtomicBranches.lean
6.87 kB
| import Mathlib | |
| import OAI.Probability.Perceptron.Cascade.IndexedCascadeRegular | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Set | |
| open scoped ENNReal NNReal BigOperators | |
| namespace SphericalPerceptronFreeEnergy | |
| lemma injective_of_simple_count_map {I A : Type*} [Countable I] | |
| [MeasurableSpace I] [MeasurableSingletonClass I] | |
| [MeasurableSpace A] [MeasurableSingletonClass A] | |
| (p : I β A) (hp : Measurable p) | |
| (hs : βα΅ x β(Measure.count.map p), (Measure.count.map p) {x} = 1) : | |
| Function.Injective p := by | |
| classical | |
| have h : β i, (Measure.count.map p) {p i} = 1 := | |
| Measure.ae_count_iff.mp (ae_of_ae_map hp.aemeasurable hs) | |
| intro i j hij | |
| by_contra hn | |
| have hle : (Measure.count : Measure I) {i,j} β€ 1 := by | |
| rw [β h i,Measure.map_apply hp (measurableSet_singleton _)] | |
| apply measure_mono | |
| intro k hk | |
| rcases hk with rfl | hk | |
| Β· rfl | |
| Β· simpa only [mem_singleton_iff] using hk βΈ hij.symm | |
| have htwo : (Measure.count : Measure I) {i,j} = 2 := by | |
| have he : (β({i,j} : Finset I) : Set I) = {i,j} := by ext k; simp | |
| rw [β he,Measure.count_apply_finset] | |
| simp [hn] | |
| rw [htwo] at hle | |
| norm_num at hle | |
| lemma markedStableMassKernel_count_map {I S : Type*} [Countable I] | |
| [MeasurableSpace I] [MeasurableSingletonClass I] [MeasurableSpace S] | |
| (p : I β βΓS) (hp : Measurable p) : | |
| markedStableMassKernel (Measure.count.map p) = | |
| (normalizedMeasure (Measure.count.withDensity | |
| (fun i => ENNReal.ofReal (Real.exp (p i).1)))).map p := by | |
| rw [normalizedMeasure_map _ hp] | |
| change normalizedMeasure ((Measure.count.map p).withDensity | |
| (fun t : βΓS => ENNReal.ofReal (Real.exp t.1))) = _ | |
| rw [map_withDensity_comp Measure.count hp (by fun_prop)] | |
| rfl | |
| lemma stableMassKernel_count_map_atom {I S : Type*} [Countable I] | |
| [MeasurableSpace I] [MeasurableSingletonClass I] [MeasurableSpace S] | |
| (p : I β βΓS) (hp : Measurable p) (hinj : Function.Injective (fun i => (p i).1)) | |
| (i : I) : | |
| stableMassKernel ((Measure.count.map p).map Prod.fst) {(p i).1} = | |
| ((β' j, ENNReal.ofReal (Real.exp (p j).1))β»ΒΉ) * | |
| ENNReal.ofReal (Real.exp (p i).1) := by | |
| rw [Measure.map_map measurable_fst hp] | |
| change normalizedMeasure ((Measure.count.map (fun j => (p j).1)).withDensity | |
| (fun x => ENNReal.ofReal (Real.exp x))) {(p i).1} = _ | |
| have hp' : Measurable (fun j => (p j).1) := hp.fst | |
| rw [map_withDensity_comp Measure.count hp' (by fun_prop), | |
| β normalizedMeasure_map _ hp', | |
| Measure.map_apply hp' (measurableSet_singleton _)] | |
| have hpre : (fun j => (p j).1) β»ΒΉ' {(p i).1} = {i} := by | |
| ext j | |
| simp only [mem_preimage,mem_singleton_iff,hinj.eq_iff] | |
| rw [hpre,normalizedMeasure,Measure.smul_apply,smul_eq_mul, | |
| withDensity_apply _ (measurableSet_singleton i),withDensity_apply _ MeasurableSet.univ, | |
| Measure.restrict_univ,lintegral_count] | |
| simp | |
| def countedBlockProbability {I S : Type*} (p : I β βΓS) : | |
| List (βΓ(S β ββ₯0β)) β {m : β} β (Fin m β β) β ββ₯0β | |
| | [],_,_ => 1 | |
| | nf::ns,_,z => β' i, if β j, z j = (p i).1 then 0 else | |
| (((β' k, ENNReal.ofReal (Real.exp (p k).1))β»ΒΉ)* | |
| ENNReal.ofReal (Real.exp (p i).1))^nf.1 * nf.2 (p i).2 * | |
| countedBlockProbability p ns (Fin.cons (p i).1 z) | |
| lemma markedBlockProbability_count_map {I S : Type*} [Countable I] | |
| [MeasurableSpace I] [MeasurableSingletonClass I] [MeasurableSpace S] | |
| (p : I β βΓS) (hp : Measurable p) (hinj : Function.Injective (fun i => (p i).1)) | |
| (ns : List (βΓ(S β ββ₯0β))) | |
| (hn : β nf β ns, 1 β€ nf.1) (hm : β nf β ns, Measurable nf.2) | |
| {m : β} (z : Fin m β β) : | |
| markedBlockProbability ns (Measure.count.map p) z = countedBlockProbability p ns z := by | |
| classical | |
| induction ns generalizing m with | |
| | nil => rfl | |
| | cons nf ns ih => | |
| have hnf := hn nf (by simp) | |
| have hn' : β n β ns, 1 β€ n.1 := fun n h => hn n (by simp [h]) | |
| have hm' : β n β ns, Measurable n.2 := fun n h => hm n (by simp [h]) | |
| unfold markedBlockProbability countedBlockProbability | |
| rw [markedStableMassKernel_count_map p hp] | |
| have ha : Measurable (fun t : βΓS => | |
| stableMassKernel ((Measure.count.map p).map Prod.fst) {t.1}) := | |
| stableMassAtom_measurable_comp measurable_const measurable_fst | |
| have ht : Measurable (fun t : βΓS => | |
| markedBlockProbability ns (Measure.count.map p) (Fin.cons t.1 z)) := | |
| (markedBlockProbability_measurable ns hm' (m+1)).comp | |
| (measurable_const.prodMk (measurable_fin_cons measurable_fst measurable_const)) | |
| have hf : Measurable (fun t : βΓS => if β j, z j = t.1 then (0:ββ₯0β) else | |
| (stableMassKernel ((Measure.count.map p).map Prod.fst) {t.1})^(nf.1-1)* | |
| nf.2 t.2*markedBlockProbability ns (Measure.count.map p) (Fin.cons t.1 z)) := | |
| measurable_const.ite (cascadeMeasurableSet_exists fun j => | |
| measurableSet_eq_fun measurable_const measurable_fst) | |
| (((ha.pow_const _).mul ((hm nf (by simp)).comp measurable_snd)).mul ht) | |
| have hweight : Measurable (fun i => ENNReal.ofReal (Real.exp (p i).1)) := | |
| hp.fst.exp.ennreal_ofReal | |
| have hfp : Measurable (fun i => if β j, z j = (p i).1 then (0:ββ₯0β) else | |
| (stableMassKernel ((Measure.count.map p).map Prod.fst) {(p i).1})^(nf.1-1)* | |
| nf.2 (p i).2*markedBlockProbability ns (Measure.count.map p) (Fin.cons (p i).1 z)) := | |
| hf.comp hp | |
| rw [lintegral_map hf hp,normalizedMeasure,lintegral_smul_measure,smul_eq_mul, | |
| withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ, | |
| lintegral_withDensity_eq_lintegral_mul _ hweight hfp, | |
| lintegral_count,lintegral_count,β ENNReal.tsum_mul_left] | |
| apply tsum_congr | |
| intro i | |
| simp only [Pi.mul_apply] | |
| split_ifs with hi | |
| Β· simp | |
| Β· rw [stableMassKernel_count_map_atom p hp hinj,ih hn' hm'] | |
| have hpw := pow_succ (((β' k, ENNReal.ofReal (Real.exp (p k).1))β»ΒΉ)* | |
| ENNReal.ofReal (Real.exp (p i).1)) (nf.1-1) | |
| rw [Nat.sub_add_cancel hnf] at hpw | |
| rw [hpw] | |
| ring | |
| instance finiteSigmaMeasurableSingleton (k : β β β) : | |
| MeasurableSingletonClass (Ξ£ j, Fin (k j)) := by | |
| constructor | |
| intro x | |
| apply MeasurableSpace.measurableSet_iInf.mpr | |
| intro j | |
| change MeasurableSet ((Sigma.mk j) β»ΒΉ' {x}) | |
| exact (Set.toFinite _).measurableSet | |
| lemma indexedPoissonMeasure_eq_map_count {A : Type*} [MeasurableSpace A] | |
| (a : β β βΓ(β β A)) : | |
| indexedPoissonMeasure a = Measure.count.map | |
| (fun i : Ξ£ j, Fin ((a j).1) => (a i.1).2 i.2.val) := by | |
| apply Measure.ext_of_lintegral | |
| intro f hf | |
| rw [indexedPoissonMeasure_lintegral a hf, | |
| lintegral_map hf (measurable_of_countable _),lintegral_count,ENNReal.tsum_sigma'] | |
| simp only [tsum_fintype] | |
| end SphericalPerceptronFreeEnergy | |
| end | |
| end OAI | |