cfahlgren1's picture
download
raw
18 kB
import OAI.Probability.RadialTransition.CanonicalCosts
namespace OAI
universe uIndex uOtherIndex uX
noncomputable section
open scoped BigOperators NNReal ContDiff ENNReal
open Filter MeasureTheory Set
namespace RadialTransition
def orderedEnergy (φ : Potential) {ι : Type uIndex} [Fintype ι] (x : ι → Position) : ℝ := by
classical
exact (∑ i, ∑ j, if i ≠ j then φ (nndist (x i) (x j)) else 0) / 2
theorem orderedEnergy_fin (φ : Potential) {N : ℕ} (x : Fin N → Position) :
orderedEnergy φ x = energy φ x := by
have h := twice_pair_sum (fun i j => φ (nndist (x i) (x j)))
(fun i j => by rw [nndist_comm])
have hh : (∑ i : Fin N, ∑ j : Fin N,
if i ≠ j then φ (nndist (x i) (x j)) else 0) = 2 * energy φ x := h.symm
have he : orderedEnergy φ x = (∑ i : Fin N, ∑ j : Fin N,
if i ≠ j then φ (nndist (x i) (x j)) else 0) / 2 := by
unfold orderedEnergy
congr 1
apply Finset.sum_congr rfl
intro i _
apply Finset.sum_congr rfl
intro j _
by_cases hij : i = j <;> simp [hij]
rw [he, hh]
ring
theorem orderedEnergy_equiv {ι : Type uIndex} {κ : Type uOtherIndex} [Fintype ι] [Fintype κ]
(e : ι ≃ κ) (φ : Potential) (x : κ → Position) :
orderedEnergy φ (x ∘ e) = orderedEnergy φ x := by
classical
unfold orderedEnergy
congr 1
have hi (i : ι) : (∑ j : ι, if i ≠ j then φ (nndist (x (e i)) (x (e j))) else 0) =
∑ j : κ, if e i ≠ j then φ (nndist (x (e i)) (x j)) else 0 := by
convert e.sum_comp (fun j => if e i ≠ j then φ (nndist (x (e i)) (x j)) else 0) using 1
simp only [ne_eq, e.injective.eq_iff]
simpa only [Function.comp_apply, hi] using
e.sum_comp (fun i => ∑ j, if i ≠ j then φ (nndist (x i) (x j)) else 0)
theorem continuous_orderedEnergy {ι : Type uIndex} [Fintype ι] {φ : Potential}
(hφ : Continuous φ) : Continuous (fun x : ι → Position => orderedEnergy φ x) := by
classical
unfold orderedEnergy
apply Continuous.div_const
apply continuous_finsetSum
intro i _
apply continuous_finsetSum
intro j _
split_ifs
· exact hφ.comp ((continuous_apply i).nndist (continuous_apply j))
· exact continuous_const
theorem orderedEnergy_abs_bound {ι : Type uIndex} [Fintype ι] {φ : Potential} {M : ℝ}
(hM : 0 ≤ M) (hφM : ∀ r, |φ r| ≤ M) (x : ι → Position) :
|orderedEnergy φ x| ≤ (Fintype.card ι : ℝ)^2 * M := by
classical
have hh : |∑ i : ι, ∑ j : ι, if i ≠ j then φ (nndist (x i) (x j)) else 0| ≤
∑ i : ι, ∑ j : ι, M := by
apply (Finset.abs_sum_le_sum_abs _ _).trans
apply Finset.sum_le_sum
intro i _
apply (Finset.abs_sum_le_sum_abs _ _).trans
apply Finset.sum_le_sum
intro j _
split_ifs
· exact hφM _
· simpa using hM
simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] at hh
unfold orderedEnergy
rw [abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 2)]
nlinarith [mul_nonneg (sq_nonneg (Fintype.card ι : ℝ)) hM]
theorem integrable_orderedBoltzmann {ι : Type uIndex} [Fintype ι] {φ : Potential}
(hφ : Continuous φ) (hb : IsBoundedPotential φ) (β : ℝ)
(μ : Measure (ι → Position)) [IsFiniteMeasure μ] :
Integrable (fun x : ι → Position => Real.exp (-β * orderedEnergy φ x)) μ := by
obtain ⟨M, hM, hφM⟩ := hb
apply Integrable.of_bound ((Real.continuous_exp.comp
(continuous_const.mul (continuous_orderedEnergy hφ))).aestronglyMeasurable)
(Real.exp (|β| * ((Fintype.card ι : ℝ)^2 * M)))
filter_upwards [] with x
change |Real.exp _| ≤ _
rw [abs_of_pos (Real.exp_pos _)]
apply Real.exp_le_exp.mpr
calc
-β * orderedEnergy φ x ≤ |-β * orderedEnergy φ x| := le_abs_self _
_ = |β| * |orderedEnergy φ x| := by rw [abs_mul, abs_neg]
_ ≤ _ := mul_le_mul_of_nonneg_left (orderedEnergy_abs_bound hM hφM x) (abs_nonneg β)
def rawPartition (φ : Potential) (A : Set Position) (ι : Type uIndex) [Fintype ι] (β : ℝ) : ℝ :=
∫ x : ι → Position, Real.exp (-β * orderedEnergy φ x) ∂Measure.pi (fun _ : ι => volume.restrict A)
def partitionOn (φ : Potential) (A : Set Position) (N : ℕ) (β : ℝ) : ℝ :=
(N.factorial : ℝ)⁻¹ * rawPartition φ A (Fin N) β
theorem rawPartition_nonneg (φ : Potential) (A : Set Position) (ι : Type uIndex) [Fintype ι] (β : ℝ) :
0 ≤ rawPartition φ A ι β := integral_nonneg (fun _ => (Real.exp_pos _).le)
theorem rawPartition_equiv {ι : Type uIndex} {κ : Type uOtherIndex} [Fintype ι] [Fintype κ]
(e : ι ≃ κ) (φ : Potential) (A : Set Position) (β : ℝ) :
rawPartition φ A ι β = rawPartition φ A κ β := by
have hp := measurePreserving_piCongrLeft (fun _ : κ => volume.restrict A) e
have hh := hp.integral_comp' (fun x => Real.exp (-β * orderedEnergy φ x))
have he (x : ι → Position) : orderedEnergy φ ((MeasurableEquiv.piCongrLeft (fun _ : κ => Position) e) x) =
orderedEnergy φ x := by
have ht := orderedEnergy_equiv e φ ((MeasurableEquiv.piCongrLeft (fun _ : κ => Position) e) x)
simpa only [Function.comp_def, MeasurableEquiv.coe_piCongrLeft,
Equiv.piCongrLeft_apply_apply] using ht.symm
simpa only [rawPartition, he] using hh
theorem measure_pi_add {ι : Type uIndex} [Fintype ι] [DecidableEq ι] {X : ι → Type uX}
[∀ i, MeasurableSpace (X i)] (μ ν : (i : ι) → Measure (X i))
[∀ i, SigmaFinite (μ i)] [∀ i, SigmaFinite (ν i)] :
Measure.pi (fun i => μ i + ν i) =
∑ T : Finset ι, Measure.pi (fun i => if i ∈ T then μ i else ν i) := by
classical
have hσ (T : Finset ι) : ∀ i, SigmaFinite (if i ∈ T then μ i else ν i) := by
intro i
split_ifs <;> infer_instance
refine Measure.pi_eq (μ := fun i => μ i + ν i) (fun s hs => ?_)
simp only [Measure.finsetSum_apply, Measure.pi_pi, Measure.add_apply]
rw [Fintype.prod_add]
apply Finset.sum_congr rfl
intro T _
have he (i : ι) : (if i ∈ T then μ i else ν i) (s i) =
if i ∈ T then μ i (s i) else ν i (s i) := by split_ifs <;> rfl
simp_rw [he]
rw [Finset.prod_ite]
congr 1 <;> congr 1 <;> ext i <;> simp
theorem sum_split_four {ι : Type uIndex} [Fintype ι] (p : ι → Prop) [DecidablePred p]
(F : ι → ι → ℝ) :
(∑ i, ∑ j, F i j) =
(∑ i : Subtype p, ∑ j : Subtype p, F i j) +
(∑ i : Subtype p, ∑ j : {j // ¬p j}, F i j) +
(∑ i : {i // ¬p i}, ∑ j : Subtype p, F i j) +
(∑ i : {i // ¬p i}, ∑ j : {j // ¬p j}, F i j) := by
rw [← Fintype.sum_subtype_add_sum_subtype p (fun i => ∑ j, F i j)]
simp_rw [← Fintype.sum_subtype_add_sum_subtype p (fun j => F _ j)]
simp only [Finset.sum_add_distrib]
ring
theorem orderedEnergy_split {ι : Type uIndex} [Fintype ι] (p : ι → Prop) [DecidablePred p]
(φ : Potential) (x : ι → Position) :
orderedEnergy φ x = orderedEnergy φ (fun i : Subtype p => x i) +
orderedEnergy φ (fun i : {i // ¬p i} => x i) +
∑ i : Subtype p, ∑ j : {j // ¬p j}, φ (nndist (x i) (x j)) := by
classical
have hn (i : Subtype p) (j : {i // ¬p i}) : (i : ι) ≠ j := by
intro h
exact j.property (h ▸ i.property)
unfold orderedEnergy
rw [sum_split_four p]
dsimp only
have hpp (i j : Subtype p) : (if (i : ι) ≠ (j : ι) then φ (nndist (x i) (x j)) else 0) =
if i ≠ j then φ (nndist (x i) (x j)) else 0 := by
by_cases h : i = j
· simp [h]
· simp [h, Subtype.coe_ne_coe.mpr h]
have hmm (i j : {i // ¬p i}) : (if (i : ι) ≠ (j : ι) then φ (nndist (x i) (x j)) else 0) =
if i ≠ j then φ (nndist (x i) (x j)) else 0 := by
by_cases h : i = j
· simp [h]
· simp [h, Subtype.coe_ne_coe.mpr h]
have hpm (i : Subtype p) (j : {i // ¬p i}) :
(if (i : ι) ≠ (j : ι) then φ (nndist (x i) (x j)) else 0) = φ (nndist (x i) (x j)) := by
rw [ite_eq_left (hn i j)]
have hmp (i : {i // ¬p i}) (j : Subtype p) :
(if (i : ι) ≠ (j : ι) then φ (nndist (x i) (x j)) else 0) = φ (nndist (x i) (x j)) := by
rw [ite_eq_left (hn j i).symm]
simp_rw [hpp, hmm, hpm, hmp]
have hs : (∑ i : {i // ¬p i}, ∑ j : Subtype p, φ (nndist (x i) (x j))) =
∑ i : Subtype p, ∑ j : {j // ¬p j}, φ (nndist (x i) (x j)) := by
rw [Finset.sum_comm]
simp_rw [nndist_comm]
rw [hs]
ring_nf
theorem orderedEnergy_split_le {ι : Type uIndex} [Fintype ι] (p : ι → Prop) [DecidablePred p]
(φ : Potential) (x : ι → Position)
(hc : ∀ i j, p i → ¬p j → φ (nndist (x i) (x j)) ≤ 0) :
orderedEnergy φ x ≤ orderedEnergy φ (fun i : Subtype p => x i) +
orderedEnergy φ (fun i : {i // ¬p i} => x i) := by
rw [orderedEnergy_split p]
have hh : (∑ i : Subtype p, ∑ j : {j // ¬p j}, φ (nndist (x i) (x j))) ≤ 0 := by
apply Finset.sum_nonpos
intro i _
apply Finset.sum_nonpos
intro j _
exact hc i j i.property j.property
linarith
theorem sector_product_integral {ι : Type uIndex} [Fintype ι] (p : ι → Prop) [DecidablePred p]
(F : (Subtype p → Position) → ℝ) (G : ({i // ¬p i} → Position) → ℝ)
(μ ν : Measure Position) [SigmaFinite μ] [SigmaFinite ν] :
(∫ x : ι → Position, F (fun i => x i) * G (fun i => x i)
∂Measure.pi (fun i => if p i then μ else ν)) =
(∫ x : Subtype p → Position, F x ∂Measure.pi (fun _ => μ)) *
∫ x : {i // ¬p i} → Position, G x ∂Measure.pi (fun _ => ν) := by
have : ∀ i : ι, SigmaFinite (if p i then μ else ν) := by
intro i
split_ifs <;> infer_instance
have hp := measurePreserving_piEquivPiSubtypeProd (fun i => if p i then μ else ν) p
have hh := hp.integral_comp' (fun z => F z.1 * G z.2)
simp only [MeasurableEquiv.piEquivPiSubtypeProd_apply,
Subtype.prop, ite_true, (fun i : {i // ¬p i} => i.property), ite_false] at hh
exact hh.trans (integral_prod_mul F G)
theorem sector_raw_lower {ι : Type uIndex} [Fintype ι] (p : ι → Prop) [DecidablePred p]
{φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {β : ℝ} (hβ : 0 ≤ β)
{A B : Set Position} (hA : MeasurableSet A) (hB : MeasurableSet B)
(hAfin : volume A ≠ ⊤) (hBfin : volume B ≠ ⊤)
(hc : ∀ x ∈ A, ∀ y ∈ B, φ (nndist x y) ≤ 0) :
rawPartition φ A (Subtype p) β * rawPartition φ B {i // ¬p i} β ≤
∫ x : ι → Position, Real.exp (-β * orderedEnergy φ x)
∂Measure.pi (fun i => if p i then volume.restrict A else volume.restrict B) := by
let μ := fun i : ι => if p i then volume.restrict A else volume.restrict B
let : IsFiniteMeasure (volume.restrict A) := isFiniteMeasure_restrict.mpr hAfin
let : IsFiniteMeasure (volume.restrict B) := isFiniteMeasure_restrict.mpr hBfin
have : ∀ i, IsFiniteMeasure (μ i) := by
intro i
dsimp [μ]
split_ifs <;> infer_instance
have hiA := integrable_orderedBoltzmann hφ hb β (Measure.pi (fun _ : Subtype p => volume.restrict A))
have hiB := integrable_orderedBoltzmann hφ hb β (Measure.pi (fun _ : {i // ¬p i} => volume.restrict B))
have hp := measurePreserving_piEquivPiSubtypeProd μ p
have hip : Integrable (fun z : (Subtype p → Position) × ({i // ¬p i} → Position) =>
Real.exp (-β * orderedEnergy φ z.1) * Real.exp (-β * orderedEnergy φ z.2))
((Measure.pi (fun i : Subtype p => μ i)).prod (Measure.pi (fun i : {i // ¬p i} => μ i))) := by
simpa only [μ, Subtype.prop, ite_true, (fun i : {i // ¬p i} => i.property), ite_false] using hiA.mul_prod hiB
have his := hp.integrable_comp_of_integrable hip
have hiQ := integrable_orderedBoltzmann hφ hb β (Measure.pi μ)
have hae : ∀ᵐ x : ι → Position ∂Measure.pi μ, ∀ i, x i ∈ (if p i then A else B) := by
apply ae_all_iff.mpr
intro i
apply (Measure.tendsto_eval_ae_ae (μ := μ)).eventually
dsimp [μ]
split_ifs <;> exact ae_restrict_mem (by assumption)
have hh := integral_mono_ae his hiQ (hae.mono (fun x hx => ?_))
· simp only [MeasurableEquiv.piEquivPiSubtypeProd_apply, Function.comp_apply] at hh
change (∫ x : ι → Position, Real.exp (-β * orderedEnergy φ (fun i : Subtype p => x i)) *
Real.exp (-β * orderedEnergy φ (fun i : {i // ¬p i} => x i))
∂Measure.pi (fun i => if p i then volume.restrict A else volume.restrict B)) ≤ _ at hh
have hprod := sector_product_integral p
(fun x : Subtype p → Position => Real.exp (-β * orderedEnergy φ x))
(fun x : {i // ¬p i} → Position => Real.exp (-β * orderedEnergy φ x))
(volume.restrict A) (volume.restrict B)
exact hprod.symm.trans_le hh
· change Real.exp (-β * orderedEnergy φ (fun i : Subtype p => x i)) *
Real.exp (-β * orderedEnergy φ (fun i : {i // ¬p i} => x i)) ≤ _
rw [← Real.exp_add]
apply Real.exp_le_exp.mpr
have he := orderedEnergy_split_le p φ x (fun i j hi hj => hc (x i)
(by simpa [hi] using hx i) (x j) (by simpa [hj] using hx j))
nlinarith
theorem rawPartition_union_sum {ι : Type uIndex} [Fintype ι] [DecidableEq ι]
{φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) (β : ℝ)
{A B : Set Position} (hB : MeasurableSet B) (hab : Disjoint A B)
(hAfin : volume A ≠ ⊤) (hBfin : volume B ≠ ⊤) :
rawPartition φ (A ∪ B) ι β =
∑ T : Finset ι, ∫ x : ι → Position, Real.exp (-β * orderedEnergy φ x)
∂Measure.pi (fun i => if i ∈ T then volume.restrict A else volume.restrict B) := by
let : IsFiniteMeasure (volume.restrict A) := isFiniteMeasure_restrict.mpr hAfin
let : IsFiniteMeasure (volume.restrict B) := isFiniteMeasure_restrict.mpr hBfin
unfold rawPartition
simp_rw [Measure.restrict_union hab hB]
rw [measure_pi_add]
apply integral_finsetSum_measure
intro T _
have : ∀ i : ι, IsFiniteMeasure (if i ∈ T then volume.restrict A else volume.restrict B) := by
intro i
split_ifs <;> infer_instance
exact integrable_orderedBoltzmann hφ hb β _
theorem rawPartition_union_lower {φ : Potential} (hφ : Continuous φ)
(hb : IsBoundedPotential φ) {β : ℝ} (hβ : 0 ≤ β)
{A B : Set Position} (hA : MeasurableSet A) (hB : MeasurableSet B) (hab : Disjoint A B)
(hAfin : volume A ≠ ⊤) (hBfin : volume B ≠ ⊤)
(hc : ∀ x ∈ A, ∀ y ∈ B, φ (nndist x y) ≤ 0) (m n : ℕ) :
((m + n).choose m : ℝ) * rawPartition φ A (Fin m) β * rawPartition φ B (Fin n) β ≤
rawPartition φ (A ∪ B) (Fin (m + n)) β := by
classical
let S : Finset (Finset (Fin (m + n))) := Finset.univ.powersetCard m
let I (T : Finset (Fin (m + n))) := ∫ x : Fin (m + n) → Position, Real.exp (-β * orderedEnergy φ x)
∂Measure.pi (fun i => if i ∈ T then volume.restrict A else volume.restrict B)
have hterm (T : Finset (Fin (m + n))) (hT : T ∈ S) :
rawPartition φ A (Fin m) β * rawPartition φ B (Fin n) β ≤ I T := by
have hcard : T.card = m := (Finset.mem_powersetCard.mp hT).2
have hcardA : Fintype.card {i : Fin (m + n) // i ∈ T} = m := by
simpa only [Fintype.card_coe] using hcard
have hcardB : Fintype.card {i : Fin (m + n) // i ∉ T} = n := by
rw [Fintype.card_subtype_compl, hcardA, Fintype.card_fin]
omega
have hh := sector_raw_lower (fun i => i ∈ T) hφ hb hβ hA hB hAfin hBfin hc
have heA := rawPartition_equiv (Fintype.equivFinOfCardEq hcardA) φ A β
have heB := rawPartition_equiv (Fintype.equivFinOfCardEq hcardB) φ B β
convert hh using 1
congr 1
· convert heA.symm using 1
congr!
· exact heB.symm
have hs := Finset.sum_le_sum hterm
have hnn (T : Finset (Fin (m + n))) : 0 ≤ I T := integral_nonneg (fun _ => (Real.exp_pos _).le)
have hsubset : S ⊆ Finset.univ := Finset.subset_univ _
have hh := hs.trans (Finset.sum_le_sum_of_subset_of_nonneg hsubset (fun T _ _ => hnn T))
have hcardS : S.card = (m + n).choose m := by
simp only [S, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin]
rw [Finset.sum_const, hcardS, nsmul_eq_mul] at hh
rw [rawPartition_union_sum hφ hb β hB hab hAfin hBfin]
simpa only [mul_assoc, I] using hh
theorem partitionOn_union_lower {φ : Potential} (hφ : Continuous φ)
(hb : IsBoundedPotential φ) {β : ℝ} (hβ : 0 ≤ β)
{A B : Set Position} (hA : MeasurableSet A) (hB : MeasurableSet B) (hab : Disjoint A B)
(hAfin : volume A ≠ ⊤) (hBfin : volume B ≠ ⊤)
(hc : ∀ x ∈ A, ∀ y ∈ B, φ (nndist x y) ≤ 0) (m n : ℕ) :
partitionOn φ A m β * partitionOn φ B n β ≤ partitionOn φ (A ∪ B) (m + n) β := by
have hh := rawPartition_union_lower hφ hb hβ hA hB hab hAfin hBfin hc m n
have hm : (m.factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero m
have hn : (n.factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero n
have hmn : ((m + n).factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero (m + n)
have hfac : ((m + n).choose m : ℝ) * m.factorial * n.factorial = (m + n).factorial := by
exact_mod_cast (by simpa using Nat.choose_mul_factorial_mul_factorial (Nat.le_add_right m n))
have hcancel : ((m + n).factorial : ℝ)⁻¹ * ((m + n).choose m : ℝ) =
(m.factorial : ℝ)⁻¹ * (n.factorial : ℝ)⁻¹ := by
field_simp
nlinarith [hfac]
have hh' := mul_le_mul_of_nonneg_left hh
(inv_nonneg.mpr (by positivity : (0 : ℝ) ≤ (m + n).factorial))
unfold partitionOn
have he : (m.factorial : ℝ)⁻¹ * rawPartition φ A (Fin m) β *
((n.factorial : ℝ)⁻¹ * rawPartition φ B (Fin n) β) =
((m + n).factorial : ℝ)⁻¹ *
(((m + n).choose m : ℝ) * rawPartition φ A (Fin m) β * rawPartition φ B (Fin n) β) := by
calc
_ = ((m.factorial : ℝ)⁻¹ * (n.factorial : ℝ)⁻¹) *
(rawPartition φ A (Fin m) β * rawPartition φ B (Fin n) β) := by ring
_ = _ := by rw [← hcancel]; ring
rw [he]
exact hh'
end RadialTransition
end
end OAI

Xet Storage Details

Size:
18 kB
·
Xet hash:
120503e612d6ff020ca8b7ab28ec0b6d0ba403f548705353771816eb2737cf00

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.