Download data/lean/OAI/Geometry/LatticeCovering/GridCounts.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 28.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/LatticeCovering/GridCounts.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/LatticeCovering/GridCounts.lean
-
curl -L -o GridCounts.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/LatticeCovering/GridCounts.lean
28.4 kB
| import OAI.Geometry.LatticeCovering.GaussianSections | |
| namespace OAI | |
| section | |
| noncomputable section | |
| namespace SingleLatticeCovering.RealLatticeCount | |
| open Module MeasureTheory Measure Filter Set Bornology | |
| open scoped Pointwise Topology | |
| variable {ΞΉ : Type*} [Fintype ΞΉ] | |
| lemma convex_dilation_mono {ΞΉ : Type*} [Fintype ΞΉ] {S : Set (ΞΉ β β)} (hS : Convex β S) (h0 : 0 β S) | |
| {x y : β} (hx : 0 < x) (hxy : x β€ y) : x β’ S β y β’ S := by | |
| rintro _ β¨u,hu,rflβ© | |
| have hy : 0 < y := hx.trans_le hxy | |
| refine β¨(x/y) β’ u, ?_, ?_β© | |
| Β· have h := hS h0 hu (sub_nonneg.mpr ((div_le_one hy).mpr hxy)) | |
| (div_nonneg hx.le hy.le) (by ring : 1-x/y+x/y=1) | |
| simpa using h | |
| Β· change y β’ ((x/y) β’ u) = x β’ u | |
| rw [smul_smul] | |
| congr 1 | |
| field_simp | |
| theorem tendsto_real_grid_count (L : Submodule β€ (ΞΉ β β)) | |
| [DiscreteTopology L] [IsZLattice β L] {S : Set (ΞΉ β β)} | |
| (hSb : IsBounded S) (hSm : MeasurableSet S) | |
| (hSf : volume (frontier S) = 0) | |
| (hSd : β β¦x y : ββ¦, 0 < x β x β€ y β x β’ S β y β’ S) : | |
| Tendsto (fun t : β => (Nat.card β₯(S β© tβ»ΒΉ β’ (L : Set (ΞΉ β β))) : β) / | |
| t ^ Fintype.card ΞΉ) atTop (π (volume.real S / ZLattice.covolume L)) := by | |
| let b := IsZLattice.basis L | |
| let f := (b.ofZLatticeBasis β).equivFun | |
| have hbound : IsBounded (f '' S) := by | |
| rw [βNormedSpace.isVonNBounded_iff β] at hSb β’ | |
| exact hSb.image ((b.ofZLatticeBasis β).equivFunL : (ΞΉ β β) βL[β] ΞΉ β β) | |
| have hmeas : MeasurableSet (f '' S) := | |
| (b.ofZLatticeBasis β).equivFunL.toHomeomorph.toMeasurableEquiv.measurableSet_image.mpr hSm | |
| have hfront : volume (frontier (f '' S)) = 0 := by | |
| have hf : frontier (f '' S) = f '' frontier S := by | |
| rw [LinearEquiv.image_eq_preimage_symm, LinearEquiv.image_eq_preimage_symm] | |
| exact (Homeomorph.preimage_frontier (b.ofZLatticeBasis β).equivFunL.toHomeomorph.symm S).symm | |
| rw [hf, ZLattice.volume_image_eq_volume_div_covolume L b, hSf, ENNReal.zero_div] | |
| have hdilate : β β¦x y : ββ¦, 0 < x β x β€ y β x β’ (f '' S) β y β’ (f '' S) := by | |
| intro x y hx hxy | |
| simp_rw [βimage_smul_set] | |
| exact Set.image_mono (hSd hx hxy) | |
| have hlim := tendsto_card_div_pow_atTop_volume' (f '' S) hbound hmeas hfront hdilate | |
| have hv : volume.real (f '' S) = volume.real S / ZLattice.covolume L := by | |
| simp only [measureReal_def] | |
| rw [ZLattice.volume_image_eq_volume_div_covolume L b, ENNReal.toReal_div, | |
| ENNReal.toReal_ofReal (ZLattice.covolume_pos L volume).le] | |
| rw [hv] at hlim | |
| apply hlim.congr' | |
| filter_upwards [eventually_gt_atTop (0:β)] with t ht | |
| congr 1 | |
| congr 1 | |
| refine Nat.card_congr <| (f.toEquiv.subtypeEquiv (fun x => ?_)).symm | |
| dsimp only [f] | |
| simp only [Set.mem_inter_iff, β b.ofZLatticeBasis_span β, LinearEquiv.coe_toEquiv, | |
| Basis.equivFun_apply, Set.mem_image, DFunLike.coe_fn_eq, EmbeddingLike.apply_eq_iff_eq, | |
| exists_eq_right, Set.mem_inv_smul_set_iffβ ht.ne', | |
| βFinsupp.coe_smul, βmap_smul, SetLike.mem_coe, Basis.mem_span_iff_repr_mem, | |
| Pi.basisFun_repr] | |
| theorem tendsto_convex_grid_count (L : Submodule β€ (ΞΉ β β)) | |
| [DiscreteTopology L] [IsZLattice β L] {S : Set (ΞΉ β β)} | |
| (hSc : IsCompact S) (hSv : Convex β S) (h0 : 0 β S) : | |
| Tendsto (fun t : β => (Nat.card β₯(S β© tβ»ΒΉ β’ (L : Set (ΞΉ β β))) : β) / | |
| t ^ Fintype.card ΞΉ) atTop (π (volume.real S / ZLattice.covolume L)) := | |
| tendsto_real_grid_count L hSc.isBounded hSc.measurableSet | |
| (hSv.addHaar_frontier volume) (fun _ _ => convex_dilation_mono hSv h0) | |
| end SingleLatticeCovering.RealLatticeCount | |
| noncomputable section | |
| namespace SingleLatticeCovering.GridGeometry | |
| open MeasureTheory Measure Set Bornology | |
| open scoped BigOperators Pointwise | |
| def weightedGridConfiguration {r d : β} (J : Set (Fin d β β)) (c : Fin r β β) : | |
| Set (Fin r Γ Fin d β β) := | |
| {x | (β i, (fun j => x (i,j)) β J) β§ (fun j => β i, c i*x (i,j)) β J} | |
| lemma weightedGridConfiguration_convex {r d : β} {J : Set (Fin d β β)} | |
| (hJ : Convex β J) (c : Fin r β β) : Convex β (weightedGridConfiguration J c) := by | |
| intro x hx y hy a b ha hb hab | |
| constructor | |
| Β· intro i | |
| exact hJ (hx.1 i) (hy.1 i) ha hb hab | |
| Β· have he : (fun j => β i, c i*(a β’ x+b β’ y) (i,j)) = | |
| a β’ (fun j => β i, c i*x (i,j)) + b β’ (fun j => β i, c i*y (i,j)) := by | |
| ext j | |
| simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul, Finset.mul_sum, | |
| βFinset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| ring | |
| rw [he] | |
| exact hJ hx.2 hy.2 ha hb hab | |
| lemma weightedGridConfiguration_closed {r d : β} {J : Set (Fin d β β)} | |
| (hJ : IsClosed J) (c : Fin r β β) : IsClosed (weightedGridConfiguration J c) := by | |
| have he : weightedGridConfiguration J c = | |
| (β i, (fun x : Fin r Γ Fin d β β => fun j => x (i,j)) β»ΒΉ' J) β© | |
| (fun x : Fin r Γ Fin d β β => fun j => β i, c i*x (i,j)) β»ΒΉ' J := by | |
| ext x | |
| simp [weightedGridConfiguration] | |
| rw [he] | |
| exact (isClosed_iInter (fun i => hJ.preimage (by fun_prop))).inter | |
| (hJ.preimage (by fun_prop)) | |
| lemma weightedGridConfiguration_bounded {r d : β} {J : Set (Fin d β β)} | |
| (hJ : IsBounded J) (c : Fin r β β) : IsBounded (weightedGridConfiguration J c) := by | |
| obtain β¨R,hRβ© := hJ.exists_norm_le | |
| apply isBounded_iff_forall_norm_le.mpr | |
| refine β¨max R 0, fun x hx => ?_β© | |
| apply (pi_norm_le_iff_of_nonneg (le_max_right R 0)).mpr | |
| intro ij | |
| exact (norm_le_pi_norm (fun j => x (ij.1,j)) ij.2).trans | |
| ((hR _ (hx.1 ij.1)).trans (le_max_left R 0)) | |
| lemma weightedGridConfiguration_compact {r d : β} {J : Set (Fin d β β)} | |
| (hJ : IsCompact J) (c : Fin r β β) : IsCompact (weightedGridConfiguration J c) := | |
| Metric.isCompact_of_isClosed_isBounded | |
| (weightedGridConfiguration_closed hJ.isClosed c) | |
| (weightedGridConfiguration_bounded hJ.isBounded c) | |
| lemma zero_mem_weightedGridConfiguration {r d : β} {J : Set (Fin d β β)} | |
| (h0 : 0 β J) (c : Fin r β β) : 0 β weightedGridConfiguration J c := by | |
| constructor | |
| Β· intro i | |
| exact h0 | |
| Β· convert h0 using 1 | |
| ext j | |
| simp | |
| end SingleLatticeCovering.GridGeometry | |
| namespace SingleLatticeCovering.GridLimit | |
| open MeasureTheory Measure Filter Set | |
| open FiniteKernel GridGeometry RealLatticeCount | |
| open scoped Topology Pointwise | |
| theorem primitive_configuration_limit {r d : β} (a : Fin (r+1) β β€) | |
| (ha0 : a 0 β 0) (hprim : Finset.univ.gcd a = 1) | |
| {J : Set (Fin d β β)} (hJc : IsCompact J) (hJv : Convex β J) (h0 : 0 β J) : | |
| Tendsto (fun t : β => | |
| (Nat.card β₯(weightedGridConfiguration J (fun i => -(a i.succ:β)/(a 0:β)) β© | |
| tβ»ΒΉ β’ (kernelLattice (gridRelationForm (d:=d) (a 0).natAbs (fun i => a i.succ)) : | |
| Set (Fin r Γ Fin d β β))) : β) / t^(r*d)) | |
| atTop (π (volume.real (weightedGridConfiguration J (fun i => -(a i.succ:β)/(a 0:β))) / | |
| |(a 0:β)|^d)) := by | |
| let : NeZero (a 0).natAbs := β¨Int.natAbs_ne_zero.mpr ha0β© | |
| have h := tendsto_convex_grid_count | |
| (kernelLattice (gridRelationForm (d:=d) (a 0).natAbs (fun i => a i.succ))) | |
| (weightedGridConfiguration_compact hJc (fun i => -(a i.succ:β)/(a 0:β))) | |
| (weightedGridConfiguration_convex hJv _) | |
| (zero_mem_weightedGridConfiguration h0 _) | |
| simpa only [Fintype.card_prod, Fintype.card_fin, primitive_grid_covolume a ha0 hprim] using h | |
| end SingleLatticeCovering.GridLimit | |
| namespace SingleLatticeCovering.GridLimit | |
| open MeasureTheory Measure Filter Set | |
| open FiniteKernel GridGeometry RealLatticeCount | |
| open scoped Topology Pointwise BigOperators | |
| lemma finite_scaled_lattice_inter {ΞΉ : Type*} [Fintype ΞΉ] | |
| (L : Submodule β€ (ΞΉ β β)) [DiscreteTopology L] | |
| {S : Set (ΞΉ β β)} (hS : IsCompact S) {t : β} (ht : t β 0) : | |
| (S β© tβ»ΒΉ β’ (L : Set (ΞΉ β β))).Finite := by | |
| have hT : ((t β’ S) β© (L : Set (ΞΉ β β))).Finite := by | |
| apply Metric.finite_isBounded_inter_isClosed DiscreteTopology.isDiscrete | |
| (hS.smul t).isBounded | |
| exact AddSubgroup.isClosed_of_discreteTopology (U := L.toAddSubgroup) | |
| apply Set.Finite.of_injOn (t := (t β’ S) β© (L : Set (ΞΉ β β))) | |
| (f := fun x => t β’ x) ?_ ?_ hT | |
| Β· rintro x β¨hx, y, hy, rflβ© | |
| constructor | |
| Β· exact β¨tβ»ΒΉ β’ y,hx,rflβ© | |
| Β· simpa only [smul_smul, mul_inv_cancelβ ht, one_smul] using hy | |
| Β· intro x hx y hy hxy | |
| exact smul_right_injective (ΞΉ β β) ht hxy | |
| lemma projected_grid_relation_mem {r d : β} (a : Fin (r+1) β β€) | |
| (x : Fin (r+1) β Fin d β β€) (h : β j, β i, a i*x i j = 0) : | |
| (fun ij : Fin r Γ Fin d => (x ij.1.succ ij.2 : β)) β | |
| kernelLattice (gridRelationForm (d:=d) (a 0).natAbs (fun i => a i.succ)) := by | |
| let z : integerLattice (Fin r Γ Fin d) := integerCoordinates.symm (fun ij => x ij.1.succ ij.2) | |
| have he : (z : Fin r Γ Fin d β β) = (fun ij => (x ij.1.succ ij.2 : β)) := by | |
| ext ij | |
| rw [βintegerCoordinates_cast] | |
| simp [z] | |
| rw [βhe, mem_kernelLattice_iff] | |
| ext j | |
| have hcast := congrArg (fun t : β€ => (t : ZMod (a 0).natAbs)) (h j) | |
| have hzero : (a 0 : ZMod (a 0).natAbs) = 0 := by | |
| rw [ZMod.intCast_zmod_eq_zero_iff_dvd] | |
| exact Int.natAbs_dvd.mpr (dvd_refl (a 0)) | |
| simpa [gridRelationForm,z,Fin.sum_univ_succ,Int.cast_add,Int.cast_mul,Int.cast_sum,hzero] | |
| using hcast | |
| lemma omitted_vertex_identity {r d : β} (a : Fin (r+1) β β€) (ha0 : a 0 β 0) | |
| (x : Fin (r+1) β Fin d β β€) (h : β j, β i, a i*x i j = 0) (t : β) : | |
| (fun j => β i : Fin r, (-(a i.succ:β)/(a 0:β))*(tβ»ΒΉ*(x i.succ j:β))) = | |
| (fun j => tβ»ΒΉ*(x 0 j:β)) := by | |
| ext j | |
| have hh := congrArg (fun z : β€ => (z:β)) (h j) | |
| simp only [Fin.sum_univ_succ,Int.cast_add,Int.cast_sum,Int.cast_mul,Int.cast_zero] at hh | |
| have haR : (a 0:β) β 0 := Int.cast_ne_zero.mpr ha0 | |
| apply (mul_left_cancelβ haR) | |
| rw [Finset.mul_sum] | |
| have he (i : Fin r) : (a 0:β)*(-(a i.succ:β)/(a 0:β)*(tβ»ΒΉ*(x i.succ j:β))) = | |
| -tβ»ΒΉ*((a i.succ:β)*(x i.succ j:β)) := by field_simp | |
| simp_rw [he] | |
| rw [βFinset.mul_sum] | |
| rw [show (β i : Fin r, (a i.succ:β)*(x i.succ j:β)) = -(a 0:β)*(x 0 j:β) by linarith] | |
| ring | |
| theorem circuit_count_le_primitive_grid {r d : β} (a : Fin (r+1) β β€) | |
| (ha0 : a 0 β 0) (J : Set (Fin d β β)) (hJ : IsCompact J) | |
| (X : Finset (Fin (r+1) β Fin d β β€)) {t : β} (ht : 0 < t) | |
| (hX : β x β X, β i, (fun j => tβ»ΒΉ*(x i j:β)) β J) | |
| (hrel : β x β X, β j, β i, a i*x i j = 0) : | |
| (X.card:β) / t^(r*d) β€ | |
| (Nat.card β₯(weightedGridConfiguration J (fun i => -(a i.succ:β)/(a 0:β)) β© | |
| tβ»ΒΉ β’ (kernelLattice (gridRelationForm (d:=d) (a 0).natAbs (fun i => a i.succ)) : | |
| Set (Fin r Γ Fin d β β))) : β) / t^(r*d) := by | |
| classical | |
| let S := weightedGridConfiguration J (fun i => -(a i.succ:β)/(a 0:β)) | |
| let L := kernelLattice (gridRelationForm (d:=d) (a 0).natAbs (fun i => a i.succ)) | |
| have hfin : (S β© tβ»ΒΉ β’ (L : Set (Fin r Γ Fin d β β))).Finite := | |
| finite_scaled_lattice_inter L (weightedGridConfiguration_compact hJ _) ht.ne' | |
| let := hfin.fintype | |
| let f : X β β₯(S β© tβ»ΒΉ β’ (L : Set (Fin r Γ Fin d β β))) := fun x => | |
| β¨fun ij => tβ»ΒΉ*(x.val ij.1.succ ij.2:β), by | |
| constructor | |
| Β· refine β¨fun i => hX x.val x.property i.succ, ?_β© | |
| rw [omitted_vertex_identity a ha0 x.val (hrel x.val x.property) t] | |
| exact hX x.val x.property 0 | |
| Β· exact β¨(fun ij => (x.val ij.1.succ ij.2:β)), | |
| projected_grid_relation_mem a x.val (hrel x.val x.property),rflβ©β© | |
| have hf : Function.Injective f := by | |
| intro x y hxy | |
| have hs (i : Fin r) (j : Fin d) : x.val i.succ j = y.val i.succ j := by | |
| have hh := congrFun (congrArg Subtype.val hxy) (i,j) | |
| change tβ»ΒΉ*(x.val i.succ j:β) = tβ»ΒΉ*(y.val i.succ j:β) at hh | |
| exact Int.cast_injective (mul_left_cancelβ (inv_ne_zero ht.ne') hh) | |
| apply Subtype.ext | |
| funext i j | |
| refine Fin.cases ?_ (fun i => hs i j) i | |
| have hx := hrel x.val x.property j | |
| have hy := hrel y.val y.property j | |
| rw [Fin.sum_univ_succ] at hx hy | |
| simp_rw [hs] at hx | |
| apply mul_left_cancelβ ha0 | |
| linarith | |
| apply div_le_div_of_nonneg_right _ (pow_nonneg ht.le _) | |
| change (X.card:β) β€ (Nat.card β₯(S β© tβ»ΒΉ β’ (L : Set (Fin r Γ Fin d β β))) : β) | |
| apply Nat.cast_le.mpr | |
| simpa only [Nat.card_eq_fintype_card,Fintype.card_coe] using Nat.card_le_card_of_injective f hf | |
| end SingleLatticeCovering.GridLimit | |
| noncomputable section | |
| namespace SingleLatticeCovering.SimplexYoung | |
| open MeasureTheory Measure Set Matrix Filter Topology | |
| open scoped ENNReal BigOperators | |
| abbrev V (r : β) := Fin r β β | |
| def simplexMean {r : β} (u : V (r+1)) : β := (β i, u i) / (r+1:β) | |
| def simplexForm {r : β} (i : Fin (r+1)) : V r ββ[β] β := | |
| Fin.cases (-(β j : Fin r, (LinearMap.proj j : V r ββ[β] β))) | |
| (fun j => LinearMap.proj j) i | |
| lemma simplexForm_zero {r : β} (x : V r) : simplexForm 0 x = -β j, x j := by | |
| simp [simplexForm] | |
| lemma simplexForm_succ {r : β} (j : Fin r) (x : V r) : simplexForm j.succ x = x j := rfl | |
| lemma sum_simplexForm {r : β} (x : V r) : (β i, simplexForm i x) = 0 := by | |
| simp [Fin.sum_univ_succ, simplexForm_zero, simplexForm_succ] | |
| def simplexDual {r : β} : V (r+1) ββ[β] V r where | |
| toFun u j := u j.succ - simplexMean u | |
| map_add' u v := by | |
| ext j | |
| simp [simplexMean, Finset.sum_add_distrib, add_div]; ring | |
| map_smul' c u := by | |
| ext j | |
| simp only [simplexMean, Pi.smul_apply, smul_eq_mul, RingHom.id_apply] | |
| rw [βFinset.mul_sum] | |
| ring | |
| lemma simplexDual_apply {r : β} (u : V (r+1)) (j : Fin r) : | |
| simplexDual u j = u j.succ - simplexMean u := rfl | |
| lemma simplexDual_form {r : β} (x : V r) : | |
| simplexDual (fun i => simplexForm i x) = x := by | |
| ext j | |
| simp [simplexDual_apply, simplexMean, sum_simplexForm, simplexForm_succ] | |
| lemma simplexForm_dual {r : β} (u : V (r+1)) (i : Fin (r+1)) : | |
| simplexForm i (simplexDual u) = u i - simplexMean u := by | |
| refine Fin.cases ?_ (fun j => rfl) i | |
| rw [simplexForm_zero] | |
| simp only [simplexDual_apply, Finset.sum_sub_distrib, Finset.sum_const, | |
| Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] | |
| have hn : (r+1:β) β 0 := by positivity | |
| dsimp [simplexMean] | |
| rw [Fin.sum_univ_succ] | |
| push_cast | |
| field_simp [hn] | |
| ring | |
| lemma simplex_projection_square {r : β} (u : V (r+1)) : | |
| (β i, (simplexForm i (simplexDual u))^2) β€ β i, (u i)^2 := by | |
| simp_rw [simplexForm_dual] | |
| have hex : (β i, (u i - simplexMean u)^2) = | |
| (β i, (u i)^2) - (r+1:β) * (simplexMean u)^2 := by | |
| simp_rw [sub_sq] | |
| rw [Finset.sum_add_distrib, Finset.sum_sub_distrib] | |
| simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] | |
| have he : (β i, 2 * u i * simplexMean u) = 2 * simplexMean u * (β i, u i) := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro i _; ring | |
| rw [he] | |
| dsimp [simplexMean] | |
| field_simp | |
| ring | |
| rw [hex] | |
| exact sub_le_self _ (mul_nonneg (Nat.cast_nonneg _) (sq_nonneg _)) | |
| lemma det_diagonal_rankOne {r : β} (a u v : V r) (ha : β i, a i β 0) : | |
| (Matrix.diagonal a + Matrix.replicateCol Unit u * Matrix.replicateRow Unit v).det = | |
| (β i, a i) * (1 + β i, v i * (a i)β»ΒΉ * u i) := by | |
| have hai : Ring.inverse a = fun i => (a i)β»ΒΉ := by | |
| let au : (V r)Λ£ := β¨a, (fun i => (a i)β»ΒΉ), by ext i; simp [ha i], by ext i; simp [ha i]β© | |
| exact Ring.inverse_unit au | |
| rw [Matrix.det_add_replicateCol_mul_replicateRow | |
| (isUnit_iff_ne_zero.mpr (by simpa using Finset.prod_ne_zero_iff.mpr (fun i _ => ha i))), | |
| Matrix.det_diagonal, Matrix.inv_diagonal, hai, Matrix.det_unique] | |
| simp [Matrix.mul_apply, Matrix.diagonal_apply] | |
| def simplexJacobian {r : β} (s : V (r+1)) : Matrix (Fin r) (Fin r) β := | |
| Matrix.diagonal (fun j : Fin r => s j.succ) + | |
| Matrix.replicateCol Unit (fun _ : Fin r => (1:β)) * | |
| Matrix.replicateRow Unit (fun j : Fin r => (s 0-s j.succ)/(r+1:β)) | |
| lemma simplexJacobian_apply {r : β} (s : V (r+1)) (j l : Fin r) : | |
| simplexJacobian s j l = (if j=l then s j.succ else 0) + | |
| (s 0-s l.succ)/(r+1:β) := by | |
| simp [simplexJacobian, Matrix.diagonal_apply, Matrix.mul_apply] | |
| lemma simplexJacobian_det {r : β} (s : V (r+1)) (hs : β i, 0 < s i) : | |
| (simplexJacobian s).det = (β i, s i) * ((β i, (s i)β»ΒΉ)/(r+1:β)) := by | |
| rw [simplexJacobian, det_diagonal_rankOne _ _ _ (fun i => (hs i.succ).ne')] | |
| simp only [mul_one] | |
| have hsum : (β i : Fin r, ((s 0-s i.succ)/(r+1:β)) * (s i.succ)β»ΒΉ) = | |
| s 0/(r+1:β) * (β i : Fin r, (s i.succ)β»ΒΉ) - (r:β)/(r+1:β) := by | |
| have he (i : Fin r) : ((s 0-s i.succ)/(r+1:β)) * (s i.succ)β»ΒΉ = | |
| (s 0/(r+1:β)) * (s i.succ)β»ΒΉ - 1/(r+1:β) := by | |
| field_simp [(hs i.succ).ne'] | |
| simp_rw [he] | |
| rw [Finset.sum_sub_distrib, βFinset.mul_sum] | |
| simp [div_eq_mul_inv] | |
| rw [hsum, Fin.prod_univ_succ, Fin.sum_univ_succ] | |
| have hn : (r+1:β) β (0:β) := by positivity | |
| field_simp [(hs 0).ne', hn] | |
| push_cast | |
| ring | |
| lemma simplexJacobian_det_ge {r : β} (s : V (r+1)) (hs : β i, 0 < s i) : | |
| (β i, (s i)^((r:β)/(r+1:β))) β€ (simplexJacobian s).det := by | |
| have hn : (0:β) < (r+1:β) := by positivity | |
| have hg := Real.geom_mean_le_arith_mean_weighted (s := Finset.univ) | |
| (fun _ : Fin (r+1) => (1:β)/(r+1:β)) (fun i => (s i)β»ΒΉ) | |
| (fun _ _ => (div_pos zero_lt_one hn).le) | |
| (by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; field_simp) (fun i _ => (inv_pos.mpr (hs i)).le) | |
| have hp : 0 < β i, s i := Finset.prod_pos (fun i _ => hs i) | |
| have he : (β i, (s i)^((r:β)/(r+1:β))) = | |
| (β i, s i) * (β i, ((s i)β»ΒΉ)^((1:β)/(r+1:β))) := by | |
| rw [βFinset.prod_mul_distrib] | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| rw [Real.inv_rpow (hs i).le, βdiv_eq_mul_inv] | |
| calc | |
| (s i)^((r:β)/(r+1:β)) = (s i)^((1:β)-1/(r+1:β)) := by | |
| congr 1; push_cast; field_simp; ring | |
| _ = (s i)^((1:β)) / (s i)^((1:β)/(r+1:β)) := Real.rpow_sub (hs i) _ _ | |
| _ = _ := by rw [Real.rpow_one] | |
| rw [he, simplexJacobian_det s hs] | |
| apply mul_le_mul_of_nonneg_left _ hp.le | |
| calc | |
| _ β€ β i, (1:β)/(r+1:β) * (s i)β»ΒΉ := hg | |
| _ = _ := by rw [βFinset.mul_sum]; ring | |
| def simplexTransport {r : β} (T : Fin (r+1) β β β β) (x : V r) : V r := | |
| simplexDual (fun i => T i (simplexForm i x)) | |
| lemma simplexTransport_injective {r : β} {T : Fin (r+1) β β β β} | |
| (hT : β i, StrictMono (T i)) : Function.Injective (simplexTransport T) := by | |
| intro x y hxy | |
| let u : V (r+1) := fun i => T i (simplexForm i x)-T i (simplexForm i y) | |
| have hu : simplexDual u = 0 := by | |
| change simplexDual ((fun i => T i (simplexForm i x)) - (fun i => T i (simplexForm i y))) = 0 | |
| rw [map_sub] | |
| exact sub_eq_zero.mpr hxy | |
| have hue (i : Fin (r+1)) : u i = simplexMean u := by | |
| have h := simplexForm_dual u i | |
| rw [hu, map_zero] at h | |
| exact sub_eq_zero.mp h.symm | |
| have hsum : (β i, u i * (simplexForm i x-simplexForm i y)) = 0 := by | |
| simp_rw [hue, β map_sub] | |
| rw [βFinset.mul_sum, sum_simplexForm, mul_zero] | |
| have hn (i : Fin (r+1)) : 0 β€ u i*(simplexForm i x-simplexForm i y) := by | |
| dsimp [u] | |
| rcases le_total (simplexForm i x) (simplexForm i y) with h | h | |
| Β· exact mul_nonneg_of_nonpos_of_nonpos (sub_nonpos.mpr ((hT i).monotone h)) (sub_nonpos.mpr h) | |
| Β· exact mul_nonneg (sub_nonneg.mpr ((hT i).monotone h)) (sub_nonneg.mpr h) | |
| have hzero := (Finset.sum_eq_zero_iff_of_nonneg (fun i _ => hn i)).mp hsum | |
| ext j | |
| have h := hzero j.succ (Finset.mem_univ _) | |
| change (T j.succ (x j)-T j.succ (y j))*(x j-y j)=0 at h | |
| rcases mul_eq_zero.mp h with h | h | |
| Β· exact (hT j.succ).injective (sub_eq_zero.mp h) | |
| Β· exact sub_eq_zero.mp h | |
| def simplexDerivative {r : β} (s : V (r+1)) : V r βL[β] V r := | |
| simplexDual.toContinuousLinearMap.comp | |
| (ContinuousLinearMap.pi (fun i => s i β’ (simplexForm i).toContinuousLinearMap)) | |
| lemma simplexTransport_hasFDerivAt {r : β} {T T' : Fin (r+1) β β β β} | |
| (hT : β i t, HasDerivAt (T i) (T' i t) t) (x : V r) : | |
| HasFDerivAt (simplexTransport T) | |
| (simplexDerivative (fun i => T' i (simplexForm i x))) x := by | |
| apply simplexDual.toContinuousLinearMap.hasFDerivAt.comp | |
| apply hasFDerivAt_pi.mpr | |
| intro i | |
| exact (hT i (simplexForm i x)).comp_hasFDerivAt x | |
| (simplexForm i).toContinuousLinearMap.hasFDerivAt | |
| lemma simplexDerivative_eq {r : β} (s : V (r+1)) : | |
| (simplexDerivative s).toLinearMap = Matrix.toLin' (simplexJacobian s) := by | |
| apply LinearMap.ext | |
| intro x | |
| ext j | |
| change s j.succ * simplexForm j.succ x - | |
| simplexMean (fun i => s i * simplexForm i x) = (simplexJacobian s *α΅₯ x) j | |
| simp only [simplexForm_succ, simplexMean, Fin.sum_univ_succ, simplexForm_zero, | |
| Matrix.mulVec, dotProduct, simplexJacobian_apply, add_mul, Finset.sum_add_distrib, | |
| ite_mul, zero_mul, Finset.sum_ite_eq, Finset.mem_univ, ite_true] | |
| simp_rw [div_mul_eq_mul_div, sub_mul] | |
| rw [βFinset.sum_div, Finset.sum_sub_distrib, βFinset.mul_sum] | |
| ring | |
| lemma simplexDerivative_det {r : β} (s : V (r+1)) : | |
| (simplexDerivative s).det = (simplexJacobian s).det := by | |
| change LinearMap.det (simplexDerivative s).toLinearMap = _ | |
| rw [simplexDerivative_eq, LinearMap.det_toLin'] | |
| lemma simplex_transport_pointwise {r : β} (u s : V (r+1)) (hs : β i, 0 < s i) : | |
| (β i, (Real.exp (-(u i)^2) * s i) ^ ((r:β)/(r+1:β))) β€ | |
| |(simplexDerivative s).det| * | |
| Real.exp (-((r:β)/(r+1:β)) * β i, (simplexForm i (simplexDual u))^2) := by | |
| have hpow (i : Fin (r+1)) : | |
| (Real.exp (-(u i)^2) * s i) ^ ((r:β)/(r+1:β)) = | |
| Real.exp (-((r:β)/(r+1:β))*(u i)^2) * (s i)^((r:β)/(r+1:β)) := by | |
| rw [Real.mul_rpow (Real.exp_pos _).le (hs i).le, β Real.exp_mul] | |
| congr 2; ring | |
| simp_rw [hpow] | |
| rw [Finset.prod_mul_distrib, β Real.exp_sum] | |
| have hex : Real.exp (β i, -((r:β)/(r+1:β))*(u i)^2) β€ | |
| Real.exp (-((r:β)/(r+1:β)) * β i, (simplexForm i (simplexDual u))^2) := by | |
| apply Real.exp_le_exp.mpr | |
| rw [βFinset.mul_sum] | |
| exact mul_le_mul_of_nonpos_left (simplex_projection_square u) (neg_nonpos.mpr (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))) | |
| have hd := simplexJacobian_det_ge s hs | |
| have hdn : 0 β€ (simplexJacobian s).det := | |
| (Finset.prod_nonneg (fun i _ => Real.rpow_nonneg (hs i).le _)).trans hd | |
| rw [simplexDerivative_det, abs_of_nonneg hdn] | |
| exact (mul_le_mul hex hd (Finset.prod_nonneg (fun i _ => Real.rpow_nonneg (hs i).le _)) | |
| (Real.exp_pos _).le).trans_eq (mul_comm _ _) | |
| def simplexRoot {r : β} : Matrix (Fin r) (Fin r) β := | |
| 1 + Matrix.replicateCol Unit (fun _ : Fin r => (1:β)) * | |
| Matrix.replicateRow Unit (fun _ : Fin r => (1:β)/(Real.sqrt (r+1:β)+1)) | |
| lemma simplexRoot_mulVec {r : β} (x : V r) (j : Fin r) : | |
| simplexRoot.mulVec x j = x j + (β l, x l)/(Real.sqrt (r+1:β)+1) := by | |
| rw [simplexRoot, Matrix.add_mulVec, Matrix.one_mulVec] | |
| simp [Matrix.mulVec, Matrix.mul_apply, dotProduct, βFinset.mul_sum] | |
| ring | |
| lemma simplexRoot_det {r : β} : | |
| (simplexRoot (r:=r)).det = Real.sqrt (r+1:β) := by | |
| rw [simplexRoot, Matrix.det_one_add_replicateCol_mul_replicateRow] | |
| simp only [dotProduct, mul_one, | |
| Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] | |
| have hn : 0 β€ (r+1:β) := Nat.zero_le _ | |
| have hs : (Real.sqrt (r+1:β))^2 = (r+1:β) := Real.sq_sqrt (by positivity) | |
| have hd : Real.sqrt (r+1:β)+1 β 0 := by positivity | |
| push_cast at * | |
| field_simp | |
| nlinarith | |
| lemma simplexRoot_square {r : β} (x : V r) : | |
| (β j, (simplexRoot.mulVec x j)^2) = β i, (simplexForm i x)^2 := by | |
| simp_rw [simplexRoot_mulVec] | |
| rw [Fin.sum_univ_succ] | |
| simp only [simplexForm_zero, simplexForm_succ, neg_sq] | |
| simp_rw [add_sq] | |
| rw [Finset.sum_add_distrib, Finset.sum_add_distrib] | |
| have hs : (β j : Fin r, 2*x j*((β l, x l)/(Real.sqrt (r+1:β)+1))) = | |
| 2*((β l, x l)/(Real.sqrt (r+1:β)+1)) * β j, x j := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro j _; ring | |
| rw [hs] | |
| simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] | |
| have he : (Real.sqrt (r+1:β))^2 = (r+1:β) := Real.sq_sqrt (by positivity) | |
| have hd : Real.sqrt (r+1:β)+1 β 0 := by positivity | |
| push_cast at * | |
| field_simp | |
| nlinarith [congrArg (fun z : β => z*(β j, x j)^2) he] | |
| lemma simplex_gaussian_integral {r : β} (c : β) (hc : 0 < c) : | |
| (β«β» x : V r, ENNReal.ofReal | |
| (Real.exp (-c * β i : Fin (r+1), (simplexForm i x)^2))) = | |
| ENNReal.ofReal ((Real.sqrt (Real.pi/c))^r / Real.sqrt (r+1:β)) := by | |
| let B : V r ββ[β] V r := Matrix.toLin' simplexRoot | |
| have hdet : B.det = Real.sqrt (r+1:β) := by | |
| rw [LinearMap.det_toLin', simplexRoot_det] | |
| have hp : 0 < Real.sqrt (r+1:β) := Real.sqrt_pos.mpr (by positivity) | |
| let g : V r β ββ₯0β := fun x => ENNReal.ofReal (Real.exp (-c * β j, (x j)^2)) | |
| have hg : Measurable g := by | |
| apply Continuous.measurable | |
| dsimp [g] | |
| apply ENNReal.continuous_ofReal.comp | |
| fun_prop | |
| have he (x : V r) : g (B x) = | |
| ENNReal.ofReal (Real.exp (-c * β i : Fin (r+1), (simplexForm i x)^2)) := by | |
| dsimp [g, B] | |
| rw [simplexRoot_square] | |
| have hgi : (β«β» x, g x) = ENNReal.ofReal ((Real.sqrt (Real.pi/c))^r) := by | |
| have hex (x : V r) : Real.exp (-c * β j, (x j)^2) = | |
| β j, Real.exp (-c*(x j)^2) := by rw [Finset.mul_sum, Real.exp_sum] | |
| dsimp [g] | |
| rw [β ofReal_integral_eq_lintegral_ofReal | |
| (show Integrable (fun x : V r => Real.exp (-c * β j, (x j)^2)) volume from by | |
| simp_rw [hex] | |
| exact Integrable.fintype_prod (fun i : Fin r => integrable_exp_neg_mul_sq hc)) | |
| (Filter.Eventually.of_forall (fun x : V r => (Real.exp_pos _).le))] | |
| congr 1 | |
| simp_rw [hex] | |
| rw [integral_fintype_prod_volume_eq_prod (fun (_ : Fin r) (t : β) => Real.exp (-c*t^2))] | |
| simp only [integral_gaussian, Finset.prod_const, Finset.card_univ, Fintype.card_fin] | |
| have hm := Real.map_linearMap_volume_pi_eq_smul_volume_pi | |
| (f:=B) (by rw [hdet]; exact hp.ne') | |
| calc | |
| _ = β«β» x, g (B x) := by simp_rw [he] | |
| _ = β«β» y, g y β(Measure.map B volume) := (lintegral_map hg B.continuous_of_finiteDimensional.measurable).symm | |
| _ = _ := by | |
| rw [hm, lintegral_smul_measure, hgi, hdet, abs_of_pos (inv_pos.mpr hp), smul_eq_mul, | |
| βENNReal.ofReal_mul (inv_pos.mpr hp).le] | |
| congr 1; ring | |
| lemma simplex_transport_integral {r : β} (hr : 0 < r) {T T' : Fin (r+1) β β β β} | |
| (hmono : β i, StrictMono (T i)) | |
| (hT : β i t, HasDerivAt (T i) (T' i t) t) (hpos : β i t, 0 < T' i t) : | |
| (β«β» x : V r, ENNReal.ofReal | |
| (β i, (Real.exp (-(T i (simplexForm i x))^2) * T' i (simplexForm i x)) ^ ((r:β)/(r+1:β)))) β€ | |
| ENNReal.ofReal ((Real.sqrt (Real.pi/((r:β)/(r+1:β))))^r / Real.sqrt (r+1:β)) := by | |
| let g : V r β ββ₯0β := fun x => ENNReal.ofReal | |
| (Real.exp (-((r:β)/(r+1:β)) * β i, (simplexForm i x)^2)) | |
| calc | |
| _ β€ β«β» x : V r, ENNReal.ofReal |(simplexDerivative (fun i => T' i (simplexForm i x))).det| * | |
| g (simplexTransport T x) := by | |
| apply lintegral_mono | |
| intro x | |
| change _ β€ ENNReal.ofReal |_| * ENNReal.ofReal _ | |
| rw [βENNReal.ofReal_mul (abs_nonneg _)] | |
| exact ENNReal.ofReal_le_ofReal (simplex_transport_pointwise | |
| (fun i => T i (simplexForm i x)) (fun i => T' i (simplexForm i x)) (fun i => hpos i _)) | |
| _ = β«β» y in simplexTransport T '' Set.univ, g y := by | |
| symm | |
| simpa using lintegral_image_eq_lintegral_abs_det_fderiv_mul volume | |
| MeasurableSet.univ (fun x _ => (simplexTransport_hasFDerivAt hT x).hasFDerivWithinAt) | |
| (simplexTransport_injective hmono).injOn g | |
| _ β€ β«β» y, g y := lintegral_mono' Measure.restrict_le_self (le_refl _) | |
| _ = _ := simplex_gaussian_integral _ (div_pos (Nat.cast_pos.mpr hr) (by positivity)) | |
| end SingleLatticeCovering.SimplexYoung | |
| open MeasureTheory Filter Set | |
| open scoped Topology | |
| noncomputable section | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |