File size: 16,858 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 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | import OAI.Analysis.Calculus.Current.Holomorphic
/-! Differential ingredients for the wave-current divergence calculation.
The Gaussian pair is defined by its actual scalar expression. The calculus
lemmas take ordinary derivative certificates for input curves; they do not
assume the weighted conservation identity to be proved.
-/
namespace OAI.Analysis.Calculus.Current
noncomputable section
def squaredDistance {d : β} (W : Fin d β β) (v : Fin d β β) : β :=
β i, βW i - (v i : β)β ^ 2
def gaussianLog {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(y : β) (W : Fin d β β) : β :=
-(d : β) * Real.log y -
y / 2 * (ΞΊ * squaredDistance W v + ΞΊ' * squaredDistance W v')
/-- The pair weight `N` of equation (current-gaussian-pair), on `y > 0`. -/
def gaussianPair {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(y : β) (W : Fin d β β) : β := Real.exp (gaussianLog ΞΊ ΞΊ' v v' y W)
theorem gaussianPair_formula {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(y : β) (hy : 0 < y) (W : Fin d β β) :
gaussianPair ΞΊ ΞΊ' v v' y W = (y ^ d)β»ΒΉ *
Real.exp (-(y / 2 * (ΞΊ * squaredDistance W v + ΞΊ' * squaredDistance W v'))) := by
unfold gaussianPair gaussianLog
rw [sub_eq_add_neg, Real.exp_add]
congr 1
rw [neg_mul, Real.exp_neg, Real.exp_nat_mul, Real.exp_log hy]
theorem gaussianPair_pos {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(y : β) (W : Fin d β β) : 0 < gaussianPair ΞΊ ΞΊ' v v' y W :=
Real.exp_pos _
/-- Differentiate the exact Euclidean squared distance along an arbitrary real curve. -/
theorem hasDerivAt_squaredDistance {d : β} (W : β β Fin d β β)
(W' : Fin d β β) (v : Fin d β β) (t : β)
(hW : β i, HasDerivAt (fun s => W s i) (W' i) t) :
HasDerivAt (fun s => squaredDistance (W s) v)
(β i, 2 * inner β (W t i - (v i : β)) (W' i)) t := by
exact HasDerivAt.fun_sum fun i _ => ((hW i).sub_const (v i : β)).norm_sq
/-- Ordinary derivative of the exact logarithmic Gaussian pair. -/
theorem hasDerivAt_gaussianLog {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(y : β β β) (y' : β) (W : β β Fin d β β) (W' : Fin d β β) (t : β)
(hy : HasDerivAt y y' t) (hy0 : y t β 0)
(hW : β i, HasDerivAt (fun s => W s i) (W' i) t) :
HasDerivAt (fun s => gaussianLog ΞΊ ΞΊ' v v' (y s) (W s))
(-(d : β) * (y' / y t) -
((y' / 2) * (ΞΊ * squaredDistance (W t) v + ΞΊ' * squaredDistance (W t) v') +
y t / 2 *
(ΞΊ * (β i, 2 * inner β (W t i - (v i : β)) (W' i)) +
ΞΊ' * (β i, 2 * inner β (W t i - (v' i : β)) (W' i))))) t := by
exact ((hy.log hy0).const_mul (-(d : β))).sub
((hy.div_const 2).mul
(((hasDerivAt_squaredDistance W W' v t hW).const_mul ΞΊ).add
((hasDerivAt_squaredDistance W W' v' t hW).const_mul ΞΊ')))
/-- Ordinary derivative of the exact Gaussian pair. -/
theorem hasDerivAt_gaussianPair {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(y : β β β) (y' : β) (W : β β Fin d β β) (W' : Fin d β β) (t : β)
(hy : HasDerivAt y y' t) (hy0 : y t β 0)
(hW : β i, HasDerivAt (fun s => W s i) (W' i) t) :
HasDerivAt (fun s => gaussianPair ΞΊ ΞΊ' v v' (y s) (W s))
(gaussianPair ΞΊ ΞΊ' v v' (y t) (W t) *
(-(d : β) * (y' / y t) -
((y' / 2) * (ΞΊ * squaredDistance (W t) v + ΞΊ' * squaredDistance (W t) v') +
y t / 2 *
(ΞΊ * (β i, 2 * inner β (W t i - (v i : β)) (W' i)) +
ΞΊ' * (β i, 2 * inner β (W t i - (v' i : β)) (W' i)))))) t := by
exact (hasDerivAt_gaussianLog ΞΊ ΞΊ' v v' y y' W W' t hy hy0 hW).exp
/-- A real line in the actual complex imaginary-coordinate space. -/
def imaginaryLine {d : β} (z h : Index d β β) (t : β) : Index d β β :=
fun a => z a + (t : β) * h a
@[simp] theorem imaginaryLine_zero {d : β} (z h : Index d β β) :
imaginaryLine z h 0 = z := by
funext a
simp [imaginaryLine]
theorem hasDerivAt_imaginaryLine {d : β} (z h : Index d β β) (a : Index d) :
HasDerivAt (fun t : β => imaginaryLine z h t a) (h a) 0 := by
have hc : HasDerivAt (fun t : β => z a + t * h a) (h a) (0 : β) := by
simpa using ((hasDerivAt_id (0 : β)).mul_const (h a)).const_add (z a)
exact hc.comp_ofReal
private theorem hasDerivAt_complex_norm {f : β β β} {f' : β} {t : β}
(hf : HasDerivAt f f' t) (h0 : f t β 0) :
HasDerivAt (fun s => βf sβ) (inner β (f t) f' / βf tβ) t := by
have hh := hf.norm_sq.sqrt (pow_ne_zero 2 (norm_ne_zero_iff.mpr h0))
convert hh using 1
Β· funext s
simp
Β· simp
ring
def radiusSlope {d : β} (z h : Index d β β) : β :=
inner β (z none) (h none) / βz noneβ
def ratioSlope {d : β} (z h : Index d β β) : Fin d β β :=
fun i => (h (some (some i)) * z none - z (some (some i)) * h none) / z none ^ 2
theorem hasDerivAt_radius_line {d : β} (z h : Index d β β) (hY : z none β 0) :
HasDerivAt (fun t => βimaginaryLine z h t noneβ) (radiusSlope z h) 0 := by
simpa [imaginaryLine, radiusSlope] using
hasDerivAt_complex_norm (hasDerivAt_imaginaryLine z h none)
(by simpa [imaginaryLine] using hY)
theorem hasDerivAt_ratio_line {d : β} (z h : Index d β β) (hY : z none β 0)
(i : Fin d) :
HasDerivAt (fun t => ratio (imaginaryLine z h t) i) (ratioSlope z h i) 0 := by
have hc (a : Index d) : HasDerivAt (fun t : β => z a + t * h a) (h a) (0 : β) := by
simpa using ((hasDerivAt_id (0 : β)).mul_const (h a)).const_add (z a)
have hh := ((hc (some (some i))).div (hc none) (by simpa using hY)).comp_ofReal
simpa [ratio, imaginaryLine, ratioSlope] using hh
/-- The actual scalar field `N` on the imaginary coordinates. -/
def gaussianField {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) (z : Index d β β) : β :=
gaussianPair ΞΊ ΞΊ' v v' βz noneβ (ratio z)
/-- Explicit directional derivative of `log N` in the actual imaginary coordinates. -/
def gaussianLogSlope {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(z h : Index d β β) : β :=
-(d : β) * (radiusSlope z h / βz noneβ) -
((radiusSlope z h / 2) *
(ΞΊ * squaredDistance (ratio z) v + ΞΊ' * squaredDistance (ratio z) v') +
βz noneβ / 2 *
(ΞΊ * (β i, 2 * inner β (ratio z i - (v i : β)) (ratioSlope z h i)) +
ΞΊ' * (β i, 2 * inner β (ratio z i - (v' i : β)) (ratioSlope z h i))))
/-- Every real directional derivative of the exact Gaussian field is verified. -/
theorem hasDerivAt_gaussianField_line {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(z h : Index d β β) (hY : z none β 0) :
HasDerivAt (fun t => gaussianField ΞΊ ΞΊ' v v' (imaginaryLine z h t))
(gaussianField ΞΊ ΞΊ' v v' z * gaussianLogSlope ΞΊ ΞΊ' v v' z h) 0 := by
have hh := hasDerivAt_gaussianPair ΞΊ ΞΊ' v v'
(fun t => βimaginaryLine z h t noneβ) (radiusSlope z h)
(fun t => ratio (imaginaryLine z h t)) (ratioSlope z h) 0
(hasDerivAt_radius_line z h hY)
(by simpa [imaginaryLine] using norm_ne_zero_iff.mpr hY)
(hasDerivAt_ratio_line z h hY)
simpa only [gaussianField, gaussianLogSlope, imaginaryLine_zero] using hh
/-- The two real directional derivatives that form `β conj(Vβ) barDβ`.
The equivalence with the coordinate sum is real linearity of the differential. -/
def barDirectional {d : β} (f : (Index d β β) β β) (z V : Index d β β) : β :=
((deriv (fun t => f (imaginaryLine z V t)) 0 : β) : β) +
Complex.I * ((deriv (fun t => f (imaginaryLine z (fun a => Complex.I * V a) t)) 0 : β) : β)
theorem gaussianField_barDirectional {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(z V : Index d β β) (hY : z none β 0) :
barDirectional (gaussianField ΞΊ ΞΊ' v v') z V =
(gaussianField ΞΊ ΞΊ' v v' z : β) *
((gaussianLogSlope ΞΊ ΞΊ' v v' z V : β) +
Complex.I * (gaussianLogSlope ΞΊ ΞΊ' v v' z (fun a => Complex.I * V a) : β)) := by
unfold barDirectional
rw [(hasDerivAt_gaussianField_line ΞΊ ΞΊ' v v' z V hY).deriv,
(hasDerivAt_gaussianField_line ΞΊ ΞΊ' v v' z (fun a => Complex.I * V a) hY).deriv]
push_cast
ring
theorem complex_inner_pair (a b : β) :
(inner β a b : β) + Complex.I * (inner β a (Complex.I * b) : β) = a * star b := by
apply Complex.ext <;> simp <;> ring
def distanceSlope {d : β} (W h : Fin d β β) (v : Fin d β β) : β :=
β i, 2 * inner β (W i - (v i : β)) (h i)
theorem distanceSlope_pair {d : β} (W h : Fin d β β) (v : Fin d β β) :
(distanceSlope W h v : β) +
Complex.I * (distanceSlope W (fun i => Complex.I * h i) v : β) =
2 * β i, (W i - (v i : β)) * star (h i) := by
simp only [distanceSlope, Complex.ofReal_sum, Complex.ofReal_mul,
Complex.ofReal_ofNat, Finset.mul_sum]
rw [β Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro i _
linear_combination (2 : β) * complex_inner_pair (W i - (v i : β)) (h i)
def energySlope {d : β} (y : β) (W : Fin d β β) (y' : β)
(W' : Fin d β β) (v : Fin d β β) : β :=
y' * squaredDistance W v + y * distanceSlope W W' v
theorem energySlope_pair {d : β} (y yβ yβ : β) (W h : Fin d β β) (v : Fin d β β) :
(energySlope y W yβ h v : β) +
Complex.I * (energySlope y W yβ (fun i => Complex.I * h i) v : β) =
((yβ : β) + Complex.I * (yβ : β)) * (squaredDistance W v : β) +
(y : β) * (2 * β i, (W i - (v i : β)) * star (h i)) := by
have hd := distanceSlope_pair W h v
simp only [energySlope, Complex.ofReal_add, Complex.ofReal_mul]
linear_combination (y : β) * hd
theorem ratioSlope_I {d : β} (z h : Index d β β) (i : Fin d) :
ratioSlope z (fun a => Complex.I * h a) i = Complex.I * ratioSlope z h i := by
unfold ratioSlope
ring
theorem radiusSlope_pair {d : β} (z h : Index d β β) :
(radiusSlope z h : β) +
Complex.I * (radiusSlope z (fun a => Complex.I * h a) : β) =
z none * star (h none) / (βz noneβ : β) := by
unfold radiusSlope
push_cast
rw [β mul_div_assoc, β add_div, complex_inner_pair]
theorem ratioSlope_tangentVector {d : β} (z : Index d β β) (hY : z none β 0)
(v : Fin d β β) (i : Fin d) :
ratioSlope z (tangentVector (fun i => (v i : β)) (ratio z)) i =
((v i : β) - ratio z i) / (2 * z none) := by
simp only [ratioSlope, tangentVector, ratio]
field_simp
ring
theorem radiusSlope_tangentVector_pair {d : β} (z : Index d β β)
(v : Fin d β β) :
(radiusSlope z (tangentVector (fun i => (v i : β)) (ratio z)) : β) +
Complex.I * (radiusSlope z
(fun a => Complex.I * tangentVector (fun i => (v i : β)) (ratio z) a) : β) =
z none / (βz noneβ : β) := by
rw [radiusSlope_pair]
simp [tangentVector]
theorem norm_square_eq_mul_star (z : β) : (βzβ : β) ^ 2 = z * star z := by
rw [β Complex.ofReal_pow]
apply Complex.ext <;> simp [Complex.sq_norm, Complex.normSq_apply] ; ring
theorem norm_div_star (Y : β) (hY : Y β 0) :
(βYβ : β) / star Y = Y / (βYβ : β) := by
have hn : (βYβ : β) β 0 := by exact_mod_cast norm_ne_zero_iff.mpr hY
have hs : star Y β 0 := star_ne_zero.mpr hY
apply (div_eq_div_iff hs hn).mpr
simpa only [β pow_two] using norm_square_eq_mul_star Y
theorem squaredDistance_coe {d : β} (W : Fin d β β) (v : Fin d β β) :
(squaredDistance W v : β) =
β i, (W i - (v i : β)) * star (W i - (v i : β)) := by
simp only [squaredDistance, Complex.ofReal_sum, Complex.ofReal_pow]
apply Finset.sum_congr rfl
intro i _
exact norm_square_eq_mul_star _
private theorem gaussian_energy_cancellation {d : β} (Y : β) (hY : Y β 0)
(W : Fin d β β) (v w : Fin d β β) :
(Y / (βYβ : β)) * (squaredDistance W w : β) +
(βYβ : β) * (2 * β i, (W i - (w i : β)) *
star (((v i : β) - W i) / (2 * Y))) =
(Y / (βYβ : β)) * β i, (W i - (w i : β)) * ((v i : β) - (w i : β)) := by
rw [squaredDistance_coe]
simp only [Finset.mul_sum]
rw [β Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro i _
have hs : star Y β 0 := star_ne_zero.mpr hY
have hc : (βYβ : β) * (2 * ((W i - (w i : β)) *
star (((v i : β) - W i) / (2 * Y)))) =
((βYβ : β) / star Y) * (W i - (w i : β)) * ((v i : β) - star (W i)) := by
simp only [star_divβ, star_sub, star_mul, star_ofNat, Complex.star_def,
Complex.conj_ofReal]
field_simp
rw [hc, norm_div_star Y hY]
simp only [star_sub, Complex.star_def, Complex.conj_ofReal]
ring
/-- The Gaussian directional cancellation in equation (gaussian-directional-identity),
written using the two actual real differential components already proved above. -/
theorem gaussian_energy_tangent_pair {d : β} (z : Index d β β) (hY : z none β 0)
(v w : Fin d β β) :
let V := tangentVector (fun i => (v i : β)) (ratio z)
(energySlope βz noneβ (ratio z) (radiusSlope z V) (ratioSlope z V) w : β) +
Complex.I * (energySlope βz noneβ (ratio z)
(radiusSlope z (fun a => Complex.I * V a))
(ratioSlope z (fun a => Complex.I * V a)) w : β) =
(z none / (βz noneβ : β)) *
β i, (ratio z i - (w i : β)) * ((v i : β) - (w i : β)) := by
dsimp only
rw [funext (ratioSlope_I z (tangentVector (fun i => (v i : β)) (ratio z)))]
rw [energySlope_pair, radiusSlope_tangentVector_pair]
simp_rw [ratioSlope_tangentVector z hY]
exact gaussian_energy_cancellation (z none) hY (ratio z) v w
theorem gaussianLogSlope_energy {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(z h : Index d β β) :
gaussianLogSlope ΞΊ ΞΊ' v v' z h =
-(d : β) * (radiusSlope z h / βz noneβ) -
(ΞΊ * energySlope βz noneβ (ratio z) (radiusSlope z h) (ratioSlope z h) v +
ΞΊ' * energySlope βz noneβ (ratio z) (radiusSlope z h) (ratioSlope z h) v') / 2 := by
unfold gaussianLogSlope energySlope distanceSlope
ring
theorem gaussian_energy_tangent_pair_phase {d : β} (z : Index d β β)
(hY : z none β 0) (v w : Fin d β β) :
let V := tangentVector (fun i => (v i : β)) (ratio z)
(energySlope βz noneβ (ratio z) (radiusSlope z V) (ratioSlope z V) w : β) +
Complex.I * (energySlope βz noneβ (ratio z)
(radiusSlope z (fun a => Complex.I * V a))
(ratioSlope z (fun a => Complex.I * V a)) w : β) =
-2 * (z none / (βz noneβ : β)) *
(β a, phaseRow (fun i => (w i : β)) a * V a) := by
dsimp only
rw [gaussian_energy_tangent_pair z hY, phase_polarization]
have hs : (β i, ((w i : β) - ratio z i) * ((w i : β) - (v i : β))) =
β i, (ratio z i - (w i : β)) * ((v i : β) - (w i : β)) := by
apply Finset.sum_congr rfl
intro i _
ring
rw [hs]
ring
/-- The full logarithmic Gaussian directional identity, for two distinct modes. -/
theorem gaussianLogSlope_tangent_pair {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(z : Index d β β) (hY : z none β 0) :
let V := tangentVector (fun i => (v i : β)) (ratio z)
(gaussianLogSlope ΞΊ ΞΊ' v v' z V : β) +
Complex.I * (gaussianLogSlope ΞΊ ΞΊ' v v' z (fun a => Complex.I * V a) : β) =
(z none / (βz noneβ : β)) *
(-(d : β) / (βz noneβ : β) +
(ΞΊ' : β) * β a, phaseRow (fun i => (v' i : β)) a * V a) := by
dsimp only
have hr := radiusSlope_tangentVector_pair z v
have hv := gaussian_energy_tangent_pair_phase z hY v v
have hv' := gaussian_energy_tangent_pair_phase z hY v v'
dsimp only at hv hv'
rw [phase_tangent] at hv
simp only [mul_zero] at hv
simp only [gaussianLogSlope_energy, Complex.ofReal_sub, Complex.ofReal_mul,
Complex.ofReal_neg, Complex.ofReal_natCast, Complex.ofReal_div,
Complex.ofReal_add, Complex.ofReal_ofNat]
linear_combination (-(d : β) / (βz noneβ : β)) * hr -
((ΞΊ : β) / 2) * hv - ((ΞΊ' : β) / 2) * hv'
/-- Equation (current-log-derivative) applied to the exact scalar Gaussian field. -/
theorem gaussianField_tangent_derivative {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β)
(z : Index d β β) (hY : z none β 0) :
let V := tangentVector (fun i => (v i : β)) (ratio z)
barDirectional (gaussianField ΞΊ ΞΊ' v v') z V =
(gaussianField ΞΊ ΞΊ' v v' z : β) * (z none / (βz noneβ : β)) *
(-(d : β) / (βz noneβ : β) +
(ΞΊ' : β) * β a, phaseRow (fun i => (v' i : β)) a * V a) := by
dsimp only
rw [gaussianField_barDirectional ΞΊ ΞΊ' v v' z _ hY,
gaussianLogSlope_tangent_pair ΞΊ ΞΊ' v v' z hY]
ring
end
end OAI.Analysis.Calculus.Current
|