Download data/lean/OAI/Probability/EntangledGames/SpectralEntropy.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/EntangledGames/SpectralEntropy.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/EntangledGames/SpectralEntropy.lean
-
curl -L -o SpectralEntropy.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/EntangledGames/SpectralEntropy.lean
16.7 kB
| import OAI.Probability.EntangledGames.Resolvent | |
| namespace OAI | |
| universe u_n u_Ξ± u_m u_p u_r u_J | |
| open scoped BigOperators ComplexOrder | |
| open scoped MatrixOrder | |
| open Matrix | |
| open MeasureTheory Filter Set | |
| open scoped Topology | |
| noncomputable section | |
| open scoped BigOperators MatrixOrder ComplexOrder Topology Matrix.Norms.Elementwise | |
| open Matrix MeasureTheory Set | |
| namespace ThresholdParallelRepetition.Resolvent | |
| variable {n : Type u_n} [Fintype n] [DecidableEq n] | |
| local instance matrixContinuousENorm : ContinuousENorm (Matrix n n β) := | |
| @SeminormedAddGroup.toContinuousENorm _ inferInstance | |
| local instance matrixPreorder : Preorder (Matrix n n β) := | |
| (Matrix.instPartialOrder : PartialOrder (Matrix n n β)).toPreorder | |
| omit [DecidableEq n] in | |
| lemma isClosed_posSemidef : IsClosed {A : Matrix n n β | A.PosSemidef} := by | |
| simp only [Matrix.posSemidef_iff_dotProduct_mulVec] | |
| apply IsClosed.inter | |
| Β· exact isClosed_eq (by fun_prop) continuous_id | |
| Β· have heq : {A : Matrix n n β | β x, 0 β€ star x β¬α΅₯ (A *α΅₯ x)} = | |
| β x : n β β, {A | 0 β€ star x β¬α΅₯ (A *α΅₯ x)} := by ext; simp | |
| change IsClosed {A : Matrix n n β | β x, 0 β€ star x β¬α΅₯ (A *α΅₯ x)} | |
| rw [heq] | |
| apply isClosed_iInter | |
| intro x | |
| apply isClosed_le continuous_const | |
| simp only [Matrix.mulVec, dotProduct] | |
| fun_prop | |
| local instance matrixClosedIci : ClosedIciTopology (Matrix n n β) where | |
| isClosed_Ici A := by | |
| exact isClosed_posSemidef.preimage (continuous_id.sub continuous_const) | |
| lemma integral_matrix_nonneg {Ξ± : Type u_Ξ±} [MeasurableSpace Ξ±] {ΞΌ : Measure Ξ±} | |
| {f : Ξ± β Matrix n n β} (hf : βα΅ s βΞΌ, (f s).PosSemidef) : | |
| (β« s, f s βΞΌ).PosSemidef := by | |
| apply Matrix.nonneg_iff_posSemidef.mp | |
| exact @integral_nonneg_of_ae Ξ± (Matrix n n β) _ _ _ ΞΌ _ _ _ | |
| matrixClosedIci f (hf.mono fun _ h => h.nonneg) | |
| lemma integral_matrix_mono {Ξ± : Type u_Ξ±} [MeasurableSpace Ξ±] {ΞΌ : Measure Ξ±} | |
| {f g : Ξ± β Matrix n n β} (hf : Integrable f ΞΌ) (hg : Integrable g ΞΌ) | |
| (hfg : f β€α΅[ΞΌ] g) : (β« s, f s βΞΌ) β€ β« s, g s βΞΌ := | |
| @integral_mono_ae Ξ± (Matrix n n β) _ _ _ ΞΌ _ _ _ matrixClosedIci f g hf hg hfg | |
| def spectralLinear (U : Matrix n n β) : (n β β) βL[β] Matrix n n β := | |
| LinearMap.toContinuousLinearMap | |
| { toFun := fun v => U * diagonal (fun i => (v i : β)) * Uα΄΄ | |
| map_add' := by | |
| intro v w | |
| simp only [Pi.add_apply, Complex.ofReal_add] | |
| change U * diagonal ((fun i => (v i : β)) + (fun i => (w i : β))) * Uα΄΄ = _ | |
| erw [β Matrix.diagonal_add] | |
| rw [mul_add, add_mul] | |
| map_smul' := by | |
| intro c v | |
| simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply] | |
| have hd : diagonal (fun i => ((c * v i : β) : β)) = | |
| c β’ diagonal (fun i => (v i : β)) := by | |
| ext i j | |
| simp only [Matrix.diagonal_apply, Matrix.smul_apply, Complex.ofReal_mul, | |
| Complex.real_smul] | |
| split_ifs <;> simp | |
| rw [hd, Matrix.mul_smul, Matrix.smul_mul] } | |
| lemma spectralLinear_apply (U : Matrix n n β) (v : n β β) : | |
| spectralLinear U v = U * diagonal (fun i => (v i : β)) * Uα΄΄ := rfl | |
| lemma cfc_eq_spectralLinear {A : Matrix n n β} (hA : A.IsHermitian) (f : β β β) : | |
| cfc f A = spectralLinear (hA.eigenvectorUnitary : Matrix n n β) | |
| (fun i => f (hA.eigenvalues i)) := by | |
| rw [hA.cfc_eq] | |
| rfl | |
| lemma integrable_cfc {Ξ± : Type u_Ξ±} [MeasurableSpace Ξ±] {ΞΌ : Measure Ξ±} | |
| {A : Matrix n n β} (hA : A.IsHermitian) (f : Ξ± β β β β) | |
| (hf : β i, Integrable (fun s => f s (hA.eigenvalues i)) ΞΌ) : | |
| Integrable (fun s => cfc (f s) A) ΞΌ := by | |
| simp_rw [cfc_eq_spectralLinear hA] | |
| exact (spectralLinear _).integrable_comp (Integrable.of_eval hf) | |
| lemma integral_cfc {Ξ± : Type u_Ξ±} [MeasurableSpace Ξ±] {ΞΌ : Measure Ξ±} | |
| {A : Matrix n n β} (hA : A.IsHermitian) (f : Ξ± β β β β) | |
| (hf : β i, Integrable (fun s => f s (hA.eigenvalues i)) ΞΌ) : | |
| (β« s, cfc (f s) A βΞΌ) = cfc (fun t => β« s, f s t βΞΌ) A := by | |
| simp_rw [cfc_eq_spectralLinear hA] | |
| erw [(spectralLinear _).integral_comp_comm (Integrable.of_eval hf)] | |
| congr 1 | |
| ext i | |
| exact eval_integral hf i | |
| end ThresholdParallelRepetition.Resolvent | |
| noncomputable section | |
| open scoped BigOperators ComplexOrder MatrixOrder Matrix.Norms.Elementwise Topology | |
| open Matrix MeasureTheory Filter Set | |
| namespace ThresholdParallelRepetition.Resolvent | |
| attribute [local instance] matrixContinuousENorm matrixPreorder matrixClosedIci | |
| variable {n : Type u_n} [Fintype n] [DecidableEq n] | |
| lemma spectrum_nonneg {A : Matrix n n β} (hA : A.PosSemidef) | |
| {t : β} (ht : t β spectrum β A) : 0 β€ t := by | |
| rw [hA.isHermitian.spectrum_real_eq_range_eigenvalues] at ht | |
| obtain β¨i, rflβ© := ht | |
| exact hA.eigenvalues_nonneg i | |
| lemma eigenvalues_le_one {A : Matrix n n β} (hA : A.PosSemidef) | |
| (hA1 : A β€ 1) (i : n) : hA.isHermitian.eigenvalues i β€ 1 := by | |
| have h : cfc (fun t : β => t) A β€ cfc (fun _ : β => (1 : β)) A := by | |
| erw [cfc_id' β A hA.isHermitian, cfc_const (1 : β) A hA.isHermitian, | |
| map_one] | |
| exact hA1 | |
| exact (cfc_le_iff (fun t : β => t) (fun _ : β => (1 : β)) A | |
| (ha := hA.isHermitian)).mp h _ (hA.isHermitian.eigenvalues_mem_spectrum_real i) | |
| lemma resolvent_cfc {A : Matrix n n β} (hA : A.PosSemidef) | |
| {s : β} (hs : 0 < s) : | |
| resolvent A s = cfc (fun t : β => (t + s)β»ΒΉ) A := by | |
| erw [cfc_inv (fun t : β => t + s) A | |
| (fun t ht => ne_of_gt (add_pos_of_nonneg_of_pos (spectrum_nonneg hA ht) hs)) | |
| (ha := hA.isHermitian)] | |
| erw [cfc_add A (fun t : β => t) (fun _ : β => s), | |
| cfc_id' β A hA.isHermitian, cfc_const s A hA.isHermitian, | |
| Algebra.algebraMap_eq_smul_one, β Matrix.nonsing_inv_eq_ringInverse] | |
| rfl | |
| lemma purificationKernel_cfc {A : Matrix n n β} (hA : A.PosSemidef) | |
| {s : β} (hs : 0 < s) : | |
| purificationKernel A s = cfc (fun t : β => t / (t + s)) A := by | |
| rw [purificationKernel, resolvent_cfc hA hs] | |
| calc | |
| A * cfc (fun t : β => (t + s)β»ΒΉ) A = | |
| cfc (fun t : β => t) A * cfc (fun t : β => (t + s)β»ΒΉ) A := by | |
| erw [cfc_id' β A hA.isHermitian] | |
| _ = _ := by | |
| rw [β cfc_mul (fun t : β => t) (fun t : β => (t + s)β»ΒΉ) A | |
| (hg := A.finite_real_spectrum.continuousOn _)] | |
| rfl | |
| lemma purificationKernel_square_cfc {A : Matrix n n β} (hA : A.PosSemidef) | |
| {s : β} (hs : 0 < s) : | |
| (purificationKernel A s)α΄΄ * purificationKernel A s = | |
| cfc (fun t : β => t ^ 2 / (t + s) ^ 2) A := by | |
| rw [purificationKernel_cfc hA hs, | |
| (cfc_predicate (fun t : β => t / (t + s)) A).isHermitian.eq, | |
| β cfc_mul (fun t : β => t / (t + s)) (fun t : β => t / (t + s)) A | |
| (A.finite_real_spectrum.continuousOn _) (A.finite_real_spectrum.continuousOn _)] | |
| apply cfc_congr | |
| intro t _ | |
| change t / (t + s) * (t / (t + s)) = t ^ 2 / (t + s) ^ 2 | |
| rw [β pow_two, div_pow] | |
| lemma kernel_square_integrable {A : Matrix n n β} (hA : A.PosSemidef) : | |
| IntegrableOn (fun s : β => (purificationKernel A s)α΄΄ * purificationKernel A s) | |
| (Ioi 0) := by | |
| have hi := integrable_cfc hA.isHermitian (fun (s t : β) => t ^ 2 / (t + s) ^ 2) | |
| (fun i => (scalar_square_integral (hA.eigenvalues_nonneg i)).1) | |
| apply hi.congr | |
| filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs | |
| exact (purificationKernel_square_cfc hA hs).symm | |
| lemma kernel_square_integral {A : Matrix n n β} (hA : A.PosSemidef) : | |
| (β« s : β in Ioi 0, (purificationKernel A s)α΄΄ * purificationKernel A s) = A := by | |
| calc | |
| _ = β« s : β in Ioi 0, cfc (fun t : β => t ^ 2 / (t + s) ^ 2) A := by | |
| apply integral_congr_ae | |
| filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs | |
| exact purificationKernel_square_cfc hA hs | |
| _ = cfc (fun t : β => β« s : β in Ioi 0, t ^ 2 / (t + s) ^ 2) A := | |
| integral_cfc hA.isHermitian _ (fun i => (scalar_square_integral (hA.eigenvalues_nonneg i)).1) | |
| _ = cfc (fun t : β => t) A := by | |
| apply cfc_congr | |
| intro t ht | |
| exact (scalar_square_integral (spectrum_nonneg hA ht)).2 | |
| _ = A := cfc_id' β A hA.isHermitian | |
| def effectEntropy (A : Matrix n n β) : Matrix n n β := cfc (fun t : β => t * Real.log t) A | |
| def entropyIntegrand (A : Matrix n n β) (s : β) : Matrix n n β := | |
| (1 / (1 + s) : β) β’ A - purificationKernel A s | |
| lemma entropyIntegrand_cfc {A : Matrix n n β} (hA : A.PosSemidef) | |
| {s : β} (hs : 0 < s) : | |
| entropyIntegrand A s = cfc (fun t : β => t / (1 + s) - t / (t + s)) A := by | |
| rw [entropyIntegrand, purificationKernel_cfc hA hs, | |
| cfc_sub (fun t : β => t / (1 + s)) (fun t : β => t / (t + s)) A | |
| (A.finite_real_spectrum.continuousOn _) (A.finite_real_spectrum.continuousOn _)] | |
| congr 1 | |
| calc | |
| _ = cfc (fun t : β => (1 / (1 + s)) β’ t) A := by | |
| erw [cfc_smul (1 / (1 + s) : β) (fun t : β => t) A, | |
| cfc_id' β A hA.isHermitian] | |
| _ = _ := by apply cfc_congr; intro t _; simp [smul_eq_mul, div_eq_mul_inv, mul_comm] | |
| lemma entropy_integrable {A : Matrix n n β} (hA : A.PosSemidef) (hA1 : A β€ 1) : | |
| IntegrableOn (entropyIntegrand A) (Ioi 0) := by | |
| have hi := integrable_cfc hA.isHermitian | |
| (fun (s t : β) => t / (1 + s) - t / (t + s)) | |
| (fun i => (scalar_entropy_integral (hA.eigenvalues_nonneg i) (eigenvalues_le_one hA hA1 i)).1) | |
| apply hi.congr | |
| filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs | |
| exact (entropyIntegrand_cfc hA hs).symm | |
| lemma entropy_integral {A : Matrix n n β} (hA : A.PosSemidef) (hA1 : A β€ 1) : | |
| (β« s : β in Ioi 0, entropyIntegrand A s) = effectEntropy A := by | |
| calc | |
| _ = β« s : β in Ioi 0, cfc (fun t : β => t / (1 + s) - t / (t + s)) A := by | |
| apply integral_congr_ae | |
| filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs | |
| exact entropyIntegrand_cfc hA hs | |
| _ = cfc (fun t : β => β« s : β in Ioi 0, t / (1 + s) - t / (t + s)) A := | |
| integral_cfc hA.isHermitian _ (fun i => | |
| (scalar_entropy_integral (hA.eigenvalues_nonneg i) (eigenvalues_le_one hA hA1 i)).1) | |
| _ = effectEntropy A := by | |
| apply cfc_congr | |
| intro t ht | |
| rw [hA.isHermitian.spectrum_real_eq_range_eigenvalues] at ht | |
| obtain β¨i, rflβ© := ht | |
| exact (scalar_entropy_integral (hA.eigenvalues_nonneg i) (eigenvalues_le_one hA hA1 i)).2 | |
| end ThresholdParallelRepetition.Resolvent | |
| noncomputable section | |
| open scoped BigOperators ComplexOrder MatrixOrder Matrix.Norms.Elementwise Topology | |
| open Matrix MeasureTheory Filter Set | |
| namespace ThresholdParallelRepetition.Resolvent | |
| attribute [local instance] matrixContinuousENorm matrixPreorder matrixClosedIci | |
| variable {n : Type u_n} [Fintype n] [DecidableEq n] | |
| local instance rectContinuousENorm {m : Type u_m} {p : Type u_p} [Fintype m] [Fintype p] : | |
| ContinuousENorm (Matrix m p β) := | |
| @SeminormedAddGroup.toContinuousENorm _ inferInstance | |
| lemma scalar_kernel_memLp {t : β} (ht : 0 β€ t) : | |
| MemLp (fun s : β => t / (t + s)) 2 (volume.restrict (Ioi 0)) := by | |
| have hm : Measurable (fun s : β => t / (t + s)) := by fun_prop | |
| apply (memLp_two_iff_integrable_sq hm.aestronglyMeasurable).2 | |
| simpa only [IntegrableOn, div_pow] using (scalar_square_integral ht).1 | |
| lemma kernel_entry_memLp {A : Matrix n n β} (hA : A.PosSemidef) (i j : n) : | |
| MemLp (fun s : β => purificationKernel A s i j) 2 (volume.restrict (Ioi 0)) := by | |
| let U : Matrix n n β := hA.isHermitian.eigenvectorUnitary | |
| let t : n β β := hA.isHermitian.eigenvalues | |
| have hf (k : n) : MemLp (fun s : β => U i k * (t k / (t k + s) : β) * star (U j k)) | |
| 2 (volume.restrict (Ioi 0)) := | |
| (((scalar_kernel_memLp (hA.eigenvalues_nonneg k)).ofReal (K := β)).const_mul | |
| (U i k)).mul_const (star (U j k)) | |
| have hi := memLp_finsetSum Finset.univ (fun k _ => hf k) | |
| apply hi.ae_eq | |
| filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs | |
| rw [purificationKernel_cfc hA hs, hA.isHermitian.cfc_eq] | |
| change (β k, U i k * (t k / (t k + s) : β) * star (U j k)) = | |
| (U * diagonal (fun k => ((t k / (t k + s) : β) : β)) * Uα΄΄) i j | |
| simp only [Matrix.mul_apply, Matrix.diagonal_apply, Matrix.conjTranspose_apply, | |
| mul_ite, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true] | |
| lemma integrable_gram {Ξ± : Type u_Ξ±} [MeasurableSpace Ξ±] {ΞΌ : Measure Ξ±} | |
| {m : Type u_m} {p : Type u_p} {r : Type u_r} [Fintype m] [Fintype p] [Fintype r] | |
| {f : Ξ± β Matrix r m β} {g : Ξ± β Matrix r p β} | |
| (hf : β i j, MemLp (fun s => f s i j) 2 ΞΌ) | |
| (hg : β i j, MemLp (fun s => g s i j) 2 ΞΌ) : | |
| Integrable (fun s => (f s)α΄΄ * g s) ΞΌ := by | |
| apply Integrable.of_eval | |
| intro i | |
| apply Integrable.of_eval | |
| intro j | |
| change Integrable (fun s => β k, star (f s k i) * g s k j) ΞΌ | |
| apply integrable_finsetSum | |
| intro k _ | |
| exact memLp_one_iff_integrable.mp ((hf k i).star.mul (hg k j)) | |
| lemma kernel_cross_integrable {A B : Matrix n n β} (hA : A.PosSemidef) (hB : B.PosSemidef) : | |
| IntegrableOn (fun s : β => (purificationKernel A s)α΄΄ * purificationKernel B s) (Ioi 0) := | |
| integrable_gram (kernel_entry_memLp hA) (kernel_entry_memLp hB) | |
| lemma kernel_distance_integrable {A B : Matrix n n β} | |
| (hA : A.PosSemidef) (hB : B.PosSemidef) : | |
| IntegrableOn (fun s : β => (purificationKernel A s - purificationKernel B s)α΄΄ * | |
| (purificationKernel A s - purificationKernel B s)) (Ioi 0) := by | |
| apply integrable_gram <;> intro i j <;> | |
| exact (kernel_entry_memLp hA i j).sub (kernel_entry_memLp hB i j) | |
| end ThresholdParallelRepetition.Resolvent | |
| noncomputable section | |
| open scoped BigOperators ComplexOrder MatrixOrder Matrix.Norms.Elementwise Topology | |
| open Matrix MeasureTheory Filter Set | |
| namespace ThresholdParallelRepetition.Resolvent | |
| attribute [local instance] matrixContinuousENorm matrixPreorder matrixClosedIci | |
| variable {n : Type u_n} [Fintype n] [DecidableEq n] | |
| lemma entropy_gap_integrand_eq {J : Type u_J} [Fintype J] | |
| (A : J β Matrix n n β) (w : J β β) (B : Matrix n n β) | |
| (hA : β j, (A j).PosSemidef) (hB : B.PosSemidef) | |
| (hw : β j, w j = 1) (hmean : β j, w j β’ A j = B) | |
| {s : β} (hs : 0 < s) : | |
| (β j, w j β’ entropyIntegrand (A j) s) - entropyIntegrand B s = | |
| s β’ β j, w j β’ (resolvent (A j) s - resolvent B s) := by | |
| have hc (c : β) : β j, w j β’ (c β’ A j) = c β’ B := by | |
| simp_rw [smul_comm (w _) c] | |
| rw [β Finset.smul_sum, hmean] | |
| have hone : β j, w j β’ (1 : Matrix n n β) = 1 := by | |
| rw [β Finset.sum_smul, hw, one_smul] | |
| have hr : β j, w j β’ (s β’ resolvent (A j) s) = s β’ β j, w j β’ resolvent (A j) s := by | |
| simp_rw [smul_comm (w _) s] | |
| rw [Finset.smul_sum] | |
| simp_rw [entropyIntegrand, purificationKernel_eq (hA _) hs, purificationKernel_eq hB hs, | |
| smul_sub, Finset.sum_sub_distrib] | |
| rw [hc, hone, hr, β Finset.sum_smul, hw, one_smul] | |
| module | |
| lemma weighted_distance_jensen {J : Type u_J} [Fintype J] | |
| (A : J β Matrix n n β) (w : J β β) (B : Matrix n n β) | |
| (hA : β j, (A j).PosSemidef) (hA1 : β j, A j β€ 1) | |
| (hB : B.PosSemidef) (hB1 : B β€ 1) | |
| (hw0 : β j, 0 β€ w j) (hw : β j, w j = 1) (hmean : β j, w j β’ A j = B) : | |
| (β j, w j β’ (β« s : β in Ioi 0, | |
| (purificationKernel (A j) s - purificationKernel B s)α΄΄ * | |
| (purificationKernel (A j) s - purificationKernel B s))) β€ | |
| (β j, w j β’ effectEntropy (A j)) - effectEntropy B := by | |
| have hf (j : J) := (kernel_distance_integrable (hA j) hB).smul (w j) | |
| have hg (j : J) := (entropy_integrable (hA j) (hA1 j)).smul (w j) | |
| have hleft := integrable_finsetSum Finset.univ (fun j _ => hf j) | |
| have hright := (integrable_finsetSum Finset.univ (fun j _ => hg j)).sub | |
| (entropy_integrable hB hB1) | |
| have hi := integral_matrix_mono hleft hright (show | |
| (fun s => β j, w j β’ ((purificationKernel (A j) s - purificationKernel B s)α΄΄ * | |
| (purificationKernel (A j) s - purificationKernel B s))) β€α΅[volume.restrict (Ioi 0)] | |
| (fun s => (β j, w j β’ entropyIntegrand (A j) s) - entropyIntegrand B s) from by | |
| filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs | |
| rw [entropy_gap_integrand_eq A w B hA hB hw hmean hs] | |
| exact weighted_kernel_square_le A w B hA hB hw0 hw hmean hs) | |
| erw [integral_finsetSum _ (fun j _ => hf j), | |
| integral_sub (integrable_finsetSum Finset.univ (fun j _ => hg j)) | |
| (entropy_integrable hB hB1), | |
| integral_finsetSum _ (fun j _ => hg j)] at hi | |
| simp only [Pi.smul_apply] at hi | |
| simp_rw [integral_smul, entropy_integral (hA _) (hA1 _), entropy_integral hB hB1] at hi | |
| exact hi | |
| end ThresholdParallelRepetition.Resolvent | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |