introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
10.7 kB
import OAI.Probability.ContinuumTransition.SpatialProducts
namespace OAI
section
open scoped Topology BigOperators ENNReal
open Filter MeasureTheory Set
namespace ContinuumTemperature
noncomputable def tileCenter (β„“ L : ℝ) {k : β„•} (i : Fin 3 β†’ Fin k) : Space :=
WithLp.toLp 2 (fun j => (β„“+2)*((i j : ℝ)+1/2)-L/2)
noncomputable def tileBox (β„“ L : ℝ) {k : β„•} (i : Fin 3 β†’ Fin k) : Set Space :=
(fun x => x + tileCenter β„“ L i) '' cube β„“
theorem isCompact_tileBox (β„“ L : ℝ) {k : β„•} (i : Fin 3 β†’ Fin k) :
IsCompact (tileBox β„“ L i) :=
(isCompact_cube β„“).image (continuous_id.add continuous_const)
theorem tileBox_subset {β„“ L : ℝ} {k : β„•} (hβ„“ : 0 ≀ β„“)
(hk : (k : ℝ)*(β„“+2) ≀ L) (i : Fin 3 β†’ Fin k) : tileBox β„“ L i βŠ† cube L := by
rintro x ⟨y, hy, rfl⟩ j
have hyj := hy j
have hij : (i j : ℝ)+1 ≀ k := by exact_mod_cast (i j).isLt
have h0 : (0 : ℝ) ≀ (i j : ℝ) := Nat.cast_nonneg _
change y j + ((β„“+2)*((i j : ℝ)+1/2)-L/2) ∈ Icc (-L/2) (L/2)
constructor <;> nlinarith [hyj.1, hyj.2]
theorem tileBox_separation {β„“ L : ℝ} {k : β„•} (hβ„“ : 0 ≀ β„“)
{i j : Fin 3 β†’ Fin k} (hij : i β‰  j) {x y : Space}
(hx : x ∈ tileBox β„“ L i) (hy : y ∈ tileBox β„“ L j) : 2 ≀ β€–x-yβ€– := by
obtain ⟨a, ha, rfl⟩ := hx
obtain ⟨b, hb, rfl⟩ := hy
obtain ⟨r, hr⟩ : βˆƒ r, i r β‰  j r := by
by_contra! h
exact hij (funext h)
have har := ha r
have hbr := hb r
have hnorm : |(a+tileCenter β„“ L i) r - (b+tileCenter β„“ L j) r| ≀
β€–(a+tileCenter β„“ L i)-(b+tileCenter β„“ L j)β€– := by
simpa only [PiLp.sub_apply, Real.norm_eq_abs] using
PiLp.norm_apply_le ((a+tileCenter β„“ L i)-(b+tileCenter β„“ L j)) r
change |a r + ((β„“+2)*((i r : ℝ)+1/2)-L/2) -
(b r + ((β„“+2)*((j r : ℝ)+1/2)-L/2))| ≀
β€–(a+tileCenter β„“ L i)-(b+tileCenter β„“ L j)β€– at hnorm
rw [abs_le] at hnorm
rcases lt_or_gt_of_ne hr with h | h
Β· have hh : (i r : ℝ)+1 ≀ (j r : ℝ) := by exact_mod_cast h
have hmul := mul_le_mul_of_nonneg_left hh (by linarith : 0 ≀ β„“+2)
nlinarith [har.1, har.2, hbr.1, hbr.2]
Β· have hh : (j r : ℝ)+1 ≀ (i r : ℝ) := by exact_mod_cast h
have hmul := mul_le_mul_of_nonneg_left hh (by linarith : 0 ≀ β„“+2)
nlinarith [har.1, har.2, hbr.1, hbr.2]
theorem tileBox_pairwiseDisjoint {β„“ L : ℝ} {k : β„•} (hβ„“ : 0 ≀ β„“) :
Pairwise (fun i j : Fin 3 β†’ Fin k => Disjoint (tileBox β„“ L i) (tileBox β„“ L j)) := by
intro i j hij
apply Set.disjoint_left.mpr
intro x hx hy
have hh := tileBox_separation hβ„“ hij hx hy
simp only [sub_self, norm_zero] at hh
norm_num at hh
theorem partition_tiling_lower {Ο† : ℝ β†’ ℝ} (hΟ† : Measurable (radialPotential Ο†))
{Ξ² B β„“ L : ℝ} (hΞ² : 0 ≀ Ξ²) (hβ„“ : 0 ≀ β„“) (hL : 0 ≀ L)
(hstable : βˆ€ (N : β„•) (x : Fin N β†’ Space),
((-B * (N : ℝ) : ℝ) : EReal) ≀ energy Ο† x)
(hsign : βˆ€ r, 1 ≀ r β†’ Ο† r ≀ 0)
(n : (Fin 3 β†’ Fin ⌊L/(β„“+2)βŒ‹β‚Š) β†’ β„•) :
(∏ i, partition Ο† Ξ² β„“ (n i)) ≀ partition Ο† Ξ² L (βˆ‘ i, n i) := by
classical
have hden : 0 < β„“+2 := by linarith
have hk : (⌊L/(β„“+2)βŒ‹β‚Š : ℝ)*(β„“+2) ≀ L := by
apply (le_div_iffβ‚€ hden).mp
exact Nat.floor_le (div_nonneg hL hden.le)
have hh := setPartition_product_lower hφ hβ hstable (tileBox ℓ L) n Finset.univ
(fun i _ => (isCompact_tileBox β„“ L i).measurableSet)
(fun i _ j _ hij => tileBox_pairwiseDisjoint hβ„“ hij)
(fun i _ j _ hij a ha b hb => hsign _ (le_trans (by norm_num)
(tileBox_separation hβ„“ hij ha hb)))
(isCompact_cube L).measure_lt_top.ne (fun i _ => tileBox_subset hβ„“ hk i)
have hv (i : Fin 3 β†’ Fin ⌊L/(β„“+2)βŒ‹β‚Š) :
setPartition Ο† Ξ² (tileBox β„“ L i) (n i) = partition Ο† Ξ² β„“ (n i) := by
rw [tileBox, setPartition_translate, setPartition, generalPartition_eq_partition]
simp_rw [hv] at hh
simpa only [setPartition, generalPartition_eq_partition] using hh
theorem exists_concentrated_counts (K H N : β„•) (hN : N ≀ K*H) :
βˆƒ r : Fin K β†’ β„•, (βˆ‘ i, r i) = N ∧ (βˆ€ i, r i ≀ H) ∧
(βˆ‘ i, if r i = 0 then 0 else 1) * H ≀ N+H := by
induction K generalizing N with
| zero =>
have hzero : N = 0 := by omega
subst N
exact ⟨Fin.elim0, by simp, (fun i => Fin.elim0 i), by simp⟩
| succ K ih =>
by_cases hh : N ≀ H
· refine ⟨Fin.cons N (fun _ => 0), ?_, ?_, ?_⟩
Β· simp [Fin.sum_univ_succ]
Β· intro i
refine Fin.cases hh (fun _ => Nat.zero_le _) i
Β· simp only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, ite_true, Finset.sum_const_zero,
add_zero]
split_ifs <;> omega
Β· have hHK : N-H ≀ K*H := by
rw [Nat.succ_mul] at hN
omega
obtain ⟨r, hr, hbound, hc⟩ := ih (N-H) hHK
have hH : 0 < H := by
by_contra hzero
have hz : H = 0 := by omega
simp only [hz, Nat.mul_zero, Nat.le_zero] at hN
omega
refine ⟨Fin.cons H r, ?_, ?_, ?_⟩
Β· simp only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, hr]
omega
Β· intro i
exact Fin.cases (le_refl H) hbound i
Β· simp only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, ite_eq_right hH.ne']
have hsub := Nat.sub_add_cancel (show H ≀ N by omega)
nlinarith
theorem exists_adjusted_counts (K b H N : β„•) (hb : 0 < b) (hH : 2*b ≀ H)
(hN : N ≀ K*H) :
βˆƒ r : Fin K β†’ β„•, (βˆ‘ i, r i) = N ∧ (βˆ€ i, r i ≀ H) ∧
((βˆ‘ i, if r i = b then 0 else 1 : β„•) : ℝ) * b ≀
|(N : ℝ) - (K : ℝ)*b| + H := by
have hbH : b ≀ H := by omega
by_cases hNb : K*b ≀ N
Β· have hdel : N-K*b ≀ K*(H-b) := by
rw [Nat.mul_sub_left_distrib]
omega
obtain ⟨d, hsum, hbound, hc⟩ := exists_concentrated_counts K (H-b) (N-K*b) hdel
refine ⟨fun i => b+d i, ?_, ?_, ?_⟩
Β· simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ,
Fintype.card_fin, smul_eq_mul, hsum]
omega
Β· intro i
change b+d i ≀ H
have hh := hbound i
omega
Β· have heq : (βˆ‘ i, if b+d i = b then 0 else 1 : β„•) =
βˆ‘ i, if d i = 0 then 0 else 1 := by
apply Finset.sum_congr rfl
intro i _
simp only [Nat.add_eq_left]
rw [heq]
have hineq : (βˆ‘ i, if d i = 0 then 0 else 1) * b ≀ (N-K*b)+H := by
have hh := Nat.mul_le_mul_left (βˆ‘ i, if d i = 0 then 0 else 1) (show b ≀ H-b by omega)
omega
have hsub : ((N-K*b : β„•) : ℝ) = (N : ℝ)-(K : ℝ)*b := by
rw [Nat.cast_sub hNb, Nat.cast_mul]
have hsgn : 0 ≀ (N : ℝ)-(K : ℝ)*b := by
have hh : (K : ℝ)*b ≀ (N : ℝ) := by exact_mod_cast hNb
linarith
rw [abs_of_nonneg hsgn]
have hh : ((βˆ‘ i, if d i = 0 then 0 else 1 : β„•) : ℝ)*b ≀ ((N-K*b : β„•) : ℝ)+H := by
exact_mod_cast hineq
rwa [hsub] at hh
Β· have hNb' : N ≀ K*b := by omega
obtain ⟨d, hsum, hbound, hc⟩ := exists_concentrated_counts K b (K*b-N) (Nat.sub_le _ _)
refine ⟨fun i => b-d i, ?_, ?_, ?_⟩
Β· have hh : (βˆ‘ i : Fin K, (b - d i)) + (βˆ‘ i : Fin K, d i) = K*b := by
rw [← Finset.sum_add_distrib]
simp only [Nat.sub_add_cancel (hbound _), Finset.sum_const, Finset.card_univ,
Fintype.card_fin, smul_eq_mul]
change (βˆ‘ i : Fin K, (b - d i)) = N
rw [hsum] at hh
omega
Β· intro i
exact (Nat.sub_le b _).trans hbH
Β· have heq : (βˆ‘ i, if b-d i = b then 0 else 1 : β„•) =
βˆ‘ i, if d i = 0 then 0 else 1 := by
apply Finset.sum_congr rfl
intro i _
have hh : b-d i = b ↔ d i = 0 := by omega
simp only [hh]
rw [heq]
have hineq : (βˆ‘ i, if d i = 0 then 0 else 1) * b ≀ (K*b-N)+H := by omega
have hsub : ((K*b-N : β„•) : ℝ) = (K : ℝ)*b-N := by
rw [Nat.cast_sub hNb', Nat.cast_mul]
have hsgn : (N : ℝ)-(K : ℝ)*b ≀ 0 := by
have hh : (N : ℝ) ≀ (K : ℝ)*b := by exact_mod_cast hNb'
linarith
rw [abs_of_nonpos hsgn]
have hh : ((βˆ‘ i, if d i = 0 then 0 else 1 : β„•) : ℝ)*b ≀ ((K*b-N : β„•) : ℝ)+H := by
exact_mod_cast hineq
rw [hsub] at hh
linarith
noncomputable def tileCount (β„“ L : ℝ) : β„• := ⌊L/(β„“+2)βŒ‹β‚Š ^ 3
theorem sum_baseline_le {K b H : β„•} {r : Fin K β†’ β„•} {a : β„• β†’ ℝ} {M : ℝ}
(hr : βˆ€ i, r i ≀ H) (ha : βˆ€ n, n ≀ H β†’ a n ≀ M) (hb : -M ≀ a b) :
βˆ‘ i, a (r i) ≀ K*a b + 2*M*(βˆ‘ i, if r i = b then 0 else 1 : β„•) := by
classical
calc
βˆ‘ i, a (r i) ≀ βˆ‘ i, (a b + 2*M*(if r i = b then 0 else 1 : β„•)) := by
apply Finset.sum_le_sum
intro i _
by_cases hh : r i = b
Β· simp [hh]
Β· simp only [ite_eq_right hh, Nat.cast_one, mul_one]
linarith [ha (r i) (hr i)]
_ = _ := by
rw [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin,
nsmul_eq_mul, ← Finset.mul_sum, Nat.cast_sum]
theorem adjusted_box_comparison (a : ℝ β†’ β„• β†’ ℝ) {β„“ L M : ℝ} {b H N : β„•}
(hβ„“ : 0 < β„“) (hL : 0 < L) (hM : 0 ≀ M) (hb : 0 < b) (hH : 2*b ≀ H)
(hN : N ≀ tileCount β„“ L * H)
(hbox : βˆ€ r : Fin (tileCount β„“ L) β†’ β„•, (βˆ‘ i, r i) = N β†’
a L N ≀ β„“^3/L^3 * βˆ‘ i, a β„“ (r i))
(hbound : βˆ€ n, n ≀ H β†’ a β„“ n ≀ M) (hbase : -M ≀ a β„“ b) :
a L N ≀ ((tileCount β„“ L : ℝ)/L^3)*β„“^3*a β„“ b +
(2*M*β„“^3/(b : ℝ)) * (|(N : ℝ)/L^3 - ((tileCount β„“ L : ℝ)/L^3)*b| + H/L^3) := by
classical
obtain ⟨r, hr, hcounts, hchange⟩ := exists_adjusted_counts (tileCount β„“ L) b H N hb hH hN
have hs := sum_baseline_le hcounts hbound hbase
have hm : 0 ≀ β„“^3/L^3 := div_nonneg (pow_nonneg hβ„“.le _) (pow_nonneg hL.le _)
have hbR : (0 : ℝ) < b := by exact_mod_cast hb
have hc : (βˆ‘ i, if r i = b then 0 else 1 : β„•) ≀
(|(N : ℝ) - (tileCount β„“ L : ℝ)*b|+H)/(b : ℝ) :=
(le_div_iffβ‚€ hbR).2 hchange
calc
a L N ≀ β„“^3/L^3 * βˆ‘ i, a β„“ (r i) := hbox r hr
_ ≀ β„“^3/L^3 * ((tileCount β„“ L : ℝ)*a β„“ b +
2*M*((|(N : ℝ)-(tileCount β„“ L : ℝ)*b|+H)/(b : ℝ))) := by
apply mul_le_mul_of_nonneg_left _ hm
exact hs.trans (add_le_add le_rfl (mul_le_mul_of_nonneg_left hc (show 0 ≀ 2*M by positivity)))
_ = _ := by
have heq : (N : ℝ)/L^3 - ((tileCount β„“ L : ℝ)/L^3)*b =
((N : ℝ)-(tileCount β„“ L : ℝ)*b)/L^3 := by ring
rw [heq, abs_div, abs_of_pos (pow_pos hL 3)]
ring
end ContinuumTemperature
end
end OAI