Download lean/OAI/Probability/RadialTransition/BoundedCore.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 9.4 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/RadialTransition/BoundedCore.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Probability/RadialTransition/BoundedCore.lean
-
curl -L -o BoundedCore.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/RadialTransition/BoundedCore.lean
9.4 kB
| import OAI.Probability.RadialTransition.ShellGeometry | |
| namespace OAI | |
| universe uV | |
| noncomputable section | |
| open scoped BigOperators NNReal ContDiff ENNReal | |
| open Filter MeasureTheory Set | |
| namespace RadialTransition | |
| def clamp01 (x : ℝ) : ℝ := max 0 (min 1 x) | |
| theorem clamp01_nonneg (x : ℝ) : 0 ≤ clamp01 x := le_max_left _ _ | |
| theorem clamp01_le_one (x : ℝ) : clamp01 x ≤ 1 := | |
| max_le (by norm_num) (min_le_left _ _) | |
| theorem clamp01_eq_zero {x : ℝ} (hx : x ≤ 0) : clamp01 x = 0 := by | |
| exact max_eq_left (le_trans (min_le_right _ _) hx) | |
| theorem clamp01_eq_one {x : ℝ} (hx : 1 ≤ x) : clamp01 x = 1 := by | |
| simp [clamp01, min_eq_left hx] | |
| theorem clamp01_mono : Monotone clamp01 := by | |
| intro x y hxy | |
| exact max_le_max le_rfl (min_le_min le_rfl hxy) | |
| theorem continuous_clamp01 : Continuous clamp01 := by | |
| unfold clamp01 | |
| fun_prop | |
| def microLength (t : ℝ) : ℝ := Real.exp (-t) | |
| def shellStep (t : ℝ) : ℝ := microLength t / 3000 | |
| def coreReal (t r : ℝ) : ℝ := | |
| t ^ 2 * min | |
| (1 - clamp01 ((r - microLength t) / shellStep t) + | |
| clamp01 ((r - microLength t - 2 * shellStep t) / shellStep t)) | |
| (clamp01 (1 + t * (1 - r))) | |
| def corePotential (t : ℝ) : Potential := fun r => coreReal t r | |
| theorem microLength_pos (t : ℝ) : 0 < microLength t := Real.exp_pos _ | |
| theorem shellStep_pos (t : ℝ) : 0 < shellStep t := div_pos (microLength_pos t) (by norm_num) | |
| theorem coreReal_nonneg (t r : ℝ) : 0 ≤ coreReal t r := by | |
| apply mul_nonneg (sq_nonneg t) | |
| apply le_min | |
| · linarith [clamp01_le_one ((r - microLength t) / shellStep t), | |
| clamp01_nonneg ((r - microLength t - 2 * shellStep t) / shellStep t)] | |
| · exact clamp01_nonneg _ | |
| theorem coreReal_le (t r : ℝ) : coreReal t r ≤ t ^ 2 := by | |
| have hh : min | |
| (1 - clamp01 ((r - microLength t) / shellStep t) + | |
| clamp01 ((r - microLength t - 2 * shellStep t) / shellStep t)) | |
| (clamp01 (1 + t * (1 - r))) ≤ 1 := | |
| (min_le_right _ _).trans (clamp01_le_one _) | |
| simpa only [coreReal, mul_one] using mul_le_mul_of_nonneg_left hh (sq_nonneg t) | |
| theorem continuous_coreReal (t : ℝ) : Continuous (coreReal t) := by | |
| unfold coreReal | |
| exact continuous_const.mul | |
| (((continuous_const.sub (continuous_clamp01.comp | |
| ((continuous_id.sub continuous_const).div_const _))).add | |
| (continuous_clamp01.comp | |
| (((continuous_id.sub continuous_const).sub continuous_const).div_const _))).min | |
| (continuous_clamp01.comp | |
| (continuous_const.add (continuous_const.mul (continuous_const.sub continuous_id))))) | |
| theorem continuous_corePotential (t : ℝ) : Continuous (corePotential t) := | |
| (continuous_coreReal t).comp NNReal.continuous_coe | |
| theorem bounded_corePotential (t : ℝ) : IsBoundedPotential (corePotential t) := by | |
| refine ⟨t ^ 2, sq_nonneg t, fun r => ?_⟩ | |
| change |coreReal t r| ≤ t ^ 2 | |
| rw [abs_of_nonneg (coreReal_nonneg t r)] | |
| exact coreReal_le t r | |
| theorem coreReal_zero_plateau (t r : ℝ) | |
| (hlo : microLength t + shellStep t ≤ r) | |
| (hhi : r ≤ microLength t + 2 * shellStep t) : coreReal t r = 0 := by | |
| have hd := shellStep_pos t | |
| have hdown : clamp01 ((r - microLength t) / shellStep t) = 1 := | |
| clamp01_eq_one ((le_div_iff₀ hd).mpr (by linarith)) | |
| have hup : clamp01 ((r - microLength t - 2 * shellStep t) / shellStep t) = 0 := | |
| clamp01_eq_zero (div_nonpos_of_nonpos_of_nonneg (by linarith) hd.le) | |
| simp only [coreReal, hdown, hup, sub_self, add_zero, | |
| min_eq_left (clamp01_nonneg _), mul_zero] | |
| theorem coreReal_zero_outer {t r : ℝ} (ht : 0 < t) (hr : 1 + 1 / t ≤ r) : | |
| coreReal t r = 0 := by | |
| have hc : clamp01 (1 + t * (1 - r)) = 0 := by | |
| apply clamp01_eq_zero | |
| have hm := mul_le_mul_of_nonneg_left hr ht.le | |
| have hd := div_mul_cancel₀ (1 : ℝ) (ne_of_gt ht) | |
| nlinarith [hm, hd] | |
| have hs : 0 ≤ 1 - clamp01 ((r - microLength t) / shellStep t) + | |
| clamp01 ((r - microLength t - 2 * shellStep t) / shellStep t) := by | |
| linarith [clamp01_le_one ((r - microLength t) / shellStep t), | |
| clamp01_nonneg ((r - microLength t - 2 * shellStep t) / shellStep t)] | |
| simp only [coreReal, hc, min_eq_right hs, mul_zero] | |
| theorem coreReal_full_left {t r : ℝ} (ht : 0 ≤ t) | |
| (hl : r ≤ microLength t) (hr : r ≤ 1) : coreReal t r = t ^ 2 := by | |
| have hd := shellStep_pos t | |
| have hdown : clamp01 ((r - microLength t) / shellStep t) = 0 := | |
| clamp01_eq_zero (div_nonpos_of_nonpos_of_nonneg (by linarith) hd.le) | |
| have hup : clamp01 ((r - microLength t - 2 * shellStep t) / shellStep t) = 0 := | |
| clamp01_eq_zero (div_nonpos_of_nonpos_of_nonneg (by linarith) hd.le) | |
| have hc : clamp01 (1 + t * (1 - r)) = 1 := | |
| clamp01_eq_one (by nlinarith [mul_nonneg ht (sub_nonneg.mpr hr)]) | |
| simp [coreReal, hdown, hup, hc] | |
| theorem coreReal_full_right {t r : ℝ} (ht : 0 ≤ t) | |
| (hl : microLength t + 3 * shellStep t ≤ r) (hr : r ≤ 1) : | |
| coreReal t r = t ^ 2 := by | |
| have hd := shellStep_pos t | |
| have hdown : clamp01 ((r - microLength t) / shellStep t) = 1 := | |
| clamp01_eq_one ((le_div_iff₀ hd).mpr (by linarith)) | |
| have hup : clamp01 ((r - microLength t - 2 * shellStep t) / shellStep t) = 1 := | |
| clamp01_eq_one ((le_div_iff₀ hd).mpr (by linarith)) | |
| have hc : clamp01 (1 + t * (1 - r)) = 1 := | |
| clamp01_eq_one (by nlinarith [mul_nonneg ht (sub_nonneg.mpr hr)]) | |
| simp [coreReal, hdown, hup, hc] | |
| theorem coreReal_full_of_not_shell {t r : ℝ} (ht : 0 ≤ t) (hr : r ≤ 1) | |
| (hs : ¬(microLength t ≤ r ∧ r ≤ (1 + (1 : ℝ) / 1000) * microLength t)) : | |
| coreReal t r = t ^ 2 := by | |
| by_cases hlo : microLength t ≤ r | |
| · apply coreReal_full_right ht ?_ hr | |
| have hhi : (1 + (1 : ℝ) / 1000) * microLength t < r := | |
| lt_of_not_ge (fun hh => hs ⟨hlo, hh⟩) | |
| dsimp [shellStep] | |
| linarith [hhi] | |
| · exact coreReal_full_left ht (le_of_not_ge hlo) hr | |
| theorem twice_pair_sum {N : ℕ} (F : Fin N → Fin N → ℝ) | |
| (hF : ∀ i j, F i j = F j i) : | |
| 2 * (∑ i, ∑ j with i < j, F i j) = | |
| ∑ i, ∑ j, if i ≠ j then F i j else 0 := by | |
| classical | |
| simp only [Finset.sum_filter] | |
| have hswap : (∑ i, ∑ j, if j < i then F i j else 0) = | |
| ∑ i, ∑ j, if i < j then F i j else 0 := by | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| rw [hF j i] | |
| calc | |
| 2 * (∑ i, ∑ j, if i < j then F i j else 0) = | |
| (∑ i, ∑ j, if i < j then F i j else 0) + | |
| (∑ i, ∑ j, if j < i then F i j else 0) := by rw [hswap]; ring | |
| _ = _ := by | |
| rw [← Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| rw [← Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| rcases lt_trichotomy i j with h | h | h | |
| · simp [h, ne_of_lt h, not_lt_of_ge h.le] | |
| · simp [h] | |
| · simp [h, ne_of_gt h, not_lt_of_ge h.le] | |
| theorem sum_adj_indicator {V : Type uV} [Fintype V] (G : SimpleGraph V) | |
| [DecidableRel G.Adj] : | |
| (∑ i, ∑ j, if G.Adj i j then (1 : ℝ) else 0) = 2 * G.edgeFinset.card := by | |
| classical | |
| have hi (i : V) : (∑ j, if G.Adj i j then (1 : ℝ) else 0) = G.degree i := by | |
| rw [← G.card_neighborFinset_eq_degree, G.neighborFinset_eq_filter] | |
| simp | |
| simp_rw [hi] | |
| exact_mod_cast G.sum_degrees_eq_twice_card_edges | |
| theorem core_energy_lower_small_diameter {N : ℕ} {t : ℝ} (ht : 0 ≤ t) | |
| (x : Fin N → Position) (hx : ∀ i j, dist (x i) (x j) ≤ 1) : | |
| t ^ 2 / 8 * (N : ℝ) ^ 2 - t ^ 2 / 2 * N ≤ energy (corePotential t) x := by | |
| classical | |
| let G := shellGraph x (microLength t) | |
| have hG : G.CliqueFree 5 := shellGraph_cliqueFree x (microLength_pos t) | |
| have hbound : (8 : ℝ) * G.edgeFinset.card ≤ 3 * (N : ℝ) ^ 2 := by | |
| have hh : 8 * G.edgeFinset.card ≤ 3 * N ^ 2 := by | |
| simpa using shell_edge_bound G hG | |
| exact_mod_cast hh | |
| have hpair := twice_pair_sum | |
| (fun i j => coreReal t (dist (x i) (x j))) (fun i j => by rw [dist_comm]) | |
| have heq : (∑ i, ∑ j with i < j, coreReal t (dist (x i) (x j))) = | |
| energy (corePotential t) x := by rfl | |
| rw [heq] at hpair | |
| have hterm (i j : Fin N) : | |
| t ^ 2 * ((if i ≠ j then (1 : ℝ) else 0) - (if G.Adj i j then 1 else 0)) ≤ | |
| (if i ≠ j then coreReal t (dist (x i) (x j)) else 0) := by | |
| by_cases hij : i = j | |
| · subst j | |
| simp | |
| · simp only [ite_eq_left hij] | |
| by_cases hA : G.Adj i j | |
| · simp only [hA, ite_true, sub_self, mul_zero] | |
| exact coreReal_nonneg _ _ | |
| · simp only [hA, ite_false, sub_zero, mul_one] | |
| rw [coreReal_full_of_not_shell ht (hx i j)] | |
| intro h | |
| exact hA ⟨hij, h⟩ | |
| have hsum := Finset.sum_le_sum (s := Finset.univ) fun i _ => | |
| Finset.sum_le_sum (s := Finset.univ) fun j _ => hterm i j | |
| have hcount : (∑ i : Fin N, ∑ j : Fin N, if i ≠ j then (1 : ℝ) else 0) = | |
| (N : ℝ) ^ 2 - N := by | |
| have hite (i j : Fin N) : (if i ≠ j then (1 : ℝ) else 0) = | |
| 1 - (if i = j then 1 else 0) := by by_cases h : i = j <;> simp [h] | |
| simp_rw [hite] | |
| simp only [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, | |
| Fintype.card_fin, nsmul_eq_mul, mul_one, Finset.sum_ite_eq, | |
| Finset.mem_univ, ite_true] | |
| ring | |
| simp only [mul_sub, Finset.sum_sub_distrib, ← Finset.mul_sum] at hsum | |
| rw [hcount, sum_adj_indicator G, ← hpair] at hsum | |
| have hb := mul_le_mul_of_nonneg_left hbound (sq_nonneg t) | |
| nlinarith [hsum, hb] | |
| end RadialTransition | |
| end | |
| end OAI | |