Download data/lean/OAI/Analysis/HardSphere/Paths/NearPotential.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 19.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/HardSphere/Paths/NearPotential.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/HardSphere/Paths/NearPotential.lean
-
curl -L -o NearPotential.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/HardSphere/Paths/NearPotential.lean
19.3 kB
| import Mathlib | |
| import OAI.Analysis.HardSphere.Paths.TimeGaps | |
| namespace OAI | |
| section | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Set Filter | |
| open scoped ENNReal BigOperators Topology | |
| namespace HardSphere.DyadicSkeleton | |
| lemma orderedEncounterConstant_one_le : 1 β€ orderedEncounterConstant := by | |
| simpa only [orderedEncounterConstant,ENNReal.toReal_one] using | |
| ENNReal.toReal_mono gapKernel_sum_ne_top gapKernel_sum_one_le | |
| def nearPotential (n : β) (y : Fin 2 β β) (R : β) (Ο : Noise) : β := | |
| (nearTest n y R Ο).toReal | |
| lemma nearPotential_nonneg (n : β) (y : Fin 2 β β) (R : β) (Ο : Noise) : | |
| 0 β€ nearPotential n y R Ο := ENNReal.toReal_nonneg | |
| lemma nearPotential_le_one (n : β) (y : Fin 2 β β) (R : β) (Ο : Noise) : | |
| nearPotential n y R Ο β€ 1 := by | |
| simpa only [nearPotential,ENNReal.toReal_one] using | |
| ENNReal.toReal_mono (by norm_num : (1:ββ₯0β) β β) (nearTest_le_one n y R Ο) | |
| lemma nearPotential_cast (n : β) (y : Fin 2 β β) (R : β) (Ο : Noise) : | |
| ENNReal.ofReal (nearPotential n y R Ο) = nearTest n y R Ο := | |
| ENNReal.ofReal_toReal (ne_top_of_le_ne_top (by norm_num) (nearTest_le_one n y R Ο)) | |
| @[fun_prop] lemma measurable_nearPotential (n : β) (y : Fin 2 β β) (R : β) : | |
| Measurable (nearPotential n y R) := (measurable_nearTest n y R).ennreal_toReal | |
| def singleRadiusWeights (R : β) (a : ββ₯0β) (l : β) : ββ₯0β := if l=R then a else 0 | |
| lemma singleRadiusWeights_envelope (R : β) (a : ββ₯0β) (n : β) | |
| (y : Fin 2 β β) (Ο : Noise) : | |
| radiusEnvelope (singleRadiusWeights R a) n y Ο = a * nearTest n y (R:β) Ο := by | |
| simp [radiusEnvelope,singleRadiusWeights,ite_mul] | |
| lemma singleRadiusWeights_activity (R : β) (a : ββ₯0β) : | |
| radiusActivity (singleRadiusWeights R a) = | |
| ENNReal.ofReal orderedEncounterConstant * (a * radiusFactor (R:β)) := by | |
| simp [radiusActivity,singleRadiusWeights,ite_mul] | |
| def hitConstant : β := (4 * Real.exp 2 * orderedEncounterConstant)β»ΒΉ | |
| lemma hitConstant_pos : 0 < hitConstant := by | |
| unfold hitConstant | |
| positivity [orderedEncounterConstant_pos] | |
| lemma hitConstant_le_one : hitConstant β€ 1 := by | |
| have he : 1 β€ Real.exp 2 := Real.one_le_exp (by norm_num) | |
| have hc := orderedEncounterConstant_one_le | |
| have hd : 1 β€ 4 * Real.exp 2 * orderedEncounterConstant := by nlinarith | |
| exact (inv_le_oneβ (by positivity)).mpr hd | |
| lemma same_time_hit_moment (T R : β) (y : β β Fin 2 β β) : | |
| (β«β» Ο, ENNReal.ofReal (Real.exp ((hitConstant/(1+(R:β))^2) * | |
| β u β Finset.range (T+1), nearPotential u (y u) (R:β) Ο)) βlaw) β€ 2 := by | |
| let a := hitConstant/(2*(1+(R:β))^2) | |
| have hp : 0 < (1+(R:β))^2 := by positivity | |
| have ha : 0 β€ a := by dsimp [a]; exact div_nonneg hitConstant_pos.le (by positivity) | |
| have ha1 : a β€ 1 := by | |
| dsimp [a] | |
| apply (div_le_one (by positivity)).mpr | |
| have hr := Nat.cast_nonneg (Ξ±:=β) R | |
| nlinarith [hitConstant_le_one] | |
| have hsmall : ENNReal.ofReal (2*Real.exp 2) * | |
| radiusActivity (singleRadiusWeights R (ENNReal.ofReal a)) β€ (1/2:ββ₯0β) := by | |
| rw [singleRadiusWeights_activity,radiusFactor, | |
| β ENNReal.ofReal_mul ha,β ENNReal.ofReal_mul orderedEncounterConstant_pos.le, | |
| β ENNReal.ofReal_mul (by positivity : 0 β€ 2*Real.exp 2)] | |
| have heq : 2*Real.exp 2*(orderedEncounterConstant*(a*(1+(R:β))^2)) = 1/4 := by | |
| dsimp [a,hitConstant] | |
| field_simp [ne_of_gt orderedEncounterConstant_pos,ne_of_gt (Real.exp_pos 2)] | |
| rw [heq] | |
| norm_num [ENNReal.ofReal_div_of_pos] | |
| have h := radius_exponential_bound T (singleRadiusWeights R (ENNReal.ofReal a)) y | |
| (fun n Ο β¦ a*nearPotential n (y n) (R:β) Ο) | |
| (fun n Ο β¦ mul_nonneg ha (nearPotential_nonneg n (y n) (R:β) Ο)) | |
| (fun n Ο β¦ (mul_le_mul_of_nonneg_left (nearPotential_le_one n (y n) (R:β) Ο) ha).trans | |
| (by simpa using ha1)) | |
| (by intro n Ο; rw [ENNReal.ofReal_mul ha,nearPotential_cast,singleRadiusWeights_envelope]) hsmall | |
| convert h using 1 | |
| apply lintegral_congr | |
| intro Ο | |
| congr 2 | |
| rw [β Finset.mul_sum] | |
| dsimp [a] | |
| field_simp | |
| def transverseDistance (n : β) (y : Fin 2 β β) (Ο : Noise) : β := | |
| max |position Ο 0 n-y 0| |position Ο 1 n-y 1| | |
| lemma transverseDistance_nonneg (n : β) (y : Fin 2 β β) (Ο : Noise) : | |
| 0 β€ transverseDistance n y Ο := (abs_nonneg _).trans (le_max_left _ _) | |
| @[fun_prop] lemma measurable_transverseDistance (n : β) (y : Fin 2 β β) : | |
| Measurable (transverseDistance n y) := by unfold transverseDistance; fun_prop | |
| lemma nearTest_eq_one (n : β) (y : Fin 2 β β) (R : β) (Ο : Noise) | |
| (h : transverseDistance n y Ο β€ R) : nearTest n y R Ο = 1 := by | |
| have h' := max_le_iff.mp h | |
| simp [nearTest,coordinateTest,h'.1,h'.2] | |
| def softPotential (B : β) (n : β) (y : Fin 2 β β) (Ο : Noise) : β := | |
| Real.exp (-transverseDistance n y Ο/B) | |
| lemma softPotential_nonneg (B : β) (n : β) (y : Fin 2 β β) (Ο : Noise) : | |
| 0 β€ softPotential B n y Ο := (Real.exp_pos _).le | |
| lemma softPotential_le_one (B : β) (hB : 0 < B) (n : β) (y : Fin 2 β β) (Ο : Noise) : | |
| softPotential B n y Ο β€ 1 := | |
| Real.exp_le_one_iff.mpr (div_nonpos_of_nonpos_of_nonneg (by | |
| linarith [transverseDistance_nonneg n y Ο]) hB.le) | |
| @[fun_prop] lemma measurable_softPotential (B : β) (n : β) (y : Fin 2 β β) : | |
| Measurable (softPotential B n y) := by unfold softPotential; fun_prop | |
| def softWeights (B : β) (l : β) : ββ₯0β := ENNReal.ofReal (Real.exp ((1-(l:β))/B)) | |
| lemma softPotential_envelope (B : β) (hB : 0 < B) (n : β) (y : Fin 2 β β) (Ο : Noise) : | |
| ENNReal.ofReal (softPotential B n y Ο) β€ radiusEnvelope (softWeights B) n y Ο := by | |
| let l := βtransverseDistance n y Οββ | |
| have hl : transverseDistance n y Ο β€ (l:β) := Nat.le_ceil _ | |
| have hl' : (l:β) < transverseDistance n y Ο+1 := | |
| Nat.ceil_lt_add_one (transverseDistance_nonneg n y Ο) | |
| refine le_trans ?_ (ENNReal.le_tsum (f := fun k : β β¦ | |
| softWeights B k * nearTest n y (k:β) Ο) l) | |
| rw [nearTest_eq_one n y (l:β) Ο hl,mul_one] | |
| change ENNReal.ofReal (Real.exp (-transverseDistance n y Ο/B)) β€ | |
| ENNReal.ofReal (Real.exp ((1-(l:β))/B)) | |
| apply ENNReal.ofReal_le_ofReal | |
| apply Real.exp_le_exp.mpr | |
| exact div_le_div_of_nonneg_right (by linarith) hB.le | |
| lemma soft_activity_ne_top (B : β) (hB : 0 < B) : radiusActivity (softWeights B) β β := by | |
| let q := Real.exp (-1/B) | |
| have hq : βqβ < 1 := by | |
| rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] | |
| apply Real.exp_lt_one_iff.mpr | |
| exact div_neg_of_neg_of_pos (by norm_num) hB | |
| have hs0 : Summable (fun l : β β¦ q^l) := summable_geometric_of_norm_lt_one hq | |
| have hs1 := summable_pow_mul_geometric_of_norm_lt_one 1 hq | |
| have hs2 := summable_pow_mul_geometric_of_norm_lt_one 2 hq | |
| have hs : Summable (fun l : β β¦ Real.exp ((1-(l:β))/B)*(1+(l:β))^2) := by | |
| have h := ((hs2.add (hs1.mul_left 2)).add hs0).mul_left (Real.exp (1/B)) | |
| apply h.congr | |
| intro l | |
| have he : Real.exp ((1-(l:β))/B) = Real.exp (1/B) * q^l := by | |
| rw [show (1-(l:β))/B = 1/B + (l:β)*(-1/B) by ring,Real.exp_add,Real.exp_nat_mul] | |
| rw [he] | |
| simp only [pow_one] | |
| ring | |
| have he : (β' l : β, softWeights B l * radiusFactor (l:β)) = | |
| ENNReal.ofReal (β' l : β, Real.exp ((1-(l:β))/B)*(1+(l:β))^2) := by | |
| simp only [softWeights,radiusFactor,β ENNReal.ofReal_mul (Real.exp_pos _).le] | |
| exact (ENNReal.ofReal_tsum_of_nonneg (fun l β¦ by positivity) hs).symm | |
| unfold radiusActivity | |
| rw [he] | |
| finiteness | |
| lemma same_time_soft_moment (B : β) (hB : 0 < B) : | |
| β ΞΎ : β, 0 < ΞΎ β§ β (T : β) (y : β β Fin 2 β β), | |
| (β«β» Ο, ENNReal.ofReal (Real.exp (ΞΎ * | |
| β u β Finset.range (T+1), softPotential B u (y u) Ο)) βlaw) β€ 2 := by | |
| let A := (radiusActivity (softWeights B)).toReal | |
| let Ξ΄ := (4*Real.exp 2*(1+A))β»ΒΉ | |
| have hA : 0 β€ A := ENNReal.toReal_nonneg | |
| have hAc : ENNReal.ofReal A = radiusActivity (softWeights B) := | |
| ENNReal.ofReal_toReal (soft_activity_ne_top B hB) | |
| have hd : 0 < Ξ΄ := by dsimp [Ξ΄]; positivity | |
| have hd1 : Ξ΄ β€ 1 := by | |
| apply (inv_le_oneβ (by positivity)).mpr | |
| have he : 1 β€ Real.exp 2 := Real.one_le_exp (by norm_num) | |
| nlinarith | |
| refine β¨2*Ξ΄,by positivity,?_β© | |
| intro T y | |
| let a := fun l β¦ ENNReal.ofReal Ξ΄ * softWeights B l | |
| have hsmall : ENNReal.ofReal (2*Real.exp 2) * radiusActivity a β€ (1/2:ββ₯0β) := by | |
| rw [show radiusActivity a = ENNReal.ofReal Ξ΄ * radiusActivity (softWeights B) from | |
| radiusActivity_smul _ _,β hAc,β ENNReal.ofReal_mul hd.le, | |
| β ENNReal.ofReal_mul (by positivity : 0 β€ 2*Real.exp 2)] | |
| calc | |
| _ β€ ENNReal.ofReal (1/2:β) := by | |
| apply ENNReal.ofReal_le_ofReal | |
| dsimp [Ξ΄] | |
| have he := Real.exp_pos 2 | |
| field_simp | |
| nlinarith | |
| _ = _ := by norm_num [ENNReal.ofReal_div_of_pos] | |
| have h := radius_exponential_bound T a y | |
| (fun n Ο β¦ Ξ΄ * softPotential B n (y n) Ο) | |
| (fun n Ο β¦ mul_nonneg hd.le (softPotential_nonneg B n (y n) Ο)) | |
| (fun n Ο β¦ (mul_le_mul_of_nonneg_left (softPotential_le_one B hB n (y n) Ο) hd.le).trans | |
| (by simpa using hd1)) | |
| (by | |
| intro n Ο | |
| rw [ENNReal.ofReal_mul hd.le] | |
| exact (mul_le_mul_right (softPotential_envelope B hB n (y n) Ο) (ENNReal.ofReal Ξ΄)).trans_eq | |
| (radiusEnvelope_smul _ _ n (y n) Ο).symm) hsmall | |
| convert h using 1 | |
| apply lintegral_congr | |
| intro Ο | |
| congr 2 | |
| rw [β Finset.mul_sum] | |
| ring | |
| def twoCopyDistance (n : β) (z : Noise Γ Noise) : β := | |
| transverseDistance n (fun j β¦ position z.2 j n) z.1 | |
| @[fun_prop] lemma measurable_twoCopyDistance (n : β) : | |
| Measurable (twoCopyDistance n) := by | |
| unfold twoCopyDistance transverseDistance | |
| exact (((measurable_position 0 n).comp measurable_fst).sub | |
| ((measurable_position 0 n).comp measurable_snd)).abs.max | |
| (((measurable_position 1 n).comp measurable_fst).sub | |
| ((measurable_position 1 n).comp measurable_snd)).abs | |
| @[fun_prop] lemma measurable_twoCopyNear (n : β) (R : β) : | |
| Measurable (fun z : Noise Γ Noise β¦ | |
| nearPotential n (fun j β¦ position z.2 j n) R z.1) := by | |
| unfold nearPotential nearTest | |
| apply Measurable.ennreal_toReal | |
| apply Measurable.mul | |
| all_goals | |
| apply measurable_const.indicator | |
| apply measurableSet_le _ measurable_const | |
| apply Measurable.abs | |
| exact ((measurable_position _ n).comp measurable_fst).sub | |
| ((measurable_position _ n).comp measurable_snd) | |
| lemma two_copy_hit_moment (T R : β) : | |
| (β«β» z, ENNReal.ofReal (Real.exp ((hitConstant/(1+(R:β))^2) * | |
| β u β Finset.range (T+1), nearPotential u | |
| (fun j β¦ position z.2 j u) (R:β) z.1)) βlaw.prod law) β€ 2 := by | |
| rw [lintegral_prod_symm _ (by | |
| apply Measurable.aemeasurable | |
| apply Measurable.ennreal_ofReal | |
| apply Measurable.exp | |
| apply Measurable.const_mul | |
| exact Finset.measurable_sum _ (fun u _ β¦ measurable_twoCopyNear u (R:β)))] | |
| calc | |
| _ β€ β«β» _ : Noise, (2:ββ₯0β) βlaw := lintegral_mono (fun Ο β¦ | |
| same_time_hit_moment T R (fun u j β¦ position Ο j u)) | |
| _ = 2 := by simp | |
| lemma two_copy_soft_moment (B : β) (hB : 0 < B) : | |
| β ΞΎ : β, 0 < ΞΎ β§ β T : β, | |
| (β«β» z, ENNReal.ofReal (Real.exp (ΞΎ * | |
| β u β Finset.range (T+1), Real.exp (-twoCopyDistance u z / B))) | |
| βlaw.prod law) β€ 2 := by | |
| obtain β¨ΞΎ,hΞΎ,hβ© := same_time_soft_moment B hB | |
| refine β¨ΞΎ,hΞΎ,fun T β¦ ?_β© | |
| rw [lintegral_prod_symm _ (by fun_prop)] | |
| calc | |
| _ β€ β«β» _ : Noise, (2:ββ₯0β) βlaw := lintegral_mono (fun Ο β¦ | |
| h T (fun u j β¦ position Ο j u)) | |
| _ = 2 := by simp | |
| lemma position_lipschitz (Ο : Noise) (j : Fin 2) (s t : β) : | |
| |position Ο j s-position Ο j t| β€ |(s:β)-t|/2 := by | |
| have hinc (a k : β) : |position Ο j (a+k)-position Ο j a| β€ (k:β)/2 := by | |
| induction k with | |
| | zero => simp | |
| | succ k ih => | |
| rw [Nat.add_succ, position_succ] | |
| calc | |
| _ = |(position Ο j (a+k)-position Ο j a)+velocity Ο j (a+k)| := by congr 1; ring | |
| _ β€ _ := abs_add_le _ _ | |
| _ β€ (k:β)/2+1/2 := add_le_add ih (velocity_abs_le Ο j (a+k)) | |
| _ = _ := by push_cast; ring | |
| rcases le_total t s with h | h | |
| Β· have hs : 0 β€ (s:β)-t := sub_nonneg.mpr (by exact_mod_cast h) | |
| rw [abs_of_nonneg hs] | |
| simpa only [Nat.add_sub_of_le h,Nat.cast_sub h] using hinc t (s-t) | |
| Β· have hs : 0 β€ (t:β)-s := sub_nonneg.mpr (by exact_mod_cast h) | |
| rw [abs_sub_comm (s:β),abs_of_nonneg hs,abs_sub_comm (position Ο j s)] | |
| simpa only [Nat.add_sub_of_le h,Nat.cast_sub h] using hinc s (t-s) | |
| lemma position_abs_le (Ο : Noise) (j : Fin 2) (t : β) : | |
| |position Ο j t| β€ (t:β)/2 := by | |
| simpa [position,abs_of_nonneg (Nat.cast_nonneg (Ξ±:=β) t)] using position_lipschitz Ο j t 0 | |
| lemma fold_time_lipschitz (n s t : β) (hs : s β€ n) (ht : t β€ n) : | |
| |((min s (n-s):β):β)-((min t (n-t):β):β)| β€ |(s:β)-t| := by | |
| have h := abs_min_sub_min_le_max (s:β) ((n:β)-s) (t:β) ((n:β)-t) | |
| have he : |((n:β)-s)-((n:β)-t)| = |(s:β)-t| := by | |
| rw [sub_sub_sub_cancel_left,abs_sub_comm] | |
| simpa only [Nat.cast_min,Nat.cast_sub hs,Nat.cast_sub ht,he,max_self] using h | |
| abbrev Vertex := Fin 3 β β€ | |
| def baseTrans (n : β) (d : Fin 2 β β€) (Ο : Noise) (t : β) (j : Fin 2) : β := | |
| (t:β)*(d j:β)/(n:β)+position Ο j (min t (n-t)) | |
| def baseVertex (n : β) (d : Fin 2 β β€) (Ο : Noise) (t : β) : Vertex := | |
| ![(t:β€),βbaseTrans n d Ο t 0β,βbaseTrans n d Ο t 1β] | |
| @[fun_prop] lemma measurable_baseTrans (n : β) (d : Fin 2 β β€) (t : β) (j : Fin 2) : | |
| Measurable (fun Ο β¦ baseTrans n d Ο t j) := by unfold baseTrans; fun_prop | |
| @[fun_prop] lemma measurable_baseVertex (n : β) (d : Fin 2 β β€) (t : β) : | |
| Measurable (fun Ο β¦ baseVertex n d Ο t) := by | |
| apply Measurable.of_eval | |
| intro j | |
| fin_cases j | |
| Β· exact measurable_const | |
| Β· exact Int.measurable_floor.comp (measurable_baseTrans n d t 0) | |
| Β· exact Int.measurable_floor.comp (measurable_baseTrans n d t 1) | |
| lemma drift_rate_le (n : β) (hn : 0 < n) (d : β€) (hd : |d| β€ n) : | |
| |(d:β)/(n:β)| β€ 1 := by | |
| have hn' : 0 < (n:β) := by exact_mod_cast hn | |
| rw [abs_div,abs_of_pos hn',div_le_one hn'] | |
| exact_mod_cast hd | |
| lemma baseTrans_lipschitz (n : β) (hn : 0 < n) (d : Fin 2 β β€) | |
| (hd : βj, |d j| β€ n) (Ο : Noise) (s t : β) (hs : s β€ n) (ht : t β€ n) (j : Fin 2) : | |
| |baseTrans n d Ο s j-baseTrans n d Ο t j| β€ (3/2)*|(s:β)-t| := by | |
| have hp := (position_lipschitz Ο j (min s (n-s)) (min t (n-t))).trans | |
| (div_le_div_of_nonneg_right (fold_time_lipschitz n s t hs ht) (by norm_num : (0:β) β€ 2)) | |
| calc | |
| _ = |((s:β)-t)*((d j:β)/(n:β))+ | |
| (position Ο j (min s (n-s))-position Ο j (min t (n-t)))| := by | |
| unfold baseTrans; congr 1; ring | |
| _ β€ _ := abs_add_le _ _ | |
| _ β€ |(s:β)-t| + |(s:β)-t|/2 := add_le_add (by | |
| rw [abs_mul] | |
| exact (mul_le_mul_of_nonneg_left (drift_rate_le n hn (d j) (hd j)) | |
| (abs_nonneg _)).trans_eq (mul_one _)) hp | |
| _ = _ := by ring | |
| lemma floor_abs_sub_le_two (x y : β) (h : |x-y| β€ 3/2) : | |
| |βxβ-βyβ| β€ (2:β€) := by | |
| have hf := Int.floor_le x | |
| have hg := Int.lt_floor_add_one y | |
| have hf' := Int.floor_le y | |
| have hg' := Int.lt_floor_add_one x | |
| obtain β¨hl,huβ© := abs_le.mp h | |
| apply abs_le.mpr | |
| constructor | |
| Β· by_contra hn | |
| have h' : βyβ-βxβ β₯ (3:β€) := by omega | |
| have hh : (3:β) β€ (βyβ:β)-(βxβ:β) := by exact_mod_cast h' | |
| linarith | |
| Β· by_contra hn | |
| have h' : βxβ-βyβ β₯ (3:β€) := by omega | |
| have hh : (3:β) β€ (βxβ:β)-(βyβ:β) := by exact_mod_cast h' | |
| linarith | |
| lemma baseVertex_step (n : β) (hn : 0 < n) (d : Fin 2 β β€) | |
| (hd : βj, |d j| β€ n) (Ο : Noise) (t : β) (ht : t < n) (j : Fin 3) : | |
| |baseVertex n d Ο (t+1) j-baseVertex n d Ο t j| β€ 2 := by | |
| have hh (i : Fin 2) : |βbaseTrans n d Ο (t+1) iβ-βbaseTrans n d Ο t iβ| β€ (2:β€) := by | |
| apply floor_abs_sub_le_two | |
| have h := baseTrans_lipschitz n hn d hd Ο (t+1) t (by omega) (by omega) i | |
| simpa only [Nat.cast_add,Nat.cast_one,add_sub_cancel_left,abs_one,mul_one] using h | |
| fin_cases j | |
| Β· norm_num [baseVertex] | |
| Β· exact hh 0 | |
| Β· exact hh 1 | |
| lemma baseVertex_initial (n : β) (d : Fin 2 β β€) (Ο : Noise) : | |
| baseVertex n d Ο 0 = 0 := by | |
| ext j | |
| fin_cases j <;> simp [baseVertex,baseTrans,position] | |
| lemma baseVertex_final (n : β) (hn : 0 < n) (d : Fin 2 β β€) (Ο : Noise) : | |
| baseVertex n d Ο n = ![(n:β€),d 0,d 1] := by | |
| have hn0 : (n:β) β 0 := by exact_mod_cast (ne_of_gt hn) | |
| ext j | |
| fin_cases j <;> simp [baseVertex,baseTrans,position,mul_div_cancel_leftβ _ hn0] | |
| def axisSteps (a b : β€) : List β€ := | |
| if a β€ b then (List.range (b-a).toNat).map (fun k : β β¦ a+(k:β€)+1) | |
| else (List.range (a-b).toNat).map (fun k : β β¦ a-(k:β€)-1) | |
| lemma axisSteps_length (a b : β€) : (axisSteps a b).length = (b-a).natAbs := by | |
| unfold axisSteps | |
| split_ifs with h <;> simp only [List.length_map,List.length_range] | |
| Β· have hh := Int.natAbs_of_nonneg (by omega : 0 β€ b-a) | |
| have hh' := Int.toNat_of_nonneg (by omega : 0 β€ b-a) | |
| omega | |
| Β· rw [β Int.natAbs_neg,Int.neg_sub] | |
| have hh := Int.natAbs_of_nonneg (by omega : 0 β€ a-b) | |
| have hh' := Int.toNat_of_nonneg (by omega : 0 β€ a-b) | |
| omega | |
| lemma axisSteps_between (a b c : β€) (hc : c β axisSteps a b) : | |
| min a b β€ c β§ c β€ max a b := by | |
| unfold axisSteps at hc | |
| split_ifs at hc with h | |
| Β· obtain β¨k,hk,rflβ© := List.mem_map.mp hc | |
| have hk' := List.mem_range.mp hk | |
| simp only [min_eq_left h,max_eq_right h] | |
| omega | |
| Β· obtain β¨k,hk,rflβ© := List.mem_map.mp hc | |
| have hk' := List.mem_range.mp hk | |
| simp only [min_eq_right (by omega : b β€ a),max_eq_left (by omega : b β€ a)] | |
| omega | |
| lemma axisSteps_near_final (a b c : β€) (hc : c β axisSteps a b) : | |
| |c-b| β€ |a-b| := by | |
| obtain β¨hl,huβ© := axisSteps_between a b c hc | |
| rcases le_total a b with h|h | |
| Β· rw [min_eq_left h] at hl | |
| rw [max_eq_right h] at hu | |
| rw [abs_of_nonpos (by omega : a-b β€ 0),abs_of_nonpos (by omega : c-b β€ 0)] | |
| omega | |
| Β· rw [min_eq_right h] at hl | |
| rw [max_eq_left h] at hu | |
| rw [abs_of_nonneg (by omega : 0 β€ a-b),abs_of_nonneg (by omega : 0 β€ c-b)] | |
| omega | |
| def refineStep (a b : Vertex) : List Vertex := | |
| [![b 0,a 1,a 2]] ++ | |
| (axisSteps (a 1) (b 1)).map (fun c β¦ ![b 0,c,a 2]) ++ | |
| (axisSteps (a 2) (b 2)).map (fun c β¦ ![b 0,b 1,c]) | |
| lemma refineStep_length (a b : Vertex) (h : βj, |b j-a j| β€ 2) : | |
| (refineStep a b).length β€ 5 := by | |
| simp only [refineStep,List.length_append,List.length_singleton,List.length_map,axisSteps_length] | |
| have h1 := h 1 | |
| have h2 := h 2 | |
| have ha1 : (b 1-a 1).natAbs β€ 2 := by | |
| have hh : ((b 1-a 1).natAbs:β€) β€ 2 := by simpa only [Int.natCast_natAbs] using h1 | |
| exact_mod_cast hh | |
| have ha2 : (b 2-a 2).natAbs β€ 2 := by | |
| have hh : ((b 2-a 2).natAbs:β€) β€ 2 := by simpa only [Int.natCast_natAbs] using h2 | |
| exact_mod_cast hh | |
| omega | |
| end HardSphere.DyadicSkeleton | |
| end | |
| end | |
| end OAI | |