Offline · exact source
Exact Lean source

CloningValueExpansionAlgebra

formalization/Cloning/CloningValueExpansionAlgebra.lean

Source hash: af6f16de349bbb8d3745b0f91df6dd8fd7c21f5eafac500178ee61dabf77a4c8

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
1import Cloning.ScalarTaylorRemainder
2import Mathlib.Analysis.Asymptotics.Lemmas
3import Mathlib.Analysis.Calculus.Deriv.Basic
4 
5/-! Cubic remainders for squared losses and finite products. -/
6noncomputable section
7open scoped Topology BigOperators
8open Filter Asymptotics
9namespace Cloning.ValueExpansion
10set_option backward.isDefEq.respectTransparency false
11 
12/-- Squaring a twice differentiable simple zero keeps a cubic remainder. -/
13theorem square_zero_remainder {f : ℝ→ℝ} {a : ℝ}
14    (hf : ContDiffAt ℝ 2 f 0) (hzero : f 0=0) (hd : HasDerivAt f a 0) :
15    (fun x=>f x^2-a^2*x^2) =O[𝓝 (0:ℝ)] (fun x=>x^3) := by
16  have hr : (fun x=>f x-a*x) =O[𝓝 (0:ℝ)] (fun x=>x^2) := by
17    have h := ScalarTaylor.local_taylor_isBigO 1 hf
18    convert h using 1
19    · ext x
20      simp only [taylorWithinEval_succ,taylor_within_zero_eval,
21        iteratedDerivWithin_univ,iteratedDeriv_one,smul_eq_mul,hzero,sub_zero]
22      norm_num
23      rw [hd.deriv]
24      ring
25    · simp
26  have hf1 : f =O[𝓝 (0:ℝ)] (fun x=>x) := by
27    simpa only [hzero,sub_zero] using hd.isBigO_sub
28  have hs := hr.mul (hf1.add (isBigO_const_mul_self a (fun x : ℝ=>x) (𝓝 0)))
29  convert hs using 1 <;> ext x <;> ring
30 
31def HasQuadraticExpansion (f : ℝ→ℝ) (a : ℝ) : Prop :=
32  (fun x=>f x-(1-a*x^2)) =O[𝓝 (0:ℝ)] (fun x=>x^3)
33 
34theorem HasQuadraticExpansion.one : HasQuadraticExpansion (fun _=>1) 0 := by
35  simpa only [HasQuadraticExpansion,zero_mul,sub_zero,sub_self] using
36    (isBigO_zero (fun x : ℝ=>x^3) (𝓝 (0:ℝ)))
37 
38theorem HasQuadraticExpansion.tendsto {f : ℝ→ℝ} {a : ℝ}
39    (hf : HasQuadraticExpansion f a) : Tendsto f (𝓝 0) (𝓝 1) := by
40  have hr : Tendsto (fun x=>f x-(1-a*x^2)) (𝓝 (0:ℝ)) (𝓝 0) :=
41    hf.trans_tendsto (by simpa using (tendsto_id.pow 3 : Tendsto (fun x : ℝ=>x^3) (𝓝 0) (𝓝 (0^3))))
42  have hp : Tendsto (fun x : ℝ=>1-a*x^2) (𝓝 0) (𝓝 1) := by
43    simpa using (tendsto_const_nhds : Tendsto (fun _ : ℝ=>(1:ℝ)) (𝓝 0) (𝓝 1)).sub
44      (((tendsto_id : Tendsto (fun x : ℝ=>x) (𝓝 0) (𝓝 0)).pow 2).const_mul a)
45  convert hr.add hp using 1 <;> simp
46 
47theorem HasQuadraticExpansion.mul {f g : ℝ→ℝ} {a b : ℝ}
48    (hf : HasQuadraticExpansion f a) (hg : HasQuadraticExpansion g b) :
49    HasQuadraticExpansion (fun x=>f x*g x) (a+b) := by
50  have hp : Tendsto (fun x : ℝ=>1-a*x^2) (𝓝 0) (𝓝 1) := by
51    simpa using (tendsto_const_nhds : Tendsto (fun _ : ℝ=>(1:ℝ)) (𝓝 0) (𝓝 1)).sub
52      (((tendsto_id : Tendsto (fun x : ℝ=>x) (𝓝 0) (𝓝 0)).pow 2).const_mul a)
53  have h₁ := Asymptotics.IsBigO.mul hf (hg.tendsto.isBigO_one ℝ)
54  have h₂ := Asymptotics.IsBigO.mul (hp.isBigO_one ℝ) hg
55  simp only [mul_one,one_mul] at h₁ h₂
56  have h₃ := ((isLittleO_pow_pow (by decide : 3<4) (𝕜:=ℝ)).isBigO).const_mul_left (a*b)
57  have h := (h₁.add h₂).add h₃
58  dsimp only [HasQuadraticExpansion] at *
59  convert h using 1 <;> ext x <;> ring
60 
61theorem HasQuadraticExpansion.prod {ι : Type*} (s : Finset ι)
62    (f : ι→ℝ→ℝ) (a : ι→ℝ) (h : ∀i∈s,HasQuadraticExpansion (f i) (a i)) :
63    HasQuadraticExpansion (fun x=>∏i∈s,f i x) (∑i∈s,a i) := by
64  classical
65  induction s using Finset.induction_on with
66  | empty => simpa only [Finset.prod_empty,Finset.sum_empty] using HasQuadraticExpansion.one
67  | @insert i s his ih =>
68    simpa only [Finset.prod_insert his,Finset.sum_insert his] using
69      (h i (Finset.mem_insert_self _ _)).mul (ih (fun j hj=>h j (Finset.mem_insert_of_mem hj)))
70 
71end Cloning.ValueExpansion