import OAI.Probability.RadialTransition.PartitionReplication namespace OAI noncomputable section open scoped BigOperators NNReal ContDiff ENNReal open Filter MeasureTheory Set namespace RadialTransition def grandOn (φ : Potential) (A : Set Position) (β z : ℝ) : ℝ := ∑' N : ℕ, Real.exp (z * N) * partitionOn φ A N β theorem partitionOn_stability_upper {φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {B β : ℝ} (hstable : StableWith φ B) (hβ : 0 ≤ β) {A : Set Position} (hAfin : volume A ≠ ⊤) (N : ℕ) : partitionOn φ A N β ≤ (volume.real A) ^ N * Real.exp (β * B * N) / N.factorial := by let : IsFiniteMeasure (volume.restrict A) := isFiniteMeasure_restrict.mpr hAfin have hh : rawPartition φ A (Fin N) β ≤ (volume.real A) ^ N * Real.exp (β * B * N) := by calc _ ≤ ∫ _ : Fin N → Position, Real.exp (β * B * N) ∂Measure.pi (fun _ : Fin N => volume.restrict A) := by apply integral_mono (integrable_orderedBoltzmann hφ hb β _) (integrable_const _) intro x apply Real.exp_le_exp.mpr rw [orderedEnergy_fin] nlinarith [mul_le_mul_of_nonneg_left (hstable N x) hβ] _ = _ := by simp [integral_const, measureReal_def, Measure.pi_univ] have hh' := mul_le_mul_of_nonneg_left hh (show (0 : ℝ) ≤ (N.factorial : ℝ)⁻¹ by positivity) simpa only [partitionOn, div_eq_mul_inv, mul_comm, mul_left_comm, mul_assoc] using hh' theorem grandOn_term_upper {φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {B β : ℝ} (hstable : StableWith φ B) (hβ : 0 ≤ β) {A : Set Position} (hAfin : volume A ≠ ⊤) (z : ℝ) (N : ℕ) : Real.exp (z * N) * partitionOn φ A N β ≤ (volume.real A * Real.exp (β * B + z)) ^ N / N.factorial := by have hh := mul_le_mul_of_nonneg_left (partitionOn_stability_upper hφ hb hstable hβ hAfin N) (Real.exp_pos (z * N)).le apply hh.trans_eq rw [Real.exp_add, mul_pow, mul_pow, ← Real.exp_nat_mul (β * B) N, ← Real.exp_nat_mul z N] have he₁ : β * B * (N : ℝ) = (N : ℝ) * (β * B) := by ring have he₂ : z * (N : ℝ) = (N : ℝ) * z := by ring rw [he₁, he₂] ring theorem grandOn_summable {φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {B β : ℝ} (hstable : StableWith φ B) (hβ : 0 ≤ β) {A : Set Position} (hAfin : volume A ≠ ⊤) (z : ℝ) : Summable (fun N : ℕ => Real.exp (z * N) * partitionOn φ A N β) := Summable.of_nonneg_of_le (fun N => mul_nonneg (Real.exp_pos _).le (partitionOn_nonneg φ A N β)) (grandOn_term_upper hφ hb hstable hβ hAfin z) (Real.summable_pow_div_factorial _) theorem grandOn_bounds {φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {B β : ℝ} (hstable : StableWith φ B) (hβ : 0 ≤ β) {A : Set Position} (hAfin : volume A ≠ ⊤) (z : ℝ) : 1 ≤ grandOn φ A β z ∧ grandOn φ A β z ≤ Real.exp (volume.real A * Real.exp (β * B + z)) := by have hs := grandOn_summable hφ hb hstable hβ hAfin z constructor · have hh := hs.le_tsum 0 (fun N _ => mul_nonneg (Real.exp_pos _).le (partitionOn_nonneg φ A N β)) convert hh using 1 <;> first | rfl | norm_num [partitionOn_zero] · have hh := hs.tsum_le_tsum (grandOn_term_upper hφ hb hstable hβ hAfin z) (Real.summable_pow_div_factorial _) have he : (∑' N : ℕ, (volume.real A * Real.exp (β * B + z)) ^ N / N.factorial) = Real.exp (volume.real A * Real.exp (β * B + z)) := by rw [Real.exp_eq_exp_ℝ, NormedSpace.exp_eq_tsum_div] exact hh.trans_eq he theorem grandOn_union_lower {φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {B β : ℝ} (hstable : StableWith φ B) (hβ : 0 ≤ β) {A D : Set Position} (hA : MeasurableSet A) (hD : MeasurableSet D) (had : Disjoint A D) (hAfin : volume A ≠ ⊤) (hDfin : volume D ≠ ⊤) (hc : ∀ x ∈ A, ∀ y ∈ D, φ (nndist x y) ≤ 0) (z : ℝ) : grandOn φ A β z * grandOn φ D β z ≤ grandOn φ (A ∪ D) β z := by have hUfin : volume (A ∪ D) ≠ ⊤ := (measure_union_le A D).trans_lt (ENNReal.add_lt_top.mpr ⟨hAfin.lt_top, hDfin.lt_top⟩) |>.ne have hsA := grandOn_summable hφ hb hstable hβ hAfin z have hsD := grandOn_summable hφ hb hstable hβ hDfin z have hsU := grandOn_summable hφ hb hstable hβ hUfin z have hcov (N : ℕ) : (∑ m ∈ Finset.range (N + 1), (Real.exp (z * m) * partitionOn φ A m β) * (Real.exp (z * ((N - m : ℕ) : ℝ)) * partitionOn φ D (N - m) β)) ≤ Real.exp (z * N) * partitionOn φ (A ∪ D) N β := by have he : (∑ m ∈ Finset.range (N + 1), (Real.exp (z * m) * partitionOn φ A m β) * (Real.exp (z * ((N - m : ℕ) : ℝ)) * partitionOn φ D (N - m) β)) = Real.exp (z * N) * ∑ m ∈ Finset.range (N + 1), partitionOn φ A m β * partitionOn φ D (N - m) β := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro m hm have hmN : m ≤ N := Nat.le_of_lt_succ (Finset.mem_range.mp hm) have he : z * (m : ℝ) + z * (N - m : ℕ) = z * N := by rw [Nat.cast_sub hmN]; ring calc _ = (Real.exp (z * m) * Real.exp (z * ((N - m : ℕ) : ℝ))) * (partitionOn φ A m β * partitionOn φ D (N - m) β) := by ring _ = _ := by rw [← Real.exp_add, he] rw [he] exact mul_le_mul_of_nonneg_left (partitionOn_union_convolution hφ hb hβ hA hD had hAfin hDfin hc N) (Real.exp_pos _).le have hnn (N : ℕ) : 0 ≤ ∑ m ∈ Finset.range (N + 1), (Real.exp (z * m) * partitionOn φ A m β) * (Real.exp (z * ((N - m : ℕ) : ℝ)) * partitionOn φ D (N - m) β) := by apply Finset.sum_nonneg intro m _ exact mul_nonneg (mul_nonneg (Real.exp_pos _).le (partitionOn_nonneg φ A m β)) (mul_nonneg (Real.exp_pos _).le (partitionOn_nonneg φ D (N - m) β)) rw [grandOn, grandOn, tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm hsA.norm hsD.norm] exact (Summable.of_nonneg_of_le hnn hcov hsU).tsum_le_tsum hcov hsU theorem grandOn_mono {φ : Potential} (hφ : Continuous φ) (hb : IsBoundedPotential φ) {B β : ℝ} (hstable : StableWith φ B) (hβ : 0 ≤ β) {A D : Set Position} (hsub : A ⊆ D) (hDfin : volume D ≠ ⊤) (z : ℝ) : grandOn φ A β z ≤ grandOn φ D β z := by have hAfin : volume A ≠ ⊤ := (measure_mono hsub).trans_lt hDfin.lt_top |>.ne exact (grandOn_summable hφ hb hstable hβ hAfin z).tsum_le_tsum (fun N => mul_le_mul_of_nonneg_left (partitionOn_mono hφ hb β N hsub hDfin) (Real.exp_pos _).le) (grandOn_summable hφ hb hstable hβ hDfin z) theorem grandOn_translate (φ : Potential) (A : Set Position) (a : Position) (β z : ℝ) : grandOn φ (translateSet a A) β z = grandOn φ A β z := by simp only [grandOn, partitionOn_translate] theorem grandOn_cube (φ : Potential) (L t β h : ℝ) : grandOn φ (cube L) β (t * h) = grandPartition φ t L β h := by simp only [grandOn, grandPartition, partitionOn_cube] end RadialTransition end end OAI