Download data/lean/OAI/MathematicalPhysics/AlternatingFlow/DecayBounds.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/AlternatingFlow/DecayBounds.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/AlternatingFlow/DecayBounds.lean
-
curl -L -o DecayBounds.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/AlternatingFlow/DecayBounds.lean
16.1 kB
| import OAI.MathematicalPhysics.AlternatingFlow.InitialNames | |
| namespace OAI | |
| section DecayBoundsDevelopment | |
| open scoped BigOperators Topology ContDiff | |
| open Filter | |
| namespace AlternatingNS.Effective | |
| attribute [local instance] Arithmetic.rationalCoding | |
| open Bounds (readScale readScale_nonneg potential_decomposition norm_iterated_curl amplitude norm_comp_linear) | |
| lemma potential_bound : β C : (Machine Γ β) Γ β β β, Computable C β§ β M N r n x, | |
| βiteratedFDeriv β r (fun x => Spatial.cutoff x * | |
| Spatial.shearPotential (Construction.donorIndex n) (Construction.receiverIndex n) 0 | |
| (LocalRule.write M N n) (LocalRule.signal M N n) x) xβ β€ | |
| (C ((M,N),r) : β) * (Scales.Ξ΅ M.base N n + Scales.Ξ΅ M.base N (n + 1) * readScale M N n ^ r) := by | |
| obtain β¨sA, A, cA, haβ© := fixedPotential_scaled | |
| obtain β¨sB, B, cB, hbβ© := corePotential_scaled | |
| refine β¨fun z => A ((), z.2) + B z, | |
| Primrec.nat_add.to_comp.comp | |
| (cA.comp ((Computable.const ()).pair Computable.snd)) cB, fun M N r n x => ?_β© | |
| have hA : 0 β€ (A ((),r) : β) := Nat.cast_nonneg _ | |
| have hB : 0 β€ (B ((M,N),r) : β) := Nat.cast_nonneg _ | |
| simp only [Nat.cast_add] | |
| have hΞ΅ : 0 β€ Scales.Ξ΅ M.base N (n + 1) := Scales.Ξ΅_nonneg _ _ _ (by have := M.base_ge_four; omega) | |
| have hΞ΅' : Scales.Ξ΅ M.base N (n + 1) β€ Scales.Ξ΅ M.base N n := | |
| (Scales.Ξ΅_strictAnti M.base N (by have := M.base_ge_four; omega)).antitone (by omega) | |
| have hβ := sA () n | |
| have hβ := sB (M,N) n | |
| simp_rw [potential_decomposition] | |
| change βiteratedFDeriv β r (fun x => | |
| (Scales.Ξ΅ M.base N n - Scales.Ξ΅ M.base N (n + 1)) β’ Bounds.fixedPotential n x + | |
| Scales.Ξ΅ M.base N (n + 1) β’ Bounds.corePotential M N n x) xβ β€ _ | |
| have hsβ : ContDiff β β (fun x => | |
| (Scales.Ξ΅ M.base N n - Scales.Ξ΅ M.base N (n + 1)) β’ Bounds.fixedPotential n x) := hβ.const_smul _ | |
| have hsβ : ContDiff β β (fun x => | |
| Scales.Ξ΅ M.base N (n + 1) β’ Bounds.corePotential M N n x) := hβ.const_smul _ | |
| rw [fun_iteratedFDeriv_add_apply | |
| (hsβ.of_le (WithTop.coe_le_coe.mpr le_top)).contDiffAt | |
| (hsβ.of_le (WithTop.coe_le_coe.mpr le_top)).contDiffAt] | |
| apply (norm_add_le _ _).trans | |
| rw [iteratedFDeriv_const_smul_apply' (hβ.of_le (WithTop.coe_le_coe.mpr le_top)).contDiffAt, | |
| iteratedFDeriv_const_smul_apply' (hβ.of_le (WithTop.coe_le_coe.mpr le_top)).contDiffAt, | |
| norm_smul, norm_smul, Real.norm_eq_abs, Real.norm_eq_abs, | |
| abs_of_nonneg (sub_nonneg.mpr hΞ΅'), abs_of_nonneg hΞ΅] | |
| have haa : βiteratedFDeriv β r (Bounds.fixedPotential n) xβ β€ (A ((),r) : β) := by simpa using ha () r n x | |
| have hbb := hb (M,N) r n x | |
| have hscale := pow_nonneg (readScale_nonneg M N n) r | |
| calc | |
| _ β€ Scales.Ξ΅ M.base N n * (A ((),r) : β) + | |
| Scales.Ξ΅ M.base N (n + 1) * ((B ((M,N),r) : β) * readScale M N n ^ r) := by | |
| exact add_le_add | |
| (mul_le_mul (by linarith) haa (norm_nonneg _) (by linarith)) | |
| (mul_le_mul_of_nonneg_left hbb hΞ΅) | |
| _ β€ _ := by nlinarith [mul_nonneg (show 0 β€ Scales.Ξ΅ M.base N n by linarith) hB, | |
| mul_nonneg hA (mul_nonneg hΞ΅ hscale)] | |
| lemma slot_estimate : β C : (Machine Γ β) Γ β β β, Computable C β§ β M N r n x, | |
| βiteratedFDeriv β r (Construction.slot M N n) xβ β€ | |
| (C ((M,N),r) : β) * (Scales.Ξ΅ M.base N n + Scales.Ξ΅ M.base N (n + 1) * readScale M N n ^ (r + 1)) := by | |
| obtain β¨C, hC, hcβ© := potential_bound | |
| refine β¨fun z => 2 * C (z.1,z.2+1), | |
| Primrec.nat_mul.to_comp.comp (Computable.const 2) | |
| (hC.comp (Computable.fst.pair (Computable.succ.comp Computable.snd))), fun M N r n x => ?_β© | |
| have h := norm_iterated_curl (Construction.receiverIndex n) 0 _ | |
| (Spatial.cutoff_smooth.mul (Spatial.shearPotential_smooth (Construction.donorIndex n) | |
| (Construction.receiverIndex n) 0 _ _ | |
| (LocalRule.write_smooth M N n) (LocalRule.signal_smooth M N n))) r x | |
| apply h.trans | |
| push_cast | |
| nlinarith [hc M N (r+1) n x] | |
| def readCost (z : (Machine Γ β) Γ β) : β := | |
| 1 + β n β Finset.range z.2, z.1.1.base ^ | |
| (Scales.s z.1.2 n + (z.2+1) * (Scales.s z.1.2 n + 1 + Scales.K z.1.2 n)) | |
| lemma readCost_computable : Computable readCost := by | |
| have hM : Computable (fun z : ((Machine Γ β) Γ β) Γ β => z.1.1.1) := | |
| Computable.fst.comp (Computable.fst.comp Computable.fst) | |
| have hN : Computable (fun z : ((Machine Γ β) Γ β) Γ β => z.1.1.2) := | |
| Computable.snd.comp (Computable.fst.comp Computable.fst) | |
| have hs : Computable (fun z : ((Machine Γ β) Γ β) Γ β => Scales.s z.1.1.2 z.2) := exponent.to_comp.comp hN Computable.snd | |
| have hK : Computable (fun z : ((Machine Γ β) Γ β) Γ β => Scales.K z.1.1.2 z.2) := capacity.to_comp.comp hN Computable.snd | |
| have hp : Computableβ (fun z : (Machine Γ β) Γ β => fun n : β => z.1.1.base ^ (Scales.s z.1.2 n + (z.2+1) * (Scales.s z.1.2 n + 1 + Scales.K z.1.2 n))) := nat_pow.to_comp.comp (base.to_comp.comp hM) | |
| (Primrec.nat_add.to_comp.comp hs (Primrec.nat_mul.to_comp.comp | |
| (Computable.succ.comp (Computable.snd.comp Computable.fst)) | |
| (Primrec.nat_add.to_comp.comp (Computable.succ.comp hs) hK))) | |
| unfold readCost | |
| exact Primrec.nat_add.to_comp.comp (Computable.const 1) | |
| ((nat_sum_range hp).comp Computable.id Computable.snd) | |
| lemma uniform_read_cost (M : Machine) (N r n : β) : | |
| Scales.Ξ΅ M.base N (n + 1) * readScale M N n ^ (r + 1) β€ | |
| (readCost ((M,N),r) : β) * Scales.Ξ΅ M.base N n := by | |
| have hb : (1 : β) β€ M.base := by have := M.base_ge_four; exact_mod_cast (by omega : 1 β€ M.base) | |
| have hΞ΅ (n : β) : 0 < Scales.Ξ΅ M.base N n := | |
| Scales.Ξ΅_pos _ _ _ (by have := M.base_ge_four; omega) | |
| have hD : (1 : β) β€ readCost ((M,N),r) := by | |
| dsimp [readCost]; push_cast | |
| exact le_add_of_nonneg_right (Finset.sum_nonneg (by intros; positivity)) | |
| have he : readScale M N n ^ (r + 1) = | |
| (M.base : β) ^ ((r+1) * (Scales.s N n + 1 + Scales.K N n)) := by | |
| rw [readScale, β pow_mul, Nat.mul_comm] | |
| by_cases hn : n < r | |
| Β· have hle : M.base ^ (Scales.s N n + (r+1) * (Scales.s N n + 1 + Scales.K N n)) β€ readCost ((M,N),r) := | |
| (Finset.single_le_sum (f := fun n => M.base ^ (Scales.s N n + (r+1) * (Scales.s N n + 1 + Scales.K N n))) | |
| (fun _ _ => Nat.zero_le _) (Finset.mem_range.mpr hn)).trans (Nat.le_add_left _ _) | |
| have hpow : ((M.base : β) ^ Scales.s N n) β 0 := ne_of_gt (pow_pos (zero_lt_one.trans_le hb) _) | |
| calc | |
| _ β€ readScale M N n ^ (r+1) := by | |
| apply mul_le_of_le_one_left (pow_nonneg (readScale_nonneg M N n) _) | |
| simpa [Scales.Ξ΅, abs_of_nonneg (inv_nonneg.mpr (pow_nonneg (zero_le_one.trans hb) _))] using | |
| Bounds.inverse_power_bound M (Scales.s N (n+1)) | |
| _ = (M.base : β) ^ (Scales.s N n + (r+1) * (Scales.s N n + 1 + Scales.K N n)) * Scales.Ξ΅ M.base N n := by | |
| rw [he, pow_add, Scales.Ξ΅]; field_simp | |
| _ β€ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hle) (hΞ΅ n).le | |
| Β· rw [he] | |
| exact (Scales.derivative_cost_bound M.base N r n (by have := M.base_ge_four; omega) | |
| (by omega)).trans (le_mul_of_one_le_left (hΞ΅ n).le hD) | |
| lemma slot_decay : β C : (Machine Γ β) Γ β β β, Computable C β§ β M N r n x, | |
| βiteratedFDeriv β r (Construction.slot M N n) xβ β€ (C ((M,N),r) : β) * Scales.Ξ΅ M.base N n := by | |
| obtain β¨C,hC,hcβ© := slot_estimate | |
| refine β¨fun z => C z * (1 + readCost z), Primrec.nat_mul.to_comp.comp hC | |
| (Primrec.nat_add.to_comp.comp (Computable.const 1) readCost_computable), fun M N r n x => ?_β© | |
| apply (hc M N r n x).trans | |
| push_cast | |
| have h := mul_le_mul_of_nonneg_left (uniform_read_cost M N r n) (Nat.cast_nonneg (C ((M,N),r)) : (0 : β) β€ _) | |
| nlinarith | |
| lemma loading_bound : β C : (Machine Γ List β) Γ β β β, Computable C β§ β M w r x, | |
| βiteratedFDeriv β r (Construction.loading M w) xβ β€ C ((M,w),r) := by | |
| obtain β¨hs,C,hC,hcβ© := loadingPotential_scaled | |
| refine β¨fun z => 2 * C (z.1,z.2+1), Primrec.nat_mul.to_comp.comp (Computable.const 2) | |
| (hC.comp (Computable.fst.pair (Computable.succ.comp Computable.snd))), fun M w r x => ?_β© | |
| apply (norm_iterated_curl 1 0 _ (hs (M,w) 0) r x).trans | |
| have h := hc (M,w) (r+1) 0 x | |
| simp only [one_pow, mul_one] at h | |
| push_cast | |
| linarith | |
| lemma piece_decay : β C : (Machine Γ List β) Γ β β β, Computable C β§ β M w r n x, | |
| βiteratedFDeriv β r (Construction.piece M w n) xβ β€ (C ((M,w),r) : β) * amplitude M w.length n := by | |
| obtain β¨A,hA,haβ© := loading_bound | |
| obtain β¨B,hB,hbβ© := slot_decay | |
| refine β¨fun z => A z + B ((z.1.1,z.1.2.length),z.2), Primrec.nat_add.to_comp.comp hA | |
| (hB.comp (((Computable.fst.comp Computable.fst).pair | |
| (Primrec.list_length.to_comp.comp (Computable.snd.comp Computable.fst))).pair Computable.snd)), fun M w r n x => ?_β© | |
| cases n with | |
| | zero => | |
| simp only [Construction.piece, amplitude, mul_one, Nat.cast_add] | |
| exact (ha M w r x).trans (le_add_of_nonneg_right (Nat.cast_nonneg _)) | |
| | succ n => | |
| simp only [Construction.piece, amplitude, Nat.cast_add] | |
| exact (hb M w.length r n x).trans (mul_le_mul_of_nonneg_right | |
| (le_add_of_nonneg_left (Nat.cast_nonneg _)) (Scales.Ξ΅_nonneg _ _ _ (by have := M.base_ge_four; omega))) | |
| lemma pulse_scaled : Scaled (fun _ : Unit => fun _ => 1) (fun _ _ => Profiles.pulse) := by | |
| have hclock := transition_scaled.affine (fun _ _ => zero_le_one) (fun _ _ => 2) | |
| (fun _ _ => -1/2) (fun _ => 2) (Computable.const 2) (by intros; norm_num) | |
| have he : (fun t => Real.smoothTransition (2 * t + -1/2)) = Profiles.clock := by | |
| funext t; unfold Profiles.clock; congr 1; ring | |
| obtain β¨hs,C,hC,hcβ© := hclock | |
| refine β¨fun _ _ => Profiles.pulse_smooth, fun z => C ((),z.2+1), | |
| hC.comp ((Computable.const ()).pair (Computable.succ.comp Computable.snd)), fun a r n x => ?_β© | |
| rw [he] at hc | |
| change βiteratedFDeriv β r (deriv Profiles.clock) xβ β€ _ | |
| simpa [one_pow, norm_iteratedFDeriv_eq_norm_iteratedDeriv, iteratedDeriv_succ'] using hc () (r+1) 0 x | |
| lemma pulsePiece_decay : β C : (Machine Γ List β) Γ β β β, Computable C β§ β M w r n z, | |
| βiteratedFDeriv β r (Bounds.pulsePiece M w n) zβ β€ (C ((M,w),r) : β) * amplitude M w.length n := by | |
| obtain β¨_,A,hA,haβ© := pulse_scaled | |
| obtain β¨B,hB,hbβ© := piece_decay | |
| let C := fun z : (Machine Γ List β) Γ β => β i β Finset.range (z.2+1), z.2.choose i * A ((),i) * B (z.1,z.2-i) | |
| have hi : Computableβ (fun z : (Machine Γ List β) Γ β => fun i : β => z.2.choose i * A ((),i) * B (z.1,z.2-i)) := | |
| Primrec.nat_mul.to_comp.comp (Primrec.nat_mul.to_comp.comp | |
| (choose.to_comp.comp (Computable.snd.comp Computable.fst) Computable.snd) | |
| (hA.comp ((Computable.const ()).pair Computable.snd))) | |
| (hB.comp ((Computable.fst.comp Computable.fst).pair | |
| (Primrec.nat_sub.to_comp.comp (Computable.snd.comp Computable.fst) Computable.snd))) | |
| refine β¨C, (nat_sum_range hi).comp Computable.id (Computable.succ.comp Computable.snd), fun M w r n z => ?_β© | |
| have hp (i : β) : | |
| βiteratedFDeriv β i (fun z : β Γ Space => Profiles.pulse (z.1 - n)) zβ β€ (A ((),i) : β) := by | |
| apply (norm_comp_linear (fun t => Profiles.pulse (t - n)) | |
| (Profiles.pulse_smooth.comp (contDiff_id.sub contDiff_const)) (ContinuousLinearMap.fst β β Space) | |
| i z).trans | |
| rw [iteratedFDeriv_comp_sub] | |
| have hβ : βiteratedFDeriv β i Profiles.pulse (z.1 - n)β β€ (A ((),i) : β) := by simpa using ha () i 0 (z.1 - n) | |
| have hβ := pow_le_pow_leftβ (norm_nonneg _) (ContinuousLinearMap.norm_fst_le β β Space) i | |
| simpa only [one_pow, mul_one, ContinuousLinearMap.coe_fst', ContinuousLinearMap.coe_snd'] using mul_le_mul hβ hβ (pow_nonneg (norm_nonneg _) _) (Nat.cast_nonneg (A ((),i))) | |
| have hw (i : β) : | |
| βiteratedFDeriv β i (fun z : β Γ Space => Construction.piece M w n z.2) zβ β€ | |
| (B ((M,w),i) : β) * amplitude M w.length n := by | |
| apply (norm_comp_linear (Construction.piece M w n) (Construction.piece_smooth M w n) | |
| (ContinuousLinearMap.snd β β Space) i z).trans | |
| have hβ := hb M w i n z.2 | |
| have hβ := pow_le_pow_leftβ (norm_nonneg _) (ContinuousLinearMap.norm_snd_le β β Space) i | |
| simpa only [one_pow, mul_one, ContinuousLinearMap.coe_fst', ContinuousLinearMap.coe_snd'] using mul_le_mul hβ hβ (pow_nonneg (norm_nonneg _) _) | |
| (mul_nonneg (Nat.cast_nonneg (B ((M,w),i))) (Bounds.amplitude_nonneg M w.length n)) | |
| apply (norm_iteratedFDeriv_smul_le | |
| (Profiles.pulse_smooth.comp (contDiff_fst.sub contDiff_const)) | |
| ((Construction.piece_smooth M w n).comp contDiff_snd) z (WithTop.coe_le_coe.mpr le_top)).trans | |
| calc | |
| _ β€ β i β Finset.range (r + 1), (r.choose i : β) * (A ((),i) : β) * ((B ((M,w),r-i) : β) * amplitude M w.length n) := by | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| apply mul_le_mul _ (hw (r - i)) (norm_nonneg _) (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg (A ((),i)))) | |
| exact mul_le_mul_of_nonneg_left (hp i) (Nat.cast_nonneg _) | |
| _ = (C ((M,w),r) : β) * amplitude M w.length n := by | |
| simp only [C, Nat.cast_sum, Nat.cast_mul, Finset.sum_mul, mul_assoc] | |
| lemma epsilon_small (M : Machine) (N n : β) : Scales.Ξ΅ M.base N n β€ (1/8:β)^n := by | |
| have hb : (2 : β) β€ M.base := by exact_mod_cast (le_trans (by decide : 2 β€ 4) M.base_ge_four) | |
| have hs : 3*n β€ Scales.s N n := by have := Scales.s_lower N n; nlinarith | |
| unfold Scales.Ξ΅ | |
| have hp : (8:β)^n β€ (M.base:β)^Scales.s N n := by | |
| calc | |
| _ = (2:β)^(3*n) := by rw [pow_mul]; norm_num | |
| _ β€ (2:β)^Scales.s N n := pow_le_pow_rightβ (by norm_num) hs | |
| _ β€ _ := pow_le_pow_leftβ (by norm_num) hb _ | |
| simpa only [one_div, inv_pow] using inv_antiβ (by positivity : (0:β) < 8^n) hp | |
| lemma weighted_epsilon (M : Machine) (N J n : β) : | |
| (1+(n:β))^J * Scales.Ξ΅ M.base N n β€ 4 * J.factorial * (1/2:β)^n := by | |
| have hpoly : (1+(n:β))^J β€ (J.factorial:β) * (4 * 4^n) := by | |
| have h := (div_le_iffβ (by positivity : (0:β) < J.factorial)).mp | |
| (Real.pow_div_factorial_le_exp (1+(n:β)) (by positivity) J) | |
| have he : Real.exp (1+(n:β)) β€ 4 * 4^n := by | |
| rw [Real.exp_add, show (n:β) = n*1 by ring, Real.exp_nat_mul] | |
| exact mul_le_mul (Real.exp_one_lt_three.le.trans (by norm_num)) | |
| (pow_le_pow_leftβ (Real.exp_pos _).le (Real.exp_one_lt_three.le.trans (by norm_num)) n) | |
| (by positivity) (by norm_num) | |
| exact h.trans (by nlinarith [mul_le_mul_of_nonneg_right he (Nat.cast_nonneg J.factorial : (0:β) β€ _)]) | |
| calc | |
| _ β€ ((J.factorial:β) * (4 * 4^n)) * (1/8:β)^n := | |
| mul_le_mul hpoly (epsilon_small M N n) (Scales.Ξ΅_nonneg _ _ _ (by have := M.base_ge_four; omega)) (by positivity) | |
| _ = _ := by rw [mul_assoc _ (4*4^n), mul_assoc 4, β mul_pow]; norm_num; ring | |
| lemma weighted_amplitude_sum (M : Machine) (N J : β) : | |
| (β' n : β, (1+(n:β))^J * amplitude M N n) β€ (1 + 8 * 2^J * J.factorial : β) := by | |
| have hs := Bounds.weighted_amplitude_summable M N J | |
| rw [hs.tsum_eq_zero_add] | |
| simp only [amplitude, Nat.cast_zero, add_zero, one_pow, mul_one] | |
| have hc : β n : β, (1+(n+1:β))^J * amplitude M N (n+1) β€ | |
| (2:β)^J * (4 * J.factorial * (1/2:β)^n) := by | |
| intro n | |
| simp only [amplitude, Nat.cast_add, Nat.cast_one] | |
| calc | |
| _ β€ (2*(1+(n:β)))^J * Scales.Ξ΅ M.base N n := mul_le_mul_of_nonneg_right | |
| (pow_le_pow_leftβ (by positivity) (by nlinarith) J) | |
| (Scales.Ξ΅_nonneg _ _ _ (by have := M.base_ge_four; omega)) | |
| _ β€ _ := by rw [mul_pow, mul_assoc]; exact mul_le_mul_of_nonneg_left (weighted_epsilon M N J n) (by positivity) | |
| have h := (hs.comp_injective Nat.succ_injective).tsum_le_tsum hc | |
| ((summable_geometric_two.mul_left (4*(J.factorial:β))).mul_left ((2:β)^J)) | |
| simp only [tsum_mul_left, tsum_geometric_two, amplitude, Nat.cast_add, Nat.cast_one] at h | |
| push_cast | |
| nlinarith | |
| end AlternatingNS.Effective | |
| end DecayBoundsDevelopment | |
| end OAI | |