Download data/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean
-
curl -L -o BoxTiling.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean
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 | |