File size: 5,498 Bytes
dd14c26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import Mathlib
import OAI.Probability.LogConcave.Sampling.SpatialTensor

namespace OAI

section
section
noncomputable section
namespace LogConcaveSampling
open scoped Classical BigOperators NNReal

namespace JetCalculus
lemma gadj_scalar_at {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
    {ι : Type*} [Fintype ι] (b : ι → E) (s : ι → E → ℝ) {V : ι → E → ℝ} {p : E}
    (hV : ∀i,DifferentiableAt ℝ (V i) p) (c : ℝ) :
    gadj b s (fun i y => c*V i y) p=c*gadj b s V p := by
  unfold gadj cadj
  simp_rw [dir_const_mul_at (hV _)]
  rw [Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro i _
  ring
end JetCalculus

namespace TensorAtom
variable {S : Type} [Fintype S]

lemma jetCard (l : List S) (hN : l.Nodup) (hall : ∀s,s∈l) (hne : l≠[]) :
    2≤Fintype.card (S ⊕ Unit) := by
  have he := Fintype.card_congr (List.Nodup.getEquivOfForallMemList l hN hall)
  have hp := List.length_pos_iff.mpr hne
  simp only [Fintype.card_fin] at he
  simp only [Fintype.card_sum,Fintype.card_unit]
  omega

abbrev SplitIndex (l : List S) := ↥(l.toFinset.powerset.erase ∅)

omit [Fintype S] in
lemma splitIndex_nonempty {l : List S} (a : SplitIndex l) : a.val.Nonempty :=
  Finset.nonempty_iff_ne_empty.mpr (Finset.mem_erase.mp a.property).1

def splitAtom (l : List S) (hN : l.Nodup) (hall : ∀s,s∈l) (a : SplitIndex l) : TensorAtom (S ⊕ Unit) :=
  splitProduct l hN hall a.val (splitIndex_nonempty a)

lemma splitAtom_weight (l : List S) (hN : l.Nodup) (hall : ∀s,s∈l) (a : SplitIndex l) :
    (splitAtom l hN hall a).expression.weight=l.length-1 := splitProduct_weight _ _ _ _ _

lemma material_jetList {d : ℕ} {F : Point d → ℝ} {lam : ℝ≥0}
    (hF : Primitive F lam) (x : Point d) {r ρ : ℝ} (hr : 0<r)
    (hlam : 0<lam) (hl : (lam:ℝ)*r^2≤1/2) (hρ0 : 0≤ρ) (hρ1 : ρ<1)
    (l : List S) (hN : l.Nodup) (hall : ∀s,s∈l) (hne : l≠[])
    (c : S ⊕ Unit → Fin d) (y : Point d) :
    JetCalculus.mdir (1,0) jointSpace r (jointMean F x r)
      ((jetList l hN hall hne).eval F x r ((lam:ℝ)*r) c) (ρ,y)=
      ((extendedU l hN hall).adjoint (jetCard l hN hall hne)).eval F x r ((lam:ℝ)*r) c (ρ,y)+
      2*(r*((lam:ℝ)*r))*ρ*∑a : SplitIndex l,(splitAtom l hN hall a).eval F x r ((lam:ℝ)*r) c (ρ,y) := by
  let L : ℝ := (lam:ℝ)*r
  have hL : L≠0 := ne_of_gt (mul_pos (by exact_mod_cast hlam) hr)
  let v : S → Point d := fun s => JetCalculus.spaceBasis d (c (Sum.inl s))
  let U := jointU F x r L v l (c (Sum.inr ()))
  let V := fun k => jointU F x r L (Sum.elim v (fun _ : Unit => JetCalculus.spaceBasis d k))
    (Sum.inr ()::l.map Sum.inl) (c (Sum.inr ()))
  have hU := jointU_timeSmooth hF x hr hlam hl v l hN (c (Sum.inr ()))
  have hV (k : Fin d) := jointU_timeSmooth hF x hr hlam hl
    (Sum.elim v (fun _ : Unit => JetCalculus.spaceBasis d k)) _ (extra_list_nodup hN) (c (Sum.inr ()))
  have hA : ((extendedU l hN hall).adjoint (jetCard l hN hall hne)).eval F x r L c (ρ,y)=
      L⁻¹*JetCalculus.gadj jointSpace (jointScore F x r) V (ρ,y) := by
    rw [adjoint_eval]
    have he : (fun k => (extendedU l hN hall).eval F x r L (Sum.elim c (fun _ => k)))=
        fun k p => L⁻¹*V k p := by
      funext k
      rw [extendedU_eval]
      rfl
    rw [he]
    exact JetCalculus.gadj_scalar_at _ _ (fun k =>
      (hV k (ρ,y) (by dsimp; linarith) hρ1).differentiableAt (by simp)) _
  change JetCalculus.mdir (1,0) jointSpace r (jointMean F x r)
      ((jetList l hN hall hne).eval F x r L c) (ρ,y)=_
  rw [jetList_eval,JetCalculus.mdir_const_mul_at _ _ _ _
    ((hU (ρ,y) (by dsimp; linarith) hρ1).differentiableAt (by simp)),
    material_jointU hF x hr hlam hl hρ0 hρ1 v l hN,hA]
  rw [mul_add]
  congr 1
  simp only [splitAtom,splitProduct_eval]
  rw [←Finset.sum_coe_sort]
  simp only [Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro a _
  apply Finset.sum_congr rfl
  intro k _
  dsimp only [L,v]
  field_simp [hL]

end TensorAtom
end LogConcaveSampling

end

end

section

noncomputable section
namespace LogConcaveSampling
open scoped Classical BigOperators

namespace JetCalculus

lemma dir_time {d : ℕ} (P : Polynomial ℝ) (v : ℝ × Point d) (p : ℝ × Point d) :
    dir v (fun q : ℝ × Point d => P.eval q.1) p=P.derivative.eval p.1*v.1 := by
  have hh := (P.hasDerivAt p.1).comp_hasFDerivAt p (hasFDerivAt_fst (𝕜:=ℝ) (p:=p))
  simp only [Function.comp_def] at hh
  change (fderiv ℝ (fun q : ℝ × Point d => P.eval q.1) p) v=_
  rw [hh.fderiv]
  rfl

lemma mdir_time {d : ℕ} (P : Polynomial ℝ) (r : ℝ) (M : Fin d → ℝ × Point d → ℝ)
    (p : ℝ × Point d) :
    mdir (1,0) jointSpace r M (fun q : ℝ × Point d => P.eval q.1) p=P.derivative.eval p.1 := by
  unfold mdir
  simp only [dir_time,jointSpace,mul_zero,Finset.sum_const_zero,sub_zero,mul_one]

lemma gadj_time_at {d : ℕ} (P : Polynomial ℝ) (s : Fin d → ℝ × Point d → ℝ)
    {V : Fin d → ℝ × Point d → ℝ} {p : ℝ × Point d}
    (hV : ∀i,DifferentiableAt ℝ (V i) p) :
    gadj jointSpace s (fun i q => P.eval q.1*V i q) p=P.eval p.1*gadj jointSpace s V p := by
  have hP : DifferentiableAt ℝ (fun q : ℝ × Point d => P.eval q.1) p :=
    P.differentiable.differentiableAt.comp p differentiableAt_fst
  unfold gadj cadj
  simp_rw [dir_mul_at hP (hV _),dir_time]
  simp only [jointSpace,mul_zero,zero_mul,zero_add]
  rw [Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro i _
  ring

end JetCalculus
end LogConcaveSampling

end

end

end

end OAI