Download data/lean/OAI/MathematicalPhysics/AlternatingFlow/Quantitative.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 11 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/AlternatingFlow/Quantitative.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/AlternatingFlow/Quantitative.lean
-
curl -L -o Quantitative.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/AlternatingFlow/Quantitative.lean
11 kB
| import OAI.MathematicalPhysics.AlternatingFlow.Model | |
| namespace OAI | |
| section QuantitativeDevelopment | |
| open scoped BigOperators ContDiff | |
| namespace AlternatingNS | |
| namespace Quantitative | |
| noncomputable def rhoTerm (m : β) (x : β) : β := xβ»ΒΉ ^ m * expNegInvGlue x | |
| lemma rhoTerm_smooth (m : β) : ContDiff β β (rhoTerm m) := by | |
| change ContDiff β β (fun x => xβ»ΒΉ ^ m * expNegInvGlue x) | |
| simpa only [Polynomial.eval_X_pow] using | |
| (expNegInvGlue.contDiff_polynomial_eval_inv_mul (n := β€) (Polynomial.X ^ m : Polynomial β)) | |
| lemma rhoTerm_deriv (m : β) : | |
| deriv (rhoTerm m) = fun x => rhoTerm (m + 2) x - m * rhoTerm (m + 1) x := by | |
| funext x | |
| have h := (expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul | |
| (Polynomial.X ^ m : Polynomial β) x).deriv | |
| simp only [Polynomial.eval_X_pow] at h | |
| change deriv (rhoTerm m) x = _ at h | |
| rw [h] | |
| simp only [Polynomial.derivative_X_pow, Polynomial.eval_mul, Polynomial.eval_sub, | |
| Polynomial.eval_C, Polynomial.eval_X_pow, rhoTerm] | |
| cases m with | |
| | zero => norm_num | |
| | succ m => simp only [Nat.succ_sub_one, Nat.cast_add, Nat.cast_one, pow_succ]; ring | |
| lemma exp_monomial_bound (y : β) (hy : 0 β€ y) (m : β) : | |
| y ^ m * Real.exp (-y) β€ m.factorial := by | |
| have h := Real.pow_div_factorial_le_exp y hy m | |
| have hp : (0 : β) < m.factorial := by exact_mod_cast Nat.factorial_pos m | |
| have h' := (div_le_iffβ hp).mp h | |
| calc | |
| _ β€ (Real.exp y * m.factorial) * Real.exp (-y) := | |
| mul_le_mul_of_nonneg_right h' (Real.exp_pos _).le | |
| _ = _ := by rw [mul_right_comm, β Real.exp_add]; simp | |
| lemma rhoTerm_bound (m : β) (x : β) : |rhoTerm m x| β€ m.factorial := by | |
| by_cases hx : x β€ 0 | |
| Β· simp [rhoTerm, expNegInvGlue.zero_of_nonpos hx] | |
| Β· have hx' : 0 < x := lt_of_not_ge hx | |
| rw [rhoTerm, expNegInvGlue, ite_eq_right hx, | |
| abs_of_nonneg (mul_nonneg (pow_nonneg (inv_pos.mpr hx').le _) (Real.exp_pos _).le)] | |
| exact exp_monomial_bound xβ»ΒΉ (inv_pos.mpr hx').le m | |
| lemma rhoTerm_derivative_bound (r m : β) (x : β) : | |
| |iteratedDeriv r (rhoTerm m) x| β€ | |
| ((m + 2 * r).factorial : β) * (m + 2 * r + 1 : β) ^ r := by | |
| induction r generalizing m with | |
| | zero => simpa using rhoTerm_bound m x | |
| | succ r ih => | |
| rw [iteratedDeriv_succ', rhoTerm_deriv] | |
| have hs (j : β) : ContDiffAt β (r : ββΟ) (rhoTerm j) x := | |
| ((rhoTerm_smooth j).of_le (WithTop.coe_le_coe.mpr le_top)).contDiffAt | |
| change |iteratedDeriv r (rhoTerm (m + 2) - fun x => (m : β) * rhoTerm (m + 1) x) x| β€ _ | |
| rw [iteratedDeriv_sub (hs _) (contDiffAt_const.mul (hs _)), iteratedDeriv_const_mul _ (hs _)] | |
| have ht : m + 2 + 2 * r = m + 2 * (r + 1) := by omega | |
| have hf : ((m + 1 + 2 * r).factorial : β) β€ (m + 2 * (r + 1)).factorial := by | |
| exact_mod_cast Nat.factorial_le (by omega : m + 1 + 2 * r β€ m + 2 * (r + 1)) | |
| have hp : ((m + 1 + 2 * r + 1 : β) : β) ^ r β€ (m + 2 * (r + 1) + 1 : β) ^ r := by | |
| apply pow_le_pow_leftβ (by positivity) | |
| exact_mod_cast (by omega : m + 1 + 2 * r + 1 β€ m + 2 * (r + 1) + 1) | |
| have hsmall := (ih (m + 1)).trans (mul_le_mul hf hp (by positivity) (by positivity)) | |
| have hbig := ih (m + 2) | |
| rw [ht] at hbig | |
| calc | |
| _ β€ |iteratedDeriv r (rhoTerm (m + 2)) x| + (m : β) * |iteratedDeriv r (rhoTerm (m + 1)) x| := by | |
| simpa only [Real.norm_eq_abs, abs_mul, Nat.abs_cast] using | |
| norm_sub_le (iteratedDeriv r (rhoTerm (m + 2)) x) ((m : β) * iteratedDeriv r (rhoTerm (m + 1)) x) | |
| _ β€ ((m + 2 * (r + 1)).factorial : β) * (m + 2 * (r + 1) + 1 : β) ^ r + | |
| m * (((m + 2 * (r + 1)).factorial : β) * (m + 2 * (r + 1) + 1 : β) ^ r) := | |
| add_le_add hbig (mul_le_mul_of_nonneg_left hsmall (Nat.cast_nonneg _)) | |
| _ β€ _ := by | |
| rw [pow_succ] | |
| have hm : (m : β) + 1 β€ (m + 2 * (r + 1) + 1 : β) := by | |
| push_cast; nlinarith | |
| nlinarith [mul_nonneg (show (0 : β) β€ (m + 2 * (r + 1)).factorial by positivity) | |
| (show (0 : β) β€ (m + 2 * (r + 1) + 1 : β) ^ r by positivity)] | |
| lemma rho_derivative_bound (r : β) (x : β) : | |
| |iteratedDeriv r expNegInvGlue x| β€ ((2 * r).factorial : β) * (2 * r + 1 : β) ^ r := by | |
| have he : rhoTerm 0 = expNegInvGlue := by funext x; simp [rhoTerm] | |
| simpa only [he, zero_add] using rhoTerm_derivative_bound r 0 x | |
| def rhoBound (r : β) : β := (2 * r).factorial * (2 * r + 1) ^ r | |
| lemma rho_jet_bound (r : β) (x : β) : | |
| βiteratedFDeriv β r expNegInvGlue xβ β€ rhoBound r := by | |
| simpa only [norm_iteratedFDeriv_eq_norm_iteratedDeriv, Real.norm_eq_abs, | |
| rhoBound, Nat.cast_mul, Nat.cast_pow] using rho_derivative_bound r x | |
| lemma transition_denom_lower (x : β) : | |
| (1 / 9 : β) β€ expNegInvGlue x + expNegInvGlue (1 - x) := by | |
| have he : (1 / 9 : β) β€ Real.exp (-2) := by | |
| rw [Real.exp_neg] | |
| apply (le_inv_commβ (by norm_num) (Real.exp_pos _)).mpr | |
| have h : Real.exp (2 : β) = Real.exp 1 ^ 2 := by | |
| simp | |
| rw [h] | |
| nlinarith [Real.exp_one_lt_three, Real.exp_pos 1] | |
| have hhalf : (1 / 9 : β) β€ expNegInvGlue (1 / 2) := by | |
| norm_num [expNegInvGlue] at * | |
| exact he | |
| by_cases hx : (1 / 2 : β) β€ x | |
| Β· exact le_trans (hhalf.trans (expNegInvGlue.monotone hx)) | |
| (le_add_of_nonneg_right (expNegInvGlue.nonneg _)) | |
| Β· exact le_trans (hhalf.trans (expNegInvGlue.monotone (by linarith : 1 / 2 β€ 1 - x))) | |
| (le_add_of_nonneg_left (expNegInvGlue.nonneg _)) | |
| lemma inverse_jet_bound (q r : β) {x : β} (hx : 0 < x) (hq : xβ»ΒΉ β€ q) : | |
| βiteratedFDeriv β r (fun x : β => xβ»ΒΉ) xβ β€ (r.factorial * q ^ (r + 1) : β) := by | |
| rw [norm_iteratedFDeriv_eq_norm_iteratedDeriv, iteratedDeriv_eq_iterate, iter_deriv_inv] | |
| have hexp : (-1 - (r : β€)) = -((r + 1 : β) : β€) := by omega | |
| rw [hexp, zpow_neg, zpow_natCast, β inv_pow, norm_mul, norm_mul, norm_pow] | |
| simp only [norm_neg, norm_one, one_pow, one_mul, Real.norm_eq_abs, | |
| Nat.abs_cast, Nat.cast_mul, Nat.cast_pow, | |
| abs_of_nonneg (pow_nonneg (inv_pos.mpr hx).le _)] | |
| gcongr | |
| def reciprocalBound (q : β) (B : β β β) (r : β) : β := | |
| r.factorial * (r.factorial * q ^ (r + 1)) * | |
| (1 + β i β Finset.range (r + 1), B i) ^ r | |
| lemma reciprocal_jet_bound {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] | |
| (f : E β β) (hf : ContDiff β β f) (B : β β β) | |
| (hB : β r x, βiteratedFDeriv β r f xβ β€ B r) | |
| (q : β) (hq : 1 β€ q) (hpos : β x, 0 < f x) (hrecip : β x, (f x)β»ΒΉ β€ q) | |
| (r : β) (x : E) : | |
| βiteratedFDeriv β r (fun x => (f x)β»ΒΉ) xβ β€ reciprocalBound q B r := by | |
| classical | |
| let D : β := 1 + β i β Finset.range (r + 1), (B i : β) | |
| let C : β := r.factorial * (q : β) ^ (r + 1) | |
| have hD : 1 β€ D := le_add_of_nonneg_right (Finset.sum_nonneg (fun i _ => Nat.cast_nonneg _)) | |
| have hd (i : β) (hi : i β€ r) : (B i : β) β€ D := by | |
| have h := Finset.single_le_sum (s := Finset.range (r + 1)) | |
| (f := fun i => (B i : β)) (fun i _ => Nat.cast_nonneg _) (Finset.mem_range.mpr (by omega : i < r + 1)) | |
| dsimp [D]; linarith | |
| have hu : UniqueDiffOn β (Set.Ioi (0 : β)) := isOpen_Ioi.uniqueDiffOn | |
| have hinv : ContDiffOn β β (fun y : β => yβ»ΒΉ) (Set.Ioi 0) := | |
| (contDiffOn_inv β).mono (by intro y hy; simpa using ne_of_gt hy) | |
| have h := norm_iteratedFDeriv_comp_le' (g := fun y : β => yβ»ΒΉ) (f := f) | |
| (t := Set.Ioi 0) (fun y hy => by rcases hy with β¨z, rflβ©; exact hpos z) | |
| hu hinv hf (WithTop.coe_le_coe.mpr le_top : (r : ββΟ) β€ β) x (C := C) (D := D) ?_ ?_ | |
| Β· simpa only [reciprocalBound, C, D, Nat.cast_mul, Nat.cast_pow, Nat.cast_add, | |
| Nat.cast_one, Nat.cast_sum, Function.comp_def] using h | |
| Β· intro i hi | |
| rw [iteratedFDerivWithin_eq_iteratedFDeriv hu (contDiffAt_inv β (hpos x).ne') (hpos x)] | |
| apply (inverse_jet_bound q i (hpos x) (hrecip x)).trans | |
| dsimp [C] | |
| push_cast | |
| apply mul_le_mul | |
| Β· exact_mod_cast Nat.factorial_le hi | |
| Β· exact pow_le_pow_rightβ (by exact_mod_cast hq) (by omega) | |
| Β· positivity | |
| Β· positivity | |
| Β· intro i hi hir | |
| exact (hB i x).trans ((hd i hir).trans (le_self_powβ hD (by omega))) | |
| noncomputable def transitionDenom (x : β) : β := expNegInvGlue x + expNegInvGlue (1 - x) | |
| lemma transitionDenom_smooth : ContDiff β β transitionDenom := | |
| expNegInvGlue.contDiff.add (expNegInvGlue.contDiff.comp (contDiff_const.sub contDiff_id)) | |
| lemma transitionDenom_bound (r : β) (x : β) : | |
| βiteratedFDeriv β r transitionDenom xβ β€ (2 * rhoBound r : β) := by | |
| have hs : ContDiff β β (fun x => expNegInvGlue (1 - x)) := | |
| expNegInvGlue.contDiff.comp (contDiff_const.sub contDiff_id) | |
| unfold transitionDenom | |
| rw [fun_iteratedFDeriv_add_apply (expNegInvGlue.contDiff (n := β€) |>.of_le | |
| (WithTop.coe_le_coe.mpr le_top : (r : ββΟ) β€ β) |>.contDiffAt) | |
| (hs.of_le (WithTop.coe_le_coe.mpr le_top) |>.contDiffAt)] | |
| apply (norm_add_le _ _).trans | |
| have hβ : βiteratedFDeriv β r (fun x => expNegInvGlue (1 - x)) xβ β€ rhoBound r := by | |
| rw [norm_iteratedFDeriv_eq_norm_iteratedDeriv, iteratedDeriv_comp_const_sub] | |
| simp only [norm_smul, norm_pow, norm_neg, norm_one, one_pow, one_mul] | |
| simpa only [norm_iteratedFDeriv_eq_norm_iteratedDeriv] using rho_jet_bound r (1 - x) | |
| have hβ := rho_jet_bound r x | |
| push_cast | |
| linarith | |
| def transitionInvBound (r : β) : β := reciprocalBound 9 (fun i => 2 * rhoBound i) r | |
| lemma transitionInv_bound (r : β) (x : β) : | |
| βiteratedFDeriv β r (fun x => (transitionDenom x)β»ΒΉ) xβ β€ transitionInvBound r := by | |
| apply reciprocal_jet_bound transitionDenom transitionDenom_smooth | |
| (fun i => 2 * rhoBound i) transitionDenom_bound 9 (by norm_num) | |
| (fun x => Real.smoothTransition.pos_denom x) _ r x | |
| intro x | |
| exact (inv_le_commβ (Real.smoothTransition.pos_denom x) (by norm_num : (0 : β) < 9)).mpr | |
| (by simpa only [one_div] using transition_denom_lower x) | |
| def transitionBound (r : β) : β := | |
| β i β Finset.range (r + 1), r.choose i * rhoBound i * transitionInvBound (r - i) | |
| lemma transition_jet_bound (r : β) (x : β) : | |
| βiteratedFDeriv β r Real.smoothTransition xβ β€ transitionBound r := by | |
| have he : Real.smoothTransition = fun x => expNegInvGlue x * (transitionDenom x)β»ΒΉ := by | |
| funext x; simp only [Real.smoothTransition, transitionDenom, div_eq_mul_inv] | |
| rw [he] | |
| apply (norm_iteratedFDeriv_mul_le (expNegInvGlue.contDiff (n := β€)) | |
| (transitionDenom_smooth.inv (fun x => (Real.smoothTransition.pos_denom x).ne')) x | |
| (WithTop.coe_le_coe.mpr le_top : (r : ββΟ) β€ β)).trans | |
| simp only [transitionBound, Nat.cast_sum, Nat.cast_mul] | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| apply mul_le_mul _ (transitionInv_bound (r - i) x) (norm_nonneg _) (by positivity) | |
| exact mul_le_mul_of_nonneg_left (rho_jet_bound i x) (Nat.cast_nonneg _) | |
| end Quantitative | |
| end AlternatingNS | |
| end QuantitativeDevelopment | |
| end OAI | |