Download data/lean/OAI/Analysis/Calculus/Current/Divergence.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/Calculus/Current/Divergence.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/Calculus/Current/Divergence.lean
-
curl -L -o Divergence.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/Calculus/Current/Divergence.lean
16.9 kB
| import OAI.Analysis.Calculus.Current.Holomorphic | |
| /-! Differential ingredients for the wave-current divergence calculation. | |
| The Gaussian pair is defined by its actual scalar expression. The calculus | |
| lemmas take ordinary derivative certificates for input curves; they do not | |
| assume the weighted conservation identity to be proved. | |
| -/ | |
| namespace OAI.Analysis.Calculus.Current | |
| noncomputable section | |
| def squaredDistance {d : β} (W : Fin d β β) (v : Fin d β β) : β := | |
| β i, βW i - (v i : β)β ^ 2 | |
| def gaussianLog {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (y : β) (W : Fin d β β) : β := | |
| -(d : β) * Real.log y - | |
| y / 2 * (ΞΊ * squaredDistance W v + ΞΊ' * squaredDistance W v') | |
| /-- The pair weight `N` of equation (current-gaussian-pair), on `y > 0`. -/ | |
| def gaussianPair {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (y : β) (W : Fin d β β) : β := Real.exp (gaussianLog ΞΊ ΞΊ' v v' y W) | |
| theorem gaussianPair_formula {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (y : β) (hy : 0 < y) (W : Fin d β β) : | |
| gaussianPair ΞΊ ΞΊ' v v' y W = (y ^ d)β»ΒΉ * | |
| Real.exp (-(y / 2 * (ΞΊ * squaredDistance W v + ΞΊ' * squaredDistance W v'))) := by | |
| unfold gaussianPair gaussianLog | |
| rw [sub_eq_add_neg, Real.exp_add] | |
| congr 1 | |
| rw [neg_mul, Real.exp_neg, Real.exp_nat_mul, Real.exp_log hy] | |
| theorem gaussianPair_pos {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (y : β) (W : Fin d β β) : 0 < gaussianPair ΞΊ ΞΊ' v v' y W := | |
| Real.exp_pos _ | |
| /-- Differentiate the exact Euclidean squared distance along an arbitrary real curve. -/ | |
| theorem hasDerivAt_squaredDistance {d : β} (W : β β Fin d β β) | |
| (W' : Fin d β β) (v : Fin d β β) (t : β) | |
| (hW : β i, HasDerivAt (fun s => W s i) (W' i) t) : | |
| HasDerivAt (fun s => squaredDistance (W s) v) | |
| (β i, 2 * inner β (W t i - (v i : β)) (W' i)) t := by | |
| exact HasDerivAt.fun_sum fun i _ => ((hW i).sub_const (v i : β)).norm_sq | |
| /-- Ordinary derivative of the exact logarithmic Gaussian pair. -/ | |
| theorem hasDerivAt_gaussianLog {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (y : β β β) (y' : β) (W : β β Fin d β β) (W' : Fin d β β) (t : β) | |
| (hy : HasDerivAt y y' t) (hy0 : y t β 0) | |
| (hW : β i, HasDerivAt (fun s => W s i) (W' i) t) : | |
| HasDerivAt (fun s => gaussianLog ΞΊ ΞΊ' v v' (y s) (W s)) | |
| (-(d : β) * (y' / y t) - | |
| ((y' / 2) * (ΞΊ * squaredDistance (W t) v + ΞΊ' * squaredDistance (W t) v') + | |
| y t / 2 * | |
| (ΞΊ * (β i, 2 * inner β (W t i - (v i : β)) (W' i)) + | |
| ΞΊ' * (β i, 2 * inner β (W t i - (v' i : β)) (W' i))))) t := by | |
| exact ((hy.log hy0).const_mul (-(d : β))).sub | |
| ((hy.div_const 2).mul | |
| (((hasDerivAt_squaredDistance W W' v t hW).const_mul ΞΊ).add | |
| ((hasDerivAt_squaredDistance W W' v' t hW).const_mul ΞΊ'))) | |
| /-- Ordinary derivative of the exact Gaussian pair. -/ | |
| theorem hasDerivAt_gaussianPair {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (y : β β β) (y' : β) (W : β β Fin d β β) (W' : Fin d β β) (t : β) | |
| (hy : HasDerivAt y y' t) (hy0 : y t β 0) | |
| (hW : β i, HasDerivAt (fun s => W s i) (W' i) t) : | |
| HasDerivAt (fun s => gaussianPair ΞΊ ΞΊ' v v' (y s) (W s)) | |
| (gaussianPair ΞΊ ΞΊ' v v' (y t) (W t) * | |
| (-(d : β) * (y' / y t) - | |
| ((y' / 2) * (ΞΊ * squaredDistance (W t) v + ΞΊ' * squaredDistance (W t) v') + | |
| y t / 2 * | |
| (ΞΊ * (β i, 2 * inner β (W t i - (v i : β)) (W' i)) + | |
| ΞΊ' * (β i, 2 * inner β (W t i - (v' i : β)) (W' i)))))) t := by | |
| exact (hasDerivAt_gaussianLog ΞΊ ΞΊ' v v' y y' W W' t hy hy0 hW).exp | |
| /-- A real line in the actual complex imaginary-coordinate space. -/ | |
| def imaginaryLine {d : β} (z h : Index d β β) (t : β) : Index d β β := | |
| fun a => z a + (t : β) * h a | |
| @[simp] theorem imaginaryLine_zero {d : β} (z h : Index d β β) : | |
| imaginaryLine z h 0 = z := by | |
| funext a | |
| simp [imaginaryLine] | |
| theorem hasDerivAt_imaginaryLine {d : β} (z h : Index d β β) (a : Index d) : | |
| HasDerivAt (fun t : β => imaginaryLine z h t a) (h a) 0 := by | |
| have hc : HasDerivAt (fun t : β => z a + t * h a) (h a) (0 : β) := by | |
| simpa using ((hasDerivAt_id (0 : β)).mul_const (h a)).const_add (z a) | |
| exact hc.comp_ofReal | |
| private theorem hasDerivAt_complex_norm {f : β β β} {f' : β} {t : β} | |
| (hf : HasDerivAt f f' t) (h0 : f t β 0) : | |
| HasDerivAt (fun s => βf sβ) (inner β (f t) f' / βf tβ) t := by | |
| have hh := hf.norm_sq.sqrt (pow_ne_zero 2 (norm_ne_zero_iff.mpr h0)) | |
| convert hh using 1 | |
| Β· funext s | |
| simp | |
| Β· simp | |
| ring | |
| def radiusSlope {d : β} (z h : Index d β β) : β := | |
| inner β (z none) (h none) / βz noneβ | |
| def ratioSlope {d : β} (z h : Index d β β) : Fin d β β := | |
| fun i => (h (some (some i)) * z none - z (some (some i)) * h none) / z none ^ 2 | |
| theorem hasDerivAt_radius_line {d : β} (z h : Index d β β) (hY : z none β 0) : | |
| HasDerivAt (fun t => βimaginaryLine z h t noneβ) (radiusSlope z h) 0 := by | |
| simpa [imaginaryLine, radiusSlope] using | |
| hasDerivAt_complex_norm (hasDerivAt_imaginaryLine z h none) | |
| (by simpa [imaginaryLine] using hY) | |
| theorem hasDerivAt_ratio_line {d : β} (z h : Index d β β) (hY : z none β 0) | |
| (i : Fin d) : | |
| HasDerivAt (fun t => ratio (imaginaryLine z h t) i) (ratioSlope z h i) 0 := by | |
| have hc (a : Index d) : HasDerivAt (fun t : β => z a + t * h a) (h a) (0 : β) := by | |
| simpa using ((hasDerivAt_id (0 : β)).mul_const (h a)).const_add (z a) | |
| have hh := ((hc (some (some i))).div (hc none) (by simpa using hY)).comp_ofReal | |
| simpa [ratio, imaginaryLine, ratioSlope] using hh | |
| /-- The actual scalar field `N` on the imaginary coordinates. -/ | |
| def gaussianField {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) (z : Index d β β) : β := | |
| gaussianPair ΞΊ ΞΊ' v v' βz noneβ (ratio z) | |
| /-- Explicit directional derivative of `log N` in the actual imaginary coordinates. -/ | |
| def gaussianLogSlope {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (z h : Index d β β) : β := | |
| -(d : β) * (radiusSlope z h / βz noneβ) - | |
| ((radiusSlope z h / 2) * | |
| (ΞΊ * squaredDistance (ratio z) v + ΞΊ' * squaredDistance (ratio z) v') + | |
| βz noneβ / 2 * | |
| (ΞΊ * (β i, 2 * inner β (ratio z i - (v i : β)) (ratioSlope z h i)) + | |
| ΞΊ' * (β i, 2 * inner β (ratio z i - (v' i : β)) (ratioSlope z h i)))) | |
| /-- Every real directional derivative of the exact Gaussian field is verified. -/ | |
| theorem hasDerivAt_gaussianField_line {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (z h : Index d β β) (hY : z none β 0) : | |
| HasDerivAt (fun t => gaussianField ΞΊ ΞΊ' v v' (imaginaryLine z h t)) | |
| (gaussianField ΞΊ ΞΊ' v v' z * gaussianLogSlope ΞΊ ΞΊ' v v' z h) 0 := by | |
| have hh := hasDerivAt_gaussianPair ΞΊ ΞΊ' v v' | |
| (fun t => βimaginaryLine z h t noneβ) (radiusSlope z h) | |
| (fun t => ratio (imaginaryLine z h t)) (ratioSlope z h) 0 | |
| (hasDerivAt_radius_line z h hY) | |
| (by simpa [imaginaryLine] using norm_ne_zero_iff.mpr hY) | |
| (hasDerivAt_ratio_line z h hY) | |
| simpa only [gaussianField, gaussianLogSlope, imaginaryLine_zero] using hh | |
| /-- The two real directional derivatives that form `β conj(Vβ) barDβ`. | |
| The equivalence with the coordinate sum is real linearity of the differential. -/ | |
| def barDirectional {d : β} (f : (Index d β β) β β) (z V : Index d β β) : β := | |
| ((deriv (fun t => f (imaginaryLine z V t)) 0 : β) : β) + | |
| Complex.I * ((deriv (fun t => f (imaginaryLine z (fun a => Complex.I * V a) t)) 0 : β) : β) | |
| theorem gaussianField_barDirectional {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (z V : Index d β β) (hY : z none β 0) : | |
| barDirectional (gaussianField ΞΊ ΞΊ' v v') z V = | |
| (gaussianField ΞΊ ΞΊ' v v' z : β) * | |
| ((gaussianLogSlope ΞΊ ΞΊ' v v' z V : β) + | |
| Complex.I * (gaussianLogSlope ΞΊ ΞΊ' v v' z (fun a => Complex.I * V a) : β)) := by | |
| unfold barDirectional | |
| rw [(hasDerivAt_gaussianField_line ΞΊ ΞΊ' v v' z V hY).deriv, | |
| (hasDerivAt_gaussianField_line ΞΊ ΞΊ' v v' z (fun a => Complex.I * V a) hY).deriv] | |
| push_cast | |
| ring | |
| theorem complex_inner_pair (a b : β) : | |
| (inner β a b : β) + Complex.I * (inner β a (Complex.I * b) : β) = a * star b := by | |
| apply Complex.ext <;> simp <;> ring | |
| def distanceSlope {d : β} (W h : Fin d β β) (v : Fin d β β) : β := | |
| β i, 2 * inner β (W i - (v i : β)) (h i) | |
| theorem distanceSlope_pair {d : β} (W h : Fin d β β) (v : Fin d β β) : | |
| (distanceSlope W h v : β) + | |
| Complex.I * (distanceSlope W (fun i => Complex.I * h i) v : β) = | |
| 2 * β i, (W i - (v i : β)) * star (h i) := by | |
| simp only [distanceSlope, Complex.ofReal_sum, Complex.ofReal_mul, | |
| Complex.ofReal_ofNat, Finset.mul_sum] | |
| rw [β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| linear_combination (2 : β) * complex_inner_pair (W i - (v i : β)) (h i) | |
| def energySlope {d : β} (y : β) (W : Fin d β β) (y' : β) | |
| (W' : Fin d β β) (v : Fin d β β) : β := | |
| y' * squaredDistance W v + y * distanceSlope W W' v | |
| theorem energySlope_pair {d : β} (y yβ yβ : β) (W h : Fin d β β) (v : Fin d β β) : | |
| (energySlope y W yβ h v : β) + | |
| Complex.I * (energySlope y W yβ (fun i => Complex.I * h i) v : β) = | |
| ((yβ : β) + Complex.I * (yβ : β)) * (squaredDistance W v : β) + | |
| (y : β) * (2 * β i, (W i - (v i : β)) * star (h i)) := by | |
| have hd := distanceSlope_pair W h v | |
| simp only [energySlope, Complex.ofReal_add, Complex.ofReal_mul] | |
| linear_combination (y : β) * hd | |
| theorem ratioSlope_I {d : β} (z h : Index d β β) (i : Fin d) : | |
| ratioSlope z (fun a => Complex.I * h a) i = Complex.I * ratioSlope z h i := by | |
| unfold ratioSlope | |
| ring | |
| theorem radiusSlope_pair {d : β} (z h : Index d β β) : | |
| (radiusSlope z h : β) + | |
| Complex.I * (radiusSlope z (fun a => Complex.I * h a) : β) = | |
| z none * star (h none) / (βz noneβ : β) := by | |
| unfold radiusSlope | |
| push_cast | |
| rw [β mul_div_assoc, β add_div, complex_inner_pair] | |
| theorem ratioSlope_tangentVector {d : β} (z : Index d β β) (hY : z none β 0) | |
| (v : Fin d β β) (i : Fin d) : | |
| ratioSlope z (tangentVector (fun i => (v i : β)) (ratio z)) i = | |
| ((v i : β) - ratio z i) / (2 * z none) := by | |
| simp only [ratioSlope, tangentVector, ratio] | |
| field_simp | |
| ring | |
| theorem radiusSlope_tangentVector_pair {d : β} (z : Index d β β) | |
| (v : Fin d β β) : | |
| (radiusSlope z (tangentVector (fun i => (v i : β)) (ratio z)) : β) + | |
| Complex.I * (radiusSlope z | |
| (fun a => Complex.I * tangentVector (fun i => (v i : β)) (ratio z) a) : β) = | |
| z none / (βz noneβ : β) := by | |
| rw [radiusSlope_pair] | |
| simp [tangentVector] | |
| theorem norm_square_eq_mul_star (z : β) : (βzβ : β) ^ 2 = z * star z := by | |
| rw [β Complex.ofReal_pow] | |
| apply Complex.ext <;> simp [Complex.sq_norm, Complex.normSq_apply] ; ring | |
| theorem norm_div_star (Y : β) (hY : Y β 0) : | |
| (βYβ : β) / star Y = Y / (βYβ : β) := by | |
| have hn : (βYβ : β) β 0 := by exact_mod_cast norm_ne_zero_iff.mpr hY | |
| have hs : star Y β 0 := star_ne_zero.mpr hY | |
| apply (div_eq_div_iff hs hn).mpr | |
| simpa only [β pow_two] using norm_square_eq_mul_star Y | |
| theorem squaredDistance_coe {d : β} (W : Fin d β β) (v : Fin d β β) : | |
| (squaredDistance W v : β) = | |
| β i, (W i - (v i : β)) * star (W i - (v i : β)) := by | |
| simp only [squaredDistance, Complex.ofReal_sum, Complex.ofReal_pow] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| exact norm_square_eq_mul_star _ | |
| private theorem gaussian_energy_cancellation {d : β} (Y : β) (hY : Y β 0) | |
| (W : Fin d β β) (v w : Fin d β β) : | |
| (Y / (βYβ : β)) * (squaredDistance W w : β) + | |
| (βYβ : β) * (2 * β i, (W i - (w i : β)) * | |
| star (((v i : β) - W i) / (2 * Y))) = | |
| (Y / (βYβ : β)) * β i, (W i - (w i : β)) * ((v i : β) - (w i : β)) := by | |
| rw [squaredDistance_coe] | |
| simp only [Finset.mul_sum] | |
| rw [β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| have hs : star Y β 0 := star_ne_zero.mpr hY | |
| have hc : (βYβ : β) * (2 * ((W i - (w i : β)) * | |
| star (((v i : β) - W i) / (2 * Y)))) = | |
| ((βYβ : β) / star Y) * (W i - (w i : β)) * ((v i : β) - star (W i)) := by | |
| simp only [star_divβ, star_sub, star_mul, star_ofNat, Complex.star_def, | |
| Complex.conj_ofReal] | |
| field_simp | |
| rw [hc, norm_div_star Y hY] | |
| simp only [star_sub, Complex.star_def, Complex.conj_ofReal] | |
| ring | |
| /-- The Gaussian directional cancellation in equation (gaussian-directional-identity), | |
| written using the two actual real differential components already proved above. -/ | |
| theorem gaussian_energy_tangent_pair {d : β} (z : Index d β β) (hY : z none β 0) | |
| (v w : Fin d β β) : | |
| let V := tangentVector (fun i => (v i : β)) (ratio z) | |
| (energySlope βz noneβ (ratio z) (radiusSlope z V) (ratioSlope z V) w : β) + | |
| Complex.I * (energySlope βz noneβ (ratio z) | |
| (radiusSlope z (fun a => Complex.I * V a)) | |
| (ratioSlope z (fun a => Complex.I * V a)) w : β) = | |
| (z none / (βz noneβ : β)) * | |
| β i, (ratio z i - (w i : β)) * ((v i : β) - (w i : β)) := by | |
| dsimp only | |
| rw [funext (ratioSlope_I z (tangentVector (fun i => (v i : β)) (ratio z)))] | |
| rw [energySlope_pair, radiusSlope_tangentVector_pair] | |
| simp_rw [ratioSlope_tangentVector z hY] | |
| exact gaussian_energy_cancellation (z none) hY (ratio z) v w | |
| theorem gaussianLogSlope_energy {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (z h : Index d β β) : | |
| gaussianLogSlope ΞΊ ΞΊ' v v' z h = | |
| -(d : β) * (radiusSlope z h / βz noneβ) - | |
| (ΞΊ * energySlope βz noneβ (ratio z) (radiusSlope z h) (ratioSlope z h) v + | |
| ΞΊ' * energySlope βz noneβ (ratio z) (radiusSlope z h) (ratioSlope z h) v') / 2 := by | |
| unfold gaussianLogSlope energySlope distanceSlope | |
| ring | |
| theorem gaussian_energy_tangent_pair_phase {d : β} (z : Index d β β) | |
| (hY : z none β 0) (v w : Fin d β β) : | |
| let V := tangentVector (fun i => (v i : β)) (ratio z) | |
| (energySlope βz noneβ (ratio z) (radiusSlope z V) (ratioSlope z V) w : β) + | |
| Complex.I * (energySlope βz noneβ (ratio z) | |
| (radiusSlope z (fun a => Complex.I * V a)) | |
| (ratioSlope z (fun a => Complex.I * V a)) w : β) = | |
| -2 * (z none / (βz noneβ : β)) * | |
| (β a, phaseRow (fun i => (w i : β)) a * V a) := by | |
| dsimp only | |
| rw [gaussian_energy_tangent_pair z hY, phase_polarization] | |
| have hs : (β i, ((w i : β) - ratio z i) * ((w i : β) - (v i : β))) = | |
| β i, (ratio z i - (w i : β)) * ((v i : β) - (w i : β)) := by | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| ring | |
| rw [hs] | |
| ring | |
| /-- The full logarithmic Gaussian directional identity, for two distinct modes. -/ | |
| theorem gaussianLogSlope_tangent_pair {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (z : Index d β β) (hY : z none β 0) : | |
| let V := tangentVector (fun i => (v i : β)) (ratio z) | |
| (gaussianLogSlope ΞΊ ΞΊ' v v' z V : β) + | |
| Complex.I * (gaussianLogSlope ΞΊ ΞΊ' v v' z (fun a => Complex.I * V a) : β) = | |
| (z none / (βz noneβ : β)) * | |
| (-(d : β) / (βz noneβ : β) + | |
| (ΞΊ' : β) * β a, phaseRow (fun i => (v' i : β)) a * V a) := by | |
| dsimp only | |
| have hr := radiusSlope_tangentVector_pair z v | |
| have hv := gaussian_energy_tangent_pair_phase z hY v v | |
| have hv' := gaussian_energy_tangent_pair_phase z hY v v' | |
| dsimp only at hv hv' | |
| rw [phase_tangent] at hv | |
| simp only [mul_zero] at hv | |
| simp only [gaussianLogSlope_energy, Complex.ofReal_sub, Complex.ofReal_mul, | |
| Complex.ofReal_neg, Complex.ofReal_natCast, Complex.ofReal_div, | |
| Complex.ofReal_add, Complex.ofReal_ofNat] | |
| linear_combination (-(d : β) / (βz noneβ : β)) * hr - | |
| ((ΞΊ : β) / 2) * hv - ((ΞΊ' : β) / 2) * hv' | |
| /-- Equation (current-log-derivative) applied to the exact scalar Gaussian field. -/ | |
| theorem gaussianField_tangent_derivative {d : β} (ΞΊ ΞΊ' : β) (v v' : Fin d β β) | |
| (z : Index d β β) (hY : z none β 0) : | |
| let V := tangentVector (fun i => (v i : β)) (ratio z) | |
| barDirectional (gaussianField ΞΊ ΞΊ' v v') z V = | |
| (gaussianField ΞΊ ΞΊ' v v' z : β) * (z none / (βz noneβ : β)) * | |
| (-(d : β) / (βz noneβ : β) + | |
| (ΞΊ' : β) * β a, phaseRow (fun i => (v' i : β)) a * V a) := by | |
| dsimp only | |
| rw [gaussianField_barDirectional ΞΊ ΞΊ' v v' z _ hY, | |
| gaussianLogSlope_tangent_pair ΞΊ ΞΊ' v v' z hY] | |
| ring | |
| end | |
| end OAI.Analysis.Calculus.Current | |