File size: 32,873 Bytes
a2ee19a | 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | import Mathlib
import OAI.Probability.ParisiFinite.PartitionSite
namespace OAI
/-! Abs Mul Exp Le. -/
noncomputable section
open scoped BigOperators ComplexConjugate InnerProductSpace Topology ComplexOrder
open Filter
open scoped BigOperators
open scoped Matrix Matrix.Norms.L2Operator ComplexConjugate
open scoped InnerProductSpace ComplexConjugate
open Filter Topology
open Filter Set Topology
open scoped InnerProductSpace ComplexConjugate Topology
open scoped InnerProductSpace
open scoped BigOperators Topology InnerProductSpace
open scoped BigOperators InnerProductSpace
open scoped BigOperators Matrix Topology ComplexConjugate
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators Topology
open scoped BigOperators Matrix Topology
open scoped BigOperators Matrix Topology Matrix.Norms.Operator
open scoped Topology
open Filter Asymptotics
open scoped InnerProductSpace Topology
open scoped InnerProductSpace BigOperators
open scoped InnerProductSpace Topology BigOperators
open scoped Topology BigOperators
open scoped Matrix Matrix.Norms.L2Operator InnerProductSpace
open scoped Matrix Matrix.Norms.L2Operator InnerProductSpace BigOperators
open Filter ContinuousLinearMap
open ContinuousLinearMap
open scoped InnerProductSpace BigOperators Topology
open ContinuousLinearMap InnerProductSpace
open ContinuousLinearMap Filter
open Filter MeasureTheory
open scoped Topology ENNReal
open MeasureTheory ProbabilityTheory
open scoped BigOperators Topology RealInnerProductSpace
open scoped BigOperators TensorProduct
open scoped Topology InnerProductSpace
open MeasureTheory Filter
open MeasureTheory ProbabilityTheory Complex
open scoped BigOperators Topology InnerProductSpace ComplexConjugate
open scoped BigOperators Topology NNReal
open scoped BigOperators NNReal Topology
open scoped BigOperators NNReal
open scoped NNReal Topology
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal Topology
namespace ParisiFinite
lemma abs_mul_exp_le (c z : ℝ) :
|z| * Real.exp (c*|z|) ≤ Real.exp ((c+1)*|z|) := by
have hz : |z| ≤ Real.exp |z| := by linarith [Real.add_one_le_exp |z|]
calc
_ ≤ Real.exp |z| * Real.exp (c*|z|) := mul_le_mul_of_nonneg_right hz (Real.exp_pos _).le
_ = Real.exp ((c+1)*|z|) := by rw [← Real.exp_add]; congr 1; ring
lemma exp_scale_near_le {L : ℝ≥0} {f : ℝ → ℝ} (hf : LipschitzWith L f)
(a x s₀ : ℝ) {s : ℝ} (hs : |s-s₀| ≤ 1) (z : ℝ) :
Real.exp (a*f (x+s*z)) ≤
Real.exp (|a| * |f x|)*Real.exp ((|a| * L*(|s₀|+1))*|z|) := by
have hss : |s| ≤ |s₀|+1 := by
have ht := abs_add_le (s-s₀) s₀
rw [sub_add_cancel] at ht
linarith
rw [← Real.exp_add]
apply Real.exp_le_exp.mpr
have hb := shift_norm_le hf x s z
have hmul := mul_le_mul_of_nonneg_right
(mul_le_mul_of_nonneg_left hss L.coe_nonneg) (abs_nonneg z)
calc
a*f (x+s*z) ≤ |a| * |f (x+s*z)| := by simpa only [abs_mul] using le_abs_self (a*f (x+s*z))
_ ≤ |a| * (|f x|+(L:ℝ)*(|s₀|+1)*|z|) := mul_le_mul_of_nonneg_left (by linarith) (abs_nonneg a)
_ = _ := by ring
lemma coord_exp_scale_near_le {L : ℝ≥0} {f : ℝ → ℝ} (hf : LipschitzWith L f)
(a x s₀ : ℝ) {s : ℝ} (hs : |s-s₀| ≤ 1) (z : ℝ) :
|z| * Real.exp (a*f (x+s*z)) ≤
Real.exp (|a| * |f x|)*Real.exp ((|a| * L*(|s₀|+1)+1)*|z|) := by
calc
_ ≤ |z| * (Real.exp (|a| * |f x|)*Real.exp ((|a| * L*(|s₀|+1))*|z|)) :=
mul_le_mul_of_nonneg_left (exp_scale_near_le hf a x s₀ hs z) (abs_nonneg z)
_ = Real.exp (|a| * |f x|)*(|z| * Real.exp ((|a| * L*(|s₀|+1))*|z|)) := by ring
_ ≤ _ := mul_le_mul_of_nonneg_left (abs_mul_exp_le _ z) (Real.exp_pos _).le
lemma integrable_coord_exp_weight {L : ℝ≥0} {f g : ℝ → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) {M : ℝ≥0} (hM : ∀ x, |g x| ≤ M) (a s x : ℝ) :
Integrable (fun z => z*(Real.exp (a*f (x+s*z))*g (x+s*z))) (gaussianReal 0 1) := by
have hc := hf.continuous
apply (((integrable_exp_abs _).const_mul (Real.exp (|a| * |f x|))).mul_const (M:ℝ)).mono'
(by fun_prop)
exact ae_of_all _ fun z => by
simp only [Real.norm_eq_abs, abs_mul, abs_of_pos (Real.exp_pos _)]
rw [← mul_assoc]
exact mul_le_mul (coord_exp_scale_near_le hf a x s (by simp) z) (hM _)
(abs_nonneg _) (by positivity)
lemma hasDerivAt_scale_expMass (f : SmoothField) (a s x : ℝ) :
HasDerivAt (fun r => expMass a r f.val x)
(∫ z, a * (z*(Real.exp (a*f.val (x+s*z))*f.d1 (x+s*z))) ∂gaussianReal 0 1) s := by
have hc := f.continuousVal
have hc₁ := f.continuousD1
apply (hasDerivAt_integral_of_dominated_loc_of_deriv_le
(s := Metric.ball s 1)
(bound := fun z => (Real.exp (|a| * |f.val x|)*
Real.exp ((|a| * f.bound1*(|s|+1)+1)*|z|)) * (|a| * f.bound1))
(F' := fun r z => a * (z*(Real.exp (a*f.val (x+r*z))*f.d1 (x+r*z))))
(Metric.ball_mem_nhds _ (by norm_num)) ?_ (integrable_exp_shift f.lipschitz a x s)
(by fun_prop) ?_ ?_ ?_).2
· exact Eventually.of_forall fun _ => by fun_prop
· exact ae_of_all _ fun z r hr => by
simp only [Real.norm_eq_abs, abs_mul, abs_of_pos (Real.exp_pos _)]
have he : |a| * (|z| * (Real.exp (a*f.val (x+r*z))*|f.d1 (x+r*z)|)) =
(|z| * Real.exp (a*f.val (x+r*z)))*(|a| * |f.d1 (x+r*z)|) := by ring
rw [he]
apply mul_le_mul (coord_exp_scale_near_le f.lipschitz a x s
(by simpa [Real.dist_eq] using hr.le) z)
· exact mul_le_mul_of_nonneg_left (f.normD1 _) (abs_nonneg _)
· positivity
· positivity
· exact ((integrable_exp_abs _).const_mul _).mul_const _
· exact ae_of_all _ fun z r _ => by
have h := ((f.hasD1 (x+r*z)).comp r (((hasDerivAt_id r).mul_const z).const_add x)).const_mul a
convert h.exp using 1 <;> first | rfl | (simp only [Function.comp_apply, id_eq, one_mul]; ring)
lemma hasDerivAt_scale_average (f : SmoothField) (s x : ℝ) :
HasDerivAt (fun r => ∫ z, f.val (x+r*z) ∂gaussianReal 0 1)
(∫ z, z*f.d1 (x+s*z) ∂gaussianReal 0 1) s := by
have hc := f.continuousVal
have hc₁ := f.continuousD1
apply (hasDerivAt_integral_of_dominated_loc_of_deriv_le (s := Set.univ)
(bound := fun z => |z| * (f.bound1:ℝ)) (F' := fun r z => z*f.d1 (x+r*z))
univ_mem ?_ (integrable_shift f.lipschitz x s) (by fun_prop) ?_
(SKQAOA.integrable_abs_standard.mul_const _) ?_).2
· exact Eventually.of_forall fun _ => by fun_prop
· exact ae_of_all _ fun z r _ => by
rw [Real.norm_eq_abs, abs_mul]
exact mul_le_mul_of_nonneg_left (f.normD1 _) (abs_nonneg _)
· exact ae_of_all _ fun z r _ => by
convert (f.hasD1 (x+r*z)).comp r (((hasDerivAt_id r).mul_const z).const_add x) using 1 <;>
first | rfl | (simp only [one_mul]; ring)
lemma gaussian_tilt_ibp (f : SmoothField) (a s x : ℝ) :
(∫ z, z*(Real.exp (a*f.val (x+s*z))*f.d1 (x+s*z)) ∂gaussianReal 0 1) =
s * (expMoment a s f.val f.d2 x + a*expMoment a s f.val (fun y => f.d1 y^2) x) := by
let G : ℝ → ℝ := fun z => Real.exp (a*f.val (x+s*z))*f.d1 (x+s*z)
let G' : ℝ → ℝ := fun z => s*(Real.exp (a*f.val (x+s*z))*(f.d2 (x+s*z)+a*f.d1 (x+s*z)^2))
have hD : ∀ z, HasDerivAt G (G' z) z := by
intro z
have h₁ := (f.hasD1 (x+s*z)).comp z (((hasDerivAt_id z).const_mul s).const_add x)
have h₂ := (f.hasD2 (x+s*z)).comp z (((hasDerivAt_id z).const_mul s).const_add x)
convert ((h₁.const_mul a).exp.mul h₂) using 1 <;>
first | rfl | (dsimp [G']; ring)
have hi := integrable_exp_weight f.lipschitz f.continuousD1 f.normD1 a s x
have hi₂ := integrable_exp_weight f.lipschitz f.continuousD2 f.normD2 a s x
have hs := integrable_exp_weight f.lipschitz (g := fun y => f.d1 y^2)
(by have hc := f.continuousD1; fun_prop) (sq_bound f.normD1) a s x
have hi' : Integrable G' (gaussianReal 0 1) := by
convert (hi₂.add (hs.const_mul a)).const_mul s using 1
funext z
dsimp [G']
ring
have he := SKGaussian.integral_mul_eq_integral_deriv hD hi hi'
(integrable_coord_exp_weight f.lipschitz f.continuousD1 f.normD1 a s x)
change (∫ z, z*G z ∂gaussianReal 0 1) = _
rw [he]
have heq : G' = fun z => s *
(Real.exp (a*f.val (x+s*z))*f.d2 (x+s*z) +
a*(Real.exp (a*f.val (x+s*z))*f.d1 (x+s*z)^2)) := by
funext z
dsimp [G']
ring
rw [heq, integral_const_mul, integral_add hi₂ (hs.const_mul a), integral_const_mul]
rfl
end ParisiFinite
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal Topology
namespace ParisiFinite
lemma hasDerivAt_step_scale (f : SmoothField) (a s x : ℝ) :
HasDerivAt (fun r => step a r f.val x)
(s*(tiltedMean a s f.val f.d2 x + a*tiltedMean a s f.val (fun y => f.d1 y^2) x)) s := by
by_cases ha : a = 0
· subst a
have h := hasDerivAt_scale_average f s x
have hb := gaussian_tilt_ibp f 0 s x
simp only [zero_mul, Real.exp_zero, one_mul, add_zero, expMoment] at hb
rw [hb] at h
simpa only [step, logMean_zero, tiltedMean_zero, zero_mul, add_zero] using h
· have h := ((hasDerivAt_scale_expMass f a s x).log
(expMass_pos f.lipschitz a s x).ne').div_const a
rw [integral_const_mul, gaussian_tilt_ibp] at h
have he : (a*(s*(expMoment a s f.val f.d2 x + a*expMoment a s f.val (fun y => f.d1 y^2) x)) /
expMass a s f.val x) / a =
s*(tiltedMean a s f.val f.d2 x + a*tiltedMean a s f.val (fun y => f.d1 y^2) x) := by
unfold tiltedMean
field_simp
rw [he] at h
have hs : (fun r => step a r f.val x) =
(fun r => Real.log (expMass a r f.val x) / a) := by
funext r
simp [step, logMean, ha, expMass]
rw [hs]
exact h
lemma hasDerivAt_transform_scale (f : SmoothField) (a s x : ℝ) :
HasDerivAt (fun r => (f.transform a r).val x)
(s*((f.transform a s).d2 x + a*((f.transform a s).d1 x)^2)) s := by
convert hasDerivAt_step_scale f a s x using 1 <;>
first | rfl | (dsimp [SmoothField.transform]; ring)
def fieldOnInterval (f : SmoothField) (a b t : ℝ) : SmoothField :=
f.transform a (Real.sqrt (b-t))
lemma hasDerivAt_fieldOnInterval_time (f : SmoothField) (a b t x : ℝ) (ht : t < b) :
HasDerivAt (fun r => (fieldOnInterval f a b r).val x)
(-(1/2 : ℝ)*((fieldOnInterval f a b t).d2 x +
a*((fieldOnInterval f a b t).d1 x)^2)) t := by
have hb : 0 < b-t := sub_pos.mpr ht
have hs := (((hasDerivAt_id t).const_sub b).sqrt (ne_of_gt hb))
have h := (hasDerivAt_transform_scale f a (Real.sqrt (b-t)) x).comp t hs
convert h using 1 <;>
first | rfl | (dsimp [fieldOnInterval]; field_simp)
@[simp] lemma fieldOnInterval_right (f : SmoothField) (a b x : ℝ) :
(fieldOnInterval f a b b).val x = f.val x := by
by_cases ha : a = 0
· simp [fieldOnInterval, SmoothField.transform, step, logMean, ha]
· simp [fieldOnInterval, SmoothField.transform, step, logMean, ha]
lemma fieldOnInterval_spatial1 (f : SmoothField) (a b t x : ℝ) :
HasDerivAt (fieldOnInterval f a b t).val ((fieldOnInterval f a b t).d1 x) x :=
(fieldOnInterval f a b t).hasD1 x
lemma fieldOnInterval_spatial2 (f : SmoothField) (a b t x : ℝ) :
HasDerivAt (fieldOnInterval f a b t).d1 ((fieldOnInterval f a b t).d2 x) x :=
(fieldOnInterval f a b t).hasD2 x
lemma fieldOnInterval_terminal (β : ℝ≥0) (hβ : 0 < β) (a b x : ℝ) :
(fieldOnInterval (terminalField β hβ) a b b).val x =
Real.log (2*Real.cosh ((β:ℝ)*x)) / β := by
rw [fieldOnInterval_right]
rfl
end ParisiFinite
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal Topology
namespace ParisiFinite
section Ambient
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
def ambientStep (a : ℝ) (c : E) (f : E → ℝ) (x : E) : ℝ :=
logMean (gaussianReal 0 1) a (fun z => f (x+z • c))
def ambientMass (a : ℝ) (c : E) (f : E → ℝ) (x : E) : ℝ :=
∫ z, Real.exp (a*f (x+z • c)) ∂gaussianReal 0 1
def ambientMoment (a : ℝ) (c : E) (f g : E → ℝ) (x : E) : ℝ :=
∫ z, Real.exp (a*f (x+z • c))*g (x+z • c) ∂gaussianReal 0 1
def ambientTilt (a : ℝ) (c : E) (f g : E → ℝ) (x : E) : ℝ :=
ambientMoment a c f g x / ambientMass a c f x
lemma line_lipschitz {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f) (x c : E) :
LipschitzWith (L*‖c‖₊) (fun z : ℝ => f (x+z • c)) := by
rw [lipschitzWith_iff_norm_sub_le]
intro z w
have h := hf.norm_sub_le (x+z • c) (x+w • c)
rw [add_sub_add_left_eq_sub, ← sub_smul, norm_smul] at h
simpa [NNReal.coe_mul, mul_comm, mul_left_comm, mul_assoc] using h
lemma integrable_ambient {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f) (x c : E) :
Integrable (fun z : ℝ => f (x+z • c)) (gaussianReal 0 1) := by
simpa only [zero_add, one_mul] using integrable_shift (line_lipschitz hf x c) 0 1
lemma integrable_exp_ambient {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f) (a : ℝ) (x c : E) :
Integrable (fun z : ℝ => Real.exp (a*f (x+z • c))) (gaussianReal 0 1) := by
simpa only [zero_add, one_mul] using integrable_exp_shift (line_lipschitz hf x c) a 0 1
lemma ambientMass_pos {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f) (a : ℝ) (c x : E) :
0 < ambientMass a c f x := integral_exp_pos (integrable_exp_ambient hf a x c)
lemma integrable_ambient_weight {L : ℝ≥0} {f g : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) {M : ℝ} (hM : ∀ x, |g x| ≤ M) (a : ℝ) (c x : E) :
Integrable (fun z => Real.exp (a*f (x+z • c))*g (x+z • c)) (gaussianReal 0 1) := by
apply (integrable_exp_ambient hf a x c).mul_bdd (by fun_prop)
exact ae_of_all _ fun z => by simpa only [Real.norm_eq_abs] using hM (x+z • c)
lemma ambientStep_lipschitz {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f)
{a : ℝ} (ha : 0 ≤ a) (c : E) : LipschitzWith L (ambientStep a c f) := by
rw [lipschitzWith_iff_norm_sub_le]
intro x y
rw [Real.norm_eq_abs]
apply logMean_stable ha (integrable_ambient hf x c) (integrable_ambient hf y c)
(integrable_exp_ambient hf a x c) (integrable_exp_ambient hf a y c)
intro z
simpa only [Real.norm_eq_abs, add_sub_add_right_eq_sub] using
hf.norm_sub_le (x+z • c) (y+z • c)
lemma ambient_exp_near_le {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f)
(a : ℝ) (x₀ c : E) {x : E} (hx : ‖x-x₀‖ ≤ 1) (z : ℝ) :
Real.exp (a*f (x+z • c)) ≤
Real.exp (|a| *(|f x₀|+L))*Real.exp ((|a| *L*‖c‖)*|z|) := by
have hb : |f (x+z • c)| ≤ |f x₀| + L + (L:ℝ)*‖c‖*|z| := by
have hv := hf.norm_sub_le (x+z • c) x₀
have ht := norm_add_le (x-x₀) (z • c)
have he : x+z • c-x₀ = (x-x₀)+z • c := by abel
rw [he] at hv
rw [norm_smul, Real.norm_eq_abs] at ht
have htri := abs_add_le (f (x+z • c)-f x₀) (f x₀)
rw [sub_add_cancel] at htri
rw [Real.norm_eq_abs] at hv
nlinarith [L.coe_nonneg]
rw [← Real.exp_add]
apply Real.exp_le_exp.mpr
calc
_ ≤ |a| * |f (x+z • c)| := by simpa only [abs_mul] using le_abs_self (a*f (x+z • c))
_ ≤ |a| *(|f x₀|+L+(L:ℝ)*‖c‖*|z|) := mul_le_mul_of_nonneg_left hb (abs_nonneg _)
_ = _ := by ring
lemma continuous_ambientMoment {L : ℝ≥0} {f g : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) {M : ℝ} (hM : ∀ x, |g x| ≤ M) (a : ℝ) (c : E) :
Continuous (ambientMoment a c f g) := by
have hc := hf.continuous
apply continuous_iff_continuousAt.mpr
intro x₀
apply continuousAt_of_dominated
(bound := fun z => (Real.exp (|a| *(|f x₀|+L))*Real.exp ((|a| *L*‖c‖)*|z|))*M)
· exact Eventually.of_forall fun _ => (integrable_ambient_weight hf hg hM a c _).aestronglyMeasurable
· filter_upwards [Metric.ball_mem_nhds x₀ (by norm_num : (0:ℝ)<1)] with x hx
exact ae_of_all _ fun z => by
rw [Real.norm_eq_abs, abs_mul, abs_of_pos (Real.exp_pos _)]
apply mul_le_mul (ambient_exp_near_le hf a x₀ c (by have hh : dist x x₀ < 1 := hx; simpa only [dist_eq_norm] using hh.le) z)
(hM _) (abs_nonneg _)
positivity
· exact ((integrable_exp_abs _).const_mul _).mul_const _
· exact ae_of_all _ fun z => by fun_prop
lemma continuous_ambientTilt {L : ℝ≥0} {f g : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) {M : ℝ} (hM : ∀ x, |g x| ≤ M) (a : ℝ) (c : E) :
Continuous (ambientTilt a c f g) := by
have he : ambientMass a c f = ambientMoment a c f (fun _ => 1) := by
funext x
simp [ambientMass, ambientMoment]
have hm : Continuous (ambientMass a c f) := by
rw [he]
exact continuous_ambientMoment hf continuous_const (by intro; norm_num : ∀ x : E, |(1:ℝ)| ≤ 1) a c
exact (continuous_ambientMoment hf hg hM a c).div hm (fun x => (ambientMass_pos hf a c x).ne')
@[simp] lemma ambientTilt_zero (c : E) (f g : E → ℝ) (x : E) :
ambientTilt 0 c f g x = ∫ z, g (x+z • c) ∂gaussianReal 0 1 := by
simp [ambientTilt, ambientMoment, ambientMass]
lemma abs_ambientTilt_le {L : ℝ≥0} {f g : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) {M : ℝ} (hM : ∀ x, |g x| ≤ M) (a : ℝ) (c x : E) :
|ambientTilt a c f g x| ≤ M := by
have hi := integrable_ambient_weight hf hg hM a c x
have hp := ambientMass_pos hf a c x
unfold ambientTilt
rw [abs_div, abs_of_pos hp, div_le_iff₀ hp]
apply abs_integral_le_integral_abs.trans
have h := integral_mono hi.abs ((integrable_exp_ambient hf a x c).const_mul M)
(fun z => by
rw [abs_mul, abs_of_pos (Real.exp_pos _), mul_comm M]
exact mul_le_mul_of_nonneg_left (hM _) (Real.exp_pos _).le)
simpa only [integral_const_mul, ambientMass] using h
end Ambient
end ParisiFinite
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal Topology
namespace ParisiFinite
section Ambient
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
lemma ambient_exp_near_le_radius {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f)
(a : ℝ) (x₀ c : E) {x : E} {r : ℝ} (hx : ‖x-x₀‖ ≤ r) (z : ℝ) :
Real.exp (a*f (x+z • c)) ≤
Real.exp (|a| * (|f x₀|+(L:ℝ)*r))*Real.exp ((|a| * L*‖c‖)*|z|) := by
have hb : |f (x+z • c)| ≤ |f x₀| + (L:ℝ)*r + (L:ℝ)*‖c‖*|z| := by
have hv := hf.norm_sub_le (x+z • c) x₀
have ht := norm_add_le (x-x₀) (z • c)
have he : x+z • c-x₀ = (x-x₀)+z • c := by abel
rw [he] at hv
rw [norm_smul, Real.norm_eq_abs] at ht
have htri := abs_add_le (f (x+z • c)-f x₀) (f x₀)
rw [sub_add_cancel] at htri
rw [Real.norm_eq_abs] at hv
nlinarith [L.coe_nonneg]
rw [← Real.exp_add]
apply Real.exp_le_exp.mpr
calc
_ ≤ |a| * |f (x+z • c)| := by simpa only [abs_mul] using le_abs_self (a*f (x+z • c))
_ ≤ |a| * (|f x₀|+(L:ℝ)*r+(L:ℝ)*‖c‖*|z|) := mul_le_mul_of_nonneg_left hb (abs_nonneg _)
_ = _ := by ring
lemma hasDerivAt_ambientMoment {L : ℝ≥0} {f f' g g' : E → ℝ} (hf : LipschitzWith L f)
(hf' : Continuous f') (hg : Continuous g) (hg' : Continuous g')
{M N P : ℝ≥0} (hM : ∀ x, |f' x| ≤ M) (hN : ∀ x, |g x| ≤ N) (hP : ∀ x, |g' x| ≤ P)
(v : E)
(hdf : ∀ y t, HasDerivAt (fun u : ℝ => f (y+u • v)) (f' (y+t • v)) t)
(hdg : ∀ y t, HasDerivAt (fun u : ℝ => g (y+u • v)) (g' (y+t • v)) t)
(a : ℝ) (c x : E) (t₀ : ℝ) :
HasDerivAt (fun t => ambientMoment a c f g (x+t • v))
(∫ z, Real.exp (a*f (x+t₀ • v+z • c))*
(a*f' (x+t₀ • v+z • c)*g (x+t₀ • v+z • c)+g' (x+t₀ • v+z • c)) ∂gaussianReal 0 1) t₀ := by
have hc := hf.continuous
apply (hasDerivAt_integral_of_dominated_loc_of_deriv_le
(s := Metric.ball t₀ 1)
(bound := fun z =>
(Real.exp (|a| * (|f (x+t₀ • v)|+(L:ℝ)*‖v‖))*Real.exp ((|a| * L*‖c‖)*|z|)) * (|a| * M*N+P))
(F' := fun t z => Real.exp (a*f (x+t • v+z • c))*
(a*f' (x+t • v+z • c)*g (x+t • v+z • c)+g' (x+t • v+z • c)))
(Metric.ball_mem_nhds _ (by norm_num)) ?_ ?_ ?_ ?_ ?_ ?_).2
· exact Eventually.of_forall fun _ => by fun_prop
· exact integrable_ambient_weight hf hg hN a c (x+t₀ • v)
· fun_prop
· exact ae_of_all _ fun z t ht => by
have hxt : ‖(x+t • v)-(x+t₀ • v)‖ ≤ ‖v‖ := by
rw [add_sub_add_left_eq_sub, ← sub_smul, norm_smul, Real.norm_eq_abs]
apply mul_le_of_le_one_left (norm_nonneg _)
have hh : dist t t₀ < 1 := ht
simpa only [Real.dist_eq] using hh.le
rw [Real.norm_eq_abs, abs_mul, abs_of_pos (Real.exp_pos _)]
apply mul_le_mul (ambient_exp_near_le_radius hf a (x+t₀ • v) c hxt z)
· apply (abs_add_le _ _).trans
rw [abs_mul, abs_mul]
exact add_le_add (mul_le_mul
(mul_le_mul_of_nonneg_left (hM _) (abs_nonneg a)) (hN _)
(abs_nonneg _) (by positivity)) (hP _)
· exact abs_nonneg _
· positivity
· exact ((integrable_exp_abs _).const_mul _).mul_const _
· exact ae_of_all _ fun z t _ => by
have he (u : ℝ) : x+u • v+z • c = (x+z • c)+u • v := by abel
simp_rw [he]
convert ((hdf (x+z • c) t).const_mul a).exp.mul (hdg (x+z • c) t) using 1
first | rfl | ring
lemma hasDerivAt_ambientMass {L : ℝ≥0} {f f' : E → ℝ} (hf : LipschitzWith L f)
(hf' : Continuous f') {M : ℝ≥0} (hM : ∀ x, |f' x| ≤ M) (v : E)
(hdf : ∀ y t, HasDerivAt (fun u : ℝ => f (y+u • v)) (f' (y+t • v)) t)
(a : ℝ) (c x : E) (t₀ : ℝ) :
HasDerivAt (fun t => ambientMass a c f (x+t • v))
(a*ambientMoment a c f f' (x+t₀ • v)) t₀ := by
have h := hasDerivAt_ambientMoment hf hf' continuous_const continuous_const hM
(N := 1) (P := 0) (by intro; norm_num) (by intro; norm_num) v hdf
(fun y t => hasDerivAt_const t (1:ℝ)) a c x t₀
have he : ambientMoment a c f (fun _ => 1) = ambientMass a c f := by
funext y
simp [ambientMoment, ambientMass]
rw [he] at h
simpa only [mul_one, add_zero, mul_left_comm _ a, integral_const_mul, ambientMoment] using h
lemma hasDerivAt_ambientMean {L : ℝ≥0} {f f' : E → ℝ} (hf : LipschitzWith L f)
(hf' : Continuous f') {M : ℝ≥0} (hM : ∀ x, |f' x| ≤ M) (v : E)
(hdf : ∀ y t, HasDerivAt (fun u : ℝ => f (y+u • v)) (f' (y+t • v)) t)
(c x : E) (t₀ : ℝ) :
HasDerivAt (fun t => ∫ z, f (x+t • v+z • c) ∂gaussianReal 0 1)
(∫ z, f' (x+t₀ • v+z • c) ∂gaussianReal 0 1) t₀ := by
have hc := hf.continuous
apply (hasDerivAt_integral_of_dominated_loc_of_deriv_le (s := Set.univ)
(bound := fun _ => (M:ℝ)) (F' := fun t z => f' (x+t • v+z • c)) univ_mem ?_
(integrable_ambient hf (x+t₀ • v) c) (by fun_prop) ?_ (integrable_const _) ?_).2
· exact Eventually.of_forall fun _ => by fun_prop
· exact ae_of_all _ fun z t _ => by simpa only [Real.norm_eq_abs] using hM _
· exact ae_of_all _ fun z t _ => by
have he (u : ℝ) : x+u • v+z • c = (x+z • c)+u • v := by abel
simpa only [he] using hdf (x+z • c) t
lemma hasDerivAt_ambientStep {L : ℝ≥0} {f f' : E → ℝ} (hf : LipschitzWith L f)
(hf' : Continuous f') {M : ℝ≥0} (hM : ∀ x, |f' x| ≤ M) (v : E)
(hdf : ∀ y t, HasDerivAt (fun u : ℝ => f (y+u • v)) (f' (y+t • v)) t)
(a : ℝ) (c x : E) (t₀ : ℝ) :
HasDerivAt (fun t => ambientStep a c f (x+t • v))
(ambientTilt a c f f' (x+t₀ • v)) t₀ := by
by_cases ha : a=0
· subst a
simpa only [ambientStep, logMean_zero, ambientTilt_zero] using
hasDerivAt_ambientMean hf hf' hM v hdf c x t₀
· have h := ((hasDerivAt_ambientMass hf hf' hM v hdf a c x t₀).log
(ambientMass_pos hf a c (x+t₀ • v)).ne').div_const a
have he : (a*ambientMoment a c f f' (x+t₀ • v)/ambientMass a c f (x+t₀ • v))/a =
ambientTilt a c f f' (x+t₀ • v) := by
unfold ambientTilt
field_simp
rw [he] at h
have heq : (fun t : ℝ => ambientStep a c f (x+t • v)) =
(fun t : ℝ => Real.log (ambientMass a c f (x+t • v))/a) := by
funext t
simp [ambientStep, logMean, ha, ambientMass]
rw [heq]
exact h
end Ambient
end ParisiFinite
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal Topology
namespace ParisiFinite
section Ambient
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
lemma ambientMoment_add {L : ℝ≥0} {f g h : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) (hh : Continuous h) {M N : ℝ}
(hM : ∀ x, |g x| ≤ M) (hN : ∀ x, |h x| ≤ N) (a : ℝ) (c x : E) :
ambientMoment a c f (fun y => g y+h y) x =
ambientMoment a c f g x + ambientMoment a c f h x := by
simp only [ambientMoment, mul_add]
exact integral_add (integrable_ambient_weight hf hg hM a c x) (integrable_ambient_weight hf hh hN a c x)
lemma ambientMoment_const_mul (a : ℝ) (c : E) (f g : E → ℝ) (x : E) (k : ℝ) :
ambientMoment a c f (fun y => k*g y) x = k*ambientMoment a c f g x := by
simp only [ambientMoment, mul_left_comm _ k, integral_const_mul]
lemma ambientTilt_add {L : ℝ≥0} {f g h : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) (hh : Continuous h) {M N : ℝ}
(hM : ∀ x, |g x| ≤ M) (hN : ∀ x, |h x| ≤ N) (a : ℝ) (c x : E) :
ambientTilt a c f (fun y => g y+h y) x =
ambientTilt a c f g x + ambientTilt a c f h x := by
simp only [ambientTilt, ambientMoment_add hf hg hh hM hN, add_div]
lemma ambientTilt_const_mul (a : ℝ) (c : E) (f g : E → ℝ) (x : E) (k : ℝ) :
ambientTilt a c f (fun y => k*g y) x = k*ambientTilt a c f g x := by
simp only [ambientTilt, ambientMoment_const_mul, mul_div_assoc]
lemma ambientTilt_mono {L : ℝ≥0} {f g h : E → ℝ} (hf : LipschitzWith L f)
(hg : Continuous g) (hh : Continuous h) {M N : ℝ}
(hM : ∀ x, |g x| ≤ M) (hN : ∀ x, |h x| ≤ N)
(hgh : ∀ x, g x ≤ h x) (a : ℝ) (c x : E) :
ambientTilt a c f g x ≤ ambientTilt a c f h x := by
apply div_le_div_of_nonneg_right _ (ambientMass_pos hf a c x).le
apply integral_mono (integrable_ambient_weight hf hg hM a c x)
(integrable_ambient_weight hf hh hN a c x)
intro z
exact mul_le_mul_of_nonneg_left (hgh _) (Real.exp_pos _).le
lemma ambientTilt_const {L : ℝ≥0} {f : E → ℝ} (hf : LipschitzWith L f)
(a : ℝ) (c x : E) (k : ℝ) :
ambientTilt a c f (fun _ => k) x = k := by
simp only [ambientTilt, ambientMoment, integral_mul_const, ambientMass]
exact mul_div_cancel_left₀ _ (ambientMass_pos hf a c x).ne'
lemma hasDerivAt_ambientTilt {L : ℝ≥0} {f f' g g' : E → ℝ} (hf : LipschitzWith L f)
(hf' : Continuous f') (hg : Continuous g) (hg' : Continuous g')
{M N P : ℝ≥0} (hM : ∀ x, |f' x| ≤ M) (hN : ∀ x, |g x| ≤ N) (hP : ∀ x, |g' x| ≤ P)
(v : E)
(hdf : ∀ y t, HasDerivAt (fun u : ℝ => f (y+u • v)) (f' (y+t • v)) t)
(hdg : ∀ y t, HasDerivAt (fun u : ℝ => g (y+u • v)) (g' (y+t • v)) t)
(a : ℝ) (c x : E) (t₀ : ℝ) :
HasDerivAt (fun t => ambientTilt a c f g (x+t • v))
(ambientTilt a c f g' (x+t₀ • v) + a*
(ambientTilt a c f (fun y => f' y*g y) (x+t₀ • v) -
ambientTilt a c f f' (x+t₀ • v)*ambientTilt a c f g (x+t₀ • v))) t₀ := by
have h := hasDerivAt_ambientMoment hf hf' hg hg' hM hN hP v hdf hdg a c x t₀
have he (y : E) : a*f' y*g y+g' y = g' y+a*(f' y*g y) := by ring
simp_rw [he] at h
change HasDerivAt (fun t => ambientMoment a c f g (x+t • v))
(ambientMoment a c f (fun y => g' y+a*(f' y*g y)) (x+t₀ • v)) t₀ at h
rw [ambientMoment_add hf hg' (by fun_prop) hP
(fun y => by
rw [abs_mul, abs_mul]
exact mul_le_mul_of_nonneg_left (mul_le_mul (hM _) (hN _) (abs_nonneg _) M.coe_nonneg) (abs_nonneg a)),
ambientMoment_const_mul] at h
have hd := h.div (hasDerivAt_ambientMass hf hf' hM v hdf a c x t₀)
(ambientMass_pos hf a c (x+t₀ • v)).ne'
convert hd using 1 <;> first | rfl | (unfold ambientTilt; field_simp; ring)
end Ambient
end ParisiFinite
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal Topology
namespace ParisiFinite
structure DirectionalField (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where
val : E → ℝ
first : E → E → ℝ
second : E → E → E → ℝ
lip : ℝ≥0
lipschitz : LipschitzWith lip val
continuousFirst : ∀ v, Continuous (first v)
continuousSecond : ∀ v w, Continuous (second v w)
hasFirst : ∀ v x t, HasDerivAt (fun u : ℝ => val (x+u • v)) (first v (x+t • v)) t
hasSecond : ∀ v w x t, HasDerivAt (fun u : ℝ => first w (x+u • v)) (second v w (x+t • v)) t
boundFirst : E → ℝ≥0
boundSecond : E → E → ℝ≥0
normFirst : ∀ v x, |first v x| ≤ boundFirst v
normSecond : ∀ v w x, |second v w x| ≤ boundSecond v w
namespace DirectionalField
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
def transform (f : DirectionalField E) (a : ℝ≥0) (c : E) : DirectionalField E where
val := ambientStep a c f.val
first v := ambientTilt a c f.val (f.first v)
second v w x := ambientTilt a c f.val (f.second v w) x + (a:ℝ)*
(ambientTilt a c f.val (fun y => f.first v y*f.first w y) x -
ambientTilt a c f.val (f.first v) x*ambientTilt a c f.val (f.first w) x)
lip := f.lip
lipschitz := ambientStep_lipschitz f.lipschitz a.coe_nonneg c
continuousFirst v := continuous_ambientTilt f.lipschitz (f.continuousFirst v) (f.normFirst v) a c
continuousSecond v w := by
have h1 := continuous_ambientTilt f.lipschitz (f.continuousFirst v) (f.normFirst v) a c
have h2 := continuous_ambientTilt f.lipschitz (f.continuousFirst w) (f.normFirst w) a c
have h12 := continuous_ambientTilt f.lipschitz (f.continuousSecond v w) (f.normSecond v w) a c
have hp := continuous_ambientTilt f.lipschitz ((f.continuousFirst v).mul (f.continuousFirst w))
(fun y => by
simp only [Pi.mul_apply, abs_mul]
exact mul_le_mul (f.normFirst v y) (f.normFirst w y) (abs_nonneg _) (f.boundFirst v).coe_nonneg) (a:ℝ) c
fun_prop
hasFirst v x t := hasDerivAt_ambientStep f.lipschitz (f.continuousFirst v) (f.normFirst v)
v (f.hasFirst v) a c x t
hasSecond v w x t := hasDerivAt_ambientTilt f.lipschitz (f.continuousFirst v)
(f.continuousFirst w) (f.continuousSecond v w) (f.normFirst v) (f.normFirst w)
(f.normSecond v w) v (f.hasFirst v) (f.hasSecond v w) a c x t
boundFirst := f.boundFirst
boundSecond v w := f.boundSecond v w + 2*a*f.boundFirst v*f.boundFirst w
normFirst v := abs_ambientTilt_le f.lipschitz (f.continuousFirst v) (f.normFirst v) a c
normSecond v w x := by
have h1 := abs_ambientTilt_le f.lipschitz (f.continuousFirst v) (f.normFirst v) (a:ℝ) c x
have h2 := abs_ambientTilt_le f.lipschitz (f.continuousFirst w) (f.normFirst w) (a:ℝ) c x
have h12 := abs_ambientTilt_le f.lipschitz (f.continuousSecond v w) (f.normSecond v w) (a:ℝ) c x
have hp := abs_ambientTilt_le f.lipschitz ((f.continuousFirst v).mul (f.continuousFirst w))
(fun y => by
simp only [Pi.mul_apply, abs_mul]
exact mul_le_mul (f.normFirst v y) (f.normFirst w y) (abs_nonneg _) (f.boundFirst v).coe_nonneg) (a:ℝ) c x
change |ambientTilt a c f.val (fun y => f.first v y * f.first w y) x| ≤
(f.boundFirst v : ℝ) * (f.boundFirst w : ℝ) at hp
have hprod := mul_le_mul h1 h2 (abs_nonneg _) (f.boundFirst v).coe_nonneg
have hsub := abs_sub_le (ambientTilt a c f.val (fun y => f.first v y*f.first w y) x) 0
(ambientTilt a c f.val (f.first v) x*ambientTilt a c f.val (f.first w) x)
simp only [sub_zero, zero_sub, abs_neg, abs_mul] at hsub
apply (abs_add_le _ _).trans
rw [abs_mul, abs_of_nonneg a.coe_nonneg]
simp only [NNReal.coe_add, NNReal.coe_mul, NNReal.coe_ofNat]
nlinarith [a.coe_nonneg]
def slice (f : DirectionalField E) (x v : E) : SmoothField where
val t := f.val (x+t • v)
d1 t := f.first v (x+t • v)
d2 t := f.second v v (x+t • v)
hasD1 := f.hasFirst v x
hasD2 := f.hasSecond v v x
continuousD2 := (f.continuousSecond v v).comp (by fun_prop)
bound1 := f.boundFirst v
bound2 := f.boundSecond v v
normD1 t := f.normFirst v _
normD2 t := f.normSecond v v _
lemma hasDerivAt_transform_scale (f : DirectionalField E) (a : ℝ≥0) (c x : E) (s : ℝ) :
HasDerivAt (fun r => (f.transform a (r • c)).val x)
(s*(ambientTilt a (s • c) f.val (f.second c c) x +
(a:ℝ)*ambientTilt a (s • c) f.val (fun y => (f.first c y)^2) x)) s := by
have h := ParisiFinite.hasDerivAt_step_scale (f.slice x c) a s 0
convert h using 1 <;>
simp only [transform, slice, step, ambientStep, ambientTilt, tiltedMean, expMoment,
expMass, ambientMass, ambientMoment, zero_add, smul_smul, mul_comm]
end DirectionalField
end ParisiFinite
end
end OAI
|