File size: 4,267 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | import Mathlib
import OAI.Probability.SKBarriers.Gaussian.BlockStein
import OAI.Probability.SKBarriers.Replicas.ReplicaOverlap
namespace OAI
section
section
noncomputable section
open scoped BigOperators
open MeasureTheory ProbabilityTheory Filter
namespace SK.Analytic
open Matrix
section ReplicaVarianceSplit
variable {S : Type} [Fintype S]
theorem finiteReplicaMoment_const (p : S β β) (hp : β s, p s = 1) (c : β) :
finiteReplicaMoment p (fun _ _ => c) = c := by
simp only [finiteReplicaMoment,β Finset.mul_sum,β Finset.sum_mul,hp,mul_one,one_mul]
theorem finiteReplicaMoment_add (p : S β β) (g h : S β S β β) :
finiteReplicaMoment p (fun s t => g s t+h s t) = finiteReplicaMoment p g+finiteReplicaMoment p h := by
simp only [finiteReplicaMoment,mul_add,Finset.sum_add_distrib]
theorem finiteReplicaMoment_const_mul (p : S β β) (g : S β S β β) (c : β) :
finiteReplicaMoment p (fun s t => c*g s t) = c*finiteReplicaMoment p g := by
simp only [finiteReplicaMoment,Finset.mul_sum]
apply Finset.sum_congr rfl; intro s _
apply Finset.sum_congr rfl; intro t _
ring
theorem finiteReplicaMoment_sub_square (p : S β β) (hp : β s, p s = 1) (g : S β S β β) (r : β) :
finiteReplicaMoment p (fun s t => (g s t-r)^2) =
finiteReplicaMoment p (fun s t => (g s t)^2)-2*r*finiteReplicaMoment p g+r^2 := by
have he : (fun s t => (g s t-r)^2) = fun s t => (g s t)^2+(-2*r)*g s t+r^2 := by
funext s t; ring
rw [he,finiteReplicaMoment_add,finiteReplicaMoment_add,finiteReplicaMoment_const_mul,finiteReplicaMoment_const p hp]
ring
theorem finiteReplicaMoment_variance_split (p : S β β) (hp : β s, p s = 1) (g : S β S β β) (r : β) :
finiteReplicaMoment p (fun s t => (g s t-r)^2) =
finiteReplicaMoment p (fun s t => (g s t-finiteReplicaMoment p g)^2)+(finiteReplicaMoment p g-r)^2 := by
rw [finiteReplicaMoment_sub_square p hp,finiteReplicaMoment_sub_square p hp]
ring
theorem finiteReplicaMoment_normalizedDot {N : β} (p : S β β) (v : S β Fin N β β) :
finiteReplicaMoment p (fun s t => normalizedDot (v s) (v t)) = normalizedSquare (finiteMean p v) := by
have he : (fun s t => normalizedDot (v s) (v t)) = fun s t => (N : β)β»ΒΉ*(v s β¬α΅₯ v t) := by
funext s t; simp only [normalizedDot,dotProduct,div_eq_mul_inv]; ring
rw [he,finiteReplicaMoment_const_mul,finiteReplicaMoment_dot]
simp only [normalizedSquare,dotProduct,pow_two,div_eq_mul_inv,mul_comm]
theorem finiteCovariance_trace_square_nonneg {I : Type} [Fintype I]
(p : S β β) (v : S β I β β) (hp : β s, 0 β€ p s) (hs : β s, p s = 1) :
0 β€ ((finiteCovariance p v)*(finiteCovariance p v)).trace := by
have h := (finiteCovariance_posSemidef p v hp hs).isHermitian
simpa only [h.eq] using (Matrix.posSemidef_conjTranspose_mul_self (finiteCovariance p v)).trace_nonneg
theorem finiteReplica_normalized_variance_le {N : β} (hN : 0 < N)
(p : S β β) (v : S β Fin N β β) (hp : β s, 0 β€ p s) (hs : β s, p s = 1)
(hv : β s i, |v s i| β€ 1) :
finiteReplicaMoment p (fun s t => (normalizedDot (v s) (v t)-normalizedSquare (finiteMean p v))^2) β€
((finiteCovariance p v)*(finiteCovariance p v)).trace/(N : β)^2+
2*Real.sqrt (((finiteCovariance p v)*(finiteCovariance p v)).trace/(N : β)^2) := by
let T := ((finiteCovariance p v)*(finiteCovariance p v)).trace
let m := finiteMean p v
have hn : (0 : β) < N := by exact_mod_cast hN
have hT : 0 β€ T := finiteCovariance_trace_square_nonneg p v hp hs
have he : (fun s t => (normalizedDot (v s) (v t)-normalizedSquare m)^2) =
fun s t => ((N : β)^2)β»ΒΉ*(v s β¬α΅₯ v t-m β¬α΅₯ m)^2 := by
funext s t
simp only [normalizedDot,normalizedSquare,dotProduct,pow_two,div_eq_mul_inv]
ring
rw [he,finiteReplicaMoment_const_mul]
have H := mul_le_mul_of_nonneg_left (finiteReplica_variance_le p v hp hs hv)
(inv_nonneg.2 (sq_nonneg (N : β)))
apply H.trans_eq
simp only [Fintype.card_fin]
rw [Real.sqrt_div hT,Real.sqrt_sq hn.le]
change ((N : β)^2)β»ΒΉ*(T+2*(N : β)*Real.sqrt T) = T/(N : β)^2+2*(Real.sqrt T/(N : β))
field_simp [ne_of_gt hn]
end ReplicaVarianceSplit
end SK.Analytic
end
end
end
end OAI
|