source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean | import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
/-!
# Continuity of power functions
This file contains lemmas about continuity of the power functions on `β`, `β`, `ββ₯0`, and `ββ₯0β`.
-/
noncomputable section
open Real Topology NNReal ENNReal Filter ComplexConjugate Finset Set
section CpowLimits
/-!
## Continuity for complex powers
-/
open Complex
variable {Ξ± : Type*}
theorem zero_cpow_eq_nhds {b : β} (hb : b β 0) : (fun x : β => (0 : β) ^ x) =αΆ [π b] 0 := by
suffices βαΆ x : β in π b, x β 0 from
this.mono fun x hx β¦ by
dsimp only
rw [zero_cpow hx, Pi.zero_apply]
exact IsOpen.eventually_mem isOpen_ne hb
theorem cpow_eq_nhds {a b : β} (ha : a β 0) :
(fun x => x ^ b) =αΆ [π a] fun x => exp (log x * b) := by
suffices βαΆ x : β in π a, x β 0 from
this.mono fun x hx β¦ by
dsimp only
rw [cpow_def_of_ne_zero hx]
exact IsOpen.eventually_mem isOpen_ne ha
theorem cpow_eq_nhds' {p : β Γ β} (hp_fst : p.fst β 0) :
(fun x => x.1 ^ x.2) =αΆ [π p] fun x => exp (log x.1 * x.2) := by
suffices βαΆ x : β Γ β in π p, x.1 β 0 from
this.mono fun x hx β¦ by
dsimp only
rw [cpow_def_of_ne_zero hx]
refine IsOpen.eventually_mem ?_ hp_fst
change IsOpen { x : β Γ β | x.1 = 0 }αΆ
rw [isOpen_compl_iff]
exact isClosed_eq continuous_fst continuous_const
-- Continuity of `fun x => a ^ x`: union of these two lemmas is optimal.
theorem continuousAt_const_cpow {a b : β} (ha : a β 0) : ContinuousAt (fun x : β => a ^ x) b := by
have cpow_eq : (fun x : β => a ^ x) = fun x => exp (log a * x) := by
ext1 b
rw [cpow_def_of_ne_zero ha]
rw [cpow_eq]
exact continuous_exp.continuousAt.comp (ContinuousAt.mul continuousAt_const continuousAt_id)
theorem continuousAt_const_cpow' {a b : β} (h : b β 0) : ContinuousAt (fun x : β => a ^ x) b := by
by_cases ha : a = 0
Β· rw [ha, continuousAt_congr (zero_cpow_eq_nhds h)]
exact continuousAt_const
Β· exact continuousAt_const_cpow ha
/-- The function `z ^ w` is continuous in `(z, w)` provided that `z` does not belong to the interval
`(-β, 0]` on the real line. See also `Complex.continuousAt_cpow_zero_of_re_pos` for a version that
works for `z = 0` but assumes `0 < re w`. -/
theorem continuousAt_cpow {p : β Γ β} (hp_fst : p.fst β slitPlane) :
ContinuousAt (fun x : β Γ β => x.1 ^ x.2) p := by
rw [continuousAt_congr (cpow_eq_nhds' <| slitPlane_ne_zero hp_fst)]
refine continuous_exp.continuousAt.comp ?_
exact
ContinuousAt.mul
(ContinuousAt.comp (continuousAt_clog hp_fst) continuous_fst.continuousAt)
continuous_snd.continuousAt
theorem continuousAt_cpow_const {a b : β} (ha : a β slitPlane) :
ContinuousAt (Β· ^ b) a :=
Tendsto.comp (@continuousAt_cpow (a, b) ha) (continuousAt_id.prodMk continuousAt_const)
theorem Filter.Tendsto.cpow {l : Filter Ξ±} {f g : Ξ± β β} {a b : β} (hf : Tendsto f l (π a))
(hg : Tendsto g l (π b)) (ha : a β slitPlane) :
Tendsto (fun x => f x ^ g x) l (π (a ^ b)) :=
(@continuousAt_cpow (a, b) ha).tendsto.comp (hf.prodMk_nhds hg)
theorem Filter.Tendsto.const_cpow {l : Filter Ξ±} {f : Ξ± β β} {a b : β} (hf : Tendsto f l (π b))
(h : a β 0 β¨ b β 0) : Tendsto (fun x => a ^ f x) l (π (a ^ b)) := by
cases h with
| inl h => exact (continuousAt_const_cpow h).tendsto.comp hf
| inr h => exact (continuousAt_const_cpow' h).tendsto.comp hf
variable [TopologicalSpace Ξ±] {f g : Ξ± β β} {s : Set Ξ±} {a : Ξ±}
nonrec theorem ContinuousWithinAt.cpow (hf : ContinuousWithinAt f s a)
(hg : ContinuousWithinAt g s a) (h0 : f a β slitPlane) :
ContinuousWithinAt (fun x => f x ^ g x) s a :=
hf.cpow hg h0
nonrec theorem ContinuousWithinAt.const_cpow {b : β} (hf : ContinuousWithinAt f s a)
(h : b β 0 β¨ f a β 0) : ContinuousWithinAt (fun x => b ^ f x) s a :=
hf.const_cpow h
nonrec theorem ContinuousAt.cpow (hf : ContinuousAt f a) (hg : ContinuousAt g a)
(h0 : f a β slitPlane) : ContinuousAt (fun x => f x ^ g x) a :=
hf.cpow hg h0
nonrec theorem ContinuousAt.const_cpow {b : β} (hf : ContinuousAt f a) (h : b β 0 β¨ f a β 0) :
ContinuousAt (fun x => b ^ f x) a :=
hf.const_cpow h
theorem ContinuousOn.cpow (hf : ContinuousOn f s) (hg : ContinuousOn g s)
(h0 : β a β s, f a β slitPlane) : ContinuousOn (fun x => f x ^ g x) s := fun a ha =>
(hf a ha).cpow (hg a ha) (h0 a ha)
theorem ContinuousOn.const_cpow {b : β} (hf : ContinuousOn f s) (h : b β 0 β¨ β a β s, f a β 0) :
ContinuousOn (fun x => b ^ f x) s := fun a ha => (hf a ha).const_cpow (h.imp id fun h => h a ha)
theorem Continuous.cpow (hf : Continuous f) (hg : Continuous g)
(h0 : β a, f a β slitPlane) : Continuous fun x => f x ^ g x :=
continuous_iff_continuousAt.2 fun a => hf.continuousAt.cpow hg.continuousAt (h0 a)
theorem Continuous.const_cpow {b : β} (hf : Continuous f) (h : b β 0 β¨ β a, f a β 0) :
Continuous fun x => b ^ f x :=
continuous_iff_continuousAt.2 fun a => hf.continuousAt.const_cpow <| h.imp id fun h => h a
theorem ContinuousOn.cpow_const {b : β} (hf : ContinuousOn f s)
(h : β a : Ξ±, a β s β f a β slitPlane) : ContinuousOn (fun x => f x ^ b) s :=
hf.cpow continuousOn_const h
@[fun_prop]
lemma continuous_const_cpow (z : β) [NeZero z] : Continuous fun s : β β¦ z ^ s :=
continuous_id.const_cpow (.inl <| NeZero.ne z)
end CpowLimits
section RpowLimits
/-!
## Continuity for real powers
-/
namespace Real
theorem continuousAt_const_rpow {a b : β} (h : a β 0) : ContinuousAt (a ^ Β·) b := by
simp only [rpow_def]
refine Complex.continuous_re.continuousAt.comp ?_
refine (continuousAt_const_cpow ?_).comp Complex.continuous_ofReal.continuousAt
norm_cast
theorem continuousAt_const_rpow' {a b : β} (h : b β 0) : ContinuousAt (a ^ Β·) b := by
simp only [rpow_def]
refine Complex.continuous_re.continuousAt.comp ?_
refine (continuousAt_const_cpow' ?_).comp Complex.continuous_ofReal.continuousAt
norm_cast
theorem rpow_eq_nhds_of_neg {p : β Γ β} (hp_fst : p.fst < 0) :
(fun x : β Γ β => x.1 ^ x.2) =αΆ [π p] fun x => exp (log x.1 * x.2) * cos (x.2 * Ο) := by
suffices βαΆ x : β Γ β in π p, x.1 < 0 from
this.mono fun x hx β¦ by
dsimp only
rw [rpow_def_of_neg hx]
exact IsOpen.eventually_mem (isOpen_lt continuous_fst continuous_const) hp_fst
theorem rpow_eq_nhds_of_pos {p : β Γ β} (hp_fst : 0 < p.fst) :
(fun x : β Γ β => x.1 ^ x.2) =αΆ [π p] fun x => exp (log x.1 * x.2) := by
suffices βαΆ x : β Γ β in π p, 0 < x.1 from
this.mono fun x hx β¦ by
dsimp only
rw [rpow_def_of_pos hx]
exact IsOpen.eventually_mem (isOpen_lt continuous_const continuous_fst) hp_fst
theorem continuousAt_rpow_of_ne (p : β Γ β) (hp : p.1 β 0) :
ContinuousAt (fun p : β Γ β => p.1 ^ p.2) p := by
rw [ne_iff_lt_or_gt] at hp
cases hp with
| inl hp =>
rw [continuousAt_congr (rpow_eq_nhds_of_neg hp)]
refine ContinuousAt.mul ?_ (continuous_cos.continuousAt.comp ?_)
Β· refine continuous_exp.continuousAt.comp (ContinuousAt.mul ?_ continuous_snd.continuousAt)
refine (continuousAt_log ?_).comp continuous_fst.continuousAt
exact hp.ne
Β· exact continuous_snd.continuousAt.mul continuousAt_const
| inr hp =>
rw [continuousAt_congr (rpow_eq_nhds_of_pos hp)]
refine continuous_exp.continuousAt.comp (ContinuousAt.mul ?_ continuous_snd.continuousAt)
refine (continuousAt_log ?_).comp continuous_fst.continuousAt
exact hp.ne'
theorem continuousAt_rpow_of_pos (p : β Γ β) (hp : 0 < p.2) :
ContinuousAt (fun p : β Γ β => p.1 ^ p.2) p := by
obtain β¨x, yβ© := p
dsimp only at hp
obtain hx | rfl := ne_or_eq x 0
Β· exact continuousAt_rpow_of_ne (x, y) hx
have A : Tendsto (fun p : β Γ β => exp (log p.1 * p.2)) (π[β ] 0 ΓΛ’ π y) (π 0) :=
tendsto_exp_atBot.comp
((tendsto_log_nhdsNE_zero.comp tendsto_fst).atBot_mul_pos hp tendsto_snd)
have B : Tendsto (fun p : β Γ β => p.1 ^ p.2) (π[β ] 0 ΓΛ’ π y) (π 0) :=
squeeze_zero_norm (fun p => abs_rpow_le_exp_log_mul p.1 p.2) A
have C : Tendsto (fun p : β Γ β => p.1 ^ p.2) (π[{0}] 0 ΓΛ’ π y) (pure 0) := by
rw [nhdsWithin_singleton, tendsto_pure, pure_prod, eventually_map]
exact (lt_mem_nhds hp).mono fun y hy => zero_rpow hy.ne'
simpa only [β sup_prod, β nhdsWithin_union, compl_union_self, nhdsWithin_univ, nhds_prod_eq,
ContinuousAt, zero_rpow hp.ne'] using B.sup (C.mono_right (pure_le_nhds _))
theorem continuousAt_rpow (p : β Γ β) (h : p.1 β 0 β¨ 0 < p.2) :
ContinuousAt (fun p : β Γ β => p.1 ^ p.2) p :=
h.elim (fun h => continuousAt_rpow_of_ne p h) fun h => continuousAt_rpow_of_pos p h
@[fun_prop]
theorem continuousAt_rpow_const (x : β) (q : β) (h : x β 0 β¨ 0 β€ q) :
ContinuousAt (fun x : β => x ^ q) x := by
rw [le_iff_lt_or_eq, β or_assoc] at h
obtain h|rfl := h
Β· exact (continuousAt_rpow (x, q) h).compβ continuousAt_id continuousAt_const
Β· simp_rw [rpow_zero]; exact continuousAt_const
@[fun_prop]
theorem continuous_rpow_const {q : β} (h : 0 β€ q) : Continuous (fun x : β => x ^ q) :=
continuous_iff_continuousAt.mpr fun x β¦ continuousAt_rpow_const x q (.inr h)
@[fun_prop]
lemma continuous_const_rpow {a : β} (h : a β 0) : Continuous (fun x : β β¦ a ^ x) :=
continuous_iff_continuousAt.mpr fun _ β¦ continuousAt_const_rpow h
end Real
section
variable {Ξ± : Type*}
theorem Filter.Tendsto.rpow {l : Filter Ξ±} {f g : Ξ± β β} {x y : β} (hf : Tendsto f l (π x))
(hg : Tendsto g l (π y)) (h : x β 0 β¨ 0 < y) : Tendsto (fun t => f t ^ g t) l (π (x ^ y)) :=
(Real.continuousAt_rpow (x, y) h).tendsto.comp (hf.prodMk_nhds hg)
theorem Filter.Tendsto.rpow_const {l : Filter Ξ±} {f : Ξ± β β} {x p : β} (hf : Tendsto f l (π x))
(h : x β 0 β¨ 0 β€ p) : Tendsto (fun a => f a ^ p) l (π (x ^ p)) :=
if h0 : 0 = p then h0 βΈ by simp [tendsto_const_nhds]
else hf.rpow tendsto_const_nhds (h.imp id fun h' => h'.lt_of_ne h0)
variable [TopologicalSpace Ξ±] {f g : Ξ± β β} {s : Set Ξ±} {x : Ξ±} {p : β}
nonrec theorem ContinuousAt.rpow (hf : ContinuousAt f x) (hg : ContinuousAt g x)
(h : f x β 0 β¨ 0 < g x) : ContinuousAt (fun t => f t ^ g t) x :=
hf.rpow hg h
nonrec theorem ContinuousWithinAt.rpow (hf : ContinuousWithinAt f s x)
(hg : ContinuousWithinAt g s x) (h : f x β 0 β¨ 0 < g x) :
ContinuousWithinAt (fun t => f t ^ g t) s x :=
hf.rpow hg h
theorem ContinuousOn.rpow (hf : ContinuousOn f s) (hg : ContinuousOn g s)
(h : β x β s, f x β 0 β¨ 0 < g x) : ContinuousOn (fun t => f t ^ g t) s := fun t ht =>
(hf t ht).rpow (hg t ht) (h t ht)
theorem Continuous.rpow (hf : Continuous f) (hg : Continuous g) (h : β x, f x β 0 β¨ 0 < g x) :
Continuous fun x => f x ^ g x :=
continuous_iff_continuousAt.2 fun x => hf.continuousAt.rpow hg.continuousAt (h x)
nonrec theorem ContinuousWithinAt.rpow_const (hf : ContinuousWithinAt f s x) (h : f x β 0 β¨ 0 β€ p) :
ContinuousWithinAt (fun x => f x ^ p) s x :=
hf.rpow_const h
nonrec theorem ContinuousAt.rpow_const (hf : ContinuousAt f x) (h : f x β 0 β¨ 0 β€ p) :
ContinuousAt (fun x => f x ^ p) x :=
hf.rpow_const h
theorem ContinuousOn.rpow_const (hf : ContinuousOn f s) (h : β x β s, f x β 0 β¨ 0 β€ p) :
ContinuousOn (fun x => f x ^ p) s := fun x hx => (hf x hx).rpow_const (h x hx)
theorem Continuous.rpow_const (hf : Continuous f) (h : β x, f x β 0 β¨ 0 β€ p) :
Continuous fun x => f x ^ p :=
continuous_iff_continuousAt.2 fun x => hf.continuousAt.rpow_const (h x)
end
end RpowLimits
/-! ## Continuity results for `cpow`, part II
These results involve relating real and complex powers, so cannot be done higher up.
-/
section CpowLimits2
namespace Complex
/-- See also `continuousAt_cpow` and `Complex.continuousAt_cpow_of_re_pos`. -/
theorem continuousAt_cpow_zero_of_re_pos {z : β} (hz : 0 < z.re) :
ContinuousAt (fun x : β Γ β => x.1 ^ x.2) (0, z) := by
have hzβ : z β 0 := ne_of_apply_ne re hz.ne'
rw [ContinuousAt, zero_cpow hzβ, tendsto_zero_iff_norm_tendsto_zero]
refine squeeze_zero (fun _ => norm_nonneg _) (fun _ => norm_cpow_le _ _) ?_
simp only [div_eq_mul_inv, β Real.exp_neg]
refine Tendsto.zero_mul_isBoundedUnder_le ?_ ?_
Β· convert
(continuous_fst.norm.tendsto ((0 : β), z)).rpow
((continuous_re.comp continuous_snd).tendsto _) _ <;>
simp [hz, Real.zero_rpow hz.ne']
Β· simp only [Function.comp_def, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)]
rcases exists_gt |im z| with β¨C, hCβ©
refine β¨Real.exp (Ο * C), eventually_map.2 ?_β©
refine
(((continuous_im.comp continuous_snd).abs.tendsto (_, z)).eventually (gt_mem_nhds hC)).mono
fun z hz => Real.exp_le_exp.2 <| (neg_le_abs _).trans ?_
rw [_root_.abs_mul]
exact
mul_le_mul (abs_le.2 β¨(neg_pi_lt_arg _).le, arg_le_pi _β©) hz.le (_root_.abs_nonneg _)
Real.pi_pos.le
open ComplexOrder in
/-- See also `continuousAt_cpow` for a version that assumes `p.1 β 0` but makes no
assumptions about `p.2`. -/
theorem continuousAt_cpow_of_re_pos {p : β Γ β} (hβ : 0 β€ p.1.re β¨ p.1.im β 0) (hβ : 0 < p.2.re) :
ContinuousAt (fun x : β Γ β => x.1 ^ x.2) p := by
obtain β¨z, wβ© := p
rw [β not_lt_zero_iff, lt_iff_le_and_ne, not_and_or, Ne, Classical.not_not,
not_le_zero_iff] at hβ
rcases hβ with (hβ | (rfl : z = 0))
exacts [continuousAt_cpow hβ, continuousAt_cpow_zero_of_re_pos hβ]
/-- See also `continuousAt_cpow_const` for a version that assumes `z β 0` but makes no
assumptions about `w`. -/
theorem continuousAt_cpow_const_of_re_pos {z w : β} (hz : 0 β€ re z β¨ im z β 0) (hw : 0 < re w) :
ContinuousAt (fun x => x ^ w) z :=
Tendsto.comp (@continuousAt_cpow_of_re_pos (z, w) hz hw)
(continuousAt_id.prodMk continuousAt_const)
/-- Continuity of `(x, y) β¦ x ^ y` as a function on `β Γ β`. -/
theorem continuousAt_ofReal_cpow (x : β) (y : β) (h : 0 < y.re β¨ x β 0) :
ContinuousAt (fun p => (p.1 : β) ^ p.2 : β Γ β β β) (x, y) := by
rcases lt_trichotomy (0 : β) x with (hx | rfl | hx)
Β· -- x > 0 : easy case
have : ContinuousAt (fun p => β¨βp.1, p.2β© : β Γ β β β Γ β) (x, y) := by fun_prop
refine (continuousAt_cpow (Or.inl ?_)).comp this
rwa [ofReal_re]
Β· -- x = 0 : reduce to continuousAt_cpow_zero_of_re_pos
have A : ContinuousAt (fun p => p.1 ^ p.2 : β Γ β β β) β¨β(0 : β), yβ© := by
rw [ofReal_zero]
apply continuousAt_cpow_zero_of_re_pos
tauto
have B : ContinuousAt (fun p => β¨βp.1, p.2β© : β Γ β β β Γ β) β¨0, yβ© := by fun_prop
exact A.comp_of_eq B rfl
Β· -- x < 0 : difficult case
suffices ContinuousAt (fun p => (-(p.1 : β)) ^ p.2 * exp (Ο * I * p.2) : β Γ β β β) (x, y) by
refine this.congr (eventually_of_mem (prod_mem_nhds (Iio_mem_nhds hx) univ_mem) ?_)
exact fun p hp => (ofReal_cpow_of_nonpos (le_of_lt hp.1) p.2).symm
have A : ContinuousAt (fun p => β¨-βp.1, p.2β© : β Γ β β β Γ β) (x, y) := by fun_prop
apply ContinuousAt.mul
Β· refine (continuousAt_cpow (Or.inl ?_)).comp A
rwa [neg_re, ofReal_re, neg_pos]
Β· exact (continuous_exp.comp (continuous_const.mul continuous_snd)).continuousAt
theorem continuousAt_ofReal_cpow_const (x : β) (y : β) (h : 0 < y.re β¨ x β 0) :
ContinuousAt (fun a => (a : β) ^ y : β β β) x :=
(continuousAt_ofReal_cpow x y h).compβ_of_eq (by fun_prop) (by fun_prop) rfl
theorem continuous_ofReal_cpow_const {y : β} (hs : 0 < y.re) :
Continuous (fun x => (x : β) ^ y : β β β) :=
continuous_iff_continuousAt.mpr fun x => continuousAt_ofReal_cpow_const x y (Or.inl hs)
end Complex
end CpowLimits2
/-! ## Limits and continuity for `ββ₯0` powers -/
namespace NNReal
theorem continuousAt_rpow {x : ββ₯0} {y : β} (h : x β 0 β¨ 0 < y) :
ContinuousAt (fun p : ββ₯0 Γ β => p.1 ^ p.2) (x, y) := by
have :
(fun p : ββ₯0 Γ β => p.1 ^ p.2) =
Real.toNNReal β (fun p : β Γ β => p.1 ^ p.2) β fun p : ββ₯0 Γ β => (p.1.1, p.2) := by
ext p
simp only [coe_rpow, val_eq_coe, Function.comp_apply, coe_toNNReal', left_eq_sup]
exact_mod_cast zero_le (p.1 ^ p.2)
rw [this]
refine continuous_real_toNNReal.continuousAt.comp (ContinuousAt.comp ?_ ?_)
Β· apply Real.continuousAt_rpow
simpa using h
Β· fun_prop
theorem eventually_pow_one_div_le (x : ββ₯0) {y : ββ₯0} (hy : 1 < y) :
βαΆ n : β in atTop, x ^ (1 / n : β) β€ y := by
obtain β¨m, hmβ© := add_one_pow_unbounded_of_pos x (tsub_pos_of_lt hy)
rw [tsub_add_cancel_of_le hy.le] at hm
refine eventually_atTop.2 β¨m + 1, fun n hn => ?_β©
simp only [one_div]
simpa only [NNReal.rpow_inv_le_iff (Nat.cast_pos.2 <| m.succ_pos.trans_le hn),
NNReal.rpow_natCast] using hm.le.trans (pow_right_monoβ hy.le (m.le_succ.trans hn))
end NNReal
open Filter
theorem Filter.Tendsto.nnrpow {Ξ± : Type*} {f : Filter Ξ±} {u : Ξ± β ββ₯0} {v : Ξ± β β} {x : ββ₯0}
{y : β} (hx : Tendsto u f (π x)) (hy : Tendsto v f (π y)) (h : x β 0 β¨ 0 < y) :
Tendsto (fun a => u a ^ v a) f (π (x ^ y)) :=
Tendsto.comp (NNReal.continuousAt_rpow h) (hx.prodMk_nhds hy)
namespace NNReal
theorem continuousAt_rpow_const {x : ββ₯0} {y : β} (h : x β 0 β¨ 0 β€ y) :
ContinuousAt (fun z => z ^ y) x :=
h.elim (fun h => tendsto_id.nnrpow tendsto_const_nhds (Or.inl h)) fun h =>
h.eq_or_lt.elim (fun h => h βΈ by simp only [rpow_zero, continuousAt_const]) fun h =>
tendsto_id.nnrpow tendsto_const_nhds (Or.inr h)
@[fun_prop]
theorem continuous_rpow_const {y : β} (h : 0 β€ y) : Continuous fun x : ββ₯0 => x ^ y :=
continuous_iff_continuousAt.2 fun _ => continuousAt_rpow_const (Or.inr h)
@[fun_prop]
theorem continuousOn_rpow_const_compl_zero {r : β} :
ContinuousOn (fun z : ββ₯0 => z ^ r) {0}αΆ :=
fun _ h => ContinuousAt.continuousWithinAt <| NNReal.continuousAt_rpow_const (.inl h)
-- even though this follows from `ContinuousOn.mono` and the previous lemma, we include it for
-- automation purposes with `fun_prop`, because the side goal `0 β s β¨ 0 β€ r` is often easy to check
@[fun_prop]
theorem continuousOn_rpow_const {r : β} {s : Set ββ₯0}
(h : 0 β s β¨ 0 β€ r) : ContinuousOn (fun z : ββ₯0 => z ^ r) s :=
h.elim (fun _ β¦ ContinuousOn.mono (s := {0}αΆ) (by fun_prop) (by simp_all))
(NNReal.continuous_rpow_const Β· |>.continuousOn)
end NNReal
/-! ## Continuity for `ββ₯0β` powers -/
namespace ENNReal
theorem eventually_pow_one_div_le {x : ββ₯0β} (hx : x β β) {y : ββ₯0β} (hy : 1 < y) :
βαΆ n : β in atTop, x ^ (1 / n : β) β€ y := by
lift x to ββ₯0 using hx
by_cases h : y = β
Β· exact Eventually.of_forall fun n => h.symm βΈ le_top
Β· lift y to ββ₯0 using h
have := NNReal.eventually_pow_one_div_le x (mod_cast hy : 1 < y)
refine this.congr (Eventually.of_forall fun n => ?_)
rw [β coe_rpow_of_nonneg x (by positivity : 0 β€ (1 / n : β)), coe_le_coe]
private theorem continuousAt_rpow_const_of_pos {x : ββ₯0β} {y : β} (h : 0 < y) :
ContinuousAt (fun a : ββ₯0β => a ^ y) x := by
by_cases hx : x = β€
Β· rw [hx, ContinuousAt]
convert ENNReal.tendsto_rpow_at_top h
simp [h]
lift x to ββ₯0 using hx
rw [continuousAt_coe_iff]
convert continuous_coe.continuousAt.comp (NNReal.continuousAt_rpow_const (Or.inr h.le)) using 1
ext1 x
simp [β coe_rpow_of_nonneg _ h.le]
@[continuity, fun_prop]
theorem continuous_rpow_const {y : β} : Continuous fun a : ββ₯0β => a ^ y := by
refine continuous_iff_continuousAt.2 fun x => ?_
rcases lt_trichotomy (0 : β) y with (hy | rfl | hy)
Β· exact continuousAt_rpow_const_of_pos hy
Β· simp only [rpow_zero]
exact continuousAt_const
Β· obtain β¨z, hzβ© : β z, y = -z := β¨-y, (neg_neg _).symmβ©
have z_pos : 0 < z := by simpa [hz] using hy
simp_rw [hz, rpow_neg]
exact continuous_inv.continuousAt.comp (continuousAt_rpow_const_of_pos z_pos)
theorem tendsto_const_mul_rpow_nhds_zero_of_pos {c : ββ₯0β} (hc : c β β) {y : β} (hy : 0 < y) :
Tendsto (fun x : ββ₯0β => c * x ^ y) (π 0) (π 0) := by
convert ENNReal.Tendsto.const_mul (ENNReal.continuous_rpow_const.tendsto 0) _
Β· simp [hy]
Β· exact Or.inr hc
end ENNReal
theorem Filter.Tendsto.ennrpow_const {Ξ± : Type*} {f : Filter Ξ±} {m : Ξ± β ββ₯0β} {a : ββ₯0β} (r : β)
(hm : Tendsto m f (π a)) : Tendsto (fun x => m x ^ r) f (π (a ^ r)) :=
(ENNReal.continuous_rpow_const.tendsto a).comp hm |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Pow/Complex.lean | import Mathlib.Analysis.SpecialFunctions.Complex.Log
/-! # Power function on `β`
We construct the power functions `x ^ y`, where `x` and `y` are complex numbers.
-/
open Real Topology Filter ComplexConjugate Finset Set
namespace Complex
/-- The complex power function `x ^ y`, given by `x ^ y = exp(y log x)` (where `log` is the
principal determination of the logarithm), unless `x = 0` where one sets `0 ^ 0 = 1` and
`0 ^ y = 0` for `y β 0`. -/
noncomputable def cpow (x y : β) : β :=
if x = 0 then if y = 0 then 1 else 0 else exp (log x * y)
noncomputable instance : Pow β β :=
β¨cpowβ©
@[simp]
theorem cpow_eq_pow (x y : β) : cpow x y = x ^ y :=
rfl
theorem cpow_def (x y : β) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) :=
rfl
theorem cpow_def_of_ne_zero {x : β} (hx : x β 0) (y : β) : x ^ y = exp (log x * y) :=
if_neg hx
@[simp]
theorem cpow_zero (x : β) : x ^ (0 : β) = 1 := by simp [cpow_def]
@[simp]
theorem cpow_eq_zero_iff (x y : β) : x ^ y = 0 β x = 0 β§ y β 0 := by
simp only [cpow_def]
split_ifs <;> simp [*, exp_ne_zero]
theorem cpow_ne_zero_iff {x y : β} :
x ^ y β 0 β x β 0 β¨ y = 0 := by
rw [ne_eq, cpow_eq_zero_iff, not_and_or, ne_eq, not_not]
theorem cpow_ne_zero_iff_of_exponent_ne_zero {x y : β} (hy : y β 0) :
x ^ y β 0 β x β 0 := by simp [hy]
@[simp]
theorem zero_cpow {x : β} (h : x β 0) : (0 : β) ^ x = 0 := by simp [cpow_def, *]
theorem zero_cpow_eq_iff {x : β} {a : β} : (0 : β) ^ x = a β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
constructor
Β· intro hyp
simp only [cpow_def, if_true] at hyp
grind
Β· rintro (β¨h, rflβ© | β¨rfl, rflβ©)
Β· exact zero_cpow h
Β· exact cpow_zero _
theorem eq_zero_cpow_iff {x : β} {a : β} : a = (0 : β) ^ x β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
rw [β zero_cpow_eq_iff, eq_comm]
@[simp]
theorem cpow_one (x : β) : x ^ (1 : β) = x :=
if hx : x = 0 then by simp [hx, cpow_def]
else by rw [cpow_def, if_neg (one_ne_zero : (1 : β) β 0), if_neg hx, mul_one, exp_log hx]
@[simp]
theorem one_cpow (x : β) : (1 : β) ^ x = 1 := by
rw [cpow_def]
split_ifs <;> simp_all [one_ne_zero]
theorem cpow_add {x : β} (y z : β) (hx : x β 0) : x ^ (y + z) = x ^ y * x ^ z := by
simp only [cpow_def, ite_mul, mul_ite]
simp_all [exp_add, mul_add]
theorem cpow_mul {x y : β} (z : β) (hβ : -Ο < (log x * y).im) (hβ : (log x * y).im β€ Ο) :
x ^ (y * z) = (x ^ y) ^ z := by
simp only [cpow_def]
split_ifs <;> simp_all [exp_ne_zero, log_exp hβ hβ, mul_assoc]
theorem cpow_neg (x y : β) : x ^ (-y) = (x ^ y)β»ΒΉ := by
simp only [cpow_def, neg_eq_zero, mul_neg]
split_ifs <;> simp [exp_neg]
theorem cpow_sub {x : β} (y z : β) (hx : x β 0) : x ^ (y - z) = x ^ y / x ^ z := by
rw [sub_eq_add_neg, cpow_add _ _ hx, cpow_neg, div_eq_mul_inv]
theorem cpow_neg_one (x : β) : x ^ (-1 : β) = xβ»ΒΉ := by simpa using cpow_neg x 1
/-- See also `Complex.cpow_int_mul'`. -/
lemma cpow_int_mul (x : β) (n : β€) (y : β) : x ^ (n * y) = (x ^ y) ^ n := by
rcases eq_or_ne x 0 with rfl | hx
Β· rcases eq_or_ne n 0 with rfl | hn
Β· simp
Β· rcases eq_or_ne y 0 with rfl | hy <;> simp [*, zero_zpow]
Β· rw [cpow_def_of_ne_zero hx, cpow_def_of_ne_zero hx, mul_left_comm, exp_int_mul]
lemma cpow_mul_int (x y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by rw [mul_comm, cpow_int_mul]
lemma cpow_nat_mul (x : β) (n : β) (y : β) : x ^ (n * y) = (x ^ y) ^ n :=
mod_cast cpow_int_mul x n y
lemma cpow_ofNat_mul (x : β) (n : β) [n.AtLeastTwo] (y : β) :
x ^ (ofNat(n) * y) = (x ^ y) ^ ofNat(n) :=
cpow_nat_mul x n y
lemma cpow_mul_nat (x y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [mul_comm, cpow_nat_mul]
lemma cpow_mul_ofNat (x y : β) (n : β) [n.AtLeastTwo] :
x ^ (y * ofNat(n)) = (x ^ y) ^ ofNat(n) :=
cpow_mul_nat x y n
@[simp, norm_cast]
theorem cpow_natCast (x : β) (n : β) : x ^ (n : β) = x ^ n := by simpa using cpow_nat_mul x n 1
@[simp]
lemma cpow_ofNat (x : β) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ ofNat(n) :=
cpow_natCast x n
theorem cpow_two (x : β) : x ^ (2 : β) = x ^ (2 : β) := cpow_ofNat x 2
@[simp, norm_cast]
theorem cpow_intCast (x : β) (n : β€) : x ^ (n : β) = x ^ n := by simpa using cpow_int_mul x n 1
@[simp]
theorem cpow_nat_inv_pow (x : β) {n : β} (hn : n β 0) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
rw [β cpow_nat_mul, mul_inv_cancelβ, cpow_one]
assumption_mod_cast
@[simp]
lemma cpow_ofNat_inv_pow (x : β) (n : β) [n.AtLeastTwo] :
(x ^ ((ofNat(n) : β)β»ΒΉ)) ^ (ofNat(n) : β) = x :=
cpow_nat_inv_pow _ (NeZero.ne n)
/-- A version of `Complex.cpow_int_mul` with RHS that matches `Complex.cpow_mul`.
The assumptions on the arguments are needed
because the equality fails, e.g., for `x = -I`, `n = 2`, `y = 1/2`. -/
lemma cpow_int_mul' {x : β} {n : β€} (hlt : -Ο < n * x.arg) (hle : n * x.arg β€ Ο) (y : β) :
x ^ (n * y) = (x ^ n) ^ y := by
rw [mul_comm] at hlt hle
rw [cpow_mul, cpow_intCast] <;> simpa [log_im]
/-- A version of `Complex.cpow_nat_mul` with RHS that matches `Complex.cpow_mul`.
The assumptions on the arguments are needed
because the equality fails, e.g., for `x = -I`, `n = 2`, `y = 1/2`. -/
lemma cpow_nat_mul' {x : β} {n : β} (hlt : -Ο < n * x.arg) (hle : n * x.arg β€ Ο) (y : β) :
x ^ (n * y) = (x ^ n) ^ y :=
cpow_int_mul' hlt hle y
lemma cpow_ofNat_mul' {x : β} {n : β} [n.AtLeastTwo] (hlt : -Ο < OfNat.ofNat n * x.arg)
(hle : OfNat.ofNat n * x.arg β€ Ο) (y : β) :
x ^ (OfNat.ofNat n * y) = (x ^ ofNat(n)) ^ y :=
cpow_nat_mul' hlt hle y
lemma pow_cpow_nat_inv {x : β} {n : β} (hβ : n β 0) (hlt : -(Ο / n) < x.arg) (hle : x.arg β€ Ο / n) :
(x ^ n) ^ (nβ»ΒΉ : β) = x := by
rw [β cpow_nat_mul', mul_inv_cancelβ (Nat.cast_ne_zero.2 hβ), cpow_one]
Β· rwa [β div_lt_iffβ' (Nat.cast_pos.2 hβ.bot_lt), neg_div]
Β· rwa [β le_div_iffβ' (Nat.cast_pos.2 hβ.bot_lt)]
lemma pow_cpow_ofNat_inv {x : β} {n : β} [n.AtLeastTwo] (hlt : -(Ο / OfNat.ofNat n) < x.arg)
(hle : x.arg β€ Ο / OfNat.ofNat n) :
(x ^ ofNat(n)) ^ ((OfNat.ofNat n : β)β»ΒΉ) = x :=
pow_cpow_nat_inv (NeZero.ne n) hlt hle
/-- See also `Complex.pow_cpow_ofNat_inv` for a version that also works for `x * I`, `0 β€ x`. -/
lemma sq_cpow_two_inv {x : β} (hx : 0 < x.re) : (x ^ (2 : β)) ^ (2β»ΒΉ : β) = x :=
pow_cpow_ofNat_inv (neg_pi_div_two_lt_arg_iff.2 <| .inl hx)
(arg_le_pi_div_two_iff.2 <| .inl hx.le)
@[simp] lemma isSquare (x : β) : IsSquare x := β¨x ^ (2β»ΒΉ : β), by simp [β sq]β©
theorem mul_cpow_ofReal_nonneg {a b : β} (ha : 0 β€ a) (hb : 0 β€ b) (r : β) :
((a : β) * (b : β)) ^ r = (a : β) ^ r * (b : β) ^ r := by
rcases eq_or_ne r 0 with (rfl | hr)
Β· simp only [cpow_zero, mul_one]
rcases eq_or_lt_of_le ha with (rfl | ha')
Β· rw [ofReal_zero, zero_mul, zero_cpow hr, zero_mul]
rcases eq_or_lt_of_le hb with (rfl | hb')
Β· rw [ofReal_zero, mul_zero, zero_cpow hr, mul_zero]
have ha'' : (a : β) β 0 := ofReal_ne_zero.mpr ha'.ne'
have hb'' : (b : β) β 0 := ofReal_ne_zero.mpr hb'.ne'
rw [cpow_def_of_ne_zero (mul_ne_zero ha'' hb''), log_ofReal_mul ha' hb'', ofReal_log ha,
add_mul, exp_add, β cpow_def_of_ne_zero ha'', β cpow_def_of_ne_zero hb'']
lemma natCast_mul_natCast_cpow (m n : β) (s : β) : (m * n : β) ^ s = m ^ s * n ^ s :=
ofReal_natCast m βΈ ofReal_natCast n βΈ mul_cpow_ofReal_nonneg m.cast_nonneg n.cast_nonneg s
lemma natCast_cpow_natCast_mul (n m : β) (z : β) : (n : β) ^ (m * z) = ((n : β) ^ m) ^ z := by
refine cpow_nat_mul' (x := n) (n := m) ?_ ?_ z
Β· simp only [natCast_arg, mul_zero, Left.neg_neg_iff, pi_pos]
Β· simp only [natCast_arg, mul_zero, pi_pos.le]
theorem inv_cpow_eq_ite (x : β) (n : β) :
xβ»ΒΉ ^ n = if x.arg = Ο then conj (x ^ conj n)β»ΒΉ else (x ^ n)β»ΒΉ := by
simp_rw [Complex.cpow_def, log_inv_eq_ite, inv_eq_zero, map_eq_zero, ite_mul, neg_mul,
RCLike.conj_inv, apply_ite conj, apply_ite exp, apply_ite Inv.inv, map_zero, map_one, exp_neg,
inv_one, inv_zero, β exp_conj, map_mul, conj_conj]
split_ifs with hx hn ha ha <;> rfl
theorem inv_cpow (x : β) (n : β) (hx : x.arg β Ο) : xβ»ΒΉ ^ n = (x ^ n)β»ΒΉ := by
rw [inv_cpow_eq_ite, if_neg hx]
/-- `Complex.inv_cpow_eq_ite` with the `ite` on the other side. -/
theorem inv_cpow_eq_ite' (x : β) (n : β) :
(x ^ n)β»ΒΉ = if x.arg = Ο then conj (xβ»ΒΉ ^ conj n) else xβ»ΒΉ ^ n := by
rw [inv_cpow_eq_ite, apply_ite conj, conj_conj, conj_conj]
split_ifs with h
Β· rfl
Β· rw [inv_cpow _ _ h]
theorem conj_cpow_eq_ite (x : β) (n : β) :
conj x ^ n = if x.arg = Ο then x ^ n else conj (x ^ conj n) := by
simp_rw [cpow_def, map_eq_zero, apply_ite conj, map_one, map_zero, β exp_conj, map_mul, conj_conj,
log_conj_eq_ite]
split_ifs with hcx hn hx <;> rfl
theorem conj_cpow (x : β) (n : β) (hx : x.arg β Ο) : conj x ^ n = conj (x ^ conj n) := by
rw [conj_cpow_eq_ite, if_neg hx]
theorem cpow_conj (x : β) (n : β) (hx : x.arg β Ο) : x ^ conj n = conj (conj x ^ n) := by
rw [conj_cpow _ _ hx, conj_conj]
lemma natCast_add_one_cpow_ne_zero (n : β) (z : β) : (n + 1 : β) ^ z β 0 :=
mt (cpow_eq_zero_iff ..).mp fun H β¦ by norm_cast at H; exact H.1
end Complex
-- section Tactics
-- /-!
-- ## Tactic extensions for complex powers
-- -/
-- namespace NormNum
-- theorem cpow_pos (a b : β) (b' : β) (c : β) (hb : b = b') (h : a ^ b' = c) : a ^ b = c := by
-- rw [β h, hb, Complex.cpow_natCast]
-- theorem cpow_neg (a b : β) (b' : β) (c c' : β) (hb : b = b') (h : a ^ b' = c) (hc : cβ»ΒΉ = c') :
-- a ^ (-b) = c' := by rw [β hc, β h, hb, Complex.cpow_neg, Complex.cpow_natCast]
-- open Tactic
-- /-- Generalized version of `prove_cpow`, `prove_nnrpow`, `prove_ennrpow`. -/
-- unsafe def prove_rpow' (pos neg zero : Name) (Ξ± Ξ² one a b : expr) : tactic (expr Γ expr) := do
-- let na β a.to_rat
-- let icΞ± β mk_instance_cache Ξ±
-- let icΞ² β mk_instance_cache Ξ²
-- match match_sign b with
-- | Sum.inl b => do
-- let nc β mk_instance_cache q(β)
-- let (icΞ², nc, b', hb) β prove_nat_uncast icΞ² nc b
-- let (icΞ±, c, h) β prove_pow a na icΞ± b'
-- let cr β c
-- let (icΞ±, c', hc) β prove_inv icΞ± c cr
-- pure (c', (expr.const neg []).mk_app [a, b, b', c, c', hb, h, hc])
-- | Sum.inr ff => pure (one, expr.const zero [] a)
-- | Sum.inr tt => do
-- let nc β mk_instance_cache q(β)
-- let (icΞ², nc, b', hb) β prove_nat_uncast icΞ² nc b
-- let (icΞ±, c, h) β prove_pow a na icΞ± b'
-- pure (c, (expr.const Pos []).mk_app [a, b, b', c, hb, h])
-- /-- Evaluate `Complex.cpow a b` where `a` is a rational numeral and `b` is an integer. -/
-- unsafe def prove_cpow : expr β expr β tactic (expr Γ expr) :=
-- prove_rpow' `` cpow_pos `` cpow_neg `` Complex.cpow_zero q(β) q(β) q((1 : β))
-- /-- Evaluates expressions of the form `cpow a b` and `a ^ b` in the special case where
-- `b` is an integer and `a` is a positive rational (so it's really just a rational power). -/
-- @[norm_num]
-- unsafe def eval_cpow : expr β tactic (expr Γ expr)
-- | q(@Pow.pow _ _ Complex.hasPow $(a) $(b)) => b.to_int >> prove_cpow a b
-- | q(Complex.cpow $(a) $(b)) => b.to_int >> prove_cpow a b
-- | _ => tactic.failed
-- end NormNum
-- end Tactics |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean | import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Power function on `ββ₯0` and `ββ₯0β`
We construct the power functions `x ^ y` where
* `x` is a nonnegative real number and `y` is a real number;
* `x` is a number from `[0, +β]` (a.k.a. `ββ₯0β`) and `y` is a real number.
We also prove basic properties of these functions.
-/
noncomputable section
open Real NNReal ENNReal ComplexConjugate Finset Function Set
namespace NNReal
variable {x : ββ₯0} {w y z : β}
/-- The nonnegative real power function `x^y`, defined for `x : ββ₯0` and `y : β` as the
restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`,
one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y β 0`. -/
noncomputable def rpow (x : ββ₯0) (y : β) : ββ₯0 :=
β¨(x : β) ^ y, Real.rpow_nonneg x.2 yβ©
noncomputable instance : Pow ββ₯0 β :=
β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x : ββ₯0) (y : β) : rpow x y = x ^ y :=
rfl
@[simp, norm_cast]
theorem coe_rpow (x : ββ₯0) (y : β) : ((x ^ y : ββ₯0) : β) = (x : β) ^ y :=
rfl
@[simp]
theorem rpow_zero (x : ββ₯0) : x ^ (0 : β) = 1 :=
NNReal.eq <| Real.rpow_zero _
theorem rpow_zero_pos (x : ββ₯0) : 0 < x ^ (0 : β) := by rw [rpow_zero]; exact one_pos
@[simp]
theorem rpow_eq_zero_iff {x : ββ₯0} {y : β} : x ^ y = 0 β x = 0 β§ y β 0 := by
rw [β NNReal.coe_inj, coe_rpow, β NNReal.coe_eq_zero]
exact Real.rpow_eq_zero_iff_of_nonneg x.2
lemma rpow_eq_zero (hy : y β 0) : x ^ y = 0 β x = 0 := by simp [hy]
@[simp]
theorem zero_rpow {x : β} (h : x β 0) : (0 : ββ₯0) ^ x = 0 :=
NNReal.eq <| Real.zero_rpow h
@[simp]
theorem rpow_one (x : ββ₯0) : x ^ (1 : β) = x :=
NNReal.eq <| Real.rpow_one _
lemma rpow_neg (x : ββ₯0) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ :=
NNReal.eq <| Real.rpow_neg x.2 _
@[simp, norm_cast]
lemma rpow_natCast (x : ββ₯0) (n : β) : x ^ (n : β) = x ^ n :=
NNReal.eq <| by simpa only [coe_rpow, coe_pow] using Real.rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ββ₯0) (n : β€) : x ^ (n : β) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
@[simp]
theorem one_rpow (x : β) : (1 : ββ₯0) ^ x = 1 :=
NNReal.eq <| Real.one_rpow _
theorem rpow_add {x : ββ₯0} (hx : x β 0) (y z : β) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) _ _
theorem rpow_add' (h : y + z β 0) (x : ββ₯0) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add' x.2 h
lemma rpow_add_intCast (hx : x β 0) (y : β) (n : β€) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast (mod_cast hx) _ _
lemma rpow_add_natCast (hx : x β 0) (y : β) (n : β) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast (mod_cast hx) _ _
lemma rpow_sub_intCast (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast (mod_cast hx) _ _
lemma rpow_sub_natCast (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast (mod_cast hx) _ _
lemma rpow_add_intCast' {n : β€} (h : y + n β 0) (x : ββ₯0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast' (mod_cast x.2) h
lemma rpow_add_natCast' {n : β} (h : y + n β 0) (x : ββ₯0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast' (mod_cast x.2) h
lemma rpow_sub_intCast' {n : β€} (h : y - n β 0) (x : ββ₯0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast' (mod_cast x.2) h
lemma rpow_sub_natCast' {n : β} (h : y - n β 0) (x : ββ₯0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast' (mod_cast x.2) h
lemma rpow_add_one (hx : x β 0) (y : β) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_natCast hx y 1
lemma rpow_sub_one (hx : x β 0) (y : β) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_natCast hx y 1
lemma rpow_add_one' (h : y + 1 β 0) (x : ββ₯0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' h, rpow_one]
lemma rpow_one_add' (h : 1 + y β 0) (x : ββ₯0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' h, rpow_one]
theorem rpow_add_of_nonneg (x : ββ₯0) {y z : β} (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
ext; exact Real.rpow_add_of_nonneg x.2 hy hz
/-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (x : ββ₯0) (hw : w β 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [β h, rpow_add']; rwa [h]
theorem rpow_mul (x : ββ₯0) (y z : β) : x ^ (y * z) = (x ^ y) ^ z :=
NNReal.eq <| Real.rpow_mul x.2 y z
lemma rpow_natCast_mul (x : ββ₯0) (n : β) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_natCast]
lemma rpow_mul_natCast (x : ββ₯0) (y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_natCast]
lemma rpow_intCast_mul (x : ββ₯0) (n : β€) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_intCast]
lemma rpow_mul_intCast (x : ββ₯0) (y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_intCast]
theorem rpow_neg_one (x : ββ₯0) : x ^ (-1 : β) = xβ»ΒΉ := by simp [rpow_neg]
theorem rpow_sub {x : ββ₯0} (hx : x β 0) (y z : β) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) y z
theorem rpow_sub' (h : y - z β 0) (x : ββ₯0) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub' x.2 h
lemma rpow_sub_one' (h : y - 1 β 0) (x : ββ₯0) : x ^ (y - 1) = x ^ y / x := by
rw [rpow_sub' h, rpow_one]
lemma rpow_one_sub' (h : 1 - y β 0) (x : ββ₯0) : x ^ (1 - y) = x / x ^ y := by
rw [rpow_sub' h, rpow_one]
theorem rpow_inv_rpow_self {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ y) ^ (1 / y) = x := by
rw [β rpow_mul]
field_simp
simp
theorem rpow_self_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ (1 / y)) ^ y = x := by
rw [β rpow_mul]
field_simp
simp
theorem inv_rpow (x : ββ₯0) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ :=
NNReal.eq <| Real.inv_rpow x.2 y
theorem div_rpow (x y : ββ₯0) (z : β) : (x / y) ^ z = x ^ z / y ^ z :=
NNReal.eq <| Real.div_rpow x.2 y.2 z
theorem sqrt_eq_rpow (x : ββ₯0) : sqrt x = x ^ (1 / (2 : β)) := by
refine NNReal.eq ?_
push_cast
exact Real.sqrt_eq_rpow x.1
@[simp]
lemma rpow_ofNat (x : ββ₯0) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ (OfNat.ofNat n : β) :=
rpow_natCast x n
theorem rpow_two (x : ββ₯0) : x ^ (2 : β) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow {x y : ββ₯0} {z : β} : (x * y) ^ z = x ^ z * y ^ z :=
NNReal.eq <| Real.mul_rpow x.2 y.2
/-- `rpow` as a `MonoidHom` -/
@[simps]
def rpowMonoidHom (r : β) : ββ₯0 β* ββ₯0 where
toFun := (Β· ^ r)
map_one' := one_rpow _
map_mul' _x _y := mul_rpow
/-- `rpow` variant of `List.prod_map_pow` for `ββ₯0` -/
theorem list_prod_map_rpow (l : List ββ₯0) (r : β) :
(l.map (Β· ^ r)).prod = l.prod ^ r :=
l.prod_hom (rpowMonoidHom r)
theorem list_prod_map_rpow' {ΞΉ} (l : List ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(l.map (f Β· ^ r)).prod = (l.map f).prod ^ r := by
rw [β list_prod_map_rpow, List.map_map]; rfl
/-- `rpow` version of `Multiset.prod_map_pow` for `ββ₯0`. -/
lemma multiset_prod_map_rpow {ΞΉ} (s : Multiset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(s.map (f Β· ^ r)).prod = (s.map f).prod ^ r :=
s.prod_hom' (rpowMonoidHom r) _
/-- `rpow` version of `Finset.prod_pow` for `ββ₯0`. -/
lemma finset_prod_rpow {ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(β i β s, f i ^ r) = (β i β s, f i) ^ r :=
multiset_prod_map_rpow _ _ _
-- note: these don't really belong here, but they're much easier to prove in terms of the above
section Real
/-- `rpow` version of `List.prod_map_pow` for `Real`. -/
theorem _root_.Real.list_prod_map_rpow (l : List β) (hl : β x β l, (0 : β) β€ x) (r : β) :
(l.map (Β· ^ r)).prod = l.prod ^ r := by
lift l to List ββ₯0 using hl
have := congr_arg ((β) : ββ₯0 β β) (NNReal.list_prod_map_rpow l r)
push_cast at this
rw [List.map_map] at this β’
exact mod_cast this
theorem _root_.Real.list_prod_map_rpow' {ΞΉ} (l : List ΞΉ) (f : ΞΉ β β)
(hl : β i β l, (0 : β) β€ f i) (r : β) :
(l.map (f Β· ^ r)).prod = (l.map f).prod ^ r := by
rw [β Real.list_prod_map_rpow (l.map f) _ r, List.map_map]
Β· rfl
simpa using hl
/-- `rpow` version of `Multiset.prod_map_pow`. -/
theorem _root_.Real.multiset_prod_map_rpow {ΞΉ} (s : Multiset ΞΉ) (f : ΞΉ β β)
(hs : β i β s, (0 : β) β€ f i) (r : β) :
(s.map (f Β· ^ r)).prod = (s.map f).prod ^ r := by
obtain β¨lβ© := s
simpa using Real.list_prod_map_rpow' l f hs r
/-- `rpow` version of `Finset.prod_pow`. -/
theorem _root_.Real.finset_prod_rpow
{ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β β) (hs : β i β s, 0 β€ f i) (r : β) :
(β i β s, f i ^ r) = (β i β s, f i) ^ r :=
Real.multiset_prod_map_rpow s.val f hs r
end Real
@[gcongr] theorem rpow_le_rpow {x y : ββ₯0} {z : β} (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z :=
Real.rpow_le_rpow x.2 hβ hβ
@[gcongr] theorem rpow_lt_rpow {x y : ββ₯0} {z : β} (hβ : x < y) (hβ : 0 < z) : x ^ z < y ^ z :=
Real.rpow_lt_rpow x.2 hβ hβ
theorem rpow_lt_rpow_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ z < y ^ z β x < y :=
Real.rpow_lt_rpow_iff x.2 y.2 hz
theorem rpow_le_rpow_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
Real.rpow_le_rpow_iff x.2 y.2 hz
theorem le_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
rw [β rpow_le_rpow_iff hz, β one_div, rpow_self_rpow_inv hz.ne']
theorem rpow_inv_le_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
rw [β rpow_le_rpow_iff hz, β one_div, rpow_self_rpow_inv hz.ne']
theorem lt_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^z < y := by
simp only [β not_le, rpow_inv_le_iff hz]
theorem rpow_inv_lt_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z := by
simp only [β not_le, le_rpow_inv_iff hz]
section
variable {y : ββ₯0}
lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z :=
Real.rpow_lt_rpow_of_neg hx hxy hz
lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x β€ y) (hz : z β€ 0) : y ^ z β€ x ^ z :=
Real.rpow_le_rpow_of_nonpos hx hxy hz
lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z β y < x :=
Real.rpow_lt_rpow_iff_of_neg hx hy hz
lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z β€ y ^ z β y β€ x :=
Real.rpow_le_rpow_iff_of_neg hx hy hz
lemma le_rpow_inv_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y :=
Real.le_rpow_inv_iff_of_pos x.2 hy hz
lemma rpow_inv_le_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z :=
Real.rpow_inv_le_iff_of_pos x.2 hy hz
lemma lt_rpow_inv_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x < y ^ zβ»ΒΉ β x ^ z < y :=
Real.lt_rpow_inv_iff_of_pos x.2 hy hz
lemma rpow_inv_lt_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x ^ zβ»ΒΉ < y β x < y ^ z :=
Real.rpow_inv_lt_iff_of_pos x.2 hy hz
lemma le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x β€ y ^ zβ»ΒΉ β y β€ x ^ z :=
Real.le_rpow_inv_iff_of_neg hx hy hz
lemma lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x < y ^ zβ»ΒΉ β y < x ^ z :=
Real.lt_rpow_inv_iff_of_neg hx hy hz
lemma rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ zβ»ΒΉ < y β y ^ z < x :=
Real.rpow_inv_lt_iff_of_neg hx hy hz
lemma rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ zβ»ΒΉ β€ y β y ^ z β€ x :=
Real.rpow_inv_le_iff_of_neg hx hy hz
end
@[gcongr] theorem rpow_lt_rpow_of_exponent_lt {x : ββ₯0} {y z : β} (hx : 1 < x) (hyz : y < z) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_lt hx hyz
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ββ₯0} {y z : β} (hx : 1 β€ x) (hyz : y β€ z) :
x ^ y β€ x ^ z :=
Real.rpow_le_rpow_of_exponent_le hx hyz
theorem rpow_lt_rpow_of_exponent_gt {x : ββ₯0} {y z : β} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz
theorem rpow_le_rpow_of_exponent_ge {x : ββ₯0} {y z : β} (hx0 : 0 < x) (hx1 : x β€ 1) (hyz : z β€ y) :
x ^ y β€ x ^ z :=
Real.rpow_le_rpow_of_exponent_ge hx0 hx1 hyz
theorem rpow_pos {p : β} {x : ββ₯0} (hx_pos : 0 < x) : 0 < x ^ p := by
have rpow_pos_of_nonneg : β {p : β}, 0 < p β 0 < x ^ p := by
intro p hp_pos
rw [β zero_rpow hp_pos.ne']
exact rpow_lt_rpow hx_pos hp_pos
rcases lt_trichotomy (0 : β) p with (hp_pos | rfl | hp_neg)
Β· exact rpow_pos_of_nonneg hp_pos
Β· simp only [zero_lt_one, rpow_zero]
Β· rw [β neg_neg p, rpow_neg, inv_pos]
exact rpow_pos_of_nonneg (neg_pos.mpr hp_neg)
theorem rpow_lt_one {x : ββ₯0} {z : β} (hx1 : x < 1) (hz : 0 < z) : x ^ z < 1 :=
Real.rpow_lt_one (coe_nonneg x) hx1 hz
theorem rpow_le_one {x : ββ₯0} {z : β} (hx2 : x β€ 1) (hz : 0 β€ z) : x ^ z β€ 1 :=
Real.rpow_le_one x.2 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x : ββ₯0} {z : β} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 :=
Real.rpow_lt_one_of_one_lt_of_neg hx hz
theorem rpow_le_one_of_one_le_of_nonpos {x : ββ₯0} {z : β} (hx : 1 β€ x) (hz : z β€ 0) : x ^ z β€ 1 :=
Real.rpow_le_one_of_one_le_of_nonpos hx hz
theorem one_lt_rpow {x : ββ₯0} {z : β} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z :=
Real.one_lt_rpow hx hz
theorem one_le_rpow {x : ββ₯0} {z : β} (h : 1 β€ x) (hβ : 0 β€ z) : 1 β€ x ^ z :=
Real.one_le_rpow h hβ
theorem one_lt_rpow_of_pos_of_lt_one_of_neg {x : ββ₯0} {z : β} (hx1 : 0 < x) (hx2 : x < 1)
(hz : z < 0) : 1 < x ^ z :=
Real.one_lt_rpow_of_pos_of_lt_one_of_neg hx1 hx2 hz
theorem one_le_rpow_of_pos_of_le_one_of_nonpos {x : ββ₯0} {z : β} (hx1 : 0 < x) (hx2 : x β€ 1)
(hz : z β€ 0) : 1 β€ x ^ z :=
Real.one_le_rpow_of_pos_of_le_one_of_nonpos hx1 hx2 hz
theorem rpow_le_self_of_le_one {x : ββ₯0} {z : β} (hx : x β€ 1) (h_one_le : 1 β€ z) : x ^ z β€ x := by
rcases eq_bot_or_bot_lt x with (rfl | (h : 0 < x))
Β· have : z β 0 := by linarith
simp [this]
nth_rw 2 [β NNReal.rpow_one x]
exact NNReal.rpow_le_rpow_of_exponent_ge h hx h_one_le
theorem rpow_left_injective {x : β} (hx : x β 0) : Function.Injective fun y : ββ₯0 => y ^ x :=
fun y z hyz => by simpa only [rpow_inv_rpow_self hx] using congr_arg (fun y => y ^ (1 / x)) hyz
theorem rpow_eq_rpow_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x ^ z = y ^ z β x = y :=
(rpow_left_injective hz).eq_iff
theorem rpow_left_surjective {x : β} (hx : x β 0) : Function.Surjective fun y : ββ₯0 => y ^ x :=
fun y => β¨y ^ xβ»ΒΉ, by simp_rw [β rpow_mul, inv_mul_cancelβ hx, rpow_one]β©
theorem rpow_left_bijective {x : β} (hx : x β 0) : Function.Bijective fun y : ββ₯0 => y ^ x :=
β¨rpow_left_injective hx, rpow_left_surjective hxβ©
theorem eq_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x = y ^ zβ»ΒΉ β x ^ z = y := by
rw [β rpow_eq_rpow_iff hz, β one_div, rpow_self_rpow_inv hz]
theorem rpow_inv_eq_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x ^ zβ»ΒΉ = y β x = y ^ z := by
rw [β rpow_eq_rpow_iff hz, β one_div, rpow_self_rpow_inv hz]
@[simp] lemma rpow_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ y) ^ yβ»ΒΉ = x := by
rw [β rpow_mul, mul_inv_cancelβ hy, rpow_one]
@[simp] lemma rpow_inv_rpow {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ yβ»ΒΉ) ^ y = x := by
rw [β rpow_mul, inv_mul_cancelβ hy, rpow_one]
theorem pow_rpow_inv_natCast (x : ββ₯0) {n : β} (hn : n β 0) : (x ^ n) ^ (nβ»ΒΉ : β) = x := by
rw [β NNReal.coe_inj, coe_rpow, NNReal.coe_pow]
exact Real.pow_rpow_inv_natCast x.2 hn
theorem rpow_inv_natCast_pow (x : ββ₯0) {n : β} (hn : n β 0) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
rw [β NNReal.coe_inj, NNReal.coe_pow, coe_rpow]
exact Real.rpow_inv_natCast_pow x.2 hn
theorem _root_.Real.toNNReal_rpow_of_nonneg {x y : β} (hx : 0 β€ x) :
Real.toNNReal (x ^ y) = Real.toNNReal x ^ y := by
nth_rw 1 [β Real.coe_toNNReal x hx]
rw [β NNReal.coe_rpow, Real.toNNReal_coe]
theorem strictMono_rpow_of_pos {z : β} (h : 0 < z) : StrictMono fun x : ββ₯0 => x ^ z :=
fun x y hxy => by simp only [NNReal.rpow_lt_rpow hxy h]
theorem monotone_rpow_of_nonneg {z : β} (h : 0 β€ z) : Monotone fun x : ββ₯0 => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 βΈ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ββ₯0 => x ^ y` into an order isomorphism when `y : β` is positive,
where the inverse is `fun x : ββ₯0 => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : β) (hy : 0 < y) : ββ₯0 βo ββ₯0 :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [β rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_eq (y : β) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]; rfl
theorem _root_.Real.nnnorm_rpow_of_nonneg {x y : β} (hx : 0 β€ x) : βx ^ yββ = βxββ ^ y := by
ext; exact Real.norm_rpow_of_nonneg hx
end NNReal
namespace ENNReal
/-- The real power function `x^y` on extended nonnegative reals, defined for `x : ββ₯0β` and
`y : β` as the restriction of the real power function if `0 < x < β€`, and with the natural values
for `0` and `β€` (i.e., `0 ^ x = 0` for `x > 0`, `1` for `x = 0` and `β€` for `x < 0`, and
`β€ ^ x = 1 / 0 ^ x`). -/
noncomputable def rpow : ββ₯0β β β β ββ₯0β
| some x, y => if x = 0 β§ y < 0 then β€ else (x ^ y : ββ₯0)
| none, y => if 0 < y then β€ else if y = 0 then 1 else 0
noncomputable instance : Pow ββ₯0β β :=
β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x : ββ₯0β) (y : β) : rpow x y = x ^ y :=
rfl
@[simp]
theorem rpow_zero {x : ββ₯0β} : x ^ (0 : β) = 1 := by
cases x <;>
Β· dsimp only [(Β· ^ Β·), Pow.pow, rpow]
simp
theorem rpow_zero_pos (x : ββ₯0β) : 0 < x ^ (0 : β) := by rw [rpow_zero]; exact one_pos
theorem top_rpow_def (y : β) : (β€ : ββ₯0β) ^ y = if 0 < y then β€ else if y = 0 then 1 else 0 :=
rfl
@[simp]
theorem top_rpow_of_pos {y : β} (h : 0 < y) : (β€ : ββ₯0β) ^ y = β€ := by simp [top_rpow_def, h]
@[simp]
theorem top_rpow_of_neg {y : β} (h : y < 0) : (β€ : ββ₯0β) ^ y = 0 := by
simp [top_rpow_def, asymm h, ne_of_lt h]
@[simp]
theorem zero_rpow_of_pos {y : β} (h : 0 < y) : (0 : ββ₯0β) ^ y = 0 := by
rw [β ENNReal.coe_zero, β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), rpow, Pow.pow]
simp [asymm h, ne_of_gt h]
@[simp]
theorem zero_rpow_of_neg {y : β} (h : y < 0) : (0 : ββ₯0β) ^ y = β€ := by
rw [β ENNReal.coe_zero, β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), rpow, Pow.pow]
simp [h]
theorem zero_rpow_def (y : β) : (0 : ββ₯0β) ^ y = if 0 < y then 0 else if y = 0 then 1 else β€ := by
rcases lt_trichotomy (0 : β) y with (H | rfl | H)
Β· simp [H, zero_rpow_of_pos]
Β· simp
Β· simp [H, asymm H, ne_of_lt, zero_rpow_of_neg]
@[simp]
theorem zero_rpow_mul_self (y : β) : (0 : ββ₯0β) ^ y * (0 : ββ₯0β) ^ y = (0 : ββ₯0β) ^ y := by
rw [zero_rpow_def]
split_ifs
exacts [zero_mul _, one_mul _, top_mul_top]
@[norm_cast]
theorem coe_rpow_of_ne_zero {x : ββ₯0} (h : x β 0) (y : β) : (β(x ^ y) : ββ₯0β) = x ^ y := by
rw [β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), Pow.pow, rpow]
simp [h]
@[norm_cast]
theorem coe_rpow_of_nonneg (x : ββ₯0) {y : β} (h : 0 β€ y) : β(x ^ y) = (x : ββ₯0β) ^ y := by
by_cases hx : x = 0
Β· rcases le_iff_eq_or_lt.1 h with (H | H)
Β· simp [hx, H.symm]
Β· simp [hx, zero_rpow_of_pos H, NNReal.zero_rpow (ne_of_gt H)]
Β· exact coe_rpow_of_ne_zero hx _
theorem coe_rpow_def (x : ββ₯0) (y : β) :
(x : ββ₯0β) ^ y = if x = 0 β§ y < 0 then β€ else β(x ^ y) :=
rfl
theorem rpow_ofNNReal {M : ββ₯0} {P : β} (hP : 0 β€ P) : (M : ββ₯0β) ^ P = β(M ^ P) := by
rw [ENNReal.coe_rpow_of_nonneg _ hP, β ENNReal.rpow_eq_pow]
@[simp]
theorem rpow_one (x : ββ₯0β) : x ^ (1 : β) = x := by
cases x
Β· exact dif_pos zero_lt_one
Β· change ite _ _ _ = _
simp only [NNReal.rpow_one, ite_eq_right_iff, top_ne_coe, and_imp]
exact fun _ => zero_le_one.not_gt
@[simp]
theorem one_rpow (x : β) : (1 : ββ₯0β) ^ x = 1 := by
rw [β coe_one, β coe_rpow_of_ne_zero one_ne_zero]
simp
@[simp]
theorem rpow_eq_zero_iff {x : ββ₯0β} {y : β} : x ^ y = 0 β x = 0 β§ 0 < y β¨ x = β€ β§ y < 0 := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
Β· simp [β coe_rpow_of_ne_zero h, h]
lemma rpow_eq_zero_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y = 0 β x = 0 := by
simp [hy, hy.not_gt]
@[simp]
theorem rpow_eq_top_iff {x : ββ₯0β} {y : β} : x ^ y = β€ β x = 0 β§ y < 0 β¨ x = β€ β§ 0 < y := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
Β· simp [β coe_rpow_of_ne_zero h, h]
theorem rpow_eq_top_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y = β€ β x = β€ := by
simp [rpow_eq_top_iff, hy, asymm hy]
lemma rpow_lt_top_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y < β β x < β := by
simp only [lt_top_iff_ne_top, Ne, rpow_eq_top_iff_of_pos hy]
theorem rpow_eq_top_of_nonneg (x : ββ₯0β) {y : β} (hy0 : 0 β€ y) : x ^ y = β€ β x = β€ := by
simp +contextual [ENNReal.rpow_eq_top_iff, hy0.not_gt]
-- This is an unsafe rule since we want to try `rpow_ne_top_of_ne_zero` if `y < 0`.
@[aesop (rule_sets := [finiteness]) unsafe apply]
theorem rpow_ne_top_of_nonneg {x : ββ₯0β} {y : β} (hy0 : 0 β€ y) (h : x β β€) : x ^ y β β€ :=
mt (ENNReal.rpow_eq_top_of_nonneg x hy0) h
-- This is an unsafe rule since we want to try `rpow_ne_top_of_nonneg'` if `x = 0`.
@[aesop (rule_sets := [finiteness]) unsafe apply]
theorem rpow_ne_top_of_nonneg' {y : β} {x : ββ₯0β} (hx : 0 < x) (hx' : x β β€) : x ^ y β β€ :=
fun h β¦ by simp [rpow_eq_top_iff, hx.ne', hx'] at h
theorem rpow_lt_top_of_nonneg {x : ββ₯0β} {y : β} (hy0 : 0 β€ y) (h : x β β€) : x ^ y < β€ :=
lt_top_iff_ne_top.mpr (ENNReal.rpow_ne_top_of_nonneg hy0 h)
-- This is an unsafe rule since we want to try `rpow_ne_top_of_nonneg` if `x = 0`.
@[aesop (rule_sets := [finiteness]) unsafe apply]
theorem rpow_ne_top_of_ne_zero {x : ββ₯0β} {y : β} (hx : x β 0) (hx' : x β β€) : x ^ y β β€ := by
simp [rpow_eq_top_iff, hx, hx']
theorem rpow_add {x : ββ₯0β} (y z : β) (hx : x β 0) (h'x : x β β€) : x ^ (y + z) = x ^ y * x ^ z := by
cases x with
| top => exact (h'x rfl).elim
| coe x =>
have : x β 0 := fun h => by simp [h] at hx
simp [β coe_rpow_of_ne_zero this, NNReal.rpow_add this]
theorem rpow_add_of_nonneg {x : ββ₯0β} (y z : β) (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
induction x using recTopCoe
Β· rcases hy.eq_or_lt with rfl | hy
Β· rw [rpow_zero, one_mul, zero_add]
rcases hz.eq_or_lt with rfl | hz
Β· rw [rpow_zero, mul_one, add_zero]
simp [top_rpow_of_pos, hy, hz, add_pos hy hz]
simp [β coe_rpow_of_nonneg, hy, hz, add_nonneg hy hz, NNReal.rpow_add_of_nonneg _ hy hz]
lemma rpow_add_of_add_pos {x : ββ₯0β} (hx : x β β€) (y z : β) (hyz : 0 < y + z) :
x ^ (y + z) = x ^ y * x ^ z := by
obtain (rfl | hx') := eq_or_ne x 0
Β· by_cases hy' : 0 < y
Β· simp [ENNReal.zero_rpow_of_pos hyz, ENNReal.zero_rpow_of_pos hy']
Β· have hz' : 0 < z := by linarith
simp [ENNReal.zero_rpow_of_pos hyz, ENNReal.zero_rpow_of_pos hz']
Β· rw [ENNReal.rpow_add _ _ hx' hx]
theorem rpow_neg (x : ββ₯0β) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [top_rpow_of_pos, top_rpow_of_neg, H, neg_pos.mpr]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, zero_rpow_of_pos, zero_rpow_of_neg, H, neg_pos.mpr]
Β· have A : x ^ y β 0 := by simp [h]
simp [β coe_rpow_of_ne_zero h, β coe_inv A, NNReal.rpow_neg]
theorem rpow_sub {x : ββ₯0β} (y z : β) (hx : x β 0) (h'x : x β β€) : x ^ (y - z) = x ^ y / x ^ z := by
rw [sub_eq_add_neg, rpow_add _ _ hx h'x, rpow_neg, div_eq_mul_inv]
theorem rpow_neg_one (x : ββ₯0β) : x ^ (-1 : β) = xβ»ΒΉ := by simp [rpow_neg]
theorem rpow_mul (x : ββ₯0β) (y z : β) : x ^ (y * z) = (x ^ y) ^ z := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, zero_rpow_of_neg, zero_rpow_of_pos, top_rpow_of_neg, top_rpow_of_pos,
mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [h, Hy, Hz, zero_rpow_of_neg, zero_rpow_of_pos, top_rpow_of_neg, top_rpow_of_pos,
mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
Β· have : x ^ y β 0 := by simp [h]
simp [β coe_rpow_of_ne_zero, h, this, NNReal.rpow_mul]
@[simp, norm_cast]
theorem rpow_natCast (x : ββ₯0β) (n : β) : x ^ (n : β) = x ^ n := by
cases x
Β· cases n <;> simp [top_rpow_of_pos (Nat.cast_add_one_pos _), top_pow (Nat.succ_ne_zero _)]
Β· simp [β coe_rpow_of_nonneg _ (Nat.cast_nonneg n)]
@[simp]
lemma rpow_ofNat (x : ββ₯0β) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ (OfNat.ofNat n) :=
rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ββ₯0β) (n : β€) : x ^ (n : β) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
theorem rpow_two (x : ββ₯0β) : x ^ (2 : β) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow_eq_ite (x y : ββ₯0β) (z : β) :
(x * y) ^ z = if (x = 0 β§ y = β€ β¨ x = β€ β§ y = 0) β§ z < 0 then β€ else x ^ z * y ^ z := by
rcases eq_or_ne z 0 with (rfl | hz); Β· simp
replace hz := hz.lt_or_gt
wlog hxy : x β€ y
Β· convert this y x z hz (le_of_not_ge hxy) using 2 <;> simp only [mul_comm, and_comm, or_comm]
rcases eq_or_ne x 0 with (rfl | hx0)
Β· induction y <;> rcases hz with hz | hz <;> simp [*, hz.not_gt]
rcases eq_or_ne y 0 with (rfl | hy0)
Β· exact (hx0 (bot_unique hxy)).elim
induction x
Β· rcases hz with hz | hz <;> simp [hz, top_unique hxy]
induction y
Β· rw [ne_eq, coe_eq_zero] at hx0
rcases hz with hz | hz <;> simp [*]
simp only [*]
norm_cast at *
rw [β coe_rpow_of_ne_zero (mul_ne_zero hx0 hy0), NNReal.mul_rpow]
norm_cast
theorem mul_rpow_of_ne_top {x y : ββ₯0β} (hx : x β β€) (hy : y β β€) (z : β) :
(x * y) ^ z = x ^ z * y ^ z := by simp [*, mul_rpow_eq_ite]
@[norm_cast]
theorem coe_mul_rpow (x y : ββ₯0) (z : β) : ((x : ββ₯0β) * y) ^ z = (x : ββ₯0β) ^ z * (y : ββ₯0β) ^ z :=
mul_rpow_of_ne_top coe_ne_top coe_ne_top z
theorem prod_coe_rpow {ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
β i β s, (f i : ββ₯0β) ^ r = ((β i β s, f i : ββ₯0) : ββ₯0β) ^ r := by
classical
induction s using Finset.induction with
| empty => simp
| insert _ _ hi ih => simp_rw [prod_insert hi, ih, β coe_mul_rpow, coe_mul]
theorem mul_rpow_of_ne_zero {x y : ββ₯0β} (hx : x β 0) (hy : y β 0) (z : β) :
(x * y) ^ z = x ^ z * y ^ z := by simp [*, mul_rpow_eq_ite]
theorem mul_rpow_of_nonneg (x y : ββ₯0β) {z : β} (hz : 0 β€ z) : (x * y) ^ z = x ^ z * y ^ z := by
simp [hz.not_gt, mul_rpow_eq_ite]
theorem prod_rpow_of_ne_top {ΞΉ} {s : Finset ΞΉ} {f : ΞΉ β ββ₯0β} (hf : β i β s, f i β β) (r : β) :
β i β s, f i ^ r = (β i β s, f i) ^ r := by
classical
induction s using Finset.induction with
| empty => simp
| insert i s hi ih =>
have h2f : β i β s, f i β β := fun i hi β¦ hf i <| mem_insert_of_mem hi
rw [prod_insert hi, prod_insert hi, ih h2f, β mul_rpow_of_ne_top <| hf i <| mem_insert_self ..]
apply prod_ne_top h2f
theorem prod_rpow_of_nonneg {ΞΉ} {s : Finset ΞΉ} {f : ΞΉ β ββ₯0β} {r : β} (hr : 0 β€ r) :
β i β s, f i ^ r = (β i β s, f i) ^ r := by
classical
induction s using Finset.induction with
| empty => simp
| insert _ _ hi ih => simp_rw [prod_insert hi, ih, β mul_rpow_of_nonneg _ _ hr]
theorem inv_rpow (x : ββ₯0β) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ := by
rcases eq_or_ne y 0 with (rfl | hy); Β· simp only [rpow_zero, inv_one]
replace hy := hy.lt_or_gt
rcases eq_or_ne x 0 with (rfl | h0); Β· cases hy <;> simp [*]
rcases eq_or_ne x β€ with (rfl | h_top); Β· cases hy <;> simp [*]
apply ENNReal.eq_inv_of_mul_eq_one_left
rw [β mul_rpow_of_ne_zero (ENNReal.inv_ne_zero.2 h_top) h0, ENNReal.inv_mul_cancel h0 h_top,
one_rpow]
theorem div_rpow_of_nonneg (x y : ββ₯0β) {z : β} (hz : 0 β€ z) : (x / y) ^ z = x ^ z / y ^ z := by
rw [div_eq_mul_inv, mul_rpow_of_nonneg _ _ hz, inv_rpow, div_eq_mul_inv]
theorem strictMono_rpow_of_pos {z : β} (h : 0 < z) : StrictMono fun x : ββ₯0β => x ^ z := by
intro x y hxy
lift x to ββ₯0 using ne_top_of_lt hxy
rcases eq_or_ne y β with (rfl | hy)
Β· simp only [top_rpow_of_pos h, β coe_rpow_of_nonneg _ h.le, coe_lt_top]
Β· lift y to ββ₯0 using hy
simp only [β coe_rpow_of_nonneg _ h.le, NNReal.rpow_lt_rpow (coe_lt_coe.1 hxy) h, coe_lt_coe]
theorem monotone_rpow_of_nonneg {z : β} (h : 0 β€ z) : Monotone fun x : ββ₯0β => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 βΈ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ββ₯0β => x ^ y` into an order isomorphism when `y : β` is positive,
where the inverse is `fun x : ββ₯0β => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : β) (hy : 0 < y) : ββ₯0β βo ββ₯0β :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [β rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_apply (y : β) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]
rfl
@[gcongr] theorem rpow_le_rpow {x y : ββ₯0β} {z : β} (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z :=
monotone_rpow_of_nonneg hβ hβ
@[gcongr] theorem rpow_lt_rpow {x y : ββ₯0β} {z : β} (hβ : x < y) (hβ : 0 < z) : x ^ z < y ^ z :=
strictMono_rpow_of_pos hβ hβ
theorem rpow_le_rpow_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
(strictMono_rpow_of_pos hz).le_iff_le
theorem rpow_lt_rpow_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ z < y ^ z β x < y :=
(strictMono_rpow_of_pos hz).lt_iff_lt
lemma max_rpow {x y : ββ₯0β} {p : β} (hp : 0 β€ p) : max x y ^ p = max (x ^ p) (y ^ p) := by
rcases le_total x y with hxy | hxy
Β· rw [max_eq_right hxy, max_eq_right (rpow_le_rpow hxy hp)]
Β· rw [max_eq_left hxy, max_eq_left (rpow_le_rpow hxy hp)]
theorem le_rpow_inv_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
nth_rw 1 [β rpow_one x]
nth_rw 1 [β @mul_inv_cancelβ _ _ z hz.ne']
rw [rpow_mul, @rpow_le_rpow_iff _ _ zβ»ΒΉ (by simp [hz])]
theorem rpow_inv_lt_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z := by
simp only [β not_le, le_rpow_inv_iff hz]
theorem lt_rpow_inv_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^ z < y := by
nth_rw 1 [β rpow_one x]
nth_rw 1 [β @mul_inv_cancelβ _ _ z (ne_of_lt hz).symm]
rw [rpow_mul, @rpow_lt_rpow_iff _ _ zβ»ΒΉ (by simp [hz])]
theorem rpow_inv_le_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
nth_rw 1 [β ENNReal.rpow_one y]
nth_rw 1 [β @mul_inv_cancelβ _ _ z hz.ne.symm]
rw [ENNReal.rpow_mul, ENNReal.rpow_le_rpow_iff (inv_pos.2 hz)]
@[gcongr]
theorem rpow_lt_rpow_of_exponent_lt {x : ββ₯0β} {y z : β} (hx : 1 < x) (hx' : x β β€) (hyz : y < z) :
x ^ y < x ^ z := by
lift x to ββ₯0 using hx'
rw [one_lt_coe_iff] at hx
simp [β coe_rpow_of_ne_zero (ne_of_gt (lt_trans zero_lt_one hx)),
NNReal.rpow_lt_rpow_of_exponent_lt hx hyz]
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ββ₯0β} {y z : β} (hx : 1 β€ x) (hyz : y β€ z) :
x ^ y β€ x ^ z := by
cases x
Β· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, top_rpow_of_neg, top_rpow_of_pos, le_refl] <;>
linarith
Β· simp only [one_le_coe_iff] at hx
simp [β coe_rpow_of_ne_zero (ne_of_gt (lt_of_lt_of_le zero_lt_one hx)),
NNReal.rpow_le_rpow_of_exponent_le hx hyz]
theorem rpow_lt_rpow_of_exponent_gt {x : ββ₯0β} {y z : β} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z := by
lift x to ββ₯0 using ne_of_lt (lt_of_lt_of_le hx1 le_top)
simp only [coe_lt_one_iff, coe_pos] at hx0 hx1
simp [β coe_rpow_of_ne_zero (ne_of_gt hx0), NNReal.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz]
theorem rpow_le_rpow_of_exponent_ge {x : ββ₯0β} {y z : β} (hx1 : x β€ 1) (hyz : z β€ y) :
x ^ y β€ x ^ z := by
lift x to ββ₯0 using ne_of_lt (lt_of_le_of_lt hx1 coe_lt_top)
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, h, zero_rpow_of_neg, zero_rpow_of_pos, le_refl] <;>
linarith
Β· rw [coe_le_one_iff] at hx1
simp [β coe_rpow_of_ne_zero h,
NNReal.rpow_le_rpow_of_exponent_ge (bot_lt_iff_ne_bot.mpr h) hx1 hyz]
theorem rpow_le_self_of_le_one {x : ββ₯0β} {z : β} (hx : x β€ 1) (h_one_le : 1 β€ z) : x ^ z β€ x := by
nth_rw 2 [β ENNReal.rpow_one x]
exact ENNReal.rpow_le_rpow_of_exponent_ge hx h_one_le
theorem le_rpow_self_of_one_le {x : ββ₯0β} {z : β} (hx : 1 β€ x) (h_one_le : 1 β€ z) : x β€ x ^ z := by
nth_rw 1 [β ENNReal.rpow_one x]
exact ENNReal.rpow_le_rpow_of_exponent_le hx h_one_le
theorem rpow_pos_of_nonneg {p : β} {x : ββ₯0β} (hx_pos : 0 < x) (hp_nonneg : 0 β€ p) : 0 < x ^ p := by
by_cases hp_zero : p = 0
Β· simp [hp_zero, zero_lt_one]
Β· rw [β Ne] at hp_zero
have hp_pos := lt_of_le_of_ne hp_nonneg hp_zero.symm
rw [β zero_rpow_of_pos hp_pos]
exact rpow_lt_rpow hx_pos hp_pos
theorem rpow_pos {p : β} {x : ββ₯0β} (hx_pos : 0 < x) (hx_ne_top : x β β€) : 0 < x ^ p := by
rcases lt_or_ge 0 p with hp_pos | hp_nonpos
Β· exact rpow_pos_of_nonneg hx_pos (le_of_lt hp_pos)
Β· rw [β neg_neg p, rpow_neg, ENNReal.inv_pos]
exact rpow_ne_top_of_nonneg (Right.nonneg_neg_iff.mpr hp_nonpos) hx_ne_top
theorem rpow_lt_one {x : ββ₯0β} {z : β} (hx : x < 1) (hz : 0 < z) : x ^ z < 1 := by
lift x to ββ₯0 using ne_of_lt (lt_of_lt_of_le hx le_top)
simp only [coe_lt_one_iff] at hx
simp [β coe_rpow_of_nonneg _ (le_of_lt hz), NNReal.rpow_lt_one hx hz]
theorem rpow_le_one {x : ββ₯0β} {z : β} (hx : x β€ 1) (hz : 0 β€ z) : x ^ z β€ 1 := by
lift x to ββ₯0 using ne_of_lt (lt_of_le_of_lt hx coe_lt_top)
simp only [coe_le_one_iff] at hx
simp [β coe_rpow_of_nonneg _ hz, NNReal.rpow_le_one hx hz]
theorem rpow_lt_one_of_one_lt_of_neg {x : ββ₯0β} {z : β} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by
cases x
Β· simp [top_rpow_of_neg hz, zero_lt_one]
Β· simp only [one_lt_coe_iff] at hx
simp [β coe_rpow_of_ne_zero (ne_of_gt (lt_trans zero_lt_one hx)),
NNReal.rpow_lt_one_of_one_lt_of_neg hx hz]
theorem rpow_le_one_of_one_le_of_neg {x : ββ₯0β} {z : β} (hx : 1 β€ x) (hz : z < 0) : x ^ z β€ 1 := by
cases x
Β· simp [top_rpow_of_neg hz]
Β· simp only [one_le_coe_iff] at hx
simp [β coe_rpow_of_ne_zero (ne_of_gt (lt_of_lt_of_le zero_lt_one hx)),
NNReal.rpow_le_one_of_one_le_of_nonpos hx (le_of_lt hz)]
theorem one_lt_rpow {x : ββ₯0β} {z : β} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by
cases x
Β· simp [top_rpow_of_pos hz]
Β· simp only [one_lt_coe_iff] at hx
simp [β coe_rpow_of_nonneg _ (le_of_lt hz), NNReal.one_lt_rpow hx hz]
theorem one_le_rpow {x : ββ₯0β} {z : β} (hx : 1 β€ x) (hz : 0 < z) : 1 β€ x ^ z := by
cases x
Β· simp [top_rpow_of_pos hz]
Β· simp only [one_le_coe_iff] at hx
simp [β coe_rpow_of_nonneg _ (le_of_lt hz), NNReal.one_le_rpow hx (le_of_lt hz)]
theorem one_lt_rpow_of_pos_of_lt_one_of_neg {x : ββ₯0β} {z : β} (hx1 : 0 < x) (hx2 : x < 1)
(hz : z < 0) : 1 < x ^ z := by
lift x to ββ₯0 using ne_of_lt (lt_of_lt_of_le hx2 le_top)
simp only [coe_lt_one_iff, coe_pos] at hx1 hx2 β’
simp [β coe_rpow_of_ne_zero (ne_of_gt hx1), NNReal.one_lt_rpow_of_pos_of_lt_one_of_neg hx1 hx2 hz]
theorem one_le_rpow_of_pos_of_le_one_of_neg {x : ββ₯0β} {z : β} (hx1 : 0 < x) (hx2 : x β€ 1)
(hz : z < 0) : 1 β€ x ^ z := by
lift x to ββ₯0 using ne_of_lt (lt_of_le_of_lt hx2 coe_lt_top)
simp only [coe_le_one_iff, coe_pos] at hx1 hx2 β’
simp [β coe_rpow_of_ne_zero (ne_of_gt hx1),
NNReal.one_le_rpow_of_pos_of_le_one_of_nonpos hx1 hx2 (le_of_lt hz)]
@[simp] lemma toNNReal_rpow (x : ββ₯0β) (z : β) : (x ^ z).toNNReal = x.toNNReal ^ z := by
rcases lt_trichotomy z 0 with (H | H | H)
Β· cases x with
| top => simp [H, ne_of_lt]
| coe x =>
by_cases hx : x = 0
Β· simp [hx, H, ne_of_lt]
Β· simp [β coe_rpow_of_ne_zero hx]
Β· simp [H]
Β· cases x
Β· simp [H, ne_of_gt]
simp [β coe_rpow_of_nonneg _ (le_of_lt H)]
theorem toReal_rpow (x : ββ₯0β) (z : β) : x.toReal ^ z = (x ^ z).toReal := by
rw [ENNReal.toReal, ENNReal.toReal, β NNReal.coe_rpow, ENNReal.toNNReal_rpow]
theorem ofReal_rpow_of_pos {x p : β} (hx_pos : 0 < x) :
ENNReal.ofReal x ^ p = ENNReal.ofReal (x ^ p) := by
simp_rw [ENNReal.ofReal]
rw [β coe_rpow_of_ne_zero, coe_inj, Real.toNNReal_rpow_of_nonneg hx_pos.le]
simp [hx_pos]
theorem ofReal_rpow_of_nonneg {x p : β} (hx_nonneg : 0 β€ x) (hp_nonneg : 0 β€ p) :
ENNReal.ofReal x ^ p = ENNReal.ofReal (x ^ p) := by
by_cases hp0 : p = 0
Β· simp [hp0]
by_cases hx0 : x = 0
Β· rw [β Ne] at hp0
have hp_pos : 0 < p := lt_of_le_of_ne hp_nonneg hp0.symm
simp [hx0, hp_pos, hp_pos.ne.symm]
rw [β Ne] at hx0
exact ofReal_rpow_of_pos (hx_nonneg.lt_of_ne hx0.symm)
@[simp] lemma rpow_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0β) : (x ^ y) ^ yβ»ΒΉ = x := by
rw [β rpow_mul, mul_inv_cancelβ hy, rpow_one]
@[simp] lemma rpow_inv_rpow {y : β} (hy : y β 0) (x : ββ₯0β) : (x ^ yβ»ΒΉ) ^ y = x := by
rw [β rpow_mul, inv_mul_cancelβ hy, rpow_one]
lemma pow_rpow_inv_natCast {n : β} (hn : n β 0) (x : ββ₯0β) : (x ^ n) ^ (nβ»ΒΉ : β) = x := by
rw [β rpow_natCast, β rpow_mul, mul_inv_cancelβ (by positivity), rpow_one]
lemma rpow_inv_natCast_pow {n : β} (hn : n β 0) (x : ββ₯0β) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
rw [β rpow_natCast, β rpow_mul, inv_mul_cancelβ (by positivity), rpow_one]
lemma rpow_natCast_mul (x : ββ₯0β) (n : β) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_natCast]
lemma rpow_mul_natCast (x : ββ₯0β) (y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_natCast]
lemma rpow_intCast_mul (x : ββ₯0β) (n : β€) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_intCast]
lemma rpow_mul_intCast (x : ββ₯0β) (y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_intCast]
lemma rpow_left_injective {x : β} (hx : x β 0) : Injective fun y : ββ₯0β β¦ y ^ x :=
HasLeftInverse.injective β¨fun y β¦ y ^ xβ»ΒΉ, rpow_rpow_inv hxβ©
theorem rpow_left_surjective {x : β} (hx : x β 0) : Function.Surjective fun y : ββ₯0β => y ^ x :=
HasRightInverse.surjective β¨fun y β¦ y ^ xβ»ΒΉ, rpow_inv_rpow hxβ©
theorem rpow_left_bijective {x : β} (hx : x β 0) : Function.Bijective fun y : ββ₯0β => y ^ x :=
β¨rpow_left_injective hx, rpow_left_surjective hxβ©
lemma _root_.Real.enorm_rpow_of_nonneg {x y : β} (hx : 0 β€ x) (hy : 0 β€ y) :
βx ^ yββ = βxββ ^ y := by simp [enorm, nnnorm_rpow_of_nonneg hx, coe_rpow_of_nonneg _ hy]
lemma add_rpow_le_two_rpow_mul_rpow_add_rpow {p : β} (a b : ββ₯0β) (hp : 0 β€ p) :
(a + b) ^ p β€ 2 ^ p * (a ^ p + b ^ p) := calc
(a + b) ^ p β€ (2 * max a b) ^ p := by rw [two_mul]; gcongr <;> simp
_ = 2 ^ p * (max a b) ^ p := mul_rpow_of_nonneg _ _ hp
_ = 2 ^ p * max (a ^ p) (b ^ p) := by rw [max_rpow hp]
_ β€ 2 ^ p * (a ^ p + b ^ p) := by gcongr; apply max_le_add_of_nonneg <;> simp
end ENNReal
-- Porting note(https://github.com/leanprover-community/mathlib4/issues/6038): restore
-- section Tactics
-- /-!
-- ## Tactic extensions for powers on `ββ₯0` and `ββ₯0β`
-- -/
-- namespace NormNum
-- theorem nnrpow_pos (a : ββ₯0) (b : β) (b' : β) (c : ββ₯0) (hb : b = b') (h : a ^ b' = c) :
-- a ^ b = c := by rw [β h, hb, NNReal.rpow_natCast]
-- theorem nnrpow_neg (a : ββ₯0) (b : β) (b' : β) (c c' : ββ₯0) (hb : b = b') (h : a ^ b' = c)
-- (hc : cβ»ΒΉ = c') : a ^ (-b) = c' := by
-- rw [β hc, β h, hb, NNReal.rpow_neg, NNReal.rpow_natCast]
-- theorem ennrpow_pos (a : ββ₯0β) (b : β) (b' : β) (c : ββ₯0β) (hb : b = b') (h : a ^ b' = c) :
-- a ^ b = c := by rw [β h, hb, ENNReal.rpow_natCast]
-- theorem ennrpow_neg (a : ββ₯0β) (b : β) (b' : β) (c c' : ββ₯0β) (hb : b = b') (h : a ^ b' = c)
-- (hc : cβ»ΒΉ = c') : a ^ (-b) = c' := by
-- rw [β hc, β h, hb, ENNReal.rpow_neg, ENNReal.rpow_natCast]
-- /-- Evaluate `NNReal.rpow a b` where `a` is a rational numeral and `b` is an integer. -/
-- unsafe def prove_nnrpow : expr β expr β tactic (expr Γ expr) :=
-- prove_rpow' `` nnrpow_pos `` nnrpow_neg `` NNReal.rpow_zero q(ββ₯0) q(β) q((1 : ββ₯0))
-- /-- Evaluate `ENNReal.rpow a b` where `a` is a rational numeral and `b` is an integer. -/
-- unsafe def prove_ennrpow : expr β expr β tactic (expr Γ expr) :=
-- prove_rpow' `` ennrpow_pos `` ennrpow_neg `` ENNReal.rpow_zero q(ββ₯0β) q(β) q((1 : ββ₯0β))
-- /-- Evaluates expressions of the form `rpow a b` and `a ^ b` in the special case where
-- `b` is an integer and `a` is a positive rational (so it's really just a rational power). -/
-- @[norm_num]
-- unsafe def eval_nnrpow_ennrpow : expr β tactic (expr Γ expr)
-- | q(@Pow.pow _ _ NNReal.Real.hasPow $(a) $(b)) => b.to_int >> prove_nnrpow a b
-- | q(NNReal.rpow $(a) $(b)) => b.to_int >> prove_nnrpow a b
-- | q(@Pow.pow _ _ ENNReal.Real.hasPow $(a) $(b)) => b.to_int >> prove_ennrpow a b
-- | q(ENNReal.rpow $(a) $(b)) => b.to_int >> prove_ennrpow a b
-- | _ => tactic.failed
-- end NormNum
-- namespace Tactic
-- namespace Positivity
-- private theorem nnrpow_pos {a : ββ₯0} (ha : 0 < a) (b : β) : 0 < a ^ b :=
-- NNReal.rpow_pos ha
-- /-- Auxiliary definition for the `positivity` tactic to handle real powers of nonnegative reals.
-- -/
-- unsafe def prove_nnrpow (a b : expr) : tactic strictness := do
-- let strictness_a β core a
-- match strictness_a with
-- | positive p => positive <$> mk_app `` nnrpow_pos [p, b]
-- | _ => failed
-- -- We already know `0 β€ x` for all `x : ββ₯0`
-- private theorem ennrpow_pos {a : ββ₯0β} {b : β} (ha : 0 < a) (hb : 0 < b) : 0 < a ^ b :=
-- ENNReal.rpow_pos_of_nonneg ha hb.le
-- /-- Auxiliary definition for the `positivity` tactic to handle real powers of extended
-- nonnegative reals. -/
-- unsafe def prove_ennrpow (a b : expr) : tactic strictness := do
-- let strictness_a β core a
-- let strictness_b β core b
-- match strictness_a, strictness_b with
-- | positive pa, positive pb => positive <$> mk_app `` ennrpow_pos [pa, pb]
-- | positive pa, nonnegative pb => positive <$> mk_app `` ENNReal.rpow_pos_of_nonneg [pa, pb]
-- | _, _ => failed
-- -- We already know `0 β€ x` for all `x : ββ₯0β`
-- end Positivity
-- open Positivity
-- /-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
-- the base is nonnegative and positive when the base is positive. -/
-- @[positivity]
-- unsafe def positivity_nnrpow_ennrpow : expr β tactic strictness
-- | q(@Pow.pow _ _ NNReal.Real.hasPow $(a) $(b)) => prove_nnrpow a b
-- | q(NNReal.rpow $(a) $(b)) => prove_nnrpow a b
-- | q(@Pow.pow _ _ ENNReal.Real.hasPow $(a) $(b)) => prove_ennrpow a b
-- | q(ENNReal.rpow $(a) $(b)) => prove_ennrpow a b
-- | _ => failed
-- end Tactic
-- end Tactics
/-! ### Positivity extension -/
namespace Mathlib.Meta.Positivity
open Lean Meta Qq
/-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
the base is nonnegative and positive when the base is positive.
This is the `NNReal` analogue of `evalRpow` for `Real`. -/
@[positivity (_ : ββ₯0) ^ (_ : β)]
def evalNNRealRpow : PositivityExt where eval {u Ξ±} _ _ e := do
match u, Ξ±, e with
| 0, ~q(ββ₯0), ~q($a ^ (0 : β)) =>
assertInstancesCommute
pure (.positive q(NNReal.rpow_zero_pos $a))
| 0, ~q(ββ₯0), ~q($a ^ ($b : β)) =>
let ra β core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa =>
pure (.positive q(NNReal.rpow_pos $pa))
| _ => pure (.nonnegative q(zero_le $e))
| _, _, _ => throwError "not NNReal.rpow"
private def isFiniteM? (x : Q(ββ₯0β)) : MetaM (Option Q($x β (β€ : ββ₯0β))) := do
let mvar β mkFreshExprMVar q($x β (β€ : ββ₯0β))
let save β saveState
let (goals, _) β Elab.runTactic mvar.mvarId! <|β `(tactic| finiteness)
if goals.isEmpty then
pure <| some <|β instantiateMVars mvar
else
restoreState save
pure none
/-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
the base is nonnegative and positive when the base is positive.
This is the `ENNReal` analogue of `evalRpow` for `Real`. -/
@[positivity (_ : ββ₯0β) ^ (_ : β)]
def evalENNRealRpow : PositivityExt where eval {u Ξ±} _ _ e := do
match u, Ξ±, e with
| 0, ~q(ββ₯0β), ~q($a ^ (0 : β)) =>
assertInstancesCommute
pure (.positive q(ENNReal.rpow_zero_pos $a))
| 0, ~q(ββ₯0β), ~q($a ^ ($b : β)) =>
let ra β core q(inferInstance) q(inferInstance) a
let rb β catchNone <| core q(inferInstance) q(inferInstance) b
assertInstancesCommute
match ra, rb with
| .positive pa, .positive pb =>
pure (.positive q(ENNReal.rpow_pos_of_nonneg $pa <| le_of_lt $pb))
| .positive pa, .nonnegative pb =>
pure (.positive q(ENNReal.rpow_pos_of_nonneg $pa $pb))
| .positive pa, _ =>
let some ha β isFiniteM? a | pure <| .nonnegative q(zero_le $e)
pure <| .positive q(ENNReal.rpow_pos $pa $ha)
| _, _ => pure <| .nonnegative q(zero_le $e)
| _, _, _ => throwError "not ENNReal.rpow"
end Mathlib.Meta.Positivity |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean | import Mathlib.Analysis.SpecialFunctions.Pow.Complex
import Mathlib.Data.Nat.NthRoot.Defs
import Qq
/-! # Power function on `β`
We construct the power functions `x ^ y`, where `x` and `y` are real numbers.
-/
noncomputable section
open Real ComplexConjugate Finset Set
/-
## Definitions
-/
namespace Real
variable {x y z : β}
/-- The real power function `x ^ y`, defined as the real part of the complex power function.
For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for
`y β 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex
determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (Ο y)`. -/
noncomputable def rpow (x y : β) :=
((x : β) ^ (y : β)).re
noncomputable instance : Pow β β := β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x y : β) : rpow x y = x ^ y := rfl
theorem rpow_def (x y : β) : x ^ y = ((x : β) ^ (y : β)).re := rfl
theorem rpow_def_of_nonneg {x : β} (hx : 0 β€ x) (y : β) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by
simp only [rpow_def, Complex.cpow_def]; split_ifs <;>
simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul,
(Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero]
theorem rpow_def_of_pos {x : β} (hx : 0 < x) (y : β) : x ^ y = exp (log x * y) := by
rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)]
theorem exp_mul (x y : β) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp]
@[simp, norm_cast]
theorem rpow_intCast (x : β) (n : β€) : x ^ (n : β) = x ^ n := by
simp only [rpow_def, β Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast,
Complex.ofReal_re]
@[simp, norm_cast]
theorem rpow_natCast (x : β) (n : β) : x ^ (n : β) = x ^ n := by simpa using rpow_intCast x n
@[simp, norm_cast]
theorem rpow_neg_natCast (x : β) (n : β) : x ^ (-n : β) = x ^ (-n : β€) := by
rw [β rpow_intCast, Int.cast_neg, Int.cast_natCast]
@[simp]
lemma rpow_ofNat (x : β) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ (ofNat(n) : β) :=
rpow_natCast x n
@[simp]
theorem rpow_neg_ofNat (x : β) (n : β) [n.AtLeastTwo] : x ^ (-ofNat(n) : β) = x ^ (-ofNat(n) : β€) :=
rpow_neg_natCast _ _
@[simp]
theorem exp_one_rpow (x : β) : exp 1 ^ x = exp x := by rw [β exp_mul, one_mul]
@[simp] lemma exp_one_pow (n : β) : exp 1 ^ n = exp n := by rw [β rpow_natCast, exp_one_rpow]
theorem rpow_eq_zero_iff_of_nonneg (hx : 0 β€ x) : x ^ y = 0 β x = 0 β§ y β 0 := by
simp only [rpow_def_of_nonneg hx]
split_ifs <;> simp [*, exp_ne_zero]
@[simp]
lemma rpow_eq_zero (hx : 0 β€ x) (hy : y β 0) : x ^ y = 0 β x = 0 := by
simp [rpow_eq_zero_iff_of_nonneg, *]
lemma rpow_ne_zero (hx : 0 β€ x) (hy : y β 0) : x ^ y β 0 β x β 0 := by
simp [hx, hy]
open Real
theorem rpow_def_of_neg {x : β} (hx : x < 0) (y : β) : x ^ y = exp (log x * y) * cos (y * Ο) := by
rw [rpow_def, Complex.cpow_def, if_neg]
Β· have : Complex.log x * y = β(log (-x) * y) + β(y * Ο) * Complex.I := by
simp only [Complex.log, Complex.norm_real, norm_eq_abs, abs_of_neg hx, log_neg_eq_log,
Complex.arg_ofReal_of_neg hx, Complex.ofReal_mul]
ring
rw [this, Complex.exp_add_mul_I, β Complex.ofReal_exp, β Complex.ofReal_cos, β
Complex.ofReal_sin, mul_add, β Complex.ofReal_mul, β mul_assoc, β Complex.ofReal_mul,
Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im,
Real.log_neg_eq_log]
ring
Β· rw [Complex.ofReal_eq_zero]
exact ne_of_lt hx
theorem rpow_def_of_nonpos {x : β} (hx : x β€ 0) (y : β) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * Ο) := by
split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _
@[bound]
theorem rpow_pos_of_pos {x : β} (hx : 0 < x) (y : β) : 0 < x ^ y := by
rw [rpow_def_of_pos hx]; apply exp_pos
@[simp]
theorem rpow_zero (x : β) : x ^ (0 : β) = 1 := by simp [rpow_def]
theorem rpow_zero_pos (x : β) : 0 < x ^ (0 : β) := by simp
@[simp]
theorem zero_rpow {x : β} (h : x β 0) : (0 : β) ^ x = 0 := by simp [rpow_def, *]
theorem zero_rpow_eq_iff {x : β} {a : β} : 0 ^ x = a β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
constructor
Β· intro hyp
simp only [rpow_def, Complex.ofReal_zero] at hyp
by_cases h : x = 0
Β· subst h
simp only [Complex.one_re, Complex.ofReal_zero, Complex.cpow_zero] at hyp
exact Or.inr β¨rfl, hyp.symmβ©
Β· rw [Complex.zero_cpow (Complex.ofReal_ne_zero.mpr h)] at hyp
exact Or.inl β¨h, hyp.symmβ©
Β· rintro (β¨h, rflβ© | β¨rfl, rflβ©)
Β· exact zero_rpow h
Β· exact rpow_zero _
theorem eq_zero_rpow_iff {x : β} {a : β} : a = 0 ^ x β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
rw [β zero_rpow_eq_iff, eq_comm]
@[simp]
theorem rpow_one (x : β) : x ^ (1 : β) = x := by simp [rpow_def]
@[simp]
theorem one_rpow (x : β) : (1 : β) ^ x = 1 := by simp [rpow_def]
theorem zero_rpow_le_one (x : β) : (0 : β) ^ x β€ 1 := by
by_cases h : x = 0 <;> simp [h, zero_le_one]
theorem zero_rpow_nonneg (x : β) : 0 β€ (0 : β) ^ x := by
by_cases h : x = 0 <;> simp [h, zero_le_one]
@[bound]
theorem rpow_nonneg {x : β} (hx : 0 β€ x) (y : β) : 0 β€ x ^ y := by
rw [rpow_def_of_nonneg hx]; split_ifs <;>
simp only [zero_le_one, le_refl, le_of_lt (exp_pos _)]
theorem abs_rpow_of_nonneg {x y : β} (hx_nonneg : 0 β€ x) : |x ^ y| = |x| ^ y := by
have h_rpow_nonneg : 0 β€ x ^ y := Real.rpow_nonneg hx_nonneg _
rw [abs_eq_self.mpr hx_nonneg, abs_eq_self.mpr h_rpow_nonneg]
@[bound]
theorem abs_rpow_le_abs_rpow (x y : β) : |x ^ y| β€ |x| ^ y := by
rcases le_or_gt 0 x with hx | hx
Β· rw [abs_rpow_of_nonneg hx]
Β· rw [abs_of_neg hx, rpow_def_of_neg hx, rpow_def_of_pos (neg_pos.2 hx), log_neg_eq_log, abs_mul,
abs_of_pos (exp_pos _)]
exact mul_le_of_le_one_right (exp_pos _).le (abs_cos_le_one _)
theorem abs_rpow_le_exp_log_mul (x y : β) : |x ^ y| β€ exp (log x * y) := by
refine (abs_rpow_le_abs_rpow x y).trans ?_
by_cases hx : x = 0
Β· by_cases hy : y = 0 <;> simp [hx, hy, zero_le_one]
Β· rw [rpow_def_of_pos (abs_pos.2 hx), log_abs]
lemma rpow_inv_log (hxβ : 0 < x) (hxβ : x β 1) : x ^ (log x)β»ΒΉ = exp 1 := by
rw [rpow_def_of_pos hxβ, mul_inv_cancelβ]
exact log_ne_zero.2 β¨hxβ.ne', hxβ, by boundβ©
/-- See `Real.rpow_inv_log` for the equality when `x β 1` is strictly positive. -/
lemma rpow_inv_log_le_exp_one : x ^ (log x)β»ΒΉ β€ exp 1 := by
calc
_ β€ |x ^ (log x)β»ΒΉ| := le_abs_self _
_ β€ |x| ^ (log x)β»ΒΉ := abs_rpow_le_abs_rpow ..
rw [β log_abs]
obtain hx | hx := (abs_nonneg x).eq_or_lt'
Β· simp [hx]
Β· rw [rpow_def_of_pos hx]
gcongr
exact mul_inv_le_one
theorem norm_rpow_of_nonneg {x y : β} (hx_nonneg : 0 β€ x) : βx ^ yβ = βxβ ^ y := by
simp_rw [Real.norm_eq_abs]
exact abs_rpow_of_nonneg hx_nonneg
variable {w x y z : β}
theorem rpow_add (hx : 0 < x) (y z : β) : x ^ (y + z) = x ^ y * x ^ z := by
simp only [rpow_def_of_pos hx, mul_add, exp_add]
theorem rpow_add' (hx : 0 β€ x) (h : y + z β 0) : x ^ (y + z) = x ^ y * x ^ z := by
rcases hx.eq_or_lt with (rfl | pos)
Β· rw [zero_rpow h, zero_eq_mul]
have : y β 0 β¨ z β 0 := not_and_or.1 fun β¨hy, hzβ© => h <| hy.symm βΈ hz.symm βΈ zero_add 0
exact this.imp zero_rpow zero_rpow
Β· exact rpow_add pos _ _
/-- Variant of `Real.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (hx : 0 β€ x) (hw : w β 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [β h, rpow_add' hx]; rwa [h]
theorem rpow_add_of_nonneg (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
rcases hy.eq_or_lt with (rfl | hy)
Β· rw [zero_add, rpow_zero, one_mul]
exact rpow_add' hx (ne_of_gt <| add_pos_of_pos_of_nonneg hy hz)
/-- For `0 β€ x`, the only problematic case in the equality `x ^ y * x ^ z = x ^ (y + z)` is for
`x = 0` and `y + z = 0`, where the right-hand side is `1` while the left-hand side can vanish.
The inequality is always true, though, and given in this lemma. -/
theorem le_rpow_add {x : β} (hx : 0 β€ x) (y z : β) : x ^ y * x ^ z β€ x ^ (y + z) := by
rcases le_iff_eq_or_lt.1 hx with (H | pos)
Β· by_cases h : y + z = 0
Β· simp only [H.symm, h, rpow_zero]
calc
(0 : β) ^ y * 0 ^ z β€ 1 * 1 :=
mul_le_mul (zero_rpow_le_one y) (zero_rpow_le_one z) (zero_rpow_nonneg z) zero_le_one
_ = 1 := by simp
Β· simp [rpow_add', β H, h]
Β· simp [rpow_add pos]
theorem rpow_sum_of_pos {ΞΉ : Type*} {a : β} (ha : 0 < a) (f : ΞΉ β β) (s : Finset ΞΉ) :
(a ^ β x β s, f x) = β x β s, a ^ f x :=
map_sum (β¨β¨fun (x : β) => (a ^ x : β), rpow_zero aβ©, rpow_add haβ© : β β+ (Additive β)) f s
theorem rpow_sum_of_nonneg {ΞΉ : Type*} {a : β} (ha : 0 β€ a) {s : Finset ΞΉ} {f : ΞΉ β β}
(h : β x β s, 0 β€ f x) : (a ^ β x β s, f x) = β x β s, a ^ f x := by
induction s using Finset.cons_induction with
| empty => rw [sum_empty, Finset.prod_empty, rpow_zero]
| cons i s hi ihs =>
rw [forall_mem_cons] at h
rw [sum_cons, prod_cons, β ihs h.2, rpow_add_of_nonneg ha h.1 (sum_nonneg h.2)]
/-- See also `rpow_neg` for a version with `(x ^ y)β»ΒΉ` in the RHS. -/
theorem rpow_neg_eq_inv_rpow (x y : β) : x ^ (-y) = xβ»ΒΉ ^ y := by
simp [rpow_def, Complex.cpow_neg, Complex.inv_cpow_eq_ite, apply_ite]
/-- See also `rpow_neg_eq_inv_rpow` for a version with `xβ»ΒΉ ^ y` in the RHS. -/
theorem rpow_neg {x : β} (hx : 0 β€ x) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ := by
simp only [rpow_def_of_nonneg hx]; split_ifs <;> simp_all [exp_neg]
theorem rpow_sub {x : β} (hx : 0 < x) (y z : β) : x ^ (y - z) = x ^ y / x ^ z := by
simp only [sub_eq_add_neg, rpow_add hx, rpow_neg (le_of_lt hx), div_eq_mul_inv]
theorem rpow_sub' {x : β} (hx : 0 β€ x) {y z : β} (h : y - z β 0) : x ^ (y - z) = x ^ y / x ^ z := by
simp only [sub_eq_add_neg] at h β’
simp only [rpow_add' hx h, rpow_neg hx, div_eq_mul_inv]
protected theorem _root_.HasCompactSupport.rpow_const {Ξ± : Type*} [TopologicalSpace Ξ±] {f : Ξ± β β}
(hf : HasCompactSupport f) {r : β} (hr : r β 0) : HasCompactSupport (fun x β¦ f x ^ r) :=
hf.comp_left (g := (Β· ^ r)) (Real.zero_rpow hr)
end Real
/-!
## Comparing real and complex powers
-/
namespace Complex
theorem ofReal_cpow {x : β} (hx : 0 β€ x) (y : β) : ((x ^ y : β) : β) = (x : β) ^ (y : β) := by
simp only [Real.rpow_def_of_nonneg hx, Complex.cpow_def, ofReal_eq_zero]; split_ifs <;>
simp [Complex.ofReal_log hx]
theorem ofReal_cpow_of_nonpos {x : β} (hx : x β€ 0) (y : β) :
(x : β) ^ y = (-x : β) ^ y * exp (Ο * I * y) := by
rcases hx.eq_or_lt with (rfl | hlt)
Β· rcases eq_or_ne y 0 with (rfl | hy) <;> simp [*]
have hne : (x : β) β 0 := ofReal_ne_zero.mpr hlt.ne
rw [cpow_def_of_ne_zero hne, cpow_def_of_ne_zero (neg_ne_zero.2 hne), β exp_add, β add_mul, log,
log, norm_neg, arg_ofReal_of_neg hlt, β ofReal_neg, arg_ofReal_of_nonneg (neg_nonneg.2 hx),
ofReal_zero, zero_mul, add_zero]
lemma cpow_ofReal (x : β) (y : β) :
x ^ (y : β) = β(βxβ ^ y) * (Real.cos (arg x * y) + Real.sin (arg x * y) * I) := by
rcases eq_or_ne x 0 with rfl | hx
Β· simp [ofReal_cpow le_rfl]
Β· rw [cpow_def_of_ne_zero hx, exp_eq_exp_re_mul_sin_add_cos, mul_comm (log x)]
norm_cast
rw [re_ofReal_mul, im_ofReal_mul, log_re, log_im, mul_comm y, mul_comm y, Real.exp_mul,
Real.exp_log]
rwa [norm_pos_iff]
lemma cpow_ofReal_re (x : β) (y : β) : (x ^ (y : β)).re = βxβ ^ y * Real.cos (arg x * y) := by
rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.cos]
lemma cpow_ofReal_im (x : β) (y : β) : (x ^ (y : β)).im = βxβ ^ y * Real.sin (arg x * y) := by
rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.sin]
theorem norm_cpow_of_ne_zero {z : β} (hz : z β 0) (w : β) :
βz ^ wβ = βzβ ^ w.re / Real.exp (arg z * im w) := by
rw [cpow_def_of_ne_zero hz, norm_exp, mul_re, log_re, log_im, Real.exp_sub,
Real.rpow_def_of_pos (norm_pos_iff.mpr hz)]
theorem norm_cpow_of_imp {z w : β} (h : z = 0 β w.re = 0 β w = 0) :
βz ^ wβ = βzβ ^ w.re / Real.exp (arg z * im w) := by
rcases ne_or_eq z 0 with (hz | rfl) <;> [exact norm_cpow_of_ne_zero hz w; rw [norm_zero]]
rcases eq_or_ne w.re 0 with hw | hw
Β· simp [h rfl hw]
Β· rw [Real.zero_rpow hw, zero_div, zero_cpow, norm_zero]
exact ne_of_apply_ne re hw
theorem norm_cpow_le (z w : β) : βz ^ wβ β€ βzβ ^ w.re / Real.exp (arg z * im w) := by
by_cases! h : z = 0 β w.re = 0 β w = 0
Β· exact (norm_cpow_of_imp h).le
Β· simp [h]
@[simp]
theorem norm_cpow_real (x : β) (y : β) : βx ^ (y : β)β = βxβ ^ y := by
rw [norm_cpow_of_imp] <;> simp
@[simp]
theorem norm_cpow_inv_nat (x : β) (n : β) : βx ^ (nβ»ΒΉ : β)β = βxβ ^ (nβ»ΒΉ : β) := by
rw [β norm_cpow_real]; simp
theorem norm_cpow_eq_rpow_re_of_pos {x : β} (hx : 0 < x) (y : β) : β(x : β) ^ yβ = x ^ y.re := by
rw [norm_cpow_of_ne_zero (ofReal_ne_zero.mpr hx.ne'), arg_ofReal_of_nonneg hx.le,
zero_mul, Real.exp_zero, div_one, Complex.norm_of_nonneg hx.le]
theorem norm_cpow_eq_rpow_re_of_nonneg {x : β} (hx : 0 β€ x) {y : β} (hy : re y β 0) :
β(x : β) ^ yβ = x ^ re y := by
rw [norm_cpow_of_imp] <;> simp [*, arg_ofReal_of_nonneg, abs_of_nonneg]
open Filter in
lemma norm_ofReal_cpow_eventually_eq_atTop (c : β) :
(fun t : β β¦ β(t : β) ^ cβ) =αΆ [atTop] fun t β¦ t ^ c.re := by
filter_upwards [eventually_gt_atTop 0] with t ht
rw [norm_cpow_eq_rpow_re_of_pos ht]
lemma norm_natCast_cpow_of_re_ne_zero (n : β) {s : β} (hs : s.re β 0) :
β(n : β) ^ sβ = (n : β) ^ (s.re) := by
rw [β ofReal_natCast, norm_cpow_eq_rpow_re_of_nonneg n.cast_nonneg hs]
lemma norm_natCast_cpow_of_pos {n : β} (hn : 0 < n) (s : β) :
β(n : β) ^ sβ = (n : β) ^ (s.re) := by
rw [β ofReal_natCast, norm_cpow_eq_rpow_re_of_pos (Nat.cast_pos.mpr hn) _]
lemma norm_natCast_cpow_pos_of_pos {n : β} (hn : 0 < n) (s : β) : 0 < β(n : β) ^ sβ :=
(norm_natCast_cpow_of_pos hn _).symm βΈ Real.rpow_pos_of_pos (Nat.cast_pos.mpr hn) _
theorem cpow_mul_ofReal_nonneg {x : β} (hx : 0 β€ x) (y : β) (z : β) :
(x : β) ^ (βy * z) = (β(x ^ y) : β) ^ z := by
rw [cpow_mul, ofReal_cpow hx]
Β· rw [β ofReal_log hx, β ofReal_mul, ofReal_im, neg_lt_zero]; exact Real.pi_pos
Β· rw [β ofReal_log hx, β ofReal_mul, ofReal_im]; exact Real.pi_pos.le
end Complex
/-! ### Positivity extension -/
namespace Mathlib.Meta.Positivity
open Lean Meta Qq
/-- Extension for the `positivity` tactic: exponentiation by a real number is positive (namely 1)
when the exponent is zero. The other cases are done in `evalRpow`. -/
@[positivity (_ : β) ^ (0 : β)]
def evalRpowZero : PositivityExt where eval {u Ξ±} _ _ e := do
match u, Ξ±, e with
| 0, ~q(β), ~q($a ^ (0 : β)) =>
assertInstancesCommute
pure (.positive q(Real.rpow_zero_pos $a))
| _, _, _ => throwError "not Real.rpow"
/-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
the base is nonnegative and positive when the base is positive. -/
@[positivity (_ : β) ^ (_ : β)]
def evalRpow : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q($a ^ ($b : β)) =>
let ra β core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa =>
pure (.positive q(Real.rpow_pos_of_pos $pa $b))
| .nonnegative pa =>
pure (.nonnegative q(Real.rpow_nonneg $pa $b))
| _ => pure .none
| _, _, _ => throwError "not Real.rpow"
end Mathlib.Meta.Positivity
/-!
## Further algebraic properties of `rpow`
-/
namespace Real
variable {x y z : β} {n : β}
theorem rpow_mul {x : β} (hx : 0 β€ x) (y z : β) : x ^ (y * z) = (x ^ y) ^ z := by
rw [β Complex.ofReal_inj, Complex.ofReal_cpow (rpow_nonneg hx _),
Complex.ofReal_cpow hx, Complex.ofReal_mul, Complex.cpow_mul, Complex.ofReal_cpow hx] <;>
simp only [(Complex.ofReal_mul _ _).symm, (Complex.ofReal_log hx).symm, Complex.ofReal_im,
neg_lt_zero, pi_pos, le_of_lt pi_pos]
lemma rpow_pow_comm {x : β} (hx : 0 β€ x) (y : β) (n : β) : (x ^ y) ^ n = (x ^ n) ^ y := by
simp_rw [β rpow_natCast, β rpow_mul hx, mul_comm y]
lemma rpow_zpow_comm {x : β} (hx : 0 β€ x) (y : β) (n : β€) : (x ^ y) ^ n = (x ^ n) ^ y := by
simp_rw [β rpow_intCast, β rpow_mul hx, mul_comm y]
lemma rpow_add_intCast {x : β} (hx : x β 0) (y : β) (n : β€) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_def, rpow_def, Complex.ofReal_add,
Complex.cpow_add _ _ (Complex.ofReal_ne_zero.mpr hx), Complex.ofReal_intCast,
Complex.cpow_intCast, β Complex.ofReal_zpow, mul_comm, Complex.re_ofReal_mul, mul_comm]
lemma rpow_add_natCast {x : β} (hx : x β 0) (y : β) (n : β) : x ^ (y + n) = x ^ y * x ^ n := by
simpa using rpow_add_intCast hx y n
lemma rpow_sub_intCast {x : β} (hx : x β 0) (y : β) (n : β€) : x ^ (y - n) = x ^ y / x ^ n := by
simpa using rpow_add_intCast hx y (-n)
lemma rpow_sub_natCast {x : β} (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
simpa using rpow_sub_intCast hx y n
lemma rpow_add_intCast' (hx : 0 β€ x) {n : β€} (h : y + n β 0) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_add' hx h, rpow_intCast]
lemma rpow_add_natCast' (hx : 0 β€ x) (h : y + n β 0) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_add' hx h, rpow_natCast]
lemma rpow_sub_intCast' (hx : 0 β€ x) {n : β€} (h : y - n β 0) : x ^ (y - n) = x ^ y / x ^ n := by
rw [rpow_sub' hx h, rpow_intCast]
lemma rpow_sub_natCast' (hx : 0 β€ x) (h : y - n β 0) : x ^ (y - n) = x ^ y / x ^ n := by
rw [rpow_sub' hx h, rpow_natCast]
theorem rpow_add_one {x : β} (hx : x β 0) (y : β) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_natCast hx y 1
theorem rpow_sub_one {x : β} (hx : x β 0) (y : β) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_natCast hx y 1
lemma rpow_add_one' (hx : 0 β€ x) (h : y + 1 β 0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' hx h, rpow_one]
lemma rpow_one_add' (hx : 0 β€ x) (h : 1 + y β 0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' hx h, rpow_one]
lemma rpow_sub_one' (hx : 0 β€ x) (h : y - 1 β 0) : x ^ (y - 1) = x ^ y / x := by
rw [rpow_sub' hx h, rpow_one]
lemma rpow_one_sub' (hx : 0 β€ x) (h : 1 - y β 0) : x ^ (1 - y) = x / x ^ y := by
rw [rpow_sub' hx h, rpow_one]
theorem rpow_two (x : β) : x ^ (2 : β) = x ^ 2 := by
simp
theorem rpow_neg_one (x : β) : x ^ (-1 : β) = xβ»ΒΉ := by
rw [rpow_neg_eq_inv_rpow, rpow_one]
theorem mul_rpow (hx : 0 β€ x) (hy : 0 β€ y) : (x * y) ^ z = x ^ z * y ^ z := by
iterate 2 rw [Real.rpow_def_of_nonneg]; split_ifs with h_ifs <;> simp_all
Β· rw [log_mul βΉ_βΊ βΉ_βΊ, add_mul, exp_add, rpow_def_of_pos (hy.lt_of_ne' βΉ_βΊ)]
all_goals positivity
theorem inv_rpow (hx : 0 β€ x) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ := by
rw [β rpow_neg_eq_inv_rpow, rpow_neg hx]
theorem div_rpow (hx : 0 β€ x) (hy : 0 β€ y) (z : β) : (x / y) ^ z = x ^ z / y ^ z := by
simp only [div_eq_mul_inv, mul_rpow hx (inv_nonneg.2 hy), inv_rpow hy]
theorem log_rpow {x : β} (hx : 0 < x) (y : β) : log (x ^ y) = y * log x := by
apply exp_injective
rw [exp_log (rpow_pos_of_pos hx y), β exp_log hx, mul_comm, rpow_def_of_pos (exp_pos (log x)) y]
theorem mul_log_eq_log_iff {x y z : β} (hx : 0 < x) (hz : 0 < z) :
y * log x = log z β x ^ y = z :=
β¨fun h β¦ log_injOn_pos (rpow_pos_of_pos hx _) hz <| log_rpow hx _ |>.trans h,
by rintro rfl; rw [log_rpow hx]β©
@[simp] lemma rpow_rpow_inv (hx : 0 β€ x) (hy : y β 0) : (x ^ y) ^ yβ»ΒΉ = x := by
rw [β rpow_mul hx, mul_inv_cancelβ hy, rpow_one]
@[simp] lemma rpow_inv_rpow (hx : 0 β€ x) (hy : y β 0) : (x ^ yβ»ΒΉ) ^ y = x := by
rw [β rpow_mul hx, inv_mul_cancelβ hy, rpow_one]
theorem pow_rpow_inv_natCast (hx : 0 β€ x) (hn : n β 0) : (x ^ n) ^ (nβ»ΒΉ : β) = x := by
have hn0 : (n : β) β 0 := Nat.cast_ne_zero.2 hn
rw [β rpow_natCast, β rpow_mul hx, mul_inv_cancelβ hn0, rpow_one]
theorem rpow_inv_natCast_pow (hx : 0 β€ x) (hn : n β 0) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
have hn0 : (n : β) β 0 := Nat.cast_ne_zero.2 hn
rw [β rpow_natCast, β rpow_mul hx, inv_mul_cancelβ hn0, rpow_one]
lemma rpow_natCast_mul (hx : 0 β€ x) (n : β) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul hx, rpow_natCast]
lemma rpow_mul_natCast (hx : 0 β€ x) (y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul hx, rpow_natCast]
lemma rpow_intCast_mul (hx : 0 β€ x) (n : β€) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul hx, rpow_intCast]
lemma rpow_mul_intCast (hx : 0 β€ x) (y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul hx, rpow_intCast]
/-! Note: lemmas about `(β i β s, f i ^ r)` such as `Real.finset_prod_rpow` are proved
in `Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean` instead. -/
/-!
## Order and monotonicity
-/
@[gcongr, bound]
theorem rpow_lt_rpow (hx : 0 β€ x) (hxy : x < y) (hz : 0 < z) : x ^ z < y ^ z := by
rw [le_iff_eq_or_lt] at hx; rcases hx with hx | hx
Β· rw [β hx, zero_rpow (ne_of_gt hz)]
exact rpow_pos_of_pos (by rwa [β hx] at hxy) _
Β· rw [rpow_def_of_pos hx, rpow_def_of_pos (lt_trans hx hxy), exp_lt_exp]
exact mul_lt_mul_of_pos_right (log_lt_log hx hxy) hz
theorem strictMonoOn_rpow_Ici_of_exponent_pos {r : β} (hr : 0 < r) :
StrictMonoOn (fun (x : β) => x ^ r) (Set.Ici 0) :=
fun _ ha _ _ hab => rpow_lt_rpow ha hab hr
@[gcongr, bound]
theorem rpow_le_rpow {x y z : β} (h : 0 β€ x) (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z := by
rcases eq_or_lt_of_le hβ with (rfl | hβ'); Β· rfl
rcases eq_or_lt_of_le hβ with (rfl | hβ'); Β· simp
exact le_of_lt (rpow_lt_rpow h hβ' hβ')
theorem monotoneOn_rpow_Ici_of_exponent_nonneg {r : β} (hr : 0 β€ r) :
MonotoneOn (fun (x : β) => x ^ r) (Set.Ici 0) :=
fun _ ha _ _ hab => rpow_le_rpow ha hab hr
lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z := by
have := hx.trans hxy
rw [β inv_lt_invβ, β rpow_neg, β rpow_neg]
on_goal 1 => refine rpow_lt_rpow ?_ hxy (neg_pos.2 hz)
all_goals positivity
lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x β€ y) (hz : z β€ 0) : y ^ z β€ x ^ z := by
have := hx.trans_le hxy
rw [β inv_le_invβ, β rpow_neg, β rpow_neg]
on_goal 1 => refine rpow_le_rpow ?_ hxy (neg_nonneg.2 hz)
all_goals positivity
theorem rpow_lt_rpow_iff (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ z < y ^ z β x < y :=
β¨lt_imp_lt_of_le_imp_le fun h => rpow_le_rpow hy h (le_of_lt hz), fun h => rpow_lt_rpow hx h hzβ©
theorem rpow_le_rpow_iff (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff hy hx hz
lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z β y < x :=
β¨lt_imp_lt_of_le_imp_le fun h β¦ rpow_le_rpow_of_nonpos hx h hz.le,
fun h β¦ rpow_lt_rpow_of_neg hy h hzβ©
lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z β€ y ^ z β y β€ x :=
le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff_of_neg hy hx hz
lemma le_rpow_inv_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
rw [β rpow_le_rpow_iff hx _ hz, rpow_inv_rpow] <;> positivity
lemma rpow_inv_le_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
rw [β rpow_le_rpow_iff _ hy hz, rpow_inv_rpow] <;> positivity
lemma lt_rpow_inv_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^ z < y :=
lt_iff_lt_of_le_iff_le <| rpow_inv_le_iff_of_pos hy hx hz
lemma rpow_inv_lt_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z :=
lt_iff_lt_of_le_iff_le <| le_rpow_inv_iff_of_pos hy hx hz
theorem le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x β€ y ^ zβ»ΒΉ β y β€ x ^ z := by
rw [β rpow_le_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x < y ^ zβ»ΒΉ β y < x ^ z := by
rw [β rpow_lt_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ^ zβ»ΒΉ < y β y ^ z < x := by
rw [β rpow_lt_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ^ zβ»ΒΉ β€ y β y ^ z β€ x := by
rw [β rpow_le_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_lt_rpow_of_exponent_lt (hx : 1 < x) (hyz : y < z) : x ^ y < x ^ z := by
repeat' rw [rpow_def_of_pos (lt_trans zero_lt_one hx)]
rw [exp_lt_exp]; exact mul_lt_mul_of_pos_left hyz (log_pos hx)
@[gcongr]
theorem rpow_le_rpow_of_exponent_le (hx : 1 β€ x) (hyz : y β€ z) : x ^ y β€ x ^ z := by
repeat' rw [rpow_def_of_pos (lt_of_lt_of_le zero_lt_one hx)]
rw [exp_le_exp]; exact mul_le_mul_of_nonneg_left hyz (log_nonneg hx)
@[deprecated (since := "2025-10-28")] alias rpow_lt_rpow_of_exponent_neg :=
rpow_lt_rpow_of_neg
theorem strictAntiOn_rpow_Ioi_of_exponent_neg {r : β} (hr : r < 0) :
StrictAntiOn (fun (x : β) => x ^ r) (Set.Ioi 0) :=
fun _ ha _ _ hab => rpow_lt_rpow_of_neg ha hab hr
@[deprecated (since := "2025-10-28")] alias rpow_le_rpow_of_exponent_nonpos :=
rpow_le_rpow_of_nonpos
theorem antitoneOn_rpow_Ioi_of_exponent_nonpos {r : β} (hr : r β€ 0) :
AntitoneOn (fun (x : β) => x ^ r) (Set.Ioi 0) :=
fun _ ha _ _ hab => rpow_le_rpow_of_nonpos ha hab hr
@[simp]
theorem rpow_le_rpow_left_iff (hx : 1 < x) : x ^ y β€ x ^ z β y β€ z := by
have x_pos : 0 < x := lt_trans zero_lt_one hx
rw [β log_le_log_iff (rpow_pos_of_pos x_pos y) (rpow_pos_of_pos x_pos z), log_rpow x_pos,
log_rpow x_pos, mul_le_mul_iff_leftβ (log_pos hx)]
@[simp]
theorem rpow_lt_rpow_left_iff (hx : 1 < x) : x ^ y < x ^ z β y < z := by
rw [lt_iff_not_ge, rpow_le_rpow_left_iff hx, lt_iff_not_ge]
theorem rpow_lt_rpow_of_exponent_gt (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) : x ^ y < x ^ z := by
repeat' rw [rpow_def_of_pos hx0]
rw [exp_lt_exp]; exact mul_lt_mul_of_neg_left hyz (log_neg hx0 hx1)
theorem rpow_le_rpow_of_exponent_ge (hx0 : 0 < x) (hx1 : x β€ 1) (hyz : z β€ y) : x ^ y β€ x ^ z := by
repeat' rw [rpow_def_of_pos hx0]
rw [exp_le_exp]; exact mul_le_mul_of_nonpos_left hyz (log_nonpos (le_of_lt hx0) hx1)
@[simp]
theorem rpow_le_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) :
x ^ y β€ x ^ z β z β€ y := by
rw [β log_le_log_iff (rpow_pos_of_pos hx0 y) (rpow_pos_of_pos hx0 z), log_rpow hx0, log_rpow hx0,
mul_le_mul_right_of_neg (log_neg hx0 hx1)]
@[simp]
theorem rpow_lt_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) :
x ^ y < x ^ z β z < y := by
rw [lt_iff_not_ge, rpow_le_rpow_left_iff_of_base_lt_one hx0 hx1, lt_iff_not_ge]
theorem rpow_lt_one {x z : β} (hx1 : 0 β€ x) (hx2 : x < 1) (hz : 0 < z) : x ^ z < 1 := by
rw [β one_rpow z]
exact rpow_lt_rpow hx1 hx2 hz
theorem rpow_le_one {x z : β} (hx1 : 0 β€ x) (hx2 : x β€ 1) (hz : 0 β€ z) : x ^ z β€ 1 := by
rw [β one_rpow z]
exact rpow_le_rpow hx1 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x z : β} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by
convert rpow_lt_rpow_of_exponent_lt hx hz
exact (rpow_zero x).symm
theorem rpow_le_one_of_one_le_of_nonpos {x z : β} (hx : 1 β€ x) (hz : z β€ 0) : x ^ z β€ 1 := by
convert rpow_le_rpow_of_exponent_le hx hz
exact (rpow_zero x).symm
theorem one_lt_rpow {x z : β} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by
rw [β one_rpow z]
exact rpow_lt_rpow zero_le_one hx hz
theorem one_le_rpow {x z : β} (hx : 1 β€ x) (hz : 0 β€ z) : 1 β€ x ^ z := by
rw [β one_rpow z]
exact rpow_le_rpow zero_le_one hx hz
theorem one_lt_rpow_of_pos_of_lt_one_of_neg (hx1 : 0 < x) (hx2 : x < 1) (hz : z < 0) :
1 < x ^ z := by
convert rpow_lt_rpow_of_exponent_gt hx1 hx2 hz
exact (rpow_zero x).symm
theorem one_le_rpow_of_pos_of_le_one_of_nonpos (hx1 : 0 < x) (hx2 : x β€ 1) (hz : z β€ 0) :
1 β€ x ^ z := by
convert rpow_le_rpow_of_exponent_ge hx1 hx2 hz
exact (rpow_zero x).symm
theorem rpow_lt_one_iff_of_pos (hx : 0 < x) : x ^ y < 1 β 1 < x β§ y < 0 β¨ x < 1 β§ 0 < y := by
rw [rpow_def_of_pos hx, exp_lt_one_iff, mul_neg_iff, log_pos_iff hx.le, log_neg_iff hx]
theorem rpow_lt_one_iff (hx : 0 β€ x) :
x ^ y < 1 β x = 0 β§ y β 0 β¨ 1 < x β§ y < 0 β¨ x < 1 β§ 0 < y := by
rcases hx.eq_or_lt with (rfl | hx)
Β· rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, zero_lt_one]
Β· simp [rpow_lt_one_iff_of_pos hx, hx.ne.symm]
theorem rpow_lt_one_iff' {x y : β} (hx : 0 β€ x) (hy : 0 < y) :
x ^ y < 1 β x < 1 := by
rw [β Real.rpow_lt_rpow_iff hx zero_le_one hy, Real.one_rpow]
theorem one_lt_rpow_iff_of_pos (hx : 0 < x) : 1 < x ^ y β 1 < x β§ 0 < y β¨ x < 1 β§ y < 0 := by
rw [rpow_def_of_pos hx, one_lt_exp_iff, mul_pos_iff, log_pos_iff hx.le, log_neg_iff hx]
theorem one_lt_rpow_iff (hx : 0 β€ x) : 1 < x ^ y β 1 < x β§ 0 < y β¨ 0 < x β§ x < 1 β§ y < 0 := by
rcases hx.eq_or_lt with (rfl | hx)
Β· rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, (zero_lt_one' β).not_gt]
Β· simp [one_lt_rpow_iff_of_pos hx, hx]
/-- This is a more general but less convenient version of `rpow_le_rpow_of_exponent_ge`.
This version allows `x = 0`, so it explicitly forbids `x = y = 0`, `z β 0`. -/
theorem rpow_le_rpow_of_exponent_ge_of_imp (hx0 : 0 β€ x) (hx1 : x β€ 1) (hyz : z β€ y)
(h : x = 0 β y = 0 β z = 0) :
x ^ y β€ x ^ z := by
rcases eq_or_lt_of_le hx0 with (rfl | hx0')
Β· rcases eq_or_ne y 0 with rfl | hy0
Β· rw [h rfl rfl]
Β· rw [zero_rpow hy0]
apply zero_rpow_nonneg
Β· exact rpow_le_rpow_of_exponent_ge hx0' hx1 hyz
/-- This version of `rpow_le_rpow_of_exponent_ge` allows `x = 0` but requires `0 β€ z`.
See also `rpow_le_rpow_of_exponent_ge_of_imp` for the most general version. -/
theorem rpow_le_rpow_of_exponent_ge' (hx0 : 0 β€ x) (hx1 : x β€ 1) (hz : 0 β€ z) (hyz : z β€ y) :
x ^ y β€ x ^ z :=
rpow_le_rpow_of_exponent_ge_of_imp hx0 hx1 hyz fun _ hy β¦ le_antisymm (hyz.trans_eq hy) hz
lemma rpow_max {x y p : β} (hx : 0 β€ x) (hy : 0 β€ y) (hp : 0 β€ p) :
(max x y) ^ p = max (x ^ p) (y ^ p) := by
rcases le_total x y with hxy | hxy
Β· rw [max_eq_right hxy, max_eq_right (rpow_le_rpow hx hxy hp)]
Β· rw [max_eq_left hxy, max_eq_left (rpow_le_rpow hy hxy hp)]
theorem self_le_rpow_of_le_one (hβ : 0 β€ x) (hβ : x β€ 1) (hβ : y β€ 1) : x β€ x ^ y := by
simpa only [rpow_one]
using rpow_le_rpow_of_exponent_ge_of_imp hβ hβ hβ fun _ β¦ (absurd Β· one_ne_zero)
theorem self_le_rpow_of_one_le (hβ : 1 β€ x) (hβ : 1 β€ y) : x β€ x ^ y := by
simpa only [rpow_one] using rpow_le_rpow_of_exponent_le hβ hβ
theorem rpow_le_self_of_le_one (hβ : 0 β€ x) (hβ : x β€ 1) (hβ : 1 β€ y) : x ^ y β€ x := by
simpa only [rpow_one]
using rpow_le_rpow_of_exponent_ge_of_imp hβ hβ hβ fun _ β¦ (absurd Β· (one_pos.trans_le hβ).ne')
theorem rpow_le_self_of_one_le (hβ : 1 β€ x) (hβ : y β€ 1) : x ^ y β€ x := by
simpa only [rpow_one] using rpow_le_rpow_of_exponent_le hβ hβ
theorem self_lt_rpow_of_lt_one (hβ : 0 < x) (hβ : x < 1) (hβ : y < 1) : x < x ^ y := by
simpa only [rpow_one] using rpow_lt_rpow_of_exponent_gt hβ hβ hβ
theorem self_lt_rpow_of_one_lt (hβ : 1 < x) (hβ : 1 < y) : x < x ^ y := by
simpa only [rpow_one] using rpow_lt_rpow_of_exponent_lt hβ hβ
theorem rpow_lt_self_of_lt_one (hβ : 0 < x) (hβ : x < 1) (hβ : 1 < y) : x ^ y < x := by
simpa only [rpow_one] using rpow_lt_rpow_of_exponent_gt hβ hβ hβ
theorem rpow_lt_self_of_one_lt (hβ : 1 < x) (hβ : y < 1) : x ^ y < x := by
simpa only [rpow_one] using rpow_lt_rpow_of_exponent_lt hβ hβ
theorem rpow_left_injOn {x : β} (hx : x β 0) : InjOn (fun y : β => y ^ x) { y : β | 0 β€ y } := by
rintro y hy z hz (hyz : y ^ x = z ^ x)
rw [β rpow_one y, β rpow_one z, β mul_inv_cancelβ hx, rpow_mul hy, rpow_mul hz, hyz]
lemma rpow_left_inj (hx : 0 β€ x) (hy : 0 β€ y) (hz : z β 0) : x ^ z = y ^ z β x = y :=
(rpow_left_injOn hz).eq_iff hx hy
lemma rpow_inv_eq (hx : 0 β€ x) (hy : 0 β€ y) (hz : z β 0) : x ^ zβ»ΒΉ = y β x = y ^ z := by
rw [β rpow_left_inj _ hy hz, rpow_inv_rpow hx hz]; positivity
lemma eq_rpow_inv (hx : 0 β€ x) (hy : 0 β€ y) (hz : z β 0) : x = y ^ zβ»ΒΉ β x ^ z = y := by
rw [β rpow_left_inj hx _ hz, rpow_inv_rpow hy hz]; positivity
theorem le_rpow_iff_log_le (hx : 0 < x) (hy : 0 < y) : x β€ y ^ z β log x β€ z * log y := by
rw [β log_le_log_iff hx (rpow_pos_of_pos hy z), log_rpow hy]
lemma le_pow_iff_log_le (hx : 0 < x) (hy : 0 < y) : x β€ y ^ n β log x β€ n * log y :=
rpow_natCast _ _ βΈ le_rpow_iff_log_le hx hy
lemma le_zpow_iff_log_le {n : β€} (hx : 0 < x) (hy : 0 < y) : x β€ y ^ n β log x β€ n * log y :=
rpow_intCast _ _ βΈ le_rpow_iff_log_le hx hy
lemma le_rpow_of_log_le (hy : 0 < y) (h : log x β€ z * log y) : x β€ y ^ z := by
obtain hx | hx := le_or_gt x 0
Β· exact hx.trans (rpow_pos_of_pos hy _).le
Β· exact (le_rpow_iff_log_le hx hy).2 h
lemma le_pow_of_log_le (hy : 0 < y) (h : log x β€ n * log y) : x β€ y ^ n :=
rpow_natCast _ _ βΈ le_rpow_of_log_le hy h
lemma le_zpow_of_log_le {n : β€} (hy : 0 < y) (h : log x β€ n * log y) : x β€ y ^ n :=
rpow_intCast _ _ βΈ le_rpow_of_log_le hy h
theorem lt_rpow_iff_log_lt (hx : 0 < x) (hy : 0 < y) : x < y ^ z β log x < z * log y := by
rw [β log_lt_log_iff hx (rpow_pos_of_pos hy z), log_rpow hy]
lemma lt_pow_iff_log_lt (hx : 0 < x) (hy : 0 < y) : x < y ^ n β log x < n * log y :=
rpow_natCast _ _ βΈ lt_rpow_iff_log_lt hx hy
lemma lt_zpow_iff_log_lt {n : β€} (hx : 0 < x) (hy : 0 < y) : x < y ^ n β log x < n * log y :=
rpow_intCast _ _ βΈ lt_rpow_iff_log_lt hx hy
lemma lt_rpow_of_log_lt (hy : 0 < y) (h : log x < z * log y) : x < y ^ z := by
obtain hx | hx := le_or_gt x 0
Β· exact hx.trans_lt (rpow_pos_of_pos hy _)
Β· exact (lt_rpow_iff_log_lt hx hy).2 h
lemma lt_pow_of_log_lt (hy : 0 < y) (h : log x < n * log y) : x < y ^ n :=
rpow_natCast _ _ βΈ lt_rpow_of_log_lt hy h
lemma lt_zpow_of_log_lt {n : β€} (hy : 0 < y) (h : log x < n * log y) : x < y ^ n :=
rpow_intCast _ _ βΈ lt_rpow_of_log_lt hy h
lemma rpow_le_iff_le_log (hx : 0 < x) (hy : 0 < y) : x ^ z β€ y β z * log x β€ log y := by
rw [β log_le_log_iff (rpow_pos_of_pos hx _) hy, log_rpow hx]
lemma pow_le_iff_le_log (hx : 0 < x) (hy : 0 < y) : x ^ n β€ y β n * log x β€ log y := by
rw [β rpow_le_iff_le_log hx hy, rpow_natCast]
lemma zpow_le_iff_le_log {n : β€} (hx : 0 < x) (hy : 0 < y) : x ^ n β€ y β n * log x β€ log y := by
rw [β rpow_le_iff_le_log hx hy, rpow_intCast]
lemma le_log_of_rpow_le (hx : 0 < x) (h : x ^ z β€ y) : z * log x β€ log y :=
log_rpow hx _ βΈ log_le_log (by positivity) h
lemma le_log_of_pow_le (hx : 0 < x) (h : x ^ n β€ y) : n * log x β€ log y :=
le_log_of_rpow_le hx (rpow_natCast _ _ βΈ h)
lemma le_log_of_zpow_le {n : β€} (hx : 0 < x) (h : x ^ n β€ y) : n * log x β€ log y :=
le_log_of_rpow_le hx (rpow_intCast _ _ βΈ h)
lemma rpow_le_of_le_log (hy : 0 < y) (h : log x β€ z * log y) : x β€ y ^ z := by
obtain hx | hx := le_or_gt x 0
Β· exact hx.trans (rpow_pos_of_pos hy _).le
Β· exact (le_rpow_iff_log_le hx hy).2 h
lemma pow_le_of_le_log (hy : 0 < y) (h : log x β€ n * log y) : x β€ y ^ n :=
rpow_natCast _ _ βΈ rpow_le_of_le_log hy h
lemma zpow_le_of_le_log {n : β€} (hy : 0 < y) (h : log x β€ n * log y) : x β€ y ^ n :=
rpow_intCast _ _ βΈ rpow_le_of_le_log hy h
lemma rpow_lt_iff_lt_log (hx : 0 < x) (hy : 0 < y) : x ^ z < y β z * log x < log y := by
rw [β log_lt_log_iff (rpow_pos_of_pos hx _) hy, log_rpow hx]
lemma pow_lt_iff_lt_log (hx : 0 < x) (hy : 0 < y) : x ^ n < y β n * log x < log y := by
rw [β rpow_lt_iff_lt_log hx hy, rpow_natCast]
lemma zpow_lt_iff_lt_log {n : β€} (hx : 0 < x) (hy : 0 < y) : x ^ n < y β n * log x < log y := by
rw [β rpow_lt_iff_lt_log hx hy, rpow_intCast]
lemma lt_log_of_rpow_lt (hx : 0 < x) (h : x ^ z < y) : z * log x < log y :=
log_rpow hx _ βΈ log_lt_log (by positivity) h
lemma lt_log_of_pow_lt (hx : 0 < x) (h : x ^ n < y) : n * log x < log y :=
lt_log_of_rpow_lt hx (rpow_natCast _ _ βΈ h)
lemma lt_log_of_zpow_lt {n : β€} (hx : 0 < x) (h : x ^ n < y) : n * log x < log y :=
lt_log_of_rpow_lt hx (rpow_intCast _ _ βΈ h)
lemma rpow_lt_of_lt_log (hy : 0 < y) (h : log x < z * log y) : x < y ^ z := by
obtain hx | hx := le_or_gt x 0
Β· exact hx.trans_lt (rpow_pos_of_pos hy _)
Β· exact (lt_rpow_iff_log_lt hx hy).2 h
lemma pow_lt_of_lt_log (hy : 0 < y) (h : log x < n * log y) : x < y ^ n :=
rpow_natCast _ _ βΈ rpow_lt_of_lt_log hy h
lemma zpow_lt_of_lt_log {n : β€} (hy : 0 < y) (h : log x < n * log y) : x < y ^ n :=
rpow_intCast _ _ βΈ rpow_lt_of_lt_log hy h
theorem rpow_le_one_iff_of_pos (hx : 0 < x) : x ^ y β€ 1 β 1 β€ x β§ y β€ 0 β¨ x β€ 1 β§ 0 β€ y := by
rw [rpow_def_of_pos hx, exp_le_one_iff, mul_nonpos_iff, log_nonneg_iff hx, log_nonpos_iff hx.le]
/-- Bound for `|log x * x ^ t|` in the interval `(0, 1]`, for positive real `t`. -/
theorem abs_log_mul_self_rpow_lt (x t : β) (h1 : 0 < x) (h2 : x β€ 1) (ht : 0 < t) :
|log x * x ^ t| < 1 / t := by
rw [lt_div_iffβ ht]
have := abs_log_mul_self_lt (x ^ t) (rpow_pos_of_pos h1 t) (rpow_le_one h1.le h2 ht.le)
rwa [log_rpow h1, mul_assoc, abs_mul, abs_of_pos ht, mul_comm] at this
/-- `log x` is bounded above by a multiple of every power of `x` with positive exponent. -/
lemma log_le_rpow_div {x Ξ΅ : β} (hx : 0 β€ x) (hΞ΅ : 0 < Ξ΅) : log x β€ x ^ Ξ΅ / Ξ΅ := by
rcases hx.eq_or_lt with rfl | h
Β· rw [log_zero, zero_rpow hΞ΅.ne', zero_div]
rw [le_div_iffβ' hΞ΅]
exact (log_rpow h Ξ΅).symm.trans_le <| (log_le_sub_one_of_pos <| rpow_pos_of_pos h Ξ΅).trans
(sub_one_lt _).le
/-- The (real) logarithm of a natural number `n` is bounded by a multiple of every power of `n`
with positive exponent. -/
lemma log_natCast_le_rpow_div (n : β) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : log n β€ n ^ Ξ΅ / Ξ΅ :=
log_le_rpow_div n.cast_nonneg hΞ΅
lemma strictMono_rpow_of_base_gt_one {b : β} (hb : 1 < b) :
StrictMono (b ^ Β· : β β β) := by
simp_rw [Real.rpow_def_of_pos (zero_lt_one.trans hb)]
exact exp_strictMono.comp <| StrictMono.const_mul strictMono_id <| Real.log_pos hb
lemma monotone_rpow_of_base_ge_one {b : β} (hb : 1 β€ b) :
Monotone (b ^ Β· : β β β) := by
rcases lt_or_eq_of_le hb with hb | rfl
case inl => exact (strictMono_rpow_of_base_gt_one hb).monotone
case inr => intro _ _ _; simp
lemma strictAnti_rpow_of_base_lt_one {b : β} (hbβ : 0 < b) (hbβ : b < 1) :
StrictAnti (b ^ Β· : β β β) := by
simp_rw [Real.rpow_def_of_pos hbβ]
exact exp_strictMono.comp_strictAnti <| StrictMono.const_mul_of_neg strictMono_id
<| Real.log_neg hbβ hbβ
lemma antitone_rpow_of_base_le_one {b : β} (hbβ : 0 < b) (hbβ : b β€ 1) :
Antitone (b ^ Β· : β β β) := by
rcases lt_or_eq_of_le hbβ with hbβ | rfl
case inl => exact (strictAnti_rpow_of_base_lt_one hbβ hbβ).antitone
case inr => intro _ _ _; simp
lemma rpow_right_inj (hxβ : 0 < x) (hxβ : x β 1) : x ^ y = x ^ z β y = z := by
refine β¨fun H β¦ ?_, fun H β¦ by rw [H]β©
rcases hxβ.lt_or_gt with h | h
Β· exact (strictAnti_rpow_of_base_lt_one hxβ h).injective H
Β· exact (strictMono_rpow_of_base_gt_one h).injective H
/-- Guessing rule for the `bound` tactic: when trying to prove `x ^ y β€ x ^ z`, we can either assume
`1 β€ x` or `0 < x β€ 1`. -/
@[bound] lemma rpow_le_rpow_of_exponent_le_or_ge {x y z : β}
(h : 1 β€ x β§ y β€ z β¨ 0 < x β§ x β€ 1 β§ z β€ y) : x ^ y β€ x ^ z := by
rcases h with β¨x1, yzβ© | β¨x0, x1, zyβ©
Β· exact Real.rpow_le_rpow_of_exponent_le x1 yz
Β· exact Real.rpow_le_rpow_of_exponent_ge x0 x1 zy
end Real
namespace Complex
lemma norm_prime_cpow_le_one_half (p : Nat.Primes) {s : β} (hs : 1 < s.re) :
β(p : β) ^ (-s)β β€ 1 / 2 := by
rw [norm_natCast_cpow_of_re_ne_zero p <| by rw [neg_re]; linarith only [hs]]
refine (Real.rpow_le_rpow_of_nonpos zero_lt_two (Nat.cast_le.mpr p.prop.two_le) <|
by rw [neg_re]; linarith only [hs]).trans ?_
rw [one_div, β Real.rpow_neg_one]
exact Real.rpow_le_rpow_of_exponent_le one_le_two <| (neg_lt_neg hs).le
lemma one_sub_prime_cpow_ne_zero {p : β} (hp : p.Prime) {s : β} (hs : 1 < s.re) :
1 - (p : β) ^ (-s) β 0 := by
refine sub_ne_zero_of_ne fun H β¦ ?_
have := norm_prime_cpow_le_one_half β¨p, hpβ© hs
simp only at this
rw [β H, norm_one] at this
norm_num at this
lemma norm_natCast_cpow_le_norm_natCast_cpow_of_pos {n : β} (hn : 0 < n) {w z : β}
(h : w.re β€ z.re) :
β(n : β) ^ wβ β€ β(n : β) ^ zβ := by
simp_rw [norm_natCast_cpow_of_pos hn]
exact Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast hn) h
lemma norm_natCast_cpow_le_norm_natCast_cpow_iff {n : β} (hn : 1 < n) {w z : β} :
β(n : β) ^ wβ β€ β(n : β) ^ zβ β w.re β€ z.re := by
simp_rw [norm_natCast_cpow_of_pos (Nat.zero_lt_of_lt hn),
Real.rpow_le_rpow_left_iff (Nat.one_lt_cast.mpr hn)]
lemma norm_log_natCast_le_rpow_div (n : β) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : βlog nβ β€ n ^ Ξ΅ / Ξ΅ := by
rcases n.eq_zero_or_pos with rfl | h
Β· rw [Nat.cast_zero, Nat.cast_zero, log_zero, norm_zero, Real.zero_rpow hΞ΅.ne', zero_div]
rw [β natCast_log, norm_real, norm_of_nonneg <| Real.log_nonneg <| by
exact_mod_cast Nat.one_le_of_lt h.lt]
exact Real.log_natCast_le_rpow_div n hΞ΅
end Complex
/-!
## Square roots of reals
-/
namespace Real
variable {z x y : β}
section Sqrt
theorem sqrt_eq_rpow (x : β) : βx = x ^ (1 / (2 : β)) := by
obtain h | h := le_or_gt 0 x
Β· rw [β mul_self_inj_of_nonneg (sqrt_nonneg _) (rpow_nonneg h _), mul_self_sqrt h, β sq,
β rpow_natCast, β rpow_mul h]
simp
Β· have : 1 / (2 : β) * Ο = Ο / (2 : β) := by ring
rw [sqrt_eq_zero_of_nonpos h.le, rpow_def_of_neg h, this, cos_pi_div_two, mul_zero]
theorem rpow_div_two_eq_sqrt {x : β} (r : β) (hx : 0 β€ x) : x ^ (r / 2) = βx ^ r := by
rw [sqrt_eq_rpow, β rpow_mul hx]
congr
ring
end Sqrt
end Real
namespace Complex
lemma cpow_inv_two_re (x : β) : (x ^ (2β»ΒΉ : β)).re = β((βxβ + x.re) / 2) := by
rw [β ofReal_ofNat, β ofReal_inv, cpow_ofReal_re, β div_eq_mul_inv, β one_div,
β Real.sqrt_eq_rpow, cos_half, β sqrt_mul, β mul_div_assoc, mul_add, mul_one, norm_mul_cos_arg]
exacts [norm_nonneg _, (neg_pi_lt_arg _).le, arg_le_pi _]
lemma cpow_inv_two_im_eq_sqrt {x : β} (hx : 0 β€ x.im) :
(x ^ (2β»ΒΉ : β)).im = β((βxβ - x.re) / 2) := by
rw [β ofReal_ofNat, β ofReal_inv, cpow_ofReal_im, β div_eq_mul_inv, β one_div,
β Real.sqrt_eq_rpow, sin_half_eq_sqrt, β sqrt_mul (norm_nonneg _), β mul_div_assoc, mul_sub,
mul_one, norm_mul_cos_arg]
Β· rwa [arg_nonneg_iff]
Β· linarith [pi_pos, arg_le_pi x]
lemma cpow_inv_two_im_eq_neg_sqrt {x : β} (hx : x.im < 0) :
(x ^ (2β»ΒΉ : β)).im = -β((βxβ - x.re) / 2) := by
rw [β ofReal_ofNat, β ofReal_inv, cpow_ofReal_im, β div_eq_mul_inv, β one_div,
β Real.sqrt_eq_rpow, sin_half_eq_neg_sqrt, mul_neg, β sqrt_mul (norm_nonneg _),
β mul_div_assoc, mul_sub, mul_one, norm_mul_cos_arg]
Β· linarith [pi_pos, neg_pi_lt_arg x]
Β· exact (arg_neg_iff.2 hx).le
lemma abs_cpow_inv_two_im (x : β) : |(x ^ (2β»ΒΉ : β)).im| = β((βxβ - x.re) / 2) := by
rw [β ofReal_ofNat, β ofReal_inv, cpow_ofReal_im, β div_eq_mul_inv, β one_div,
β Real.sqrt_eq_rpow, abs_mul, abs_of_nonneg (sqrt_nonneg _), abs_sin_half,
β sqrt_mul (norm_nonneg _), β mul_div_assoc, mul_sub, mul_one, norm_mul_cos_arg]
open scoped ComplexOrder in
lemma inv_natCast_cpow_ofReal_pos {n : β} (hn : n β 0) (x : β) :
0 < ((n : β) ^ (x : β))β»ΒΉ := by
refine RCLike.inv_pos_of_pos ?_
rw [show (n : β) ^ (x : β) = (n : β) ^ (x : β) from rfl, β ofReal_cpow n.cast_nonneg']
positivity
end Complex
section Tactics
/-!
## Tactic extensions for real powers
-/
namespace Mathlib.Meta.NormNum
open Lean.Meta Qq
theorem IsNat.rpow_eq_pow {b : β} {n : β} (h : IsNat b n) (a : β) : a ^ b = a ^ n := by
rw [h.1, Real.rpow_natCast]
theorem IsInt.rpow_eq_inv_pow {b : β} {n : β} (h : IsInt b (.negOfNat n)) (a : β) :
a ^ b = (a ^ n)β»ΒΉ := by
rw [h.1, Real.rpow_intCast, Int.negOfNat_eq, zpow_neg, Int.ofNat_eq_coe, zpow_natCast]
@[deprecated IsNat.rpow_eq_pow (since := "2025-10-21")]
theorem isNat_rpow_pos {a b : β} {nb ne : β}
(pb : IsNat b nb) (pe' : IsNat (a ^ nb) ne) :
IsNat (a ^ b) ne := by
rwa [pb.out, rpow_natCast]
@[deprecated IsInt.rpow_eq_inv_pow (since := "2025-10-21")]
theorem isNat_rpow_neg {a b : β} {nb ne : β}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsNat (a ^ (Int.negOfNat nb)) ne) :
IsNat (a ^ b) ne := by
rwa [pb.out, Real.rpow_intCast]
@[deprecated IsNat.rpow_eq_pow (since := "2025-10-21")]
theorem isInt_rpow_pos {a b : β} {nb ne : β}
(pb : IsNat b nb) (pe' : IsInt (a ^ nb) (Int.negOfNat ne)) :
IsInt (a ^ b) (Int.negOfNat ne) := by
rwa [pb.out, rpow_natCast]
@[deprecated IsInt.rpow_eq_inv_pow (since := "2025-10-21")]
theorem isInt_rpow_neg {a b : β} {nb ne : β}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsInt (a ^ (Int.negOfNat nb)) (Int.negOfNat ne)) :
IsInt (a ^ b) (Int.negOfNat ne) := by
rwa [pb.out, Real.rpow_intCast]
@[deprecated IsNat.rpow_eq_pow (since := "2025-10-21")]
theorem isNNRat_rpow_pos {a b : β} {nb : β}
{num den : β}
(pb : IsNat b nb) (pe' : IsNNRat (a ^ nb) num den) :
IsNNRat (a ^ b) num den := by
rwa [pb.out, rpow_natCast]
@[deprecated IsNat.rpow_eq_pow (since := "2025-10-21")]
theorem isRat_rpow_pos {a b : β} {nb : β}
{num : β€} {den : β}
(pb : IsNat b nb) (pe' : IsRat (a ^ nb) num den) :
IsRat (a ^ b) num den := by
rwa [pb.out, rpow_natCast]
@[deprecated IsInt.rpow_eq_inv_pow (since := "2025-10-21")]
theorem isNNRat_rpow_neg {a b : β} {nb : β}
{num den : β}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsNNRat (a ^ (Int.negOfNat nb)) num den) :
IsNNRat (a ^ b) num den := by
rwa [pb.out, Real.rpow_intCast]
@[deprecated IsInt.rpow_eq_inv_pow (since := "2025-10-21")]
theorem isRat_rpow_neg {a b : β} {nb : β}
{num : β€} {den : β}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsRat (a ^ (Int.negOfNat nb)) num den) :
IsRat (a ^ b) num den := by
rwa [pb.out, Real.rpow_intCast]
/-- Given proofs
- that `a` is a natural number `m`
- that `b` is a nonnegative rational number `n / d`
- that `r ^ d = m ^ n` (written as `r ^ d = k`, `m ^ n = l`, `k = l`)
prove that `a ^ b = r`.
-/
theorem IsNat.rpow_isNNRat {a b : β} {m n d r : β} (ha : IsNat a m) (hb : IsNNRat b n d)
(k : β) (hr : r ^ d = k) (l : β) (hm : m ^ n = l) (hkl : k = l) : IsNat (a ^ b) r := by
rcases ha with β¨rflβ©
constructor
have : d β 0 := mod_cast hb.den_nz
rw [hb.to_eq rfl rfl, div_eq_mul_inv, Real.rpow_natCast_mul, β Nat.cast_pow, hm, β hkl, β hr,
Nat.cast_pow, Real.pow_rpow_inv_natCast] <;> positivity
theorem IsNNRat.rpow_isNNRat (a b : β) (na da : β) (ha : IsNNRat a na da)
(nr dr : β) (hnum : IsNat ((na : β) ^ b) nr) (hden : IsNat ((da : β) ^ b) dr) :
IsNNRat (a ^ b) nr dr := by
suffices IsNNRat (nr / dr : β) nr dr by
simpa [ha.to_eq, Real.div_rpow, hnum.1, hden.1]
apply IsNNRat.of_raw
rw [β hden.1]
apply (Real.rpow_pos_of_pos _ _).ne'
exact lt_of_le_of_ne' da.cast_nonneg ha.den_nz
theorem rpow_isRat_eq_inv_rpow (a b : β) (n d : β) (hb : IsRat b (Int.negOfNat n) d) :
a ^ b = (aβ»ΒΉ) ^ (n / d : β) := by
rw [β Real.rpow_neg_eq_inv_rpow, hb.neg_to_eq rfl rfl]
open Lean in
/-- Given proofs
- that `a` is a natural number `na`;
- that `b` is a nonnegative rational number `nb / db`;
returns a tuple of
- a natural number `r` (result);
- the same number, as an expression;
- a proof that `a ^ b = r`.
Fails if `na` is not a `db`th power of a natural number.
-/
def proveIsNatRPowIsNNRat
(a : Q(β)) (na : Q(β)) (pa : Q(IsNat $a $na))
(b : Q(β)) (nb db : Q(β)) (pb : Q(IsNNRat $b $nb $db)) :
MetaM (β Γ Ξ£ r : Q(β), Q(IsNat ($a ^ $b) $r)) := do
let r := (Nat.nthRoot db.natLit! na.natLit!) ^ nb.natLit!
have er : Q(β) := mkRawNatLit r
-- avoid evaluating powers in kernel
let .some β¨c, pcβ© β liftM <| OptionT.run <| evalNatPow er db | failure
let .some β¨d, pdβ© β liftM <| OptionT.run <| evalNatPow na nb | failure
guard (c.natLit! = d.natLit!)
have hcd : Q($c = $d) := (q(Eq.refl $c) : Expr)
return (r, β¨er, q(IsNat.rpow_isNNRat $pa $pb $c $pc $d $pd $hcd)β©)
/-- Evaluates expressions of the form `a ^ b` when `a` and `b` are both reals.
Works if `a`, `b`, and `a ^ b` are in fact rational numbers,
except for the case `a < 0`, `b` isn't integer.
TODO: simplify terms like `(-a : β) ^ (b / 3 : β)` and `(-a : β) ^ (b / 2 : β)` too,
possibly after first considering changing the junk value. -/
@[norm_num (_ : β) ^ (_ : β)]
def evalRPow : NormNumExt where eval {u Ξ±R} e := do
match u, Ξ±R, e with
| 0, ~q(β), ~q(($a : β)^($b : β)) =>
match β derive b with
| .isNat sΞ² nb pb =>
assumeInstancesCommute
return .eqTrans q(IsNat.rpow_eq_pow $pb _) (β derive q($a ^ $nb))
| .isNegNat sΞ² nb pb =>
assumeInstancesCommute
return .eqTrans q(IsInt.rpow_eq_inv_pow $pb _) (β derive q(($a ^ $nb)β»ΒΉ))
| .isNNRat _ qb nb db pb => do
assumeInstancesCommute
match β derive a with
| .isNat sa na pa => do
let β¨_, r, prβ© β proveIsNatRPowIsNNRat a na pa b nb db pb
return .isNat sa r pr
| .isNNRat _ qΞ± na da pa => do
assumeInstancesCommute
let β¨rnum, ernum, pnumβ© β
proveIsNatRPowIsNNRat q(Nat.rawCast $na) na q(IsNat.of_raw _ _) b nb db pb
let β¨rden, erden, pdenβ© β
proveIsNatRPowIsNNRat q(Nat.rawCast $da) da q(IsNat.of_raw _ _) b nb db pb
return .isNNRat q(inferInstance) (rnum / rden) ernum erden
q(IsNNRat.rpow_isNNRat $a $b $na $da $pa $ernum $erden $pnum $pden)
| _ => failure
| .isNegNNRat _ qb nb db pb => do
let r β derive q(($aβ»ΒΉ) ^ ($nb / $db : β))
assumeInstancesCommute
return .eqTrans q(rpow_isRat_eq_inv_rpow $a $b $nb $db $pb) r
| _ => failure
| _ => failure
end Mathlib.Meta.NormNum
end Tactics |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean | import Mathlib.Analysis.SpecialFunctions.Gaussian.GaussianIntegral
import Mathlib.Analysis.Complex.CauchyIntegral
import Mathlib.MeasureTheory.Integral.Pi
import Mathlib.Analysis.Fourier.FourierTransform
/-!
# Fourier transform of the Gaussian
We prove that the Fourier transform of the Gaussian function is another Gaussian:
* `integral_cexp_quadratic`: general formula for `β« (x : β), exp (b * x ^ 2 + c * x + d)`
* `fourierIntegral_gaussian`: for all complex `b` and `t` with `0 < re b`, we have
`β« x:β, exp (I * t * x) * exp (-b * x^2) = (Ο / b) ^ (1 / 2) * exp (-t ^ 2 / (4 * b))`.
* `fourierIntegral_gaussian_pi`: a variant with `b` and `t` scaled to give a more symmetric
statement, and formulated in terms of the Fourier transform operator `π`.
We also give versions of these formulas in finite-dimensional inner product spaces, see
`integral_cexp_neg_mul_sq_norm_add` and `fourierIntegral_gaussian_innerProductSpace`.
-/
/-!
## Fourier integral of Gaussian functions
-/
open Real Set MeasureTheory Filter Asymptotics intervalIntegral
open scoped Real Topology FourierTransform RealInnerProductSpace
open Complex hiding exp continuous_exp
noncomputable section
namespace GaussianFourier
variable {b : β}
/-- The integral of the Gaussian function over the vertical edges of a rectangle
with vertices at `(Β±T, 0)` and `(Β±T, c)`. -/
def verticalIntegral (b : β) (c T : β) : β :=
β« y : β in (0 : β)..c, I * (cexp (-b * (T + y * I) ^ 2) - cexp (-b * (T - y * I) ^ 2))
/-- Explicit formula for the norm of the Gaussian function along the vertical
edges. -/
theorem norm_cexp_neg_mul_sq_add_mul_I (b : β) (c T : β) :
βcexp (-b * (T + c * I) ^ 2)β = exp (-(b.re * T ^ 2 - 2 * b.im * c * T - b.re * c ^ 2)) := by
rw [Complex.norm_exp, neg_mul, neg_re, β re_add_im b]
simp only [sq, re_add_im, mul_re, mul_im, add_re, add_im, ofReal_re, ofReal_im, I_re, I_im]
ring_nf
theorem norm_cexp_neg_mul_sq_add_mul_I' (hb : b.re β 0) (c T : β) :
βcexp (-b * (T + c * I) ^ 2)β =
exp (-(b.re * (T - b.im * c / b.re) ^ 2 - c ^ 2 * (b.im ^ 2 / b.re + b.re))) := by
have :
b.re * T ^ 2 - 2 * b.im * c * T - b.re * c ^ 2 =
b.re * (T - b.im * c / b.re) ^ 2 - c ^ 2 * (b.im ^ 2 / b.re + b.re) := by
field
rw [norm_cexp_neg_mul_sq_add_mul_I, this]
theorem verticalIntegral_norm_le (hb : 0 < b.re) (c : β) {T : β} (hT : 0 β€ T) :
βverticalIntegral b c Tβ β€
(2 : β) * |c| * exp (-(b.re * T ^ 2 - (2 : β) * |b.im| * |c| * T - b.re * c ^ 2)) := by
-- first get uniform bound for integrand
have vert_norm_bound :
β {T : β},
0 β€ T β
β {c y : β},
|y| β€ |c| β
βcexp (-b * (T + y * I) ^ 2)β β€
exp (-(b.re * T ^ 2 - (2 : β) * |b.im| * |c| * T - b.re * c ^ 2)) := by
intro T hT c y hy
rw [norm_cexp_neg_mul_sq_add_mul_I b]
gcongr exp (-(_ - ?_ * _ - _ * ?_))
Β· (conv_lhs => rw [mul_assoc]); (conv_rhs => rw [mul_assoc])
gcongr _ * ?_
refine (le_abs_self _).trans ?_
rw [abs_mul]
gcongr
Β· rwa [sq_le_sq]
-- now main proof
apply (intervalIntegral.norm_integral_le_of_norm_le_const _).trans
Β· rw [sub_zero]
conv_lhs => simp only [mul_comm _ |c|]
conv_rhs =>
conv =>
congr
rw [mul_comm]
rw [mul_assoc]
Β· intro y hy
have absy : |y| β€ |c| := by
rcases le_or_gt 0 c with (h | h)
Β· rw [uIoc_of_le h] at hy
rw [abs_of_nonneg h, abs_of_pos hy.1]
exact hy.2
Β· rw [uIoc_of_ge h.le] at hy
rw [abs_of_neg h, abs_of_nonpos hy.2, neg_le_neg_iff]
exact hy.1.le
rw [norm_mul, norm_I, one_mul, two_mul]
refine (norm_sub_le _ _).trans (add_le_add (vert_norm_bound hT absy) ?_)
rw [β abs_neg y] at absy
simpa only [neg_mul, ofReal_neg] using vert_norm_bound hT absy
theorem tendsto_verticalIntegral (hb : 0 < b.re) (c : β) :
Tendsto (verticalIntegral b c) atTop (π 0) := by
-- complete proof using squeeze theorem:
rw [tendsto_zero_iff_norm_tendsto_zero]
refine
tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds ?_
(Eventually.of_forall fun _ => norm_nonneg _)
((eventually_ge_atTop (0 : β)).mp
(Eventually.of_forall fun T hT => verticalIntegral_norm_le hb c hT))
rw [(by ring : 0 = 2 * |c| * 0)]
refine (tendsto_exp_atBot.comp (tendsto_neg_atTop_atBot.comp ?_)).const_mul _
apply tendsto_atTop_add_const_right
simp_rw [sq, β mul_assoc, β sub_mul]
refine Tendsto.atTop_mul_atTopβ (tendsto_atTop_add_const_right _ _ ?_) tendsto_id
exact (tendsto_const_mul_atTop_of_pos hb).mpr tendsto_id
theorem integrable_cexp_neg_mul_sq_add_real_mul_I (hb : 0 < b.re) (c : β) :
Integrable fun x : β => cexp (-b * (x + c * I) ^ 2) := by
refine
β¨(Complex.continuous_exp.comp
(continuous_const.mul
((continuous_ofReal.add continuous_const).pow 2))).aestronglyMeasurable,
?_β©
rw [β hasFiniteIntegral_norm_iff]
simp_rw [norm_cexp_neg_mul_sq_add_mul_I' hb.ne', neg_sub _ (c ^ 2 * _),
sub_eq_add_neg _ (b.re * _), Real.exp_add]
suffices Integrable fun x : β => exp (-(b.re * x ^ 2)) by
exact (Integrable.comp_sub_right this (b.im * c / b.re)).hasFiniteIntegral.const_mul _
simp_rw [β neg_mul]
apply integrable_exp_neg_mul_sq hb
theorem integral_cexp_neg_mul_sq_add_real_mul_I (hb : 0 < b.re) (c : β) :
β« x : β, cexp (-b * (x + c * I) ^ 2) = (Ο / b) ^ (1 / 2 : β) := by
refine
tendsto_nhds_unique
(intervalIntegral_tendsto_integral (integrable_cexp_neg_mul_sq_add_real_mul_I hb c)
tendsto_neg_atTop_atBot tendsto_id)
?_
set Iβ := fun T => β« x : β in -T..T, cexp (-b * (x + c * I) ^ 2) with HIβ
let Iβ := fun T : β => β« x : β in -T..T, cexp (-b * (x : β) ^ 2)
let Iβ := fun T : β => β« y : β in (0 : β)..c, cexp (-b * (T + y * I) ^ 2)
let Iβ
:= fun T : β => β« y : β in (0 : β)..c, cexp (-b * (-T + y * I) ^ 2)
have C : β T : β, Iβ T - Iβ T + I * Iβ T - I * Iβ
T = 0 := by
intro T
have :=
integral_boundary_rect_eq_zero_of_differentiableOn (fun z => cexp (-b * z ^ 2)) (-T)
(T + c * I)
(by
refine Differentiable.differentiableOn (Differentiable.const_mul ?_ _).cexp
exact differentiable_pow 2)
simpa only [neg_im, ofReal_im, neg_zero, ofReal_zero, zero_mul, add_zero, neg_re,
ofReal_re, add_re, mul_re, I_re, mul_zero, I_im, tsub_zero, add_im, mul_im,
mul_one, zero_add, Algebra.id.smul_eq_mul, ofReal_neg] using this
simp_rw [id, β HIβ]
have : Iβ = fun T : β => Iβ T + verticalIntegral b c T := by
ext1 T
specialize C T
rw [sub_eq_zero] at C
unfold verticalIntegral
rw [intervalIntegral.integral_const_mul, intervalIntegral.integral_sub]
Β· simp_rw [(fun a b => by rw [sq]; ring_nf : β a b : β, (a - b * I) ^ 2 = (-a + b * I) ^ 2)]
change Iβ T = Iβ T + I * (Iβ T - Iβ
T)
rw [mul_sub, β C]
abel
all_goals apply Continuous.intervalIntegrable; continuity
rw [this, β add_zero ((Ο / b : β) ^ (1 / 2 : β)), β integral_gaussian_complex hb]
refine Tendsto.add ?_ (tendsto_verticalIntegral hb c)
exact
intervalIntegral_tendsto_integral (integrable_cexp_neg_mul_sq hb) tendsto_neg_atTop_atBot
tendsto_id
theorem _root_.integral_cexp_quadratic (hb : b.re < 0) (c d : β) :
β« x : β,
cexp (b * x ^ 2 + c * x + d) = (Ο / -b) ^ (1 / 2 : β) * cexp (d - c ^ 2 / (4 * b)) := by
have hb' : b β 0 := by contrapose! hb; rw [hb, zero_re]
have h (x : β) : cexp (b * x ^ 2 + c * x + d) =
cexp (- -b * (x + c / (2 * b)) ^ 2) * cexp (d - c ^ 2 / (4 * b)) := by
simp_rw [β Complex.exp_add]
congr 1
field
simp_rw [h, MeasureTheory.integral_mul_const]
rw [β re_add_im (c / (2 * b))]
simp_rw [β add_assoc, β ofReal_add]
rw [integral_add_right_eq_self fun a : β β¦ cexp (- -b * (βa + β(c / (2 * b)).im * I) ^ 2),
integral_cexp_neg_mul_sq_add_real_mul_I ((neg_re b).symm βΈ (neg_pos.mpr hb))]
lemma _root_.integrable_cexp_quadratic' (hb : b.re < 0) (c d : β) :
Integrable (fun (x : β) β¦ cexp (b * x ^ 2 + c * x + d)) := by
have hb' : b β 0 := by contrapose! hb; rw [hb, zero_re]
by_contra H
simpa [hb', pi_ne_zero, Complex.exp_ne_zero, integral_undef H]
using integral_cexp_quadratic hb c d
lemma _root_.integrable_cexp_quadratic (hb : 0 < b.re) (c d : β) :
Integrable (fun (x : β) β¦ cexp (-b * x ^ 2 + c * x + d)) := by
have : (-b).re < 0 := by simpa using hb
exact integrable_cexp_quadratic' this c d
theorem _root_.fourierIntegral_gaussian (hb : 0 < b.re) (t : β) :
β« x : β, cexp (I * t * x) * cexp (-b * x ^ 2) =
(Ο / b) ^ (1 / 2 : β) * cexp (-t ^ 2 / (4 * b)) := by
conv => enter [1, 2, x]; rw [β Complex.exp_add, add_comm, β add_zero (-b * x ^ 2 + I * t * x)]
rw [integral_cexp_quadratic (show (-b).re < 0 by rwa [neg_re, neg_lt_zero]), neg_neg, zero_sub,
mul_neg, div_neg, neg_neg, mul_pow, I_sq, neg_one_mul, mul_comm]
theorem _root_.fourierIntegral_gaussian_pi' (hb : 0 < b.re) (c : β) :
(π fun x : β => cexp (-Ο * b * x ^ 2 + 2 * Ο * c * x)) = fun t : β =>
1 / b ^ (1 / 2 : β) * cexp (-Ο / b * (t + I * c) ^ 2) := by
haveI : b β 0 := by contrapose! hb; rw [hb, zero_re]
have h : (-βΟ * b).re < 0 := by
simpa only [neg_mul, neg_re, re_ofReal_mul, neg_lt_zero] using mul_pos pi_pos hb
ext1 t
simp_rw [fourierIntegral_real_eq_integral_exp_smul, smul_eq_mul, β Complex.exp_add, β add_assoc]
have (x : β) : β(-2 * Ο * x * t) * I + -Ο * b * x ^ 2 + 2 * Ο * c * x =
-Ο * b * x ^ 2 + (-2 * Ο * I * t + 2 * Ο * c) * x + 0 := by push_cast; ring
simp_rw [this, integral_cexp_quadratic h, neg_mul, neg_neg]
congr 2
Β· rw [β div_div, div_self <| ofReal_ne_zero.mpr pi_ne_zero, one_div, inv_cpow, β one_div]
rw [Ne, arg_eq_pi_iff, not_and_or, not_lt]
exact Or.inl hb.le
Β· field_simp
ring_nf
simp only [I_sq]
ring
theorem _root_.fourierIntegral_gaussian_pi (hb : 0 < b.re) :
(π fun (x : β) β¦ cexp (-Ο * b * x ^ 2)) =
fun t : β β¦ 1 / b ^ (1 / 2 : β) * cexp (-Ο / b * t ^ 2) := by
simpa only [mul_zero, zero_mul, add_zero] using fourierIntegral_gaussian_pi' hb 0
section InnerProductSpace
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace β V] [FiniteDimensional β V]
[MeasurableSpace V] [BorelSpace V]
theorem integrable_cexp_neg_sum_mul_add {ΞΉ : Type*} [Fintype ΞΉ] {b : ΞΉ β β}
(hb : β i, 0 < (b i).re) (c : ΞΉ β β) :
Integrable (fun (v : ΞΉ β β) β¦ cexp (-β i, b i * (v i : β) ^ 2 + β i, c i * v i)) := by
simp_rw [β Finset.sum_neg_distrib, β Finset.sum_add_distrib, Complex.exp_sum, β neg_mul]
apply Integrable.fintype_prod (f := fun i (v : β) β¦ cexp (-b i * v ^ 2 + c i * v)) (fun i β¦ ?_)
convert integrable_cexp_quadratic (hb i) (c i) 0 using 3 with x
simp only [add_zero]
theorem integrable_cexp_neg_mul_sum_add {ΞΉ : Type*} [Fintype ΞΉ] (hb : 0 < b.re) (c : ΞΉ β β) :
Integrable (fun (v : ΞΉ β β) β¦ cexp (-b * β i, (v i : β) ^ 2 + β i, c i * v i)) := by
simp_rw [neg_mul, Finset.mul_sum]
exact integrable_cexp_neg_sum_mul_add (fun _ β¦ hb) c
theorem integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace
{ΞΉ : Type*} [Fintype ΞΉ] (hb : 0 < b.re) (c : β) (w : EuclideanSpace β ΞΉ) :
Integrable (fun (v : EuclideanSpace β ΞΉ) β¦ cexp (- b * βvβ^2 + c * βͺw, vβ«)) := by
rw [β (PiLp.volume_preserving_toLp ΞΉ).integrable_comp_emb
(MeasurableEquiv.toLp 2 _).measurableEmbedding]
simp only [neg_mul, Function.comp_def]
convert integrable_cexp_neg_mul_sum_add hb (fun i β¦ c * w i) using 3 with v
simp only [EuclideanSpace.norm_eq, norm_eq_abs, sq_abs, PiLp.inner_apply, RCLike.inner_apply,
conj_trivial, ofReal_sum, ofReal_mul, Finset.mul_sum, neg_mul, Finset.sum_neg_distrib, mul_assoc]
norm_cast
rw [sq_sqrt]
Β· simp [Finset.mul_sum, mul_comm]
Β· exact Finset.sum_nonneg (fun i _hi β¦ by positivity)
/-- In a real inner product space, the complex exponential of minus the square of the norm plus
a scalar product is integrable. Useful when discussing the Fourier transform of a Gaussian. -/
theorem integrable_cexp_neg_mul_sq_norm_add (hb : 0 < b.re) (c : β) (w : V) :
Integrable (fun (v : V) β¦ cexp (-b * βvβ ^ 2 + c * βͺw, vβ«)) := by
let e := (stdOrthonormalBasis β V).repr.symm
rw [β e.measurePreserving.integrable_comp_emb e.toHomeomorph.measurableEmbedding]
convert integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace
hb c (e.symm w) with v
simp only [neg_mul, Function.comp_apply, LinearIsometryEquiv.norm_map,
LinearIsometryEquiv.symm_symm,
LinearIsometryEquiv.inner_map_eq_flip]
theorem integral_cexp_neg_sum_mul_add {ΞΉ : Type*} [Fintype ΞΉ] {b : ΞΉ β β}
(hb : β i, 0 < (b i).re) (c : ΞΉ β β) :
β« v : ΞΉ β β, cexp (-β i, b i * (v i : β) ^ 2 + β i, c i * v i)
= β i, (Ο / b i) ^ (1 / 2 : β) * cexp (c i ^ 2 / (4 * b i)) := by
simp_rw [β Finset.sum_neg_distrib, β Finset.sum_add_distrib, Complex.exp_sum, β neg_mul]
rw [integral_fintype_prod_volume_eq_prod (f := fun i (v : β) β¦ cexp (-b i * v ^ 2 + c i * v))]
congr with i
have : (-b i).re < 0 := by simpa using hb i
convert integral_cexp_quadratic this (c i) 0 using 1 <;> simp [div_neg]
theorem integral_cexp_neg_mul_sum_add {ΞΉ : Type*} [Fintype ΞΉ] (hb : 0 < b.re) (c : ΞΉ β β) :
β« v : ΞΉ β β, cexp (-b * β i, (v i : β) ^ 2 + β i, c i * v i)
= (Ο / b) ^ (Fintype.card ΞΉ / 2 : β) * cexp ((β i, c i ^ 2) / (4 * b)) := by
simp_rw [neg_mul, Finset.mul_sum, integral_cexp_neg_sum_mul_add (fun _ β¦ hb) c, one_div,
Finset.prod_mul_distrib, Finset.prod_const, β cpow_nat_mul, β Complex.exp_sum, Fintype.card,
Finset.sum_div, div_eq_mul_inv]
theorem integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace
{ΞΉ : Type*} [Fintype ΞΉ] (hb : 0 < b.re) (c : β) (w : EuclideanSpace β ΞΉ) :
β« v : EuclideanSpace β ΞΉ, cexp (- b * βvβ^2 + c * βͺw, vβ«) =
(Ο / b) ^ (Fintype.card ΞΉ / 2 : β) * cexp (c ^ 2 * βwβ^2 / (4 * b)) := by
rw [β (PiLp.volume_preserving_toLp ΞΉ).integral_comp
(MeasurableEquiv.toLp 2 _).measurableEmbedding]
simp only [neg_mul]
convert integral_cexp_neg_mul_sum_add hb (fun i β¦ c * w i) using 5 with _x y
Β· simp only [EuclideanSpace.norm_eq, norm_eq_abs, sq_abs, neg_mul, neg_inj, mul_eq_mul_left_iff]
norm_cast
left
rw [sq_sqrt]
exact Finset.sum_nonneg (fun i _hi β¦ by positivity)
Β· simp [PiLp.inner_apply, Finset.mul_sum, mul_assoc]
simp_rw [mul_comm]
Β· simp only [EuclideanSpace.norm_eq, Real.norm_eq_abs, sq_abs, mul_pow, β Finset.mul_sum]
congr
norm_cast
rw [sq_sqrt]
exact Finset.sum_nonneg (fun i _hi β¦ by positivity)
theorem integral_cexp_neg_mul_sq_norm_add
(hb : 0 < b.re) (c : β) (w : V) :
β« v : V, cexp (-b * βvβ ^ 2 + c * βͺw, vβ«) =
(Ο / b) ^ (Module.finrank β V / 2 : β) * cexp (c ^ 2 * βwβ ^ 2 / (4 * b)) := by
let e := (stdOrthonormalBasis β V).repr.symm
rw [β e.measurePreserving.integral_comp e.toHomeomorph.measurableEmbedding]
convert integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace
hb c (e.symm w) <;> simp [LinearIsometryEquiv.inner_map_eq_flip]
theorem integral_cexp_neg_mul_sq_norm (hb : 0 < b.re) :
β« v : V, cexp (-b * βvβ ^ 2) = (Ο / b) ^ (Module.finrank β V / 2 : β) := by
simpa using integral_cexp_neg_mul_sq_norm_add hb 0 (0 : V)
theorem integral_rexp_neg_mul_sq_norm {b : β} (hb : 0 < b) :
β« v : V, rexp (-b * βvβ ^ 2) = (Ο / b) ^ (Module.finrank β V / 2 : β) := by
rw [β ofReal_inj]
convert integral_cexp_neg_mul_sq_norm (show 0 < (b : β).re from hb) (V := V)
Β· change ofRealLI (β« (v : V), rexp (-b * βvβ ^ 2)) = β« (v : V), cexp (-βb * ββvβ ^ 2)
rw [β ofRealLI.integral_comp_comm]
simp [ofRealLI]
Β· rw [β ofReal_div, ofReal_cpow (by positivity)]
simp
theorem _root_.fourierIntegral_gaussian_innerProductSpace' (hb : 0 < b.re) (x w : V) :
π (fun v β¦ cexp (-b * βvβ ^ 2 + 2 * Ο * Complex.I * βͺx, vβ«)) w =
(Ο / b) ^ (Module.finrank β V / 2 : β) * cexp (-Ο ^ 2 * βx - wβ ^ 2 / b) := by
simp only [neg_mul, fourierIntegral_eq', ofReal_neg, ofReal_mul, ofReal_ofNat,
smul_eq_mul, β Complex.exp_add, real_inner_comm w]
convert integral_cexp_neg_mul_sq_norm_add hb (2 * Ο * Complex.I) (x - w) using 3 with v
Β· congr 1
simp [inner_sub_left]
ring
Β· have : b β 0 := by contrapose! hb; rw [hb, zero_re]
simp [mul_pow]
ring
theorem _root_.fourierIntegral_gaussian_innerProductSpace (hb : 0 < b.re) (w : V) :
π (fun (v : V) β¦ cexp (-b * βvβ ^ 2)) w =
(Ο / b) ^ (Module.finrank β V / 2 : β) * cexp (-Ο ^ 2 * βwβ ^ 2 / b) := by
simpa using fourierIntegral_gaussian_innerProductSpace' hb 0 w
end InnerProductSpace
end GaussianFourier |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Gaussian/PoissonSummation.lean | import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform
import Mathlib.Analysis.Fourier.PoissonSummation
/-!
# Poisson summation applied to the Gaussian
In `Real.tsum_exp_neg_mul_int_sq` and `Complex.tsum_exp_neg_mul_int_sq`, we use Poisson summation
to prove the identity
`β' (n : β€), exp (-Ο * a * n ^ 2) = 1 / a ^ (1 / 2) * β' (n : β€), exp (-Ο / a * n ^ 2)`
for positive real `a`, or complex `a` with positive real part. (See also
`NumberTheory.ModularForms.JacobiTheta`.)
-/
open Real Set MeasureTheory Filter Asymptotics intervalIntegral
open scoped Real Topology FourierTransform RealInnerProductSpace
open Complex hiding exp continuous_exp
noncomputable section
section GaussianPoisson
/-! First we show that Gaussian-type functions have rapid decay along `cocompact β`. -/
lemma rexp_neg_quadratic_isLittleO_rpow_atTop {a : β} (ha : a < 0) (b s : β) :
(fun x β¦ rexp (a * x ^ 2 + b * x)) =o[atTop] (Β· ^ s) := by
suffices (fun x β¦ rexp (a * x ^ 2 + b * x)) =o[atTop] (fun x β¦ rexp (-x)) by
refine this.trans ?_
simpa only [neg_one_mul] using isLittleO_exp_neg_mul_rpow_atTop zero_lt_one s
rw [isLittleO_exp_comp_exp_comp]
have : (fun x β¦ -x - (a * x ^ 2 + b * x)) = fun x β¦ x * (-a * x - (b + 1)) := by
ext1 x; ring_nf
rw [this]
exact tendsto_id.atTop_mul_atTopβ <| tendsto_atTop_add_const_right _ _ <|
tendsto_id.const_mul_atTop (neg_pos.mpr ha)
lemma cexp_neg_quadratic_isLittleO_rpow_atTop {a : β} (ha : a.re < 0) (b : β) (s : β) :
(fun x : β β¦ cexp (a * x ^ 2 + b * x)) =o[atTop] (Β· ^ s) := by
apply Asymptotics.IsLittleO.of_norm_left
convert rexp_neg_quadratic_isLittleO_rpow_atTop ha b.re s with x
simp_rw [Complex.norm_exp, add_re, β ofReal_pow, mul_comm (_ : β) β(_ : β),
re_ofReal_mul, mul_comm _ (re _)]
lemma cexp_neg_quadratic_isLittleO_abs_rpow_cocompact {a : β} (ha : a.re < 0) (b : β) (s : β) :
(fun x : β β¦ cexp (a * x ^ 2 + b * x)) =o[cocompact β] (|Β·| ^ s) := by
rw [cocompact_eq_atBot_atTop, isLittleO_sup]
constructor
Β· refine ((cexp_neg_quadratic_isLittleO_rpow_atTop ha (-b) s).comp_tendsto
Filter.tendsto_neg_atBot_atTop).congr' (Eventually.of_forall fun x β¦ ?_) ?_
Β· simp only [neg_mul, Function.comp_apply, ofReal_neg, neg_sq, mul_neg, neg_neg]
Β· refine (eventually_lt_atBot 0).mp (Eventually.of_forall fun x hx β¦ ?_)
simp only [Function.comp_apply, abs_of_neg hx]
Β· refine (cexp_neg_quadratic_isLittleO_rpow_atTop ha b s).congr' EventuallyEq.rfl ?_
refine (eventually_gt_atTop 0).mp (Eventually.of_forall fun x hx β¦ ?_)
simp_rw [abs_of_pos hx]
theorem tendsto_rpow_abs_mul_exp_neg_mul_sq_cocompact {a : β} (ha : 0 < a) (s : β) :
Tendsto (fun x : β => |x| ^ s * rexp (-a * x ^ 2)) (cocompact β) (π 0) := by
conv in rexp _ => rw [β sq_abs]
rw [cocompact_eq_atBot_atTop, β comap_abs_atTop]
erw [tendsto_comap'_iff (m := fun y => y ^ s * rexp (-a * y ^ 2))
(mem_atTop_sets.mpr β¨0, fun b hb => β¨b, abs_of_nonneg hbβ©β©)]
exact
(rpow_mul_exp_neg_mul_sq_isLittleO_exp_neg ha s).tendsto_zero_of_tendsto
(tendsto_exp_atBot.comp <| tendsto_id.const_mul_atTop_of_neg (neg_lt_zero.mpr one_half_pos))
theorem isLittleO_exp_neg_mul_sq_cocompact {a : β} (ha : 0 < a.re) (s : β) :
(fun x : β => Complex.exp (-a * x ^ 2)) =o[cocompact β] fun x : β => |x| ^ s := by
convert cexp_neg_quadratic_isLittleO_abs_rpow_cocompact (?_ : (-a).re < 0) 0 s using 1
Β· simp_rw [zero_mul, add_zero]
Β· rwa [neg_re, neg_lt_zero]
/-- Jacobi's theta-function transformation formula for the sum of `exp -Q(x)`, where `Q` is a
negative definite quadratic form. -/
theorem Complex.tsum_exp_neg_quadratic {a : β} (ha : 0 < a.re) (b : β) :
(β' n : β€, cexp (-Ο * a * n ^ 2 + 2 * Ο * b * n)) =
1 / a ^ (1 / 2 : β) * β' n : β€, cexp (-Ο / a * (n + I * b) ^ 2) := by
let f : β β β := fun x β¦ cexp (-Ο * a * x ^ 2 + 2 * Ο * b * x)
have hCf : Continuous f := by
refine Complex.continuous_exp.comp (Continuous.add ?_ ?_)
Β· exact continuous_const.mul (Complex.continuous_ofReal.pow 2)
Β· exact continuous_const.mul Complex.continuous_ofReal
have hFf : π f = fun x : β β¦ 1 / a ^ (1 / 2 : β) * cexp (-Ο / a * (x + I * b) ^ 2) :=
fourierIntegral_gaussian_pi' ha b
have h1 : 0 < (βΟ * a).re := by
rw [re_ofReal_mul]
exact mul_pos pi_pos ha
have h2 : 0 < (βΟ / a).re := by
rw [div_eq_mul_inv, re_ofReal_mul, inv_re]
refine mul_pos pi_pos (div_pos ha <| normSq_pos.mpr ?_)
contrapose! ha
rw [ha, zero_re]
have f_bd : f =O[cocompact β] (fun x => |x| ^ (-2 : β)) := by
convert (cexp_neg_quadratic_isLittleO_abs_rpow_cocompact ?_ _ (-2)).isBigO
rwa [neg_mul, neg_re, neg_lt_zero]
have Ff_bd : (π f) =O[cocompact β] (fun x => |x| ^ (-2 : β)) := by
rw [hFf]
have : β (x : β), -βΟ / a * (βx + I * b) ^ 2 =
-βΟ / a * x ^ 2 + (-2 * Ο * I * b) / a * x + Ο * b ^ 2 / a := by
intro x; ring_nf; rw [I_sq]; ring
simp_rw [this]
conv => enter [2, x]; rw [Complex.exp_add, β mul_assoc _ _ (Complex.exp _), mul_comm]
refine ((cexp_neg_quadratic_isLittleO_abs_rpow_cocompact
(?_) (-2 * βΟ * I * b / a) (-2)).isBigO.const_mul_left _).const_mul_left _
rwa [neg_div, neg_re, neg_lt_zero]
convert Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay hCf one_lt_two f_bd Ff_bd 0 using 1
Β· simp only [f, zero_add, ofReal_intCast]
Β· rw [β tsum_mul_left]
simp only [QuotientAddGroup.mk_zero, fourier_eval_zero, mul_one, hFf, ofReal_intCast]
theorem Complex.tsum_exp_neg_mul_int_sq {a : β} (ha : 0 < a.re) :
(β' n : β€, cexp (-Ο * a * (n : β) ^ 2)) =
1 / a ^ (1 / 2 : β) * β' n : β€, cexp (-Ο / a * (n : β) ^ 2) := by
simpa only [mul_zero, zero_mul, add_zero] using Complex.tsum_exp_neg_quadratic ha 0
theorem Real.tsum_exp_neg_mul_int_sq {a : β} (ha : 0 < a) :
(β' n : β€, exp (-Ο * a * (n : β) ^ 2)) =
(1 : β) / a ^ (1 / 2 : β) * (β' n : β€, exp (-Ο / a * (n : β) ^ 2)) := by
simpa only [β ofReal_inj, ofReal_tsum, ofReal_exp, ofReal_mul, ofReal_neg, ofReal_pow,
ofReal_intCast, ofReal_div, ofReal_one, ofReal_cpow ha.le, ofReal_ofNat, mul_zero, zero_mul,
add_zero] using Complex.tsum_exp_neg_quadratic (by rwa [ofReal_re] : 0 < (a : β).re) 0
end GaussianPoisson |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Gaussian/GaussianIntegral.lean | import Mathlib.Analysis.SpecialFunctions.Gamma.Basic
import Mathlib.Analysis.SpecialFunctions.PolarCoord
import Mathlib.Analysis.Complex.Convex
import Mathlib.Data.Nat.Factorial.DoubleFactorial
/-!
# Gaussian integral
We prove various versions of the formula for the Gaussian integral:
* `integral_gaussian`: for real `b` we have `β« x:β, exp (-b * x^2) = β(Ο / b)`.
* `integral_gaussian_complex`: for complex `b` with `0 < re b` we have
`β« x:β, exp (-b * x^2) = (Ο / b) ^ (1 / 2)`.
* `integral_gaussian_Ioi` and `integral_gaussian_complex_Ioi`: variants for integrals over `Ioi 0`.
* `Complex.Gamma_one_half_eq`: the formula `Ξ (1 / 2) = βΟ`.
-/
noncomputable section
open Real Set MeasureTheory Filter Asymptotics
open scoped Real Topology
open Complex hiding exp
theorem exp_neg_mul_rpow_isLittleO_exp_neg {p b : β} (hb : 0 < b) (hp : 1 < p) :
(fun x : β => exp (- b * x ^ p)) =o[atTop] fun x : β => exp (-x) := by
rw [isLittleO_exp_comp_exp_comp]
suffices Tendsto (fun x => x * (b * x ^ (p - 1) + -1)) atTop atTop by
refine Tendsto.congr' ?_ this
refine eventuallyEq_of_mem (Ioi_mem_atTop (0 : β)) (fun x hx => ?_)
rw [mem_Ioi] at hx
rw [rpow_sub_one hx.ne']
field
apply tendsto_id.atTop_mul_atTopβ
refine tendsto_atTop_add_const_right atTop (-1 : β) ?_
exact Tendsto.const_mul_atTop hb (tendsto_rpow_atTop (by linarith))
theorem exp_neg_mul_sq_isLittleO_exp_neg {b : β} (hb : 0 < b) :
(fun x : β => exp (-b * x ^ 2)) =o[atTop] fun x : β => exp (-x) := by
simp_rw [β rpow_two]
exact exp_neg_mul_rpow_isLittleO_exp_neg hb one_lt_two
theorem rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg (s : β) {b p : β} (hp : 1 < p) (hb : 0 < b) :
(fun x : β => x ^ s * exp (- b * x ^ p)) =o[atTop] fun x : β => exp (-(1 / 2) * x) := by
apply ((isBigO_refl (fun x : β => x ^ s) atTop).mul_isLittleO
(exp_neg_mul_rpow_isLittleO_exp_neg hb hp)).trans
simpa only [mul_comm] using Real.Gamma_integrand_isLittleO s
theorem rpow_mul_exp_neg_mul_sq_isLittleO_exp_neg {b : β} (hb : 0 < b) (s : β) :
(fun x : β => x ^ s * exp (-b * x ^ 2)) =o[atTop] fun x : β => exp (-(1 / 2) * x) := by
simp_rw [β rpow_two]
exact rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg s one_lt_two hb
theorem integrableOn_rpow_mul_exp_neg_rpow {p s : β} (hs : -1 < s) (hp : 1 β€ p) :
IntegrableOn (fun x : β => x ^ s * exp (- x ^ p)) (Ioi 0) := by
obtain hp | hp := le_iff_lt_or_eq.mp hp
Β· have h_exp : β x, ContinuousAt (fun x => exp (- x)) x := fun x => continuousAt_neg.rexp
rw [β Ioc_union_Ioi_eq_Ioi zero_le_one, integrableOn_union]
constructor
Β· rw [β integrableOn_Icc_iff_integrableOn_Ioc]
refine IntegrableOn.mul_continuousOn ?_ ?_ isCompact_Icc
Β· refine (intervalIntegrable_iff_integrableOn_Icc_of_le zero_le_one).mp ?_
exact intervalIntegral.intervalIntegrable_rpow' hs
Β· intro x _
change ContinuousWithinAt ((fun x => exp (- x)) β (fun x => x ^ p)) (Icc 0 1) x
refine ContinuousAt.comp_continuousWithinAt (h_exp _) ?_
exact continuousWithinAt_id.rpow_const (Or.inr (le_of_lt (lt_trans zero_lt_one hp)))
Β· have h_rpow : β (x r : β), x β Ici 1 β ContinuousWithinAt (fun x => x ^ r) (Ici 1) x := by
intro _ _ hx
refine continuousWithinAt_id.rpow_const (Or.inl ?_)
exact ne_of_gt (lt_of_lt_of_le zero_lt_one hx)
refine integrable_of_isBigO_exp_neg (by simp : (0 : β) < 1 / 2)
(ContinuousOn.mul (fun x hx => h_rpow x s hx) (fun x hx => ?_)) (IsLittleO.isBigO ?_)
Β· change ContinuousWithinAt ((fun x => exp (- x)) β (fun x => x ^ p)) (Ici 1) x
exact ContinuousAt.comp_continuousWithinAt (h_exp _) (h_rpow x p hx)
Β· convert rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg s hp (by simp : (0 : β) < 1) using 3
rw [neg_mul, one_mul]
Β· simp_rw [β hp, Real.rpow_one]
convert Real.GammaIntegral_convergent (by linarith : 0 < s + 1) using 2
rw [add_sub_cancel_right, mul_comm]
theorem integrableOn_rpow_mul_exp_neg_mul_rpow {p s b : β} (hs : -1 < s) (hp : 1 β€ p) (hb : 0 < b) :
IntegrableOn (fun x : β => x ^ s * exp (- b * x ^ p)) (Ioi 0) := by
have hib : 0 < b ^ (-pβ»ΒΉ) := rpow_pos_of_pos hb _
suffices IntegrableOn (fun x β¦ (b ^ (-pβ»ΒΉ)) ^ s * (x ^ s * exp (-x ^ p))) (Ioi 0) by
rw [show 0 = b ^ (-pβ»ΒΉ) * 0 by rw [mul_zero], β integrableOn_Ioi_comp_mul_left_iff _ _ hib]
refine this.congr_fun (fun _ hx => ?_) measurableSet_Ioi
rw [β mul_assoc, mul_rpow, mul_rpow, β rpow_mul (z := p), neg_mul, neg_mul, inv_mul_cancelβ,
rpow_neg_one, mul_inv_cancel_leftβ]
all_goals linarith [mem_Ioi.mp hx]
refine Integrable.const_mul ?_ _
rw [β IntegrableOn]
exact integrableOn_rpow_mul_exp_neg_rpow hs hp
theorem integrableOn_rpow_mul_exp_neg_mul_sq {b : β} (hb : 0 < b) {s : β} (hs : -1 < s) :
IntegrableOn (fun x : β => x ^ s * exp (-b * x ^ 2)) (Ioi 0) := by
simp_rw [β rpow_two]
exact integrableOn_rpow_mul_exp_neg_mul_rpow hs one_le_two hb
theorem integrable_rpow_mul_exp_neg_mul_sq {b : β} (hb : 0 < b) {s : β} (hs : -1 < s) :
Integrable fun x : β => x ^ s * exp (-b * x ^ 2) := by
rw [β integrableOn_univ, β @Iio_union_Ici _ _ (0 : β), integrableOn_union,
integrableOn_Ici_iff_integrableOn_Ioi]
refine β¨?_, integrableOn_rpow_mul_exp_neg_mul_sq hb hsβ©
rw [β (Measure.measurePreserving_neg (volume : Measure β)).integrableOn_comp_preimage
(Homeomorph.neg β).measurableEmbedding]
simp only [Function.comp_def, neg_sq, neg_preimage, neg_Iio, neg_zero]
apply Integrable.mono' (integrableOn_rpow_mul_exp_neg_mul_sq hb hs)
Β· apply Measurable.aestronglyMeasurable
exact (measurable_id'.neg.pow measurable_const).mul
((measurable_id'.pow measurable_const).const_mul (-b)).exp
Β· have : MeasurableSet (Ioi (0 : β)) := measurableSet_Ioi
filter_upwards [ae_restrict_mem this] with x hx
have h'x : 0 β€ x := le_of_lt hx
rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg (exp_pos _).le]
apply mul_le_mul_of_nonneg_right _ (exp_pos _).le
simpa [abs_of_nonneg h'x] using abs_rpow_le_abs_rpow (-x) s
theorem integrable_exp_neg_mul_sq {b : β} (hb : 0 < b) :
Integrable fun x : β => exp (-b * x ^ 2) := by
simpa using integrable_rpow_mul_exp_neg_mul_sq hb (by simp : (-1 : β) < 0)
theorem integrableOn_Ioi_exp_neg_mul_sq_iff {b : β} :
IntegrableOn (fun x : β => exp (-b * x ^ 2)) (Ioi 0) β 0 < b := by
refine β¨fun h => ?_, fun h => (integrable_exp_neg_mul_sq h).integrableOnβ©
by_contra! hb
have : β«β» _ : β in Ioi 0, 1 β€ β«β» x : β in Ioi 0, βexp (-b * x ^ 2)ββ := by
apply lintegral_mono (fun x β¦ _)
simp only [neg_mul, ENNReal.one_le_coe_iff, β toNNReal_one, toNNReal_le_iff_le_coe,
Real.norm_of_nonneg (exp_pos _).le, coe_nnnorm, one_le_exp_iff, Right.nonneg_neg_iff]
exact fun x β¦ mul_nonpos_of_nonpos_of_nonneg hb (sq_nonneg x)
simpa using this.trans_lt h.2
theorem integrable_exp_neg_mul_sq_iff {b : β} :
(Integrable fun x : β => exp (-b * x ^ 2)) β 0 < b :=
β¨fun h => integrableOn_Ioi_exp_neg_mul_sq_iff.mp h.integrableOn, integrable_exp_neg_mul_sqβ©
theorem integrable_mul_exp_neg_mul_sq {b : β} (hb : 0 < b) :
Integrable fun x : β => x * exp (-b * x ^ 2) := by
simpa using integrable_rpow_mul_exp_neg_mul_sq hb (by simp : (-1 : β) < 1)
theorem norm_cexp_neg_mul_sq (b : β) (x : β) :
βComplex.exp (-b * (x : β) ^ 2)β = exp (-b.re * x ^ 2) := by
rw [norm_exp, β ofReal_pow, mul_comm (-b) _, re_ofReal_mul, neg_re, mul_comm]
theorem integrable_cexp_neg_mul_sq {b : β} (hb : 0 < b.re) :
Integrable fun x : β => cexp (-b * (x : β) ^ 2) := by
refine β¨(Complex.continuous_exp.comp
(continuous_const.mul (continuous_ofReal.pow 2))).aestronglyMeasurable, ?_β©
rw [β hasFiniteIntegral_norm_iff]
simp_rw [norm_cexp_neg_mul_sq]
exact (integrable_exp_neg_mul_sq hb).2
theorem integrable_mul_cexp_neg_mul_sq {b : β} (hb : 0 < b.re) :
Integrable fun x : β => βx * cexp (-b * (x : β) ^ 2) := by
refine β¨(continuous_ofReal.mul (Complex.continuous_exp.comp ?_)).aestronglyMeasurable, ?_β©
Β· exact continuous_const.mul (continuous_ofReal.pow 2)
have := (integrable_mul_exp_neg_mul_sq hb).hasFiniteIntegral
rw [β hasFiniteIntegral_norm_iff] at this β’
convert this
rw [norm_mul, norm_mul, norm_cexp_neg_mul_sq b, norm_real, norm_of_nonneg (exp_pos _).le]
theorem integral_mul_cexp_neg_mul_sq {b : β} (hb : 0 < b.re) :
β« r : β in Ioi 0, (r : β) * cexp (-b * (r : β) ^ 2) = (2 * b)β»ΒΉ := by
have hb' : b β 0 := by contrapose! hb; rw [hb, zero_re]
have A : β x : β, HasDerivAt (fun x => -(2 * b)β»ΒΉ * cexp (-b * x ^ 2))
(x * cexp (-b * x ^ 2)) x := by
intro x
convert ((hasDerivAt_pow 2 x).const_mul (-b)).cexp.const_mul (-(2 * b)β»ΒΉ) using 1
field
have B : Tendsto (fun y : β β¦ -(2 * b)β»ΒΉ * cexp (-b * (y : β) ^ 2))
atTop (π (-(2 * b)β»ΒΉ * 0)) := by
refine Tendsto.const_mul _ (tendsto_zero_iff_norm_tendsto_zero.mpr ?_)
simp_rw [norm_cexp_neg_mul_sq b]
exact tendsto_exp_atBot.comp
((tendsto_pow_atTop two_ne_zero).const_mul_atTop_of_neg (neg_lt_zero.2 hb))
convert integral_Ioi_of_hasDerivAt_of_tendsto' (fun x _ => (A βx).comp_ofReal)
(integrable_mul_cexp_neg_mul_sq hb).integrableOn B using 1
simp only [mul_zero, ofReal_zero, zero_pow, Ne,
not_false_iff, Complex.exp_zero, mul_one, sub_neg_eq_add, zero_add, reduceCtorEq]
/-- The *square* of the Gaussian integral `β« x:β, exp (-b * x^2)` is equal to `Ο / b`. -/
theorem integral_gaussian_sq_complex {b : β} (hb : 0 < b.re) :
(β« x : β, cexp (-b * (x : β) ^ 2)) ^ 2 = Ο / b := by
/- We compute `(β« exp (-b x^2))^2` as an integral over `β^2`, and then make a polar change
of coordinates. We are left with `β« r * exp (-b r^2)`, which has been computed in
`integral_mul_cexp_neg_mul_sq` using the fact that this function has an obvious primitive. -/
calc
(β« x : β, cexp (-b * (x : β) ^ 2)) ^ 2 =
β« p : β Γ β, cexp (-b * (p.1 : β) ^ 2) * cexp (-b * (p.2 : β) ^ 2) := by
rw [pow_two, β integral_prod_mul]; rfl
_ = β« p : β Γ β, cexp (-b * ((p.1 : β)^ 2 + (p.2 : β) ^ 2)) := by
congr
ext1 p
rw [β Complex.exp_add, mul_add]
_ = β« p in polarCoord.target, p.1 β’
cexp (-b * ((p.1 * Complex.cos p.2) ^ 2 + (p.1 * Complex.sin p.2) ^ 2)) := by
rw [β integral_comp_polarCoord_symm]
simp only [polarCoord_symm_apply, ofReal_mul, ofReal_cos, ofReal_sin]
_ = (β« r in Ioi (0 : β), r * cexp (-b * (r : β) ^ 2)) * β« ΞΈ in Ioo (-Ο) Ο, 1 := by
rw [β setIntegral_prod_mul]
congr with p : 1
rw [mul_one]
congr
conv_rhs => rw [β one_mul ((p.1 : β) ^ 2), β sin_sq_add_cos_sq (p.2 : β)]
ring
_ = βΟ / b := by
simp only [integral_const, MeasurableSet.univ, measureReal_restrict_apply,
univ_inter, real_smul, mul_one, integral_mul_cexp_neg_mul_sq hb]
rw [volume_real_Ioo_of_le (by linarith [pi_nonneg])]
simp
ring
theorem integral_gaussian (b : β) : β« x : β, exp (-b * x ^ 2) = β(Ο / b) := by
-- First we deal with the crazy case where `b β€ 0`: then both sides vanish.
rcases le_or_gt b 0 with (hb | hb)
Β· rw [integral_undef, sqrt_eq_zero_of_nonpos]
Β· exact div_nonpos_of_nonneg_of_nonpos pi_pos.le hb
Β· simpa only [not_lt, integrable_exp_neg_mul_sq_iff] using hb
-- Assume now `b > 0`. Then both sides are non-negative and their squares agree.
refine (sq_eq_sqβ (by positivity) (by positivity)).1 ?_
rw [β ofReal_inj, ofReal_pow, β coe_algebraMap, RCLike.algebraMap_eq_ofReal, β integral_ofReal,
sq_sqrt (div_pos pi_pos hb).le, β RCLike.algebraMap_eq_ofReal, coe_algebraMap, ofReal_div]
convert integral_gaussian_sq_complex (by rwa [ofReal_re] : 0 < (b : β).re) with _ x
rw [ofReal_exp, ofReal_mul, ofReal_pow, ofReal_neg]
theorem continuousAt_gaussian_integral (b : β) (hb : 0 < re b) :
ContinuousAt (fun c : β => β« x : β, cexp (-c * (x : β) ^ 2)) b := by
let f : β β β β β := fun (c : β) (x : β) => cexp (-c * (x : β) ^ 2)
obtain β¨d, hd, hd'β© := exists_between hb
have f_meas : β c : β, AEStronglyMeasurable (f c) volume := fun c => by
apply Continuous.aestronglyMeasurable
exact Complex.continuous_exp.comp (continuous_const.mul (continuous_ofReal.pow 2))
have f_cts : β x : β, ContinuousAt (fun c => f c x) b := fun x =>
(Complex.continuous_exp.comp (continuous_id'.neg.mul continuous_const)).continuousAt
have f_le_bd : βαΆ c : β in π b, βα΅ x : β, βf c xβ β€ exp (-d * x ^ 2) := by
refine eventually_of_mem ((continuous_re.isOpen_preimage _ isOpen_Ioi).mem_nhds hd') ?_
intro c hc; filter_upwards with x
rw [norm_cexp_neg_mul_sq]
gcongr
exact le_of_lt hc
exact
continuousAt_of_dominated (Eventually.of_forall f_meas) f_le_bd (integrable_exp_neg_mul_sq hd)
(ae_of_all _ f_cts)
theorem integral_gaussian_complex {b : β} (hb : 0 < re b) :
β« x : β, cexp (-b * (x : β) ^ 2) = (Ο / b) ^ (1 / 2 : β) := by
have nv : β {b : β}, 0 < re b β b β 0 := by intro b hb; contrapose! hb; rw [hb]; simp
apply
(convex_halfSpace_re_gt 0).isPreconnected.eq_of_sq_eq ?_ ?_ (fun c hc => ?_) (fun {c} hc => ?_)
(by simp : 0 < re (1 : β)) ?_ hb
Β· -- integral is continuous
exact continuousOn_of_forall_continuousAt continuousAt_gaussian_integral
Β· -- `(Ο / b) ^ (1 / 2 : β)` is continuous
refine
continuousOn_of_forall_continuousAt fun b hb =>
(continuousAt_cpow_const (Or.inl ?_)).comp (continuousAt_const.div continuousAt_id (nv hb))
rw [div_re, ofReal_im, ofReal_re, zero_mul, zero_div, add_zero]
exact div_pos (mul_pos pi_pos hb) (normSq_pos.mpr (nv hb))
Β· -- equality at 1
have : β x : β, cexp (-(1 : β) * (x : β) ^ 2) = exp (-(1 : β) * x ^ 2) := by
intro x
simp only [ofReal_exp, neg_mul, one_mul, ofReal_neg, ofReal_pow]
simp_rw [this, β coe_algebraMap, RCLike.algebraMap_eq_ofReal, integral_ofReal,
β RCLike.algebraMap_eq_ofReal, coe_algebraMap]
conv_rhs =>
congr
Β· rw [β ofReal_one, β ofReal_div]
Β· rw [β ofReal_one, β ofReal_ofNat, β ofReal_div]
rw [β ofReal_cpow, ofReal_inj]
Β· convert integral_gaussian (1 : β) using 1
rw [sqrt_eq_rpow]
Β· rw [div_one]; exact pi_pos.le
Β· -- squares of both sides agree
dsimp only [Pi.pow_apply]
rw [integral_gaussian_sq_complex hc, sq]
conv_lhs => rw [β cpow_one (βΟ / c)]
rw [β cpow_add _ _ (div_ne_zero (ofReal_ne_zero.mpr pi_ne_zero) (nv hc))]
norm_num
Β· -- RHS doesn't vanish
rw [Ne, cpow_eq_zero_iff, not_and_or]
exact Or.inl (div_ne_zero (ofReal_ne_zero.mpr pi_ne_zero) (nv hc))
-- The Gaussian integral on the half-line, `β« x in Ioi 0, exp (-b * x^2)`, for complex `b`.
theorem integral_gaussian_complex_Ioi {b : β} (hb : 0 < re b) :
β« x : β in Ioi 0, cexp (-b * (x : β) ^ 2) = (Ο / b) ^ (1 / 2 : β) / 2 := by
have full_integral := integral_gaussian_complex hb
have : MeasurableSet (Ioi (0 : β)) := measurableSet_Ioi
rw [β integral_add_compl this (integrable_cexp_neg_mul_sq hb), compl_Ioi] at full_integral
suffices β« x : β in Iic 0, cexp (-b * (x : β) ^ 2) = β« x : β in Ioi 0, cexp (-b * (x : β) ^ 2) by
rw [this, β mul_two] at full_integral
rwa [eq_div_iff]; exact two_ne_zero
have : β c : β, β« x in (0 : β)..c, cexp (-b * (x : β) ^ 2) =
β« x in -c..0, cexp (-b * (x : β) ^ 2) := by
intro c
have := intervalIntegral.integral_comp_sub_left (a := 0) (b := c)
(fun x => cexp (-b * (x : β) ^ 2)) 0
simpa [zero_sub, neg_sq, neg_zero] using this
have t1 :=
intervalIntegral_tendsto_integral_Ioi 0 (integrable_cexp_neg_mul_sq hb).integrableOn tendsto_id
have t2 :
Tendsto (fun c : β => β« x : β in (0 : β)..c, cexp (-b * (x : β) ^ 2)) atTop
(π (β« x : β in Iic 0, cexp (-b * (x : β) ^ 2))) := by
simp_rw [this]
refine intervalIntegral_tendsto_integral_Iic _ ?_ tendsto_neg_atTop_atBot
apply (integrable_cexp_neg_mul_sq hb).integrableOn
exact tendsto_nhds_unique t2 t1
-- The Gaussian integral on the half-line, `β« x in Ioi 0, exp (-b * x^2)`, for real `b`.
theorem integral_gaussian_Ioi (b : β) :
β« x in Ioi (0 : β), exp (-b * x ^ 2) = β(Ο / b) / 2 := by
rcases le_or_gt b 0 with (hb | hb)
Β· rw [integral_undef, sqrt_eq_zero_of_nonpos, zero_div]
Β· exact div_nonpos_of_nonneg_of_nonpos pi_pos.le hb
Β· rwa [β IntegrableOn, integrableOn_Ioi_exp_neg_mul_sq_iff, not_lt]
rw [β RCLike.ofReal_inj (K := β), β integral_ofReal, β RCLike.algebraMap_eq_ofReal,
coe_algebraMap]
convert integral_gaussian_complex_Ioi (by rwa [ofReal_re] : 0 < (b : β).re)
Β· simp
Β· rw [sqrt_eq_rpow, β ofReal_div, ofReal_div, ofReal_cpow]
Β· simp
Β· exact (div_pos pi_pos hb).le
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
/-- The special-value formula `Ξ(1/2) = βΟ`, which is equivalent to the Gaussian integral. -/
theorem Real.Gamma_one_half_eq : Real.Gamma (1 / 2) = βΟ := by
rw [Gamma_eq_integral one_half_pos, β integral_comp_rpow_Ioi_of_pos zero_lt_two]
convert congr_arg (fun x : β => 2 * x) (integral_gaussian_Ioi 1) using 1
Β· rw [β integral_const_mul]
refine setIntegral_congr_fun measurableSet_Ioi fun x hx => ?_
dsimp only
have : (x ^ (2 : β)) ^ (1 / (2 : β) - 1) = xβ»ΒΉ := by
rw [β rpow_mul (le_of_lt hx)]
norm_num
rw [rpow_neg (le_of_lt hx), rpow_one]
rw [smul_eq_mul, this]
simp [field, (ne_of_lt (show 0 < x from hx)).symm]
norm_num
Β· rw [div_one, β mul_div_assoc, mul_comm, mul_div_cancel_rightβ _ (two_ne_zero' β)]
/-- The special-value formula `Ξ(1/2) = βΟ`, which is equivalent to the Gaussian integral. -/
theorem Complex.Gamma_one_half_eq : Complex.Gamma (1 / 2) = (Ο : β) ^ (1 / 2 : β) := by
convert congr_arg ((β) : β β β) Real.Gamma_one_half_eq
Β· simpa only [one_div, ofReal_inv, ofReal_ofNat] using Gamma_ofReal (1 / 2)
Β· rw [sqrt_eq_rpow, ofReal_cpow pi_pos.le, ofReal_div, ofReal_ofNat, ofReal_one]
open scoped Nat in
/-- The special-value formula `Ξ(k + 1 + 1/2) = (2 * k + 1)βΌ * βΟ / (2 ^ (k + 1))` for half-integer
values of the gamma function in terms of `Nat.doubleFactorial`. -/
lemma Real.Gamma_nat_add_one_add_half (k : β) :
Gamma (k + 1 + 1 / 2) = (2 * k + 1 : β)βΌ * βΟ / (2 ^ (k + 1)) := by
induction k with
| zero => simp [-one_div, add_comm (1 : β), Gamma_add_one, Gamma_one_half_eq]; ring
| succ k ih =>
rw [add_right_comm, Gamma_add_one (by positivity), Nat.cast_add, Nat.cast_one, ih, Nat.mul_add]
simp
ring
open scoped Nat in
/-- The special-value formula `Ξ(k + 1/2) = (2 * k - 1)βΌ * βΟ / (2 ^ k))` for half-integer
values of the gamma function in terms of `Nat.doubleFactorial`. -/
lemma Real.Gamma_nat_add_half (k : β) :
Gamma (k + 1 / 2) = (2 * k - 1 : β)βΌ * βΟ / (2 ^ k) := by
cases k with
| zero => simp [- one_div, Gamma_one_half_eq]
| succ k => simpa [-one_div, mul_add] using Gamma_nat_add_one_add_half k |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Topology.Order.ProjIcc
/-!
# Inverse trigonometric functions.
See also `Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse tan function.
(This is delayed as it is easier to set up after developing complex trigonometric functions.)
Basic inequalities on trigonometric functions.
-/
noncomputable section
open Topology Filter Set Filter Real
namespace Real
variable {x y : β}
/-- Inverse of the `sin` function, returns values in the range `-Ο / 2 β€ arcsin x β€ Ο / 2`.
It defaults to `-Ο / 2` on `(-β, -1)` and to `Ο / 2` to `(1, β)`. -/
@[pp_nodot]
noncomputable def arcsin : β β β :=
Subtype.val β IccExtend (neg_le_self zero_le_one) sinOrderIso.symm
theorem arcsin_mem_Icc (x : β) : arcsin x β Icc (-(Ο / 2)) (Ο / 2) :=
Subtype.coe_prop _
@[simp]
theorem range_arcsin : range arcsin = Icc (-(Ο / 2)) (Ο / 2) := by
rw [arcsin, range_comp Subtype.val]
simp [Icc]
theorem arcsin_le_pi_div_two (x : β) : arcsin x β€ Ο / 2 :=
(arcsin_mem_Icc x).2
theorem neg_pi_div_two_le_arcsin (x : β) : -(Ο / 2) β€ arcsin x :=
(arcsin_mem_Icc x).1
theorem arcsin_projIcc (x : β) :
arcsin (projIcc (-1) 1 (neg_le_self zero_le_one) x) = arcsin x := by
rw [arcsin, Function.comp_apply, IccExtend_val, Function.comp_apply, IccExtend,
Function.comp_apply]
theorem sin_arcsin' {x : β} (hx : x β Icc (-1 : β) 1) : sin (arcsin x) = x := by
simpa [arcsin, IccExtend_of_mem _ _ hx, -OrderIso.apply_symm_apply] using
Subtype.ext_iff.1 (sinOrderIso.apply_symm_apply β¨x, hxβ©)
theorem sin_arcsin {x : β} (hxβ : -1 β€ x) (hxβ : x β€ 1) : sin (arcsin x) = x :=
sin_arcsin' β¨hxβ, hxββ©
theorem arcsin_sin' {x : β} (hx : x β Icc (-(Ο / 2)) (Ο / 2)) : arcsin (sin x) = x :=
injOn_sin (arcsin_mem_Icc _) hx <| by rw [sin_arcsin (neg_one_le_sin _) (sin_le_one _)]
theorem arcsin_sin {x : β} (hxβ : -(Ο / 2) β€ x) (hxβ : x β€ Ο / 2) : arcsin (sin x) = x :=
arcsin_sin' β¨hxβ, hxββ©
theorem strictMonoOn_arcsin : StrictMonoOn arcsin (Icc (-1) 1) :=
(Subtype.strictMono_coe _).comp_strictMonoOn <|
sinOrderIso.symm.strictMono.strictMonoOn_IccExtend _
@[gcongr]
theorem arcsin_lt_arcsin {x y : β} (hx : -1 β€ x) (hlt : x < y) (hy : y β€ 1) :
arcsin x < arcsin y :=
strictMonoOn_arcsin β¨hx, hlt.le.trans hyβ© β¨hx.trans hlt.le, hyβ© hlt
theorem monotone_arcsin : Monotone arcsin :=
(Subtype.mono_coe _).comp <| sinOrderIso.symm.monotone.IccExtend _
@[gcongr]
theorem arcsin_le_arcsin {x y : β} (h : x β€ y) : arcsin x β€ arcsin y := monotone_arcsin h
theorem injOn_arcsin : InjOn arcsin (Icc (-1) 1) :=
strictMonoOn_arcsin.injOn
theorem arcsin_inj {x y : β} (hxβ : -1 β€ x) (hxβ : x β€ 1) (hyβ : -1 β€ y) (hyβ : y β€ 1) :
arcsin x = arcsin y β x = y :=
injOn_arcsin.eq_iff β¨hxβ, hxββ© β¨hyβ, hyββ©
@[continuity, fun_prop]
theorem continuous_arcsin : Continuous arcsin :=
continuous_subtype_val.comp sinOrderIso.symm.continuous.Icc_extend'
@[fun_prop]
theorem continuousAt_arcsin {x : β} : ContinuousAt arcsin x :=
continuous_arcsin.continuousAt
theorem arcsin_eq_of_sin_eq {x y : β} (hβ : sin x = y) (hβ : x β Icc (-(Ο / 2)) (Ο / 2)) :
arcsin y = x := by
subst y
exact injOn_sin (arcsin_mem_Icc _) hβ (sin_arcsin' (sin_mem_Icc x))
@[simp]
theorem arcsin_zero : arcsin 0 = 0 :=
arcsin_eq_of_sin_eq sin_zero β¨neg_nonpos.2 pi_div_two_pos.le, pi_div_two_pos.leβ©
@[simp]
theorem arcsin_one : arcsin 1 = Ο / 2 :=
arcsin_eq_of_sin_eq sin_pi_div_two <| right_mem_Icc.2 (neg_le_self pi_div_two_pos.le)
theorem arcsin_of_one_le {x : β} (hx : 1 β€ x) : arcsin x = Ο / 2 := by
rw [β arcsin_projIcc, projIcc_of_right_le _ hx, Subtype.coe_mk, arcsin_one]
theorem arcsin_neg_one : arcsin (-1) = -(Ο / 2) :=
arcsin_eq_of_sin_eq (by rw [sin_neg, sin_pi_div_two]) <|
left_mem_Icc.2 (neg_le_self pi_div_two_pos.le)
theorem arcsin_of_le_neg_one {x : β} (hx : x β€ -1) : arcsin x = -(Ο / 2) := by
rw [β arcsin_projIcc, projIcc_of_le_left _ hx, Subtype.coe_mk, arcsin_neg_one]
@[simp]
theorem arcsin_neg (x : β) : arcsin (-x) = -arcsin x := by
rcases le_total x (-1) with hxβ | hxβ
Β· rw [arcsin_of_le_neg_one hxβ, neg_neg, arcsin_of_one_le (le_neg.2 hxβ)]
rcases le_total 1 x with hxβ | hxβ
Β· rw [arcsin_of_one_le hxβ, arcsin_of_le_neg_one (neg_le_neg hxβ)]
refine arcsin_eq_of_sin_eq ?_ ?_
Β· rw [sin_neg, sin_arcsin hxβ hxβ]
Β· exact β¨neg_le_neg (arcsin_le_pi_div_two _), neg_le.2 (neg_pi_div_two_le_arcsin _)β©
theorem arcsin_le_iff_le_sin {x y : β} (hx : x β Icc (-1 : β) 1) (hy : y β Icc (-(Ο / 2)) (Ο / 2)) :
arcsin x β€ y β x β€ sin y := by
rw [β arcsin_sin' hy, strictMonoOn_arcsin.le_iff_le hx (sin_mem_Icc _), arcsin_sin' hy]
theorem arcsin_le_iff_le_sin' {x y : β} (hy : y β Ico (-(Ο / 2)) (Ο / 2)) :
arcsin x β€ y β x β€ sin y := by
rcases le_total x (-1) with hxβ | hxβ
Β· simp [arcsin_of_le_neg_one hxβ, hy.1, hxβ.trans (neg_one_le_sin _)]
rcases lt_or_ge 1 x with hxβ | hxβ
Β· simp [arcsin_of_one_le hxβ.le, hy.2.not_ge, (sin_le_one y).trans_lt hxβ]
exact arcsin_le_iff_le_sin β¨hxβ, hxββ© (mem_Icc_of_Ico hy)
theorem le_arcsin_iff_sin_le {x y : β} (hx : x β Icc (-(Ο / 2)) (Ο / 2)) (hy : y β Icc (-1 : β) 1) :
x β€ arcsin y β sin x β€ y := by
rw [β neg_le_neg_iff, β arcsin_neg,
arcsin_le_iff_le_sin β¨neg_le_neg hy.2, neg_le.2 hy.1β© β¨neg_le_neg hx.2, neg_le.2 hx.1β©, sin_neg,
neg_le_neg_iff]
theorem le_arcsin_iff_sin_le' {x y : β} (hx : x β Ioc (-(Ο / 2)) (Ο / 2)) :
x β€ arcsin y β sin x β€ y := by
rw [β neg_le_neg_iff, β arcsin_neg, arcsin_le_iff_le_sin' β¨neg_le_neg hx.2, neg_lt.2 hx.1β©,
sin_neg, neg_le_neg_iff]
theorem arcsin_lt_iff_lt_sin {x y : β} (hx : x β Icc (-1 : β) 1) (hy : y β Icc (-(Ο / 2)) (Ο / 2)) :
arcsin x < y β x < sin y :=
not_le.symm.trans <| (not_congr <| le_arcsin_iff_sin_le hy hx).trans not_le
theorem arcsin_lt_iff_lt_sin' {x y : β} (hy : y β Ioc (-(Ο / 2)) (Ο / 2)) :
arcsin x < y β x < sin y :=
not_le.symm.trans <| (not_congr <| le_arcsin_iff_sin_le' hy).trans not_le
theorem lt_arcsin_iff_sin_lt {x y : β} (hx : x β Icc (-(Ο / 2)) (Ο / 2)) (hy : y β Icc (-1 : β) 1) :
x < arcsin y β sin x < y :=
not_le.symm.trans <| (not_congr <| arcsin_le_iff_le_sin hy hx).trans not_le
theorem lt_arcsin_iff_sin_lt' {x y : β} (hx : x β Ico (-(Ο / 2)) (Ο / 2)) :
x < arcsin y β sin x < y :=
not_le.symm.trans <| (not_congr <| arcsin_le_iff_le_sin' hx).trans not_le
theorem arcsin_eq_iff_eq_sin {x y : β} (hy : y β Ioo (-(Ο / 2)) (Ο / 2)) :
arcsin x = y β x = sin y := by
simp only [le_antisymm_iff, arcsin_le_iff_le_sin' (mem_Ico_of_Ioo hy),
le_arcsin_iff_sin_le' (mem_Ioc_of_Ioo hy)]
@[simp]
theorem arcsin_nonneg {x : β} : 0 β€ arcsin x β 0 β€ x :=
(le_arcsin_iff_sin_le' β¨neg_lt_zero.2 pi_div_two_pos, pi_div_two_pos.leβ©).trans <| by
rw [sin_zero]
@[simp]
theorem arcsin_nonpos {x : β} : arcsin x β€ 0 β x β€ 0 :=
neg_nonneg.symm.trans <| arcsin_neg x βΈ arcsin_nonneg.trans neg_nonneg
@[simp]
theorem arcsin_eq_zero_iff {x : β} : arcsin x = 0 β x = 0 := by simp [le_antisymm_iff]
@[simp]
theorem zero_eq_arcsin_iff {x} : 0 = arcsin x β x = 0 :=
eq_comm.trans arcsin_eq_zero_iff
@[simp]
theorem arcsin_pos {x : β} : 0 < arcsin x β 0 < x :=
lt_iff_lt_of_le_iff_le arcsin_nonpos
@[simp]
theorem arcsin_lt_zero {x : β} : arcsin x < 0 β x < 0 :=
lt_iff_lt_of_le_iff_le arcsin_nonneg
@[simp]
theorem arcsin_lt_pi_div_two {x : β} : arcsin x < Ο / 2 β x < 1 :=
(arcsin_lt_iff_lt_sin' (right_mem_Ioc.2 <| neg_lt_self pi_div_two_pos)).trans <| by
rw [sin_pi_div_two]
@[simp]
theorem neg_pi_div_two_lt_arcsin {x : β} : -(Ο / 2) < arcsin x β -1 < x :=
(lt_arcsin_iff_sin_lt' <| left_mem_Ico.2 <| neg_lt_self pi_div_two_pos).trans <| by
rw [sin_neg, sin_pi_div_two]
@[simp]
theorem arcsin_eq_pi_div_two {x : β} : arcsin x = Ο / 2 β 1 β€ x :=
β¨fun h => not_lt.1 fun h' => (arcsin_lt_pi_div_two.2 h').ne h, arcsin_of_one_leβ©
@[simp]
theorem pi_div_two_eq_arcsin {x} : Ο / 2 = arcsin x β 1 β€ x :=
eq_comm.trans arcsin_eq_pi_div_two
@[simp]
theorem pi_div_two_le_arcsin {x} : Ο / 2 β€ arcsin x β 1 β€ x :=
(arcsin_le_pi_div_two x).ge_iff_eq'.trans pi_div_two_eq_arcsin
@[simp]
theorem arcsin_eq_neg_pi_div_two {x : β} : arcsin x = -(Ο / 2) β x β€ -1 :=
β¨fun h => not_lt.1 fun h' => (neg_pi_div_two_lt_arcsin.2 h').ne' h, arcsin_of_le_neg_oneβ©
@[simp]
theorem neg_pi_div_two_eq_arcsin {x} : -(Ο / 2) = arcsin x β x β€ -1 :=
eq_comm.trans arcsin_eq_neg_pi_div_two
@[simp]
theorem arcsin_le_neg_pi_div_two {x} : arcsin x β€ -(Ο / 2) β x β€ -1 :=
(neg_pi_div_two_le_arcsin x).ge_iff_eq'.trans arcsin_eq_neg_pi_div_two
@[simp]
theorem pi_div_four_le_arcsin {x} : Ο / 4 β€ arcsin x β β2 / 2 β€ x := by
rw [β sin_pi_div_four, le_arcsin_iff_sin_le']
have := pi_pos
constructor <;> linarith
theorem mapsTo_sin_Ioo : MapsTo sin (Ioo (-(Ο / 2)) (Ο / 2)) (Ioo (-1) 1) := fun x h => by
rwa [mem_Ioo, β arcsin_lt_pi_div_two, β neg_pi_div_two_lt_arcsin, arcsin_sin h.1.le h.2.le]
/-- `Real.sin` as an `OpenPartialHomeomorph` between `(-Ο / 2, Ο / 2)` and `(-1, 1)`. -/
@[simp]
def sinPartialHomeomorph : OpenPartialHomeomorph β β where
toFun := sin
invFun := arcsin
source := Ioo (-(Ο / 2)) (Ο / 2)
target := Ioo (-1) 1
map_source' := mapsTo_sin_Ioo
map_target' _ hy := β¨neg_pi_div_two_lt_arcsin.2 hy.1, arcsin_lt_pi_div_two.2 hy.2β©
left_inv' _ hx := arcsin_sin hx.1.le hx.2.le
right_inv' _ hy := sin_arcsin hy.1.le hy.2.le
open_source := isOpen_Ioo
open_target := isOpen_Ioo
continuousOn_toFun := continuous_sin.continuousOn
continuousOn_invFun := continuous_arcsin.continuousOn
theorem cos_arcsin_nonneg (x : β) : 0 β€ cos (arcsin x) :=
cos_nonneg_of_mem_Icc β¨neg_pi_div_two_le_arcsin _, arcsin_le_pi_div_two _β©
-- The junk values for `arcsin` and `sqrt` make this true even outside `[-1, 1]`.
theorem cos_arcsin (x : β) : cos (arcsin x) = β(1 - x ^ 2) := by
by_cases hxβ : -1 β€ x; swap
Β· rw [not_le] at hxβ
rw [arcsin_of_le_neg_one hxβ.le, cos_neg, cos_pi_div_two, sqrt_eq_zero_of_nonpos]
nlinarith
by_cases hxβ : x β€ 1; swap
Β· rw [not_le] at hxβ
rw [arcsin_of_one_le hxβ.le, cos_pi_div_two, sqrt_eq_zero_of_nonpos]
nlinarith
have : sin (arcsin x) ^ 2 + cos (arcsin x) ^ 2 = 1 := sin_sq_add_cos_sq (arcsin x)
rw [β eq_sub_iff_add_eq', β sqrt_inj (sq_nonneg _) (sub_nonneg.2 (sin_sq_le_one (arcsin x))), sq,
sqrt_mul_self (cos_arcsin_nonneg _)] at this
rw [this, sin_arcsin hxβ hxβ]
-- The junk values for `arcsin` and `sqrt` make this true even outside `[-1, 1]`.
theorem tan_arcsin (x : β) : tan (arcsin x) = x / β(1 - x ^ 2) := by
rw [tan_eq_sin_div_cos, cos_arcsin]
by_cases hxβ : -1 β€ x; swap
Β· have h : β(1 - x ^ 2) = 0 := sqrt_eq_zero_of_nonpos (by nlinarith)
rw [h]
simp
by_cases hxβ : x β€ 1; swap
Β· have h : β(1 - x ^ 2) = 0 := sqrt_eq_zero_of_nonpos (by nlinarith)
rw [h]
simp
rw [sin_arcsin hxβ hxβ]
/-- Inverse of the `cos` function, returns values in the range `0 β€ arccos x` and `arccos x β€ Ο`.
It defaults to `Ο` on `(-β, -1)` and to `0` to `(1, β)`. -/
@[pp_nodot]
noncomputable def arccos (x : β) : β :=
Ο / 2 - arcsin x
theorem arccos_eq_pi_div_two_sub_arcsin (x : β) : arccos x = Ο / 2 - arcsin x :=
rfl
theorem arcsin_eq_pi_div_two_sub_arccos (x : β) : arcsin x = Ο / 2 - arccos x := by simp [arccos]
theorem arccos_le_pi (x : β) : arccos x β€ Ο := by
unfold arccos; linarith [neg_pi_div_two_le_arcsin x]
theorem arccos_nonneg (x : β) : 0 β€ arccos x := by
unfold arccos; linarith [arcsin_le_pi_div_two x]
@[simp]
theorem arccos_pos {x : β} : 0 < arccos x β x < 1 := by simp [arccos]
theorem cos_arccos {x : β} (hxβ : -1 β€ x) (hxβ : x β€ 1) : cos (arccos x) = x := by
rw [arccos, cos_pi_div_two_sub, sin_arcsin hxβ hxβ]
theorem arccos_cos {x : β} (hxβ : 0 β€ x) (hxβ : x β€ Ο) : arccos (cos x) = x := by
rw [arccos, β sin_pi_div_two_sub, arcsin_sin] <;> simp [sub_eq_add_neg] <;> linarith
lemma arccos_eq_of_eq_cos (hyβ : 0 β€ y) (hyβ : y β€ Ο) (hxy : x = cos y) : arccos x = y := by
rw [hxy, arccos_cos hyβ hyβ]
theorem strictAntiOn_arccos : StrictAntiOn arccos (Icc (-1) 1) := fun _ hx _ hy h =>
sub_lt_sub_left (strictMonoOn_arcsin hx hy h) _
@[gcongr]
lemma arccos_lt_arccos {x y : β} (hx : -1 β€ x) (hlt : x < y) (hy : y β€ 1) :
arccos y < arccos x := by
unfold arccos; gcongr <;> assumption
@[gcongr]
lemma arccos_le_arccos {x y : β} (hlt : x β€ y) : arccos y β€ arccos x := by unfold arccos; gcongr
theorem antitone_arccos : Antitone arccos := fun _ _ β¦ arccos_le_arccos
theorem arccos_injOn : InjOn arccos (Icc (-1) 1) :=
strictAntiOn_arccos.injOn
theorem arccos_inj {x y : β} (hxβ : -1 β€ x) (hxβ : x β€ 1) (hyβ : -1 β€ y) (hyβ : y β€ 1) :
arccos x = arccos y β x = y :=
arccos_injOn.eq_iff β¨hxβ, hxββ© β¨hyβ, hyββ©
@[simp]
theorem arccos_zero : arccos 0 = Ο / 2 := by simp [arccos]
@[simp]
theorem arccos_one : arccos 1 = 0 := by simp [arccos]
@[simp]
theorem arccos_neg_one : arccos (-1) = Ο := by simp [arccos, add_halves]
@[simp]
theorem arccos_eq_zero {x} : arccos x = 0 β 1 β€ x := by simp [arccos, sub_eq_zero]
@[simp]
theorem arccos_eq_pi_div_two {x} : arccos x = Ο / 2 β x = 0 := by simp [arccos]
@[simp]
theorem arccos_eq_pi {x} : arccos x = Ο β x β€ -1 := by
rw [arccos, sub_eq_iff_eq_add, β sub_eq_iff_eq_add', div_two_sub_self, neg_pi_div_two_eq_arcsin]
theorem arccos_neg (x : β) : arccos (-x) = Ο - arccos x := by
rw [β add_halves Ο, arccos, arcsin_neg, arccos, add_sub_assoc, sub_sub_self, sub_neg_eq_add]
theorem arccos_of_one_le {x : β} (hx : 1 β€ x) : arccos x = 0 := by
rw [arccos, arcsin_of_one_le hx, sub_self]
theorem arccos_of_le_neg_one {x : β} (hx : x β€ -1) : arccos x = Ο := by
rw [arccos, arcsin_of_le_neg_one hx, sub_neg_eq_add, add_halves]
-- The junk values for `arccos` and `sqrt` make this true even outside `[-1, 1]`.
theorem sin_arccos (x : β) : sin (arccos x) = β(1 - x ^ 2) := by
by_cases hxβ : -1 β€ x; swap
Β· rw [not_le] at hxβ
rw [arccos_of_le_neg_one hxβ.le, sin_pi, sqrt_eq_zero_of_nonpos]
nlinarith
by_cases hxβ : x β€ 1; swap
Β· rw [not_le] at hxβ
rw [arccos_of_one_le hxβ.le, sin_zero, sqrt_eq_zero_of_nonpos]
nlinarith
rw [arccos_eq_pi_div_two_sub_arcsin, sin_pi_div_two_sub, cos_arcsin]
@[simp]
theorem arccos_le_pi_div_two {x} : arccos x β€ Ο / 2 β 0 β€ x := by simp [arccos]
@[simp]
theorem arccos_lt_pi_div_two {x : β} : arccos x < Ο / 2 β 0 < x := by simp [arccos]
@[simp]
theorem arccos_le_pi_div_four {x} : arccos x β€ Ο / 4 β β2 / 2 β€ x := by
rw [arccos, β pi_div_four_le_arcsin]
constructor <;>
Β· intro
linarith
@[continuity, fun_prop]
theorem continuous_arccos : Continuous arccos :=
continuous_const.sub continuous_arcsin
-- The junk values for `arccos` and `sqrt` make this true even outside `[-1, 1]`.
theorem tan_arccos (x : β) : tan (arccos x) = β(1 - x ^ 2) / x := by
rw [arccos, tan_pi_div_two_sub, tan_arcsin, inv_div]
-- The junk values for `arccos` and `sqrt` make this true even for `1 < x`.
theorem arccos_eq_arcsin {x : β} (h : 0 β€ x) : arccos x = arcsin (β(1 - x ^ 2)) :=
(arcsin_eq_of_sin_eq (sin_arccos _)
β¨(Left.neg_nonpos_iff.2 (div_nonneg pi_pos.le (by simp))).trans (arccos_nonneg _),
arccos_le_pi_div_two.2 hβ©).symm
-- The junk values for `arcsin` and `sqrt` make this true even for `1 < x`.
theorem arcsin_eq_arccos {x : β} (h : 0 β€ x) : arcsin x = arccos (β(1 - x ^ 2)) := by
rw [eq_comm, β cos_arcsin]
exact
arccos_cos (arcsin_nonneg.2 h)
((arcsin_le_pi_div_two _).trans (div_le_self pi_pos.le one_le_two))
end Real
open Real
/-!
### Convenience dot notation lemmas
-/
namespace Filter.Tendsto
variable {Ξ± : Type*} {l : Filter Ξ±} {x : β} {f : Ξ± β β}
protected theorem arcsin (h : Tendsto f l (π x)) : Tendsto (arcsin <| f Β·) l (π (arcsin x)) :=
(continuous_arcsin.tendsto _).comp h
theorem arcsin_nhdsLE (h : Tendsto f l (π[β€] x)) :
Tendsto (arcsin <| f Β·) l (π[β€] (arcsin x)) := by
refine ((continuous_arcsin.tendsto _).inf <| MapsTo.tendsto fun y hy β¦ ?_).comp h
exact monotone_arcsin hy
theorem arcsin_nhdsGE (h : Tendsto f l (π[β₯] x)) : Tendsto (arcsin <| f Β·) l (π[β₯] (arcsin x)) :=
((continuous_arcsin.tendsto _).inf <| MapsTo.tendsto fun _ β¦ arcsin_le_arcsin).comp h
protected theorem arccos (h : Tendsto f l (π x)) : Tendsto (arccos <| f Β·) l (π (arccos x)) :=
(continuous_arccos.tendsto _).comp h
theorem arccos_nhdsLE (h : Tendsto f l (π[β€] x)) : Tendsto (arccos <| f Β·) l (π[β₯] (arccos x)) :=
((continuous_arccos.tendsto _).inf <| MapsTo.tendsto fun _ β¦ arccos_le_arccos).comp h
theorem arccos_nhdsGE (h : Tendsto f l (π[β₯] x)) :
Tendsto (arccos <| f Β·) l (π[β€] (arccos x)) := by
refine ((continuous_arccos.tendsto _).inf <| MapsTo.tendsto fun y hy β¦ ?_).comp h
simp only [mem_Ici, mem_Iic] at hy β’
exact antitone_arccos hy
end Filter.Tendsto
variable {X : Type*} [TopologicalSpace X] {f : X β β} {s : Set X} {x : X}
protected nonrec theorem ContinuousWithinAt.arcsin (h : ContinuousWithinAt f s x) :
ContinuousWithinAt (arcsin <| f Β·) s x :=
h.arcsin
protected nonrec theorem ContinuousWithinAt.arccos (h : ContinuousWithinAt f s x) :
ContinuousWithinAt (arccos <| f Β·) s x :=
h.arccos
protected nonrec theorem ContinuousAt.arcsin (h : ContinuousAt f x) :
ContinuousAt (arcsin <| f Β·) x :=
h.arcsin
protected nonrec theorem ContinuousAt.arccos (h : ContinuousAt f x) :
ContinuousAt (arccos <| f Β·) x :=
h.arccos
protected theorem ContinuousOn.arcsin (h : ContinuousOn f s) : ContinuousOn (arcsin <| f Β·) s :=
fun x hx β¦ (h x hx).arcsin
protected theorem ContinuousOn.arccos (h : ContinuousOn f s) : ContinuousOn (arccos <| f Β·) s :=
fun x hx β¦ (h x hx).arccos
protected theorem Continuous.arcsin (h : Continuous f) : Continuous (arcsin <| f Β·) :=
continuous_arcsin.comp h
protected theorem Continuous.arccos (h : Continuous f) : Continuous (arccos <| f Β·) :=
continuous_arccos.comp h |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex
/-!
# The `arctan` function.
Inequalities, identities and `Real.tan` as an `OpenPartialHomeomorph` between `(-(Ο / 2), Ο / 2)`
and the whole line.
The result of `arctan x + arctan y` is given by `arctan_add`, `arctan_add_eq_add_pi` or
`arctan_add_eq_sub_pi` depending on whether `x * y < 1` and `0 < x`. As an application of
`arctan_add` we give four Machin-like formulas (linear combinations of arctangents equal to
`Ο / 4 = arctan 1`), including John Machin's original one at
`four_mul_arctan_inv_5_sub_arctan_inv_239`.
-/
noncomputable section
open Set Filter
open scoped Topology
namespace Real
variable {x y : β}
theorem tan_add
(h : ((β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) β¨
(β k : β€, x = (2 * k + 1) * Ο / 2) β§ β l : β€, y = (2 * l + 1) * Ο / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by
simpa only [β Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div,
Complex.ofReal_mul, Complex.ofReal_tan] using
@Complex.tan_add (x : β) (y : β) (by convert h <;> norm_cast)
theorem tan_add'
(h : (β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) :=
tan_add (Or.inl h)
theorem tan_sub {x y : β}
(h : ((β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) β¨
(β k : β€, x = (2 * k + 1) * Ο / 2) β§ β l : β€, y = (2 * l + 1) * Ο / 2) :
tan (x - y) = (tan x - tan y) / (1 + tan x * tan y) := by
simpa only [β Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div,
Complex.ofReal_mul, Complex.ofReal_tan] using
@Complex.tan_sub (x : β) (y : β) (by convert h <;> norm_cast)
theorem tan_sub' {x y : β}
(h : (β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) :
tan (x - y) = (tan x - tan y) / (1 + tan x * tan y) :=
tan_sub (Or.inl h)
theorem tan_two_mul : tan (2 * x) = 2 * tan x / (1 - tan x ^ 2) := by
have := @Complex.tan_two_mul x
norm_cast at *
theorem tan_int_mul_pi_div_two (n : β€) : tan (n * Ο / 2) = 0 :=
tan_eq_zero_iff.mpr (by use n)
theorem continuousOn_tan : ContinuousOn tan {x | cos x β 0} := by
suffices ContinuousOn (fun x => sin x / cos x) {x | cos x β 0} by
have h_eq : (fun x => sin x / cos x) = tan := by ext1 x; rw [tan_eq_sin_div_cos]
rwa [h_eq] at this
exact continuousOn_sin.div continuousOn_cos fun x => id
@[continuity]
theorem continuous_tan : Continuous fun x : {x | cos x β 0} => tan x :=
continuousOn_iff_continuous_restrict.1 continuousOn_tan
theorem continuousOn_tan_Ioo : ContinuousOn tan (Ioo (-(Ο / 2)) (Ο / 2)) := by
refine ContinuousOn.mono continuousOn_tan fun x => ?_
simp only [and_imp, mem_Ioo, mem_setOf_eq, Ne]
rw [cos_eq_zero_iff]
rintro hx_gt hx_lt β¨r, hxr_eqβ©
rcases le_or_gt 0 r with h | h
Β· rw [lt_iff_not_ge] at hx_lt
refine hx_lt ?_
rw [hxr_eq, β one_mul (Ο / 2), mul_div_assoc, mul_le_mul_iff_leftβ (half_pos pi_pos)]
simp [h]
Β· rw [lt_iff_not_ge] at hx_gt
refine hx_gt ?_
rw [hxr_eq, β one_mul (Ο / 2), mul_div_assoc, neg_mul_eq_neg_mul,
mul_le_mul_iff_leftβ (half_pos pi_pos)]
have hr_le : r β€ -1 := by rwa [Int.lt_iff_add_one_le, β le_neg_iff_add_nonpos_right] at h
rw [β le_sub_iff_add_le, mul_comm, β le_div_iffβ]
Β· norm_num
assumption_mod_cast
Β· exact zero_lt_two
theorem surjOn_tan : SurjOn tan (Ioo (-(Ο / 2)) (Ο / 2)) univ :=
have := neg_lt_self pi_div_two_pos
continuousOn_tan_Ioo.surjOn_of_tendsto (nonempty_Ioo.2 this)
(by rw [tendsto_comp_coe_Ioo_atBot this]; exact tendsto_tan_neg_pi_div_two)
(by rw [tendsto_comp_coe_Ioo_atTop this]; exact tendsto_tan_pi_div_two)
theorem tan_surjective : Function.Surjective tan := fun _ => surjOn_tan.subset_range trivial
theorem image_tan_Ioo : tan '' Ioo (-(Ο / 2)) (Ο / 2) = univ :=
univ_subset_iff.1 surjOn_tan
/-- `Real.tan` as an `OrderIso` between `(-(Ο / 2), Ο / 2)` and `β`. -/
def tanOrderIso : Ioo (-(Ο / 2)) (Ο / 2) βo β :=
(strictMonoOn_tan.orderIso _ _).trans <|
(OrderIso.setCongr _ _ image_tan_Ioo).trans OrderIso.Set.univ
/-- Inverse of the `tan` function, returns values in the range `-Ο / 2 < arctan x` and
`arctan x < Ο / 2` -/
@[pp_nodot]
noncomputable def arctan (x : β) : β :=
tanOrderIso.symm x
@[simp]
theorem tan_arctan (x : β) : tan (arctan x) = x :=
tanOrderIso.apply_symm_apply x
theorem arctan_mem_Ioo (x : β) : arctan x β Ioo (-(Ο / 2)) (Ο / 2) :=
Subtype.coe_prop _
@[simp]
theorem range_arctan : range arctan = Ioo (-(Ο / 2)) (Ο / 2) :=
((EquivLike.surjective _).range_comp _).trans Subtype.range_coe
theorem arctan_tan (hxβ : -(Ο / 2) < x) (hxβ : x < Ο / 2) : arctan (tan x) = x :=
Subtype.ext_iff.1 <| tanOrderIso.symm_apply_apply β¨x, hxβ, hxββ©
theorem cos_arctan_pos (x : β) : 0 < cos (arctan x) :=
cos_pos_of_mem_Ioo <| arctan_mem_Ioo x
theorem cos_sq_arctan (x : β) : cos (arctan x) ^ 2 = 1 / (1 + x ^ 2) := by
rw_mod_cast [one_div, β inv_one_add_tan_sq (cos_arctan_pos x).ne', tan_arctan]
theorem sin_arctan (x : β) : sin (arctan x) = x / β(1 + x ^ 2) := by
rw_mod_cast [β tan_div_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan]
theorem cos_arctan (x : β) : cos (arctan x) = 1 / β(1 + x ^ 2) := by
rw_mod_cast [one_div, β inv_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan]
theorem arctan_lt_pi_div_two (x : β) : arctan x < Ο / 2 :=
(arctan_mem_Ioo x).2
theorem neg_pi_div_two_lt_arctan (x : β) : -(Ο / 2) < arctan x :=
(arctan_mem_Ioo x).1
theorem arctan_eq_arcsin (x : β) : arctan x = arcsin (x / β(1 + x ^ 2)) :=
Eq.symm <| arcsin_eq_of_sin_eq (sin_arctan x) (mem_Icc_of_Ioo <| arctan_mem_Ioo x)
theorem arcsin_eq_arctan (h : x β Ioo (-(1 : β)) 1) :
arcsin x = arctan (x / β(1 - x ^ 2)) := by
rw_mod_cast [arctan_eq_arcsin, div_pow, sq_sqrt, one_add_div, div_div, β sqrt_mul,
mul_div_cancelβ, sub_add_cancel, sqrt_one, div_one] <;> simp at h <;> nlinarith [h.1, h.2]
@[simp]
theorem arctan_zero : arctan 0 = 0 := by simp [arctan_eq_arcsin]
@[gcongr, mono]
theorem arctan_strictMono : StrictMono arctan := tanOrderIso.symm.strictMono
@[gcongr]
theorem arctan_mono : Monotone arctan := arctan_strictMono.monotone
@[deprecated arctan_strictMono (since := "2025-10-20")]
lemma arctan_lt_arctan (hxy : x < y) : arctan x < arctan y := arctan_strictMono hxy
@[simp]
theorem arctan_lt_arctan_iff : arctan x < arctan y β x < y := arctan_strictMono.lt_iff_lt
@[deprecated arctan_mono (since := "2025-10-20")]
lemma arctan_le_arctan (hxy : x β€ y) : arctan x β€ arctan y :=
arctan_strictMono.monotone hxy
@[simp]
theorem arctan_le_arctan_iff : arctan x β€ arctan y β x β€ y := arctan_strictMono.le_iff_le
theorem arctan_injective : arctan.Injective := arctan_strictMono.injective
@[simp]
theorem arctan_inj : arctan x = arctan y β x = y := arctan_injective.eq_iff
@[simp]
theorem arctan_eq_zero_iff : arctan x = 0 β x = 0 :=
.trans (by rw [arctan_zero]) arctan_injective.eq_iff
theorem tendsto_arctan_atTop : Tendsto arctan atTop (π[<] (Ο / 2)) :=
tendsto_Ioo_atTop.mp tanOrderIso.symm.tendsto_atTop
theorem tendsto_arctan_atBot : Tendsto arctan atBot (π[>] (-(Ο / 2))) :=
tendsto_Ioo_atBot.mp tanOrderIso.symm.tendsto_atBot
theorem arctan_eq_of_tan_eq (h : tan x = y) (hx : x β Ioo (-(Ο / 2)) (Ο / 2)) :
arctan y = x :=
injOn_tan (arctan_mem_Ioo _) hx (by rw [tan_arctan, h])
@[simp]
theorem arctan_one : arctan 1 = Ο / 4 :=
arctan_eq_of_tan_eq tan_pi_div_four <| by constructor <;> linarith [pi_pos]
@[simp]
theorem arctan_eq_pi_div_four : arctan x = Ο / 4 β x = 1 := arctan_injective.eq_iff' arctan_one
@[simp]
theorem arctan_neg (x : β) : arctan (-x) = -arctan x := by simp [arctan_eq_arcsin, neg_div]
@[simp]
theorem arctan_eq_neg_pi_div_four : arctan x = -(Ο / 4) β x = -1 :=
arctan_injective.eq_iff' <| by rw [arctan_neg, arctan_one]
@[simp]
theorem arctan_pos : 0 < arctan x β 0 < x := by
simpa only [arctan_zero] using arctan_lt_arctan_iff (x := 0)
@[simp]
theorem arctan_lt_zero : arctan x < 0 β x < 0 := by
simpa only [arctan_zero] using arctan_lt_arctan_iff (y := 0)
@[simp]
theorem arctan_nonneg : 0 β€ arctan x β 0 β€ x := by
simpa only [arctan_zero] using arctan_le_arctan_iff (x := 0)
@[simp]
theorem arctan_le_zero : arctan x β€ 0 β x β€ 0 := by
simpa only [arctan_zero] using arctan_le_arctan_iff (y := 0)
theorem arctan_eq_arccos (h : 0 β€ x) : arctan x = arccos (β(1 + x ^ 2))β»ΒΉ := by
rw [arctan_eq_arcsin, arccos_eq_arcsin]; swap; Β· exact inv_nonneg.2 (sqrt_nonneg _)
congr 1
rw_mod_cast [β sqrt_inv, sq_sqrt, β one_div, one_sub_div, add_sub_cancel_left, sqrt_div,
sqrt_sq h]
all_goals positivity
-- The junk values for `arccos` and `sqrt` make this true even for `1 < x`.
theorem arccos_eq_arctan (h : 0 < x) : arccos x = arctan (β(1 - x ^ 2) / x) := by
rw [arccos, eq_comm]
refine arctan_eq_of_tan_eq ?_ β¨?_, ?_β©
Β· rw_mod_cast [tan_pi_div_two_sub, tan_arcsin, inv_div]
Β· linarith only [arcsin_le_pi_div_two x, pi_pos]
Β· linarith only [arcsin_pos.2 h]
theorem arctan_inv_of_pos (h : 0 < x) : arctan xβ»ΒΉ = Ο / 2 - arctan x := by
rw [β arctan_tan (x := _ - _), tan_pi_div_two_sub, tan_arctan]
Β· norm_num
exact (arctan_lt_pi_div_two x).trans (half_lt_self_iff.mpr pi_pos)
Β· rw [sub_lt_self_iff, β arctan_zero]
exact tanOrderIso.symm.strictMono h
theorem arctan_inv_of_neg (h : x < 0) : arctan xβ»ΒΉ = -(Ο / 2) - arctan x := by
have := arctan_inv_of_pos (neg_pos.mpr h)
rwa [inv_neg, arctan_neg, neg_eq_iff_eq_neg, neg_sub', arctan_neg, neg_neg] at this
section ArctanAdd
lemma arctan_ne_mul_pi_div_two : β (k : β€), arctan x β (2 * k + 1) * Ο / 2 := by
by_contra!
obtain β¨k, hβ© := this
obtain β¨lb, ubβ© := arctan_mem_Ioo x
rw [h, neg_eq_neg_one_mul, mul_div_assoc, mul_lt_mul_iff_leftβ (by positivity)] at lb
rw [h, β one_mul (Ο / 2), mul_div_assoc, mul_lt_mul_iff_leftβ (by positivity)] at ub
norm_cast at lb ub; change -1 < _ at lb; cutsat
lemma arctan_add_arctan_lt_pi_div_two (h : x * y < 1) : arctan x + arctan y < Ο / 2 := by
rcases le_or_gt y 0 with hy | hy
Β· rw [β add_zero (Ο / 2), β arctan_zero]
exact add_lt_add_of_lt_of_le (arctan_lt_pi_div_two _) (tanOrderIso.symm.monotone hy)
Β· rw [β lt_div_iffβ hy, β inv_eq_one_div] at h
replace h : arctan x < arctan yβ»ΒΉ := tanOrderIso.symm.strictMono h
rwa [arctan_inv_of_pos hy, lt_tsub_iff_right] at h
theorem arctan_add (h : x * y < 1) :
arctan x + arctan y = arctan ((x + y) / (1 - x * y)) := by
rw [β arctan_tan (x := _ + _)]
Β· congr
conv_rhs => rw [β tan_arctan x, β tan_arctan y]
exact tan_add' β¨arctan_ne_mul_pi_div_two, arctan_ne_mul_pi_div_twoβ©
Β· rw [neg_lt, neg_add, β arctan_neg, β arctan_neg]
rw [β neg_mul_neg] at h
exact arctan_add_arctan_lt_pi_div_two h
Β· exact arctan_add_arctan_lt_pi_div_two h
theorem arctan_add_eq_add_pi (h : 1 < x * y) (hx : 0 < x) :
arctan x + arctan y = arctan ((x + y) / (1 - x * y)) + Ο := by
have hy : 0 < y := by
have := mul_pos_iff.mp (zero_lt_one.trans h)
simpa [hx, hx.asymm]
have k := arctan_add (mul_inv x y βΈ inv_lt_one_of_one_ltβ h)
rw [arctan_inv_of_pos hx, arctan_inv_of_pos hy, show _ + _ = Ο - (arctan x + arctan y) by ring,
sub_eq_iff_eq_add, β sub_eq_iff_eq_add', sub_eq_add_neg, β arctan_neg, add_comm] at k
grind
theorem arctan_add_eq_sub_pi (h : 1 < x * y) (hx : x < 0) :
arctan x + arctan y = arctan ((x + y) / (1 - x * y)) - Ο := by
rw [β neg_mul_neg] at h
have k := arctan_add_eq_add_pi h (neg_pos.mpr hx)
rw [show _ / _ = -((x + y) / (1 - x * y)) by ring, β neg_inj] at k
simp only [arctan_neg, neg_add, neg_neg, β sub_eq_add_neg _ Ο] at k
exact k
theorem two_mul_arctan (hβ : -1 < x) (hβ : x < 1) :
2 * arctan x = arctan (2 * x / (1 - x ^ 2)) := by
rw [two_mul, arctan_add (by nlinarith)]; congr 1; ring
theorem two_mul_arctan_add_pi (h : 1 < x) :
2 * arctan x = arctan (2 * x / (1 - x ^ 2)) + Ο := by
rw [two_mul, arctan_add_eq_add_pi (by nlinarith) (by linarith)]; congr 2; ring
theorem two_mul_arctan_sub_pi (h : x < -1) :
2 * arctan x = arctan (2 * x / (1 - x ^ 2)) - Ο := by
rw [two_mul, arctan_add_eq_sub_pi (by nlinarith) (by linarith)]; congr 2; ring
theorem arctan_inv_2_add_arctan_inv_3 : arctan 2β»ΒΉ + arctan 3β»ΒΉ = Ο / 4 := by
rw [arctan_add] <;> norm_num
theorem two_mul_arctan_inv_2_sub_arctan_inv_7 : 2 * arctan 2β»ΒΉ - arctan 7β»ΒΉ = Ο / 4 := by
rw [two_mul_arctan, β arctan_one, sub_eq_iff_eq_add, arctan_add] <;> norm_num
theorem two_mul_arctan_inv_3_add_arctan_inv_7 : 2 * arctan 3β»ΒΉ + arctan 7β»ΒΉ = Ο / 4 := by
rw [two_mul_arctan, arctan_add] <;> norm_num
/-- **John Machin's 1706 formula**, which he used to compute Ο to 100 decimal places. -/
theorem four_mul_arctan_inv_5_sub_arctan_inv_239 : 4 * arctan 5β»ΒΉ - arctan 239β»ΒΉ = Ο / 4 := by
rw [show 4 * arctan _ = 2 * (2 * _) by ring, two_mul_arctan, two_mul_arctan, β arctan_one,
sub_eq_iff_eq_add, arctan_add] <;> norm_num
end ArctanAdd
theorem sin_arctan_strictMono : StrictMono (sin <| arctan Β·) := fun x y h β¦
strictMonoOn_sin (Ioo_subset_Icc_self <| arctan_mem_Ioo x)
(Ioo_subset_Icc_self <| arctan_mem_Ioo y) (arctan_strictMono h)
@[simp]
theorem sin_arctan_pos : 0 < sin (arctan x) β 0 < x := by
simpa using sin_arctan_strictMono.lt_iff_lt (a := 0)
@[simp]
theorem sin_arctan_lt_zero : sin (arctan x) < 0 β x < 0 := by
simpa using sin_arctan_strictMono.lt_iff_lt (b := 0)
@[simp]
theorem sin_arctan_eq_zero : sin (arctan x) = 0 β x = 0 :=
sin_arctan_strictMono.injective.eq_iff' <| by simp
@[simp]
theorem sin_arctan_nonneg : 0 β€ sin (arctan x) β 0 β€ x := by
simpa using sin_arctan_strictMono.le_iff_le (a := 0)
@[simp]
theorem sin_arctan_le_zero : sin (arctan x) β€ 0 β x β€ 0 := by
simpa using sin_arctan_strictMono.le_iff_le (b := 0)
@[continuity]
theorem continuous_arctan : Continuous arctan :=
continuous_subtype_val.comp tanOrderIso.toHomeomorph.continuous_invFun
theorem continuousAt_arctan : ContinuousAt arctan x :=
continuous_arctan.continuousAt
/-- `Real.tan` as an `OpenPartialHomeomorph` between `(-(Ο / 2), Ο / 2)` and the whole line. -/
def tanPartialHomeomorph : OpenPartialHomeomorph β β where
toFun := tan
invFun := arctan
source := Ioo (-(Ο / 2)) (Ο / 2)
target := univ
map_source' := mapsTo_univ _ _
map_target' y _ := arctan_mem_Ioo y
left_inv' _ hx := arctan_tan hx.1 hx.2
right_inv' y _ := tan_arctan y
open_source := isOpen_Ioo
open_target := isOpen_univ
continuousOn_toFun := continuousOn_tan_Ioo
continuousOn_invFun := continuous_arctan.continuousOn
@[simp]
theorem coe_tanPartialHomeomorph : βtanPartialHomeomorph = tan :=
rfl
@[simp]
theorem coe_tanPartialHomeomorph_symm : βtanPartialHomeomorph.symm = arctan :=
rfl
end Real
namespace Mathlib.Meta.Positivity
open Lean Meta Qq
/-- Extension for `Real.arctan`. -/
@[positivity Real.arctan _]
def evalRealArctan : PositivityExt where eval {u Ξ±} z p e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.arctan $a) =>
let ra β core z p a
assumeInstancesCommute
match ra with
| .positive pa => return .positive q(Real.arctan_pos.mpr $pa)
| .nonnegative na => return .nonnegative q(Real.arctan_nonneg.mpr $na)
| .nonzero na => return .nonzero q(mt Real.arctan_eq_zero_iff.mp $na)
| .none => return .none
| _ => throwError "not Real.arctan"
/-- Extension for `Real.cos (Real.arctan _)`. -/
@[positivity Real.cos (Real.arctan _)]
def evalRealCosArctan : PositivityExt where eval {u Ξ±} _ _ e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.cos (Real.arctan $a)) =>
assumeInstancesCommute
return .positive q(Real.cos_arctan_pos _)
| _ => throwError "not Real.cos (Real.arctan _)"
/-- Extension for `Real.sin (Real.arctan _)`. -/
@[positivity Real.sin (Real.arctan _)]
def evalRealSinArctan : PositivityExt where eval {u Ξ±} z p e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.sin (Real.arctan $a)) =>
assumeInstancesCommute
match β core z p a with
| .positive pa => return .positive q(Real.sin_arctan_pos.mpr $pa)
| .nonnegative na => return .nonnegative q(Real.sin_arctan_nonneg.mpr $na)
| .nonzero na => return .nonzero q(mt Real.sin_arctan_eq_zero.mp $na)
| .none => return .none
| _ => throwError "not Real.sin (Real.arctan _)"
end Mathlib.Meta.Positivity |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean | import Mathlib.Analysis.Complex.Trigonometric
import Mathlib.Analysis.SpecialFunctions.Exponential
/-!
# Trigonometric functions as sums of infinite series
In this file we express trigonometric functions in terms of their series expansion.
## Main results
* `Complex.hasSum_cos`, `Complex.cos_eq_tsum`: `Complex.cos` as the sum of an infinite series.
* `Real.hasSum_cos`, `Real.cos_eq_tsum`: `Real.cos` as the sum of an infinite series.
* `Complex.hasSum_sin`, `Complex.sin_eq_tsum`: `Complex.sin` as the sum of an infinite series.
* `Real.hasSum_sin`, `Real.sin_eq_tsum`: `Real.sin` as the sum of an infinite series.
-/
open NormedSpace
open scoped Nat
/-! ### `cos` and `sin` for `β` and `β` -/
section SinCos
theorem Complex.hasSum_cos' (z : β) :
HasSum (fun n : β => (z * Complex.I) ^ (2 * n) / β(2 * n)!) (Complex.cos z) := by
rw [Complex.cos, Complex.exp_eq_exp_β]
have := ((expSeries_div_hasSum_exp β (z * Complex.I)).add
(expSeries_div_hasSum_exp β (-z * Complex.I))).div_const 2
replace := (Nat.divModEquiv 2).symm.hasSum_iff.mpr this
dsimp [Function.comp_def] at this
simp_rw [β mul_comm 2 _] at this
refine this.prod_fiberwise fun k => ?_
dsimp only
convert hasSum_fintype (_ : Fin 2 β β) using 1
rw [Fin.sum_univ_two]
simp_rw [Fin.val_zero, Fin.val_one, add_zero, pow_succ, pow_mul, mul_pow, neg_sq, β two_mul,
neg_mul, mul_neg, neg_div, add_neg_cancel, zero_div, add_zero,
mul_div_cancel_leftβ _ (two_ne_zero : (2 : β) β 0)]
theorem Complex.hasSum_sin' (z : β) :
HasSum (fun n : β => (z * Complex.I) ^ (2 * n + 1) / β(2 * n + 1)! / Complex.I)
(Complex.sin z) := by
rw [Complex.sin, Complex.exp_eq_exp_β]
have := (((expSeries_div_hasSum_exp β (-z * Complex.I)).sub
(expSeries_div_hasSum_exp β (z * Complex.I))).mul_right Complex.I).div_const 2
replace := (Nat.divModEquiv 2).symm.hasSum_iff.mpr this
dsimp [Function.comp_def] at this
simp_rw [β mul_comm 2 _] at this
refine this.prod_fiberwise fun k => ?_
dsimp only
convert hasSum_fintype (_ : Fin 2 β β) using 1
rw [Fin.sum_univ_two]
simp_rw [Fin.val_zero, Fin.val_one, add_zero, pow_succ, pow_mul, mul_pow, neg_sq, sub_self,
zero_mul, zero_div, zero_add, neg_mul, mul_neg, neg_div, β neg_add', β two_mul,
neg_mul, neg_div, mul_assoc, mul_div_cancel_leftβ _ (two_ne_zero : (2 : β) β 0), Complex.div_I]
/-- The power series expansion of `Complex.cos`. -/
theorem Complex.hasSum_cos (z : β) :
HasSum (fun n : β => (-1) ^ n * z ^ (2 * n) / β(2 * n)!) (Complex.cos z) := by
convert Complex.hasSum_cos' z using 1
simp_rw [mul_pow, pow_mul, Complex.I_sq, mul_comm]
/-- The power series expansion of `Complex.sin`. -/
theorem Complex.hasSum_sin (z : β) :
HasSum (fun n : β => (-1) ^ n * z ^ (2 * n + 1) / β(2 * n + 1)!) (Complex.sin z) := by
convert Complex.hasSum_sin' z using 1
simp_rw [mul_pow, pow_succ, pow_mul, Complex.I_sq, β mul_assoc, mul_div_assoc, div_right_comm,
div_self Complex.I_ne_zero, mul_comm _ ((-1 : β) ^ _), mul_one_div, mul_div_assoc, mul_assoc]
theorem Complex.cos_eq_tsum' (z : β) :
Complex.cos z = β' n : β, (z * Complex.I) ^ (2 * n) / β(2 * n)! :=
(Complex.hasSum_cos' z).tsum_eq.symm
theorem Complex.sin_eq_tsum' (z : β) :
Complex.sin z = β' n : β, (z * Complex.I) ^ (2 * n + 1) / β(2 * n + 1)! / Complex.I :=
(Complex.hasSum_sin' z).tsum_eq.symm
theorem Complex.cos_eq_tsum (z : β) :
Complex.cos z = β' n : β, (-1) ^ n * z ^ (2 * n) / β(2 * n)! :=
(Complex.hasSum_cos z).tsum_eq.symm
theorem Complex.sin_eq_tsum (z : β) :
Complex.sin z = β' n : β, (-1) ^ n * z ^ (2 * n + 1) / β(2 * n + 1)! :=
(Complex.hasSum_sin z).tsum_eq.symm
/-- The power series expansion of `Real.cos`. -/
theorem Real.hasSum_cos (r : β) :
HasSum (fun n : β => (-1) ^ n * r ^ (2 * n) / β(2 * n)!) (Real.cos r) :=
mod_cast Complex.hasSum_cos r
/-- The power series expansion of `Real.sin`. -/
theorem Real.hasSum_sin (r : β) :
HasSum (fun n : β => (-1) ^ n * r ^ (2 * n + 1) / β(2 * n + 1)!) (Real.sin r) :=
mod_cast Complex.hasSum_sin r
theorem Real.cos_eq_tsum (r : β) : Real.cos r = β' n : β, (-1) ^ n * r ^ (2 * n) / β(2 * n)! :=
(Real.hasSum_cos r).tsum_eq.symm
theorem Real.sin_eq_tsum (r : β) :
Real.sin r = β' n : β, (-1) ^ n * r ^ (2 * n + 1) / β(2 * n + 1)! :=
(Real.hasSum_sin r).tsum_eq.symm
end SinCos
/-! ### `cosh` and `sinh` for `β` and `β` -/
section SinhCosh
namespace Complex
/-- The power series expansion of `Complex.cosh`. -/
lemma hasSum_cosh (z : β) : HasSum (fun n β¦ z ^ (2 * n) / β(2 * n)!) (cosh z) := by
simpa [mul_assoc, cos_mul_I] using hasSum_cos' (z * I)
/-- The power series expansion of `Complex.sinh`. -/
lemma hasSum_sinh (z : β) : HasSum (fun n β¦ z ^ (2 * n + 1) / β(2 * n + 1)!) (sinh z) := by
simpa [mul_assoc, sin_mul_I, neg_pow z, pow_add, pow_mul, neg_mul, neg_div]
using (hasSum_sin' (z * I)).mul_right (-I)
lemma cosh_eq_tsum (z : β) : cosh z = β' n, z ^ (2 * n) / β(2 * n)! := z.hasSum_cosh.tsum_eq.symm
lemma sinh_eq_tsum (z : β) : sinh z = β' n, z ^ (2 * n + 1) / β(2 * n + 1)! :=
z.hasSum_sinh.tsum_eq.symm
end Complex
namespace Real
/-- The power series expansion of `Real.cosh`. -/
lemma hasSum_cosh (r : β) : HasSum (fun n β¦ r ^ (2 * n) / β(2 * n)!) (cosh r) :=
mod_cast Complex.hasSum_cosh r
/-- The power series expansion of `Real.sinh`. -/
lemma hasSum_sinh (r : β) : HasSum (fun n β¦ r ^ (2 * n + 1) / β(2 * n + 1)!) (sinh r) :=
mod_cast Complex.hasSum_sinh r
lemma cosh_eq_tsum (r : β) : cosh r = β' n, r ^ (2 * n) / β(2 * n)! := r.hasSum_cosh.tsum_eq.symm
lemma sinh_eq_tsum (r : β) : sinh r = β' n, r ^ (2 * n + 1) / β(2 * n + 1)! :=
r.hasSum_sinh.tsum_eq.symm
lemma cosh_le_exp_half_sq (x : β) : cosh x β€ exp (x ^ 2 / 2) := by
rw [cosh_eq_tsum, exp_eq_exp_β, exp_eq_tsum]
refine x.hasSum_cosh.summable.tsum_le_tsum (fun i β¦ ?_) <| expSeries_summable' (x ^ 2 / 2)
simp only [div_pow, pow_mul, smul_eq_mul, inv_mul_eq_div, div_div]
gcongr
norm_cast
exact Nat.two_pow_mul_factorial_le_factorial_two_mul _
end Real
end SinhCosh |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.Normed.Group.AddCircle
import Mathlib.Algebra.CharZero.Quotient
import Mathlib.Topology.Instances.Sign
/-!
# The type of angles
In this file we define `Real.Angle` to be the quotient group `β/2Οβ€` and prove a few simple lemmas
about trigonometric functions and angles.
-/
open Real
noncomputable section
namespace Real
/-- The type of angles -/
def Angle : Type :=
AddCircle (2 * Ο)
deriving NormedAddCommGroup, Inhabited
namespace Angle
/-- The canonical map from `β` to the quotient `Angle`. -/
@[coe]
protected def coe (r : β) : Angle := QuotientAddGroup.mk r
instance : Coe β Angle := β¨Angle.coeβ©
instance : CircularOrder Real.Angle :=
QuotientAddGroup.circularOrder (hp' := β¨by simp [pi_pos]β©)
@[continuity]
theorem continuous_coe : Continuous ((β) : β β Angle) :=
continuous_quotient_mk'
/-- Coercion `β β Angle` as an additive homomorphism. -/
def coeHom : β β+ Angle :=
QuotientAddGroup.mk' _
@[simp]
theorem coe_coeHom : (coeHom : β β Angle) = ((β) : β β Angle) :=
rfl
/-- An induction principle to deduce results for `Angle` from those for `β`, used with
`induction ΞΈ using Real.Angle.induction_on`. -/
@[elab_as_elim]
protected theorem induction_on {p : Angle β Prop} (ΞΈ : Angle) (h : β x : β, p x) : p ΞΈ :=
Quotient.inductionOn' ΞΈ h
@[simp]
theorem coe_zero : β(0 : β) = (0 : Angle) :=
rfl
@[simp]
theorem coe_add (x y : β) : β(x + y : β) = (βx + βy : Angle) :=
rfl
@[simp]
theorem coe_neg (x : β) : β(-x : β) = -(βx : Angle) :=
rfl
@[simp]
theorem coe_sub (x y : β) : β(x - y : β) = (βx - βy : Angle) :=
rfl
theorem coe_nsmul (n : β) (x : β) : β(n β’ x : β) = n β’ (βx : Angle) :=
rfl
theorem coe_zsmul (z : β€) (x : β) : β(z β’ x : β) = z β’ (βx : Angle) :=
rfl
theorem coe_eq_zero_iff {x : β} : (x : Angle) = 0 β β n : β€, n β’ (2 * Ο) = x :=
AddCircle.coe_eq_zero_iff (2 * Ο)
@[simp, norm_cast]
theorem natCast_mul_eq_nsmul (x : β) (n : β) : β((n : β) * x) = n β’ (βx : Angle) := by
simpa only [nsmul_eq_mul] using coeHom.map_nsmul x n
@[simp, norm_cast]
theorem intCast_mul_eq_zsmul (x : β) (n : β€) : β((n : β) * x : β) = n β’ (βx : Angle) := by
simpa only [zsmul_eq_mul] using coeHom.map_zsmul x n
theorem angle_eq_iff_two_pi_dvd_sub {Ο ΞΈ : β} : (ΞΈ : Angle) = Ο β β k : β€, ΞΈ - Ο = 2 * Ο * k := by
simp only [eq_comm]
rw [Angle.coe, Angle.coe, QuotientAddGroup.eq]
simp only [AddSubgroup.zmultiples_eq_closure,
AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
@[simp]
theorem coe_two_pi : β(2 * Ο : β) = (0 : Angle) :=
angle_eq_iff_two_pi_dvd_sub.2 β¨1, by rw [sub_zero, Int.cast_one, mul_one]β©
@[simp]
theorem neg_coe_pi : -(Ο : Angle) = Ο := by
rw [β coe_neg, angle_eq_iff_two_pi_dvd_sub]
use -1
simp [two_mul, sub_eq_add_neg]
@[simp]
theorem two_nsmul_coe_div_two (ΞΈ : β) : (2 : β) β’ (β(ΞΈ / 2) : Angle) = ΞΈ := by
rw [β coe_nsmul, two_nsmul, add_halves]
@[simp]
theorem two_zsmul_coe_div_two (ΞΈ : β) : (2 : β€) β’ (β(ΞΈ / 2) : Angle) = ΞΈ := by
rw [β coe_zsmul, two_zsmul, add_halves]
theorem two_nsmul_neg_pi_div_two : (2 : β) β’ (β(-Ο / 2) : Angle) = Ο := by
rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi]
theorem two_zsmul_neg_pi_div_two : (2 : β€) β’ (β(-Ο / 2) : Angle) = Ο := by
rw [two_zsmul, β two_nsmul, two_nsmul_neg_pi_div_two]
theorem sub_coe_pi_eq_add_coe_pi (ΞΈ : Angle) : ΞΈ - Ο = ΞΈ + Ο := by
rw [sub_eq_add_neg, neg_coe_pi]
@[simp]
theorem two_nsmul_coe_pi : (2 : β) β’ (Ο : Angle) = 0 := by simp [β natCast_mul_eq_nsmul]
@[simp]
theorem two_zsmul_coe_pi : (2 : β€) β’ (Ο : Angle) = 0 := by simp [β intCast_mul_eq_zsmul]
@[simp]
theorem coe_pi_add_coe_pi : (Ο : Real.Angle) + Ο = 0 := by rw [β two_nsmul, two_nsmul_coe_pi]
theorem zsmul_eq_iff {Ο ΞΈ : Angle} {z : β€} (hz : z β 0) :
z β’ Ο = z β’ ΞΈ β β k : Fin z.natAbs, Ο = ΞΈ + (k : β) β’ (2 * Ο / z : β) :=
QuotientAddGroup.zmultiples_zsmul_eq_zsmul_iff hz
theorem nsmul_eq_iff {Ο ΞΈ : Angle} {n : β} (hz : n β 0) :
n β’ Ο = n β’ ΞΈ β β k : Fin n, Ο = ΞΈ + (k : β) β’ (2 * Ο / n : β) :=
QuotientAddGroup.zmultiples_nsmul_eq_nsmul_iff hz
theorem two_zsmul_eq_iff {Ο ΞΈ : Angle} : (2 : β€) β’ Ο = (2 : β€) β’ ΞΈ β Ο = ΞΈ β¨ Ο = ΞΈ + βΟ := by
have : Int.natAbs 2 = 2 := rfl
rw [zsmul_eq_iff two_ne_zero, this, Fin.exists_fin_two, Fin.val_zero,
Fin.val_one, zero_smul, add_zero, one_smul, Int.cast_two,
mul_div_cancel_leftβ (_ : β) two_ne_zero]
theorem two_nsmul_eq_iff {Ο ΞΈ : Angle} : (2 : β) β’ Ο = (2 : β) β’ ΞΈ β Ο = ΞΈ β¨ Ο = ΞΈ + βΟ := by
simp_rw [β natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff]
theorem two_nsmul_eq_zero_iff {ΞΈ : Angle} : (2 : β) β’ ΞΈ = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
convert two_nsmul_eq_iff <;> simp
theorem two_nsmul_ne_zero_iff {ΞΈ : Angle} : (2 : β) β’ ΞΈ β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β two_nsmul_eq_zero_iff]
theorem two_zsmul_eq_zero_iff {ΞΈ : Angle} : (2 : β€) β’ ΞΈ = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
simp_rw [two_zsmul, β two_nsmul, two_nsmul_eq_zero_iff]
theorem two_zsmul_ne_zero_iff {ΞΈ : Angle} : (2 : β€) β’ ΞΈ β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β two_zsmul_eq_zero_iff]
theorem eq_neg_self_iff {ΞΈ : Angle} : ΞΈ = -ΞΈ β ΞΈ = 0 β¨ ΞΈ = Ο := by
rw [β add_eq_zero_iff_eq_neg, β two_nsmul, two_nsmul_eq_zero_iff]
theorem ne_neg_self_iff {ΞΈ : Angle} : ΞΈ β -ΞΈ β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β eq_neg_self_iff.not]
theorem neg_eq_self_iff {ΞΈ : Angle} : -ΞΈ = ΞΈ β ΞΈ = 0 β¨ ΞΈ = Ο := by rw [eq_comm, eq_neg_self_iff]
theorem neg_ne_self_iff {ΞΈ : Angle} : -ΞΈ β ΞΈ β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β neg_eq_self_iff.not]
theorem two_nsmul_eq_pi_iff {ΞΈ : Angle} : (2 : β) β’ ΞΈ = Ο β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
have h : (Ο : Angle) = ((2 : β) β’ (Ο / 2 : β):) := by rw [two_nsmul, add_halves]
nth_rw 1 [h]
rw [coe_nsmul, two_nsmul_eq_iff]
apply iff_of_eq -- `congr` only works on `Eq`, so rewrite from `Iff` to `Eq`.
congr
rw [add_comm, β coe_add, β sub_eq_zero, β coe_sub, neg_div, sub_neg_eq_add, add_assoc,
add_halves, β two_mul, coe_two_pi]
theorem two_zsmul_eq_pi_iff {ΞΈ : Angle} : (2 : β€) β’ ΞΈ = Ο β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
rw [two_zsmul, β two_nsmul, two_nsmul_eq_pi_iff]
theorem cos_eq_iff_coe_eq_or_eq_neg {ΞΈ Ο : β} :
cos ΞΈ = cos Ο β (ΞΈ : Angle) = Ο β¨ (ΞΈ : Angle) = -Ο := by
constructor
Β· intro Hcos
rw [β sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero,
eq_false (two_ne_zero' β), false_or, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos
rcases Hcos with (β¨n, hnβ© | β¨n, hnβ©)
Β· right
rw [eq_div_iff_mul_eq (two_ne_zero' β), β sub_eq_iff_eq_add] at hn
rw [β hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc, intCast_mul_eq_zsmul,
mul_comm, coe_two_pi, zsmul_zero]
Β· left
rw [eq_div_iff_mul_eq (two_ne_zero' β), eq_sub_iff_add_eq] at hn
rw [β hn, coe_add, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero,
zero_add]
Β· rw [angle_eq_iff_two_pi_dvd_sub, β coe_neg, angle_eq_iff_two_pi_dvd_sub]
rintro (β¨k, Hβ© | β¨k, Hβ©)
Β· rw [β sub_eq_zero, cos_sub_cos, H, mul_assoc 2 Ο k, mul_div_cancel_leftβ _ (two_ne_zero' β),
mul_comm Ο _, sin_int_mul_pi, mul_zero]
rw [β sub_eq_zero, cos_sub_cos, β sub_neg_eq_add, H, mul_assoc 2 Ο k,
mul_div_cancel_leftβ _ (two_ne_zero' β), mul_comm Ο _, sin_int_mul_pi, mul_zero,
zero_mul]
theorem sin_eq_iff_coe_eq_or_add_eq_pi {ΞΈ Ο : β} :
sin ΞΈ = sin Ο β (ΞΈ : Angle) = Ο β¨ (ΞΈ : Angle) + Ο = Ο := by
constructor
Β· intro Hsin
rw [β cos_pi_div_two_sub, β cos_pi_div_two_sub] at Hsin
rcases cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h | h
Β· left
rw [coe_sub, coe_sub] at h
exact sub_right_inj.1 h
right
rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub, sub_add_eq_add_sub, β coe_add,
add_halves, sub_sub, sub_eq_zero] at h
exact h.symm
Β· rw [angle_eq_iff_two_pi_dvd_sub, β eq_sub_iff_add_eq, β coe_sub, angle_eq_iff_two_pi_dvd_sub]
rintro (β¨k, Hβ© | β¨k, Hβ©)
Β· rw [β sub_eq_zero, sin_sub_sin, H, mul_assoc 2 Ο k, mul_div_cancel_leftβ _ (two_ne_zero' β),
mul_comm Ο _, sin_int_mul_pi, mul_zero, zero_mul]
have H' : ΞΈ + Ο = 2 * k * Ο + Ο := by
rwa [β sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add, mul_assoc, mul_comm Ο _, β
mul_assoc] at H
rw [β sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ Ο,
mul_div_cancel_leftβ _ (two_ne_zero' β), cos_add_pi_div_two, sin_int_mul_pi, neg_zero,
mul_zero]
theorem cos_sin_inj {ΞΈ Ο : β} (Hcos : cos ΞΈ = cos Ο) (Hsin : sin ΞΈ = sin Ο) : (ΞΈ : Angle) = Ο := by
rcases cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc | hc; Β· exact hc
rcases sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs | hs; Β· exact hs
rw [eq_neg_iff_add_eq_zero, hs] at hc
obtain β¨n, hnβ© : β n, n β’ _ = _ := QuotientAddGroup.leftRel_apply.mp (Quotient.exact' hc)
rw [β neg_one_mul, add_zero, β sub_eq_zero, zsmul_eq_mul, β mul_assoc, β sub_mul, mul_eq_zero,
eq_false (ne_of_gt pi_pos), or_false, sub_neg_eq_add, β Int.cast_zero, β Int.cast_one,
β Int.cast_ofNat, β Int.cast_mul, β Int.cast_add, Int.cast_inj] at hn
have : (n * 2 + 1) % (2 : β€) = 0 % (2 : β€) := congr_arg (Β· % (2 : β€)) hn
rw [add_comm, Int.add_mul_emod_self_right] at this
exact absurd this one_ne_zero
/-- The sine of a `Real.Angle`. -/
def sin (ΞΈ : Angle) : β :=
sin_periodic.lift ΞΈ
@[simp]
theorem sin_coe (x : β) : sin (x : Angle) = Real.sin x :=
rfl
@[continuity]
theorem continuous_sin : Continuous sin :=
Real.continuous_sin.quotient_liftOn' _
/-- The cosine of a `Real.Angle`. -/
def cos (ΞΈ : Angle) : β :=
cos_periodic.lift ΞΈ
@[simp]
theorem cos_coe (x : β) : cos (x : Angle) = Real.cos x :=
rfl
@[continuity]
theorem continuous_cos : Continuous cos :=
Real.continuous_cos.quotient_liftOn' _
theorem cos_eq_real_cos_iff_eq_or_eq_neg {ΞΈ : Angle} {Ο : β} :
cos ΞΈ = Real.cos Ο β ΞΈ = Ο β¨ ΞΈ = -Ο := by
induction ΞΈ using Real.Angle.induction_on
exact cos_eq_iff_coe_eq_or_eq_neg
theorem cos_eq_iff_eq_or_eq_neg {ΞΈ Ο : Angle} : cos ΞΈ = cos Ο β ΞΈ = Ο β¨ ΞΈ = -Ο := by
induction Ο using Real.Angle.induction_on
exact cos_eq_real_cos_iff_eq_or_eq_neg
theorem sin_eq_real_sin_iff_eq_or_add_eq_pi {ΞΈ : Angle} {Ο : β} :
sin ΞΈ = Real.sin Ο β ΞΈ = Ο β¨ ΞΈ + Ο = Ο := by
induction ΞΈ using Real.Angle.induction_on
exact sin_eq_iff_coe_eq_or_add_eq_pi
theorem sin_eq_iff_eq_or_add_eq_pi {ΞΈ Ο : Angle} : sin ΞΈ = sin Ο β ΞΈ = Ο β¨ ΞΈ + Ο = Ο := by
induction Ο using Real.Angle.induction_on
exact sin_eq_real_sin_iff_eq_or_add_eq_pi
@[simp]
theorem sin_zero : sin (0 : Angle) = 0 := by rw [β coe_zero, sin_coe, Real.sin_zero]
theorem sin_coe_pi : sin (Ο : Angle) = 0 := by rw [sin_coe, Real.sin_pi]
theorem sin_eq_zero_iff {ΞΈ : Angle} : sin ΞΈ = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
nth_rw 1 [β sin_zero]
rw [sin_eq_iff_eq_or_add_eq_pi]
simp
theorem sin_ne_zero_iff {ΞΈ : Angle} : sin ΞΈ β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β sin_eq_zero_iff]
@[simp]
theorem sin_neg (ΞΈ : Angle) : sin (-ΞΈ) = -sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_neg _
theorem sin_antiperiodic : Function.Antiperiodic sin (Ο : Angle) := by
intro ΞΈ
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_antiperiodic _
@[simp]
theorem sin_add_pi (ΞΈ : Angle) : sin (ΞΈ + Ο) = -sin ΞΈ :=
sin_antiperiodic ΞΈ
@[simp]
theorem sin_sub_pi (ΞΈ : Angle) : sin (ΞΈ - Ο) = -sin ΞΈ :=
sin_antiperiodic.sub_eq ΞΈ
@[simp]
theorem cos_zero : cos (0 : Angle) = 1 := by rw [β coe_zero, cos_coe, Real.cos_zero]
theorem cos_coe_pi : cos (Ο : Angle) = -1 := by rw [cos_coe, Real.cos_pi]
@[simp]
theorem cos_neg (ΞΈ : Angle) : cos (-ΞΈ) = cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_neg _
theorem cos_antiperiodic : Function.Antiperiodic cos (Ο : Angle) := by
intro ΞΈ
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_antiperiodic _
@[simp]
theorem cos_add_pi (ΞΈ : Angle) : cos (ΞΈ + Ο) = -cos ΞΈ :=
cos_antiperiodic ΞΈ
@[simp]
theorem cos_sub_pi (ΞΈ : Angle) : cos (ΞΈ - Ο) = -cos ΞΈ :=
cos_antiperiodic.sub_eq ΞΈ
theorem cos_eq_zero_iff {ΞΈ : Angle} : cos ΞΈ = 0 β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
rw [β cos_pi_div_two, β cos_coe, cos_eq_iff_eq_or_eq_neg, β coe_neg, β neg_div]
theorem sin_add (ΞΈβ ΞΈβ : Real.Angle) : sin (ΞΈβ + ΞΈβ) = sin ΞΈβ * cos ΞΈβ + cos ΞΈβ * sin ΞΈβ := by
induction ΞΈβ using Real.Angle.induction_on
induction ΞΈβ using Real.Angle.induction_on
exact Real.sin_add _ _
theorem cos_add (ΞΈβ ΞΈβ : Real.Angle) : cos (ΞΈβ + ΞΈβ) = cos ΞΈβ * cos ΞΈβ - sin ΞΈβ * sin ΞΈβ := by
induction ΞΈβ using Real.Angle.induction_on
induction ΞΈβ using Real.Angle.induction_on
exact Real.cos_add _ _
@[simp]
theorem cos_sq_add_sin_sq (ΞΈ : Real.Angle) : cos ΞΈ ^ 2 + sin ΞΈ ^ 2 = 1 := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_sq_add_sin_sq _
theorem sin_add_pi_div_two (ΞΈ : Angle) : sin (ΞΈ + β(Ο / 2)) = cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_add_pi_div_two _
theorem sin_sub_pi_div_two (ΞΈ : Angle) : sin (ΞΈ - β(Ο / 2)) = -cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_sub_pi_div_two _
theorem sin_pi_div_two_sub (ΞΈ : Angle) : sin (β(Ο / 2) - ΞΈ) = cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_pi_div_two_sub _
theorem cos_add_pi_div_two (ΞΈ : Angle) : cos (ΞΈ + β(Ο / 2)) = -sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_add_pi_div_two _
theorem cos_sub_pi_div_two (ΞΈ : Angle) : cos (ΞΈ - β(Ο / 2)) = sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_sub_pi_div_two _
theorem cos_pi_div_two_sub (ΞΈ : Angle) : cos (β(Ο / 2) - ΞΈ) = sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_pi_div_two_sub _
theorem abs_sin_eq_of_two_nsmul_eq {ΞΈ Ο : Angle} (h : (2 : β) β’ ΞΈ = (2 : β) β’ Ο) :
|sin ΞΈ| = |sin Ο| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
Β· rfl
Β· rw [sin_add_pi, abs_neg]
theorem abs_sin_eq_of_two_zsmul_eq {ΞΈ Ο : Angle} (h : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο) :
|sin ΞΈ| = |sin Ο| := by
simp_rw [two_zsmul, β two_nsmul] at h
exact abs_sin_eq_of_two_nsmul_eq h
theorem abs_cos_eq_of_two_nsmul_eq {ΞΈ Ο : Angle} (h : (2 : β) β’ ΞΈ = (2 : β) β’ Ο) :
|cos ΞΈ| = |cos Ο| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
Β· rfl
Β· rw [cos_add_pi, abs_neg]
theorem abs_cos_eq_of_two_zsmul_eq {ΞΈ Ο : Angle} (h : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο) :
|cos ΞΈ| = |cos Ο| := by
simp_rw [two_zsmul, β two_nsmul] at h
exact abs_cos_eq_of_two_nsmul_eq h
@[simp]
theorem coe_toIcoMod (ΞΈ Ο : β) : β(toIcoMod two_pi_pos Ο ΞΈ) = (ΞΈ : Angle) := by
rw [angle_eq_iff_two_pi_dvd_sub]
refine β¨-toIcoDiv two_pi_pos Ο ΞΈ, ?_β©
rw [toIcoMod_sub_self, zsmul_eq_mul, mul_comm]
@[simp]
theorem coe_toIocMod (ΞΈ Ο : β) : β(toIocMod two_pi_pos Ο ΞΈ) = (ΞΈ : Angle) := by
rw [angle_eq_iff_two_pi_dvd_sub]
refine β¨-toIocDiv two_pi_pos Ο ΞΈ, ?_β©
rw [toIocMod_sub_self, zsmul_eq_mul, mul_comm]
/-- Convert a `Real.Angle` to a real number in the interval `Ioc (-Ο) Ο`. -/
def toReal (ΞΈ : Angle) : β :=
(toIocMod_periodic two_pi_pos (-Ο)).lift ΞΈ
theorem toReal_coe (ΞΈ : β) : (ΞΈ : Angle).toReal = toIocMod two_pi_pos (-Ο) ΞΈ :=
rfl
theorem toReal_coe_eq_self_iff {ΞΈ : β} : (ΞΈ : Angle).toReal = ΞΈ β -Ο < ΞΈ β§ ΞΈ β€ Ο := by
rw [toReal_coe, toIocMod_eq_self two_pi_pos]
ring_nf
rfl
theorem toReal_coe_eq_self_iff_mem_Ioc {ΞΈ : β} : (ΞΈ : Angle).toReal = ΞΈ β ΞΈ β Set.Ioc (-Ο) Ο := by
rw [toReal_coe_eq_self_iff, β Set.mem_Ioc]
theorem toReal_injective : Function.Injective toReal := by
intro ΞΈ Ο h
induction ΞΈ using Real.Angle.induction_on
induction Ο using Real.Angle.induction_on
simpa [toReal_coe, toIocMod_eq_toIocMod, zsmul_eq_mul, mul_comm _ (2 * Ο), β
angle_eq_iff_two_pi_dvd_sub, eq_comm] using h
@[simp]
theorem toReal_inj {ΞΈ Ο : Angle} : ΞΈ.toReal = Ο.toReal β ΞΈ = Ο :=
toReal_injective.eq_iff
@[simp]
theorem coe_toReal (ΞΈ : Angle) : (ΞΈ.toReal : Angle) = ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact coe_toIocMod _ _
theorem neg_pi_lt_toReal (ΞΈ : Angle) : -Ο < ΞΈ.toReal := by
induction ΞΈ using Real.Angle.induction_on
exact left_lt_toIocMod _ _ _
theorem toReal_le_pi (ΞΈ : Angle) : ΞΈ.toReal β€ Ο := by
induction ΞΈ using Real.Angle.induction_on
convert toIocMod_le_right two_pi_pos _ _
ring
theorem abs_toReal_le_pi (ΞΈ : Angle) : |ΞΈ.toReal| β€ Ο :=
abs_le.2 β¨(neg_pi_lt_toReal _).le, toReal_le_pi _β©
theorem toReal_mem_Ioc (ΞΈ : Angle) : ΞΈ.toReal β Set.Ioc (-Ο) Ο :=
β¨neg_pi_lt_toReal _, toReal_le_pi _β©
@[simp]
theorem toIocMod_toReal (ΞΈ : Angle) : toIocMod two_pi_pos (-Ο) ΞΈ.toReal = ΞΈ.toReal := by
induction ΞΈ using Real.Angle.induction_on
rw [toReal_coe]
exact toIocMod_toIocMod _ _ _ _
@[simp]
theorem toReal_zero : (0 : Angle).toReal = 0 := by
rw [β coe_zero, toReal_coe_eq_self_iff]
exact β¨Left.neg_neg_iff.2 Real.pi_pos, Real.pi_pos.leβ©
@[simp]
theorem toReal_eq_zero_iff {ΞΈ : Angle} : ΞΈ.toReal = 0 β ΞΈ = 0 := by
nth_rw 1 [β toReal_zero]
exact toReal_inj
@[simp]
theorem toReal_pi : (Ο : Angle).toReal = Ο := by
rw [toReal_coe_eq_self_iff]
exact β¨Left.neg_lt_self Real.pi_pos, le_refl _β©
@[simp]
theorem toReal_eq_pi_iff {ΞΈ : Angle} : ΞΈ.toReal = Ο β ΞΈ = Ο := by rw [β toReal_inj, toReal_pi]
lemma toReal_neg_eq_neg_toReal_iff {ΞΈ : Angle} : (-ΞΈ).toReal = -(ΞΈ.toReal) β ΞΈ β Ο := by
nth_rw 1 [β coe_toReal ΞΈ, β coe_neg, toReal_coe_eq_self_iff]
constructor
Β· rintro β¨h, h'β© rfl
simp at h
Β· intro h
rw [neg_lt_neg_iff]
have h' : ΞΈ.toReal β Ο := by simp [h]
exact β¨(toReal_le_pi ΞΈ).lt_of_ne h', by linarith [neg_pi_lt_toReal ΞΈ]β©
theorem pi_ne_zero : (Ο : Angle) β 0 := by
rw [β toReal_injective.ne_iff, toReal_pi, toReal_zero]
exact Real.pi_ne_zero
@[simp]
theorem toReal_pi_div_two : ((Ο / 2 : β) : Angle).toReal = Ο / 2 :=
toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos]
@[simp]
theorem toReal_eq_pi_div_two_iff {ΞΈ : Angle} : ΞΈ.toReal = Ο / 2 β ΞΈ = (Ο / 2 : β) := by
rw [β toReal_inj, toReal_pi_div_two]
@[simp]
theorem toReal_neg_pi_div_two : ((-Ο / 2 : β) : Angle).toReal = -Ο / 2 :=
toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos]
@[simp]
theorem toReal_eq_neg_pi_div_two_iff {ΞΈ : Angle} : ΞΈ.toReal = -Ο / 2 β ΞΈ = (-Ο / 2 : β) := by
rw [β toReal_inj, toReal_neg_pi_div_two]
theorem pi_div_two_ne_zero : ((Ο / 2 : β) : Angle) β 0 := by
rw [β toReal_injective.ne_iff, toReal_pi_div_two, toReal_zero]
exact div_ne_zero Real.pi_ne_zero two_ne_zero
theorem neg_pi_div_two_ne_zero : ((-Ο / 2 : β) : Angle) β 0 := by
rw [β toReal_injective.ne_iff, toReal_neg_pi_div_two, toReal_zero]
exact div_ne_zero (neg_ne_zero.2 Real.pi_ne_zero) two_ne_zero
theorem abs_toReal_coe_eq_self_iff {ΞΈ : β} : |(ΞΈ : Angle).toReal| = ΞΈ β 0 β€ ΞΈ β§ ΞΈ β€ Ο :=
β¨fun h => h βΈ β¨abs_nonneg _, abs_toReal_le_pi _β©, fun h =>
(toReal_coe_eq_self_iff.2 β¨(Left.neg_neg_iff.2 Real.pi_pos).trans_le h.1, h.2β©).symm βΈ
abs_eq_self.2 h.1β©
theorem abs_toReal_neg_coe_eq_self_iff {ΞΈ : β} : |(-ΞΈ : Angle).toReal| = ΞΈ β 0 β€ ΞΈ β§ ΞΈ β€ Ο := by
refine β¨fun h => h βΈ β¨abs_nonneg _, abs_toReal_le_pi _β©, fun h => ?_β©
by_cases hnegpi : ΞΈ = Ο; Β· simp [hnegpi, Real.pi_pos.le]
rw [β coe_neg,
toReal_coe_eq_self_iff.2
β¨neg_lt_neg (lt_of_le_of_ne h.2 hnegpi), (neg_nonpos.2 h.1).trans Real.pi_pos.leβ©,
abs_neg, abs_eq_self.2 h.1]
theorem abs_toReal_eq_pi_div_two_iff {ΞΈ : Angle} :
|ΞΈ.toReal| = Ο / 2 β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
rw [abs_eq (div_nonneg Real.pi_pos.le two_pos.le), β neg_div, toReal_eq_pi_div_two_iff,
toReal_eq_neg_pi_div_two_iff]
theorem nsmul_toReal_eq_mul {n : β} (h : n β 0) {ΞΈ : Angle} :
(n β’ ΞΈ).toReal = n * ΞΈ.toReal β ΞΈ.toReal β Set.Ioc (-Ο / n) (Ο / n) := by
nth_rw 1 [β coe_toReal ΞΈ]
have h' : 0 < (n : β) := mod_cast Nat.pos_of_ne_zero h
rw [β coe_nsmul, nsmul_eq_mul, toReal_coe_eq_self_iff, Set.mem_Ioc, div_lt_iffβ' h',
le_div_iffβ' h']
theorem two_nsmul_toReal_eq_two_mul {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).toReal = 2 * ΞΈ.toReal β ΞΈ.toReal β Set.Ioc (-Ο / 2) (Ο / 2) :=
mod_cast nsmul_toReal_eq_mul two_ne_zero
theorem two_zsmul_toReal_eq_two_mul {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).toReal = 2 * ΞΈ.toReal β ΞΈ.toReal β Set.Ioc (-Ο / 2) (Ο / 2) := by
rw [two_zsmul, β two_nsmul, two_nsmul_toReal_eq_two_mul]
theorem toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff {ΞΈ : β} {k : β€} :
(ΞΈ : Angle).toReal = ΞΈ - 2 * k * Ο β ΞΈ β Set.Ioc ((2 * k - 1 : β) * Ο) ((2 * k + 1) * Ο) := by
rw [β sub_zero (ΞΈ : Angle), β zsmul_zero k, β coe_two_pi, β coe_zsmul, β coe_sub, zsmul_eq_mul, β
mul_assoc, mul_comm (k : β), toReal_coe_eq_self_iff, Set.mem_Ioc]
exact β¨fun h => β¨by linarith, by linarithβ©, fun h => β¨by linarith, by linarithβ©β©
theorem toReal_coe_eq_self_sub_two_pi_iff {ΞΈ : β} :
(ΞΈ : Angle).toReal = ΞΈ - 2 * Ο β ΞΈ β Set.Ioc Ο (3 * Ο) := by
convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff ΞΈ 1 <;> norm_num
theorem toReal_coe_eq_self_add_two_pi_iff {ΞΈ : β} :
(ΞΈ : Angle).toReal = ΞΈ + 2 * Ο β ΞΈ β Set.Ioc (-3 * Ο) (-Ο) := by
convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff ΞΈ (-1) using 2 <;> norm_num
theorem two_nsmul_toReal_eq_two_mul_sub_two_pi {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).toReal = 2 * ΞΈ.toReal - 2 * Ο β Ο / 2 < ΞΈ.toReal := by
nth_rw 1 [β coe_toReal ΞΈ]
rw [β coe_nsmul, two_nsmul, β two_mul, toReal_coe_eq_self_sub_two_pi_iff, Set.mem_Ioc]
exact
β¨fun h => by linarith, fun h =>
β¨(div_lt_iffβ' (zero_lt_two' β)).1 h, by linarith [pi_pos, toReal_le_pi ΞΈ]β©β©
theorem two_zsmul_toReal_eq_two_mul_sub_two_pi {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).toReal = 2 * ΞΈ.toReal - 2 * Ο β Ο / 2 < ΞΈ.toReal := by
rw [two_zsmul, β two_nsmul, two_nsmul_toReal_eq_two_mul_sub_two_pi]
theorem two_nsmul_toReal_eq_two_mul_add_two_pi {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).toReal = 2 * ΞΈ.toReal + 2 * Ο β ΞΈ.toReal β€ -Ο / 2 := by
nth_rw 1 [β coe_toReal ΞΈ]
rw [β coe_nsmul, two_nsmul, β two_mul, toReal_coe_eq_self_add_two_pi_iff, Set.mem_Ioc]
refine
β¨fun h => by linarith, fun h =>
β¨by linarith [pi_pos, neg_pi_lt_toReal ΞΈ], (le_div_iffβ' (zero_lt_two' β)).1 hβ©β©
theorem two_zsmul_toReal_eq_two_mul_add_two_pi {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).toReal = 2 * ΞΈ.toReal + 2 * Ο β ΞΈ.toReal β€ -Ο / 2 := by
rw [two_zsmul, β two_nsmul, two_nsmul_toReal_eq_two_mul_add_two_pi]
lemma two_nsmul_eq_iff_eq_of_abs_toReal_lt_pi_div_two {ΞΈ Ο : Angle} (hΞΈ : |ΞΈ.toReal| < Ο / 2)
(hΟ : |Ο.toReal| < Ο / 2) : (2 : β) β’ ΞΈ = (2 : β) β’ Ο β ΞΈ = Ο := by
constructor
Β· intro h
rw [two_nsmul_eq_iff] at h
rcases h with rfl | rfl
Β· rfl
Β· rw [abs_lt] at hΟ hΞΈ
rw [β coe_toReal Ο, β coe_add] at hΞΈ
by_cases hΟ' : Ο.toReal β€ 0
Β· have hΟt : -Ο < Ο.toReal + Ο β§ Ο.toReal + Ο β€ Ο := β¨by linarith, by linarithβ©
rw [toReal_coe_eq_self_iff.2 hΟt] at hΞΈ
linarith
Β· have hΟt : Ο < Ο.toReal + Ο β§ Ο.toReal + Ο β€ 3 * Ο := β¨by linarith, by linarithβ©
rw [toReal_coe_eq_self_sub_two_pi_iff.2 hΟt] at hΞΈ
linarith
Β· rintro rfl
rfl
lemma two_zsmul_eq_iff_eq_of_abs_toReal_lt_pi_div_two {ΞΈ Ο : Angle} (hΞΈ : |ΞΈ.toReal| < Ο / 2)
(hΟ : |Ο.toReal| < Ο / 2) : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο β ΞΈ = Ο := by
simp_rw [two_zsmul, β two_nsmul, two_nsmul_eq_iff_eq_of_abs_toReal_lt_pi_div_two hΞΈ hΟ]
@[simp]
theorem sin_toReal (ΞΈ : Angle) : Real.sin ΞΈ.toReal = sin ΞΈ := by
conv_rhs => rw [β coe_toReal ΞΈ, sin_coe]
@[simp]
theorem cos_toReal (ΞΈ : Angle) : Real.cos ΞΈ.toReal = cos ΞΈ := by
conv_rhs => rw [β coe_toReal ΞΈ, cos_coe]
theorem cos_nonneg_iff_abs_toReal_le_pi_div_two {ΞΈ : Angle} : 0 β€ cos ΞΈ β |ΞΈ.toReal| β€ Ο / 2 := by
nth_rw 1 [β coe_toReal ΞΈ]
rw [abs_le, cos_coe]
refine β¨fun h => ?_, cos_nonneg_of_mem_Iccβ©
by_contra hn
rw [not_and_or, not_le, not_le] at hn
refine (not_lt.2 h) ?_
rcases hn with (hn | hn)
Β· rw [β Real.cos_neg]
refine cos_neg_of_pi_div_two_lt_of_lt (by linarith) ?_
linarith [neg_pi_lt_toReal ΞΈ]
Β· refine cos_neg_of_pi_div_two_lt_of_lt hn ?_
linarith [toReal_le_pi ΞΈ]
theorem cos_pos_iff_abs_toReal_lt_pi_div_two {ΞΈ : Angle} : 0 < cos ΞΈ β |ΞΈ.toReal| < Ο / 2 := by
rw [lt_iff_le_and_ne, lt_iff_le_and_ne, cos_nonneg_iff_abs_toReal_le_pi_div_two, β
and_congr_right]
rintro -
rw [Ne, Ne, not_iff_not, @eq_comm β 0, abs_toReal_eq_pi_div_two_iff, cos_eq_zero_iff]
theorem cos_neg_iff_pi_div_two_lt_abs_toReal {ΞΈ : Angle} : cos ΞΈ < 0 β Ο / 2 < |ΞΈ.toReal| := by
rw [β not_le, β not_le, not_iff_not, cos_nonneg_iff_abs_toReal_le_pi_div_two]
theorem abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β) β’ ΞΈ + (2 : β) β’ Ο = Ο) : |cos ΞΈ| = |sin Ο| := by
rw [β eq_sub_iff_add_eq, β two_nsmul_coe_div_two, β nsmul_sub, two_nsmul_eq_iff] at h
rcases h with (rfl | rfl) <;> simp [cos_pi_div_two_sub]
theorem abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β€) β’ ΞΈ + (2 : β€) β’ Ο = Ο) : |cos ΞΈ| = |sin Ο| := by
simp_rw [two_zsmul, β two_nsmul] at h
exact abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi h
/-- The tangent of a `Real.Angle`. -/
def tan (ΞΈ : Angle) : β :=
sin ΞΈ / cos ΞΈ
theorem tan_eq_sin_div_cos (ΞΈ : Angle) : tan ΞΈ = sin ΞΈ / cos ΞΈ :=
rfl
@[simp]
theorem tan_coe (x : β) : tan (x : Angle) = Real.tan x := by
rw [tan, sin_coe, cos_coe, Real.tan_eq_sin_div_cos]
@[simp]
theorem tan_zero : tan (0 : Angle) = 0 := by rw [β coe_zero, tan_coe, Real.tan_zero]
theorem tan_coe_pi : tan (Ο : Angle) = 0 := by rw [tan_coe, Real.tan_pi]
theorem tan_periodic : Function.Periodic tan (Ο : Angle) := by
intro ΞΈ
induction ΞΈ using Real.Angle.induction_on
rw [β coe_add, tan_coe, tan_coe]
exact Real.tan_periodic _
@[simp]
theorem tan_add_pi (ΞΈ : Angle) : tan (ΞΈ + Ο) = tan ΞΈ :=
tan_periodic ΞΈ
@[simp]
theorem tan_sub_pi (ΞΈ : Angle) : tan (ΞΈ - Ο) = tan ΞΈ :=
tan_periodic.sub_eq ΞΈ
@[simp]
theorem tan_toReal (ΞΈ : Angle) : Real.tan ΞΈ.toReal = tan ΞΈ := by
conv_rhs => rw [β coe_toReal ΞΈ, tan_coe]
theorem tan_eq_of_two_nsmul_eq {ΞΈ Ο : Angle} (h : (2 : β) β’ ΞΈ = (2 : β) β’ Ο) : tan ΞΈ = tan Ο := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
Β· rfl
Β· exact tan_add_pi _
theorem tan_eq_of_two_zsmul_eq {ΞΈ Ο : Angle} (h : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο) : tan ΞΈ = tan Ο := by
simp_rw [two_zsmul, β two_nsmul] at h
exact tan_eq_of_two_nsmul_eq h
theorem tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β) β’ ΞΈ + (2 : β) β’ Ο = Ο) : tan Ο = (tan ΞΈ)β»ΒΉ := by
induction ΞΈ using Real.Angle.induction_on
induction Ο using Real.Angle.induction_on
rw [β smul_add, β coe_add, β coe_nsmul, two_nsmul, β two_mul, angle_eq_iff_two_pi_dvd_sub] at h
rcases h with β¨k, hβ©
rw [sub_eq_iff_eq_add, β mul_inv_cancel_leftβ two_ne_zero Ο, mul_assoc, β mul_add,
mul_right_inj' (two_ne_zero' β), β eq_sub_iff_add_eq', mul_inv_cancel_leftβ two_ne_zero Ο,
inv_mul_eq_div, mul_comm] at h
rw [tan_coe, tan_coe, β tan_pi_div_two_sub, h, add_sub_assoc, add_comm]
exact Real.tan_periodic.int_mul _ _
theorem tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β€) β’ ΞΈ + (2 : β€) β’ Ο = Ο) : tan Ο = (tan ΞΈ)β»ΒΉ := by
simp_rw [two_zsmul, β two_nsmul] at h
exact tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi h
/-- The sign of a `Real.Angle` is `0` if the angle is `0` or `Ο`, `1` if the angle is strictly
between `0` and `Ο` and `-1` is the angle is strictly between `-Ο` and `0`. It is defined as the
sign of the sine of the angle. -/
def sign (ΞΈ : Angle) : SignType :=
SignType.sign (sin ΞΈ)
@[simp]
theorem sign_zero : (0 : Angle).sign = 0 := by
rw [sign, sin_zero, _root_.sign_zero]
@[simp]
theorem sign_coe_pi : (Ο : Angle).sign = 0 := by rw [sign, sin_coe_pi, _root_.sign_zero]
@[simp]
theorem sign_neg (ΞΈ : Angle) : (-ΞΈ).sign = -ΞΈ.sign := by
simp_rw [sign, sin_neg, Left.sign_neg]
theorem sign_antiperiodic : Function.Antiperiodic sign (Ο : Angle) := fun ΞΈ => by
rw [sign, sign, sin_add_pi, Left.sign_neg]
@[simp]
theorem sign_add_pi (ΞΈ : Angle) : (ΞΈ + Ο).sign = -ΞΈ.sign :=
sign_antiperiodic ΞΈ
@[simp]
theorem sign_pi_add (ΞΈ : Angle) : ((Ο : Angle) + ΞΈ).sign = -ΞΈ.sign := by rw [add_comm, sign_add_pi]
@[simp]
theorem sign_sub_pi (ΞΈ : Angle) : (ΞΈ - Ο).sign = -ΞΈ.sign :=
sign_antiperiodic.sub_eq ΞΈ
@[simp]
theorem sign_pi_sub (ΞΈ : Angle) : ((Ο : Angle) - ΞΈ).sign = ΞΈ.sign := by
simp [sign_antiperiodic.sub_eq']
theorem sign_eq_zero_iff {ΞΈ : Angle} : ΞΈ.sign = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
rw [sign, _root_.sign_eq_zero_iff, sin_eq_zero_iff]
theorem sign_ne_zero_iff {ΞΈ : Angle} : ΞΈ.sign β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β sign_eq_zero_iff]
theorem toReal_neg_iff_sign_neg {ΞΈ : Angle} : ΞΈ.toReal < 0 β ΞΈ.sign = -1 := by
rw [sign, β sin_toReal, sign_eq_neg_one_iff]
rcases lt_trichotomy ΞΈ.toReal 0 with (h | h | h)
Β· exact β¨fun _ => Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_toReal ΞΈ), fun _ => hβ©
Β· simp [h]
Β· exact
β¨fun hn => False.elim (h.asymm hn), fun hn =>
False.elim (hn.not_ge (sin_nonneg_of_nonneg_of_le_pi h.le (toReal_le_pi ΞΈ)))β©
theorem toReal_nonneg_iff_sign_nonneg {ΞΈ : Angle} : 0 β€ ΞΈ.toReal β 0 β€ ΞΈ.sign := by
rcases lt_trichotomy ΞΈ.toReal 0 with (h | h | h)
Β· refine β¨fun hn => False.elim (h.not_ge hn), fun hn => ?_β©
rw [toReal_neg_iff_sign_neg.1 h] at hn
exact False.elim (hn.not_gt (by decide))
Β· simp [h, sign, β sin_toReal]
Β· refine β¨fun _ => ?_, fun _ => h.leβ©
rw [sign, β sin_toReal, sign_nonneg_iff]
exact sin_nonneg_of_nonneg_of_le_pi h.le (toReal_le_pi ΞΈ)
@[simp]
theorem sign_toReal {ΞΈ : Angle} (h : ΞΈ β Ο) : SignType.sign ΞΈ.toReal = ΞΈ.sign := by
rcases lt_trichotomy ΞΈ.toReal 0 with (ht | ht | ht)
Β· simp [ht, toReal_neg_iff_sign_neg.1 ht]
Β· simp [sign, ht, β sin_toReal]
Β· rw [sign, β sin_toReal, sign_pos ht,
sign_pos
(sin_pos_of_pos_of_lt_pi ht ((toReal_le_pi ΞΈ).lt_of_ne (toReal_eq_pi_iff.not.2 h)))]
theorem coe_abs_toReal_of_sign_nonneg {ΞΈ : Angle} (h : 0 β€ ΞΈ.sign) : β|ΞΈ.toReal| = ΞΈ := by
rw [abs_eq_self.2 (toReal_nonneg_iff_sign_nonneg.2 h), coe_toReal]
theorem neg_coe_abs_toReal_of_sign_nonpos {ΞΈ : Angle} (h : ΞΈ.sign β€ 0) : -β|ΞΈ.toReal| = ΞΈ := by
rw [SignType.nonpos_iff] at h
rcases h with (h | h)
Β· rw [abs_of_neg (toReal_neg_iff_sign_neg.2 h), coe_neg, neg_neg, coe_toReal]
Β· rw [sign_eq_zero_iff] at h
rcases h with (rfl | rfl) <;> simp [abs_of_pos Real.pi_pos]
theorem eq_iff_sign_eq_and_abs_toReal_eq {ΞΈ Ο : Angle} :
ΞΈ = Ο β ΞΈ.sign = Ο.sign β§ |ΞΈ.toReal| = |Ο.toReal| := by
refine β¨?_, fun h => ?_β©
Β· rintro rfl
exact β¨rfl, rflβ©
rcases h with β¨hs, hrβ©
rw [abs_eq_abs] at hr
rcases hr with (hr | hr)
Β· exact toReal_injective hr
Β· by_cases h : ΞΈ = Ο
Β· rw [h, toReal_pi, β neg_eq_iff_eq_neg] at hr
exact False.elim ((neg_pi_lt_toReal Ο).ne hr)
Β· by_cases h' : Ο = Ο
Β· rw [h', toReal_pi] at hr
exact False.elim ((neg_pi_lt_toReal ΞΈ).ne hr.symm)
Β· rw [β sign_toReal h, β sign_toReal h', hr, Left.sign_neg, SignType.neg_eq_self_iff,
_root_.sign_eq_zero_iff, toReal_eq_zero_iff] at hs
rw [hs, toReal_zero, neg_zero, toReal_eq_zero_iff] at hr
rw [hr, hs]
theorem eq_iff_abs_toReal_eq_of_sign_eq {ΞΈ Ο : Angle} (h : ΞΈ.sign = Ο.sign) :
ΞΈ = Ο β |ΞΈ.toReal| = |Ο.toReal| := by simpa [h] using @eq_iff_sign_eq_and_abs_toReal_eq ΞΈ Ο
@[simp]
theorem sign_coe_pi_div_two : (β(Ο / 2) : Angle).sign = 1 := by
rw [sign, sin_coe, sin_pi_div_two, sign_one]
@[simp]
theorem sign_coe_neg_pi_div_two : (β(-Ο / 2) : Angle).sign = -1 := by
rw [sign, sin_coe, neg_div, Real.sin_neg, sin_pi_div_two, Left.sign_neg, sign_one]
theorem sign_coe_nonneg_of_nonneg_of_le_pi {ΞΈ : β} (h0 : 0 β€ ΞΈ) (hpi : ΞΈ β€ Ο) :
0 β€ (ΞΈ : Angle).sign := by
rw [sign, sign_nonneg_iff]
exact sin_nonneg_of_nonneg_of_le_pi h0 hpi
theorem sign_neg_coe_nonpos_of_nonneg_of_le_pi {ΞΈ : β} (h0 : 0 β€ ΞΈ) (hpi : ΞΈ β€ Ο) :
(-ΞΈ : Angle).sign β€ 0 := by
rw [sign, sign_nonpos_iff, sin_neg, Left.neg_nonpos_iff]
exact sin_nonneg_of_nonneg_of_le_pi h0 hpi
theorem sign_two_nsmul_eq_sign_iff {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).sign = ΞΈ.sign β ΞΈ = Ο β¨ |ΞΈ.toReal| < Ο / 2 := by
by_cases hpi : ΞΈ = Ο; Β· simp [hpi]
rw [or_iff_right hpi]
refine β¨fun h => ?_, fun h => ?_β©
Β· by_contra hle
rw [not_lt, le_abs, le_neg] at hle
have hpi' : ΞΈ.toReal β Ο := by simpa using hpi
rcases hle with (hle | hle) <;> rcases hle.eq_or_lt with (heq | hlt)
Β· rw [β coe_toReal ΞΈ, β heq] at h
simp at h
Β· rw [β sign_toReal hpi, sign_pos (pi_div_two_pos.trans hlt), β sign_toReal,
two_nsmul_toReal_eq_two_mul_sub_two_pi.2 hlt, _root_.sign_neg] at h
Β· simp at h
Β· rw [β mul_sub]
exact mul_neg_of_pos_of_neg two_pos (sub_neg.2 ((toReal_le_pi _).lt_of_ne hpi'))
Β· intro he
simp [he] at h
Β· rw [β coe_toReal ΞΈ, heq] at h
simp at h
Β· rw [β sign_toReal hpi, _root_.sign_neg (hlt.trans (Left.neg_neg_iff.2 pi_div_two_pos)), β
sign_toReal] at h
swap
Β· intro he
simp [he] at h
rw [β neg_div] at hlt
rw [two_nsmul_toReal_eq_two_mul_add_two_pi.2 hlt.le, sign_pos] at h
Β· simp at h
Β· linarith [neg_pi_lt_toReal ΞΈ]
Β· have hpi' : (2 : β) β’ ΞΈ β Ο := by
rw [Ne, two_nsmul_eq_pi_iff, not_or]
constructor
Β· rintro rfl
simp [pi_pos, abs_of_pos] at h
Β· rintro rfl
rw [toReal_neg_pi_div_two] at h
simp [pi_pos, neg_div, abs_of_pos] at h
rw [abs_lt, β neg_div] at h
rw [β sign_toReal hpi, β sign_toReal hpi', two_nsmul_toReal_eq_two_mul.2 β¨h.1, h.2.leβ©,
sign_mul, sign_pos (zero_lt_two' β), one_mul]
theorem sign_two_zsmul_eq_sign_iff {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).sign = ΞΈ.sign β ΞΈ = Ο β¨ |ΞΈ.toReal| < Ο / 2 := by
rw [two_zsmul, β two_nsmul, sign_two_nsmul_eq_sign_iff]
lemma abs_toReal_add_abs_toReal_eq_pi_of_two_nsmul_add_eq_zero_of_sign_eq {ΞΈ Ο : Angle}
(h : (2 : β) β’ (ΞΈ + Ο) = 0) (hs : ΞΈ.sign = Ο.sign) (h0 : ΞΈ.sign β 0) :
|ΞΈ.toReal| + |Ο.toReal| = Ο := by
rcases two_nsmul_eq_zero_iff.mp h with h | h
Β· simp_all [add_eq_zero_iff_eq_neg.mp h]
rw [β coe_toReal ΞΈ, β coe_toReal Ο, β coe_add] at h
suffices |ΞΈ.toReal + Ο.toReal| = Ο by
rw [β this, eq_comm, abs_add_eq_add_abs_iff]
have hΞΈ := sign_toReal (sign_ne_zero_iff.1 h0).2
have hΟ := sign_toReal (sign_ne_zero_iff.1 (hs βΈ h0)).2
obtain hΞΈs | hΞΈs : ΞΈ.sign = -1 β¨ ΞΈ.sign = 1 := by simpa [h0] using ΞΈ.sign.trichotomy
Β· rw [hΞΈs, eq_comm, β toReal_neg_iff_sign_neg] at hs
exact .inr β¨(toReal_neg_iff_sign_neg.mpr hΞΈs).le, hs.leβ©
Β· simp [toReal_nonneg_iff_sign_nonneg, hs.symm, hΞΈs]
rw [abs_eq pi_nonneg]
rcases angle_eq_iff_two_pi_dvd_sub.mp h with β¨k, hkβ©
rw [sub_eq_iff_eq_add] at hk
have hu : ΞΈ.toReal + Ο.toReal β€ 2 * Ο := by linarith [toReal_le_pi ΞΈ, toReal_le_pi Ο]
have hn : -2 * Ο < ΞΈ.toReal + Ο.toReal := by linarith [neg_pi_lt_toReal ΞΈ, neg_pi_lt_toReal Ο]
rw [hk] at hu hn
have hk0 : k β€ 0 := by
by_contra hk1
grw [β show 1 β€ k by cutsat] at hu
simp only [Int.cast_one] at hu
linarith [pi_pos]
have hkn1 : -1 β€ k := by
by_contra hkn2
grw [show k β€ -2 by cutsat] at hn
simp only [Int.cast_neg, Int.cast_ofNat] at hn
linarith [pi_pos]
obtain rfl | rfl : k = -1 β¨ k = 0 := (by cutsat) <;> grind
lemma abs_toReal_add_abs_toReal_eq_pi_of_two_zsmul_add_eq_zero_of_sign_eq {ΞΈ Ο : Angle}
(h : (2 : β€) β’ (ΞΈ + Ο) = 0) (hs : ΞΈ.sign = Ο.sign) (h0 : ΞΈ.sign β 0) :
|ΞΈ.toReal| + |Ο.toReal| = Ο := by
rw [two_zsmul, β two_nsmul] at h
exact abs_toReal_add_abs_toReal_eq_pi_of_two_nsmul_add_eq_zero_of_sign_eq h hs h0
theorem continuousAt_sign {ΞΈ : Angle} (h0 : ΞΈ β 0) (hpi : ΞΈ β Ο) : ContinuousAt sign ΞΈ :=
(continuousAt_sign_of_ne_zero (sin_ne_zero_iff.2 β¨h0, hpiβ©)).comp continuous_sin.continuousAt
theorem _root_.ContinuousOn.angle_sign_comp {Ξ± : Type*} [TopologicalSpace Ξ±] {f : Ξ± β Angle}
{s : Set Ξ±} (hf : ContinuousOn f s) (hs : β z β s, f z β 0 β§ f z β Ο) :
ContinuousOn (sign β f) s := by
refine (continuousOn_of_forall_continuousAt fun ΞΈ hΞΈ => ?_).comp hf (Set.mapsTo_image f s)
obtain β¨z, hz, rflβ© := hΞΈ
exact continuousAt_sign (hs _ hz).1 (hs _ hz).2
/-- Suppose a function to angles is continuous on a connected set and never takes the values `0`
or `Ο` on that set. Then the values of the function on that set all have the same sign. -/
theorem sign_eq_of_continuousOn {Ξ± : Type*} [TopologicalSpace Ξ±] {f : Ξ± β Angle} {s : Set Ξ±}
{x y : Ξ±} (hc : IsConnected s) (hf : ContinuousOn f s) (hs : β z β s, f z β 0 β§ f z β Ο)
(hx : x β s) (hy : y β s) : (f y).sign = (f x).sign :=
(hc.image _ (hf.angle_sign_comp hs)).isPreconnected.subsingleton (Set.mem_image_of_mem _ hy)
(Set.mem_image_of_mem _ hx)
end Angle
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean | import Mathlib.Order.Monotone.Odd
import Mathlib.Analysis.Calculus.LogDeriv
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.Calculus.Deriv.MeanValue
/-!
# Differentiability of trigonometric functions
## Main statements
The differentiability of the usual trigonometric functions is proved, and their derivatives are
computed.
## Tags
sin, cos, tan, angle
-/
noncomputable section
open scoped Asymptotics Topology Filter
open Set
namespace Complex
/-- The complex sine function is everywhere strictly differentiable, with the derivative `cos x`. -/
theorem hasStrictDerivAt_sin (x : β) : HasStrictDerivAt sin (cos x) x := by
simp only [cos, div_eq_mul_inv]
convert ((((hasStrictDerivAt_id x).fun_neg.mul_const I).cexp.sub
((hasStrictDerivAt_id x).mul_const I).cexp).mul_const I).mul_const (2 : β)β»ΒΉ using 1
simp only [id]
rw [sub_mul, mul_assoc, mul_assoc, I_mul_I, neg_one_mul, neg_neg, mul_one, one_mul, mul_assoc,
I_mul_I, mul_neg_one, sub_neg_eq_add, add_comm]
/-- The complex sine function is everywhere differentiable, with the derivative `cos x`. -/
theorem hasDerivAt_sin (x : β) : HasDerivAt sin (cos x) x :=
(hasStrictDerivAt_sin x).hasDerivAt
theorem isEquivalent_sin : sin ~[π 0] id := by simpa using (hasDerivAt_sin 0).isLittleO
@[fun_prop]
theorem contDiff_sin {n} : ContDiff β n sin :=
(((contDiff_neg.mul contDiff_const).cexp.sub (contDiff_id.mul contDiff_const).cexp).mul
contDiff_const).div_const _
@[simp]
theorem differentiable_sin : Differentiable β sin := fun x => (hasDerivAt_sin x).differentiableAt
@[simp]
theorem differentiableAt_sin {x : β} : DifferentiableAt β sin x :=
differentiable_sin x
/-- The function `Complex.sin` is complex analytic. -/
@[fun_prop]
lemma analyticAt_sin {x : β} : AnalyticAt β sin x :=
contDiff_sin.contDiffAt.analyticAt
/-- The function `Complex.sin` is complex analytic. -/
lemma analyticWithinAt_sin {x : β} {s : Set β} : AnalyticWithinAt β sin s x :=
contDiff_sin.contDiffWithinAt.analyticWithinAt
/-- The function `Complex.sin` is complex analytic. -/
theorem analyticOnNhd_sin {s : Set β} : AnalyticOnNhd β sin s :=
fun _ _ β¦ analyticAt_sin
/-- The function `Complex.sin` is complex analytic. -/
lemma analyticOn_sin {s : Set β} : AnalyticOn β sin s :=
contDiff_sin.contDiffOn.analyticOn
@[simp]
theorem deriv_sin : deriv sin = cos :=
funext fun x => (hasDerivAt_sin x).deriv
/-- The complex cosine function is everywhere strictly differentiable, with the derivative
`-sin x`. -/
theorem hasStrictDerivAt_cos (x : β) : HasStrictDerivAt cos (-sin x) x := by
simp only [sin, div_eq_mul_inv, neg_mul_eq_neg_mul]
convert (((hasStrictDerivAt_id x).mul_const I).cexp.add
((hasStrictDerivAt_id x).fun_neg.mul_const I).cexp).mul_const (2 : β)β»ΒΉ using 1
simp only [id]
ring
/-- The complex cosine function is everywhere differentiable, with the derivative `-sin x`. -/
theorem hasDerivAt_cos (x : β) : HasDerivAt cos (-sin x) x :=
(hasStrictDerivAt_cos x).hasDerivAt
@[fun_prop]
theorem contDiff_cos {n} : ContDiff β n cos :=
((contDiff_id.mul contDiff_const).cexp.add (contDiff_neg.mul contDiff_const).cexp).div_const _
@[simp]
theorem differentiable_cos : Differentiable β cos := fun x => (hasDerivAt_cos x).differentiableAt
@[simp]
theorem differentiableAt_cos {x : β} : DifferentiableAt β cos x :=
differentiable_cos x
/-- The function `Complex.cos` is complex analytic. -/
@[fun_prop]
lemma analyticAt_cos {x : β} : AnalyticAt β cos x :=
contDiff_cos.contDiffAt.analyticAt
/-- The function `Complex.cos` is complex analytic. -/
lemma analyticWithinAt_cos {x : β} {s : Set β} : AnalyticWithinAt β cos s x :=
contDiff_cos.contDiffWithinAt.analyticWithinAt
/-- The function `Complex.cos` is complex analytic. -/
theorem analyticOnNhd_cos {s : Set β} : AnalyticOnNhd β cos s :=
fun _ _ β¦ analyticAt_cos
/-- The function `Complex.cos` is complex analytic. -/
lemma analyticOn_cos {s : Set β} : AnalyticOn β cos s :=
contDiff_cos.contDiffOn.analyticOn
theorem deriv_cos {x : β} : deriv cos x = -sin x :=
(hasDerivAt_cos x).deriv
@[simp]
theorem deriv_cos' : deriv cos = fun x => -sin x :=
funext fun _ => deriv_cos
/-- The complex hyperbolic sine function is everywhere strictly differentiable, with the derivative
`cosh x`. -/
theorem hasStrictDerivAt_sinh (x : β) : HasStrictDerivAt sinh (cosh x) x := by
simp only [cosh, div_eq_mul_inv]
convert ((hasStrictDerivAt_exp x).sub (hasStrictDerivAt_id x).fun_neg.cexp).mul_const (2 : β)β»ΒΉ
using 1
rw [id, mul_neg_one, sub_eq_add_neg, neg_neg]
/-- The complex hyperbolic sine function is everywhere differentiable, with the derivative
`cosh x`. -/
theorem hasDerivAt_sinh (x : β) : HasDerivAt sinh (cosh x) x :=
(hasStrictDerivAt_sinh x).hasDerivAt
theorem isEquivalent_sinh : sinh ~[π 0] id := by simpa using (hasDerivAt_sinh 0).isLittleO
@[fun_prop]
theorem contDiff_sinh {n} : ContDiff β n sinh :=
(contDiff_exp.sub contDiff_neg.cexp).div_const _
@[simp]
theorem differentiable_sinh : Differentiable β sinh := fun x => (hasDerivAt_sinh x).differentiableAt
@[simp]
theorem differentiableAt_sinh {x : β} : DifferentiableAt β sinh x :=
differentiable_sinh x
/-- The function `Complex.sinh` is complex analytic. -/
@[fun_prop]
lemma analyticAt_sinh {x : β} : AnalyticAt β sinh x :=
contDiff_sinh.contDiffAt.analyticAt
/-- The function `Complex.sinh` is complex analytic. -/
lemma analyticWithinAt_sinh {x : β} {s : Set β} : AnalyticWithinAt β sinh s x :=
contDiff_sinh.contDiffWithinAt.analyticWithinAt
/-- The function `Complex.sinh` is complex analytic. -/
theorem analyticOnNhd_sinh {s : Set β} : AnalyticOnNhd β sinh s :=
fun _ _ β¦ analyticAt_sinh
/-- The function `Complex.sinh` is complex analytic. -/
lemma analyticOn_sinh {s : Set β} : AnalyticOn β sinh s :=
contDiff_sinh.contDiffOn.analyticOn
@[simp]
theorem deriv_sinh : deriv sinh = cosh :=
funext fun x => (hasDerivAt_sinh x).deriv
/-- The complex hyperbolic cosine function is everywhere strictly differentiable, with the
derivative `sinh x`. -/
theorem hasStrictDerivAt_cosh (x : β) : HasStrictDerivAt cosh (sinh x) x := by
simp only [sinh, div_eq_mul_inv]
convert ((hasStrictDerivAt_exp x).add (hasStrictDerivAt_id x).fun_neg.cexp).mul_const (2 : β)β»ΒΉ
using 1
rw [id, mul_neg_one, sub_eq_add_neg]
/-- The complex hyperbolic cosine function is everywhere differentiable, with the derivative
`sinh x`. -/
theorem hasDerivAt_cosh (x : β) : HasDerivAt cosh (sinh x) x :=
(hasStrictDerivAt_cosh x).hasDerivAt
@[fun_prop]
theorem contDiff_cosh {n} : ContDiff β n cosh :=
(contDiff_exp.add contDiff_neg.cexp).div_const _
@[simp]
theorem differentiable_cosh : Differentiable β cosh := fun x => (hasDerivAt_cosh x).differentiableAt
@[simp]
theorem differentiableAt_cosh {x : β} : DifferentiableAt β cosh x :=
differentiable_cosh x
/-- The function `Complex.cosh` is complex analytic. -/
@[fun_prop]
lemma analyticAt_cosh {x : β} : AnalyticAt β cosh x :=
contDiff_cosh.contDiffAt.analyticAt
/-- The function `Complex.cosh` is complex analytic. -/
lemma analyticWithinAt_cosh {x : β} {s : Set β} : AnalyticWithinAt β cosh s x :=
contDiff_cosh.contDiffWithinAt.analyticWithinAt
/-- The function `Complex.cosh` is complex analytic. -/
theorem analyticOnNhd_cosh {s : Set β} : AnalyticOnNhd β cosh s :=
fun _ _ β¦ analyticAt_cosh
/-- The function `Complex.cosh` is complex analytic. -/
lemma analyticOn_cosh {s : Set β} : AnalyticOn β cosh s :=
contDiff_cosh.contDiffOn.analyticOn
@[simp]
theorem deriv_cosh : deriv cosh = sinh :=
funext fun x => (hasDerivAt_cosh x).deriv
end Complex
section
/-! ### Simp lemmas for derivatives of `fun x => Complex.cos (f x)` etc., `f : β β β` -/
variable {f : β β β} {f' x : β} {s : Set β}
/-! #### `Complex.cos` -/
theorem HasStrictDerivAt.ccos (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') x :=
(Complex.hasStrictDerivAt_cos (f x)).comp x hf
theorem HasDerivAt.ccos (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') x :=
(Complex.hasDerivAt_cos (f x)).comp x hf
theorem HasDerivWithinAt.ccos (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') s x :=
(Complex.hasDerivAt_cos (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_ccos (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Complex.cos (f x)) s x = -Complex.sin (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.ccos.derivWithin hxs
@[simp]
theorem deriv_ccos (hc : DifferentiableAt β f x) :
deriv (fun x => Complex.cos (f x)) x = -Complex.sin (f x) * deriv f x :=
hc.hasDerivAt.ccos.deriv
/-! #### `Complex.sin` -/
theorem HasStrictDerivAt.csin (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') x :=
(Complex.hasStrictDerivAt_sin (f x)).comp x hf
theorem HasDerivAt.csin (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') x :=
(Complex.hasDerivAt_sin (f x)).comp x hf
theorem HasDerivWithinAt.csin (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') s x :=
(Complex.hasDerivAt_sin (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_csin (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Complex.sin (f x)) s x = Complex.cos (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.csin.derivWithin hxs
@[simp]
theorem deriv_csin (hc : DifferentiableAt β f x) :
deriv (fun x => Complex.sin (f x)) x = Complex.cos (f x) * deriv f x :=
hc.hasDerivAt.csin.deriv
/-! #### `Complex.cosh` -/
theorem HasStrictDerivAt.ccosh (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') x :=
(Complex.hasStrictDerivAt_cosh (f x)).comp x hf
theorem HasDerivAt.ccosh (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') x :=
(Complex.hasDerivAt_cosh (f x)).comp x hf
theorem HasDerivWithinAt.ccosh (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') s x :=
(Complex.hasDerivAt_cosh (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_ccosh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Complex.cosh (f x)) s x = Complex.sinh (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.ccosh.derivWithin hxs
@[simp]
theorem deriv_ccosh (hc : DifferentiableAt β f x) :
deriv (fun x => Complex.cosh (f x)) x = Complex.sinh (f x) * deriv f x :=
hc.hasDerivAt.ccosh.deriv
/-! #### `Complex.sinh` -/
theorem HasStrictDerivAt.csinh (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') x :=
(Complex.hasStrictDerivAt_sinh (f x)).comp x hf
theorem HasDerivAt.csinh (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') x :=
(Complex.hasDerivAt_sinh (f x)).comp x hf
theorem HasDerivWithinAt.csinh (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') s x :=
(Complex.hasDerivAt_sinh (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_csinh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Complex.sinh (f x)) s x = Complex.cosh (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.csinh.derivWithin hxs
@[simp]
theorem deriv_csinh (hc : DifferentiableAt β f x) :
deriv (fun x => Complex.sinh (f x)) x = Complex.cosh (f x) * deriv f x :=
hc.hasDerivAt.csinh.deriv
end
section
/-! ### Simp lemmas for derivatives of `fun x => Complex.cos (f x)` etc., `f : E β β` -/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] {f : E β β} {f' : StrongDual β E}
{x : E} {s : Set E}
/-! #### `Complex.cos` -/
theorem HasStrictFDerivAt.ccos (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) β’ f') x :=
(Complex.hasStrictDerivAt_cos (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.ccos (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) β’ f') x :=
(Complex.hasDerivAt_cos (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.ccos (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) β’ f') s x :=
(Complex.hasDerivAt_cos (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.ccos (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Complex.cos (f x)) s x :=
hf.hasFDerivWithinAt.ccos.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.ccos (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Complex.cos (f x)) x :=
hc.hasFDerivAt.ccos.differentiableAt
theorem DifferentiableOn.ccos (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Complex.cos (f x)) s := fun x h => (hc x h).ccos
@[simp, fun_prop]
theorem Differentiable.ccos (hc : Differentiable β f) :
Differentiable β fun x => Complex.cos (f x) := fun x => (hc x).ccos
theorem fderivWithin_ccos (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Complex.cos (f x)) s x = -Complex.sin (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.ccos.fderivWithin hxs
@[simp]
theorem fderiv_ccos (hc : DifferentiableAt β f x) :
fderiv β (fun x => Complex.cos (f x)) x = -Complex.sin (f x) β’ fderiv β f x :=
hc.hasFDerivAt.ccos.fderiv
theorem ContDiff.ccos {n} (h : ContDiff β n f) : ContDiff β n fun x => Complex.cos (f x) :=
Complex.contDiff_cos.comp h
theorem ContDiffAt.ccos {n} (hf : ContDiffAt β n f x) :
ContDiffAt β n (fun x => Complex.cos (f x)) x :=
Complex.contDiff_cos.contDiffAt.comp x hf
theorem ContDiffOn.ccos {n} (hf : ContDiffOn β n f s) :
ContDiffOn β n (fun x => Complex.cos (f x)) s :=
Complex.contDiff_cos.comp_contDiffOn hf
theorem ContDiffWithinAt.ccos {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Complex.cos (f x)) s x :=
Complex.contDiff_cos.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Complex.sin` -/
theorem HasStrictFDerivAt.csin (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) β’ f') x :=
(Complex.hasStrictDerivAt_sin (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.csin (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) β’ f') x :=
(Complex.hasDerivAt_sin (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.csin (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.sin (f x)) (Complex.cos (f x) β’ f') s x :=
(Complex.hasDerivAt_sin (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.csin (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Complex.sin (f x)) s x :=
hf.hasFDerivWithinAt.csin.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.csin (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Complex.sin (f x)) x :=
hc.hasFDerivAt.csin.differentiableAt
theorem DifferentiableOn.csin (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Complex.sin (f x)) s := fun x h => (hc x h).csin
@[simp, fun_prop]
theorem Differentiable.csin (hc : Differentiable β f) :
Differentiable β fun x => Complex.sin (f x) := fun x => (hc x).csin
theorem fderivWithin_csin (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Complex.sin (f x)) s x = Complex.cos (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.csin.fderivWithin hxs
@[simp]
theorem fderiv_csin (hc : DifferentiableAt β f x) :
fderiv β (fun x => Complex.sin (f x)) x = Complex.cos (f x) β’ fderiv β f x :=
hc.hasFDerivAt.csin.fderiv
theorem ContDiff.csin {n} (h : ContDiff β n f) : ContDiff β n fun x => Complex.sin (f x) :=
Complex.contDiff_sin.comp h
theorem ContDiffAt.csin {n} (hf : ContDiffAt β n f x) :
ContDiffAt β n (fun x => Complex.sin (f x)) x :=
Complex.contDiff_sin.contDiffAt.comp x hf
theorem ContDiffOn.csin {n} (hf : ContDiffOn β n f s) :
ContDiffOn β n (fun x => Complex.sin (f x)) s :=
Complex.contDiff_sin.comp_contDiffOn hf
theorem ContDiffWithinAt.csin {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Complex.sin (f x)) s x :=
Complex.contDiff_sin.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Complex.cosh` -/
theorem HasStrictFDerivAt.ccosh (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) β’ f') x :=
(Complex.hasStrictDerivAt_cosh (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.ccosh (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) β’ f') x :=
(Complex.hasDerivAt_cosh (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.ccosh (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) β’ f') s x :=
(Complex.hasDerivAt_cosh (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.ccosh (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Complex.cosh (f x)) s x :=
hf.hasFDerivWithinAt.ccosh.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.ccosh (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Complex.cosh (f x)) x :=
hc.hasFDerivAt.ccosh.differentiableAt
theorem DifferentiableOn.ccosh (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Complex.cosh (f x)) s := fun x h => (hc x h).ccosh
@[simp, fun_prop]
theorem Differentiable.ccosh (hc : Differentiable β f) :
Differentiable β fun x => Complex.cosh (f x) := fun x => (hc x).ccosh
theorem fderivWithin_ccosh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Complex.cosh (f x)) s x = Complex.sinh (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.ccosh.fderivWithin hxs
@[simp]
theorem fderiv_ccosh (hc : DifferentiableAt β f x) :
fderiv β (fun x => Complex.cosh (f x)) x = Complex.sinh (f x) β’ fderiv β f x :=
hc.hasFDerivAt.ccosh.fderiv
theorem ContDiff.ccosh {n} (h : ContDiff β n f) : ContDiff β n fun x => Complex.cosh (f x) :=
Complex.contDiff_cosh.comp h
theorem ContDiffAt.ccosh {n} (hf : ContDiffAt β n f x) :
ContDiffAt β n (fun x => Complex.cosh (f x)) x :=
Complex.contDiff_cosh.contDiffAt.comp x hf
theorem ContDiffOn.ccosh {n} (hf : ContDiffOn β n f s) :
ContDiffOn β n (fun x => Complex.cosh (f x)) s :=
Complex.contDiff_cosh.comp_contDiffOn hf
theorem ContDiffWithinAt.ccosh {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Complex.cosh (f x)) s x :=
Complex.contDiff_cosh.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Complex.sinh` -/
theorem HasStrictFDerivAt.csinh (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) β’ f') x :=
(Complex.hasStrictDerivAt_sinh (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.csinh (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) β’ f') x :=
(Complex.hasDerivAt_sinh (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.csinh (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) β’ f') s x :=
(Complex.hasDerivAt_sinh (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.csinh (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Complex.sinh (f x)) s x :=
hf.hasFDerivWithinAt.csinh.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.csinh (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Complex.sinh (f x)) x :=
hc.hasFDerivAt.csinh.differentiableAt
theorem DifferentiableOn.csinh (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Complex.sinh (f x)) s := fun x h => (hc x h).csinh
@[simp, fun_prop]
theorem Differentiable.csinh (hc : Differentiable β f) :
Differentiable β fun x => Complex.sinh (f x) := fun x => (hc x).csinh
theorem fderivWithin_csinh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Complex.sinh (f x)) s x = Complex.cosh (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.csinh.fderivWithin hxs
@[simp]
theorem fderiv_csinh (hc : DifferentiableAt β f x) :
fderiv β (fun x => Complex.sinh (f x)) x = Complex.cosh (f x) β’ fderiv β f x :=
hc.hasFDerivAt.csinh.fderiv
theorem ContDiff.csinh {n} (h : ContDiff β n f) : ContDiff β n fun x => Complex.sinh (f x) :=
Complex.contDiff_sinh.comp h
theorem ContDiffAt.csinh {n} (hf : ContDiffAt β n f x) :
ContDiffAt β n (fun x => Complex.sinh (f x)) x :=
Complex.contDiff_sinh.contDiffAt.comp x hf
theorem ContDiffOn.csinh {n} (hf : ContDiffOn β n f s) :
ContDiffOn β n (fun x => Complex.sinh (f x)) s :=
Complex.contDiff_sinh.comp_contDiffOn hf
theorem ContDiffWithinAt.csinh {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Complex.sinh (f x)) s x :=
Complex.contDiff_sinh.contDiffAt.comp_contDiffWithinAt x hf
end
namespace Real
variable {x y z : β}
theorem hasStrictDerivAt_sin (x : β) : HasStrictDerivAt sin (cos x) x :=
(Complex.hasStrictDerivAt_sin x).real_of_complex
theorem hasDerivAt_sin (x : β) : HasDerivAt sin (cos x) x :=
(hasStrictDerivAt_sin x).hasDerivAt
theorem isEquivalent_sin : sin ~[π 0] id := by simpa using (hasDerivAt_sin 0).isLittleO
@[fun_prop]
theorem contDiff_sin {n} : ContDiff β n sin :=
Complex.contDiff_sin.real_of_complex
@[simp]
theorem differentiable_sin : Differentiable β sin := fun x => (hasDerivAt_sin x).differentiableAt
@[simp]
theorem differentiableAt_sin : DifferentiableAt β sin x :=
differentiable_sin x
/-- The function `Real.sin` is real analytic. -/
@[fun_prop]
lemma analyticAt_sin : AnalyticAt β sin x :=
contDiff_sin.contDiffAt.analyticAt
/-- The function `Real.sin` is real analytic. -/
lemma analyticWithinAt_sin {s : Set β} : AnalyticWithinAt β sin s x :=
contDiff_sin.contDiffWithinAt.analyticWithinAt
/-- The function `Real.sin` is real analytic. -/
theorem analyticOnNhd_sin {s : Set β} : AnalyticOnNhd β sin s :=
fun _ _ β¦ analyticAt_sin
/-- The function `Real.sin` is real analytic. -/
lemma analyticOn_sin {s : Set β} : AnalyticOn β sin s :=
contDiff_sin.contDiffOn.analyticOn
@[simp]
theorem deriv_sin : deriv sin = cos :=
funext fun x => (hasDerivAt_sin x).deriv
theorem hasStrictDerivAt_cos (x : β) : HasStrictDerivAt cos (-sin x) x :=
(Complex.hasStrictDerivAt_cos x).real_of_complex
theorem hasDerivAt_cos (x : β) : HasDerivAt cos (-sin x) x :=
(Complex.hasDerivAt_cos x).real_of_complex
@[fun_prop]
theorem contDiff_cos {n} : ContDiff β n cos :=
Complex.contDiff_cos.real_of_complex
@[simp]
theorem differentiable_cos : Differentiable β cos := fun x => (hasDerivAt_cos x).differentiableAt
@[simp]
theorem differentiableAt_cos : DifferentiableAt β cos x :=
differentiable_cos x
/-- The function `Real.cos` is real analytic. -/
@[fun_prop]
lemma analyticAt_cos : AnalyticAt β cos x :=
contDiff_cos.contDiffAt.analyticAt
/-- The function `Real.cos` is real analytic. -/
lemma analyticWithinAt_cos {s : Set β} : AnalyticWithinAt β cos s x :=
contDiff_cos.contDiffWithinAt.analyticWithinAt
/-- The function `Real.cos` is real analytic. -/
theorem analyticOnNhd_cos {s : Set β} : AnalyticOnNhd β cos s :=
fun _ _ β¦ analyticAt_cos
/-- The function `Real.cos` is real analytic. -/
lemma analyticOn_cos {s : Set β} : AnalyticOn β cos s :=
contDiff_cos.contDiffOn.analyticOn
theorem deriv_cos : deriv cos x = -sin x :=
(hasDerivAt_cos x).deriv
@[simp]
theorem deriv_cos' : deriv cos = fun x => -sin x :=
funext fun _ => deriv_cos
theorem hasStrictDerivAt_sinh (x : β) : HasStrictDerivAt sinh (cosh x) x :=
(Complex.hasStrictDerivAt_sinh x).real_of_complex
theorem hasDerivAt_sinh (x : β) : HasDerivAt sinh (cosh x) x :=
(Complex.hasDerivAt_sinh x).real_of_complex
theorem isEquivalent_sinh : sinh ~[π 0] id := by simpa using (hasDerivAt_sinh 0).isLittleO
@[fun_prop]
theorem contDiff_sinh {n} : ContDiff β n sinh :=
Complex.contDiff_sinh.real_of_complex
@[simp]
theorem differentiable_sinh : Differentiable β sinh := fun x => (hasDerivAt_sinh x).differentiableAt
@[simp]
theorem differentiableAt_sinh : DifferentiableAt β sinh x :=
differentiable_sinh x
/-- The function `Real.sinh` is real analytic. -/
@[fun_prop]
lemma analyticAt_sinh : AnalyticAt β sinh x :=
contDiff_sinh.contDiffAt.analyticAt
/-- The function `Real.sinh` is real analytic. -/
lemma analyticWithinAt_sinh {s : Set β} : AnalyticWithinAt β sinh s x :=
contDiff_sinh.contDiffWithinAt.analyticWithinAt
/-- The function `Real.sinh` is real analytic. -/
theorem analyticOnNhd_sinh {s : Set β} : AnalyticOnNhd β sinh s :=
fun _ _ β¦ analyticAt_sinh
/-- The function `Real.sinh` is real analytic. -/
lemma analyticOn_sinh {s : Set β} : AnalyticOn β sinh s :=
contDiff_sinh.contDiffOn.analyticOn
@[simp]
theorem deriv_sinh : deriv sinh = cosh :=
funext fun x => (hasDerivAt_sinh x).deriv
theorem hasStrictDerivAt_cosh (x : β) : HasStrictDerivAt cosh (sinh x) x :=
(Complex.hasStrictDerivAt_cosh x).real_of_complex
theorem hasDerivAt_cosh (x : β) : HasDerivAt cosh (sinh x) x :=
(Complex.hasDerivAt_cosh x).real_of_complex
@[fun_prop]
theorem contDiff_cosh {n} : ContDiff β n cosh :=
Complex.contDiff_cosh.real_of_complex
@[simp]
theorem differentiable_cosh : Differentiable β cosh := fun x => (hasDerivAt_cosh x).differentiableAt
@[simp]
theorem differentiableAt_cosh : DifferentiableAt β cosh x :=
differentiable_cosh x
/-- The function `Real.cosh` is real analytic. -/
@[fun_prop]
lemma analyticAt_cosh : AnalyticAt β cosh x :=
contDiff_cosh.contDiffAt.analyticAt
/-- The function `Real.cosh` is real analytic. -/
lemma analyticWithinAt_cosh {s : Set β} : AnalyticWithinAt β cosh s x :=
contDiff_cosh.contDiffWithinAt.analyticWithinAt
/-- The function `Real.cosh` is real analytic. -/
theorem analyticOnNhd_cosh {s : Set β} : AnalyticOnNhd β cosh s :=
fun _ _ β¦ analyticAt_cosh
/-- The function `Real.cosh` is real analytic. -/
lemma analyticOn_cosh {s : Set β} : AnalyticOn β cosh s :=
contDiff_cosh.contDiffOn.analyticOn
@[simp]
theorem deriv_cosh : deriv cosh = sinh :=
funext fun x => (hasDerivAt_cosh x).deriv
/-- `sinh` is strictly monotone. -/
theorem sinh_strictMono : StrictMono sinh :=
strictMono_of_deriv_pos <| by rw [Real.deriv_sinh]; exact cosh_pos
/-- `sinh` is injective, `β a b, sinh a = sinh b β a = b`. -/
theorem sinh_injective : Function.Injective sinh :=
sinh_strictMono.injective
@[simp]
theorem sinh_inj : sinh x = sinh y β x = y :=
sinh_injective.eq_iff
@[simp]
theorem sinh_le_sinh : sinh x β€ sinh y β x β€ y :=
sinh_strictMono.le_iff_le
@[simp]
theorem sinh_lt_sinh : sinh x < sinh y β x < y :=
sinh_strictMono.lt_iff_lt
@[simp] lemma sinh_eq_zero : sinh x = 0 β x = 0 := by rw [β @sinh_inj x, sinh_zero]
lemma sinh_ne_zero : sinh x β 0 β x β 0 := sinh_eq_zero.not
@[simp]
theorem sinh_pos_iff : 0 < sinh x β 0 < x := by simpa only [sinh_zero] using @sinh_lt_sinh 0 x
@[simp]
theorem sinh_nonpos_iff : sinh x β€ 0 β x β€ 0 := by simpa only [sinh_zero] using @sinh_le_sinh x 0
@[simp]
theorem sinh_neg_iff : sinh x < 0 β x < 0 := by simpa only [sinh_zero] using @sinh_lt_sinh x 0
@[simp]
theorem sinh_nonneg_iff : 0 β€ sinh x β 0 β€ x := by simpa only [sinh_zero] using @sinh_le_sinh 0 x
theorem abs_sinh (x : β) : |sinh x| = sinh |x| := by
cases le_total x 0 <;> simp [abs_of_nonneg, abs_of_nonpos, *]
theorem cosh_strictMonoOn : StrictMonoOn cosh (Ici 0) :=
strictMonoOn_of_deriv_pos (convex_Ici _) continuous_cosh.continuousOn fun x hx => by
rw [interior_Ici, mem_Ioi] at hx; rwa [deriv_cosh, sinh_pos_iff]
@[simp]
theorem cosh_le_cosh : cosh x β€ cosh y β |x| β€ |y| :=
cosh_abs x βΈ cosh_abs y βΈ cosh_strictMonoOn.le_iff_le (abs_nonneg x) (abs_nonneg y)
@[simp]
theorem cosh_lt_cosh : cosh x < cosh y β |x| < |y| :=
lt_iff_lt_of_le_iff_le cosh_le_cosh
@[simp]
theorem one_le_cosh (x : β) : 1 β€ cosh x :=
cosh_zero βΈ cosh_le_cosh.2 (by simp only [_root_.abs_zero, _root_.abs_nonneg])
@[simp]
theorem one_lt_cosh : 1 < cosh x β x β 0 :=
cosh_zero βΈ cosh_lt_cosh.trans (by simp only [_root_.abs_zero, abs_pos])
theorem sinh_sub_id_strictMono : StrictMono fun x => sinh x - x := by
refine strictMono_of_odd_strictMonoOn_nonneg (fun x => by simp; abel) ?_
refine strictMonoOn_of_deriv_pos (convex_Ici _) ?_ fun x hx => ?_
Β· exact (continuous_sinh.sub continuous_id).continuousOn
Β· rw [interior_Ici, mem_Ioi] at hx
rw [deriv_fun_sub, deriv_sinh, deriv_id'', sub_pos, one_lt_cosh]
exacts [hx.ne', differentiableAt_sinh, differentiableAt_id]
@[simp]
theorem self_le_sinh_iff : x β€ sinh x β 0 β€ x :=
calc
x β€ sinh x β sinh 0 - 0 β€ sinh x - x := by simp
_ β 0 β€ x := sinh_sub_id_strictMono.le_iff_le
@[simp]
theorem sinh_le_self_iff : sinh x β€ x β x β€ 0 :=
calc
sinh x β€ x β sinh x - x β€ sinh 0 - 0 := by simp
_ β x β€ 0 := sinh_sub_id_strictMono.le_iff_le
@[simp]
theorem self_lt_sinh_iff : x < sinh x β 0 < x :=
lt_iff_lt_of_le_iff_le sinh_le_self_iff
@[simp]
theorem sinh_lt_self_iff : sinh x < x β x < 0 :=
lt_iff_lt_of_le_iff_le self_le_sinh_iff
end Real
section iteratedDeriv
/-! ### Simp lemmas for iterated derivatives of `sin` and `cos`. -/
namespace Complex
@[simp]
theorem iteratedDeriv_add_one_sin (n : β) :
iteratedDeriv (n + 1) sin = iteratedDeriv n cos := by
induction n with
| zero => simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ]
@[simp]
theorem iteratedDeriv_add_one_cos (n : β) :
iteratedDeriv (n + 1) cos = - iteratedDeriv n sin := by
induction n with
| zero => ext; simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ, deriv.neg']
ext x
simp
@[simp]
theorem iteratedDeriv_even_sin (n : β) :
iteratedDeriv (2 * n) sin = (-1) ^ n * sin := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add, pow_succ]
@[simp]
theorem iteratedDeriv_even_cos (n : β) :
iteratedDeriv (2 * n) cos = (-1) ^ n * cos := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add, pow_succ]
theorem iteratedDeriv_odd_sin (n : β) :
iteratedDeriv (2 * n + 1) sin = (-1) ^ n * cos := by simp
theorem iteratedDeriv_odd_cos (n : β) :
iteratedDeriv (2 * n + 1) cos = (-1) ^ (n + 1) * sin := by simp [pow_succ]
theorem differentiable_iteratedDeriv_sin (n : β) :
Differentiable β (iteratedDeriv n sin) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_sin]
theorem differentiable_iteratedDeriv_cos (n : β) :
Differentiable β (iteratedDeriv n cos) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_cos]
@[simp]
theorem iteratedDeriv_add_one_sinh (n : β) :
iteratedDeriv (n + 1) sinh = iteratedDeriv n cosh := by
induction n with
| zero => simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ]
@[simp]
theorem iteratedDeriv_add_one_cosh (n : β) :
iteratedDeriv (n + 1) cosh = iteratedDeriv n sinh := by
induction n with
| zero => ext; simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ]
@[simp]
theorem iteratedDeriv_even_sinh (n : β) :
iteratedDeriv (2 * n) sinh = sinh := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add]
@[simp]
theorem iteratedDeriv_even_cosh (n : β) :
iteratedDeriv (2 * n) cosh = cosh := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add]
theorem iteratedDeriv_odd_sinh (n : β) :
iteratedDeriv (2 * n + 1) sinh = cosh := by simp
theorem iteratedDeriv_odd_cosh (n : β) :
iteratedDeriv (2 * n + 1) cosh = sinh := by simp
theorem differentiable_iteratedDeriv_sinh (n : β) :
Differentiable β (iteratedDeriv n sinh) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_sinh]
theorem differentiable_iteratedDeriv_cosh (n : β) :
Differentiable β (iteratedDeriv n cosh) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_cosh]
end Complex
namespace Real
@[simp]
theorem iteratedDeriv_add_one_sin (n : β) :
iteratedDeriv (n + 1) sin = iteratedDeriv n cos := by
induction n with
| zero => simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ]
@[simp]
theorem iteratedDeriv_add_one_cos (n : β) :
iteratedDeriv (n + 1) cos = - iteratedDeriv n sin := by
induction n with
| zero => ext; simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ, deriv.neg']
ext x
simp
@[simp]
theorem iteratedDeriv_even_sin (n : β) :
iteratedDeriv (2 * n) sin = (-1) ^ n * sin := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add, pow_succ]
@[simp]
theorem iteratedDeriv_even_cos (n : β) :
iteratedDeriv (2 * n) cos = (-1) ^ n * cos := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add, pow_succ]
theorem iteratedDeriv_odd_sin (n : β) :
iteratedDeriv (2 * n + 1) sin = (-1) ^ n * cos := by simp
theorem iteratedDeriv_odd_cos (n : β) :
iteratedDeriv (2 * n + 1) cos = (-1) ^ (n + 1) * sin := by simp [pow_succ]
theorem differentiable_iteratedDeriv_sin (n : β) :
Differentiable β (iteratedDeriv n sin) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_sin]
theorem differentiable_iteratedDeriv_cos (n : β) :
Differentiable β (iteratedDeriv n cos) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_cos]
theorem abs_iteratedDeriv_sin_le_one (n : β) (x : β) :
|iteratedDeriv n sin x| β€ 1 :=
match n with
| 0 => by simpa using Real.abs_sin_le_one x
| 1 => by simpa using Real.abs_cos_le_one x
| n + 2 => by simpa using abs_iteratedDeriv_sin_le_one n x
theorem abs_iteratedDeriv_cos_le_one (n : β) (x : β) :
|iteratedDeriv n cos x| β€ 1 :=
match n with
| 0 => by simpa using Real.abs_cos_le_one x
| 1 => by simpa using Real.abs_sin_le_one x
| n + 2 => by simpa using abs_iteratedDeriv_cos_le_one n x
@[simp]
theorem iteratedDeriv_add_one_sinh (n : β) :
iteratedDeriv (n + 1) sinh = iteratedDeriv n cosh := by
induction n with
| zero => simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ]
@[simp]
theorem iteratedDeriv_add_one_cosh (n : β) :
iteratedDeriv (n + 1) cosh = iteratedDeriv n sinh := by
induction n with
| zero => ext; simp
| succ n ih =>
rw [iteratedDeriv_succ, ih, iteratedDeriv_succ]
@[simp]
theorem iteratedDeriv_even_sinh (n : β) :
iteratedDeriv (2 * n) sinh = sinh := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add]
@[simp]
theorem iteratedDeriv_even_cosh (n : β) :
iteratedDeriv (2 * n) cosh = cosh := by
induction n with
| zero => simp
| succ n ih => simp_all [mul_add]
theorem iteratedDeriv_odd_sinh (n : β) :
iteratedDeriv (2 * n + 1) sinh = cosh := by simp
theorem iteratedDeriv_odd_cosh (n : β) :
iteratedDeriv (2 * n + 1) cosh = sinh := by simp
theorem differentiable_iteratedDeriv_sinh (n : β) :
Differentiable β (iteratedDeriv n sinh) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_sinh]
theorem differentiable_iteratedDeriv_cosh (n : β) :
Differentiable β (iteratedDeriv n cosh) :=
match n with
| 0 => by simp
| 1 => by simp
| n + 2 => by simp [differentiable_iteratedDeriv_cosh]
@[simp]
theorem iteratedDerivWithin_sin_Icc (n : β) {a b : β} (h : a < b) {x : β} (hx : x β Icc a b) :
iteratedDerivWithin n sin (Icc a b) x = iteratedDeriv n sin x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc h) contDiff_sin.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_cos_Icc (n : β) {a b : β} (h : a < b) {x : β} (hx : x β Icc a b) :
iteratedDerivWithin n cos (Icc a b) x = iteratedDeriv n cos x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc h) contDiff_cos.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_sinh_Icc (n : β) {a b : β} (h : a < b) {x : β} (hx : x β Icc a b) :
iteratedDerivWithin n sinh (Icc a b) x = iteratedDeriv n sinh x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc h) contDiff_sinh.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_cosh_Icc (n : β) {a b : β} (h : a < b) {x : β} (hx : x β Icc a b) :
iteratedDerivWithin n cosh (Icc a b) x = iteratedDeriv n cosh x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Icc h) contDiff_cosh.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_sin_Ioo (n : β) {a b x : β} (hx : x β Ioo a b) :
iteratedDerivWithin n sin (Ioo a b) x = iteratedDeriv n sin x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Ioo a b) contDiff_sin.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_cos_Ioo (n : β) {a b x : β} (hx : x β Ioo a b) :
iteratedDerivWithin n cos (Ioo a b) x = iteratedDeriv n cos x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Ioo a b) contDiff_cos.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_sinh_Ioo (n : β) {a b x : β} (hx : x β Ioo a b) :
iteratedDerivWithin n sinh (Ioo a b) x = iteratedDeriv n sinh x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Ioo a b) contDiff_sinh.contDiffAt hx
@[simp]
theorem iteratedDerivWithin_cosh_Ioo (n : β) {a b x : β} (hx : x β Ioo a b) :
iteratedDerivWithin n cosh (Ioo a b) x = iteratedDeriv n cosh x :=
iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Ioo a b) contDiff_cosh.contDiffAt hx
end Real
end iteratedDeriv
section
/-! ### Simp lemmas for derivatives of `fun x => Real.cos (f x)` etc., `f : β β β` -/
variable {f : β β β} {f' x : β} {s : Set β}
/-! #### `Real.cos` -/
theorem HasStrictDerivAt.cos (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.cos (f x)) (-Real.sin (f x) * f') x :=
(Real.hasStrictDerivAt_cos (f x)).comp x hf
theorem HasDerivAt.cos (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.cos (f x)) (-Real.sin (f x) * f') x :=
(Real.hasDerivAt_cos (f x)).comp x hf
theorem HasDerivWithinAt.cos (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.cos (f x)) (-Real.sin (f x) * f') s x :=
(Real.hasDerivAt_cos (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_cos (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Real.cos (f x)) s x = -Real.sin (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.cos.derivWithin hxs
@[simp]
theorem deriv_cos (hc : DifferentiableAt β f x) :
deriv (fun x => Real.cos (f x)) x = -Real.sin (f x) * deriv f x :=
hc.hasDerivAt.cos.deriv
/-! #### `Real.sin` -/
theorem HasStrictDerivAt.sin (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.sin (f x)) (Real.cos (f x) * f') x :=
(Real.hasStrictDerivAt_sin (f x)).comp x hf
theorem HasDerivAt.sin (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.sin (f x)) (Real.cos (f x) * f') x :=
(Real.hasDerivAt_sin (f x)).comp x hf
theorem HasDerivWithinAt.sin (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.sin (f x)) (Real.cos (f x) * f') s x :=
(Real.hasDerivAt_sin (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_sin (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Real.sin (f x)) s x = Real.cos (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.sin.derivWithin hxs
@[simp]
theorem deriv_sin (hc : DifferentiableAt β f x) :
deriv (fun x => Real.sin (f x)) x = Real.cos (f x) * deriv f x :=
hc.hasDerivAt.sin.deriv
/-! #### `Real.cosh` -/
theorem HasStrictDerivAt.cosh (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.cosh (f x)) (Real.sinh (f x) * f') x :=
(Real.hasStrictDerivAt_cosh (f x)).comp x hf
theorem HasDerivAt.cosh (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.cosh (f x)) (Real.sinh (f x) * f') x :=
(Real.hasDerivAt_cosh (f x)).comp x hf
theorem HasDerivWithinAt.cosh (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.cosh (f x)) (Real.sinh (f x) * f') s x :=
(Real.hasDerivAt_cosh (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_cosh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Real.cosh (f x)) s x = Real.sinh (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.cosh.derivWithin hxs
@[simp]
theorem deriv_cosh (hc : DifferentiableAt β f x) :
deriv (fun x => Real.cosh (f x)) x = Real.sinh (f x) * deriv f x :=
hc.hasDerivAt.cosh.deriv
/-! #### `Real.sinh` -/
theorem HasStrictDerivAt.sinh (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.sinh (f x)) (Real.cosh (f x) * f') x :=
(Real.hasStrictDerivAt_sinh (f x)).comp x hf
theorem HasDerivAt.sinh (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.sinh (f x)) (Real.cosh (f x) * f') x :=
(Real.hasDerivAt_sinh (f x)).comp x hf
theorem HasDerivWithinAt.sinh (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.sinh (f x)) (Real.cosh (f x) * f') s x :=
(Real.hasDerivAt_sinh (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_sinh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => Real.sinh (f x)) s x = Real.cosh (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.sinh.derivWithin hxs
@[simp]
theorem deriv_sinh (hc : DifferentiableAt β f x) :
deriv (fun x => Real.sinh (f x)) x = Real.cosh (f x) * deriv f x :=
hc.hasDerivAt.sinh.deriv
end
section
/-! ### Simp lemmas for derivatives of `fun x => Real.cos (f x)` etc., `f : E β β` -/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] {f : E β β} {f' : StrongDual β E}
{x : E} {s : Set E}
/-! #### `Real.cos` -/
theorem HasStrictFDerivAt.cos (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Real.cos (f x)) (-Real.sin (f x) β’ f') x :=
(Real.hasStrictDerivAt_cos (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.cos (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Real.cos (f x)) (-Real.sin (f x) β’ f') x :=
(Real.hasDerivAt_cos (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.cos (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Real.cos (f x)) (-Real.sin (f x) β’ f') s x :=
(Real.hasDerivAt_cos (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.cos (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Real.cos (f x)) s x :=
hf.hasFDerivWithinAt.cos.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.cos (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Real.cos (f x)) x :=
hc.hasFDerivAt.cos.differentiableAt
theorem DifferentiableOn.cos (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Real.cos (f x)) s := fun x h => (hc x h).cos
@[simp, fun_prop]
theorem Differentiable.cos (hc : Differentiable β f) : Differentiable β fun x => Real.cos (f x) :=
fun x => (hc x).cos
theorem fderivWithin_cos (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Real.cos (f x)) s x = -Real.sin (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.cos.fderivWithin hxs
@[simp]
theorem fderiv_cos (hc : DifferentiableAt β f x) :
fderiv β (fun x => Real.cos (f x)) x = -Real.sin (f x) β’ fderiv β f x :=
hc.hasFDerivAt.cos.fderiv
theorem ContDiff.cos {n} (h : ContDiff β n f) : ContDiff β n fun x => Real.cos (f x) :=
Real.contDiff_cos.comp h
theorem ContDiffAt.cos {n} (hf : ContDiffAt β n f x) : ContDiffAt β n (fun x => Real.cos (f x)) x :=
Real.contDiff_cos.contDiffAt.comp x hf
theorem ContDiffOn.cos {n} (hf : ContDiffOn β n f s) : ContDiffOn β n (fun x => Real.cos (f x)) s :=
Real.contDiff_cos.comp_contDiffOn hf
theorem ContDiffWithinAt.cos {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Real.cos (f x)) s x :=
Real.contDiff_cos.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Real.sin` -/
theorem HasStrictFDerivAt.sin (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Real.sin (f x)) (Real.cos (f x) β’ f') x :=
(Real.hasStrictDerivAt_sin (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.sin (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Real.sin (f x)) (Real.cos (f x) β’ f') x :=
(Real.hasDerivAt_sin (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.sin (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Real.sin (f x)) (Real.cos (f x) β’ f') s x :=
(Real.hasDerivAt_sin (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.sin (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Real.sin (f x)) s x :=
hf.hasFDerivWithinAt.sin.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.sin (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Real.sin (f x)) x :=
hc.hasFDerivAt.sin.differentiableAt
theorem DifferentiableOn.sin (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Real.sin (f x)) s := fun x h => (hc x h).sin
@[simp, fun_prop]
theorem Differentiable.sin (hc : Differentiable β f) : Differentiable β fun x => Real.sin (f x) :=
fun x => (hc x).sin
theorem fderivWithin_sin (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Real.sin (f x)) s x = Real.cos (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.sin.fderivWithin hxs
@[simp]
theorem fderiv_sin (hc : DifferentiableAt β f x) :
fderiv β (fun x => Real.sin (f x)) x = Real.cos (f x) β’ fderiv β f x :=
hc.hasFDerivAt.sin.fderiv
theorem ContDiff.sin {n} (h : ContDiff β n f) : ContDiff β n fun x => Real.sin (f x) :=
Real.contDiff_sin.comp h
theorem ContDiffAt.sin {n} (hf : ContDiffAt β n f x) : ContDiffAt β n (fun x => Real.sin (f x)) x :=
Real.contDiff_sin.contDiffAt.comp x hf
theorem ContDiffOn.sin {n} (hf : ContDiffOn β n f s) : ContDiffOn β n (fun x => Real.sin (f x)) s :=
Real.contDiff_sin.comp_contDiffOn hf
theorem ContDiffWithinAt.sin {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Real.sin (f x)) s x :=
Real.contDiff_sin.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Real.cosh` -/
theorem HasStrictFDerivAt.cosh (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Real.cosh (f x)) (Real.sinh (f x) β’ f') x :=
(Real.hasStrictDerivAt_cosh (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.cosh (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Real.cosh (f x)) (Real.sinh (f x) β’ f') x :=
(Real.hasDerivAt_cosh (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.cosh (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Real.cosh (f x)) (Real.sinh (f x) β’ f') s x :=
(Real.hasDerivAt_cosh (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.cosh (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Real.cosh (f x)) s x :=
hf.hasFDerivWithinAt.cosh.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.cosh (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Real.cosh (f x)) x :=
hc.hasFDerivAt.cosh.differentiableAt
theorem DifferentiableOn.cosh (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Real.cosh (f x)) s := fun x h => (hc x h).cosh
@[simp, fun_prop]
theorem Differentiable.cosh (hc : Differentiable β f) : Differentiable β fun x => Real.cosh (f x) :=
fun x => (hc x).cosh
theorem fderivWithin_cosh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Real.cosh (f x)) s x = Real.sinh (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.cosh.fderivWithin hxs
@[simp]
theorem fderiv_cosh (hc : DifferentiableAt β f x) :
fderiv β (fun x => Real.cosh (f x)) x = Real.sinh (f x) β’ fderiv β f x :=
hc.hasFDerivAt.cosh.fderiv
theorem ContDiff.cosh {n} (h : ContDiff β n f) : ContDiff β n fun x => Real.cosh (f x) :=
Real.contDiff_cosh.comp h
theorem ContDiffAt.cosh {n} (hf : ContDiffAt β n f x) :
ContDiffAt β n (fun x => Real.cosh (f x)) x :=
Real.contDiff_cosh.contDiffAt.comp x hf
theorem ContDiffOn.cosh {n} (hf : ContDiffOn β n f s) :
ContDiffOn β n (fun x => Real.cosh (f x)) s :=
Real.contDiff_cosh.comp_contDiffOn hf
theorem ContDiffWithinAt.cosh {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Real.cosh (f x)) s x :=
Real.contDiff_cosh.contDiffAt.comp_contDiffWithinAt x hf
/-! #### `Real.sinh` -/
theorem HasStrictFDerivAt.sinh (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Real.sinh (f x)) (Real.cosh (f x) β’ f') x :=
(Real.hasStrictDerivAt_sinh (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.sinh (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Real.sinh (f x)) (Real.cosh (f x) β’ f') x :=
(Real.hasDerivAt_sinh (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.sinh (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Real.sinh (f x)) (Real.cosh (f x) β’ f') s x :=
(Real.hasDerivAt_sinh (f x)).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.sinh (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Real.sinh (f x)) s x :=
hf.hasFDerivWithinAt.sinh.differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.sinh (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => Real.sinh (f x)) x :=
hc.hasFDerivAt.sinh.differentiableAt
theorem DifferentiableOn.sinh (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => Real.sinh (f x)) s := fun x h => (hc x h).sinh
@[simp, fun_prop]
theorem Differentiable.sinh (hc : Differentiable β f) : Differentiable β fun x => Real.sinh (f x) :=
fun x => (hc x).sinh
theorem fderivWithin_sinh (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => Real.sinh (f x)) s x = Real.cosh (f x) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.sinh.fderivWithin hxs
@[simp]
theorem fderiv_sinh (hc : DifferentiableAt β f x) :
fderiv β (fun x => Real.sinh (f x)) x = Real.cosh (f x) β’ fderiv β f x :=
hc.hasFDerivAt.sinh.fderiv
theorem ContDiff.sinh {n} (h : ContDiff β n f) : ContDiff β n fun x => Real.sinh (f x) :=
Real.contDiff_sinh.comp h
theorem ContDiffAt.sinh {n} (hf : ContDiffAt β n f x) :
ContDiffAt β n (fun x => Real.sinh (f x)) x :=
Real.contDiff_sinh.contDiffAt.comp x hf
theorem ContDiffOn.sinh {n} (hf : ContDiffOn β n f s) :
ContDiffOn β n (fun x => Real.sinh (f x)) s :=
Real.contDiff_sinh.comp_contDiffOn hf
theorem ContDiffWithinAt.sinh {n} (hf : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => Real.sinh (f x)) s x :=
Real.contDiff_sinh.contDiffAt.comp_contDiffWithinAt x hf
section LogDeriv
@[simp]
theorem Complex.logDeriv_sin : logDeriv (Complex.sin) = Complex.cot := by
ext
rw [logDeriv, Complex.deriv_sin, Pi.div_apply, Complex.cot]
@[simp]
theorem Real.logDeriv_sin : logDeriv (Real.sin) = Real.cot := by
ext
rw [logDeriv, Real.deriv_sin, Pi.div_apply, Real.cot_eq_cos_div_sin]
@[simp]
theorem Complex.logDeriv_cos : logDeriv (Complex.cos) = -Complex.tan := by
ext
rw [logDeriv, Complex.deriv_cos', Pi.div_apply, Pi.neg_apply, Complex.tan, neg_div]
@[simp]
theorem Real.logDeriv_cos : logDeriv (Real.cos) = -Real.tan := by
ext
rw [logDeriv, Real.deriv_cos', Pi.div_apply, Pi.neg_apply, neg_div, Real.tan_eq_sin_div_cos ]
@[simp]
theorem Complex.logDeriv_cosh : logDeriv (Complex.cosh) = Complex.tanh := by
ext
rw [logDeriv, Complex.deriv_cosh, Pi.div_apply, Complex.tanh]
@[simp]
theorem Real.logDeriv_cosh : logDeriv (Real.cosh) = Real.tanh := by
ext
rw [logDeriv, Real.deriv_cosh, Pi.div_apply, Real.tanh_eq_sinh_div_cosh]
@[simp]
theorem Complex.LogDeriv_exp : logDeriv (Complex.exp) = 1 := by
ext
rw [logDeriv, Complex.deriv_exp, Pi.div_apply, β exp_sub, sub_self, exp_zero, Pi.one_apply]
@[simp]
theorem Real.LogDeriv_exp : logDeriv (Real.exp) = 1 := by
ext
rw [logDeriv, Real.deriv_exp, Pi.div_apply, β exp_sub, sub_self, exp_zero, Pi.one_apply]
end LogDeriv
end
namespace Mathlib.Meta.Positivity
open Lean Meta Qq
private alias β¨_, sinh_pos_of_posβ© := Real.sinh_pos_iff
private alias β¨_, sinh_nonneg_of_nonnegβ© := Real.sinh_nonneg_iff
private alias β¨_, sinh_ne_zero_of_ne_zeroβ© := Real.sinh_ne_zero
/-- Extension for the `positivity` tactic: `Real.sinh` is positive/nonnegative/nonzero if its input
is. -/
@[positivity Real.sinh _]
def evalSinh : PositivityExt where eval {u Ξ±} _ _ e := do
let zΞ± : Q(Zero β) := q(inferInstance)
let pΞ± : Q(PartialOrder β) := q(inferInstance)
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.sinh $a) =>
assumeInstancesCommute
match β core zΞ± pΞ± a with
| .positive pa => return .positive q(sinh_pos_of_pos $pa)
| .nonnegative pa => return .nonnegative q(sinh_nonneg_of_nonneg $pa)
| .nonzero pa => return .nonzero q(sinh_ne_zero_of_ne_zero $pa)
| _ => return .none
| _, _, _ => throwError "not Real.sinh"
example (x : β) (hx : 0 < x) : 0 < x.sinh := by positivity
example (x : β) (hx : 0 β€ x) : 0 β€ x.sinh := by positivity
example (x : β) (hx : x β 0) : x.sinh β 0 := by positivity
end Mathlib.Meta.Positivity |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
/-!
# derivatives of the inverse trigonometric functions
Derivatives of `arcsin` and `arccos`.
-/
noncomputable section
open scoped Topology Filter Real ContDiff
open Set
namespace Real
section Arcsin
theorem deriv_arcsin_aux {x : β} (hβ : x β -1) (hβ : x β 1) :
HasStrictDerivAt arcsin (1 / β(1 - x ^ 2)) x β§ ContDiffAt β Ο arcsin x := by
rcases hβ.lt_or_gt with hβ | hβ
Β· have : 1 - x ^ 2 < 0 := by nlinarith [hβ]
rw [sqrt_eq_zero'.2 this.le, div_zero]
have : arcsin =αΆ [π x] fun _ => -(Ο / 2) :=
(gt_mem_nhds hβ).mono fun y hy => arcsin_of_le_neg_one hy.le
exact β¨(hasStrictDerivAt_const x _).congr_of_eventuallyEq this.symm,
contDiffAt_const.congr_of_eventuallyEq thisβ©
rcases hβ.lt_or_gt with hβ | hβ
Β· have : 0 < β(1 - x ^ 2) := sqrt_pos.2 (by nlinarith [hβ, hβ])
simp only [β cos_arcsin, one_div] at this β’
exact β¨sinPartialHomeomorph.hasStrictDerivAt_symm β¨hβ, hββ© this.ne' (hasStrictDerivAt_sin _),
sinPartialHomeomorph.contDiffAt_symm_deriv this.ne' β¨hβ, hββ© (hasDerivAt_sin _)
contDiff_sin.contDiffAtβ©
Β· have : 1 - x ^ 2 < 0 := by nlinarith [hβ]
rw [sqrt_eq_zero'.2 this.le, div_zero]
have : arcsin =αΆ [π x] fun _ => Ο / 2 := (lt_mem_nhds hβ).mono fun y hy => arcsin_of_one_le hy.le
exact β¨(hasStrictDerivAt_const x _).congr_of_eventuallyEq this.symm,
contDiffAt_const.congr_of_eventuallyEq thisβ©
theorem hasStrictDerivAt_arcsin {x : β} (hβ : x β -1) (hβ : x β 1) :
HasStrictDerivAt arcsin (1 / β(1 - x ^ 2)) x :=
(deriv_arcsin_aux hβ hβ).1
theorem hasDerivAt_arcsin {x : β} (hβ : x β -1) (hβ : x β 1) :
HasDerivAt arcsin (1 / β(1 - x ^ 2)) x :=
(hasStrictDerivAt_arcsin hβ hβ).hasDerivAt
theorem contDiffAt_arcsin {x : β} (hβ : x β -1) (hβ : x β 1) {n : WithTop ββ} :
ContDiffAt β n arcsin x :=
(deriv_arcsin_aux hβ hβ).2.of_le le_top
theorem hasDerivWithinAt_arcsin_Ici {x : β} (h : x β -1) :
HasDerivWithinAt arcsin (1 / β(1 - x ^ 2)) (Ici x) x := by
rcases eq_or_ne x 1 with (rfl | h')
Β· convert (hasDerivWithinAt_const (1 : β) _ (Ο / 2)).congr _ _ <;>
simp +contextual [arcsin_of_one_le]
Β· exact (hasDerivAt_arcsin h h').hasDerivWithinAt
theorem hasDerivWithinAt_arcsin_Iic {x : β} (h : x β 1) :
HasDerivWithinAt arcsin (1 / β(1 - x ^ 2)) (Iic x) x := by
rcases em (x = -1) with (rfl | h')
Β· convert (hasDerivWithinAt_const (-1 : β) _ (-(Ο / 2))).congr _ _ <;>
simp +contextual [arcsin_of_le_neg_one]
Β· exact (hasDerivAt_arcsin h' h).hasDerivWithinAt
theorem differentiableWithinAt_arcsin_Ici {x : β} :
DifferentiableWithinAt β arcsin (Ici x) x β x β -1 := by
refine β¨?_, fun h => (hasDerivWithinAt_arcsin_Ici h).differentiableWithinAtβ©
rintro h rfl
have : sin β arcsin =αΆ [π[β₯] (-1 : β)] id := by
filter_upwards [Icc_mem_nhdsGE (neg_lt_self zero_lt_one)] with x using sin_arcsin'
have := h.hasDerivWithinAt.sin.congr_of_eventuallyEq this.symm (by simp)
simpa using (uniqueDiffOn_Ici _ _ left_mem_Ici).eq_deriv _ this (hasDerivWithinAt_id _ _)
theorem differentiableWithinAt_arcsin_Iic {x : β} :
DifferentiableWithinAt β arcsin (Iic x) x β x β 1 := by
refine β¨fun h => ?_, fun h => (hasDerivWithinAt_arcsin_Iic h).differentiableWithinAtβ©
rw [β neg_neg x, β image_neg_Ici] at h
have := (h.comp (-x) differentiableWithinAt_id.fun_neg (mapsTo_image _ _)).fun_neg
simpa [(Β· β Β·), differentiableWithinAt_arcsin_Ici] using this
theorem differentiableAt_arcsin {x : β} : DifferentiableAt β arcsin x β x β -1 β§ x β 1 :=
β¨fun h => β¨differentiableWithinAt_arcsin_Ici.1 h.differentiableWithinAt,
differentiableWithinAt_arcsin_Iic.1 h.differentiableWithinAtβ©,
fun h => (hasDerivAt_arcsin h.1 h.2).differentiableAtβ©
@[simp]
theorem deriv_arcsin : deriv arcsin = fun x => 1 / β(1 - x ^ 2) := by
funext x
by_cases h : x β -1 β§ x β 1
Β· exact (hasDerivAt_arcsin h.1 h.2).deriv
Β· rw [deriv_zero_of_not_differentiableAt (mt differentiableAt_arcsin.1 h)]
simp only [not_and_or, Ne, Classical.not_not] at h
rcases h with (rfl | rfl) <;> simp
theorem differentiableOn_arcsin : DifferentiableOn β arcsin {-1, 1}αΆ := fun _x hx =>
(differentiableAt_arcsin.2
β¨fun h => hx (Or.inl h), fun h => hx (Or.inr h)β©).differentiableWithinAt
theorem contDiffOn_arcsin {n : WithTop ββ} : ContDiffOn β n arcsin {-1, 1}αΆ := fun _x hx =>
(contDiffAt_arcsin (mt Or.inl hx) (mt Or.inr hx)).contDiffWithinAt
theorem contDiffAt_arcsin_iff {x : β} {n : WithTop ββ} :
ContDiffAt β n arcsin x β n = 0 β¨ x β -1 β§ x β 1 :=
β¨fun h => or_iff_not_imp_left.2 fun hn => differentiableAt_arcsin.1 <| h.differentiableAt <|
ENat.one_le_iff_ne_zero_withTop.mpr hn,
fun h => h.elim (fun hn => hn.symm βΈ (contDiff_zero.2 continuous_arcsin).contDiffAt) fun hx =>
contDiffAt_arcsin hx.1 hx.2β©
end Arcsin
section Arccos
theorem hasStrictDerivAt_arccos {x : β} (hβ : x β -1) (hβ : x β 1) :
HasStrictDerivAt arccos (-(1 / β(1 - x ^ 2))) x :=
(hasStrictDerivAt_arcsin hβ hβ).const_sub (Ο / 2)
theorem hasDerivAt_arccos {x : β} (hβ : x β -1) (hβ : x β 1) :
HasDerivAt arccos (-(1 / β(1 - x ^ 2))) x :=
(hasDerivAt_arcsin hβ hβ).const_sub (Ο / 2)
theorem contDiffAt_arccos {x : β} (hβ : x β -1) (hβ : x β 1) {n : WithTop ββ} :
ContDiffAt β n arccos x :=
contDiffAt_const.sub (contDiffAt_arcsin hβ hβ)
theorem hasDerivWithinAt_arccos_Ici {x : β} (h : x β -1) :
HasDerivWithinAt arccos (-(1 / β(1 - x ^ 2))) (Ici x) x :=
(hasDerivWithinAt_arcsin_Ici h).const_sub _
theorem hasDerivWithinAt_arccos_Iic {x : β} (h : x β 1) :
HasDerivWithinAt arccos (-(1 / β(1 - x ^ 2))) (Iic x) x :=
(hasDerivWithinAt_arcsin_Iic h).const_sub _
theorem differentiableWithinAt_arccos_Ici {x : β} :
DifferentiableWithinAt β arccos (Ici x) x β x β -1 :=
(differentiableWithinAt_const_sub_iff _).trans differentiableWithinAt_arcsin_Ici
theorem differentiableWithinAt_arccos_Iic {x : β} :
DifferentiableWithinAt β arccos (Iic x) x β x β 1 :=
(differentiableWithinAt_const_sub_iff _).trans differentiableWithinAt_arcsin_Iic
theorem differentiableAt_arccos {x : β} : DifferentiableAt β arccos x β x β -1 β§ x β 1 :=
(differentiableAt_const _).sub_iff_right.trans differentiableAt_arcsin
@[simp]
theorem deriv_arccos : deriv arccos = fun x => -(1 / β(1 - x ^ 2)) :=
funext fun x => (deriv_const_sub _).trans <| by simp only [deriv_arcsin]
theorem differentiableOn_arccos : DifferentiableOn β arccos {-1, 1}αΆ :=
differentiableOn_arcsin.const_sub _
theorem contDiffOn_arccos {n : WithTop ββ} : ContDiffOn β n arccos {-1, 1}αΆ :=
contDiffOn_const.sub contDiffOn_arcsin
theorem contDiffAt_arccos_iff {x : β} {n : WithTop ββ} :
ContDiffAt β n arccos x β n = 0 β¨ x β -1 β§ x β 1 := by
refine Iff.trans β¨fun h => ?_, fun h => ?_β© contDiffAt_arcsin_iff <;>
simpa [arccos] using (contDiffAt_const (c := Ο / 2)).sub h
end Arccos
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean | import Mathlib.Algebra.Field.NegOnePow
import Mathlib.Algebra.Field.Periodic
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.SpecialFunctions.Exp
/-!
# Trigonometric functions
## Main definitions
This file contains the definition of `Ο`.
See also `Analysis.SpecialFunctions.Trigonometric.Inverse` and
`Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse trigonometric functions.
See also `Analysis.SpecialFunctions.Complex.Arg` and
`Analysis.SpecialFunctions.Complex.Log` for the complex argument function
and the complex logarithm.
## Main statements
Many basic inequalities on the real trigonometric functions are established.
The continuity of the usual trigonometric functions is proved.
Several facts about the real trigonometric functions have the proofs deferred to
`Analysis.SpecialFunctions.Trigonometric.Complex`,
as they are most easily proved by appealing to the corresponding fact for
complex trigonometric functions.
See also `Analysis.SpecialFunctions.Trigonometric.Chebyshev` for the multiple angle formulas
in terms of Chebyshev polynomials.
## Tags
sin, cos, tan, angle
-/
noncomputable section
open Topology Filter Set
namespace Complex
@[continuity, fun_prop]
theorem continuous_sin : Continuous sin := by
change Continuous fun z => (exp (-z * I) - exp (z * I)) * I / 2
fun_prop
@[fun_prop]
theorem continuousOn_sin {s : Set β} : ContinuousOn sin s :=
continuous_sin.continuousOn
@[continuity, fun_prop]
theorem continuous_cos : Continuous cos := by
change Continuous fun z => (exp (z * I) + exp (-z * I)) / 2
fun_prop
@[fun_prop]
theorem continuousOn_cos {s : Set β} : ContinuousOn cos s :=
continuous_cos.continuousOn
@[continuity, fun_prop]
theorem continuous_sinh : Continuous sinh := by
change Continuous fun z => (exp z - exp (-z)) / 2
fun_prop
@[continuity, fun_prop]
theorem continuous_cosh : Continuous cosh := by
change Continuous fun z => (exp z + exp (-z)) / 2
fun_prop
end Complex
namespace Real
variable {x y z : β}
@[continuity, fun_prop]
theorem continuous_sin : Continuous sin :=
Complex.continuous_re.comp (Complex.continuous_sin.comp Complex.continuous_ofReal)
@[fun_prop]
theorem continuousOn_sin {s} : ContinuousOn sin s :=
continuous_sin.continuousOn
@[continuity, fun_prop]
theorem continuous_cos : Continuous cos :=
Complex.continuous_re.comp (Complex.continuous_cos.comp Complex.continuous_ofReal)
@[fun_prop]
theorem continuousOn_cos {s} : ContinuousOn cos s :=
continuous_cos.continuousOn
@[continuity, fun_prop]
theorem continuous_sinh : Continuous sinh :=
Complex.continuous_re.comp (Complex.continuous_sinh.comp Complex.continuous_ofReal)
@[continuity, fun_prop]
theorem continuous_cosh : Continuous cosh :=
Complex.continuous_re.comp (Complex.continuous_cosh.comp Complex.continuous_ofReal)
end Real
namespace Real
theorem exists_cos_eq_zero : 0 β cos '' Icc (1 : β) 2 :=
intermediate_value_Icc' (by simp) continuousOn_cos
β¨le_of_lt cos_two_neg, le_of_lt cos_one_posβ©
/-- The number Ο = 3.14159265... Defined here using choice as twice a zero of cos in [1,2],
from which one can derive all its properties. For explicit bounds on Ο,
see `Mathlib/Analysis/Real/Pi/Bounds.lean`.
Denoted `Ο`, once the `Real` namespace is opened. -/
protected noncomputable def pi : β :=
2 * Classical.choose exists_cos_eq_zero
@[inherit_doc]
scoped notation "Ο" => Real.pi
@[simp]
theorem cos_pi_div_two : cos (Ο / 2) = 0 := by
rw [Real.pi, mul_div_cancel_leftβ _ two_ne_zero]
exact (Classical.choose_spec exists_cos_eq_zero).2
theorem one_le_pi_div_two : (1 : β) β€ Ο / 2 := by
rw [Real.pi, mul_div_cancel_leftβ _ two_ne_zero]
exact (Classical.choose_spec exists_cos_eq_zero).1.1
theorem pi_div_two_le_two : Ο / 2 β€ 2 := by
rw [Real.pi, mul_div_cancel_leftβ _ two_ne_zero]
exact (Classical.choose_spec exists_cos_eq_zero).1.2
theorem two_le_pi : (2 : β) β€ Ο :=
(div_le_div_iff_of_pos_right zero_lt_two).1
(by rw [div_self two_ne_zero]; exact one_le_pi_div_two)
theorem pi_le_four : Ο β€ 4 :=
(div_le_div_iff_of_pos_right zero_lt_two).1
(calc
Ο / 2 β€ 2 := pi_div_two_le_two
_ = 4 / 2 := by norm_num)
@[bound]
theorem pi_pos : 0 < Ο :=
lt_of_lt_of_le (by simp) two_le_pi
@[bound]
theorem pi_nonneg : 0 β€ Ο :=
pi_pos.le
@[simp]
theorem pi_ne_zero : Ο β 0 :=
pi_pos.ne'
theorem pi_div_two_pos : 0 < Ο / 2 :=
half_pos pi_pos
theorem two_pi_pos : 0 < 2 * Ο := by linarith [pi_pos]
end Real
namespace Mathlib.Meta.Positivity
open Lean.Meta Qq
/-- Extension for the `positivity` tactic: `Ο` is always positive. -/
@[positivity Real.pi]
def evalRealPi : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.pi) =>
assertInstancesCommute
pure (.positive q(Real.pi_pos))
| _, _, _ => throwError "not Real.pi"
end Mathlib.Meta.Positivity
namespace NNReal
open Real
open Real NNReal
/-- `Ο` considered as a nonnegative real. -/
noncomputable def pi : ββ₯0 :=
β¨Ο, Real.pi_pos.leβ©
@[simp]
theorem coe_real_pi : (pi : β) = Ο :=
rfl
theorem pi_pos : 0 < pi := mod_cast Real.pi_pos
theorem pi_ne_zero : pi β 0 :=
pi_pos.ne'
end NNReal
namespace Real
@[simp]
theorem sin_pi : sin Ο = 0 := by
rw [β mul_div_cancel_leftβ Ο two_ne_zero, two_mul, add_div, sin_add, cos_pi_div_two]; simp
@[simp]
theorem cos_pi : cos Ο = -1 := by
rw [β mul_div_cancel_leftβ Ο two_ne_zero, mul_div_assoc, cos_two_mul, cos_pi_div_two]
norm_num
@[simp]
theorem sin_two_pi : sin (2 * Ο) = 0 := by simp [two_mul, sin_add]
@[simp]
theorem cos_two_pi : cos (2 * Ο) = 1 := by simp [two_mul, cos_add]
theorem sin_antiperiodic : Function.Antiperiodic sin Ο := by simp [sin_add]
theorem sin_periodic : Function.Periodic sin (2 * Ο) :=
sin_antiperiodic.periodic_two_mul
@[simp]
theorem sin_add_pi (x : β) : sin (x + Ο) = -sin x :=
sin_antiperiodic x
@[simp]
theorem sin_add_two_pi (x : β) : sin (x + 2 * Ο) = sin x :=
sin_periodic x
@[simp]
theorem sin_sub_pi (x : β) : sin (x - Ο) = -sin x :=
sin_antiperiodic.sub_eq x
@[simp]
theorem sin_sub_two_pi (x : β) : sin (x - 2 * Ο) = sin x :=
sin_periodic.sub_eq x
@[simp]
theorem sin_pi_sub (x : β) : sin (Ο - x) = sin x :=
neg_neg (sin x) βΈ sin_neg x βΈ sin_antiperiodic.sub_eq'
@[simp]
theorem sin_two_pi_sub (x : β) : sin (2 * Ο - x) = -sin x :=
sin_neg x βΈ sin_periodic.sub_eq'
@[simp]
theorem sin_nat_mul_pi (n : β) : sin (n * Ο) = 0 :=
sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n
@[simp]
theorem sin_int_mul_pi (n : β€) : sin (n * Ο) = 0 :=
sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n
@[simp]
theorem sin_add_nat_mul_two_pi (x : β) (n : β) : sin (x + n * (2 * Ο)) = sin x :=
sin_periodic.nat_mul n x
@[simp]
theorem sin_add_int_mul_two_pi (x : β) (n : β€) : sin (x + n * (2 * Ο)) = sin x :=
sin_periodic.int_mul n x
@[simp]
theorem sin_sub_nat_mul_two_pi (x : β) (n : β) : sin (x - n * (2 * Ο)) = sin x :=
sin_periodic.sub_nat_mul_eq n
@[simp]
theorem sin_sub_int_mul_two_pi (x : β) (n : β€) : sin (x - n * (2 * Ο)) = sin x :=
sin_periodic.sub_int_mul_eq n
@[simp]
theorem sin_nat_mul_two_pi_sub (x : β) (n : β) : sin (n * (2 * Ο) - x) = -sin x :=
sin_neg x βΈ sin_periodic.nat_mul_sub_eq n
@[simp]
theorem sin_int_mul_two_pi_sub (x : β) (n : β€) : sin (n * (2 * Ο) - x) = -sin x :=
sin_neg x βΈ sin_periodic.int_mul_sub_eq n
theorem sin_add_int_mul_pi (x : β) (n : β€) : sin (x + n * Ο) = (-1) ^ n * sin x :=
n.cast_negOnePow β βΈ sin_antiperiodic.add_int_mul_eq n
theorem sin_add_nat_mul_pi (x : β) (n : β) : sin (x + n * Ο) = (-1) ^ n * sin x :=
sin_antiperiodic.add_nat_mul_eq n
theorem sin_sub_int_mul_pi (x : β) (n : β€) : sin (x - n * Ο) = (-1) ^ n * sin x :=
n.cast_negOnePow β βΈ sin_antiperiodic.sub_int_mul_eq n
theorem sin_sub_nat_mul_pi (x : β) (n : β) : sin (x - n * Ο) = (-1) ^ n * sin x :=
sin_antiperiodic.sub_nat_mul_eq n
theorem sin_int_mul_pi_sub (x : β) (n : β€) : sin (n * Ο - x) = -((-1) ^ n * sin x) := by
simpa only [sin_neg, mul_neg, Int.cast_negOnePow] using sin_antiperiodic.int_mul_sub_eq n
theorem sin_nat_mul_pi_sub (x : β) (n : β) : sin (n * Ο - x) = -((-1) ^ n * sin x) := by
simpa only [sin_neg, mul_neg] using sin_antiperiodic.nat_mul_sub_eq n
theorem cos_antiperiodic : Function.Antiperiodic cos Ο := by simp [cos_add]
theorem cos_periodic : Function.Periodic cos (2 * Ο) :=
cos_antiperiodic.periodic_two_mul
@[simp]
theorem abs_cos_int_mul_pi (k : β€) : |cos (k * Ο)| = 1 := by
simp [abs_cos_eq_sqrt_one_sub_sin_sq]
@[simp]
theorem cos_add_pi (x : β) : cos (x + Ο) = -cos x :=
cos_antiperiodic x
@[simp]
theorem cos_add_two_pi (x : β) : cos (x + 2 * Ο) = cos x :=
cos_periodic x
@[simp]
theorem cos_sub_pi (x : β) : cos (x - Ο) = -cos x :=
cos_antiperiodic.sub_eq x
@[simp]
theorem cos_sub_two_pi (x : β) : cos (x - 2 * Ο) = cos x :=
cos_periodic.sub_eq x
@[simp]
theorem cos_pi_sub (x : β) : cos (Ο - x) = -cos x :=
cos_neg x βΈ cos_antiperiodic.sub_eq'
@[simp]
theorem cos_two_pi_sub (x : β) : cos (2 * Ο - x) = cos x :=
cos_neg x βΈ cos_periodic.sub_eq'
@[simp]
theorem cos_nat_mul_two_pi (n : β) : cos (n * (2 * Ο)) = 1 :=
(cos_periodic.nat_mul_eq n).trans cos_zero
@[simp]
theorem cos_int_mul_two_pi (n : β€) : cos (n * (2 * Ο)) = 1 :=
(cos_periodic.int_mul_eq n).trans cos_zero
@[simp]
theorem cos_add_nat_mul_two_pi (x : β) (n : β) : cos (x + n * (2 * Ο)) = cos x :=
cos_periodic.nat_mul n x
@[simp]
theorem cos_add_int_mul_two_pi (x : β) (n : β€) : cos (x + n * (2 * Ο)) = cos x :=
cos_periodic.int_mul n x
@[simp]
theorem cos_sub_nat_mul_two_pi (x : β) (n : β) : cos (x - n * (2 * Ο)) = cos x :=
cos_periodic.sub_nat_mul_eq n
@[simp]
theorem cos_sub_int_mul_two_pi (x : β) (n : β€) : cos (x - n * (2 * Ο)) = cos x :=
cos_periodic.sub_int_mul_eq n
@[simp]
theorem cos_nat_mul_two_pi_sub (x : β) (n : β) : cos (n * (2 * Ο) - x) = cos x :=
cos_neg x βΈ cos_periodic.nat_mul_sub_eq n
@[simp]
theorem cos_int_mul_two_pi_sub (x : β) (n : β€) : cos (n * (2 * Ο) - x) = cos x :=
cos_neg x βΈ cos_periodic.int_mul_sub_eq n
theorem cos_add_int_mul_pi (x : β) (n : β€) : cos (x + n * Ο) = (-1) ^ n * cos x :=
n.cast_negOnePow β βΈ cos_antiperiodic.add_int_mul_eq n
theorem cos_add_nat_mul_pi (x : β) (n : β) : cos (x + n * Ο) = (-1) ^ n * cos x :=
cos_antiperiodic.add_nat_mul_eq n
theorem cos_sub_int_mul_pi (x : β) (n : β€) : cos (x - n * Ο) = (-1) ^ n * cos x :=
n.cast_negOnePow β βΈ cos_antiperiodic.sub_int_mul_eq n
theorem cos_sub_nat_mul_pi (x : β) (n : β) : cos (x - n * Ο) = (-1) ^ n * cos x :=
cos_antiperiodic.sub_nat_mul_eq n
theorem cos_int_mul_pi_sub (x : β) (n : β€) : cos (n * Ο - x) = (-1) ^ n * cos x :=
n.cast_negOnePow β βΈ cos_neg x βΈ cos_antiperiodic.int_mul_sub_eq n
theorem cos_nat_mul_pi_sub (x : β) (n : β) : cos (n * Ο - x) = (-1) ^ n * cos x :=
cos_neg x βΈ cos_antiperiodic.nat_mul_sub_eq n
theorem cos_nat_mul_two_pi_add_pi (n : β) : cos (n * (2 * Ο) + Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_add_pi (n : β€) : cos (n * (2 * Ο) + Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_nat_mul_two_pi_sub_pi (n : β) : cos (n * (2 * Ο) - Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_sub_pi (n : β€) : cos (n * (2 * Ο) - Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic
theorem sin_pos_of_pos_of_lt_pi {x : β} (h0x : 0 < x) (hxp : x < Ο) : 0 < sin x :=
if hx2 : x β€ 2 then sin_pos_of_pos_of_le_two h0x hx2
else sin_pi_sub x βΈ sin_pos_of_pos_of_le_two (sub_pos.2 hxp) (by linarith [pi_le_four])
theorem sin_pos_of_mem_Ioo {x : β} (hx : x β Ioo 0 Ο) : 0 < sin x :=
sin_pos_of_pos_of_lt_pi hx.1 hx.2
theorem sin_nonneg_of_mem_Icc {x : β} (hx : x β Icc 0 Ο) : 0 β€ sin x := by
rw [β closure_Ioo pi_ne_zero.symm] at hx
exact
closure_lt_subset_le continuous_const continuous_sin
(closure_mono (fun y => sin_pos_of_mem_Ioo) hx)
theorem sin_nonneg_of_nonneg_of_le_pi {x : β} (h0x : 0 β€ x) (hxp : x β€ Ο) : 0 β€ sin x :=
sin_nonneg_of_mem_Icc β¨h0x, hxpβ©
theorem sin_neg_of_neg_of_neg_pi_lt {x : β} (hx0 : x < 0) (hpx : -Ο < x) : sin x < 0 :=
neg_pos.1 <| sin_neg x βΈ sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx)
theorem sin_nonpos_of_nonpos_of_neg_pi_le {x : β} (hx0 : x β€ 0) (hpx : -Ο β€ x) : sin x β€ 0 :=
neg_nonneg.1 <| sin_neg x βΈ sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx)
@[deprecated (since := "2025-07-27")]
alias sin_nonpos_of_nonnpos_of_neg_pi_le := sin_nonpos_of_nonpos_of_neg_pi_le
@[simp]
theorem sin_pi_div_two : sin (Ο / 2) = 1 :=
have : sin (Ο / 2) = 1 β¨ sin (Ο / 2) = -1 := by
simpa [sq, mul_self_eq_one_iff] using sin_sq_add_cos_sq (Ο / 2)
this.resolve_right fun h =>
show Β¬(0 : β) < -1 by simp <|
h βΈ sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos)
theorem sin_add_pi_div_two (x : β) : sin (x + Ο / 2) = cos x := by simp [sin_add]
theorem sin_sub_pi_div_two (x : β) : sin (x - Ο / 2) = -cos x := by simp [sub_eq_add_neg, sin_add]
theorem sin_pi_div_two_sub (x : β) : sin (Ο / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add]
theorem cos_add_pi_div_two (x : β) : cos (x + Ο / 2) = -sin x := by simp [cos_add]
theorem cos_sub_pi_div_two (x : β) : cos (x - Ο / 2) = sin x := by simp [sub_eq_add_neg, cos_add]
theorem cos_pi_div_two_sub (x : β) : cos (Ο / 2 - x) = sin x := by
rw [β cos_neg, neg_sub, cos_sub_pi_div_two]
theorem cos_pos_of_mem_Ioo {x : β} (hx : x β Ioo (-(Ο / 2)) (Ο / 2)) : 0 < cos x :=
sin_add_pi_div_two x βΈ sin_pos_of_mem_Ioo β¨by linarith [hx.1], by linarith [hx.2]β©
theorem cos_nonneg_of_mem_Icc {x : β} (hx : x β Icc (-(Ο / 2)) (Ο / 2)) : 0 β€ cos x :=
sin_add_pi_div_two x βΈ sin_nonneg_of_mem_Icc β¨by linarith [hx.1], by linarith [hx.2]β©
theorem cos_nonneg_of_neg_pi_div_two_le_of_le {x : β} (hl : -(Ο / 2) β€ x) (hu : x β€ Ο / 2) :
0 β€ cos x :=
cos_nonneg_of_mem_Icc β¨hl, huβ©
theorem cos_neg_of_pi_div_two_lt_of_lt {x : β} (hxβ : Ο / 2 < x) (hxβ : x < Ο + Ο / 2) :
cos x < 0 :=
neg_pos.1 <| cos_pi_sub x βΈ cos_pos_of_mem_Ioo β¨by linarith, by linarithβ©
theorem cos_nonpos_of_pi_div_two_le_of_le {x : β} (hxβ : Ο / 2 β€ x) (hxβ : x β€ Ο + Ο / 2) :
cos x β€ 0 :=
neg_nonneg.1 <| cos_pi_sub x βΈ cos_nonneg_of_mem_Icc β¨by linarith, by linarithβ©
theorem sin_eq_sqrt_one_sub_cos_sq {x : β} (hl : 0 β€ x) (hu : x β€ Ο) :
sin x = β(1 - cos x ^ 2) := by
rw [β abs_sin_eq_sqrt_one_sub_cos_sq, abs_of_nonneg (sin_nonneg_of_nonneg_of_le_pi hl hu)]
theorem cos_eq_sqrt_one_sub_sin_sq {x : β} (hl : -(Ο / 2) β€ x) (hu : x β€ Ο / 2) :
cos x = β(1 - sin x ^ 2) := by
rw [β abs_cos_eq_sqrt_one_sub_sin_sq, abs_of_nonneg (cos_nonneg_of_mem_Icc β¨hl, huβ©)]
lemma cos_half {x : β} (hl : -Ο β€ x) (hr : x β€ Ο) : cos (x / 2) = β((1 + cos x) / 2) := by
have : 0 β€ cos (x / 2) := cos_nonneg_of_mem_Icc <| by constructor <;> linarith
rw [β sqrt_sq this, cos_sq, add_div, two_mul, add_halves]
lemma abs_sin_half (x : β) : |sin (x / 2)| = β((1 - cos x) / 2) := by
rw [β sqrt_sq_eq_abs, sin_sq_eq_half_sub, two_mul, add_halves, sub_div]
lemma sin_half_eq_sqrt {x : β} (hl : 0 β€ x) (hr : x β€ 2 * Ο) :
sin (x / 2) = β((1 - cos x) / 2) := by
rw [β abs_sin_half, abs_of_nonneg]
apply sin_nonneg_of_nonneg_of_le_pi <;> linarith
lemma sin_half_eq_neg_sqrt {x : β} (hl : -(2 * Ο) β€ x) (hr : x β€ 0) :
sin (x / 2) = -β((1 - cos x) / 2) := by
rw [β abs_sin_half, abs_of_nonpos, neg_neg]
apply sin_nonpos_of_nonpos_of_neg_pi_le <;> linarith
theorem sin_eq_zero_iff_of_lt_of_lt {x : β} (hxβ : -Ο < x) (hxβ : x < Ο) : sin x = 0 β x = 0 :=
β¨fun h => by
contrapose! h
cases h.lt_or_gt with
| inl h0 => exact (sin_neg_of_neg_of_neg_pi_lt h0 hxβ).ne
| inr h0 => exact (sin_pos_of_pos_of_lt_pi h0 hxβ).ne',
fun h => by simp [h]β©
theorem sin_eq_zero_iff {x : β} : sin x = 0 β β n : β€, (n : β) * Ο = x :=
β¨fun h =>
β¨βx / Οβ,
le_antisymm (sub_nonneg.1 (Int.sub_floor_div_mul_nonneg _ pi_pos))
(sub_nonpos.1 <|
le_of_not_gt fun hβ =>
(sin_pos_of_pos_of_lt_pi hβ (Int.sub_floor_div_mul_lt _ pi_pos)).ne
(by simp [sub_eq_add_neg, sin_add, h, sin_int_mul_pi]))β©,
fun β¨_, hnβ© => hn βΈ sin_int_mul_pi _β©
theorem sin_ne_zero_iff {x : β} : sin x β 0 β β n : β€, (n : β) * Ο β x := by
rw [β not_exists, not_iff_not, sin_eq_zero_iff]
theorem sin_eq_zero_iff_cos_eq {x : β} : sin x = 0 β cos x = 1 β¨ cos x = -1 := by
rw [β mul_self_eq_one_iff, β sin_sq_add_cos_sq, sq, sq, right_eq_add, mul_eq_zero, or_self]
theorem cos_eq_zero_iff_sin_eq {x : β} : cos x = 0 β sin x = 1 β¨ sin x = -1 := by
rw [β mul_self_eq_one_iff, β sin_sq_add_cos_sq, sq, sq, left_eq_add, mul_eq_zero, or_self]
theorem cos_eq_one_iff (x : β) : cos x = 1 β β n : β€, (n : β) * (2 * Ο) = x :=
β¨fun h =>
let β¨n, hnβ© := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (Or.inl h))
β¨n / 2,
(Int.emod_two_eq_zero_or_one n).elim
(fun hn0 => by
rwa [β mul_assoc, β @Int.cast_two β, β Int.cast_mul,
Int.ediv_mul_cancel (Int.dvd_iff_emod_eq_zero.2 hn0)])
fun hn1 => by
rw [β Int.emod_add_mul_ediv n 2, hn1, Int.cast_add, Int.cast_one, add_mul, one_mul,
add_comm, mul_comm (2 : β€), Int.cast_mul, mul_assoc, Int.cast_two] at hn
rw [β hn, cos_int_mul_two_pi_add_pi] at h
exact absurd h (by norm_num)β©,
fun β¨_, hnβ© => hn βΈ cos_int_mul_two_pi _β©
theorem cos_eq_one_iff_of_lt_of_lt {x : β} (hxβ : -(2 * Ο) < x) (hxβ : x < 2 * Ο) :
cos x = 1 β x = 0 :=
β¨fun h => by
rcases (cos_eq_one_iff _).1 h with β¨n, rflβ©
rw [mul_lt_iff_lt_one_left two_pi_pos] at hxβ
rw [neg_lt, neg_mul_eq_neg_mul, mul_lt_iff_lt_one_left two_pi_pos] at hxβ
norm_cast at hxβ hxβ
obtain rfl : n = 0 := le_antisymm (by cutsat) (by cutsat)
simp, fun h => by simp [h]β©
theorem sin_lt_sin_of_lt_of_le_pi_div_two {x y : β} (hxβ : -(Ο / 2) β€ x) (hyβ : y β€ Ο / 2)
(hxy : x < y) : sin x < sin y := by
rw [β sub_pos, sin_sub_sin]
have : 0 < sin ((y - x) / 2) := by apply sin_pos_of_pos_of_lt_pi <;> linarith
have : 0 < cos ((y + x) / 2) := by refine cos_pos_of_mem_Ioo β¨?_, ?_β© <;> linarith
positivity
theorem strictMonoOn_sin : StrictMonoOn sin (Icc (-(Ο / 2)) (Ο / 2)) := fun _ hx _ hy hxy =>
sin_lt_sin_of_lt_of_le_pi_div_two hx.1 hy.2 hxy
theorem monotoneOn_sin : MonotoneOn sin (Set.Icc (-(Ο / 2)) (Ο / 2)) :=
strictMonoOn_sin.monotoneOn
theorem cos_lt_cos_of_nonneg_of_le_pi {x y : β} (hxβ : 0 β€ x) (hyβ : y β€ Ο) (hxy : x < y) :
cos y < cos x := by
rw [β sin_pi_div_two_sub, β sin_pi_div_two_sub]
apply sin_lt_sin_of_lt_of_le_pi_div_two <;> linarith
theorem cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : β} (hxβ : 0 β€ x) (hyβ : y β€ Ο / 2)
(hxy : x < y) : cos y < cos x :=
cos_lt_cos_of_nonneg_of_le_pi hxβ (hyβ.trans (by linarith)) hxy
theorem strictAntiOn_cos : StrictAntiOn cos (Icc 0 Ο) := fun _ hx _ hy hxy =>
cos_lt_cos_of_nonneg_of_le_pi hx.1 hy.2 hxy
theorem antitoneOn_cos : AntitoneOn cos (Set.Icc 0 Ο) :=
strictAntiOn_cos.antitoneOn
theorem cos_le_cos_of_nonneg_of_le_pi {x y : β} (hxβ : 0 β€ x) (hyβ : y β€ Ο) (hxy : x β€ y) :
cos y β€ cos x :=
(strictAntiOn_cos.le_iff_ge β¨hxβ.trans hxy, hyββ© β¨hxβ, hxy.trans hyββ©).2 hxy
theorem sin_le_sin_of_le_of_le_pi_div_two {x y : β} (hxβ : -(Ο / 2) β€ x) (hyβ : y β€ Ο / 2)
(hxy : x β€ y) : sin x β€ sin y :=
(strictMonoOn_sin.le_iff_le β¨hxβ, hxy.trans hyββ© β¨hxβ.trans hxy, hyββ©).2 hxy
theorem injOn_sin : InjOn sin (Icc (-(Ο / 2)) (Ο / 2)) :=
strictMonoOn_sin.injOn
theorem injOn_cos : InjOn cos (Icc 0 Ο) :=
strictAntiOn_cos.injOn
theorem surjOn_sin : SurjOn sin (Icc (-(Ο / 2)) (Ο / 2)) (Icc (-1) 1) := by
simpa only [sin_neg, sin_pi_div_two] using
intermediate_value_Icc (neg_le_self pi_div_two_pos.le) continuous_sin.continuousOn
theorem surjOn_cos : SurjOn cos (Icc 0 Ο) (Icc (-1) 1) := by
simpa only [cos_zero, cos_pi] using intermediate_value_Icc' pi_pos.le continuous_cos.continuousOn
theorem sin_mem_Icc (x : β) : sin x β Icc (-1 : β) 1 :=
β¨neg_one_le_sin x, sin_le_one xβ©
theorem cos_mem_Icc (x : β) : cos x β Icc (-1 : β) 1 :=
β¨neg_one_le_cos x, cos_le_one xβ©
theorem mapsTo_sin (s : Set β) : MapsTo sin s (Icc (-1 : β) 1) := fun x _ => sin_mem_Icc x
theorem mapsTo_cos (s : Set β) : MapsTo cos s (Icc (-1 : β) 1) := fun x _ => cos_mem_Icc x
theorem bijOn_sin : BijOn sin (Icc (-(Ο / 2)) (Ο / 2)) (Icc (-1) 1) :=
β¨mapsTo_sin _, injOn_sin, surjOn_sinβ©
theorem bijOn_cos : BijOn cos (Icc 0 Ο) (Icc (-1) 1) :=
β¨mapsTo_cos _, injOn_cos, surjOn_cosβ©
@[simp]
theorem range_cos : range cos = (Icc (-1) 1 : Set β) :=
Subset.antisymm (range_subset_iff.2 cos_mem_Icc) surjOn_cos.subset_range
@[simp]
theorem range_sin : range sin = (Icc (-1) 1 : Set β) :=
Subset.antisymm (range_subset_iff.2 sin_mem_Icc) surjOn_sin.subset_range
theorem range_cos_infinite : (range Real.cos).Infinite := by
rw [Real.range_cos]
exact Icc_infinite (by simp)
theorem range_sin_infinite : (range Real.sin).Infinite := by
rw [Real.range_sin]
exact Icc_infinite (by simp)
section CosDivSq
variable (x : β)
/-- the series `sqrtTwoAddSeries x n` is `sqrt(2 + sqrt(2 + ... ))` with `n` square roots,
starting with `x`. We define it here because `cos (pi / 2 ^ (n+1)) = sqrtTwoAddSeries 0 n / 2`
-/
@[simp]
noncomputable def sqrtTwoAddSeries (x : β) : β β β
| 0 => x
| n + 1 => β(2 + sqrtTwoAddSeries x n)
theorem sqrtTwoAddSeries_zero : sqrtTwoAddSeries x 0 = x := by simp
theorem sqrtTwoAddSeries_one : sqrtTwoAddSeries 0 1 = β2 := by simp
theorem sqrtTwoAddSeries_two : sqrtTwoAddSeries 0 2 = β(2 + β2) := by simp
theorem sqrtTwoAddSeries_zero_nonneg : β n : β, 0 β€ sqrtTwoAddSeries 0 n
| 0 => le_refl 0
| _ + 1 => sqrt_nonneg _
theorem sqrtTwoAddSeries_nonneg {x : β} (h : 0 β€ x) : β n : β, 0 β€ sqrtTwoAddSeries x n
| 0 => h
| _ + 1 => sqrt_nonneg _
theorem sqrtTwoAddSeries_lt_two : β n : β, sqrtTwoAddSeries 0 n < 2
| 0 => by simp
| n + 1 => by
refine lt_of_lt_of_le ?_ (sqrt_sq zero_lt_two.le).le
rw [sqrtTwoAddSeries, sqrt_lt_sqrt_iff, β lt_sub_iff_add_lt']
Β· refine (sqrtTwoAddSeries_lt_two n).trans_le ?_
norm_num
Β· exact add_nonneg zero_le_two (sqrtTwoAddSeries_zero_nonneg n)
theorem sqrtTwoAddSeries_succ (x : β) :
β n : β, sqrtTwoAddSeries x (n + 1) = sqrtTwoAddSeries (β(2 + x)) n
| 0 => rfl
| n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries_succ _ _, sqrtTwoAddSeries]
@[gcongr]
theorem sqrtTwoAddSeries_monotone_left {x y : β} (h : x β€ y) :
β n : β, sqrtTwoAddSeries x n β€ sqrtTwoAddSeries y n
| 0 => h
| n + 1 => by
rw [sqrtTwoAddSeries, sqrtTwoAddSeries]; gcongr; exact sqrtTwoAddSeries_monotone_left h _
@[simp]
theorem cos_pi_over_two_pow : β n : β, cos (Ο / 2 ^ (n + 1)) = sqrtTwoAddSeries 0 n / 2
| 0 => by simp
| n + 1 => by
have A : (1 : β) < 2 ^ (n + 1) := one_lt_powβ one_lt_two n.succ_ne_zero
have B : Ο / 2 ^ (n + 1) < Ο := div_lt_self pi_pos A
have C : 0 < Ο / 2 ^ (n + 1) := by positivity
rw [pow_succ, div_mul_eq_div_div, cos_half, cos_pi_over_two_pow n, sqrtTwoAddSeries,
add_div_eq_mul_add_div, one_mul, β div_mul_eq_div_div, sqrt_div, sqrt_mul_self] <;>
linarith [sqrtTwoAddSeries_nonneg le_rfl n]
theorem sin_sq_pi_over_two_pow (n : β) :
sin (Ο / 2 ^ (n + 1)) ^ 2 = 1 - (sqrtTwoAddSeries 0 n / 2) ^ 2 := by
rw [sin_sq, cos_pi_over_two_pow]
theorem sin_sq_pi_over_two_pow_succ (n : β) :
sin (Ο / 2 ^ (n + 2)) ^ 2 = 1 / 2 - sqrtTwoAddSeries 0 n / 4 := by
rw [sin_sq_pi_over_two_pow, sqrtTwoAddSeries, div_pow, sq_sqrt, add_div, β sub_sub]
Β· congr
Β· norm_num
Β· norm_num
Β· exact add_nonneg two_pos.le (sqrtTwoAddSeries_zero_nonneg _)
@[simp]
theorem sin_pi_over_two_pow_succ (n : β) :
sin (Ο / 2 ^ (n + 2)) = β(2 - sqrtTwoAddSeries 0 n) / 2 := by
rw [eq_div_iff_mul_eq two_ne_zero, eq_comm, sqrt_eq_iff_eq_sq, mul_pow,
sin_sq_pi_over_two_pow_succ, sub_mul]
Β· congr <;> norm_num
Β· rw [sub_nonneg]
exact (sqrtTwoAddSeries_lt_two _).le
refine mul_nonneg (sin_nonneg_of_nonneg_of_le_pi ?_ ?_) zero_le_two
Β· positivity
Β· exact div_le_self pi_pos.le <| one_le_powβ one_le_two
@[simp]
theorem cos_pi_div_four : cos (Ο / 4) = β2 / 2 := by
trans cos (Ο / 2 ^ 2)
Β· congr
norm_num
Β· simp
@[simp]
theorem sin_pi_div_four : sin (Ο / 4) = β2 / 2 := by
trans sin (Ο / 2 ^ 2)
Β· congr
norm_num
Β· simp
@[simp]
theorem cos_pi_div_eight : cos (Ο / 8) = β(2 + β2) / 2 := by
trans cos (Ο / 2 ^ 3)
Β· congr
norm_num
Β· simp
@[simp]
theorem sin_pi_div_eight : sin (Ο / 8) = β(2 - β2) / 2 := by
trans sin (Ο / 2 ^ 3)
Β· congr
norm_num
Β· simp
@[simp]
theorem cos_pi_div_sixteen : cos (Ο / 16) = β(2 + β(2 + β2)) / 2 := by
trans cos (Ο / 2 ^ 4)
Β· congr
norm_num
Β· simp
@[simp]
theorem sin_pi_div_sixteen : sin (Ο / 16) = β(2 - β(2 + β2)) / 2 := by
trans sin (Ο / 2 ^ 4)
Β· congr
norm_num
Β· simp
@[simp]
theorem cos_pi_div_thirty_two : cos (Ο / 32) = β(2 + β(2 + β(2 + β2))) / 2 := by
trans cos (Ο / 2 ^ 5)
Β· congr
norm_num
Β· simp
@[simp]
theorem sin_pi_div_thirty_two : sin (Ο / 32) = β(2 - β(2 + β(2 + β2))) / 2 := by
trans sin (Ο / 2 ^ 5)
Β· congr
norm_num
Β· simp
-- This section is also a convenient location for other explicit values of `sin` and `cos`.
/-- The cosine of `Ο / 3` is `1 / 2`. -/
@[simp]
theorem cos_pi_div_three : cos (Ο / 3) = 1 / 2 := by
have hβ : (2 * cos (Ο / 3) - 1) ^ 2 * (2 * cos (Ο / 3) + 2) = 0 := by
have : cos (3 * (Ο / 3)) = cos Ο := by
congr 1
ring
linarith [cos_pi, cos_three_mul (Ο / 3)]
rcases mul_eq_zero.mp hβ with h | h
Β· linarith [eq_zero_of_pow_eq_zero h]
Β· have : cos Ο < cos (Ο / 3) := by
refine cos_lt_cos_of_nonneg_of_le_pi ?_ le_rfl ?_ <;> linarith [pi_pos]
linarith [cos_pi]
/-- The cosine of `Ο / 6` is `β3 / 2`. -/
@[simp]
theorem cos_pi_div_six : cos (Ο / 6) = β3 / 2 := by
rw [show (6 : β) = 3 * 2 by norm_num, div_mul_eq_div_div, cos_half, cos_pi_div_three, one_add_div,
β div_mul_eq_div_div, two_add_one_eq_three, sqrt_div, sqrt_mul_self] <;> linarith [pi_pos]
/-- The square of the cosine of `Ο / 6` is `3 / 4` (this is sometimes more convenient than the
result for cosine itself). -/
theorem sq_cos_pi_div_six : cos (Ο / 6) ^ 2 = 3 / 4 := by
rw [cos_pi_div_six, div_pow, sq_sqrt] <;> norm_num
/-- The sine of `Ο / 6` is `1 / 2`. -/
@[simp]
theorem sin_pi_div_six : sin (Ο / 6) = 1 / 2 := by
rw [β cos_pi_div_two_sub, β cos_pi_div_three]
congr
ring
/-- The square of the sine of `Ο / 3` is `3 / 4` (this is sometimes more convenient than the
result for cosine itself). -/
theorem sq_sin_pi_div_three : sin (Ο / 3) ^ 2 = 3 / 4 := by
rw [β cos_pi_div_two_sub, β sq_cos_pi_div_six]
congr
ring
/-- The sine of `Ο / 3` is `β3 / 2`. -/
@[simp]
theorem sin_pi_div_three : sin (Ο / 3) = β3 / 2 := by
rw [β cos_pi_div_two_sub, β cos_pi_div_six]
congr
ring
theorem quadratic_root_cos_pi_div_five :
letI c := cos (Ο / 5)
4 * c ^ 2 - 2 * c - 1 = 0 := by
set ΞΈ := Ο / 5 with hΞΈ
set c := cos ΞΈ
set s := sin ΞΈ
suffices 2 * c = 4 * c ^ 2 - 1 by simp [this]
have hs : s β 0 := by
rw [ne_eq, sin_eq_zero_iff, hΞΈ]
push_neg
intro n hn
replace hn : n * 5 = 1 := by field_simp at hn; norm_cast at hn
omega
suffices s * (2 * c) = s * (4 * c ^ 2 - 1) from mul_left_cancelβ hs this
calc s * (2 * c) = 2 * s * c := by rw [β mul_assoc, mul_comm 2]
_ = sin (2 * ΞΈ) := by rw [sin_two_mul]
_ = sin (Ο - 2 * ΞΈ) := by rw [sin_pi_sub]
_ = sin (2 * ΞΈ + ΞΈ) := by congr; linarith
_ = sin (2 * ΞΈ) * c + cos (2 * ΞΈ) * s := sin_add (2 * ΞΈ) ΞΈ
_ = 2 * s * c * c + cos (2 * ΞΈ) * s := by rw [sin_two_mul]
_ = 2 * s * c * c + (2 * c ^ 2 - 1) * s := by rw [cos_two_mul]
_ = s * (2 * c * c) + s * (2 * c ^ 2 - 1) := by linarith
_ = s * (4 * c ^ 2 - 1) := by linarith
open Polynomial in
theorem Polynomial.isRoot_cos_pi_div_five :
(4 β’ X ^ 2 - 2 β’ X - C 1 : β[X]).IsRoot (cos (Ο / 5)) := by
simpa using quadratic_root_cos_pi_div_five
/-- The cosine of `Ο / 5` is `(1 + β5) / 4`. -/
@[simp]
theorem cos_pi_div_five : cos (Ο / 5) = (1 + β5) / 4 := by
set c := cos (Ο / 5)
have : 4 * (c * c) + (-2) * c + (-1) = 0 := by
rw [β sq, neg_mul, β sub_eq_add_neg, β sub_eq_add_neg]
exact quadratic_root_cos_pi_div_five
have hd : discrim 4 (-2) (-1) = (2 * β5) * (2 * β5) := by norm_num [discrim, mul_mul_mul_comm]
rcases (quadratic_eq_zero_iff (by simp) hd c).mp this with h | h
Β· simp [h]; linarith
Β· absurd (show 0 β€ c from cos_nonneg_of_mem_Icc <| by constructor <;> linarith [pi_pos.le])
rw [not_le, h]
exact div_neg_of_neg_of_pos (by norm_num [lt_sqrt]) (by positivity)
end CosDivSq
/-- `Real.sin` as an `OrderIso` between `[-(Ο / 2), Ο / 2]` and `[-1, 1]`. -/
def sinOrderIso : Icc (-(Ο / 2)) (Ο / 2) βo Icc (-1 : β) 1 :=
(strictMonoOn_sin.orderIso _ _).trans <| OrderIso.setCongr _ _ bijOn_sin.image_eq
@[simp]
theorem coe_sinOrderIso_apply (x : Icc (-(Ο / 2)) (Ο / 2)) : (sinOrderIso x : β) = sin x :=
rfl
theorem sinOrderIso_apply (x : Icc (-(Ο / 2)) (Ο / 2)) : sinOrderIso x = β¨sin x, sin_mem_Icc xβ© :=
rfl
@[simp]
theorem tan_pi_div_four : tan (Ο / 4) = 1 := by
rw [tan_eq_sin_div_cos, cos_pi_div_four, sin_pi_div_four]
have h : β2 / 2 > 0 := by positivity
exact div_self (ne_of_gt h)
@[simp]
theorem tan_pi_div_two : tan (Ο / 2) = 0 := by simp [tan_eq_sin_div_cos]
@[simp]
theorem tan_pi_div_six : tan (Ο / 6) = 1 / β3 := by
rw [tan_eq_sin_div_cos, sin_pi_div_six, cos_pi_div_six]
ring
@[simp]
theorem tan_pi_div_three : tan (Ο / 3) = β3 := by
rw [tan_eq_sin_div_cos, sin_pi_div_three, cos_pi_div_three]
ring
theorem tan_pos_of_pos_of_lt_pi_div_two {x : β} (h0x : 0 < x) (hxp : x < Ο / 2) : 0 < tan x := by
rw [tan_eq_sin_div_cos]
exact div_pos (sin_pos_of_pos_of_lt_pi h0x (by linarith)) (cos_pos_of_mem_Ioo β¨by linarith, hxpβ©)
theorem tan_nonneg_of_nonneg_of_le_pi_div_two {x : β} (h0x : 0 β€ x) (hxp : x β€ Ο / 2) : 0 β€ tan x :=
match lt_or_eq_of_le h0x, lt_or_eq_of_le hxp with
| Or.inl hx0, Or.inl hxp => le_of_lt (tan_pos_of_pos_of_lt_pi_div_two hx0 hxp)
| Or.inl _, Or.inr hxp => by simp [hxp, tan_eq_sin_div_cos]
| Or.inr hx0, _ => by simp [hx0.symm]
theorem tan_neg_of_neg_of_pi_div_two_lt {x : β} (hx0 : x < 0) (hpx : -(Ο / 2) < x) : tan x < 0 :=
neg_pos.1 (tan_neg x βΈ tan_pos_of_pos_of_lt_pi_div_two (by linarith) (by linarith [pi_pos]))
theorem tan_nonpos_of_nonpos_of_neg_pi_div_two_le {x : β} (hx0 : x β€ 0) (hpx : -(Ο / 2) β€ x) :
tan x β€ 0 :=
neg_nonneg.1 (tan_neg x βΈ tan_nonneg_of_nonneg_of_le_pi_div_two (by linarith) (by linarith))
theorem strictMonoOn_tan : StrictMonoOn tan (Ioo (-(Ο / 2)) (Ο / 2)) := by
rintro x hx y hy hlt
rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos,
div_lt_div_iffβ (cos_pos_of_mem_Ioo hx) (cos_pos_of_mem_Ioo hy), mul_comm, β sub_pos, β sin_sub]
exact sin_pos_of_pos_of_lt_pi (sub_pos.2 hlt) <| by linarith [hx.1, hy.2]
theorem tan_lt_tan_of_lt_of_lt_pi_div_two {x y : β} (hxβ : -(Ο / 2) < x) (hyβ : y < Ο / 2)
(hxy : x < y) : tan x < tan y :=
strictMonoOn_tan β¨hxβ, hxy.trans hyββ© β¨hxβ.trans hxy, hyββ© hxy
theorem tan_lt_tan_of_nonneg_of_lt_pi_div_two {x y : β} (hxβ : 0 β€ x) (hyβ : y < Ο / 2)
(hxy : x < y) : tan x < tan y :=
tan_lt_tan_of_lt_of_lt_pi_div_two (by linarith) hyβ hxy
theorem injOn_tan : InjOn tan (Ioo (-(Ο / 2)) (Ο / 2)) :=
strictMonoOn_tan.injOn
theorem tan_inj_of_lt_of_lt_pi_div_two {x y : β} (hxβ : -(Ο / 2) < x) (hxβ : x < Ο / 2)
(hyβ : -(Ο / 2) < y) (hyβ : y < Ο / 2) (hxy : tan x = tan y) : x = y :=
injOn_tan β¨hxβ, hxββ© β¨hyβ, hyββ© hxy
theorem tan_periodic : Function.Periodic tan Ο := by
simpa only [Function.Periodic, tan_eq_sin_div_cos] using sin_antiperiodic.div cos_antiperiodic
@[simp]
theorem tan_pi : tan Ο = 0 := by rw [tan_periodic.eq, tan_zero]
theorem tan_add_pi (x : β) : tan (x + Ο) = tan x :=
tan_periodic x
theorem tan_sub_pi (x : β) : tan (x - Ο) = tan x :=
tan_periodic.sub_eq x
theorem tan_pi_sub (x : β) : tan (Ο - x) = -tan x :=
tan_neg x βΈ tan_periodic.sub_eq'
theorem tan_pi_div_two_sub (x : β) : tan (Ο / 2 - x) = (tan x)β»ΒΉ := by
rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos, inv_div, sin_pi_div_two_sub, cos_pi_div_two_sub]
theorem tan_nat_mul_pi (n : β) : tan (n * Ο) = 0 :=
tan_zero βΈ tan_periodic.nat_mul_eq n
theorem tan_int_mul_pi (n : β€) : tan (n * Ο) = 0 :=
tan_zero βΈ tan_periodic.int_mul_eq n
theorem tan_add_nat_mul_pi (x : β) (n : β) : tan (x + n * Ο) = tan x :=
tan_periodic.nat_mul n x
theorem tan_add_int_mul_pi (x : β) (n : β€) : tan (x + n * Ο) = tan x :=
tan_periodic.int_mul n x
theorem tan_sub_nat_mul_pi (x : β) (n : β) : tan (x - n * Ο) = tan x :=
tan_periodic.sub_nat_mul_eq n
theorem tan_sub_int_mul_pi (x : β) (n : β€) : tan (x - n * Ο) = tan x :=
tan_periodic.sub_int_mul_eq n
theorem tan_nat_mul_pi_sub (x : β) (n : β) : tan (n * Ο - x) = -tan x :=
tan_neg x βΈ tan_periodic.nat_mul_sub_eq n
theorem tan_int_mul_pi_sub (x : β) (n : β€) : tan (n * Ο - x) = -tan x :=
tan_neg x βΈ tan_periodic.int_mul_sub_eq n
theorem tendsto_sin_pi_div_two : Tendsto sin (π[<] (Ο / 2)) (π 1) := by
convert continuous_sin.continuousWithinAt.tendsto
simp
theorem tendsto_cos_pi_div_two : Tendsto cos (π[<] (Ο / 2)) (π[>] 0) := by
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
Β· convert continuous_cos.continuousWithinAt.tendsto
simp
Β· filter_upwards [Ioo_mem_nhdsLT (neg_lt_self pi_div_two_pos)] with x hx
exact cos_pos_of_mem_Ioo hx
theorem tendsto_tan_pi_div_two : Tendsto tan (π[<] (Ο / 2)) atTop := by
convert tendsto_cos_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_pos zero_lt_one
tendsto_sin_pi_div_two using 1
simp only [Pi.inv_apply, β div_eq_inv_mul, β tan_eq_sin_div_cos]
theorem tendsto_sin_neg_pi_div_two : Tendsto sin (π[>] (-(Ο / 2))) (π (-1)) := by
convert continuous_sin.continuousWithinAt.tendsto using 2
simp
theorem tendsto_cos_neg_pi_div_two : Tendsto cos (π[>] (-(Ο / 2))) (π[>] 0) := by
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
Β· convert continuous_cos.continuousWithinAt.tendsto
simp
Β· filter_upwards [Ioo_mem_nhdsGT (neg_lt_self pi_div_two_pos)] with x hx
exact cos_pos_of_mem_Ioo hx
theorem tendsto_tan_neg_pi_div_two : Tendsto tan (π[>] (-(Ο / 2))) atBot := by
convert tendsto_cos_neg_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_neg (by simp)
tendsto_sin_neg_pi_div_two using 1
simp only [Pi.inv_apply, β div_eq_inv_mul, β tan_eq_sin_div_cos]
end Real
namespace Complex
open Real
theorem sin_eq_zero_iff_cos_eq {z : β} : sin z = 0 β cos z = 1 β¨ cos z = -1 := by
rw [β mul_self_eq_one_iff, β sin_sq_add_cos_sq, sq, sq, right_eq_add, mul_eq_zero, or_self]
theorem cos_eq_zero_iff_sin_eq {z : β} : cos z = 0 β sin z = 1 β¨ sin z = -1 := by
rw [β mul_self_eq_one_iff, β sin_sq_add_cos_sq, sq, sq, left_eq_add, mul_eq_zero, or_self]
@[simp]
theorem cos_pi_div_two : cos (Ο / 2) = 0 :=
calc
cos (Ο / 2) = Real.cos (Ο / 2) := by rw [ofReal_cos]; simp
_ = 0 := by simp
@[simp]
theorem sin_pi_div_two : sin (Ο / 2) = 1 :=
calc
sin (Ο / 2) = Real.sin (Ο / 2) := by rw [ofReal_sin]; simp
_ = 1 := by simp
@[simp]
theorem sin_pi : sin Ο = 0 := by rw [β ofReal_sin, Real.sin_pi]; simp
@[simp]
theorem cos_pi : cos Ο = -1 := by rw [β ofReal_cos, Real.cos_pi]; simp
@[simp]
theorem sin_two_pi : sin (2 * Ο) = 0 := by simp [two_mul, sin_add]
@[simp]
theorem cos_two_pi : cos (2 * Ο) = 1 := by simp [two_mul, cos_add]
theorem sin_antiperiodic : Function.Antiperiodic sin Ο := by simp [sin_add]
theorem sin_periodic : Function.Periodic sin (2 * Ο) :=
sin_antiperiodic.periodic_two_mul
theorem sin_add_pi (x : β) : sin (x + Ο) = -sin x :=
sin_antiperiodic x
theorem sin_add_two_pi (x : β) : sin (x + 2 * Ο) = sin x :=
sin_periodic x
theorem sin_sub_pi (x : β) : sin (x - Ο) = -sin x :=
sin_antiperiodic.sub_eq x
theorem sin_sub_two_pi (x : β) : sin (x - 2 * Ο) = sin x :=
sin_periodic.sub_eq x
theorem sin_pi_sub (x : β) : sin (Ο - x) = sin x :=
neg_neg (sin x) βΈ sin_neg x βΈ sin_antiperiodic.sub_eq'
theorem sin_two_pi_sub (x : β) : sin (2 * Ο - x) = -sin x :=
sin_neg x βΈ sin_periodic.sub_eq'
theorem sin_nat_mul_pi (n : β) : sin (n * Ο) = 0 :=
sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n
theorem sin_int_mul_pi (n : β€) : sin (n * Ο) = 0 :=
sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n
theorem sin_add_nat_mul_two_pi (x : β) (n : β) : sin (x + n * (2 * Ο)) = sin x :=
sin_periodic.nat_mul n x
theorem sin_add_int_mul_two_pi (x : β) (n : β€) : sin (x + n * (2 * Ο)) = sin x :=
sin_periodic.int_mul n x
theorem sin_sub_nat_mul_two_pi (x : β) (n : β) : sin (x - n * (2 * Ο)) = sin x :=
sin_periodic.sub_nat_mul_eq n
theorem sin_sub_int_mul_two_pi (x : β) (n : β€) : sin (x - n * (2 * Ο)) = sin x :=
sin_periodic.sub_int_mul_eq n
theorem sin_nat_mul_two_pi_sub (x : β) (n : β) : sin (n * (2 * Ο) - x) = -sin x :=
sin_neg x βΈ sin_periodic.nat_mul_sub_eq n
theorem sin_int_mul_two_pi_sub (x : β) (n : β€) : sin (n * (2 * Ο) - x) = -sin x :=
sin_neg x βΈ sin_periodic.int_mul_sub_eq n
theorem cos_antiperiodic : Function.Antiperiodic cos Ο := by simp [cos_add]
theorem cos_periodic : Function.Periodic cos (2 * Ο) :=
cos_antiperiodic.periodic_two_mul
theorem cos_add_pi (x : β) : cos (x + Ο) = -cos x :=
cos_antiperiodic x
theorem cos_add_two_pi (x : β) : cos (x + 2 * Ο) = cos x :=
cos_periodic x
theorem cos_sub_pi (x : β) : cos (x - Ο) = -cos x :=
cos_antiperiodic.sub_eq x
theorem cos_sub_two_pi (x : β) : cos (x - 2 * Ο) = cos x :=
cos_periodic.sub_eq x
theorem cos_pi_sub (x : β) : cos (Ο - x) = -cos x :=
cos_neg x βΈ cos_antiperiodic.sub_eq'
theorem cos_two_pi_sub (x : β) : cos (2 * Ο - x) = cos x :=
cos_neg x βΈ cos_periodic.sub_eq'
theorem cos_nat_mul_two_pi (n : β) : cos (n * (2 * Ο)) = 1 :=
(cos_periodic.nat_mul_eq n).trans cos_zero
theorem cos_int_mul_two_pi (n : β€) : cos (n * (2 * Ο)) = 1 :=
(cos_periodic.int_mul_eq n).trans cos_zero
theorem cos_add_nat_mul_two_pi (x : β) (n : β) : cos (x + n * (2 * Ο)) = cos x :=
cos_periodic.nat_mul n x
theorem cos_add_int_mul_two_pi (x : β) (n : β€) : cos (x + n * (2 * Ο)) = cos x :=
cos_periodic.int_mul n x
theorem cos_sub_nat_mul_two_pi (x : β) (n : β) : cos (x - n * (2 * Ο)) = cos x :=
cos_periodic.sub_nat_mul_eq n
theorem cos_sub_int_mul_two_pi (x : β) (n : β€) : cos (x - n * (2 * Ο)) = cos x :=
cos_periodic.sub_int_mul_eq n
theorem cos_nat_mul_two_pi_sub (x : β) (n : β) : cos (n * (2 * Ο) - x) = cos x :=
cos_neg x βΈ cos_periodic.nat_mul_sub_eq n
theorem cos_int_mul_two_pi_sub (x : β) (n : β€) : cos (n * (2 * Ο) - x) = cos x :=
cos_neg x βΈ cos_periodic.int_mul_sub_eq n
theorem cos_nat_mul_two_pi_add_pi (n : β) : cos (n * (2 * Ο) + Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_add_pi (n : β€) : cos (n * (2 * Ο) + Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic
theorem cos_nat_mul_two_pi_sub_pi (n : β) : cos (n * (2 * Ο) - Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic
theorem cos_int_mul_two_pi_sub_pi (n : β€) : cos (n * (2 * Ο) - Ο) = -1 := by
simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic
theorem sin_add_pi_div_two (x : β) : sin (x + Ο / 2) = cos x := by simp [sin_add]
theorem sin_sub_pi_div_two (x : β) : sin (x - Ο / 2) = -cos x := by simp [sub_eq_add_neg, sin_add]
theorem sin_pi_div_two_sub (x : β) : sin (Ο / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add]
theorem cos_add_pi_div_two (x : β) : cos (x + Ο / 2) = -sin x := by simp [cos_add]
theorem cos_sub_pi_div_two (x : β) : cos (x - Ο / 2) = sin x := by simp [sub_eq_add_neg, cos_add]
theorem cos_pi_div_two_sub (x : β) : cos (Ο / 2 - x) = sin x := by
rw [β cos_neg, neg_sub, cos_sub_pi_div_two]
theorem tan_periodic : Function.Periodic tan Ο := by
simpa only [tan_eq_sin_div_cos] using sin_antiperiodic.div cos_antiperiodic
theorem tan_add_pi (x : β) : tan (x + Ο) = tan x :=
tan_periodic x
theorem tan_sub_pi (x : β) : tan (x - Ο) = tan x :=
tan_periodic.sub_eq x
theorem tan_pi_sub (x : β) : tan (Ο - x) = -tan x :=
tan_neg x βΈ tan_periodic.sub_eq'
theorem tan_pi_div_two_sub (x : β) : tan (Ο / 2 - x) = (tan x)β»ΒΉ := by
rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos, inv_div, sin_pi_div_two_sub, cos_pi_div_two_sub]
theorem tan_nat_mul_pi (n : β) : tan (n * Ο) = 0 :=
tan_zero βΈ tan_periodic.nat_mul_eq n
theorem tan_int_mul_pi (n : β€) : tan (n * Ο) = 0 :=
tan_zero βΈ tan_periodic.int_mul_eq n
theorem tan_add_nat_mul_pi (x : β) (n : β) : tan (x + n * Ο) = tan x :=
tan_periodic.nat_mul n x
theorem tan_add_int_mul_pi (x : β) (n : β€) : tan (x + n * Ο) = tan x :=
tan_periodic.int_mul n x
theorem tan_sub_nat_mul_pi (x : β) (n : β) : tan (x - n * Ο) = tan x :=
tan_periodic.sub_nat_mul_eq n
theorem tan_sub_int_mul_pi (x : β) (n : β€) : tan (x - n * Ο) = tan x :=
tan_periodic.sub_int_mul_eq n
theorem tan_nat_mul_pi_sub (x : β) (n : β) : tan (n * Ο - x) = -tan x :=
tan_neg x βΈ tan_periodic.nat_mul_sub_eq n
theorem tan_int_mul_pi_sub (x : β) (n : β€) : tan (n * Ο - x) = -tan x :=
tan_neg x βΈ tan_periodic.int_mul_sub_eq n
theorem exp_antiperiodic : Function.Antiperiodic exp (Ο * I) := by simp [exp_add, exp_mul_I]
theorem exp_periodic : Function.Periodic exp (2 * Ο * I) :=
(mul_assoc (2 : β) Ο I).symm βΈ exp_antiperiodic.periodic_two_mul
theorem exp_mul_I_antiperiodic : Function.Antiperiodic (fun x => exp (x * I)) Ο := by
simpa only [mul_inv_cancel_rightβ I_ne_zero] using exp_antiperiodic.mul_const I_ne_zero
theorem exp_mul_I_periodic : Function.Periodic (fun x => exp (x * I)) (2 * Ο) :=
exp_mul_I_antiperiodic.periodic_two_mul
@[simp]
theorem exp_pi_mul_I : exp (Ο * I) = -1 :=
exp_zero βΈ exp_antiperiodic.eq
@[simp]
theorem exp_two_pi_mul_I : exp (2 * Ο * I) = 1 :=
exp_periodic.eq.trans exp_zero
@[simp]
lemma exp_pi_div_two_mul_I : exp (Ο / 2 * I) = I := by
rw [β cos_add_sin_I, cos_pi_div_two, sin_pi_div_two, one_mul, zero_add]
@[simp]
lemma exp_neg_pi_div_two_mul_I : exp (-Ο / 2 * I) = -I := by
rw [β cos_add_sin_I, neg_div, cos_neg, cos_pi_div_two, sin_neg, sin_pi_div_two, zero_add, neg_mul,
one_mul]
@[simp]
theorem exp_nat_mul_two_pi_mul_I (n : β) : exp (n * (2 * Ο * I)) = 1 :=
(exp_periodic.nat_mul_eq n).trans exp_zero
@[simp]
theorem exp_int_mul_two_pi_mul_I (n : β€) : exp (n * (2 * Ο * I)) = 1 :=
(exp_periodic.int_mul_eq n).trans exp_zero
@[simp]
theorem exp_add_pi_mul_I (z : β) : exp (z + Ο * I) = -exp z :=
exp_antiperiodic z
@[simp]
theorem exp_sub_pi_mul_I (z : β) : exp (z - Ο * I) = -exp z :=
exp_antiperiodic.sub_eq z
/-- A supporting lemma for the **Phragmen-LindelΓΆf principle** in a horizontal strip. If `z : β`
belongs to a horizontal strip `|Complex.im z| β€ b`, `b β€ Ο / 2`, and `a β€ 0`, then
$$\left|exp^{a\left(e^{z}+e^{-z}\right)}\right| \le e^{a\cos b \exp^{|re z|}}.$$
-/
theorem norm_exp_mul_exp_add_exp_neg_le_of_abs_im_le {a b : β} (ha : a β€ 0) {z : β}
(hz : |z.im| β€ b) (hb : b β€ Ο / 2) :
βexp (a * (exp z + exp (-z)))β β€ Real.exp (a * Real.cos b * Real.exp |z.re|) := by
simp only [norm_exp, Real.exp_le_exp, re_ofReal_mul, add_re, exp_re, neg_im, Real.cos_neg, β
add_mul, mul_assoc, mul_comm (Real.cos b), neg_re, β Real.cos_abs z.im]
have : Real.exp |z.re| β€ Real.exp z.re + Real.exp (-z.re) :=
apply_abs_le_add_of_nonneg (fun x => (Real.exp_pos x).le) z.re
refine mul_le_mul_of_nonpos_left (mul_le_mul this ?_ ?_ ((Real.exp_pos _).le.trans this)) ha
Β· exact
Real.cos_le_cos_of_nonneg_of_le_pi (_root_.abs_nonneg _)
(hb.trans <| half_le_self <| Real.pi_pos.le) hz
Β· refine Real.cos_nonneg_of_mem_Icc β¨?_, hbβ©
exact (neg_nonpos.2 <| Real.pi_div_two_pos.le).trans ((_root_.abs_nonneg _).trans hz)
end Complex |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Sinc.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds
import Mathlib.Analysis.Calculus.DSlope
/-!
# Sinc function
This file contains the definition of the sinc function and some of its properties.
## Main definitions
* `Real.sinc`: the (unnormalized) sinc function, defined as `sinc x = sin x / x` for `x β 0`
and `1` for `x = 0`.
## Main statements
* `continuous_sinc`: the sinc function is continuous.
-/
open Filter
open scoped Topology
namespace Real
variable {x : β}
/-- The function `sin x / x` modified to take the value 1 at 0, which makes it continuous. -/
@[pp_nodot]
noncomputable def sinc (x : β) : β := if x = 0 then 1 else sin x / x
lemma sinc_apply : sinc x = if x = 0 then 1 else sin x / x := rfl
@[simp]
lemma sinc_zero : sinc 0 = 1 := by simp [sinc]
lemma sinc_of_ne_zero (hx : x β 0) : sinc x = sin x / x := by simp [sinc, hx]
lemma sinc_eq_dslope : sinc = dslope sin 0 := by
ext
simp [dslope, Function.update_apply, sinc, slope, div_eq_inv_mul]
@[simp]
lemma sinc_neg (x : β) : sinc (-x) = sinc x := by
by_cases hx : x = 0
Β· simp [hx]
Β· simp [sinc_of_ne_zero hx, sinc_of_ne_zero (neg_ne_zero.mpr hx)]
lemma abs_sinc_le_one (x : β) : |sinc x| β€ 1 := by
by_cases hx : x = 0
Β· simp [hx]
rw [sinc_of_ne_zero hx, abs_div]
refine div_le_of_le_mulβ (abs_nonneg _) zero_le_one ?_
rw [one_mul]
exact abs_sin_le_abs
lemma sinc_le_one (x : β) : sinc x β€ 1 := (abs_le.mp (abs_sinc_le_one x)).2
lemma neg_one_le_sinc (x : β) : -1 β€ sinc x := (abs_le.mp (abs_sinc_le_one x)).1
lemma sin_div_le_inv_abs (x : β) : sin x / x β€ |x|β»ΒΉ := by
rcases lt_trichotomy x 0 with hx | rfl | hx
Β· rw [abs_of_nonpos hx.le, β one_div, le_div_iffβ, div_eq_mul_inv]
Β· ring_nf
rw [mul_assoc, mul_inv_cancelβ hx.ne, mul_one, neg_le]
exact neg_one_le_sin x
Β· simpa using hx
Β· simp
Β· rw [abs_of_nonneg hx.le, div_eq_mul_inv, mul_inv_le_iffβ hx, inv_mul_cancelβ hx.ne']
exact sin_le_one x
lemma sinc_le_inv_abs (hx : x β 0) : sinc x β€ |x|β»ΒΉ := by
rw [sinc_of_ne_zero hx]
exact sin_div_le_inv_abs x
/-- The function `sinc` is continuous. -/
@[fun_prop]
lemma continuous_sinc : Continuous sinc := by
refine continuous_iff_continuousAt.mpr fun x β¦ ?_
rw [sinc_eq_dslope]
by_cases hx : x = 0
Β· simp [hx]
Β· rw [continuousAt_dslope_of_ne hx]
fun_prop
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean | import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {ΞΈ : β} : cos ΞΈ = 0 β β k : β€, ΞΈ = (2 * k + 1) * Ο / 2 := by
have h : (exp (ΞΈ * I) + exp (-ΞΈ * I)) / 2 = 0 β exp (2 * ΞΈ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (ΞΈ * I) + exp (-ΞΈ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, β div_eq_iff (exp_ne_zero _), β exp_sub]
ring_nf
rw [cos, h, β exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine exists_congr fun x => ?_
refine (iff_of_eq <| congr_arg _ ?_).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
ring
theorem cos_ne_zero_iff {ΞΈ : β} : cos ΞΈ β 0 β β k : β€, ΞΈ β (2 * k + 1) * Ο / 2 := by
rw [β not_exists, not_iff_not, cos_eq_zero_iff]
theorem sin_eq_zero_iff {ΞΈ : β} : sin ΞΈ = 0 β β k : β€, ΞΈ = k * Ο := by
rw [β Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
Β· rintro β¨k, hkβ©
use k + 1
simp [eq_add_of_sub_eq hk]
ring
Β· rintro β¨k, rflβ©
use k - 1
simp
ring
theorem sin_ne_zero_iff {ΞΈ : β} : sin ΞΈ β 0 β β k : β€, ΞΈ β k * Ο := by
rw [β not_exists, not_iff_not, sin_eq_zero_iff]
/-- The tangent of a complex number is equal to zero
iff this number is equal to `k * Ο / 2` for an integer `k`.
Note that this lemma takes into account that we use zero as the junk value for division by zero.
See also `Complex.tan_eq_zero_iff'`. -/
theorem tan_eq_zero_iff {ΞΈ : β} : tan ΞΈ = 0 β β k : β€, k * Ο / 2 = ΞΈ := by
rw [tan, div_eq_zero_iff, β mul_eq_zero, β mul_right_inj' two_ne_zero, mul_zero,
β mul_assoc, β sin_two_mul, sin_eq_zero_iff]
simp [field, mul_comm, eq_comm]
theorem tan_ne_zero_iff {ΞΈ : β} : tan ΞΈ β 0 β β k : β€, (k * Ο / 2 : β) β ΞΈ := by
rw [β not_exists, not_iff_not, tan_eq_zero_iff]
theorem tan_int_mul_pi_div_two (n : β€) : tan (n * Ο / 2) = 0 :=
tan_eq_zero_iff.mpr (by use n)
/-- If the tangent of a complex number is well-defined,
then it is equal to zero iff the number is equal to `k * Ο` for an integer `k`.
See also `Complex.tan_eq_zero_iff` for a version that takes into account junk values of `ΞΈ`. -/
theorem tan_eq_zero_iff' {ΞΈ : β} (hΞΈ : cos ΞΈ β 0) : tan ΞΈ = 0 β β k : β€, k * Ο = ΞΈ := by
simp only [tan, hΞΈ, div_eq_zero_iff, sin_eq_zero_iff]; simp [eq_comm]
theorem cos_eq_cos_iff {x y : β} : cos x = cos y β β k : β€, y = 2 * k * Ο + x β¨ y = 2 * k * Ο - x :=
calc
cos x = cos y β cos x - cos y = 0 := sub_eq_zero.symm
_ β -2 * sin ((x + y) / 2) * sin ((x - y) / 2) = 0 := by rw [cos_sub_cos]
_ β sin ((x + y) / 2) = 0 β¨ sin ((x - y) / 2) = 0 := by simp [(by simp : (2 : β) β 0)]
_ β sin ((x - y) / 2) = 0 β¨ sin ((x + y) / 2) = 0 := or_comm
_ β (β k : β€, y = 2 * k * Ο + x) β¨ β k : β€, y = 2 * k * Ο - x := by
apply or_congr <;>
simp [field, sin_eq_zero_iff, eq_sub_iff_add_eq',
sub_eq_iff_eq_add, mul_comm (2 : β), mul_right_comm _ (2 : β)]
constructor <;> Β· rintro β¨k, rflβ©; use -k; simp
_ β β k : β€, y = 2 * k * Ο + x β¨ y = 2 * k * Ο - x := exists_or.symm
theorem sin_eq_sin_iff {x y : β} :
sin x = sin y β β k : β€, y = 2 * k * Ο + x β¨ y = (2 * k + 1) * Ο - x := by
simp only [β Complex.cos_sub_pi_div_two, cos_eq_cos_iff, sub_eq_iff_eq_add]
refine exists_congr fun k => or_congr ?_ ?_ <;> refine Eq.congr rfl ?_ <;> simp [field] <;> ring
theorem cos_eq_one_iff {x : β} : cos x = 1 β β k : β€, k * (2 * Ο) = x := by
rw [β cos_zero, eq_comm, cos_eq_cos_iff]
simp [mul_assoc, mul_left_comm, eq_comm]
theorem cos_eq_neg_one_iff {x : β} : cos x = -1 β β k : β€, Ο + k * (2 * Ο) = x := by
rw [β neg_eq_iff_eq_neg, β cos_sub_pi, cos_eq_one_iff]
simp only [eq_sub_iff_add_eq']
theorem sin_eq_one_iff {x : β} : sin x = 1 β β k : β€, Ο / 2 + k * (2 * Ο) = x := by
rw [β cos_sub_pi_div_two, cos_eq_one_iff]
simp only [eq_sub_iff_add_eq']
theorem sin_eq_neg_one_iff {x : β} : sin x = -1 β β k : β€, -(Ο / 2) + k * (2 * Ο) = x := by
rw [β neg_eq_iff_eq_neg, β cos_add_pi_div_two, cos_eq_one_iff]
simp only [β sub_eq_neg_add, sub_eq_iff_eq_add]
theorem tan_add {x y : β}
(h : ((β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) β¨
(β k : β€, x = (2 * k + 1) * Ο / 2) β§ β l : β€, y = (2 * l + 1) * Ο / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by
rcases h with (β¨h1, h2β© | β¨β¨k, rflβ©, β¨l, rflβ©β©)
Β· rw [tan, sin_add, cos_add, β
div_div_div_cancel_rightβ (mul_ne_zero (cos_ne_zero_iff.mpr h1) (cos_ne_zero_iff.mpr h2)),
add_div, sub_div]
simp only [β div_mul_div_comm, tan, mul_one, one_mul, div_self (cos_ne_zero_iff.mpr h1),
div_self (cos_ne_zero_iff.mpr h2)]
Β· haveI t := tan_int_mul_pi_div_two
obtain β¨hx, hy, hxyβ© := t (2 * k + 1), t (2 * l + 1), t (2 * k + 1 + (2 * l + 1))
simp only [Int.cast_add, Int.cast_two, Int.cast_mul, Int.cast_one] at hx hy hxy
rw [hx, hy, add_zero, zero_div, mul_div_assoc, mul_div_assoc, β
add_mul (2 * (k : β) + 1) (2 * l + 1) (Ο / 2), β mul_div_assoc, hxy]
theorem tan_add' {x y : β}
(h : (β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) :=
tan_add (Or.inl h)
theorem tan_sub {x y : β}
(h : ((β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) β¨
(β k : β€, x = (2 * k + 1) * Ο / 2) β§ β l : β€, y = (2 * l + 1) * Ο / 2) :
tan (x - y) = (tan x - tan y) / (1 + tan x * tan y) := by
have := tan_add (x := x) (y := -y) <| by
rcases h with β¨x_ne, minus_y_neβ© | β¨x_eq, minus_y_eqβ©
Β· refine .inl β¨x_ne, fun l => ?_β©
rw [Ne, neg_eq_iff_eq_neg]
convert minus_y_ne (-l - 1) using 2
push_cast
ring
Β· refine .inr β¨x_eq, ?_β©
rcases minus_y_eq with β¨l, rflβ©
use -l - 1
push_cast
ring
rw [tan_neg] at this
convert this using 2
ring
theorem tan_sub' {x y : β}
(h : (β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y β (2 * l + 1) * Ο / 2) :
tan (x - y) = (tan x - tan y) / (1 + tan x * tan y) :=
tan_sub (Or.inl h)
theorem tan_two_mul {z : β} : tan (2 * z) = (2 : β) * tan z / ((1 : β) - tan z ^ 2) := by
by_cases! h : β k : β€, z β (2 * k + 1) * Ο / 2
Β· rw [two_mul, two_mul, sq, tan_add (Or.inl β¨h, hβ©)]
Β· rw [two_mul, two_mul, sq, tan_add (Or.inr β¨h, hβ©)]
theorem tan_add_mul_I {x y : β}
(h :
((β k : β€, x β (2 * k + 1) * Ο / 2) β§ β l : β€, y * I β (2 * l + 1) * Ο / 2) β¨
(β k : β€, x = (2 * k + 1) * Ο / 2) β§ β l : β€, y * I = (2 * l + 1) * Ο / 2) :
tan (x + y * I) = (tan x + tanh y * I) / (1 - tan x * tanh y * I) := by
rw [tan_add h, tan_mul_I, mul_assoc]
theorem tan_eq {z : β}
(h :
((β k : β€, (z.re : β) β (2 * k + 1) * Ο / 2) β§
β l : β€, (z.im : β) * I β (2 * l + 1) * Ο / 2) β¨
(β k : β€, (z.re : β) = (2 * k + 1) * Ο / 2) β§
β l : β€, (z.im : β) * I = (2 * l + 1) * Ο / 2) :
tan z = (tan z.re + tanh z.im * I) / (1 - tan z.re * tanh z.im * I) := by
convert tan_add_mul_I h; exact (re_add_im z).symm
/-- `tan x` takes the junk value `0` when `cos x = 0` -/
lemma tan_eq_zero_of_cos_eq_zero {x} (h : cos x = 0) : tan x = 0 := by
obtain β¨k, hxkβ© := cos_eq_zero_iff.mp h
exact tan_eq_zero_iff.mpr β¨2 * k + 1, by simp [hxk]β©
-- tangent half-angle substitution formulas
theorem cos_eq_two_mul_tan_half_div_one_sub_tan_half_sq (x : β) (h : cos x β -1) :
cos x = (1 - tan (x / 2) ^ 2) / (1 + tan (x / 2) ^ 2) := by
conv_lhs => rw [β mul_div_cancelβ x two_ne_zero, cos_two_mul']
have : cos (x / 2) β 0 := by grind [cos_ne_zero_iff, cos_eq_neg_one_iff]
rw [div_eq_mul_inv (1 - tan (x / 2) ^ 2) (1 + tan (x / 2) ^ 2), inv_one_add_tan_sq this,
β tan_mul_cos this]
ring
/-- `tan (x / 2)` takes the junk value `0` when `sin x = 0` so this always holds. -/
theorem sin_eq_two_mul_tan_half_div_one_add_tan_half_sq (x : β) :
sin x = (2 * tan (x / 2)) / (1 + tan (x / 2) ^ 2) := by
conv_lhs => rw [β mul_div_cancelβ x two_ne_zero, sin_two_mul]
by_cases h : cos (x / 2) = 0
Β· simp [h, tan_eq_zero_of_cos_eq_zero]
Β· rw [div_eq_mul_inv (2 * tan (x / 2)) (1 + tan (x / 2) ^ 2), inv_one_add_tan_sq h,
β tan_mul_cos h]
ring
theorem tan_eq_one_sub_tan_half_sq_div_one_add_tan_half_sq (x : β) :
tan x = (2 * tan (x / 2)) / (1 - tan (x / 2) ^ 2) := by
conv_lhs => rw [β mul_div_cancelβ x two_ne_zero, tan_two_mul]
open scoped Topology
theorem continuousOn_tan : ContinuousOn tan {x | cos x β 0} :=
continuousOn_sin.div continuousOn_cos fun _x => id
@[continuity]
theorem continuous_tan : Continuous fun x : {x | cos x β 0} => tan x :=
continuousOn_iff_continuous_restrict.1 continuousOn_tan
theorem cos_eq_iff_quadratic {z w : β} :
cos z = w β exp (z * I) ^ 2 - 2 * w * exp (z * I) + 1 = 0 := by
rw [β sub_eq_zero]
simpa [field, cos, exp_neg] using Eq.congr (by ring) rfl
theorem cos_surjective : Function.Surjective cos := by
intro x
obtain β¨w, wβ, hwβ© : β w β 0, 1 * (w * w) + -2 * x * w + 1 = 0 := by
rcases exists_quadratic_eq_zero one_ne_zero
β¨_, (cpow_nat_inv_pow _ two_ne_zero).symm.trans <| pow_two _β© with
β¨w, hwβ©
refine β¨w, ?_, hwβ©
rintro rfl
simp only [zero_add, one_ne_zero, mul_zero] at hw
refine β¨log w / I, cos_eq_iff_quadratic.2 ?_β©
rw [div_mul_cancelβ _ I_ne_zero, exp_log wβ]
convert hw using 1
ring
@[simp]
theorem range_cos : Set.range cos = Set.univ :=
cos_surjective.range_eq
theorem sin_surjective : Function.Surjective sin := by
intro x
rcases cos_surjective x with β¨z, rflβ©
exact β¨z + Ο / 2, sin_add_pi_div_two zβ©
@[simp]
theorem range_sin : Set.range sin = Set.univ :=
sin_surjective.range_eq
end Complex
namespace Real
open scoped Real
theorem cos_eq_zero_iff {ΞΈ : β} : cos ΞΈ = 0 β β k : β€, ΞΈ = (2 * k + 1) * Ο / 2 :=
mod_cast @Complex.cos_eq_zero_iff ΞΈ
theorem cos_ne_zero_iff {ΞΈ : β} : cos ΞΈ β 0 β β k : β€, ΞΈ β (2 * k + 1) * Ο / 2 :=
mod_cast @Complex.cos_ne_zero_iff ΞΈ
theorem cos_eq_cos_iff {x y : β} : cos x = cos y β β k : β€, y = 2 * k * Ο + x β¨ y = 2 * k * Ο - x :=
mod_cast @Complex.cos_eq_cos_iff x y
theorem sin_eq_sin_iff {x y : β} :
sin x = sin y β β k : β€, y = 2 * k * Ο + x β¨ y = (2 * k + 1) * Ο - x :=
mod_cast @Complex.sin_eq_sin_iff x y
theorem cos_eq_neg_one_iff {x : β} : cos x = -1 β β k : β€, Ο + k * (2 * Ο) = x :=
mod_cast @Complex.cos_eq_neg_one_iff x
theorem sin_eq_one_iff {x : β} : sin x = 1 β β k : β€, Ο / 2 + k * (2 * Ο) = x :=
mod_cast @Complex.sin_eq_one_iff x
theorem sin_eq_neg_one_iff {x : β} : sin x = -1 β β k : β€, -(Ο / 2) + k * (2 * Ο) = x :=
mod_cast @Complex.sin_eq_neg_one_iff x
theorem tan_eq_zero_iff {ΞΈ : β} : tan ΞΈ = 0 β β k : β€, k * Ο / 2 = ΞΈ :=
mod_cast @Complex.tan_eq_zero_iff ΞΈ
theorem tan_eq_zero_iff' {ΞΈ : β} (hΞΈ : cos ΞΈ β 0) : tan ΞΈ = 0 β β k : β€, k * Ο = ΞΈ := by
revert hΞΈ
exact_mod_cast @Complex.tan_eq_zero_iff' ΞΈ
theorem tan_ne_zero_iff {ΞΈ : β} : tan ΞΈ β 0 β β k : β€, k * Ο / 2 β ΞΈ :=
mod_cast @Complex.tan_ne_zero_iff ΞΈ
/-- `tan x` takes the junk value `0` when `cos x = 0` -/
lemma tan_eq_zero_of_cos_eq_zero {x} (h : cos x = 0) : tan x = 0 :=
mod_cast @Complex.tan_eq_zero_of_cos_eq_zero x (mod_cast h)
-- tangent half-angle substitution formulas
theorem cos_eq_two_mul_tan_half_div_one_sub_tan_half_sq (x : β) (h : cos x β -1) :
cos x = (1 - tan (x / 2) ^ 2) / (1 + tan (x / 2) ^ 2) :=
mod_cast @Complex.cos_eq_two_mul_tan_half_div_one_sub_tan_half_sq x (mod_cast h)
/-- `tan (x / 2)` takes the junk value `0` when `sin x = 0` so this always holds. -/
theorem sin_eq_two_mul_tan_half_div_one_add_tan_half_sq (x : β) :
sin x = (2 * tan (x / 2)) / (1 + tan (x / 2) ^ 2) :=
mod_cast @Complex.sin_eq_two_mul_tan_half_div_one_add_tan_half_sq x
theorem tan_eq_one_sub_tan_half_sq_div_one_add_tan_half_sq (x : β) :
tan x = (2 * tan (x / 2)) / (1 - tan (x / 2) ^ 2) :=
mod_cast @Complex.tan_eq_one_sub_tan_half_sq_div_one_add_tan_half_sq x
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/ArctanDeriv.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan
import Mathlib.Analysis.SpecialFunctions.Trigonometric.ComplexDeriv
/-!
# Derivatives of the `tan` and `arctan` functions.
Continuity and derivatives of the tangent and arctangent functions.
-/
noncomputable section
namespace Real
open Set Filter
open scoped Topology Real
theorem hasStrictDerivAt_tan {x : β} (h : cos x β 0) : HasStrictDerivAt tan (1 / cos x ^ 2) x :=
mod_cast (Complex.hasStrictDerivAt_tan (by exact mod_cast h)).real_of_complex
theorem hasDerivAt_tan {x : β} (h : cos x β 0) : HasDerivAt tan (1 / cos x ^ 2) x :=
mod_cast (Complex.hasDerivAt_tan (by exact mod_cast h)).real_of_complex
theorem tendsto_abs_tan_of_cos_eq_zero {x : β} (hx : cos x = 0) :
Tendsto (fun x => abs (tan x)) (π[β ] x) atTop := by
have hx : Complex.cos x = 0 := mod_cast hx
simp only [β Real.norm_eq_abs, β Complex.norm_real, Complex.ofReal_tan]
refine (Complex.tendsto_norm_tan_of_cos_eq_zero hx).comp ?_
refine Tendsto.inf Complex.continuous_ofReal.continuousAt ?_
exact tendsto_principal_principal.2 fun y => mt Complex.ofReal_inj.1
theorem tendsto_abs_tan_atTop (k : β€) :
Tendsto (fun x => abs (tan x)) (π[β ] ((2 * k + 1) * Ο / 2)) atTop :=
tendsto_abs_tan_of_cos_eq_zero <| cos_eq_zero_iff.2 β¨k, rflβ©
theorem continuousAt_tan {x : β} : ContinuousAt tan x β cos x β 0 := by
refine β¨fun hc hβ => ?_, fun h => (hasDerivAt_tan h).continuousAtβ©
exact not_tendsto_nhds_of_tendsto_atTop (tendsto_abs_tan_of_cos_eq_zero hβ) _
(hc.norm.tendsto.mono_left inf_le_left)
theorem differentiableAt_tan {x : β} : DifferentiableAt β tan x β cos x β 0 :=
β¨fun h => continuousAt_tan.1 h.continuousAt, fun h => (hasDerivAt_tan h).differentiableAtβ©
@[simp]
theorem deriv_tan (x : β) : deriv tan x = 1 / cos x ^ 2 :=
if h : cos x = 0 then by
have : Β¬DifferentiableAt β tan x := mt differentiableAt_tan.1 (Classical.not_not.2 h)
simp [deriv_zero_of_not_differentiableAt this, h, sq]
else (hasDerivAt_tan h).deriv
@[simp]
theorem contDiffAt_tan {n : WithTop ββ} {x : β} : ContDiffAt β n tan x β cos x β 0 :=
β¨fun h => continuousAt_tan.1 h.continuousAt, fun h =>
(Complex.contDiffAt_tan.2 <| mod_cast h).real_of_complexβ©
theorem hasDerivAt_tan_of_mem_Ioo {x : β} (h : x β Ioo (-(Ο / 2) : β) (Ο / 2)) :
HasDerivAt tan (1 / cos x ^ 2) x :=
hasDerivAt_tan (cos_pos_of_mem_Ioo h).ne'
theorem differentiableAt_tan_of_mem_Ioo {x : β} (h : x β Ioo (-(Ο / 2) : β) (Ο / 2)) :
DifferentiableAt β tan x :=
(hasDerivAt_tan_of_mem_Ioo h).differentiableAt
theorem hasStrictDerivAt_arctan (x : β) : HasStrictDerivAt arctan (1 / (1 + x ^ 2)) x := by
have A : cos (arctan x) β 0 := (cos_arctan_pos x).ne'
simpa [cos_sq_arctan] using
tanPartialHomeomorph.hasStrictDerivAt_symm trivial (by simpa) (hasStrictDerivAt_tan A)
theorem hasDerivAt_arctan (x : β) : HasDerivAt arctan (1 / (1 + x ^ 2)) x :=
(hasStrictDerivAt_arctan x).hasDerivAt
theorem hasDerivAt_arctan' (x : β) : HasDerivAt arctan (1 + x ^ 2)β»ΒΉ x :=
one_div (1 + x ^ 2) βΈ hasDerivAt_arctan x
theorem differentiableAt_arctan (x : β) : DifferentiableAt β arctan x :=
(hasDerivAt_arctan x).differentiableAt
theorem differentiable_arctan : Differentiable β arctan :=
differentiableAt_arctan
@[simp]
theorem deriv_arctan : deriv arctan = fun (x : β) => 1 / (1 + x ^ 2) :=
funext fun x => (hasDerivAt_arctan x).deriv
theorem contDiff_arctan {n : WithTop ββ} : ContDiff β n arctan :=
contDiff_iff_contDiffAt.2 fun x =>
have : cos (arctan x) β 0 := (cos_arctan_pos x).ne'
tanPartialHomeomorph.contDiffAt_symm_deriv (by simpa) trivial (hasDerivAt_tan this)
(contDiffAt_tan.2 this)
end Real
section
/-!
### Lemmas for derivatives of the composition of `Real.arctan` with a differentiable function
In this section we register lemmas for the derivatives of the composition of `Real.arctan` with a
differentiable function, for standalone use and use with `simp`. -/
open Real
section deriv
variable {f : β β β} {f' x : β} {s : Set β}
theorem HasStrictDerivAt.arctan (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => arctan (f x)) (1 / (1 + f x ^ 2) * f') x :=
(Real.hasStrictDerivAt_arctan (f x)).comp x hf
theorem HasDerivAt.arctan (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => arctan (f x)) (1 / (1 + f x ^ 2) * f') x :=
(Real.hasDerivAt_arctan (f x)).comp x hf
theorem HasDerivWithinAt.arctan (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => arctan (f x)) (1 / (1 + f x ^ 2) * f') s x :=
(Real.hasDerivAt_arctan (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_arctan (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => arctan (f x)) s x = 1 / (1 + f x ^ 2) * derivWithin f s x :=
hf.hasDerivWithinAt.arctan.derivWithin hxs
@[simp]
theorem deriv_arctan (hc : DifferentiableAt β f x) :
deriv (fun x => arctan (f x)) x = 1 / (1 + f x ^ 2) * deriv f x :=
hc.hasDerivAt.arctan.deriv
end deriv
section fderiv
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] {f : E β β} {f' : StrongDual β E}
{x : E} {s : Set E} {n : ββ}
theorem HasStrictFDerivAt.arctan (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => arctan (f x)) ((1 / (1 + f x ^ 2)) β’ f') x :=
(hasStrictDerivAt_arctan (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.arctan (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => arctan (f x)) ((1 / (1 + f x ^ 2)) β’ f') x :=
(hasDerivAt_arctan (f x)).comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.arctan (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => arctan (f x)) ((1 / (1 + f x ^ 2)) β’ f') s x :=
(hasDerivAt_arctan (f x)).comp_hasFDerivWithinAt x hf
theorem fderivWithin_arctan (hf : DifferentiableWithinAt β f s x) (hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => arctan (f x)) s x = (1 / (1 + f x ^ 2)) β’ fderivWithin β f s x :=
hf.hasFDerivWithinAt.arctan.fderivWithin hxs
@[simp]
theorem fderiv_arctan (hc : DifferentiableAt β f x) :
fderiv β (fun x => arctan (f x)) x = (1 / (1 + f x ^ 2)) β’ fderiv β f x :=
hc.hasFDerivAt.arctan.fderiv
theorem DifferentiableWithinAt.arctan (hf : DifferentiableWithinAt β f s x) :
DifferentiableWithinAt β (fun x => Real.arctan (f x)) s x :=
hf.hasFDerivWithinAt.arctan.differentiableWithinAt
@[simp]
theorem DifferentiableAt.arctan (hc : DifferentiableAt β f x) :
DifferentiableAt β (fun x => arctan (f x)) x :=
hc.hasFDerivAt.arctan.differentiableAt
theorem DifferentiableOn.arctan (hc : DifferentiableOn β f s) :
DifferentiableOn β (fun x => arctan (f x)) s := fun x h => (hc x h).arctan
@[simp]
theorem Differentiable.arctan (hc : Differentiable β f) : Differentiable β fun x => arctan (f x) :=
fun x => (hc x).arctan
theorem ContDiffAt.arctan (h : ContDiffAt β n f x) : ContDiffAt β n (fun x => arctan (f x)) x :=
contDiff_arctan.contDiffAt.comp x h
theorem ContDiff.arctan (h : ContDiff β n f) : ContDiff β n fun x => arctan (f x) :=
contDiff_arctan.comp h
theorem ContDiffWithinAt.arctan (h : ContDiffWithinAt β n f s x) :
ContDiffWithinAt β n (fun x => arctan (f x)) s x :=
contDiff_arctan.comp_contDiffWithinAt h
theorem ContDiffOn.arctan (h : ContDiffOn β n f s) : ContDiffOn β n (fun x => arctan (f x)) s :=
contDiff_arctan.comp_contDiffOn h
end fderiv
end |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Cotangent.lean | import Mathlib.Analysis.Calculus.IteratedDeriv.WithinZpow
import Mathlib.Analysis.Complex.UpperHalfPlane.Exp
import Mathlib.Analysis.Complex.IntegerCompl
import Mathlib.Analysis.Complex.LocallyUniformLimit
import Mathlib.Analysis.PSeries
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.NormedSpace.MultipliableUniformlyOn
import Mathlib.NumberTheory.ModularForms.EisensteinSeries.Summable
import Mathlib.Topology.Algebra.InfiniteSum.TsumUniformlyOn
/-!
# Cotangent
This file contains lemmas about the cotangent function, including useful series expansions.
In particular, we prove that
`Ο * cot (Ο * z) = Ο * I - 2 * Ο * I * β' n : β, Complex.exp (2 * Ο * I * z) ^ n`
as well as the infinite sum representation of cotangent (also known as the Mittag-Leffler
expansion): `Ο * cot (Ο * z) = 1 / z + β' n : β+, (1 / (z - n) + 1 / (z + n))`.
-/
open Real Complex
open scoped UpperHalfPlane
local notation "β_β€" => integerComplement
local notation "ββ" => UpperHalfPlane.upperHalfPlaneSet
lemma Complex.cot_eq_exp_ratio (z : β) :
cot z = (Complex.exp (2 * I * z) + 1) / (I * (1 - Complex.exp (2 * I * z))) := by
rw [Complex.cot, Complex.sin, Complex.cos]
have h1 : exp (z * I) + exp (-z * I) = exp (-(z * I)) * (exp (2 * I * z) + 1) := by
rw [mul_add, β Complex.exp_add]
ring_nf
have h2 : (exp (-z * I) - exp (z * I)) = exp (-(z * I)) * ((1 - exp (2 * I * z))) := by
ring_nf
rw [mul_assoc, β Complex.exp_add]
ring_nf
rw [h1, h2]
field
/- The version one probably wants to use more. -/
lemma Complex.cot_pi_eq_exp_ratio (z : β) :
cot (Ο * z) = (Complex.exp (2 * Ο * I * z) + 1) / (I * (1 - Complex.exp (2 * Ο * I * z))) := by
rw [cot_eq_exp_ratio (Ο * z)]
ring_nf
/- This is the version one probably wants, which is why the pi's are there. -/
theorem pi_mul_cot_pi_q_exp (z : β) :
Ο * cot (Ο * z) = Ο * I - 2 * Ο * I * β' n : β, Complex.exp (2 * Ο * I * z) ^ n := by
have h1 : Ο * ((exp (2 * Ο * I * z) + 1) / (I * (1 - exp (2 * Ο * I * z)))) =
-Ο * I * ((exp (2 * Ο * I * z) + 1) * (1 / (1 - exp (2 * Ο * I * z)))) := by
simp only [div_mul_eq_div_mul_one_div, div_I, one_div, neg_mul, mul_neg, neg_inj]
ring
rw [cot_pi_eq_exp_ratio, h1, one_div, (tsum_geometric_of_norm_lt_one
(UpperHalfPlane.norm_exp_two_pi_I_lt_one z)).symm, add_comm, geom_series_mul_one_add
(Complex.exp (2 * Ο * I * (z : β))) (UpperHalfPlane.norm_exp_two_pi_I_lt_one _)]
ring
section MittagLeffler
open Filter Function
open scoped Topology BigOperators Nat Complex
variable {x : β} {Z : Set β}
/-- The main term in the infinite product for sine. -/
noncomputable abbrev sineTerm (x : β) (n : β) : β := -x ^ 2 / (n + 1) ^ 2
lemma sineTerm_ne_zero {x : β} (hx : x β β_β€) (n : β) : 1 + sineTerm x n β 0 := by
simp only [sineTerm, ne_eq]
rw [add_eq_zero_iff_eq_neg, neg_div', eq_div_iff]
Β· have := (integerComplement_pow_two_ne_pow_two hx (n + 1 : β€))
aesop
Β· simp [Nat.cast_add_one_ne_zero n]
lemma tendsto_euler_sin_prod' (h0 : x β 0) :
Tendsto (fun n : β β¦ β i β Finset.range n, (1 + sineTerm x i)) atTop
(π (sin (Ο * x) / (Ο * x))) := by
rw [show (sin (Ο * x) / (Ο * x)) = sin (Ο * x) * (1 / (Ο * x)) by ring]
apply (Filter.Tendsto.mul_const (b := 1 / (Ο * x)) (tendsto_euler_sin_prod x)).congr
exact fun n β¦ by field_simp; rfl
lemma multipliable_sineTerm (x : β) : Multipliable fun i β¦ (1 + sineTerm x i) := by
apply multipliable_one_add_of_summable
have := summable_pow_div_add (x ^ 2) 2 1 Nat.one_lt_two
simpa [sineTerm] using this
lemma euler_sineTerm_tprod (hx : x β β_β€) :
β' i : β, (1 + sineTerm x i) = Complex.sin (Ο * x) / (Ο * x) := by
rw [β Multipliable.hasProd_iff (multipliable_sineTerm x),
Multipliable.hasProd_iff_tendsto_nat (multipliable_sineTerm x)]
exact tendsto_euler_sin_prod' (integerComplement.ne_zero hx)
private lemma sineTerm_bound_aux (hZ : IsCompact Z) :
β u : β β β, Summable u β§ β j z, z β Z β βsineTerm z jβ β€ u j := by
have hf : ContinuousOn (fun x : β => β-x ^ 2β) Z := by
fun_prop
obtain β¨s, hsβ© := bddAbove_def.mp (IsCompact.bddAbove_image hZ hf)
refine β¨fun n : β => β(s : β) / (n + 1) ^ 2β, ?_, ?_β©
Β· simpa using summable_pow_div_add (s : β) 2 1 (Nat.one_lt_two)
Β· simp only [norm_neg, norm_pow, Set.mem_image, forall_exists_index, and_imp,
forall_apply_eq_imp_iffβ, sineTerm, norm_div, norm_real, norm_eq_abs] at *
intro n x hx
gcongr
apply le_trans (hs x hx) (le_abs_self s)
lemma multipliableUniformlyOn_euler_sin_prod_on_compact (hZC : IsCompact Z) :
MultipliableUniformlyOn (fun n : β => fun z : β => (1 + sineTerm z n)) {Z} := by
obtain β¨u, hu, hu2β© := sineTerm_bound_aux hZC
refine Summable.multipliableUniformlyOn_nat_one_add hZC hu ?_ ?_
Β· filter_upwards with n z hz using hu2 n z hz
Β· fun_prop
lemma HasProdUniformlyOn_sineTerm_prod_on_compact (hZ2 : Z β β_β€)
(hZC : IsCompact Z) :
HasProdUniformlyOn (fun n : β => fun z : β => (1 + sineTerm z n))
(fun x => (Complex.sin (βΟ * x) / (βΟ * x))) {Z} := by
apply (multipliableUniformlyOn_euler_sin_prod_on_compact hZC).hasProdUniformlyOn.congr_right
exact fun s hs x hx => euler_sineTerm_tprod (by aesop)
lemma HasProdLocallyUniformlyOn_euler_sin_prod :
HasProdLocallyUniformlyOn (fun n : β => fun z : β => (1 + sineTerm z n))
(fun x => (Complex.sin (Ο * x) / (Ο * x))) β_β€ := by
apply hasProdLocallyUniformlyOn_of_forall_compact isOpen_compl_range_intCast
exact fun _ hZ hZC => HasProdUniformlyOn_sineTerm_prod_on_compact hZ hZC
/-- `sin Ο z` is non vanishing on the complement of the integers in `β`. -/
theorem sin_pi_mul_ne_zero (hx : x β β_β€) : Complex.sin (Ο * x) β 0 := by
apply Complex.sin_ne_zero_iff.2
intro k
nth_rw 2 [mul_comm]
exact Injective.ne (mul_right_injectiveβ (ofReal_ne_zero.mpr Real.pi_ne_zero)) (by aesop)
lemma cot_pi_mul_contDiffWithinAt (k : ββ) (hx : x β β_β€) :
ContDiffWithinAt β k (fun x β¦ (βΟ * x).cot) ββ x := by
simp_rw [Complex.cot, Complex.cos, Complex.sin]
exact ContDiffWithinAt.div (by fun_prop) (by fun_prop) (sin_pi_mul_ne_zero hx)
lemma tendsto_logDeriv_euler_sin_div (hx : x β β_β€) :
Tendsto (fun n : β β¦ logDeriv (fun z β¦ β j β Finset.range n, (1 + sineTerm z j)) x)
atTop (π <| logDeriv (fun t β¦ (Complex.sin (Ο * t) / (Ο * t))) x) := by
refine logDeriv_tendsto (isOpen_compl_range_intCast) β¨x, hxβ©
HasProdLocallyUniformlyOn_euler_sin_prod.tendstoLocallyUniformlyOn_finsetRange ?_ ?_
Β· filter_upwards with n using by fun_prop
Β· simp only [ne_eq, div_eq_zero_iff, mul_eq_zero, ofReal_eq_zero, not_or]
exact β¨sin_pi_mul_ne_zero hx, Real.pi_ne_zero, integerComplement.ne_zero hxβ©
lemma logDeriv_sin_div_eq_cot (hz : x β β_β€) :
logDeriv (fun t β¦ (Complex.sin (Ο * t) / (Ο * t))) x = Ο * cot (Ο * x) - 1 / x := by
have : (fun t β¦ (Complex.sin (Ο * t)/ (Ο * t))) = fun z β¦
(Complex.sin β fun t β¦ Ο * t) z / (Ο * z) := by simp
rw [this, logDeriv_div _ (by apply sin_pi_mul_ne_zero hz) ?_
(DifferentiableAt.comp _ (Complex.differentiableAt_sin) (by fun_prop)) (by fun_prop),
logDeriv_comp (Complex.differentiableAt_sin) (by fun_prop), Complex.logDeriv_sin,
deriv_const_mul _ (by fun_prop), deriv_id'', logDeriv_const_mul, logDeriv_id']
Β· ring
Β· simp
Β· simp only [ne_eq, mul_eq_zero, ofReal_eq_zero, not_or]
exact β¨Real.pi_ne_zero, integerComplement.ne_zero hzβ©
/-- The term in the infinite sum expansion of cot. -/
noncomputable abbrev cotTerm (x : β) (n : β) : β := 1 / (x - (n + 1)) + 1 / (x + (n + 1))
lemma logDeriv_sineTerm_eq_cotTerm (hx : x β β_β€) (i : β) :
logDeriv (fun (z : β) β¦ 1 + sineTerm z i) x = cotTerm x i := by
have h1 := integerComplement_add_ne_zero hx (i + 1)
have h2 : ((x : β) - (i + 1)) β 0 := by
simpa [sub_eq_add_neg] using integerComplement_add_ne_zero hx (-(i + 1))
have h3 : (i+1)^2 + -x^2 β 0 := by
have := (integerComplement_pow_two_ne_pow_two hx ((i + 1) : β€))
rw [β sub_eq_add_neg, sub_ne_zero]
aesop
simp only [Int.cast_add, Int.cast_natCast, Int.cast_one, ne_eq, sineTerm, logDeriv_apply,
deriv_const_add', deriv_div_const, deriv.fun_neg', differentiableAt_fun_id, deriv_fun_pow,
Nat.cast_ofNat, deriv_id'', cotTerm] at *
field
lemma logDeriv_prod_sineTerm_eq_sum_cotTerm (hx : x β β_β€) (n : β) :
logDeriv (fun (z : β) β¦ β j β Finset.range n, (1 + sineTerm z j)) x =
β j β Finset.range n, cotTerm x j := by
rw [logDeriv_prod]
Β· simp_rw [logDeriv_sineTerm_eq_cotTerm hx]
Β· exact fun i _ β¦ sineTerm_ne_zero hx i
Β· fun_prop
lemma tendsto_logDeriv_euler_cot_sub (hx : x β β_β€) :
Tendsto (fun n : β => β j β Finset.range n, cotTerm x j) atTop
(π <| Ο * cot (Ο * x)- 1 / x) := by
simp_rw [β logDeriv_sin_div_eq_cot hx, β logDeriv_prod_sineTerm_eq_sum_cotTerm hx]
simpa using tendsto_logDeriv_euler_sin_div hx
lemma cotTerm_identity (hz : x β β_β€) (n : β) :
cotTerm x n = 2 * x * (1 / ((x + (n + 1)) * (x - (n + 1)))) := by
simp only [cotTerm]
rw [one_div_add_one_div]
Β· ring
Β· simpa [sub_eq_add_neg] using integerComplement_add_ne_zero hz (-(n + 1) : β€)
Β· simpa using (integerComplement_add_ne_zero hz ((n : β€) + 1))
lemma Summable_cotTerm (hz : x β β_β€) : Summable fun n β¦ cotTerm x n := by
rw [funext fun n β¦ cotTerm_identity hz n]
apply Summable.mul_left
suffices Summable fun i : β β¦ (x - (βi : β))β»ΒΉ * (x + (βi : β))β»ΒΉ by
rw [β summable_nat_add_iff 1] at this
simpa using this
suffices Summable fun i : β€ β¦ (x - (βi : β))β»ΒΉ * (x + (βi : β))β»ΒΉ by
apply this.comp_injective CharZero.cast_injective
apply (EisensteinSeries.summable_linear_sub_mul_linear_add x 1 1).congr
simp [mul_comm]
lemma cot_series_rep' (hz : x β β_β€) : Ο * cot (Ο * x) - 1 / x =
β' n : β, (1 / (x - (n + 1)) + 1 / (x + (n + 1))) := by
rw [HasSum.tsum_eq]
apply (Summable.hasSum_iff_tendsto_nat (Summable_cotTerm hz)).mpr
(tendsto_logDeriv_euler_cot_sub hz)
/-- The cotangent infinite sum representation. -/
theorem cot_series_rep (hz : x β β_β€) :
Ο * cot (Ο * x) = 1 / x + β' n : β+, (1 / (x - n) + 1 / (x + n)) := by
have h0 := tsum_pnat_eq_tsum_succ (f := fun n β¦ 1 / (x - n) + 1 / (x + n))
have h1 := cot_series_rep' hz
simp only [one_div, Nat.cast_add, Nat.cast_one] at *
rw [h0, β h1]
ring
end MittagLeffler
section iteratedDeriv
open Set UpperHalfPlane
open scoped Nat
variable (k : β)
private lemma contDiffOn_inv_linear (d : β€) : ContDiffOn β k (fun z : β β¦ 1 / (z + d)) β_β€ := by
simpa using ContDiffOn.inv (by fun_prop) (fun x hx β¦ integerComplement_add_ne_zero hx d)
lemma eqOn_iteratedDeriv_cotTerm (d : β) : EqOn (iteratedDeriv k (fun z β¦ cotTerm z d))
(fun z β¦ (-1)^ k * k ! * ((z + (d + 1))^ (-1 - k : β€) + (z - (d + 1)) ^ (-1 - k : β€))) β_β€ := by
intro z hz
rw [β Pi.add_def, iteratedDeriv_add]
Β· have h2 := iter_deriv_inv_linear_sub k 1 ((d + 1 : β))
have h3 := iter_deriv_inv_linear k 1 (d + 1 : β)
simp only [one_div, one_mul, one_pow, mul_one, Int.reduceNeg, iteratedDeriv_eq_iterate] at *
rw [h2, h3]
ring
Β· simpa [sub_eq_add_neg] using (contDiffOn_inv_linear k (-(d + 1))).contDiffAt
((isOpen_compl_range_intCast).mem_nhds hz)
Β· simpa using (contDiffOn_inv_linear k (d + 1)).contDiffAt
((isOpen_compl_range_intCast).mem_nhds hz)
lemma eqOn_iteratedDerivWithin_cotTerm_integerComplement (d : β) :
EqOn
(iteratedDerivWithin k (fun z β¦ cotTerm z d) β_β€)
(fun z β¦ (-1) ^ k * k ! * ((z + (d + 1)) ^ (-1 - k : β€) + (z - (d + 1)) ^ (-1 - k : β€)))
β_β€ := by
apply Set.EqOn.trans (iteratedDerivWithin_of_isOpen isOpen_compl_range_intCast)
exact eqOn_iteratedDeriv_cotTerm ..
lemma eqOn_iteratedDerivWithin_cotTerm_upperHalfPlaneSet (d : β) :
EqOn
(iteratedDerivWithin k (fun z β¦ cotTerm z d) ββ)
(fun z β¦ (-1) ^ k * k ! * ((z + (d + 1)) ^ (-1 - k : β€) + (z - (d + 1)) ^ (-1 - k : β€)))
ββ := by
apply Set.EqOn.trans (upperHalfPlane_inter_integerComplement βΈ
iteratedDerivWithin_congr_right_of_isOpen (fun z β¦ cotTerm z d) k
isOpen_upperHalfPlaneSet (isOpen_compl_range_intCast))
intro z hz
simpa using eqOn_iteratedDerivWithin_cotTerm_integerComplement k d
(coe_mem_integerComplement β¨z, hzβ©)
open EisensteinSeries in
private noncomputable abbrev cotTermUpperBound (A B : β) (hB : 0 < B) (a : β) :=
k ! * (2 * (r (β¨β¨A, Bβ©, by simp [hB]β©) ^ (-1 - k : β€)) * β((a + 1) ^ (-1 - k : β€) : β)β)
private lemma summable_cotTermUpperBound (A B : β) (hB : 0 < B) {k : β} (hk : 1 β€ k) :
Summable fun a : β β¦ cotTermUpperBound k A B hB a := by
simp_rw [β mul_assoc]
apply Summable.mul_left
conv => enter [1, n]; rw [show (-1 - k : β€) = -(1 + k :) by cutsat, zpow_neg, zpow_natCast];
enter [1, 1, 1]; norm_cast
rw [summable_norm_iff, summable_nat_add_iff (f := fun n : β β¦ ((n : β) ^ (1 + k))β»ΒΉ)]
exact summable_nat_pow_inv.mpr <| by cutsat
open EisensteinSeries in
private lemma iteratedDerivWithin_cotTerm_bounded_uniformly
{k : β} {K : Set β} (hK : K β ββ) (A B : β) (hB : 0 < B)
(HABK : inclusion hK '' univ β verticalStrip A B) (n : β) {a : β} (ha : a β K) :
βiteratedDerivWithin k (fun z β¦ cotTerm z n) ββ aβ β€ cotTermUpperBound k A B hB n := by
simp only [eqOn_iteratedDerivWithin_cotTerm_upperHalfPlaneSet k n (hK ha), Complex.norm_mul,
norm_pow, norm_neg,norm_one, one_pow, Complex.norm_natCast, one_mul, cotTermUpperBound,
Int.reduceNeg, norm_zpow, Real.norm_eq_abs, two_mul, add_mul]
gcongr
have h1 := summand_bound_of_mem_verticalStrip (k := k + 1) (by norm_cast; cutsat) ![1, n + 1] hB
(z := β¨a, (hK ha)β©) (A := A) (by aesop)
have h2 := abs_norm_eq_max_natAbs_neg n βΈ (summand_bound_of_mem_verticalStrip (k := k + 1)
(by norm_cast; cutsat) ![1, -(n + 1)] hB (z := β¨a, (hK ha)β©) (A := A) (by aesop))
simp only [Fin.isValue, Matrix.cons_val_zero, Int.cast_one, coe_mk_subtype, one_mul,
Matrix.cons_val_one, Matrix.cons_val_fin_one, Int.cast_add, Int.cast_natCast, neg_add_rev,
abs_norm_eq_max_natAbs, Int.reduceNeg, Int.cast_neg, sub_eq_add_neg, ge_iff_le] at h1 h2 β’
refine le_trans (norm_add_le _ _) (add_le_add ?_ ?_) <;>
{simp only [Int.reduceNeg, norm_zpow]; norm_cast at h1 h2 β’}
lemma summableLocallyUniformlyOn_iteratedDerivWithin_cotTerm {k : β} (hk : 1 β€ k) :
SummableLocallyUniformlyOn (fun n β¦ iteratedDerivWithin k (fun z β¦ cotTerm z n) ββ) ββ := by
apply SummableLocallyUniformlyOn_of_locally_bounded isOpen_upperHalfPlaneSet
intro K hK hKc
obtain β¨A, B, hB, HABKβ© := subset_verticalStrip_of_isCompact
((isCompact_iff_isCompact_univ.mp hKc).image_of_continuousOn
(continuous_inclusion hK |>.continuousOn))
exact β¨cotTermUpperBound k A B hB, summable_cotTermUpperBound A B hB hk,
iteratedDerivWithin_cotTerm_bounded_uniformly hK A B hB HABKβ©
lemma differentiableOn_iteratedDerivWithin_cotTerm (n l : β) :
DifferentiableOn β (iteratedDerivWithin l (fun z β¦ cotTerm z n) ββ) ββ := by
suffices DifferentiableOn β (fun z : β β¦ (-1) ^ l * l ! * ((z + (n + 1)) ^ (-1 - l : β€) +
(z - (n + 1)) ^ (-1 - l : β€))) ββ by
exact this.congr fun z hz β¦ eqOn_iteratedDerivWithin_cotTerm_upperHalfPlaneSet l n hz
apply DifferentiableOn.const_mul
apply DifferentiableOn.add <;> refine DifferentiableOn.zpow (by fun_prop) <| .inl fun x hx β¦ ?_
Β· simpa [add_eq_zero_iff_neg_eq'] using (UpperHalfPlane.ne_int β¨x, hxβ© (-(n + 1))).symm
Β· simpa [sub_eq_zero] using (UpperHalfPlane.ne_int β¨x, hxβ© (n + 1))
private lemma aux_summable_add {k : β} (hk : 1 β€ k) (x : β) :
Summable fun (n : β) β¦ (x + (n + 1)) ^ (-1 - k : β€) := by
apply ((summable_nat_add_iff 1).mpr (summable_int_iff_summable_nat_and_neg.mp
(EisensteinSeries.linear_right_summable x 1 (k := k + 1) (by cutsat))).1).congr
simp [β zpow_neg, sub_eq_add_neg]
private lemma aux_summable_sub {k : β} (hk : 1 β€ k) (x : β) :
Summable fun (n : β) β¦ (x - (n + 1)) ^ (-1 - k : β€) := by
apply ((summable_nat_add_iff 1).mpr (summable_int_iff_summable_nat_and_neg.mp
(EisensteinSeries.linear_right_summable x 1 (k := k + 1) (by cutsat))).2).congr
simp [β zpow_neg, sub_eq_add_neg]
variable {z : β}
-- We have this auxiliary ugly version on the lhs so the rhs looks nicer.
private lemma aux_iteratedDeriv_tsum_cotTerm {k : β} (hk : 1 β€ k) (hz : z β ββ) :
(-1) ^ k * (k !) * z ^ (-1 - k : β€) +
iteratedDerivWithin k (fun z β¦ β' n : β, cotTerm z n) ββ z =
(-1) ^ k * k ! * β' n : β€, (z + n) ^ (-1 - k : β€) := by
rw [iteratedDerivWithin_tsum k isOpen_upperHalfPlaneSet hz
(fun t ht β¦ Summable_cotTerm (coe_mem_integerComplement β¨t, htβ©))
(fun l hl hl2 β¦ summableLocallyUniformlyOn_iteratedDerivWithin_cotTerm hl)
(fun n l z hl hz β¦ (differentiableOn_iteratedDerivWithin_cotTerm n l).differentiableAt
(isOpen_upperHalfPlaneSet.mem_nhds hz))]
conv =>
enter [1, 2, 1, n]
rw [eqOn_iteratedDerivWithin_cotTerm_upperHalfPlaneSet k n (by simp [hz])]
rw [tsum_of_add_one_of_neg_add_one (by simpa using aux_summable_add hk z)
(by simpa [sub_eq_add_neg] using aux_summable_sub hk z),
tsum_mul_left, Summable.tsum_add (aux_summable_add hk z) (aux_summable_sub hk z)]
push_cast
ring_nf
lemma iteratedDerivWithin_cot_sub_inv_eq_add_mul_tsum {k : β} (hk : 1 β€ k) (hz : z β ββ) :
iteratedDerivWithin k (fun x : β β¦ Ο * cot (Ο * x) - 1 / x) ββ z =
-(-1) ^ k * k ! * (z ^ (-1 - k : β€)) + (-1) ^ k * k ! * β' n : β€, (z + n) ^ (-1 - k : β€) := by
simp only [β aux_iteratedDeriv_tsum_cotTerm hk hz, one_div, neg_mul, neg_add_cancel_left]
refine iteratedDerivWithin_congr (fun z hz β¦ ?_) hz
simpa [cotTerm] using (cot_series_rep' (UpperHalfPlane.coe_mem_integerComplement β¨z, hzβ©))
private lemma iteratedDerivWithin_cot_pi_mul_sub_inv {z : β} (hz : z β ββ) :
iteratedDerivWithin k (fun x : β β¦ Ο * cot (Ο * x) - 1 / x) ββ z =
(iteratedDerivWithin k (fun x : β β¦ Ο * cot (Ο * x)) ββ z) -
(-1) ^ k * k ! * (z ^ (-1 - k : β€)) := by
simp_rw [sub_eq_add_neg]
rw [iteratedDerivWithin_fun_add hz isOpen_upperHalfPlaneSet.uniqueDiffOn]
Β· simpa [iteratedDerivWithin_fun_neg] using iteratedDerivWithin_one_div k
isOpen_upperHalfPlaneSet hz
Β· exact ContDiffWithinAt.smul (by fun_prop) (cot_pi_mul_contDiffWithinAt k
(UpperHalfPlane.coe_mem_integerComplement β¨z, hzβ©))
Β· simp only [one_div]
apply ContDiffWithinAt.neg
exact ContDiffWithinAt.inv (by fun_prop) (ne_zero β¨z, hzβ©)
lemma iteratedDerivWithin_cot_pi_mul_eq_mul_tsum_zpow {k : β} (hk : 1 β€ k) {z : β} (hz : z β ββ) :
iteratedDerivWithin k (fun x : β β¦ Ο * cot (Ο * x)) ββ z =
(-1) ^ k * k ! * β' n : β€, (z + n) ^ (-1 - k : β€):= by
have h0 := iteratedDerivWithin_cot_pi_mul_sub_inv k hz
rw [iteratedDerivWithin_cot_sub_inv_eq_add_mul_tsum hk hz, add_comm] at h0
rw [β add_left_inj (-(-1) ^ k * k ! * z ^ (-1 - k : β€)), h0]
ring
/-- The series expansion of the iterated derivative of `Ο cot (Ο z)`. -/
theorem iteratedDerivWithin_cot_pi_mul_eq_mul_tsum_div_pow {k : β} (hk : 1 β€ k) {z : β}
(hz : z β ββ) :
iteratedDerivWithin k (fun x : β β¦ Ο * cot (Ο * x)) ββ z =
(-1) ^ k * k ! * β' n : β€, 1 / (z + n) ^ (k + 1) := by
convert iteratedDerivWithin_cot_pi_mul_eq_mul_tsum_zpow hk hz with n
rw [show (-1 - k : β€) = -(k + 1 :) by norm_cast; cutsat, zpow_neg_coe_of_pos _ (by cutsat),
one_div]
end iteratedDeriv |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem hasStrictDerivAt_tan {x : β} (h : cos x β 0) : HasStrictDerivAt tan (1 / cos x ^ 2) x := by
convert (hasStrictDerivAt_sin x).div (hasStrictDerivAt_cos x) h using 1
rw_mod_cast [β sin_sq_add_cos_sq x]
ring
theorem hasDerivAt_tan {x : β} (h : cos x β 0) : HasDerivAt tan (1 / cos x ^ 2) x :=
(hasStrictDerivAt_tan h).hasDerivAt
open scoped Topology
theorem tendsto_norm_tan_of_cos_eq_zero {x : β} (hx : cos x = 0) :
Tendsto (fun x => βtan xβ) (π[β ] x) atTop := by
simp only [tan_eq_sin_div_cos, norm_div]
have A : sin x β 0 := fun h => by simpa [*, sq] using sin_sq_add_cos_sq x
have B : Tendsto cos (π[β ] x) (π[β ] 0) :=
hx βΈ (hasDerivAt_cos x).tendsto_nhdsNE (neg_ne_zero.2 A)
exact continuous_sin.continuousWithinAt.norm.pos_mul_atTop (norm_pos_iff.2 A)
(tendsto_norm_nhdsNE_zero.comp B).inv_tendsto_nhdsGT_zero
theorem tendsto_norm_tan_atTop (k : β€) :
Tendsto (fun x => βtan xβ) (π[β ] ((2 * k + 1) * Ο / 2 : β)) atTop :=
tendsto_norm_tan_of_cos_eq_zero <| cos_eq_zero_iff.2 β¨k, rflβ©
@[simp]
theorem continuousAt_tan {x : β} : ContinuousAt tan x β cos x β 0 := by
refine β¨fun hc hβ => ?_, fun h => (hasDerivAt_tan h).continuousAtβ©
exact not_tendsto_nhds_of_tendsto_atTop (tendsto_norm_tan_of_cos_eq_zero hβ) _
(hc.norm.tendsto.mono_left inf_le_left)
@[simp]
theorem differentiableAt_tan {x : β} : DifferentiableAt β tan x β cos x β 0 :=
β¨fun h => continuousAt_tan.1 h.continuousAt, fun h => (hasDerivAt_tan h).differentiableAtβ©
@[simp]
theorem deriv_tan (x : β) : deriv tan x = 1 / cos x ^ 2 :=
if h : cos x = 0 then by
have : Β¬DifferentiableAt β tan x := mt differentiableAt_tan.1 (Classical.not_not.2 h)
simp [deriv_zero_of_not_differentiableAt this, h, sq]
else (hasDerivAt_tan h).deriv
@[simp]
theorem contDiffAt_tan {x : β} {n : WithTop ββ} : ContDiffAt β n tan x β cos x β 0 :=
β¨fun h => continuousAt_tan.1 h.continuousAt, contDiff_sin.contDiffAt.div contDiff_cos.contDiffAtβ©
end Complex |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev.lean | import Mathlib.Analysis.Complex.Trigonometric
import Mathlib.LinearAlgebra.Complex.Module
import Mathlib.RingTheory.Polynomial.Chebyshev
/-!
# Multiple angle formulas in terms of Chebyshev polynomials
This file gives the trigonometric characterizations of Chebyshev polynomials, for the real
(`Real.cos`) and complex (`Complex.cos`) cosine and the real (`Real.cosh`) and complex
(`Complex.cosh`) hyperbolic cosine.
-/
namespace Polynomial.Chebyshev
open Polynomial
variable {R A : Type*} [CommRing R] [CommRing A] [Algebra R A]
@[simp, norm_cast]
theorem complex_ofReal_eval_T : β (x : β) n, (((T β n).eval x : β) : β) = (T β n).eval (x : β) :=
@algebraMap_eval_T β β _ _ _
@[simp, norm_cast]
theorem complex_ofReal_eval_U : β (x : β) n, (((U β n).eval x : β) : β) = (U β n).eval (x : β) :=
@algebraMap_eval_U β β _ _ _
@[simp, norm_cast]
theorem complex_ofReal_eval_C : β (x : β) n, (((C β n).eval x : β) : β) = (C β n).eval (x : β) :=
@algebraMap_eval_C β β _ _ _
@[simp, norm_cast]
theorem complex_ofReal_eval_S : β (x : β) n, (((S β n).eval x : β) : β) = (S β n).eval (x : β) :=
@algebraMap_eval_S β β _ _ _
/-! ### Complex versions -/
section Complex
open Complex
variable (ΞΈ : β)
/-- The `n`-th Chebyshev polynomial of the first kind evaluates on `cos ΞΈ` to the
value `cos (n * ΞΈ)`. -/
@[simp]
theorem T_complex_cos (n : β€) : (T β n).eval (cos ΞΈ) = cos (n * ΞΈ) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp only [T_add_two, eval_sub, eval_mul, eval_X, eval_ofNat, ih1, ih2, sub_eq_iff_eq_add,
cos_add_cos]
push_cast
ring_nf
| neg_add_one n ih1 ih2 =>
simp only [T_sub_one, eval_sub, eval_mul, eval_X, eval_ofNat, ih1, ih2, sub_eq_iff_eq_add',
cos_add_cos]
push_cast
ring_nf
/-- The `n`-th Chebyshev polynomial of the second kind evaluates on `cos ΞΈ` to the
value `sin ((n + 1) * ΞΈ) / sin ΞΈ`. -/
@[simp]
theorem U_complex_cos (n : β€) : (U β n).eval (cos ΞΈ) * sin ΞΈ = sin ((n + 1) * ΞΈ) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp [one_add_one_eq_two, sin_two_mul]; ring
| add_two n ih1 ih2 =>
simp only [U_add_two, eval_sub, eval_mul, eval_X, eval_ofNat, sub_mul,
mul_assoc, ih1, ih2, sub_eq_iff_eq_add, sin_add_sin]
push_cast
ring_nf
| neg_add_one n ih1 ih2 =>
simp only [U_sub_one, eval_sub, eval_mul, eval_X, eval_ofNat, sub_mul,
mul_assoc, ih1, ih2, sub_eq_iff_eq_add', sin_add_sin]
push_cast
ring_nf
/-- The `n`-th rescaled Chebyshev polynomial of the first kind (VietaβLucas polynomial) evaluates on
`2 * cos ΞΈ` to the value `2 * cos (n * ΞΈ)`. -/
@[simp]
theorem C_two_mul_complex_cos (n : β€) : (C β n).eval (2 * cos ΞΈ) = 2 * cos (n * ΞΈ) := by
simp [C_eq_two_mul_T_comp_half_mul_X]
/-- The `n`-th rescaled Chebyshev polynomial of the second kind (VietaβFibonacci polynomial)
evaluates on `2 * cos ΞΈ` to the value `sin ((n + 1) * ΞΈ) / sin ΞΈ`. -/
@[simp]
theorem S_two_mul_complex_cos (n : β€) : (S β n).eval (2 * cos ΞΈ) * sin ΞΈ = sin ((n + 1) * ΞΈ) := by
simp [S_eq_U_comp_half_mul_X]
/-- The `n`-th Chebyshev polynomial of the first kind evaluates on `cosh ΞΈ` to the
value `cosh (n * ΞΈ)`. -/
@[simp]
theorem T_complex_cosh (n : β€) : (T β n).eval (cosh ΞΈ) = cosh (n * ΞΈ) := calc
(T β n).eval (cosh ΞΈ)
_ = (T β n).eval (cos (ΞΈ * I)) := by rw [cos_mul_I]
_ = cos (n * (ΞΈ * I)) := T_complex_cos (ΞΈ * I) n
_ = cos (n * ΞΈ * I) := by rw [mul_assoc]
_ = cosh (n * ΞΈ) := cos_mul_I (n * ΞΈ)
/-- The `n`-th Chebyshev polynomial of the second kind evaluates on `cosh ΞΈ` to the
value `sinh ((n + 1) * ΞΈ) / sinh ΞΈ`. -/
@[simp]
theorem U_complex_cosh (n : β€) : (U β n).eval (cosh ΞΈ) * sinh ΞΈ = sinh ((n + 1) * ΞΈ) := calc
(U β n).eval (cosh ΞΈ) * sinh ΞΈ
_ = (U β n).eval (cos (ΞΈ * I)) * sin (ΞΈ * I) * (-I) := by simp [cos_mul_I, sin_mul_I, mul_assoc]
_ = sin ((n + 1) * (ΞΈ * I)) * (-I) := by rw [U_complex_cos]
_ = sin ((n + 1) * ΞΈ * I) * (-I) := by rw [mul_assoc]
_ = sinh ((n + 1) * ΞΈ) := by
rw [sin_mul_I ((n + 1) * ΞΈ), mul_assoc, mul_neg, I_mul_I, neg_neg, mul_one]
/-- The `n`-th rescaled Chebyshev polynomial of the first kind (VietaβLucas polynomial) evaluates on
`2 * cosh ΞΈ` to the value `2 * cosh (n * ΞΈ)`. -/
@[simp]
theorem C_two_mul_complex_cosh (n : β€) : (C β n).eval (2 * cosh ΞΈ) = 2 * cosh (n * ΞΈ) := by
simp [C_eq_two_mul_T_comp_half_mul_X]
/-- The `n`-th rescaled Chebyshev polynomial of the second kind (VietaβFibonacci polynomial)
evaluates on `2 * cosh ΞΈ` to the value `sinh ((n + 1) * ΞΈ) / sinh ΞΈ`. -/
@[simp]
theorem S_two_mul_complex_cosh (n : β€) : (S β n).eval (2 * cosh ΞΈ) * sinh ΞΈ =
sinh ((n + 1) * ΞΈ) := by
simp [S_eq_U_comp_half_mul_X]
end Complex
/-! ### Real versions -/
section Real
open Real
variable (ΞΈ : β) (n : β€)
/-- The `n`-th Chebyshev polynomial of the first kind evaluates on `cos ΞΈ` to the
value `cos (n * ΞΈ)`. -/
@[simp]
theorem T_real_cos : (T β n).eval (cos ΞΈ) = cos (n * ΞΈ) := mod_cast T_complex_cos ΞΈ n
/-- The `n`-th Chebyshev polynomial of the second kind evaluates on `cos ΞΈ` to the
value `sin ((n + 1) * ΞΈ) / sin ΞΈ`. -/
@[simp]
theorem U_real_cos : (U β n).eval (cos ΞΈ) * sin ΞΈ = sin ((n + 1) * ΞΈ) :=
mod_cast U_complex_cos ΞΈ n
/-- The `n`-th rescaled Chebyshev polynomial of the first kind (VietaβLucas polynomial) evaluates on
`2 * cos ΞΈ` to the value `2 * cos (n * ΞΈ)`. -/
@[simp]
theorem C_two_mul_real_cos : (C β n).eval (2 * cos ΞΈ) = 2 * cos (n * ΞΈ) :=
mod_cast C_two_mul_complex_cos ΞΈ n
/-- The `n`-th rescaled Chebyshev polynomial of the second kind (VietaβFibonacci polynomial)
evaluates on `2 * cos ΞΈ` to the value `sin ((n + 1) * ΞΈ) / sin ΞΈ`. -/
@[simp]
theorem S_two_mul_real_cos : (S β n).eval (2 * cos ΞΈ) * sin ΞΈ = sin ((n + 1) * ΞΈ) :=
mod_cast S_two_mul_complex_cos ΞΈ n
/-- The `n`-th Chebyshev polynomial of the first kind evaluates on `cosh ΞΈ` to the
value `cosh (n * ΞΈ)`. -/
@[simp]
theorem T_real_cosh (n : β€) : (T β n).eval (cosh ΞΈ) = cosh (n * ΞΈ) := mod_cast T_complex_cosh ΞΈ n
/-- The `n`-th Chebyshev polynomial of the second kind evaluates on `cosh ΞΈ` to the
value `sinh ((n + 1) * ΞΈ) / sinh ΞΈ`. -/
@[simp]
theorem U_real_cosh (n : β€) : (U β n).eval (cosh ΞΈ) * sinh ΞΈ = sinh ((n + 1) * ΞΈ) :=
mod_cast U_complex_cosh ΞΈ n
/-- The `n`-th rescaled Chebyshev polynomial of the first kind (VietaβLucas polynomial) evaluates on
`2 * cosh ΞΈ` to the value `2 * cosh (n * ΞΈ)`. -/
@[simp]
theorem C_two_mul_real_cosh (n : β€) : (C β n).eval (2 * cosh ΞΈ) = 2 * cosh (n * ΞΈ) :=
mod_cast C_two_mul_complex_cosh ΞΈ n
/-- The `n`-th rescaled Chebyshev polynomial of the second kind (VietaβFibonacci polynomial)
evaluates on `2 * cosh ΞΈ` to the value `sinh ((n + 1) * ΞΈ) / sinh ΞΈ`. -/
@[simp]
theorem S_two_mul_real_cosh (n : β€) : (S β n).eval (2 * cosh ΞΈ) * sinh ΞΈ = sinh ((n + 1) * ΞΈ) :=
mod_cast S_two_mul_complex_cosh ΞΈ n
end Real
end Polynomial.Chebyshev |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean | import Mathlib.Analysis.SpecialFunctions.Integrals.Basic
import Mathlib.MeasureTheory.Integral.PeakFunction
/-! # Euler's infinite product for the sine function
This file proves the infinite product formula
$$ \sin \pi z = \pi z \prod_{n = 1}^\infty \left(1 - \frac{z ^ 2}{n ^ 2}\right) $$
for any real or complex `z`. Our proof closely follows the article
[Salwinski, *Euler's Sine Product Formula: An Elementary Proof*][salwinski2018]: the basic strategy
is to prove a recurrence relation for the integrals `β« x in 0..Ο/2, cos 2 z x * cos x ^ (2 * n)`,
generalising the arguments used to prove Wallis' limit formula for `Ο`.
-/
open scoped Real Topology
open Real Set Filter intervalIntegral MeasureTheory.MeasureSpace
namespace EulerSine
section IntegralRecursion
/-! ## Recursion formula for the integral of `cos (2 * z * x) * cos x ^ n`
We evaluate the integral of `cos (2 * z * x) * cos x ^ n`, for any complex `z` and even integers
`n`, via repeated integration by parts. -/
variable {z : β} {n : β}
theorem antideriv_cos_comp_const_mul (hz : z β 0) (x : β) :
HasDerivAt (fun y : β => Complex.sin (2 * z * y) / (2 * z)) (Complex.cos (2 * z * x)) x := by
have a : HasDerivAt (fun y : β => y * (2 * z)) _ x := hasDerivAt_mul_const _
have b : HasDerivAt (Complex.sin β fun y : β => (y * (2 * z))) _ x :=
HasDerivAt.comp (x : β) (Complex.hasDerivAt_sin (x * (2 * z))) a
have c := b.comp_ofReal.div_const (2 * z)
field_simp at c; simp only [mul_rotate _ 2 z] at c
exact c
theorem antideriv_sin_comp_const_mul (hz : z β 0) (x : β) :
HasDerivAt (fun y : β => -Complex.cos (2 * z * y) / (2 * z)) (Complex.sin (2 * z * x)) x := by
have a : HasDerivAt (fun y : β => y * (2 * z)) _ x := hasDerivAt_mul_const _
have b : HasDerivAt (Complex.cos β fun y : β => (y * (2 * z))) _ x :=
HasDerivAt.comp (x : β) (Complex.hasDerivAt_cos (x * (2 * z))) a
have c := (b.comp_ofReal.div_const (2 * z)).fun_neg
simp at c β’; field_simp at c β’; simp only [mul_rotate _ 2 z] at c
exact c
theorem integral_cos_mul_cos_pow_aux (hn : 2 β€ n) (hz : z β 0) :
(β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ n) =
n / (2 * z) *
β« x in (0 : β)..Ο / 2, Complex.sin (2 * z * x) * sin x * (cos x : β) ^ (n - 1) := by
have der1 :
β x : β,
x β uIcc 0 (Ο / 2) β
HasDerivAt (fun y : β => (cos y : β) ^ n) (-n * sin x * (cos x : β) ^ (n - 1)) x := by
intro x _
have b : HasDerivAt (fun y : β => (cos y : β)) (-sin x) x := by
simpa using (hasDerivAt_cos x).ofReal_comp
convert HasDerivAt.comp x (hasDerivAt_pow _ _) b using 1
ring
convert (config := { sameFun := true })
integral_mul_deriv_eq_deriv_mul der1 (fun x _ => antideriv_cos_comp_const_mul hz x) _ _ using 2
Β· ext1 x; rw [mul_comm]
Β· rw [Complex.ofReal_zero, mul_zero, Complex.sin_zero, zero_div, mul_zero, sub_zero,
cos_pi_div_two, Complex.ofReal_zero, zero_pow (by positivity : n β 0), zero_mul, zero_sub,
β integral_neg, β integral_const_mul]
refine integral_congr fun x _ => ?_
ring
Β· apply Continuous.intervalIntegrable
exact
(continuous_const.mul (Complex.continuous_ofReal.comp continuous_sin)).mul
((Complex.continuous_ofReal.comp continuous_cos).pow (n - 1))
Β· apply Continuous.intervalIntegrable
exact Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)
theorem integral_sin_mul_sin_mul_cos_pow_eq (hn : 2 β€ n) (hz : z β 0) :
(β« x in (0 : β)..Ο / 2, Complex.sin (2 * z * x) * sin x * (cos x : β) ^ (n - 1)) =
(n / (2 * z) * β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ n) -
(n - 1) / (2 * z) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (n - 2) := by
have der1 :
β x : β,
x β uIcc 0 (Ο / 2) β
HasDerivAt (fun y : β => sin y * (cos y : β) ^ (n - 1))
((cos x : β) ^ n - (n - 1) * (sin x : β) ^ 2 * (cos x : β) ^ (n - 2)) x := by
intro x _
have c := HasDerivAt.comp (x : β) (hasDerivAt_pow (n - 1) _) (Complex.hasDerivAt_cos x)
convert ((Complex.hasDerivAt_sin x).fun_mul c).comp_ofReal using 1
Β· simp only [Complex.ofReal_sin, Complex.ofReal_cos, Function.comp]
Β· simp only [Complex.ofReal_cos, Complex.ofReal_sin]
rw [mul_neg, mul_neg, β sub_eq_add_neg, Function.comp_apply]
congr 1
Β· rw [β pow_succ', Nat.sub_add_cancel (by cutsat : 1 β€ n)]
Β· have : ((n - 1 : β) : β) = (n : β) - 1 := by
rw [Nat.cast_sub (one_le_two.trans hn), Nat.cast_one]
rw [Nat.sub_sub, this]
ring
convert
integral_mul_deriv_eq_deriv_mul der1 (fun x _ => antideriv_sin_comp_const_mul hz x) _ _ using 1
Β· refine integral_congr fun x _ => ?_
ring_nf
Β· -- now a tedious rearrangement of terms
-- gather into a single integral, and deal with continuity subgoals:
rw [sin_zero, cos_pi_div_two, Complex.ofReal_zero, zero_pow, zero_mul,
mul_zero, zero_mul, zero_mul, sub_zero, zero_sub, β
integral_neg, β integral_const_mul, β integral_const_mul, β integral_sub]
rotate_left
Β· apply Continuous.intervalIntegrable
exact
continuous_const.mul
((Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)).mul
((Complex.continuous_ofReal.comp continuous_cos).pow n))
Β· apply Continuous.intervalIntegrable
exact
continuous_const.mul
((Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)).mul
((Complex.continuous_ofReal.comp continuous_cos).pow (n - 2)))
Β· exact Nat.sub_ne_zero_of_lt hn
refine integral_congr fun x _ => ?_
dsimp only
-- get rid of real trig functions and divisions by 2 * z:
rw [Complex.ofReal_cos, Complex.ofReal_sin, Complex.sin_sq, β mul_div_right_comm, β
mul_div_right_comm, β sub_div, mul_div, β neg_div]
congr 1
have : Complex.cos x ^ n = Complex.cos x ^ (n - 2) * Complex.cos x ^ 2 := by
conv_lhs => rw [β Nat.sub_add_cancel hn, pow_add]
rw [this]
ring
Β· apply Continuous.intervalIntegrable
exact
((Complex.continuous_ofReal.comp continuous_cos).pow n).sub
((continuous_const.mul ((Complex.continuous_ofReal.comp continuous_sin).pow 2)).mul
((Complex.continuous_ofReal.comp continuous_cos).pow (n - 2)))
Β· apply Continuous.intervalIntegrable
exact Complex.continuous_sin.comp (continuous_const.mul Complex.continuous_ofReal)
/-- Note this also holds for `z = 0`, but we do not need this case for `sin_pi_mul_eq`. -/
theorem integral_cos_mul_cos_pow (hn : 2 β€ n) (hz : z β 0) :
(((1 : β) - (4 : β) * z ^ 2 / (n : β) ^ 2) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ n) =
(n - 1 : β) / n *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (n - 2) := by
have nne : (n : β) β 0 := by
contrapose! hn; rw [Nat.cast_eq_zero] at hn; rw [hn]; exact zero_lt_two
have := integral_cos_mul_cos_pow_aux hn hz
rw [integral_sin_mul_sin_mul_cos_pow_eq hn hz, sub_eq_neg_add, mul_add, β sub_eq_iff_eq_add]
at this
convert congr_arg (fun u : β => -u * (2 * z) ^ 2 / n ^ 2) this using 1 <;> field
/-- Note this also holds for `z = 0`, but we do not need this case for `sin_pi_mul_eq`. -/
theorem integral_cos_mul_cos_pow_even (n : β) (hz : z β 0) :
(((1 : β) - z ^ 2 / ((n : β) + 1) ^ 2) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n + 2)) =
(2 * n + 1 : β) / (2 * n + 2) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n) := by
convert integral_cos_mul_cos_pow (by cutsat : 2 β€ 2 * n + 2) hz using 3
Β· simp only [Nat.cast_add, Nat.cast_mul, Nat.cast_two]
nth_rw 2 [β mul_one (2 : β)]
rw [β mul_add, mul_pow, β div_div]
ring
Β· push_cast; ring
Β· push_cast; ring
/-- Relate the integral `cos x ^ n` over `[0, Ο/2]` to the integral of `sin x ^ n` over `[0, Ο]`,
which is studied in `Mathlib/Analysis/Real/Pi/Wallis.lean` and other places. -/
theorem integral_cos_pow_eq (n : β) :
(β« x in (0 : β)..Ο / 2, cos x ^ n) = 1 / 2 * β« x in (0 : β)..Ο, sin x ^ n := by
rw [mul_comm (1 / 2 : β), β div_eq_iff (one_div_ne_zero (two_ne_zero' β)), β div_mul, div_one,
mul_two]
have L : IntervalIntegrable _ volume 0 (Ο / 2) := (continuous_sin.pow n).intervalIntegrable _ _
have R : IntervalIntegrable _ volume (Ο / 2) Ο := (continuous_sin.pow n).intervalIntegrable _ _
rw [β integral_add_adjacent_intervals L R]
congr 1
Β· nth_rw 1 [(by ring : 0 = Ο / 2 - Ο / 2)]
nth_rw 3 [(by ring : Ο / 2 = Ο / 2 - 0)]
rw [β integral_comp_sub_left]
refine integral_congr fun x _ => ?_
rw [cos_pi_div_two_sub]
Β· nth_rw 3 [(by ring : Ο = Ο / 2 + Ο / 2)]
nth_rw 2 [(by ring : Ο / 2 = 0 + Ο / 2)]
rw [β integral_comp_add_right]
refine integral_congr fun x _ => ?_
rw [sin_add_pi_div_two]
theorem integral_cos_pow_pos (n : β) : 0 < β« x in (0 : β)..Ο / 2, cos x ^ n :=
(integral_cos_pow_eq n).symm βΈ mul_pos one_half_pos (integral_sin_pow_pos _)
/-- Finite form of Euler's sine product, with remainder term expressed as a ratio of cosine
integrals. -/
theorem sin_pi_mul_eq (z : β) (n : β) :
Complex.sin (Ο * z) =
((Ο * z * β j β Finset.range n, ((1 : β) - z ^ 2 / ((j : β) + 1) ^ 2)) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n)) /
(β« x in (0 : β)..Ο / 2, cos x ^ (2 * n) : β) := by
rcases eq_or_ne z 0 with (rfl | hz)
Β· simp
induction n with
| zero =>
simp_rw [mul_zero, pow_zero, mul_one, Finset.prod_range_zero, mul_one,
integral_one, sub_zero]
rw [integral_cos_mul_complex (mul_ne_zero two_ne_zero hz), Complex.ofReal_zero,
mul_zero, Complex.sin_zero, zero_div, sub_zero,
(by push_cast; ring : 2 * z * β(Ο / 2) = Ο * z)]
simp [field]
| succ n hn =>
rw [hn, Finset.prod_range_succ]
set A := β j β Finset.range n, ((1 : β) - z ^ 2 / ((j : β) + 1) ^ 2)
set B := β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n)
set C := β« x in (0 : β)..Ο / 2, cos x ^ (2 * n)
have aux' : 2 * n.succ = 2 * n + 2 := by rw [Nat.succ_eq_add_one, mul_add, mul_one]
have : (β« x in (0 : β)..Ο / 2, cos x ^ (2 * n.succ)) = (2 * (n : β) + 1) / (2 * n + 2) * C := by
rw [integral_cos_pow_eq]
dsimp only [C]
rw [integral_cos_pow_eq, aux', integral_sin_pow, sin_zero, sin_pi, pow_succ',
zero_mul, zero_mul, zero_mul, sub_zero, zero_div,
zero_add, β mul_assoc, β mul_assoc, mul_comm (1 / 2 : β) _, Nat.cast_mul, Nat.cast_ofNat]
rw [this]
change
Ο * z * A * B / C =
(Ο * z * (A * ((1 : β) - z ^ 2 / ((n : β) + 1) ^ 2)) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n.succ)) /
((2 * n + 1) / (2 * n + 2) * C : β)
have :
(Ο * z * (A * ((1 : β) - z ^ 2 / ((n : β) + 1) ^ 2)) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n.succ)) =
Ο * z * A *
(((1 : β) - z ^ 2 / (n.succ : β) ^ 2) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n.succ)) := by
grind
rw [this]
suffices
(((1 : β) - z ^ 2 / (n.succ : β) ^ 2) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n.succ)) =
(2 * n + 1) / (2 * n + 2) * B by
rw [this, Complex.ofReal_mul, Complex.ofReal_div]
have : (C : β) β 0 := Complex.ofReal_ne_zero.mpr (integral_cos_pow_pos _).ne'
have : 2 * (n : β) + 1 β 0 := by
convert (Nat.cast_add_one_ne_zero (2 * n) : (β(2 * n) + 1 : β) β 0)
simp
have : (n : β) + 1 β 0 := Nat.cast_add_one_ne_zero n
simp [field]
convert integral_cos_mul_cos_pow_even n hz
rw [Nat.cast_succ]
end IntegralRecursion
/-! ## Conclusion of the proof
The main theorem `Complex.tendsto_euler_sin_prod`, and its real variant
`Real.tendsto_euler_sin_prod`, now follow by combining `sin_pi_mul_eq` with a lemma
stating that the sequence of measures on `[0, Ο/2]` given by integration against `cos x ^ n`
(suitably normalised) tends to the Dirac measure at 0, as a special case of the general result
`tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_continuousOn`. -/
theorem tendsto_integral_cos_pow_mul_div {f : β β β} (hf : ContinuousOn f (Icc 0 (Ο / 2))) :
Tendsto
(fun n : β => (β« x in (0 : β)..Ο / 2, (cos x : β) ^ n * f x) /
(β« x in (0 : β)..Ο / 2, cos x ^ n : β))
atTop (π <| f 0) := by
simp_rw [div_eq_inv_mul (Ξ± := β), β Complex.ofReal_inv, integral_of_le pi_div_two_pos.le,
β MeasureTheory.integral_Icc_eq_integral_Ioc, β Complex.ofReal_pow, β Complex.real_smul]
have c_lt : β y : β, y β Icc 0 (Ο / 2) β y β 0 β cos y < cos 0 := fun y hy hy' =>
cos_lt_cos_of_nonneg_of_le_pi_div_two (le_refl 0) hy.2 (lt_of_le_of_ne hy.1 hy'.symm)
have c_nonneg : β x : β, x β Icc 0 (Ο / 2) β 0 β€ cos x := fun x hx =>
cos_nonneg_of_mem_Icc ((Icc_subset_Icc_left (neg_nonpos_of_nonneg pi_div_two_pos.le)) hx)
have c_zero_pos : 0 < cos 0 := by rw [cos_zero]; exact zero_lt_one
have zero_mem : (0 : β) β closure (interior (Icc 0 (Ο / 2))) := by
rw [interior_Icc, closure_Ioo pi_div_two_pos.ne, left_mem_Icc]
exact pi_div_two_pos.le
exact
tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_continuousOn isCompact_Icc
continuousOn_cos c_lt c_nonneg c_zero_pos zero_mem hf
/-- Euler's infinite product formula for the complex sine function. -/
theorem _root_.Complex.tendsto_euler_sin_prod (z : β) :
Tendsto (fun n : β => Ο * z * β j β Finset.range n, ((1 : β) - z ^ 2 / ((j : β) + 1) ^ 2))
atTop (π <| Complex.sin (Ο * z)) := by
have A :
Tendsto
(fun n : β =>
((Ο * z * β j β Finset.range n, ((1 : β) - z ^ 2 / ((j : β) + 1) ^ 2)) *
β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ (2 * n)) /
(β« x in (0 : β)..Ο / 2, cos x ^ (2 * n) : β))
atTop (π <| _) :=
Tendsto.congr (fun n => sin_pi_mul_eq z n) tendsto_const_nhds
have : π (Complex.sin (Ο * z)) = π (Complex.sin (Ο * z) * 1) := by rw [mul_one]
simp_rw [this, mul_div_assoc] at A
convert (tendsto_mul_iff_of_ne_zero _ one_ne_zero).mp A
suffices Tendsto (fun n : β =>
(β« x in (0 : β)..Ο / 2, Complex.cos (2 * z * x) * (cos x : β) ^ n) /
(β« x in (0 : β)..Ο / 2, cos x ^ n : β)) atTop (π 1) from
this.comp (tendsto_id.const_mul_atTop' zero_lt_two)
have : ContinuousOn (fun x : β => Complex.cos (2 * z * x)) (Icc 0 (Ο / 2)) :=
(Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)).continuousOn
convert tendsto_integral_cos_pow_mul_div this using 1
Β· ext1 n; congr 2 with x : 1; rw [mul_comm]
Β· rw [Complex.ofReal_zero, mul_zero, Complex.cos_zero]
/-- Euler's infinite product formula for the real sine function. -/
theorem _root_.Real.tendsto_euler_sin_prod (x : β) :
Tendsto (fun n : β => Ο * x * β j β Finset.range n, ((1 : β) - x ^ 2 / ((j : β) + 1) ^ 2))
atTop (π <| sin (Ο * x)) := by
convert (Complex.continuous_re.tendsto _).comp (Complex.tendsto_euler_sin_prod x) using 1
Β· ext1 n
rw [Function.comp_apply, β Complex.ofReal_mul, Complex.re_ofReal_mul]
suffices
(β j β Finset.range n, (1 - x ^ 2 / (j + 1) ^ 2) : β) =
(β j β Finset.range n, (1 - x ^ 2 / (j + 1) ^ 2) : β) by
rw [this, Complex.ofReal_re]
rw [Complex.ofReal_prod]
refine Finset.prod_congr (by rfl) fun n _ => ?_
norm_cast
Β· rw [β Complex.ofReal_mul, β Complex.ofReal_sin, Complex.ofReal_re]
end EulerSine |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean | import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
import Mathlib.Analysis.SpecialFunctions.Trigonometric.ArctanDeriv
/-!
# Polynomial bounds for trigonometric functions
## Main statements
This file contains upper and lower bounds for real trigonometric functions in terms
of polynomials. See `Trigonometric.Basic` for more elementary inequalities, establishing
the ranges of these functions, and their monotonicity in suitable intervals.
Here we prove the following:
* `sin_lt`: for `x > 0` we have `sin x < x`.
* `sin_gt_sub_cube`: For `0 < x β€ 1` we have `x - x ^ 3 / 4 < sin x`.
* `lt_tan`: for `0 < x < Ο/2` we have `x < tan x`.
* `cos_le_one_div_sqrt_sq_add_one` and `cos_lt_one_div_sqrt_sq_add_one`: for
`-3 * Ο / 2 β€ x β€ 3 * Ο / 2`, we have `cos x β€ 1 / sqrt (x ^ 2 + 1)`, with strict inequality if
`x β 0`. (This bound is not quite optimal, but not far off)
## Tags
sin, cos, tan, angle
-/
open Set
namespace Real
variable {x : β}
/-- For 0 < x, we have sin x < x. -/
theorem sin_lt (h : 0 < x) : sin x < x := by
rcases lt_or_ge 1 x with h' | h'
Β· exact (sin_le_one x).trans_lt h'
have hx : |x| = x := abs_of_nonneg h.le
have := le_of_abs_le (sin_bound <| show |x| β€ 1 by rwa [hx])
rw [sub_le_iff_le_add', hx] at this
apply this.trans_lt
rw [sub_add, sub_lt_self_iff, sub_pos, div_eq_mul_inv (x ^ 3)]
refine mul_lt_mul' ?_ (by norm_num) (by norm_num) (pow_pos h 3)
apply pow_le_pow_of_le_one h.le h'
simp
lemma sin_le (hx : 0 β€ x) : sin x β€ x := by
obtain rfl | hx := hx.eq_or_lt
Β· simp
Β· exact (sin_lt hx).le
lemma lt_sin (hx : x < 0) : x < sin x := by simpa using sin_lt <| neg_pos.2 hx
lemma le_sin (hx : x β€ 0) : x β€ sin x := by simpa using sin_le <| neg_nonneg.2 hx
theorem lt_sin_mul {x : β} (hx : 0 < x) (hx' : x < 1) : x < sin (Ο / 2 * x) := by
simpa [mul_comm x] using
strictConcaveOn_sin_Icc.2 β¨le_rfl, pi_pos.leβ© β¨pi_div_two_pos.le, half_le_self pi_pos.leβ©
pi_div_two_pos.ne (sub_pos.2 hx') hx
theorem le_sin_mul {x : β} (hx : 0 β€ x) (hx' : x β€ 1) : x β€ sin (Ο / 2 * x) := by
simpa [mul_comm x] using
strictConcaveOn_sin_Icc.concaveOn.2 β¨le_rfl, pi_pos.leβ©
β¨pi_div_two_pos.le, half_le_self pi_pos.leβ© (sub_nonneg.2 hx') hx
theorem mul_lt_sin {x : β} (hx : 0 < x) (hx' : x < Ο / 2) : 2 / Ο * x < sin x := by
rw [β inv_div]
simpa [-inv_div, mul_inv_cancel_leftβ pi_div_two_pos.ne'] using @lt_sin_mul ((Ο / 2)β»ΒΉ * x)
(mul_pos (inv_pos.2 pi_div_two_pos) hx) (by rwa [β div_eq_inv_mul, div_lt_one pi_div_two_pos])
/-- One half of **Jordan's inequality**.
In the range `[0, Ο / 2]`, we have a linear lower bound on `sin`. The other half is given by
`Real.sin_le`.
-/
theorem mul_le_sin {x : β} (hx : 0 β€ x) (hx' : x β€ Ο / 2) : 2 / Ο * x β€ sin x := by
rw [β inv_div]
simpa [-inv_div, mul_inv_cancel_leftβ pi_div_two_pos.ne'] using @le_sin_mul ((Ο / 2)β»ΒΉ * x)
(mul_nonneg (inv_nonneg.2 pi_div_two_pos.le) hx)
(by rwa [β div_eq_inv_mul, div_le_one pi_div_two_pos])
/-- Half of **Jordan's inequality** for negative values. -/
lemma sin_le_mul (hx : -(Ο / 2) β€ x) (hxβ : x β€ 0) : sin x β€ 2 / Ο * x := by
simpa using mul_le_sin (neg_nonneg.2 hxβ) (neg_le.2 hx)
/-- Half of **Jordan's inequality** for absolute values. -/
lemma mul_abs_le_abs_sin (hx : |x| β€ Ο / 2) : 2 / Ο * |x| β€ |sin x| := by
wlog hxβ : 0 β€ x
case inr => simpa using this (by rwa [abs_neg]) <| neg_nonneg.2 <| le_of_not_ge hxβ
rw [abs_of_nonneg hxβ] at hx β’
exact (mul_le_sin hxβ hx).trans (le_abs_self _)
lemma sin_sq_lt_sq (hx : x β 0) : sin x ^ 2 < x ^ 2 := by
wlog hxβ : 0 < x
case inr =>
simpa using this (neg_ne_zero.2 hx) <| neg_pos_of_neg <| hx.lt_of_le <| le_of_not_gt hxβ
rcases le_or_gt x 1 with hxΟ | hxΟ
case inl =>
exact pow_lt_pow_leftβ (sin_lt hxβ)
(sin_nonneg_of_nonneg_of_le_pi hxβ.le (by linarith [two_le_pi])) (by simp)
case inr =>
exact (sin_sq_le_one _).trans_lt (by rwa [one_lt_sq_iffβ hxβ.le])
lemma sin_sq_le_sq : sin x ^ 2 β€ x ^ 2 := by
rcases eq_or_ne x 0 with rfl | hx
case inl => simp
case inr => exact (sin_sq_lt_sq hx).le
lemma abs_sin_lt_abs (hx : x β 0) : |sin x| < |x| := sq_lt_sq.1 (sin_sq_lt_sq hx)
lemma abs_sin_le_abs : |sin x| β€ |x| := sq_le_sq.1 sin_sq_le_sq
lemma one_sub_sq_div_two_lt_cos (hx : x β 0) : 1 - x ^ 2 / 2 < cos x := by
have := (sin_sq_lt_sq (by positivity)).trans_eq' (sin_sq_eq_half_sub (x / 2)).symm
ring_nf at this
linarith
lemma one_sub_sq_div_two_le_cos : 1 - x ^ 2 / 2 β€ cos x := by
rcases eq_or_ne x 0 with rfl | hx
case inl => simp
case inr => exact (one_sub_sq_div_two_lt_cos hx).le
/-- Half of **Jordan's inequality** for `cos`. -/
lemma one_sub_mul_le_cos (hxβ : 0 β€ x) (hx : x β€ Ο / 2) : 1 - 2 / Ο * x β€ cos x := by
simpa [sin_pi_div_two_sub, mul_sub, div_mul_div_comm, mul_comm Ο, pi_pos.ne']
using mul_le_sin (x := Ο / 2 - x) (by simpa) (by simpa)
/-- Half of **Jordan's inequality** for `cos` and negative values. -/
lemma one_add_mul_le_cos (hxβ : -(Ο / 2) β€ x) (hx : x β€ 0) : 1 + 2 / Ο * x β€ cos x := by
simpa using one_sub_mul_le_cos (x := -x) (by linarith) (by linarith)
lemma cos_le_one_sub_mul_cos_sq (hx : |x| β€ Ο) : cos x β€ 1 - 2 / Ο ^ 2 * x ^ 2 := by
wlog hxβ : 0 β€ x
case inr => simpa using this (by rwa [abs_neg]) <| neg_nonneg.2 <| le_of_not_ge hxβ
rw [abs_of_nonneg hxβ] at hx
have : x / Ο β€ sin (x / 2) := by simpa using mul_le_sin (x := x / 2) (by positivity) (by linarith)
have := (pow_le_pow_leftβ (by positivity) this 2).trans_eq (sin_sq_eq_half_sub _)
ring_nf at this β’
linarith
/-- For 0 < x β€ 1 we have x - x ^ 3 / 4 < sin x.
This is also true for x > 1, but it's nontrivial for x just above 1. This inequality is not
tight; the tighter inequality is sin x > x - x ^ 3 / 6 for all x > 0, but this inequality has
a simpler proof. -/
theorem sin_gt_sub_cube {x : β} (h : 0 < x) (h' : x β€ 1) : x - x ^ 3 / 4 < sin x := by
have hx : |x| = x := abs_of_nonneg h.le
have := neg_le_of_abs_le (sin_bound <| show |x| β€ 1 by rwa [hx])
rw [le_sub_iff_add_le, hx] at this
refine lt_of_lt_of_le ?_ this
have : x ^ 3 / β4 - x ^ 3 / β6 = x ^ 3 * 12β»ΒΉ := by norm_num [div_eq_mul_inv, β mul_sub]
rw [add_comm, sub_add, sub_neg_eq_add, sub_lt_sub_iff_left, β lt_sub_iff_add_lt', this]
refine mul_lt_mul' ?_ (by norm_num) (by norm_num) (pow_pos h 3)
apply pow_le_pow_of_le_one h.le h'
simp
/-- The derivative of `tan x - x` is `1/(cos x)^2 - 1` away from the zeroes of cos. -/
theorem deriv_tan_sub_id (x : β) (h : cos x β 0) :
deriv (fun y : β => tan y - y) x = 1 / cos x ^ 2 - 1 :=
HasDerivAt.deriv <| by simpa using (hasDerivAt_tan h).add (hasDerivAt_id x).neg
/-- For all `0 < x < Ο/2` we have `x < tan x`.
This is proved by checking that the function `tan x - x` vanishes
at zero and has non-negative derivative. -/
theorem lt_tan {x : β} (h1 : 0 < x) (h2 : x < Ο / 2) : x < tan x := by
let U := Ico 0 (Ο / 2)
have intU : interior U = Ioo 0 (Ο / 2) := interior_Ico
have half_pi_pos : 0 < Ο / 2 := div_pos pi_pos two_pos
have cos_pos {y : β} (hy : y β U) : 0 < cos y := by
exact cos_pos_of_mem_Ioo (Ico_subset_Ioo_left (neg_lt_zero.mpr half_pi_pos) hy)
have sin_pos {y : β} (hy : y β interior U) : 0 < sin y := by
rw [intU] at hy
exact sin_pos_of_mem_Ioo (Ioo_subset_Ioo_right (div_le_self pi_pos.le one_le_two) hy)
have tan_cts_U : ContinuousOn tan U := by
apply ContinuousOn.mono continuousOn_tan
intro z hz
simp only [mem_setOf_eq]
exact (cos_pos hz).ne'
have tan_minus_id_cts : ContinuousOn (fun y : β => tan y - y) U := tan_cts_U.sub continuousOn_id
have deriv_pos (y : β) (hy : y β interior U) : 0 < deriv (fun y' : β => tan y' - y') y := by
have := cos_pos (interior_subset hy)
simp only [deriv_tan_sub_id y this.ne', one_div, gt_iff_lt, sub_pos]
norm_cast
have bd2 : cos y ^ 2 < 1 := by
apply lt_of_le_of_ne y.cos_sq_le_one
rw [cos_sq']
simpa only [Ne, sub_eq_self, sq_eq_zero_iff] using (sin_pos hy).ne'
rwa [lt_inv_commβ, inv_one]
Β· exact zero_lt_one
simpa only [sq, mul_self_pos] using this.ne'
have mono := strictMonoOn_of_deriv_pos (convex_Ico 0 (Ο / 2)) tan_minus_id_cts deriv_pos
have zero_in_U : (0 : β) β U := by rwa [left_mem_Ico]
have x_in_U : x β U := β¨h1.le, h2β©
simpa only [tan_zero, sub_zero, sub_pos] using mono zero_in_U x_in_U h1
theorem le_tan {x : β} (h1 : 0 β€ x) (h2 : x < Ο / 2) : x β€ tan x := by
rcases eq_or_lt_of_le h1 with (rfl | h1')
Β· rw [tan_zero]
Β· exact le_of_lt (lt_tan h1' h2)
theorem cos_lt_one_div_sqrt_sq_add_one {x : β} (hx1 : -(3 * Ο / 2) β€ x) (hx2 : x β€ 3 * Ο / 2)
(hx3 : x β 0) : cos x < (1 / β(x ^ 2 + 1) : β) := by
suffices β {y : β}, 0 < y β y β€ 3 * Ο / 2 β cos y < 1 / β(y ^ 2 + 1) by
rcases lt_or_lt_iff_ne.mpr hx3.symm with β¨hβ©
Β· exact this h hx2
Β· convert this (by linarith : 0 < -x) (by linarith) using 1
Β· rw [cos_neg]
Β· rw [neg_sq]
intro y hy1 hy2
have hy3 : β0 < y ^ 2 + 1 := by linarith [sq_nonneg y]
rcases lt_or_ge y (Ο / 2) with (hy2' | hy1')
Β· -- Main case : `0 < y < Ο / 2`
have hy4 : 0 < cos y := cos_pos_of_mem_Ioo β¨by linarith, hy2'β©
rw [β abs_of_nonneg (cos_nonneg_of_mem_Icc β¨by linarith, hy2'.leβ©), β
abs_of_nonneg (one_div_nonneg.mpr (sqrt_nonneg _)), β sq_lt_sq, div_pow, one_pow,
sq_sqrt hy3.le, lt_one_div (pow_pos hy4 _) hy3, β inv_one_add_tan_sq hy4.ne', one_div,
inv_inv, add_comm, add_lt_add_iff_left, sq_lt_sq, abs_of_pos hy1,
abs_of_nonneg (tan_nonneg_of_nonneg_of_le_pi_div_two hy1.le hy2'.le)]
exact Real.lt_tan hy1 hy2'
Β· -- Easy case : `Ο / 2 β€ y β€ 3 * Ο / 2`
refine lt_of_le_of_lt ?_ (one_div_pos.mpr <| sqrt_pos_of_pos hy3)
exact cos_nonpos_of_pi_div_two_le_of_le hy1' (by linarith [pi_pos])
theorem cos_le_one_div_sqrt_sq_add_one {x : β} (hx1 : -(3 * Ο / 2) β€ x) (hx2 : x β€ 3 * Ο / 2) :
cos x β€ (1 : β) / β(x ^ 2 + 1) := by
rcases eq_or_ne x 0 with (rfl | hx3)
Β· simp
Β· exact (cos_lt_one_div_sqrt_sq_add_one hx1 hx2 hx3).le
theorem norm_exp_I_mul_ofReal_sub_one_le {x : β} : β.exp (.I * x) - (1 : β)β β€ βxβ := by
rw [Complex.norm_exp_I_mul_ofReal_sub_one]
calc
_ = 2 * |Real.sin (x / 2)| := by simp
_ β€ 2 * |x / 2| := (mul_le_mul_iff_of_pos_left zero_lt_two).mpr Real.abs_sin_le_abs
_ = _ := by rw [abs_div, Nat.abs_ofNat, Real.norm_eq_abs]; ring
theorem enorm_exp_I_mul_ofReal_sub_one_le {x : β} : β.exp (.I * x) - (1 : β)ββ β€ βxββ := by
iterate 2 rw [β enorm_norm, Real.enorm_of_nonneg (norm_nonneg _)]
exact ENNReal.ofReal_le_ofReal norm_exp_I_mul_ofReal_sub_one_le
theorem nnnorm_exp_I_mul_ofReal_sub_one_le {x : β} : β.exp (.I * x) - (1 : β)ββ β€ βxββ := by
rw [β ENNReal.coe_le_coe]; exact enorm_exp_I_mul_ofReal_sub_one_le
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/Analytic.lean | import Mathlib.Analysis.Analytic.Composition
import Mathlib.Analysis.Analytic.Constructions
import Mathlib.Analysis.Complex.CauchyIntegral
import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv
/-!
# Various complex special functions are analytic
`log`, and `cpow` are analytic, since they are differentiable.
-/
open Complex Set
open scoped Topology
variable {E : Type} [NormedAddCommGroup E] [NormedSpace β E]
variable {f g : E β β} {z : β} {x : E} {s : Set E}
/-- `log` is analytic away from nonpositive reals -/
@[fun_prop]
theorem analyticAt_clog (m : z β slitPlane) : AnalyticAt β log z := by
rw [analyticAt_iff_eventually_differentiableAt]
filter_upwards [isOpen_slitPlane.eventually_mem m]
intro z m
exact differentiableAt_id.clog m
/-- `log` is analytic away from nonpositive reals -/
@[fun_prop]
theorem AnalyticAt.clog (fa : AnalyticAt β f x) (m : f x β slitPlane) :
AnalyticAt β (fun z β¦ log (f z)) x :=
(analyticAt_clog m).comp fa
theorem AnalyticWithinAt.clog (fa : AnalyticWithinAt β f s x) (m : f x β slitPlane) :
AnalyticWithinAt β (fun z β¦ log (f z)) s x :=
(analyticAt_clog m).comp_analyticWithinAt fa
/-- `log` is analytic away from nonpositive reals -/
theorem AnalyticOnNhd.clog (fs : AnalyticOnNhd β f s) (m : β z β s, f z β slitPlane) :
AnalyticOnNhd β (fun z β¦ log (f z)) s :=
fun z n β¦ (analyticAt_clog (m z n)).comp (fs z n)
theorem AnalyticOn.clog (fs : AnalyticOn β f s) (m : β z β s, f z β slitPlane) :
AnalyticOn β (fun z β¦ log (f z)) s :=
fun z n β¦ (analyticAt_clog (m z n)).analyticWithinAt.comp (fs z n) m
/-- `f z ^ g z` is analytic if `f z` is not a nonpositive real -/
theorem AnalyticWithinAt.cpow (fa : AnalyticWithinAt β f s x) (ga : AnalyticWithinAt β g s x)
(m : f x β slitPlane) : AnalyticWithinAt β (fun z β¦ f z ^ g z) s x := by
have e : (fun z β¦ f z ^ g z) =αΆ [π[insert x s] x] fun z β¦ exp (log (f z) * g z) := by
filter_upwards [(fa.continuousWithinAt_insert.eventually_ne (slitPlane_ne_zero m))]
intro z fz
simp only [fz, cpow_def, if_false]
apply AnalyticWithinAt.congr_of_eventuallyEq_insert _ e
exact ((fa.clog m).mul ga).cexp
/-- `f z ^ g z` is analytic if `f z` is not a nonpositive real -/
@[fun_prop]
theorem AnalyticAt.cpow (fa : AnalyticAt β f x) (ga : AnalyticAt β g x)
(m : f x β slitPlane) : AnalyticAt β (fun z β¦ f z ^ g z) x := by
rw [β analyticWithinAt_univ] at fa ga β’
exact fa.cpow ga m
/-- `f z ^ g z` is analytic if `f z` avoids nonpositive reals -/
theorem AnalyticOn.cpow (fs : AnalyticOn β f s) (gs : AnalyticOn β g s)
(m : β z β s, f z β slitPlane) : AnalyticOn β (fun z β¦ f z ^ g z) s :=
fun z n β¦ (fs z n).cpow (gs z n) (m z n)
/-- `f z ^ g z` is analytic if `f z` avoids nonpositive reals -/
theorem AnalyticOnNhd.cpow (fs : AnalyticOnNhd β f s) (gs : AnalyticOnNhd β g s)
(m : β z β s, f z β slitPlane) : AnalyticOnNhd β (fun z β¦ f z ^ g z) s :=
fun z n β¦ (fs z n).cpow (gs z n) (m z n)
section ReOfReal
variable {f : β β β} {s : Set β} {x : β}
@[fun_prop]
lemma AnalyticAt.re_ofReal (hf : AnalyticAt β f x) :
AnalyticAt β (fun x : β β¦ (f x).re) x :=
(Complex.reCLM.analyticAt _).comp (hf.restrictScalars.comp (Complex.ofRealCLM.analyticAt _))
@[fun_prop]
lemma AnalyticAt.im_ofReal (hf : AnalyticAt β f x) :
AnalyticAt β (fun x : β β¦ (f x).im) x :=
(Complex.imCLM.analyticAt _).comp (hf.restrictScalars.comp (Complex.ofRealCLM.analyticAt _))
lemma AnalyticWithinAt.re_ofReal (hf : AnalyticWithinAt β f (ofReal '' s) x) :
AnalyticWithinAt β (fun x : β β¦ (f x).re) s x :=
((Complex.reCLM.analyticWithinAt _ _).comp hf.restrictScalars (mapsTo_image f _)).comp
(Complex.ofRealCLM.analyticWithinAt _ _) (mapsTo_image ofReal s)
lemma AnalyticWithinAt.im_ofReal (hf : AnalyticWithinAt β f (ofReal '' s) x) :
AnalyticWithinAt β (fun x : β β¦ (f x).im) s x :=
((Complex.imCLM.analyticWithinAt _ _).comp hf.restrictScalars (mapsTo_image f _)).comp
(Complex.ofRealCLM.analyticWithinAt _ _) (mapsTo_image ofReal s)
lemma AnalyticOn.re_ofReal (hf : AnalyticOn β f (ofReal '' s)) :
AnalyticOn β (fun x : β β¦ (f x).re) s :=
((Complex.reCLM.analyticOn _).comp hf.restrictScalars (mapsTo_image f _)).comp
(Complex.ofRealCLM.analyticOn _) (mapsTo_image ofReal s)
lemma AnalyticOn.im_ofReal (hf : AnalyticOn β f (ofReal '' s)) :
AnalyticOn β (fun x : β β¦ (f x).im) s :=
((Complex.imCLM.analyticOn _).comp hf.restrictScalars (mapsTo_image f _)).comp
(Complex.ofRealCLM.analyticOn _) (mapsTo_image ofReal s)
lemma AnalyticOnNhd.re_ofReal (hf : AnalyticOnNhd β f (ofReal '' s)) :
AnalyticOnNhd β (fun x : β β¦ (f x).re) s :=
((Complex.reCLM.analyticOnNhd _).comp hf.restrictScalars (mapsTo_image f _)).comp
(Complex.ofRealCLM.analyticOnNhd _) (mapsTo_image ofReal s)
lemma AnalyticOnNhd.im_ofReal (hf : AnalyticOnNhd β f (ofReal '' s)) :
AnalyticOnNhd β (fun x : β β¦ (f x).im) s :=
((Complex.imCLM.analyticOnNhd _).comp hf.restrictScalars (mapsTo_image f _)).comp
(Complex.ofRealCLM.analyticOnNhd _) (mapsTo_image ofReal s)
end ReOfReal
section Real
variable {f : β β β} {s : Set β} {x : β}
@[fun_prop]
lemma analyticAt_log (hx : 0 < x) : AnalyticAt β Real.log x := by
have : Real.log = fun x : β β¦ (Complex.log x).re := by ext x; exact (Complex.log_ofReal_re x).symm
rw [this]
refine AnalyticAt.re_ofReal <| analyticAt_clog ?_
simp [hx]
lemma analyticOnNhd_log : AnalyticOnNhd β Real.log (Set.Ioi 0) := fun _ hx β¦ analyticAt_log hx
lemma analyticOn_log : AnalyticOn β Real.log (Set.Ioi 0) := analyticOnNhd_log.analyticOn
@[fun_prop]
lemma AnalyticAt.log (fa : AnalyticAt β f x) (m : 0 < f x) :
AnalyticAt β (fun z β¦ Real.log (f z)) x :=
(analyticAt_log m).comp fa
lemma AnalyticWithinAt.log (fa : AnalyticWithinAt β f s x) (m : 0 < f x) :
AnalyticWithinAt β (fun z β¦ Real.log (f z)) s x :=
(analyticAt_log m).comp_analyticWithinAt fa
lemma AnalyticOnNhd.log (fs : AnalyticOnNhd β f s) (m : β x β s, 0 < f x) :
AnalyticOnNhd β (fun z β¦ Real.log (f z)) s :=
fun z n β¦ (analyticAt_log (m z n)).comp (fs z n)
lemma AnalyticOn.log (fs : AnalyticOn β f s) (m : β x β s, 0 < f x) :
AnalyticOn β (fun z β¦ Real.log (f z)) s :=
fun z n β¦ (analyticAt_log (m z n)).analyticWithinAt.comp (fs z n) m
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean | import Mathlib.Analysis.SpecialFunctions.Complex.LogBounds
/-!
# Complex arctangent
This file defines the complex arctangent `Complex.arctan` as
$$\arctan z = -\frac i2 \log \frac{1 + zi}{1 - zi}$$
and shows that it extends `Real.arctan` to the complex plane. Its Taylor series expansion
$$\arctan z = \frac{(-1)^n}{2n + 1} z^{2n + 1},\ |z|<1$$
is proved in `Complex.hasSum_arctan`.
-/
namespace Complex
open scoped Real
/-- The complex arctangent, defined via the complex logarithm. -/
noncomputable def arctan (z : β) : β := -I / 2 * log ((1 + z * I) / (1 - z * I))
theorem tan_arctan {z : β} (hβ : z β I) (hβ : z β -I) : tan (arctan z) = z := by
unfold tan sin cos
rw [div_div_eq_mul_div, div_mul_cancelβ _ two_ne_zero, β div_mul_eq_mul_div,
-- multiply top and bottom by `exp (arctan z * I)`
β mul_div_mul_right _ _ (exp_ne_zero (arctan z * I)), sub_mul, add_mul,
β exp_add, neg_mul, neg_add_cancel, exp_zero, β exp_add, β two_mul]
have zβ : 1 + z * I β 0 := by
contrapose! hβ
rw [add_eq_zero_iff_neg_eq, β div_eq_iff I_ne_zero, div_I, neg_one_mul, neg_neg] at hβ
exact hβ.symm
have zβ : 1 - z * I β 0 := by
contrapose! hβ
rw [sub_eq_zero, β div_eq_iff I_ne_zero, div_I, one_mul] at hβ
exact hβ.symm
have key : exp (2 * (arctan z * I)) = (1 + z * I) / (1 - z * I) := by
rw [arctan, β mul_rotate, β mul_assoc,
show 2 * (I * (-I / 2)) = 1 by simp [field], one_mul, exp_log]
Β· exact div_ne_zero zβ zβ
-- multiply top and bottom by `1 - z * I`
rw [key, β mul_div_mul_right _ _ zβ, sub_mul, add_mul, div_mul_cancelβ _ zβ, one_mul,
show _ / _ * I = -(I * I) * z by ring, I_mul_I, neg_neg, one_mul]
/-- `cos z` is nonzero when the bounds in `arctan_tan` are met (`z` lies in the vertical strip
`-Ο / 2 < z.re < Ο / 2` and `z β Ο / 2`). -/
lemma cos_ne_zero_of_arctan_bounds {z : β} (hβ : z β Ο / 2) (hβ : -(Ο / 2) < z.re)
(hβ : z.re β€ Ο / 2) : cos z β 0 := by
refine cos_ne_zero_iff.mpr (fun k β¦ ?_)
rw [ne_eq, Complex.ext_iff, not_and_or] at hβ β’
norm_cast at hβ β’
rcases hβ with nr | ni
Β· left; contrapose! nr
rw [nr, mul_div_assoc, neg_eq_neg_one_mul, mul_lt_mul_iff_of_pos_right (by positivity)] at hβ
rw [nr, β one_mul (Ο / 2), mul_div_assoc, mul_le_mul_iff_of_pos_right (by positivity)] at hβ
norm_cast at hβ hβ
change -1 < _ at hβ
rwa [show 2 * k + 1 = 1 by cutsat, Int.cast_one, one_mul] at nr
Β· exact Or.inr ni
theorem arctan_tan {z : β} (hβ : z β Ο / 2) (hβ : -(Ο / 2) < z.re) (hβ : z.re β€ Ο / 2) :
arctan (tan z) = z := by
have h := cos_ne_zero_of_arctan_bounds hβ hβ hβ
unfold arctan tan
-- multiply top and bottom by `cos z`
rw [β mul_div_mul_right (1 + _) _ h, add_mul, sub_mul, one_mul, β mul_rotate, mul_div_cancelβ _ h]
conv_lhs =>
enter [2, 1, 2]
rw [sub_eq_add_neg, β neg_mul, β sin_neg, β cos_neg]
rw [β exp_mul_I, β exp_mul_I, β exp_sub, show z * I - -z * I = 2 * (I * z) by ring, log_exp,
show -I / 2 * (2 * (I * z)) = -(I * I) * z by ring, I_mul_I, neg_neg, one_mul]
all_goals norm_num
Β· rwa [β div_lt_iffβ' two_pos, neg_div]
Β· rwa [β le_div_iffβ' two_pos]
@[simp, norm_cast]
theorem ofReal_arctan (x : β) : (Real.arctan x : β) = arctan x := by
conv_rhs => rw [β Real.tan_arctan x]
rw [ofReal_tan, arctan_tan]
all_goals norm_cast
Β· rw [β ne_eq]; exact (Real.arctan_lt_pi_div_two _).ne
Β· exact Real.neg_pi_div_two_lt_arctan _
Β· exact (Real.arctan_lt_pi_div_two _).le
/-- The argument of `1 + z` for `z` in the open unit disc is always in `(-Ο / 2, Ο / 2)`. -/
lemma arg_one_add_mem_Ioo {z : β} (hz : βzβ < 1) : (1 + z).arg β Set.Ioo (-(Ο / 2)) (Ο / 2) := by
rw [Set.mem_Ioo, β abs_lt, abs_arg_lt_pi_div_two_iff, add_re, one_re, β neg_lt_iff_pos_add']
exact Or.inl (abs_lt.mp ((abs_re_le_norm z).trans_lt hz)).1
/-- We can combine the logs in `log (1 + z * I) + -log (1 - z * I)` into one.
This is only used in `hasSum_arctan`. -/
lemma hasSum_arctan_aux {z : β} (hz : βzβ < 1) :
log (1 + z * I) + -log (1 - z * I) = log ((1 + z * I) / (1 - z * I)) := by
have zβ := mem_slitPlane_iff_arg.mp (mem_slitPlane_of_norm_lt_one (z := z * I) (by simpa))
have zβ := mem_slitPlane_iff_arg.mp (mem_slitPlane_of_norm_lt_one (z := -(z * I)) (by simpa))
rw [β sub_eq_add_neg] at zβ
rw [β log_inv _ zβ.1, β (log_mul_eq_add_log_iff zβ.2 (inv_eq_zero.ne.mpr zβ.2)).mpr,
div_eq_mul_inv]
-- `log_mul_eq_add_log_iff` requires a bound on `arg (1 + z * I) + arg (1 - z * I)β»ΒΉ`.
-- `arg_one_add_mem_Ioo` provides sufficiently tight bounds on both terms
have bβ := arg_one_add_mem_Ioo (z := z * I) (by simpa)
have bβ : arg (1 - z * I)β»ΒΉ β Set.Ioo (-(Ο / 2)) (Ο / 2) := by
simp_rw [arg_inv, zβ.1, ite_false, Set.neg_mem_Ioo_iff, neg_neg, sub_eq_add_neg]
exact arg_one_add_mem_Ioo (by simpa)
have cβ := add_lt_add bβ.1 bβ.1
have cβ := add_lt_add bβ.2 bβ.2
rw [show -(Ο / 2) + -(Ο / 2) = -Ο by ring] at cβ
rw [show Ο / 2 + Ο / 2 = Ο by ring] at cβ
exact β¨cβ, cβ.leβ©
/-- The power series expansion of `Complex.arctan`, valid on the open unit disc. -/
theorem hasSum_arctan {z : β} (hz : βzβ < 1) :
HasSum (fun n : β β¦ (-1) ^ n * z ^ (2 * n + 1) / β(2 * n + 1)) (arctan z) := by
have := ((hasSum_taylorSeries_log (z := z * I) (by simpa)).add
(hasSum_taylorSeries_neg_log (z := z * I) (by simpa))).mul_left (-I / 2)
simp_rw [β add_div, β add_one_mul, hasSum_arctan_aux hz] at this
replace := (Nat.divModEquiv 2).symm.hasSum_iff.mpr this
dsimp [Function.comp_def] at this
simp_rw [β mul_comm 2 _] at this
refine this.prod_fiberwise fun k => ?_
dsimp only
convert hasSum_fintype (_ : Fin 2 β β) using 1
rw [Fin.sum_univ_two, Fin.val_zero, Fin.val_one, Odd.neg_one_pow (n := 2 * k + 0 + 1) (by simp),
neg_add_cancel, zero_mul, zero_div, mul_zero, zero_add,
show 2 * k + 1 + 1 = 2 * (k + 1) by ring, Even.neg_one_pow (n := 2 * (k + 1)) (by simp),
β mul_div_assoc (_ / _), β mul_assoc, show -I / 2 * (1 + 1) = -I by ring]
congr 1
rw [mul_pow, pow_succ' I, pow_mul, I_sq,
show -I * _ = -(I * I) * (-1) ^ k * z ^ (2 * k + 1) by ring, I_mul_I, neg_neg, one_mul]
end Complex
/-- The power series expansion of `Real.arctan`, valid on `-1 < x < 1`. -/
theorem Real.hasSum_arctan {x : β} (hx : βxβ < 1) :
HasSum (fun n : β => (-1) ^ n * x ^ (2 * n + 1) / β(2 * n + 1)) (arctan x) :=
mod_cast Complex.hasSum_arctan (z := x) (by simpa) |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/CircleMap.lean | import Mathlib.Analysis.SpecialFunctions.Complex.Log
import Mathlib.Order.Interval.Set.Defs
/-!
# circleMap
This file defines the circle map $ΞΈ β¦ c + R e^{ΞΈi}$, a parametrization of a circle.
## Main definitions
* `circleMap c R`: the exponential map $ΞΈ β¦ c + R e^{ΞΈi}$.
## Tags
-/
noncomputable section circleMap
open Complex Function Metric Real
/-- The exponential map $ΞΈ β¦ c + R e^{ΞΈi}$. The range of this map is the circle in `β` with center
`c` and radius `|R|`. -/
def circleMap (c : β) (R : β) : β β β := fun ΞΈ => c + R * exp (ΞΈ * I)
@[simp]
theorem circleMap_sub_center (c : β) (R : β) (ΞΈ : β) : circleMap c R ΞΈ - c = circleMap 0 R ΞΈ := by
simp [circleMap]
theorem circleMap_zero (R ΞΈ : β) : circleMap 0 R ΞΈ = R * exp (ΞΈ * I) := zero_add _
@[simp]
theorem norm_circleMap_zero (R : β) (ΞΈ : β) : βcircleMap 0 R ΞΈβ = |R| := by simp [circleMap]
theorem circleMap_notMem_ball (c : β) (R : β) (ΞΈ : β) : circleMap c R ΞΈ β ball c R := by
simp [Complex.dist_eq, le_abs_self]
@[deprecated (since := "2025-05-23")] alias circleMap_not_mem_ball := circleMap_notMem_ball
theorem circleMap_ne_mem_ball {c : β} {R : β} {w : β} (hw : w β ball c R) (ΞΈ : β) :
circleMap c R ΞΈ β w :=
(ne_of_mem_of_not_mem hw (circleMap_notMem_ball _ _ _)).symm
theorem circleMap_mem_sphere' (c : β) (R : β) (ΞΈ : β) : circleMap c R ΞΈ β sphere c |R| := by simp
theorem circleMap_mem_sphere (c : β) {R : β} (hR : 0 β€ R) (ΞΈ : β) :
circleMap c R ΞΈ β sphere c R := by
simpa only [abs_of_nonneg hR] using circleMap_mem_sphere' c R ΞΈ
theorem circleMap_mem_closedBall (c : β) {R : β} (hR : 0 β€ R) (ΞΈ : β) :
circleMap c R ΞΈ β closedBall c R :=
sphere_subset_closedBall (circleMap_mem_sphere c hR ΞΈ)
@[simp]
theorem circleMap_eq_center_iff {c : β} {R : β} {ΞΈ : β} : circleMap c R ΞΈ = c β R = 0 := by
simp [circleMap, Complex.exp_ne_zero]
@[simp]
theorem circleMap_zero_radius (c : β) : circleMap c 0 = const β c :=
funext fun _ => circleMap_eq_center_iff.2 rfl
theorem circleMap_ne_center {c : β} {R : β} (hR : R β 0) {ΞΈ : β} : circleMap c R ΞΈ β c :=
mt circleMap_eq_center_iff.1 hR
lemma circleMap_zero_mul (Rβ Rβ ΞΈβ ΞΈβ : β) :
(circleMap 0 Rβ ΞΈβ) * (circleMap 0 Rβ ΞΈβ) = circleMap 0 (Rβ * Rβ) (ΞΈβ + ΞΈβ) := by
simp only [circleMap_zero, ofReal_mul, ofReal_add, add_mul, Complex.exp_add]
ring
lemma circleMap_zero_div (Rβ Rβ ΞΈβ ΞΈβ : β) :
(circleMap 0 Rβ ΞΈβ) / (circleMap 0 Rβ ΞΈβ) = circleMap 0 (Rβ / Rβ) (ΞΈβ - ΞΈβ) := by
simp only [circleMap_zero, ofReal_div, ofReal_sub, sub_mul, Complex.exp_sub]
ring
lemma circleMap_zero_inv (R ΞΈ : β) : (circleMap 0 R ΞΈ)β»ΒΉ = circleMap 0 Rβ»ΒΉ (-ΞΈ) := by
simp [circleMap_zero, Complex.exp_neg, mul_comm]
lemma circleMap_zero_pow (n : β) (R ΞΈ : β) :
(circleMap 0 R ΞΈ) ^ n = circleMap 0 (R ^ n) (n * ΞΈ) := by
simp [circleMap_zero, mul_pow, β Complex.exp_nat_mul, β mul_assoc]
lemma circleMap_zero_zpow (n : β€) (R ΞΈ : β) :
(circleMap 0 R ΞΈ) ^ n = circleMap 0 (R ^ n) (n * ΞΈ) := by
simp [circleMap_zero, mul_zpow, β exp_int_mul, β mul_assoc]
lemma circleMap_pi_div_two (c : β) (R : β) : circleMap c R (Ο / 2) = c + R * I := by
simp only [circleMap, ofReal_div, ofReal_ofNat, exp_pi_div_two_mul_I]
lemma circleMap_neg_pi_div_two (c : β) (R : β) : circleMap c R (-Ο / 2) = c - R * I := by
simp only [circleMap, ofReal_div, ofReal_neg, ofReal_ofNat, exp_neg_pi_div_two_mul_I, mul_neg,
sub_eq_add_neg]
/-- `circleMap` is `2Ο`-periodic. -/
theorem periodic_circleMap (c : β) (R : β) : Periodic (circleMap c R) (2 * Ο) := fun ΞΈ => by
simp [circleMap, add_mul, exp_periodic _]
theorem Set.Countable.preimage_circleMap {s : Set β} (hs : s.Countable) (c : β) {R : β}
(hR : R β 0) : (circleMap c R β»ΒΉ' s).Countable :=
show (((β) : β β β) β»ΒΉ' ((Β· * I) β»ΒΉ'
(exp β»ΒΉ' ((R * Β·) β»ΒΉ' ((c + Β·) β»ΒΉ' s))))).Countable from
(((hs.preimage (add_right_injective _)).preimage <|
mul_right_injectiveβ <| ofReal_ne_zero.2 hR).preimage_cexp.preimage <|
mul_left_injectiveβ I_ne_zero).preimage ofReal_injective
lemma circleMap_eq_circleMap_iff {a b R : β} (c : β) (h_R : R β 0) :
circleMap c R a = circleMap c R b β β (n : β€), a * I = b * I + n * (2 * Ο * I) := by
have : circleMap c R a = circleMap c R b β (exp (a * I)).arg = (exp (b * I)).arg := by
simp [circleMap, ext_norm_arg_iff, h_R]
simp [this, arg_eq_arg_iff, exp_eq_exp_iff_exists_int]
lemma eq_of_circleMap_eq {a b R : β} {c : β} (h_R : R β 0) (h_dist : |a - b| < 2 * Ο)
(h : circleMap c R a = circleMap c R b) : a = b := by
rw [circleMap_eq_circleMap_iff c h_R] at h
obtain β¨n, hnβ© := h
simp only [show n * (2 * Ο * I) = (n * 2 * Ο) * I by ring, β add_mul, mul_eq_mul_right_iff,
I_ne_zero, or_false] at hn
norm_cast at hn
simp only [hn, Int.cast_mul, Int.cast_ofNat, mul_assoc, add_sub_cancel_left, abs_mul,
Nat.abs_ofNat, abs_of_pos Real.pi_pos] at h_dist
simp (disch := positivity) at h_dist
norm_cast at h_dist
simp [hn, Int.abs_lt_one_iff.mp h_dist]
open scoped Interval in
/-- `circleMap` is injective on `Ξ a b` if the distance between `a` and `b` is at most `2Ο`. -/
theorem injOn_circleMap_of_abs_sub_le {a b R : β} {c : β} (h_R : R β 0) (_ : |a - b| β€ 2 * Ο) :
(Ξ a b).InjOn (circleMap c R) := by
rintro _ β¨_, _β© _ β¨_, _β© h
apply eq_of_circleMap_eq h_R _ h
rw [abs_lt]
constructor <;> linarith [max_sub_min_eq_abs' a b]
/-- `circleMap` is injective on `Ico a b` if the distance between `a` and `b` is at most `2Ο`. -/
theorem injOn_circleMap_of_abs_sub_le' {a b R : β} {c : β} (h_R : R β 0) (_ : b - a β€ 2 * Ο) :
(Set.Ico a b).InjOn (circleMap c R) := by
rintro _ β¨_, _β© _ β¨_, _β© h
apply eq_of_circleMap_eq h_R _ h
rw [abs_lt]
constructor <;> linarith
end circleMap |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
/-!
# The argument of a complex number.
We define `arg : β β β`, returning a real number in the range (-Ο, Ο],
such that for `x β 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
open Filter Metric Set
open scoped ComplexConjugate Real Topology
namespace Complex
variable {a x z : β}
/-- `arg` returns values in the range (-Ο, Ο], such that for `x β 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : β) : β :=
if 0 β€ x.re then Real.arcsin (x.im / βxβ)
else if 0 β€ x.im then Real.arcsin ((-x).im / βxβ) + Ο else Real.arcsin ((-x).im / βxβ) - Ο
theorem sin_arg (x : β) : Real.sin (arg x) = x.im / βxβ := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, Real.sin_arcsin (abs_le.1 (abs_im_div_norm_le_one x)).1
(abs_le.1 (abs_im_div_norm_le_one x)).2, Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
theorem cos_arg {x : β} (hx : x β 0) : Real.cos (arg x) = x.re / βxβ := by
rw [arg]
split_ifs with hβ hβ
Β· rw [Real.cos_arcsin]
field_simp
simp [Real.sqrt_sq, (norm_pos_iff.mpr hx).le, *]
field
Β· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp
simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 hβ), *]
field
Β· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp
simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 hβ), *]
field
@[simp]
theorem norm_mul_exp_arg_mul_I (x : β) : βxβ * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
Β· simp
Β· have : βxβ β 0 := norm_ne_zero_iff.mpr hx
apply Complex.ext <;> simp [sin_arg, cos_arg hx, this, mul_comm βxβ]
@[simp]
theorem norm_mul_cos_add_sin_mul_I (x : β) : (βxβ * (cos (arg x) + sin (arg x) * I) : β) = x := by
rw [β exp_mul_I, norm_mul_exp_arg_mul_I]
@[simp]
lemma norm_mul_cos_arg (x : β) : βxβ * Real.cos (arg x) = x.re := by
simpa [-norm_mul_cos_add_sin_mul_I] using congr_arg re (norm_mul_cos_add_sin_mul_I x)
@[simp]
lemma norm_mul_sin_arg (x : β) : βxβ * Real.sin (arg x) = x.im := by
simpa [-norm_mul_cos_add_sin_mul_I] using congr_arg im (norm_mul_cos_add_sin_mul_I x)
theorem norm_eq_one_iff (z : β) : βzβ = 1 β β ΞΈ : β, exp (ΞΈ * I) = z := by
refine β¨fun hz => β¨arg z, ?_β©, ?_β©
Β· calc
exp (arg z * I) = βzβ * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z :=norm_mul_exp_arg_mul_I z
Β· rintro β¨ΞΈ, rflβ©
exact Complex.norm_exp_ofReal_mul_I ΞΈ
@[simp]
theorem range_exp_mul_I : (Set.range fun x : β => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_one_iff, Set.mem_range]
theorem arg_mul_cos_add_sin_mul_I {r : β} (hr : 0 < r) {ΞΈ : β} (hΞΈ : ΞΈ β Set.Ioc (-Ο) Ο) :
arg (r * (cos ΞΈ + sin ΞΈ * I)) = ΞΈ := by
simp only [arg, norm_mul, norm_cos_add_sin_mul_I, Complex.norm_of_nonneg hr.le, mul_one]
simp only [re_ofReal_mul, im_ofReal_mul, neg_im, β ofReal_cos, β ofReal_sin, β
mk_eq_add_mul_I, neg_div, mul_div_cancel_leftβ _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases hβ : ΞΈ β Set.Icc (-(Ο / 2)) (Ο / 2)
Β· rw [if_pos]
exacts [Real.arcsin_sin' hβ, Real.cos_nonneg_of_mem_Icc hβ]
Β· rw [Set.mem_Icc, not_and_or, not_le, not_le] at hβ
rcases hβ with hβ | hβ
Β· replace hΞΈ := hΞΈ.1
have hcos : Real.cos ΞΈ < 0 := by
rw [β neg_pos, β Real.cos_add_pi]
refine Real.cos_pos_of_mem_Ioo β¨?_, ?_β© <;> linarith
have hsin : Real.sin ΞΈ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hΞΈ
rw [if_neg, if_neg, β Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel_right] <;> [linarith;
linarith; exact hsin.not_ge; exact hcos.not_ge]
Β· replace hΞΈ := hΞΈ.2
have hcos : Real.cos ΞΈ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt hβ (by linarith)
have hsin : 0 β€ Real.sin ΞΈ := Real.sin_nonneg_of_mem_Icc β¨by linarith, hΞΈβ©
rw [if_neg, if_pos, β Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_ge]
theorem arg_cos_add_sin_mul_I {ΞΈ : β} (hΞΈ : ΞΈ β Set.Ioc (-Ο) Ο) : arg (cos ΞΈ + sin ΞΈ * I) = ΞΈ := by
rw [β one_mul (_ + _), β ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hΞΈ]
lemma arg_exp_mul_I (ΞΈ : β) :
arg (exp (ΞΈ * I)) = toIocMod (mul_pos two_pos Real.pi_pos) (-Ο) ΞΈ := by
convert arg_cos_add_sin_mul_I (ΞΈ := toIocMod (mul_pos two_pos Real.pi_pos) (-Ο) ΞΈ) _ using 2
Β· rw [β exp_mul_I, eq_sub_of_add_eq <| toIocMod_add_toIocDiv_zsmul _ _ ΞΈ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
Β· convert toIocMod_mem_Ioc _ _ _
ring
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
theorem ext_norm_arg {x y : β} (hβ : βxβ = βyβ) (hβ : x.arg = y.arg) : x = y := by
rw [β norm_mul_exp_arg_mul_I x, β norm_mul_exp_arg_mul_I y, hβ, hβ]
theorem ext_norm_arg_iff {x y : β} : x = y β βxβ = βyβ β§ arg x = arg y :=
β¨fun h => h βΈ β¨rfl, rflβ©, and_imp.2 ext_norm_argβ©
theorem arg_mem_Ioc (z : β) : arg z β Set.Ioc (-Ο) Ο := by
have hΟ : 0 < Ο := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz)
Β· simp [hΟ, hΟ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-Ο) with β¨N, hN, -β©
rw [two_mul, neg_add_cancel_left, β two_mul, zsmul_eq_mul] at hN
rw [β norm_mul_cos_add_sin_mul_I z, β cos_add_int_mul_two_pi _ N, β sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (norm_pos_iff.mpr hz) hN
push_cast at this
rwa [this]
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-Ο) Ο :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => β¨_, arg_cos_add_sin_mul_I hxβ©
theorem arg_le_pi (x : β) : arg x β€ Ο :=
(arg_mem_Ioc x).2
theorem neg_pi_lt_arg (x : β) : -Ο < arg x :=
(arg_mem_Ioc x).1
theorem abs_arg_le_pi (z : β) : |arg z| β€ Ο :=
abs_le.2 β¨(neg_pi_lt_arg z).le, arg_le_pi zβ©
@[simp]
theorem arg_nonneg_iff {z : β} : 0 β€ arg z β 0 β€ z.im := by
rcases eq_or_ne z 0 with (rfl | hβ); Β· simp
calc
0 β€ arg z β 0 β€ Real.sin (arg z) :=
β¨fun h => Real.sin_nonneg_of_mem_Icc β¨h, arg_le_pi zβ©, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)β©
_ β _ := by rw [sin_arg, le_div_iffβ (norm_pos_iff.mpr hβ), zero_mul]
@[simp]
theorem arg_neg_iff {z : β} : arg z < 0 β z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
theorem arg_real_mul (x : β) {r : β} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); Β· rw [mul_zero]
conv_lhs =>
rw [β norm_mul_cos_add_sin_mul_I x, β mul_assoc, β ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (norm_pos_iff.mpr hx)) x.arg_mem_Ioc]
theorem arg_mul_real {r : β} (hr : 0 < r) (x : β) : arg (x * r) = arg x :=
mul_comm x r βΈ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : β} (hx : x β 0) (hy : y β 0) :
arg x = arg y β (βyβ / βxβ : β) * x = y := by
simp only [ext_norm_arg_iff, norm_mul, norm_div, norm_real, norm_norm,
div_mul_cancelβ _ (norm_ne_zero_iff.mpr hx), true_and]
rw [β ofReal_div, arg_real_mul]
exact div_pos (norm_pos_iff.mpr hy) (norm_pos_iff.mpr hx)
@[simp] lemma arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
/-- This holds true for all `x : β` because of the junk values `0 / 0 = 0` and `arg 0 = 0`. -/
@[simp] lemma arg_div_self (x : β) : arg (x / x) = 0 := by
obtain rfl | hx := eq_or_ne x 0 <;> simp [*]
@[simp]
theorem arg_neg_one : arg (-1) = Ο := by simp [arg, le_refl, not_le.2 (zero_lt_one' β)]
@[simp]
theorem arg_I : arg I = Ο / 2 := by simp [arg, le_refl]
@[simp]
theorem arg_neg_I : arg (-I) = -(Ο / 2) := by simp [arg, le_refl]
@[simp]
theorem tan_arg (x : β) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
Β· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h,
div_div_div_cancel_rightβ (norm_ne_zero_iff.mpr h)]
theorem arg_ofReal_of_nonneg {x : β} (hx : 0 β€ x) : arg x = 0 := by simp [arg, hx]
@[simp, norm_cast]
lemma natCast_arg {n : β} : arg n = 0 :=
ofReal_natCast n βΈ arg_ofReal_of_nonneg n.cast_nonneg
@[simp]
lemma ofNat_arg {n : β} [n.AtLeastTwo] : arg ofNat(n) = 0 :=
natCast_arg
theorem arg_eq_zero_iff {z : β} : arg z = 0 β 0 β€ z.re β§ z.im = 0 := by
refine β¨fun h => ?_, ?_β©
Β· rw [β norm_mul_cos_add_sin_mul_I z, h]
simp [norm_nonneg]
Β· obtain β¨x, yβ© := z
rintro β¨h, rfl : y = 0β©
exact arg_ofReal_of_nonneg h
open ComplexOrder in
lemma arg_eq_zero_iff_zero_le {z : β} : arg z = 0 β 0 β€ z := by
rw [arg_eq_zero_iff, eq_comm, nonneg_iff]
theorem arg_eq_pi_iff {z : β} : arg z = Ο β z.re < 0 β§ z.im = 0 := by
by_cases hβ : z = 0
Β· simp [hβ, Real.pi_ne_zero.symm]
constructor
Β· intro h
rw [β norm_mul_cos_add_sin_mul_I z, h]
simp [hβ]
Β· obtain β¨x, yβ© := z
rintro β¨h : x < 0, rfl : y = 0β©
rw [β arg_neg_one, β arg_real_mul (-1) (neg_pos.2 h)]
simp [β ofReal_def]
open ComplexOrder in
lemma arg_eq_pi_iff_lt_zero {z : β} : arg z = Ο β z < 0 := arg_eq_pi_iff
theorem arg_lt_pi_iff {z : β} : arg z < Ο β 0 β€ z.re β¨ z.im β 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
theorem arg_ofReal_of_neg {x : β} (hx : x < 0) : arg x = Ο :=
arg_eq_pi_iff.2 β¨hx, rflβ©
theorem arg_eq_pi_div_two_iff {z : β} : arg z = Ο / 2 β z.re = 0 β§ 0 < z.im := by
by_cases hβ : z = 0; Β· simp [hβ, Real.pi_div_two_pos.ne]
constructor
Β· intro h
rw [β norm_mul_cos_add_sin_mul_I z, h]
simp [hβ]
Β· obtain β¨x, yβ© := z
rintro β¨rfl : x = 0, hy : 0 < yβ©
rw [β arg_I, β arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
theorem arg_eq_neg_pi_div_two_iff {z : β} : arg z = -(Ο / 2) β z.re = 0 β§ z.im < 0 := by
by_cases hβ : z = 0; Β· simp [hβ, Real.pi_ne_zero]
constructor
Β· intro h
rw [β norm_mul_cos_add_sin_mul_I z, h]
simp [hβ]
Β· obtain β¨x, yβ© := z
rintro β¨rfl : x = 0, hy : y < 0β©
rw [β arg_neg_I, β arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
theorem arg_of_re_nonneg {x : β} (hx : 0 β€ x.re) : arg x = Real.arcsin (x.im / βxβ) :=
if_pos hx
theorem arg_of_re_neg_of_im_nonneg {x : β} (hx_re : x.re < 0) (hx_im : 0 β€ x.im) :
arg x = Real.arcsin ((-x).im / βxβ) + Ο := by
simp only [arg, hx_re.not_ge, hx_im, if_true, if_false]
theorem arg_of_re_neg_of_im_neg {x : β} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / βxβ) - Ο := by
simp only [arg, hx_re.not_ge, hx_im.not_ge, if_false]
theorem arg_of_im_nonneg_of_ne_zero {z : β} (hβ : 0 β€ z.im) (hβ : z β 0) :
arg z = Real.arccos (z.re / βzβ) := by
rw [β cos_arg hβ, Real.arccos_cos (arg_nonneg_iff.2 hβ) (arg_le_pi _)]
theorem arg_of_im_pos {z : β} (hz : 0 < z.im) : arg z = Real.arccos (z.re / βzβ) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm βΈ rfl
theorem arg_of_im_neg {z : β} (hz : z.im < 0) : arg z = -Real.arccos (z.re / βzβ) := by
have hβ : z β 0 := mt (congr_arg im) hz.ne
rw [β cos_arg hβ, β Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
theorem arg_conj (x : β) : arg (conj x) = if arg x = Ο then Ο else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, norm_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
Β· simp [hr, hr.not_ge, hi.le, hi.ne, not_le.2 hi, add_comm]
Β· simp [hr, hr.not_ge, hi]
Β· simp [hr, hr.not_ge, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
Β· simp [hr]
Β· simp [hr]
Β· simp [hr]
Β· simp [hr.le, hi.ne]
Β· simp [hr.le, hr.le.not_gt]
Β· simp [hr.le, hr.le.not_gt]
theorem arg_inv (x : β) : arg xβ»ΒΉ = if arg x = Ο then Ο else -arg x := by
rw [β arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
Β· simp [hx]
Β· exact arg_real_mul (conj x) (by simp [hx])
@[simp] lemma abs_arg_inv (x : β) : |xβ»ΒΉ.arg| = |x.arg| := by rw [arg_inv]; split_ifs <;> simp [*]
-- TODO: Replace the next two lemmas by general facts about periodic functions
lemma norm_eq_one_iff' : βxβ = 1 β β ΞΈ β Set.Ioc (-Ο) Ο, exp (ΞΈ * I) = x := by
rw [norm_eq_one_iff]
constructor
Β· rintro β¨ΞΈ, rflβ©
refine β¨toIocMod (mul_pos two_pos Real.pi_pos) (-Ο) ΞΈ, ?_, ?_β©
Β· convert toIocMod_mem_Ioc _ _ _
ring
Β· rw [eq_sub_of_add_eq <| toIocMod_add_toIocDiv_zsmul _ _ ΞΈ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
Β· rintro β¨ΞΈ, _, rflβ©
exact β¨ΞΈ, rflβ©
lemma image_exp_Ioc_eq_sphere : (fun ΞΈ : β β¦ exp (ΞΈ * I)) '' Set.Ioc (-Ο) Ο = sphere 0 1 := by
ext; simpa using norm_eq_one_iff'.symm
theorem arg_le_pi_div_two_iff {z : β} : arg z β€ Ο / 2 β 0 β€ re z β¨ im z < 0 := by
rcases le_or_gt 0 (re z) with hre | hre
Β· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or]
simp only [hre.not_ge, false_or]
rcases le_or_gt 0 (im z) with him | him
Β· simp only [him.not_gt]
rw [iff_false, not_le, arg_of_re_neg_of_im_nonneg hre him, β sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, β
abs_of_nonneg him, abs_im_lt_norm]
exacts [hre.ne, norm_pos_iff.mpr <| ne_of_apply_ne re hre.ne]
Β· simp only [him]
rw [iff_true, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
theorem neg_pi_div_two_le_arg_iff {z : β} : -(Ο / 2) β€ arg z β 0 β€ re z β¨ 0 β€ im z := by
rcases le_or_gt 0 (re z) with hre | hre
Β· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or]
simp only [hre.not_ge, false_or]
rcases le_or_gt 0 (im z) with him | him
Β· simp only [him]
rw [iff_true, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
Β· simp only [him.not_ge]
rw [iff_false, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', β
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, β abs_of_neg him,
abs_im_lt_norm]
exacts [hre.ne, norm_pos_iff.mpr <| ne_of_apply_ne re hre.ne]
lemma neg_pi_div_two_lt_arg_iff {z : β} : -(Ο / 2) < arg z β 0 < re z β¨ 0 β€ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
Β· simp [hre.ne, hre.not_ge, hre.not_gt]
Β· simp [hre]
Β· simp [hre, hre.le, hre.ne']
lemma arg_lt_pi_div_two_iff {z : β} : arg z < Ο / 2 β 0 < re z β¨ im z < 0 β¨ z = 0 := by
rw [lt_iff_le_and_ne, arg_le_pi_div_two_iff, Ne, arg_eq_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
Β· have : z β 0 := by simp [Complex.ext_iff, hre.ne]
simp [hre.ne, hre.not_ge, hre.not_gt, this]
Β· have : z = 0 β z.im = 0 := by simp [Complex.ext_iff, hre]
simp [hre, this, or_comm, le_iff_eq_or_lt]
Β· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : β} : |arg z| β€ Ο / 2 β 0 β€ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, β or_and_left, β not_le,
and_not_self_iff, or_false]
@[simp]
theorem abs_arg_lt_pi_div_two_iff {z : β} : |arg z| < Ο / 2 β 0 < re z β¨ z = 0 := by
rw [abs_lt, arg_lt_pi_div_two_iff, neg_pi_div_two_lt_arg_iff, β or_and_left]
rcases eq_or_ne z 0 with hz | hz
Β· simp [hz]
Β· simp_rw [hz, or_false, β not_lt, not_and_self_iff, or_false]
@[simp]
theorem arg_conj_coe_angle (x : β) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = Ο <;> simp [arg_conj, h]
@[simp]
theorem arg_inv_coe_angle (x : β) : (arg xβ»ΒΉ : Real.Angle) = -arg x := by
by_cases h : arg x = Ο <;> simp [arg_inv, h]
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : β} (hi : 0 < x.im) : arg (-x) = arg x - Ο := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : β} (hi : x.im < 0) : arg (-x) = arg x + Ο := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, β sub_eq_add_neg]
theorem arg_neg_eq_arg_sub_pi_iff {x : β} :
arg (-x) = arg x - Ο β 0 < x.im β¨ x.im = 0 β§ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
Β· simp [hi, hi.ne, hi.not_gt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, β
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
Β· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
Β· rw [arg_ofReal_of_neg hr, β ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
Β· simp [hr, Real.pi_ne_zero]
Β· rw [arg_ofReal_of_nonneg hr.le, β ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_gt, β add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
Β· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
theorem arg_neg_eq_arg_add_pi_iff {x : β} :
arg (-x) = arg x + Ο β x.im < 0 β¨ x.im = 0 β§ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
Β· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
Β· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
Β· rw [arg_ofReal_of_neg hr, β ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_gt, β two_mul, Real.pi_ne_zero]
Β· simp [hr, Real.pi_ne_zero.symm]
Β· rw [arg_ofReal_of_nonneg hr.le, β ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
Β· simp [hi, hi.ne.symm, hi.not_gt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, β
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
theorem arg_neg_coe_angle {x : β} (hx : x β 0) : (arg (-x) : Real.Angle) = arg x + Ο := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
Β· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
Β· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
Β· rw [arg_ofReal_of_neg hr, β ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, β
Real.Angle.coe_add, β two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
Β· exact False.elim (hx (ext hr hi))
Β· rw [arg_ofReal_of_nonneg hr.le, β ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
Β· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : β} (hr : 0 < r) (ΞΈ : β) :
arg (r * (cos ΞΈ + sin ΞΈ * I)) = toIocMod Real.two_pi_pos (-Ο) ΞΈ := by
have hi : toIocMod Real.two_pi_pos (-Ο) ΞΈ β Set.Ioc (-Ο) Ο := by
convert toIocMod_mem_Ioc _ _ ΞΈ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
theorem arg_cos_add_sin_mul_I_eq_toIocMod (ΞΈ : β) :
arg (cos ΞΈ + sin ΞΈ * I) = toIocMod Real.two_pi_pos (-Ο) ΞΈ := by
rw [β one_mul (_ + _), β ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
theorem arg_mul_cos_add_sin_mul_I_sub {r : β} (hr : 0 < r) (ΞΈ : β) :
arg (r * (cos ΞΈ + sin ΞΈ * I)) - ΞΈ = 2 * Ο * β(Ο - ΞΈ) / (2 * Ο)β := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
theorem arg_cos_add_sin_mul_I_sub (ΞΈ : β) :
arg (cos ΞΈ + sin ΞΈ * I) - ΞΈ = 2 * Ο * β(Ο - ΞΈ) / (2 * Ο)β := by
rw [β one_mul (_ + _), β ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : β} (hr : 0 < r) (ΞΈ : Real.Angle) :
(arg (r * (Real.Angle.cos ΞΈ + Real.Angle.sin ΞΈ * I)) : Real.Angle) = ΞΈ := by
induction ΞΈ using Real.Angle.induction_on with | _ ΞΈ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use β(Ο - ΞΈ) / (2 * Ο)β
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr ΞΈ
theorem arg_cos_add_sin_mul_I_coe_angle (ΞΈ : Real.Angle) :
(arg (Real.Angle.cos ΞΈ + Real.Angle.sin ΞΈ * I) : Real.Angle) = ΞΈ := by
rw [β one_mul (_ + _), β ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
theorem arg_mul_coe_angle {x y : β} (hx : x β 0) (hy : y β 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy))
(arg x + arg y : Real.Angle) using 3
simp_rw [β Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), β mul_assoc (βyβ : β), norm_mul_exp_arg_mul_I, mul_comm y, β
mul_assoc, norm_mul_exp_arg_mul_I]
theorem arg_div_coe_angle {x y : β} (hx : x β 0) (hy : y β 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
theorem arg_pow_coe_angle (x : β) (n : β) :
(arg (x ^ n) : Real.Angle) = n β’ (arg x : Real.Angle) := by
obtain rfl | x0 := eq_or_ne x 0
Β· by_cases n0 : n = 0 <;> simp [n0]
Β· induction n with
| zero => simp
| succ n ih => rw [pow_succ, arg_mul_coe_angle (pow_ne_zero n x0) x0, ih, succ_nsmul]
theorem arg_zpow_coe_angle (x : β) (n : β€) :
(arg (x ^ n) : Real.Angle) = n β’ (arg x : Real.Angle) := by
match n with
| Int.ofNat m => simp [arg_pow_coe_angle]
| Int.negSucc m => simp [arg_pow_coe_angle]
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : β) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
theorem arg_coe_angle_eq_iff_eq_toReal {z : β} {ΞΈ : Real.Angle} :
(arg z : Real.Angle) = ΞΈ β arg z = ΞΈ.toReal := by
rw [β Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
@[simp]
theorem arg_coe_angle_eq_iff {x y : β} : (arg x : Real.Angle) = arg y β arg x = arg y := by
simp_rw [β Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
lemma arg_mul_eq_add_arg_iff {x y : β} (hxβ : x β 0) (hyβ : y β 0) :
(x * y).arg = x.arg + y.arg β arg x + arg y β Set.Ioc (-Ο) Ο := by
rw [β arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hxβ hyβ, β Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias β¨_, arg_mulβ© := arg_mul_eq_add_arg_iff
section slitPlane
open ComplexOrder in
/-- An alternative description of the slit plane as consisting of nonzero complex numbers
whose argument is not Ο. -/
lemma mem_slitPlane_iff_arg {z : β} : z β slitPlane β z.arg β Ο β§ z β 0 := by
simp only [mem_slitPlane_iff_not_le_zero, le_iff_lt_or_eq, ne_eq, arg_eq_pi_iff_lt_zero, not_or]
lemma slitPlane_arg_ne_pi {z : β} (hz : z β slitPlane) : z.arg β Real.pi :=
(mem_slitPlane_iff_arg.mp hz).1
end slitPlane
section Continuity
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =αΆ [π x] fun x => Real.arcsin (x.im / βxβ) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =αΆ [π x] fun x => Real.arcsin ((-x).im / βxβ) + Ο := by
suffices h_forall_nhds : βαΆ y : β in π x, y.re < 0 β§ 0 < y.im from
h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine IsOpen.eventually_mem ?_ (β¨hx_re, hx_imβ© : x.re < 0 β§ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =αΆ [π x] fun x => Real.arcsin ((-x).im / βxβ) - Ο := by
suffices h_forall_nhds : βαΆ y : β in π x, y.re < 0 β§ y.im < 0 from
h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine IsOpen.eventually_mem ?_ (β¨hx_re, hx_imβ© : x.re < 0 β§ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =αΆ [π z] fun x => Real.arccos (x.re / βxβ) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =αΆ [π z] fun x => -Real.arccos (x.re / βxβ) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
theorem continuousAt_arg (h : x β slitPlane) : ContinuousAt arg x := by
have hβ : βxβ β 0 := by
rw [norm_ne_zero_iff]
exact slitPlane_ne_zero h
rw [mem_slitPlane_iff, β lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_norm.continuousAt hβ)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_norm.continuousAt hβ)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_norm.continuousAt hβ)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
@[fun_prop]
theorem continuousOn_arg : ContinuousOn arg slitPlane :=
fun _ h β¦ continuousAt_arg h |>.continuousWithinAt
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : β} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (π[{ z : β | z.im < 0 }] z) (π (-Ο)) := by
suffices H : Tendsto (fun x : β => Real.arcsin ((-x).im / βxβ) - Ο)
(π[{ z : β | z.im < 0 }] z) (π (-Ο)) by
refine H.congr' ?_
have : βαΆ x : β in π z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin, mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_ge, if_neg him.not_ge]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_norm.continuousWithinAt _)
).sub_const Ο using 1
Β· simp [him]
Β· lift z to β using him
simpa using hre.ne
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : β} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : β | 0 β€ z.im } z := by
have : arg =αΆ [π[{ z : β | 0 β€ z.im }] z] fun x => Real.arcsin ((-x).im / βxβ) + Ο := by
have : βαΆ x : β in π z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : β | 0 β€ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_ge, if_pos him]
refine ContinuousWithinAt.congr_of_eventuallyEq ?_ this ?_
Β· refine
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_norm.continuousWithinAt ?_)).add
tendsto_const_nhds
lift z to β using him
simpa using hre.ne
Β· rw [arg, if_neg hre.not_ge, if_pos him.ge]
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : β} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (π[{ z : β | 0 β€ z.im }] z) (π Ο) := by
simpa only [arg_eq_pi_iff.2 β¨hre, himβ©] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
theorem continuousAt_arg_coe_angle (h : x β 0) : ContinuousAt ((β) β arg : β β Real.Angle) x := by
by_cases hs : x β slitPlane
Β· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
Β· rw [β Function.comp_id (((β) : β β Real.Angle) β arg),
(funext_iff.2 fun _ => (neg_neg _).symm : (id : β β β) = Neg.neg β Neg.neg), β
Function.comp_assoc]
refine ContinuousAt.comp ?_ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((β) β arg) β Neg.neg : β β Real.Angle) 0 Ο) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((β) β arg) β Neg.neg : β β Real.Angle) 0 Ο = fun z =>
(arg z : Real.Angle) + Ο := by
rw [Function.update_eq_iff]
exact β¨by simp, fun z hz => arg_neg_coe_angle hzβ©
rw [ha]
replace hs := mem_slitPlane_iff.mpr.mt hs
push_neg at hs
refine
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl ?_))).add
continuousAt_const
rw [neg_re, neg_pos]
exact hs.1.lt_of_ne fun h0 => h (Complex.ext_iff.2 β¨h0, hs.2β©)
end Continuity
end Complex |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/LogBounds.lean | import Mathlib.Analysis.Complex.Convex
import Mathlib.Analysis.SpecialFunctions.Integrals.Basic
import Mathlib.Analysis.Calculus.Deriv.Shift
import Mathlib.Analysis.SpecificLimits.RCLike
/-!
# Estimates for the complex logarithm
We show that `log (1+z)` differs from its Taylor polynomial up to degree `n` by at most
`βzβ^(n+1)/((n+1)*(1-βzβ))` when `βzβ < 1`; see `Complex.norm_log_sub_logTaylor_le`.
To this end, we derive the representation of `log (1+z)` as the integral of `1/(1+tz)`
over the unit interval (`Complex.log_eq_integral`) and introduce notation
`Complex.logTaylor n` for the Taylor polynomial up to degree `n-1`.
## TODO
Refactor using general Taylor series theory, once this exists in Mathlib.
-/
namespace Complex
/-!
### Integral representation of the complex log
-/
lemma continuousOn_one_add_mul_inv {z : β} (hz : 1 + z β slitPlane) :
ContinuousOn (fun t : β β¦ (1 + t β’ z)β»ΒΉ) (Set.Icc 0 1) :=
ContinuousOn.invβ (by fun_prop)
(fun _ ht β¦ slitPlane_ne_zero <| StarConvex.add_smul_mem starConvex_one_slitPlane hz ht.1 ht.2)
open intervalIntegral in
/-- Represent `log (1 + z)` as an integral over the unit interval -/
lemma log_eq_integral {z : β} (hz : 1 + z β slitPlane) :
log (1 + z) = z * β« (t : β) in (0 : β)..1, (1 + t β’ z)β»ΒΉ := by
convert (integral_unitInterval_deriv_eq_sub (continuousOn_one_add_mul_inv hz)
(fun _ ht β¦ hasDerivAt_log <|
StarConvex.add_smul_mem starConvex_one_slitPlane hz ht.1 ht.2)).symm using 1
simp only [log_one, sub_zero]
/-- Represent `log (1 - z)β»ΒΉ` as an integral over the unit interval -/
lemma log_inv_eq_integral {z : β} (hz : 1 - z β slitPlane) :
log (1 - z)β»ΒΉ = z * β« (t : β) in (0 : β)..1, (1 - t β’ z)β»ΒΉ := by
rw [sub_eq_add_neg 1 z] at hz β’
rw [log_inv _ <| slitPlane_arg_ne_pi hz, neg_eq_iff_eq_neg, β neg_mul]
convert log_eq_integral hz using 5
rw [sub_eq_add_neg, smul_neg]
/-!
### The Taylor polynomials of the logarithm
-/
/-- The `n`th Taylor polynomial of `log` at `1`, as a function `β β β` -/
noncomputable
def logTaylor (n : β) : β β β := fun z β¦ β j β Finset.range n, (-1) ^ (j + 1) * z ^ j / j
lemma logTaylor_zero : logTaylor 0 = fun _ β¦ 0 := by
funext
simp only [logTaylor, Finset.range_zero,
Finset.sum_empty]
lemma logTaylor_succ (n : β) :
logTaylor (n + 1) = logTaylor n + (fun z : β β¦ (-1) ^ (n + 1) * z ^ n / n) := by
funext
simpa only [logTaylor] using Finset.sum_range_succ ..
lemma logTaylor_at_zero (n : β) : logTaylor n 0 = 0 := by
induction n with
| zero => simp [logTaylor_zero]
| succ n ih => simpa [logTaylor_succ, ih] using ne_or_eq n 0
lemma hasDerivAt_logTaylor (n : β) (z : β) :
HasDerivAt (logTaylor (n + 1)) (β j β Finset.range n, (-1) ^ j * z ^ j) z := by
induction n with
| zero => simp [logTaylor_succ, logTaylor_zero, Pi.add_def, hasDerivAt_const]
| succ n ih =>
rw [logTaylor_succ]
simp only [Nat.cast_add, Nat.cast_one,
Finset.sum_range_succ]
refine HasDerivAt.add ih ?_
simp only [mul_div_assoc]
have : HasDerivAt (fun x : β β¦ (x ^ (n + 1) / (n + 1))) (z ^ n) z := by
simp_rw [div_eq_mul_inv]
convert HasDerivAt.mul_const (hasDerivAt_pow (n + 1) z) (((n : β) + 1)β»ΒΉ) using 1
simp [field]
convert HasDerivAt.const_mul _ this using 2
ring
/-!
### Bounds for the difference between log and its Taylor polynomials
-/
lemma hasDerivAt_log_sub_logTaylor (n : β) {z : β} (hz : 1 + z β slitPlane) :
HasDerivAt (fun z : β β¦ log (1 + z) - logTaylor (n + 1) z) ((-z) ^ n * (1 + z)β»ΒΉ) z := by
convert ((hasDerivAt_log hz).comp_const_add 1 z).sub (hasDerivAt_logTaylor n z) using 1
have hz' : -z β 1 := by
intro H
rw [neg_eq_iff_eq_neg] at H
simp only [H, add_neg_cancel] at hz
exact slitPlane_ne_zero hz rfl
simp_rw [β mul_pow, neg_one_mul, geom_sum_eq hz', β neg_add', div_neg, add_comm z]
simp [field]
/-- Give a bound on `β(1 + t * z)β»ΒΉβ` for `0 β€ t β€ 1` and `βzβ < 1`. -/
lemma norm_one_add_mul_inv_le {t : β} (ht : t β Set.Icc 0 1) {z : β} (hz : βzβ < 1) :
β(1 + t * z)β»ΒΉβ β€ (1 - βzβ)β»ΒΉ := by
rw [Set.mem_Icc] at ht
rw [norm_inv]
refine inv_antiβ (by linarith) ?_
calc 1 - βzβ
_ β€ 1 - t * βzβ := by
nlinarith [norm_nonneg z]
_ = 1 - βt * zβ := by
rw [norm_mul, Complex.norm_of_nonneg ht.1]
_ β€ β1 + t * zβ := by
rw [β norm_neg (t * z), β sub_neg_eq_add]
convert norm_sub_norm_le 1 (-(t * z))
exact norm_one.symm
lemma integrable_pow_mul_norm_one_add_mul_inv (n : β) {z : β} (hz : βzβ < 1) :
IntervalIntegrable (fun t : β β¦ t ^ n * β(1 + t * z)β»ΒΉβ) MeasureTheory.volume 0 1 := by
have := continuousOn_one_add_mul_inv <| mem_slitPlane_of_norm_lt_one hz
rw [β Set.uIcc_of_le zero_le_one] at this
exact ContinuousOn.intervalIntegrable (by fun_prop)
open intervalIntegral in
/-- The difference of `log (1+z)` and its `(n+1)`st Taylor polynomial can be bounded in
terms of `βzβ`. -/
lemma norm_log_sub_logTaylor_le (n : β) {z : β} (hz : βzβ < 1) :
βlog (1 + z) - logTaylor (n + 1) zβ β€ βzβ ^ (n + 1) * (1 - βzβ)β»ΒΉ / (n + 1) := by
have help : IntervalIntegrable (fun t : β β¦ t ^ n * (1 - βzβ)β»ΒΉ) MeasureTheory.volume 0 1 :=
IntervalIntegrable.mul_const (Continuous.intervalIntegrable (by fun_prop) 0 1) (1 - βzβ)β»ΒΉ
let f (z : β) : β := log (1 + z) - logTaylor (n + 1) z
let f' (z : β) : β := (-z) ^ n * (1 + z)β»ΒΉ
have hderiv : β t β Set.Icc (0 : β) 1, HasDerivAt f (f' (0 + t * z)) (0 + t * z) := by
intro t ht
rw [zero_add]
exact hasDerivAt_log_sub_logTaylor n <|
StarConvex.add_smul_mem starConvex_one_slitPlane (mem_slitPlane_of_norm_lt_one hz) ht.1 ht.2
have hcont : ContinuousOn (fun t : β β¦ f' (0 + t * z)) (Set.Icc 0 1) := by
simp only [zero_add]
exact (Continuous.continuousOn (by fun_prop)).mul <|
continuousOn_one_add_mul_inv <| mem_slitPlane_of_norm_lt_one hz
have H : f z = z * β« t in (0 : β)..1, (-(t * z)) ^ n * (1 + t * z)β»ΒΉ := by
convert (integral_unitInterval_deriv_eq_sub hcont hderiv).symm using 1
Β· simp only [f, zero_add, add_zero, log_one, logTaylor_at_zero, sub_self, sub_zero]
Β· simp only [f', real_smul, zero_add,
smul_eq_mul]
unfold f at H
simp only [H, norm_mul]
simp_rw [neg_pow (_ * z) n, mul_assoc, intervalIntegral.integral_const_mul, mul_pow,
mul_comm _ (z ^ n), mul_assoc, intervalIntegral.integral_const_mul, norm_mul, norm_pow,
norm_neg, norm_one, one_pow, one_mul, β mul_assoc, β pow_succ', mul_div_assoc]
gcongr _ * ?_
calc ββ« t in (0 : β)..1, (t : β) ^ n * (1 + t * z)β»ΒΉβ
_ β€ β« t in (0 : β)..1, t ^ n * (1 - βzβ)β»ΒΉ := by
refine intervalIntegral.norm_integral_le_of_norm_le zero_le_one ?_ help
filter_upwards with t β¨htβ, htββ©
rw [norm_mul, norm_pow, Complex.norm_of_nonneg htβ.le]
gcongr
exact norm_one_add_mul_inv_le β¨htβ.le, htββ© hz
_ = (1 - βzβ)β»ΒΉ / (n + 1) := by
rw [intervalIntegral.integral_mul_const, mul_comm, integral_pow]
simp [field]
/-- The difference `log (1+z) - z` is bounded by `βzβ^2/(2*(1-βzβ))` when `βzβ < 1`. -/
lemma norm_log_one_add_sub_self_le {z : β} (hz : βzβ < 1) :
βlog (1 + z) - zβ β€ βzβ ^ 2 * (1 - βzβ)β»ΒΉ / 2 := by
convert norm_log_sub_logTaylor_le 1 hz using 2
Β· simp [logTaylor_succ, logTaylor_zero, sub_eq_add_neg]
Β· norm_num
open scoped Topology in
lemma log_sub_logTaylor_isBigO (n : β) :
(fun z β¦ log (1 + z) - logTaylor (n + 1) z) =O[π 0] fun z β¦ z ^ (n + 1) := by
rw [Asymptotics.isBigO_iff]
use 2 / (n + 1)
filter_upwards [
eventually_norm_sub_lt 0 one_pos,
eventually_norm_sub_lt 0 (show 0 < 1 / 2 by simp)] with z hz1 hz12
rw [sub_zero] at hz1 hz12
have : (1 - βzβ)β»ΒΉ β€ 2 := by rw [inv_le_commβ (sub_pos_of_lt hz1) two_pos]; linarith
apply (norm_log_sub_logTaylor_le n hz1).trans
rw [mul_div_assoc, mul_comm, norm_pow]
gcongr
open scoped Topology in
lemma log_sub_self_isBigO :
(fun z β¦ log (1 + z) - z) =O[π 0] fun z β¦ z ^ 2 := by
convert log_sub_logTaylor_isBigO 1
simp [logTaylor_succ, logTaylor_zero]
lemma norm_log_one_add_le {z : β} (hz : βzβ < 1) :
βlog (1 + z)β β€ βzβ ^ 2 * (1 - βzβ)β»ΒΉ / 2 + βzβ := by
rw [β sub_add_cancel (log (1 + z)) z]
exact norm_add_le_of_le (Complex.norm_log_one_add_sub_self_le hz) le_rfl
/-- For `βzβ β€ 1/2`, the complex logarithm is bounded by `(3/2) * βzβ`. -/
lemma norm_log_one_add_half_le_self {z : β} (hz : βzβ β€ 1 / 2) : βlog (1 + z)β β€ (3/2) * βzβ := by
apply le_trans (norm_log_one_add_le (lt_of_le_of_lt hz one_half_lt_one))
have hz3 : (1 - βzβ)β»ΒΉ β€ 2 := by
rw [inv_eq_one_div, div_le_iffβ]
Β· linarith
Β· linarith
have hz4 : βzβ^2 * (1 - βzβ)β»ΒΉ / 2 β€ βzβ/2 * 2 / 2 := by
gcongr
Β· rw [inv_nonneg]
linarith
Β· rw [sq, div_eq_mul_one_div]
gcongr
simp only [isUnit_iff_ne_zero, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true,
IsUnit.div_mul_cancel] at hz4
linarith
/-- The difference of `log (1-z)β»ΒΉ` and its `(n+1)`st Taylor polynomial can be bounded in
terms of `βzβ`. -/
lemma norm_log_one_sub_inv_add_logTaylor_neg_le (n : β) {z : β} (hz : βzβ < 1) :
βlog (1 - z)β»ΒΉ + logTaylor (n + 1) (-z)β β€ βzβ ^ (n + 1) * (1 - βzβ)β»ΒΉ / (n + 1) := by
rw [sub_eq_add_neg,
log_inv _ <| slitPlane_arg_ne_pi <| mem_slitPlane_of_norm_lt_one <| (norm_neg z).symm βΈ hz,
β sub_neg_eq_add, β neg_sub', norm_neg]
convert norm_log_sub_logTaylor_le n <| (norm_neg z).symm βΈ hz using 4 <;> rw [norm_neg]
/-- The difference `log (1-z)β»ΒΉ - z` is bounded by `βzβ^2/(2*(1-βzβ))` when `βzβ < 1`. -/
lemma norm_log_one_sub_inv_sub_self_le {z : β} (hz : βzβ < 1) :
βlog (1 - z)β»ΒΉ - zβ β€ βzβ ^ 2 * (1 - βzβ)β»ΒΉ / 2 := by
convert norm_log_one_sub_inv_add_logTaylor_neg_le 1 hz using 2
Β· simp [logTaylor_succ, logTaylor_zero, sub_eq_add_neg]
Β· norm_num
open Filter Asymptotics in
/-- The Taylor series of the complex logarithm at `1` converges to the logarithm in the
open unit disk. -/
lemma hasSum_taylorSeries_log {z : β} (hz : βzβ < 1) :
HasSum (fun n : β β¦ (-1) ^ (n + 1) * z ^ n / n) (log (1 + z)) := by
refine (hasSum_iff_tendsto_nat_of_summable_norm ?_).mpr ?_
Β· refine (summable_geometric_of_norm_lt_one hz).norm.of_nonneg_of_le (fun _ β¦ norm_nonneg _) ?_
intro n
simp only [norm_div, norm_mul, norm_pow, norm_neg, norm_one, one_pow, one_mul, norm_natCast]
rcases n.eq_zero_or_pos with rfl | hn
Β· simp
conv => enter [2]; rw [β div_one (βzβ ^ n)]
gcongr
norm_cast
Β· rw [β tendsto_sub_nhds_zero_iff]
conv => enter [1, x]; rw [β div_one (_ - _), β logTaylor]
rw [β isLittleO_iff_tendsto fun _ h β¦ (one_ne_zero h).elim]
refine IsLittleO.trans_isBigO ?_ <| isBigO_const_one β (1 : β) atTop
have H : (fun n β¦ logTaylor n z - log (1 + z)) =O[atTop] (fun n : β β¦ βzβ ^ n) := by
have (n : β) : βlogTaylor n z - log (1 + z)β
β€ (max βlog (1 + z)β (1 - βzβ)β»ΒΉ) * β(βzβ ^ n)β := by
rw [norm_sub_rev, norm_pow, norm_norm]
cases n with
| zero => simp [logTaylor_zero]
| succ n =>
refine (norm_log_sub_logTaylor_le n hz).trans ?_
rw [mul_comm, β div_one ((max _ _) * _)]
gcongr
Β· exact le_max_right ..
Β· linarith
exact (isBigOWith_of_le' atTop this).isBigO
refine IsBigO.trans_isLittleO H ?_
convert isLittleO_pow_pow_of_lt_left (norm_nonneg z) hz
exact (one_pow _).symm
/-- The series `β z^n/n` converges to `-log (1-z)` on the open unit disk. -/
lemma hasSum_taylorSeries_neg_log {z : β} (hz : βzβ < 1) :
HasSum (fun n : β β¦ z ^ n / n) (-log (1 - z)) := by
conv => enter [1, n]; rw [β neg_neg (z ^ n / n)]
refine HasSum.neg ?_
convert hasSum_taylorSeries_log (z := -z) (norm_neg z βΈ hz) using 2 with n
rcases n.eq_zero_or_pos with rfl | hn
Β· simp
simp [field, pow_add, β mul_pow]
end Complex
section Limits
/-! Limits of functions of the form `(1 + t/x + o(1/x)) ^ x` as `x β β`. -/
open Filter Asymptotics
open scoped Topology
namespace Complex
/-- The limit of `x * log (1 + g x)` as `(x : β) β β` is `t`,
where `t : β` is the limit of `x * g x`. -/
lemma tendsto_mul_log_one_add_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun x β¦ x * g x) atTop (π t)) :
Tendsto (fun x β¦ x * log (1 + g x)) atTop (π t) := by
apply hg.congr_dist
refine IsBigO.trans_tendsto ?_ tendsto_inv_atTop_zero.ofReal
simp_rw [dist_comm (_ * g _), dist_eq, β mul_sub, isBigO_norm_left]
calc
_ =O[atTop] fun x β¦ x * g x ^ 2 := by
have hg0 := tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded hg.norm.isBoundedUnder_le
(RCLike.tendsto_ofReal_atTop_cobounded β)
exact (isBigO_refl _ _).mul (log_sub_self_isBigO.comp_tendsto hg0)
_ =αΆ [atTop] fun x β¦ (x * g x) ^ 2 * xβ»ΒΉ := by
filter_upwards [eventually_ne_atTop 0] with x hx0
rw [ofReal_inv, eq_mul_inv_iff_mul_eqβ (mod_cast hx0)]
ring
_ =O[atTop] _ := by
simpa using isBigO_const_of_tendsto hg (one_ne_zero (Ξ± := β))
|>.pow 2 |>.mul (isBigO_refl _ _)
/-- The limit of `(1 + g x) ^ x` as `(x : β) β β` is `exp t`,
where `t : β` is the limit of `x * g x`. -/
lemma tendsto_one_add_cpow_exp_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun x β¦ x * g x) atTop (π t)) :
Tendsto (fun x β¦ (1 + g x) ^ (x : β)) atTop (π (exp t)) := by
apply ((continuous_exp.tendsto _).comp (tendsto_mul_log_one_add_of_tendsto hg)).congr'
have hg0 := tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded
hg.norm.isBoundedUnder_le (RCLike.tendsto_ofReal_atTop_cobounded β)
filter_upwards [hg0.eventually_ne (show 0 β -1 by simp)] with x hg1
dsimp
rw [cpow_def_of_ne_zero, mul_comm]
intro hg0
rw [β add_eq_zero_iff_neg_eq.mp hg0] at hg1
norm_num at hg1
/-- The limit of `(1 + t/x) ^ x` as `x β β` is `exp t` for `t : β`. -/
lemma tendsto_one_add_div_cpow_exp (t : β) :
Tendsto (fun x : β β¦ (1 + t / x) ^ (x : β)) atTop (π (exp t)) := by
apply tendsto_one_add_cpow_exp_of_tendsto
apply tendsto_nhds_of_eventually_eq
filter_upwards [eventually_ne_atTop 0] with x hx0
exact mul_div_cancelβ t (mod_cast hx0)
/-- The limit of `n * log (1 + g n)` as `(n : β) β β` is `t`,
where `t : β` is the limit of `n * g n`. -/
lemma tendsto_nat_mul_log_one_add_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun n β¦ n * g n) atTop (π t)) :
Tendsto (fun n β¦ n * log (1 + g n)) atTop (π t) :=
tendsto_mul_log_one_add_of_tendsto (tendsto_smul_comp_nat_floor_of_tendsto_mul hg)
|>.comp tendsto_natCast_atTop_atTop |>.congr (by simp)
/-- The limit of `(1 + g n) ^ n` as `(n : β) β β` is `exp t`,
where `t : β` is the limit of `n * g n`. -/
lemma tendsto_one_add_pow_exp_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun n β¦ n * g n) atTop (π t)) :
Tendsto (fun n β¦ (1 + g n) ^ n) atTop (π (exp t)) :=
tendsto_one_add_cpow_exp_of_tendsto (tendsto_smul_comp_nat_floor_of_tendsto_mul hg)
|>.comp tendsto_natCast_atTop_atTop |>.congr (by simp)
/-- The limit of `(1 + t/n) ^ n` as `n β β` is `exp t` for `t : β`. -/
lemma tendsto_one_add_div_pow_exp (t : β) :
Tendsto (fun n : β β¦ (1 + t / n) ^ n) atTop (π (exp t)) :=
tendsto_one_add_div_cpow_exp t |>.comp tendsto_natCast_atTop_atTop |>.congr (by simp)
end Complex
namespace Real
/-- The limit of `x * log (1 + g x)` as `(x : β) β β` is `t`,
where `t : β` is the limit of `x * g x`. -/
lemma tendsto_mul_log_one_add_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun x β¦ x * g x) atTop (π t)) :
Tendsto (fun x β¦ x * log (1 + g x)) atTop (π t) := by
have hg0 := tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded
hg.norm.isBoundedUnder_le (tendsto_id'.mpr (by simp))
rw [β tendsto_ofReal_iff] at hg β’
push_cast at hg β’
apply (Complex.tendsto_mul_log_one_add_of_tendsto hg).congr'
filter_upwards [hg0.eventually_const_le (show (-1 : β) < 0 by simp)] with x hg1
rw [Complex.ofReal_log (by linarith), Complex.ofReal_add, Complex.ofReal_one]
theorem tendsto_mul_log_one_add_div_atTop (t : β) :
Tendsto (fun x => x * log (1 + t / x)) atTop (π t) :=
tendsto_mul_log_one_add_of_tendsto <|
tendsto_const_nhds.congr' <|
(EventuallyEq.div_mul_cancel_atTop tendsto_id).symm.trans <|
.of_eq <| funext fun _ => mul_comm _ _
@[deprecated (since := "2025-05-22")]
alias tendsto_mul_log_one_plus_div_atTop := tendsto_mul_log_one_add_div_atTop
/-- The limit of `(1 + g x) ^ x` as `(x : β) β β` is `exp t`,
where `t : β` is the limit of `x * g x`. -/
lemma tendsto_one_add_rpow_exp_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun x β¦ x * g x) atTop (π t)) :
Tendsto (fun x β¦ (1 + g x) ^ x) atTop (π (exp t)) := by
have hg0 := tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded
hg.norm.isBoundedUnder_le (tendsto_id'.mpr (by simp))
rw [β tendsto_ofReal_iff] at hg β’
push_cast at hg β’
apply (Complex.tendsto_one_add_cpow_exp_of_tendsto hg).congr'
filter_upwards [hg0.eventually_const_le (show (-1 : β) < 0 by simp)] with x hg1
rw [Complex.ofReal_cpow (by linarith), Complex.ofReal_add, Complex.ofReal_one]
/-- The limit of `(1 + t/x) ^ x` as `x β β` is `exp t` for `t : β`. -/
lemma tendsto_one_add_div_rpow_exp (t : β) :
Tendsto (fun x : β β¦ (1 + t / x) ^ x) atTop (π (exp t)) := by
apply tendsto_one_add_rpow_exp_of_tendsto
apply tendsto_nhds_of_eventually_eq
filter_upwards [eventually_ne_atTop 0] with x hx0
exact mul_div_cancelβ t (mod_cast hx0)
@[deprecated (since := "2025-05-22")]
alias tendsto_one_plus_div_rpow_exp := tendsto_one_add_div_rpow_exp
/-- The limit of `n * log (1 + g n)` as `(n : β) β β` is `t`,
where `t : β` is the limit of `n * g n`. -/
lemma tendsto_nat_mul_log_one_add_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun n β¦ n * g n) atTop (π t)) :
Tendsto (fun n β¦ n * log (1 + g n)) atTop (π t) :=
tendsto_mul_log_one_add_of_tendsto (tendsto_smul_comp_nat_floor_of_tendsto_mul hg) |>.comp
tendsto_natCast_atTop_atTop |>.congr (by simp)
/-- The limit of `(1 + g n) ^ n` as `(n : β) β β` is `exp t`,
where `t : β` is the limit of `n * g n`. -/
lemma tendsto_one_add_pow_exp_of_tendsto {g : β β β} {t : β}
(hg : Tendsto (fun n β¦ n * g n) atTop (π t)) :
Tendsto (fun n β¦ (1 + g n) ^ n) atTop (π (exp t)) :=
tendsto_one_add_rpow_exp_of_tendsto (tendsto_smul_comp_nat_floor_of_tendsto_mul hg) |>.comp
tendsto_natCast_atTop_atTop |>.congr (by simp)
/-- The limit of `(1 + t/n) ^ n` as `n β β` is `exp t` for `t : β`. -/
lemma tendsto_one_add_div_pow_exp (t : β) :
Tendsto (fun n : β β¦ (1 + t / n) ^ n) atTop (π (exp t)) :=
tendsto_one_add_div_rpow_exp t |>.comp tendsto_natCast_atTop_atTop |>.congr (by simp)
@[deprecated (since := "2025-05-22")]
alias tendsto_one_plus_div_pow_exp := tendsto_one_add_div_pow_exp
end Real
end Limits |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/CircleAddChar.lean | import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.NumberTheory.LegendreSymbol.AddCharacter
import Mathlib.RingTheory.RootsOfUnity.AlgebraicallyClosed
import Mathlib.Topology.Instances.AddCircle.Real
/-!
# Additive characters valued in the unit circle
This file defines additive characters, valued in the unit circle, from either
* the ring `ZMod N` for any non-zero natural `N`,
* the additive circle `β / T β¬ β€`, for any real `T`.
These results are separate from `Analysis.SpecialFunctions.Complex.Circle` in order to reduce
the imports of that file.
-/
open Complex Function
open scoped Real
/-- The canonical map from the additive to the multiplicative circle, as an `AddChar`. -/
noncomputable def AddCircle.toCircle_addChar {T : β} : AddChar (AddCircle T) Circle where
toFun := toCircle
map_zero_eq_one' := toCircle_zero
map_add_eq_mul' := toCircle_add
open AddCircle
namespace ZMod
/-!
### Additive characters valued in the complex circle
-/
open scoped Real
variable {N : β} [NeZero N]
/-- The additive character from `ZMod N` to the unit circle in `β`, sending `j mod N` to
`exp (2 * Ο * I * j / N)`. -/
noncomputable def toCircle : AddChar (ZMod N) Circle :=
toCircle_addChar.compAddMonoidHom toAddCircle
lemma toCircle_intCast (j : β€) :
toCircle (j : ZMod N) = exp (2 * Ο * I * j / N) := by
rw [toCircle, AddChar.compAddMonoidHom_apply, toCircle_addChar, AddChar.coe_mk,
AddCircle.toCircle, toAddCircle_intCast, Function.Periodic.lift_coe, Circle.coe_exp]
push_cast
ring_nf
lemma toCircle_natCast (j : β) :
toCircle (j : ZMod N) = exp (2 * Ο * I * j / N) := by
simpa using toCircle_intCast (N := N) j
/--
Explicit formula for `toCircle j`. Note that this is "evil" because it uses `ZMod.val`. Where
possible, it is recommended to lift `j` to `β€` and use `toCircle_intCast` instead.
-/
lemma toCircle_apply (j : ZMod N) :
toCircle j = exp (2 * Ο * I * j.val / N) := by
rw [β toCircle_natCast, natCast_zmod_val]
lemma toCircle_eq_circleExp (j : ZMod N) :
toCircle j = Circle.exp (2 * Ο * (j.val / N)) := by
ext
rw [toCircle_apply, Circle.coe_exp]
push_cast
congr; ring
lemma injective_toCircle : Injective (toCircle : ZMod N β Circle) :=
(AddCircle.injective_toCircle one_ne_zero).comp (toAddCircle_injective N)
/-- The additive character from `ZMod N` to `β`, sending `j mod N` to `exp (2 * Ο * I * j / N)`. -/
noncomputable def stdAddChar : AddChar (ZMod N) β := Circle.coeHom.compAddChar toCircle
lemma stdAddChar_coe (j : β€) :
stdAddChar (j : ZMod N) = exp (2 * Ο * I * j / N) := by simp [stdAddChar, toCircle_intCast]
lemma stdAddChar_apply (j : ZMod N) : stdAddChar j = β(toCircle j) := rfl
lemma injective_stdAddChar : Injective (stdAddChar : AddChar (ZMod N) β) :=
Subtype.coe_injective.comp injective_toCircle
/-- The standard additive character `ZMod N β β` is primitive. -/
lemma isPrimitive_stdAddChar (N : β) [NeZero N] :
(stdAddChar (N := N)).IsPrimitive := by
refine AddChar.zmod_char_primitive_of_eq_one_only_at_zero _ _ (fun t ht β¦ ?_)
rwa [β (stdAddChar (N := N)).map_zero_eq_one, injective_stdAddChar.eq_iff] at ht
/-- `ZMod.toCircle` as an `AddChar` into `rootsOfUnity n Circle`. -/
noncomputable def rootsOfUnityAddChar (n : β) [NeZero n] :
AddChar (ZMod n) (rootsOfUnity n Circle) where
toFun x := β¨toUnits (ZMod.toCircle x), by ext; simp [β AddChar.map_nsmul_eq_pow]β©
map_zero_eq_one' := by simp
map_add_eq_mul' _ _:= by ext; simp [AddChar.map_add_eq_mul]
@[simp] lemma rootsOfUnityAddChar_val (n : β) [NeZero n] (x : ZMod n) :
(rootsOfUnityAddChar n x).val = toCircle x := by
rfl
end ZMod
variable (n : β) [NeZero n]
/-- Interpret `n`-th roots of unity in `β` as elements of the circle -/
noncomputable def rootsOfUnitytoCircle : (rootsOfUnity n β) β* Circle where
toFun := fun z => β¨z.val.val,
mem_sphere_zero_iff_norm.2 (Complex.norm_eq_one_of_mem_rootsOfUnity z.prop)β©
map_one' := rfl
map_mul' _ _ := rfl
/-- Equivalence of the nth roots of unity of the Circle with nth roots of unity of the complex
numbers -/
noncomputable def rootsOfUnityCircleEquiv : rootsOfUnity n Circle β* rootsOfUnity n β where
__ := (rootsOfUnityUnitsMulEquiv β n).toMonoidHom.comp (restrictRootsOfUnity Circle.toUnits n)
invFun z := β¨(rootsOfUnitytoCircle n).toHomUnits z, by
rw [mem_rootsOfUnity', MonoidHom.coe_toHomUnits, β MonoidHom.map_pow,
β (rootsOfUnitytoCircle n).map_one]
congr
aesopβ©
left_inv _ := by aesop
right_inv _ := by aesop
instance : HasEnoughRootsOfUnity Circle n := (rootsOfUnityCircleEquiv n).symm.hasEnoughRootsOfUnity
@[simp] lemma rootsOfUnityCircleEquiv_apply (w : rootsOfUnity n Circle) :
((rootsOfUnityCircleEquiv n w).val : β) = ((w.val : Circle) : β) :=
rfl
open Real in
lemma rootsOfUnityCircleEquiv_comp_rootsOfUnityAddChar_val (j : ZMod n) :
(rootsOfUnityCircleEquiv n (ZMod.rootsOfUnityAddChar n j)).val
= Complex.exp (2 * Ο * I * j.val / n) := by
simp [β ZMod.toCircle_natCast, -ZMod.natCast_val, ZMod.natCast_zmod_val]
theorem surjective_rootsOfUnityCircleEquiv_comp_rootsOfUnityAddChar (n : β) [NeZero n] :
Surjective (rootsOfUnityCircleEquiv n β ZMod.rootsOfUnityAddChar n) := fun β¨w, hwβ© β¦ by
obtain β¨j, hj1, hj2β© := (Complex.mem_rootsOfUnity n w).mp hw
exact β¨j, by simp [Units.ext_iff, Subtype.ext_iff, β hj2, ZMod.toCircle_natCast, mul_div_assoc]β©
lemma bijective_rootsOfUnityAddChar :
Bijective (ZMod.rootsOfUnityAddChar n) where
left _ _ := by simp [ZMod.rootsOfUnityAddChar, ZMod.injective_toCircle.eq_iff]
right := (surjective_rootsOfUnityCircleEquiv_comp_rootsOfUnityAddChar n).of_comp_left
(rootsOfUnityCircleEquiv n).injective |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/LogDeriv.lean | import Mathlib.Analysis.Calculus.InverseFunctionTheorem.Deriv
import Mathlib.Analysis.Calculus.LogDeriv
import Mathlib.Analysis.SpecialFunctions.Complex.Log
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
/-!
# Differentiability of the complex `log` function
-/
assert_not_exists IsConformalMap Conformal
open Set Filter
open scoped Real Topology
namespace Complex
theorem isOpenMap_exp : IsOpenMap exp :=
isOpenMap_of_hasStrictDerivAt hasStrictDerivAt_exp exp_ne_zero
/-- `Complex.exp` as an `OpenPartialHomeomorph` with `source = {z | -Ο < im z < Ο}` and
`target = {z | 0 < re z} βͺ {z | im z β 0}`. This definition is used to prove that `Complex.log`
is complex differentiable at all points but the negative real semi-axis. -/
noncomputable def expPartialHomeomorph : OpenPartialHomeomorph β β :=
OpenPartialHomeomorph.ofContinuousOpen
{ toFun := exp
invFun := log
source := {z : β | z.im β Ioo (-Ο) Ο}
target := slitPlane
map_source' := by
rintro β¨x, yβ© β¨hβ : -Ο < y, hβ : y < Οβ©
refine (not_or_of_imp fun hz => ?_).symm
obtain rfl : y = 0 := by
rw [exp_im] at hz
simpa [(Real.exp_pos _).ne', Real.sin_eq_zero_iff_of_lt_of_lt hβ hβ] using hz
rw [β ofReal_def, exp_ofReal_re]
exact Real.exp_pos x
map_target' := fun z h => by
simp only [mem_setOf, log_im, mem_Ioo, neg_pi_lt_arg, arg_lt_pi_iff, true_and]
exact h.imp_left le_of_lt
left_inv' := fun _ hx => log_exp hx.1 (le_of_lt hx.2)
right_inv' := fun _ hx => exp_log <| slitPlane_ne_zero hx }
continuous_exp.continuousOn isOpenMap_exp (isOpen_Ioo.preimage continuous_im)
theorem hasStrictDerivAt_log {x : β} (h : x β slitPlane) : HasStrictDerivAt log xβ»ΒΉ x :=
have h0 : x β 0 := slitPlane_ne_zero h
expPartialHomeomorph.hasStrictDerivAt_symm h h0 <| by
simpa [exp_log h0] using hasStrictDerivAt_exp (log x)
lemma hasDerivAt_log {z : β} (hz : z β slitPlane) : HasDerivAt log zβ»ΒΉ z :=
HasStrictDerivAt.hasDerivAt <| hasStrictDerivAt_log hz
@[fun_prop]
lemma differentiableAt_log {z : β} (hz : z β slitPlane) : DifferentiableAt β log z :=
(hasDerivAt_log hz).differentiableAt
@[fun_prop]
theorem hasStrictFDerivAt_log_real {x : β} (h : x β slitPlane) :
HasStrictFDerivAt log (xβ»ΒΉ β’ (1 : β βL[β] β)) x :=
(hasStrictDerivAt_log h).complexToReal_fderiv
theorem contDiffAt_log {x : β} (h : x β slitPlane) {n : WithTop ββ} : ContDiffAt β n log x :=
expPartialHomeomorph.contDiffAt_symm_deriv (exp_ne_zero <| log x) h (hasDerivAt_exp _)
contDiff_exp.contDiffAt
end Complex
section LogDeriv
open Complex Filter
open scoped Topology
variable {Ξ± : Type*} [TopologicalSpace Ξ±] {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
theorem HasStrictFDerivAt.clog {f : E β β} {f' : StrongDual β E} {x : E}
(hβ : HasStrictFDerivAt f f' x) (hβ : f x β slitPlane) :
HasStrictFDerivAt (fun t => log (f t)) ((f x)β»ΒΉ β’ f') x :=
(hasStrictDerivAt_log hβ).comp_hasStrictFDerivAt x hβ
theorem HasStrictDerivAt.clog {f : β β β} {f' x : β} (hβ : HasStrictDerivAt f f' x)
(hβ : f x β slitPlane) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by
rw [div_eq_inv_mul]; exact (hasStrictDerivAt_log hβ).comp x hβ
theorem HasStrictDerivAt.clog_real {f : β β β} {x : β} {f' : β} (hβ : HasStrictDerivAt f f' x)
(hβ : f x β slitPlane) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by
simpa only [div_eq_inv_mul] using (hasStrictFDerivAt_log_real hβ).comp_hasStrictDerivAt x hβ
theorem HasFDerivAt.clog {f : E β β} {f' : StrongDual β E} {x : E} (hβ : HasFDerivAt f f' x)
(hβ : f x β slitPlane) : HasFDerivAt (fun t => log (f t)) ((f x)β»ΒΉ β’ f') x :=
(hasStrictDerivAt_log hβ).hasDerivAt.comp_hasFDerivAt x hβ
theorem HasDerivAt.clog {f : β β β} {f' x : β} (hβ : HasDerivAt f f' x)
(hβ : f x β slitPlane) : HasDerivAt (fun t => log (f t)) (f' / f x) x := by
rw [div_eq_inv_mul]; exact (hasStrictDerivAt_log hβ).hasDerivAt.comp x hβ
theorem HasDerivAt.clog_real {f : β β β} {x : β} {f' : β} (hβ : HasDerivAt f f' x)
(hβ : f x β slitPlane) : HasDerivAt (fun t => log (f t)) (f' / f x) x := by
simpa only [div_eq_inv_mul] using
(hasStrictFDerivAt_log_real hβ).hasFDerivAt.comp_hasDerivAt x hβ
theorem DifferentiableAt.clog {f : E β β} {x : E} (hβ : DifferentiableAt β f x)
(hβ : f x β slitPlane) : DifferentiableAt β (fun t => log (f t)) x :=
(hβ.hasFDerivAt.clog hβ).differentiableAt
theorem HasFDerivWithinAt.clog {f : E β β} {f' : StrongDual β E} {s : Set E} {x : E}
(hβ : HasFDerivWithinAt f f' s x) (hβ : f x β slitPlane) :
HasFDerivWithinAt (fun t => log (f t)) ((f x)β»ΒΉ β’ f') s x :=
(hasStrictDerivAt_log hβ).hasDerivAt.comp_hasFDerivWithinAt x hβ
theorem HasDerivWithinAt.clog {f : β β β} {f' x : β} {s : Set β} (hβ : HasDerivWithinAt f f' s x)
(hβ : f x β slitPlane) : HasDerivWithinAt (fun t => log (f t)) (f' / f x) s x := by
rw [div_eq_inv_mul]
exact (hasStrictDerivAt_log hβ).hasDerivAt.comp_hasDerivWithinAt x hβ
theorem HasDerivWithinAt.clog_real {f : β β β} {s : Set β} {x : β} {f' : β}
(hβ : HasDerivWithinAt f f' s x) (hβ : f x β slitPlane) :
HasDerivWithinAt (fun t => log (f t)) (f' / f x) s x := by
simpa only [div_eq_inv_mul] using
(hasStrictFDerivAt_log_real hβ).hasFDerivAt.comp_hasDerivWithinAt x hβ
theorem DifferentiableWithinAt.clog {f : E β β} {s : Set E} {x : E}
(hβ : DifferentiableWithinAt β f s x) (hβ : f x β slitPlane) :
DifferentiableWithinAt β (fun t => log (f t)) s x :=
(hβ.hasFDerivWithinAt.clog hβ).differentiableWithinAt
theorem DifferentiableOn.clog {f : E β β} {s : Set E} (hβ : DifferentiableOn β f s)
(hβ : β x β s, f x β slitPlane) : DifferentiableOn β (fun t => log (f t)) s :=
fun x hx => (hβ x hx).clog (hβ x hx)
theorem Differentiable.clog {f : E β β} (hβ : Differentiable β f)
(hβ : β x, f x β slitPlane) : Differentiable β fun t => log (f t) := fun x =>
(hβ x).clog (hβ x)
/-- The derivative of `log β f` is the logarithmic derivative provided `f` is differentiable and
we are on the slitPlane. -/
lemma Complex.deriv_log_comp_eq_logDeriv {f : β β β} {x : β} (hβ : DifferentiableAt β f x)
(hβ : f x β Complex.slitPlane) : deriv (Complex.log β f) x = logDeriv f x := by
have A := (HasDerivAt.clog hβ.hasDerivAt hβ).deriv
rw [β hβ.hasDerivAt.deriv] at A
simp only [logDeriv, Pi.div_apply, β A, Function.comp_def]
end LogDeriv |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean | import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# The complex `log` function
Basic properties, relationship with `exp`.
-/
noncomputable section
namespace Complex
open Set Filter Bornology
open scoped Real Topology ComplexConjugate
/-- Inverse of the `exp` function. Returns values such that `(log x).im > - Ο` and `(log x).im β€ Ο`.
`log 0 = 0` -/
@[pp_nodot]
noncomputable def log (x : β) : β :=
Real.log βxβ + arg x * I
theorem log_re (x : β) : x.log.re = Real.log βxβ := by simp [log]
theorem log_im (x : β) : x.log.im = x.arg := by simp [log]
theorem neg_pi_lt_log_im (x : β) : -Ο < (log x).im := by simp only [log_im, neg_pi_lt_arg]
theorem log_im_le_pi (x : β) : (log x).im β€ Ο := by simp only [log_im, arg_le_pi]
theorem exp_log {x : β} (hx : x β 0) : exp (log x) = x := by
rw [log, exp_add_mul_I, β ofReal_sin, sin_arg, β ofReal_cos, cos_arg hx, β ofReal_exp,
Real.exp_log (norm_pos_iff.mpr hx), mul_add, ofReal_div, ofReal_div,
mul_div_cancelβ _ (ofReal_ne_zero.2 <| norm_ne_zero_iff.mpr hx), β mul_assoc,
mul_div_cancelβ _ (ofReal_ne_zero.2 <| norm_ne_zero_iff.mpr hx), re_add_im]
@[simp]
theorem range_exp : Set.range exp = {0}αΆ :=
Set.ext fun x =>
β¨by
rintro β¨x, rflβ©
exact exp_ne_zero x, fun hx => β¨log x, exp_log hxβ©β©
theorem log_exp {x : β} (hxβ : -Ο < x.im) (hxβ : x.im β€ Ο) : log (exp x) = x := by
rw [log, norm_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, β ofReal_exp,
arg_mul_cos_add_sin_mul_I (Real.exp_pos _) β¨hxβ, hxββ©, re_add_im]
theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : β} (hxβ : -Ο < x.im) (hxβ : x.im β€ Ο) (hyβ : -Ο < y.im)
(hyβ : y.im β€ Ο) (hxy : exp x = exp y) : x = y := by
rw [β log_exp hxβ hxβ, β log_exp hyβ hyβ, hxy]
theorem ofReal_log {x : β} (hx : 0 β€ x) : (x.log : β) = log x :=
Complex.ext (by rw [log_re, ofReal_re, Complex.norm_of_nonneg hx])
(by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx])
@[simp, norm_cast]
lemma natCast_log {n : β} : Real.log n = log n := ofReal_natCast n βΈ ofReal_log n.cast_nonneg
@[simp]
lemma ofNat_log {n : β} [n.AtLeastTwo] :
Real.log ofNat(n) = log (OfNat.ofNat n) :=
natCast_log
theorem log_ofReal_re (x : β) : (log (x : β)).re = Real.log x := by simp [log_re]
theorem log_ofReal_mul {r : β} (hr : 0 < r) {x : β} (hx : x β 0) :
log (r * x) = Real.log r + log x := by
replace hx := norm_ne_zero_iff.mpr hx
simp_rw [log, norm_mul, norm_real, arg_real_mul _ hr, Real.norm_of_nonneg hr.le,
Real.log_mul hr.ne' hx, ofReal_add, add_assoc]
theorem log_mul_ofReal (r : β) (hr : 0 < r) (x : β) (hx : x β 0) :
log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx]
lemma log_mul_eq_add_log_iff {x y : β} (hxβ : x β 0) (hyβ : y β 0) :
log (x * y) = log x + log y β arg x + arg y β Set.Ioc (-Ο) Ο := by
refine Complex.ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hxβ hyβ
simp_rw [add_re, add_im, log_re, log_im, norm_mul,
Real.log_mul (norm_ne_zero_iff.mpr hxβ) (norm_ne_zero_iff.mpr hyβ), true_and]
alias β¨_, log_mulβ© := log_mul_eq_add_log_iff
@[simp]
theorem log_zero : log 0 = 0 := by simp [log]
@[simp]
theorem log_one : log 1 = 0 := by simp [log]
/-- This holds true for all `x : β` because of the junk values `0 / 0 = 0` and `log 0 = 0`. -/
@[simp] lemma log_div_self (x : β) : log (x / x) = 0 := by simp [log]
theorem log_neg_one : log (-1) = Ο * I := by simp [log]
theorem log_I : log I = Ο / 2 * I := by simp [log]
theorem log_neg_I : log (-I) = -(Ο / 2) * I := by simp [log]
theorem log_conj_eq_ite (x : β) : log (conj x) = if x.arg = Ο then log x else conj (log x) := by
simp_rw [log, norm_conj, arg_conj, map_add, map_mul, conj_ofReal]
split_ifs with hx
Β· rw [hx]
simp_rw [ofReal_neg, conj_I, mul_neg, neg_mul]
theorem log_conj (x : β) (h : x.arg β Ο) : log (conj x) = conj (log x) := by
rw [log_conj_eq_ite, if_neg h]
theorem log_inv_eq_ite (x : β) : log xβ»ΒΉ = if x.arg = Ο then -conj (log x) else -log x := by
by_cases hx : x = 0
Β· simp [hx]
rw [inv_def, log_mul_ofReal, Real.log_inv, ofReal_neg, β sub_eq_neg_add, log_conj_eq_ite]
Β· simp_rw [log, map_add, map_mul, conj_ofReal, conj_I, normSq_eq_norm_sq, Real.log_pow,
Nat.cast_two, ofReal_mul, neg_add, mul_neg, neg_neg]
norm_num
grind
Β· rwa [inv_pos, Complex.normSq_pos]
Β· rwa [map_ne_zero]
theorem log_inv (x : β) (hx : x.arg β Ο) : log xβ»ΒΉ = -log x := by rw [log_inv_eq_ite, if_neg hx]
theorem two_pi_I_ne_zero : (2 * Ο * I : β) β 0 := by simp [Real.pi_ne_zero, I_ne_zero]
theorem exp_eq_one_iff {x : β} : exp x = 1 β β n : β€, x = n * (2 * Ο * I) := by
constructor
Β· intro h
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos x.im (-Ο) with β¨n, hn, -β©
use -n
rw [Int.cast_neg, neg_mul, eq_neg_iff_add_eq_zero]
have : (x + n * (2 * Ο * I)).im β Set.Ioc (-Ο) Ο := by simpa [two_mul, mul_add] using hn
rw [β log_exp this.1 this.2, exp_periodic.int_mul n, h, log_one]
Β· rintro β¨n, rflβ©
exact (exp_periodic.int_mul n).eq.trans exp_zero
theorem exp_eq_exp_iff_exp_sub_eq_one {x y : β} : exp x = exp y β exp (x - y) = 1 := by
rw [exp_sub, div_eq_one_iff_eq (exp_ne_zero _)]
theorem exp_eq_exp_iff_exists_int {x y : β} : exp x = exp y β β n : β€, x = y + n * (2 * Ο * I) := by
simp only [exp_eq_exp_iff_exp_sub_eq_one, exp_eq_one_iff, sub_eq_iff_eq_add']
theorem log_exp_exists (z : β) :
β n : β€, log (exp z) = z + n * (2 * Ο * I) := by
rw [β exp_eq_exp_iff_exists_int, exp_log]
exact exp_ne_zero z
@[simp]
theorem countable_preimage_exp {s : Set β} : (exp β»ΒΉ' s).Countable β s.Countable := by
refine β¨fun hs => ?_, fun hs => ?_β©
Β· refine ((hs.image exp).insert 0).mono ?_
rw [Set.image_preimage_eq_inter_range, range_exp, β Set.diff_eq, β Set.union_singleton,
Set.diff_union_self]
exact Set.subset_union_left
Β· rw [β Set.biUnion_preimage_singleton]
refine hs.biUnion fun z hz => ?_
by_cases! h : β w, exp w = z
Β· rcases h with β¨w, rflβ©
simp only [Set.preimage, Set.mem_singleton_iff, exp_eq_exp_iff_exists_int, Set.setOf_exists]
exact Set.countable_iUnion fun m => Set.countable_singleton _
Β· simp [Set.preimage, h]
alias β¨_, _root_.Set.Countable.preimage_cexpβ© := countable_preimage_exp
theorem tendsto_log_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : β} (hre : z.re < 0)
(him : z.im = 0) : Tendsto log (π[{ z : β | z.im < 0 }] z) (π <| Real.log βzβ - Ο * I) := by
convert
(continuous_ofReal.continuousAt.comp_continuousWithinAt
(continuous_norm.continuousWithinAt.log _)).tendsto.add
(((continuous_ofReal.tendsto _).comp <|
tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero hre him).mul
tendsto_const_nhds) using 1
Β· simp [sub_eq_add_neg]
Β· lift z to β using him
simpa using hre.ne
theorem continuousWithinAt_log_of_re_neg_of_im_zero {z : β} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt log { z : β | 0 β€ z.im } z := by
convert
(continuous_ofReal.continuousAt.comp_continuousWithinAt
(continuous_norm.continuousWithinAt.log _)).tendsto.add
((continuous_ofReal.continuousAt.comp_continuousWithinAt <|
continuousWithinAt_arg_of_re_neg_of_im_zero hre him).mul
tendsto_const_nhds) using 1
lift z to β using him
simpa using hre.ne
theorem tendsto_log_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : β} (hre : z.re < 0)
(him : z.im = 0) : Tendsto log (π[{ z : β | 0 β€ z.im }] z) (π <| Real.log βzβ + Ο * I) := by
simpa only [log, arg_eq_pi_iff.2 β¨hre, himβ©] using
(continuousWithinAt_log_of_re_neg_of_im_zero hre him).tendsto
@[simp]
theorem map_exp_comap_re_atBot : map exp (comap re atBot) = π[β ] 0 := by
rw [β comap_exp_nhds_zero, map_comap, range_exp, nhdsWithin]
@[simp]
theorem map_exp_comap_re_atTop : map exp (comap re atTop) = cobounded β := by
rw [β comap_exp_cobounded, map_comap, range_exp, inf_eq_left, le_principal_iff]
exact eventually_ne_cobounded _
end Complex
section LogDeriv
open Complex Filter
open Topology
variable {Ξ± : Type*}
theorem continuousAt_clog {x : β} (h : x β slitPlane) : ContinuousAt log x := by
refine ContinuousAt.add ?_ ?_
Β· refine continuous_ofReal.continuousAt.comp ?_
refine (Real.continuousAt_log ?_).comp continuous_norm.continuousAt
exact norm_ne_zero_iff.mpr <| slitPlane_ne_zero h
Β· have h_cont_mul : Continuous fun x : β => x * I := continuous_id'.mul continuous_const
refine h_cont_mul.continuousAt.comp (continuous_ofReal.continuousAt.comp ?_)
exact continuousAt_arg h
theorem _root_.Filter.Tendsto.clog {l : Filter Ξ±} {f : Ξ± β β} {x : β} (h : Tendsto f l (π x))
(hx : x β slitPlane) : Tendsto (fun t => log (f t)) l (π <| log x) :=
(continuousAt_clog hx).tendsto.comp h
variable [TopologicalSpace Ξ±]
nonrec
theorem _root_.ContinuousAt.clog {f : Ξ± β β} {x : Ξ±} (hβ : ContinuousAt f x)
(hβ : f x β slitPlane) : ContinuousAt (fun t => log (f t)) x :=
hβ.clog hβ
nonrec
theorem _root_.ContinuousWithinAt.clog {f : Ξ± β β} {s : Set Ξ±} {x : Ξ±}
(hβ : ContinuousWithinAt f s x) (hβ : f x β slitPlane) :
ContinuousWithinAt (fun t => log (f t)) s x :=
hβ.clog hβ
nonrec
theorem _root_.ContinuousOn.clog {f : Ξ± β β} {s : Set Ξ±} (hβ : ContinuousOn f s)
(hβ : β x β s, f x β slitPlane) : ContinuousOn (fun t => log (f t)) s := fun x hx =>
(hβ x hx).clog (hβ x hx)
nonrec
theorem _root_.Continuous.clog {f : Ξ± β β} (hβ : Continuous f)
(hβ : β x, f x β slitPlane) : Continuous fun t => log (f t) :=
continuous_iff_continuousAt.2 fun x => hβ.continuousAt.clog (hβ x)
end LogDeriv |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Complex/Circle.lean | import Mathlib.Analysis.Complex.Circle
import Mathlib.Analysis.SpecialFunctions.Complex.Log
/-!
# Maps on the unit circle
In this file we prove some basic lemmas about `expMapCircle` and the restriction of `Complex.arg`
to the unit circle. These two maps define a partial equivalence between `circle` and `β`, see
`circle.argPartialEquiv` and `circle.argEquiv`, that sends the whole circle to `(-Ο, Ο]`.
-/
open Complex Function Set
open Real
namespace Circle
theorem injective_arg : Injective fun z : Circle => arg z := fun z w h =>
Subtype.ext <| ext_norm_arg (z.norm_coe.trans w.norm_coe.symm) h
@[simp]
theorem arg_eq_arg {z w : Circle} : arg z = arg w β z = w :=
injective_arg.eq_iff
theorem arg_exp {x : β} (hβ : -Ο < x) (hβ : x β€ Ο) : arg (exp x) = x := by
rw [coe_exp, exp_mul_I, arg_cos_add_sin_mul_I β¨hβ, hββ©]
@[simp]
theorem exp_arg (z : Circle) : exp (arg z) = z :=
injective_arg <| arg_exp (neg_pi_lt_arg _) (arg_le_pi _)
/-- `Complex.arg β (β)` and `expMapCircle` define a partial equivalence between `circle` and `β`
with `source = Set.univ` and `target = Set.Ioc (-Ο) Ο`. -/
@[simps -fullyApplied]
noncomputable def argPartialEquiv : PartialEquiv Circle β where
toFun := arg β (β)
invFun := exp
source := univ
target := Ioc (-Ο) Ο
map_source' _ _ := β¨neg_pi_lt_arg _, arg_le_pi _β©
map_target' := mapsTo_univ _ _
left_inv' z _ := exp_arg z
right_inv' _ hx := arg_exp hx.1 hx.2
/-- `Complex.arg` and `expMapCircle` define an equivalence between `circle` and `(-Ο, Ο]`. -/
@[simps -fullyApplied]
noncomputable def argEquiv : Circle β Ioc (-Ο) Ο where
toFun z := β¨arg z, neg_pi_lt_arg _, arg_le_pi _β©
invFun := exp β (β)
left_inv _ := argPartialEquiv.left_inv trivial
right_inv x := Subtype.ext <| argPartialEquiv.right_inv x.2
lemma leftInverse_exp_arg : LeftInverse exp (arg β (β)) := exp_arg
lemma invOn_arg_exp : InvOn (arg β (β)) exp (Ioc (-Ο) Ο) univ := argPartialEquiv.symm.invOn
lemma surjOn_exp_neg_pi_pi : SurjOn exp (Ioc (-Ο) Ο) univ := argPartialEquiv.symm.surjOn
lemma exp_eq_exp {x y : β} : exp x = exp y β β m : β€, x = y + m * (2 * Ο) := by
rw [Subtype.ext_iff, coe_exp, coe_exp, exp_eq_exp_iff_exists_int]
refine exists_congr fun n => ?_
rw [β mul_assoc, β add_mul, mul_left_inj' I_ne_zero]
norm_cast
lemma periodic_exp : Periodic exp (2 * Ο) := fun z β¦ exp_eq_exp.2 β¨1, by rw [Int.cast_one, one_mul]β©
@[simp] lemma exp_two_pi : exp (2 * Ο) = 1 := periodic_exp.eq.trans exp_zero
lemma exp_int_mul_two_pi (n : β€) : exp (n * (2 * Ο)) = 1 :=
ext <| by simpa [mul_assoc] using Complex.exp_int_mul_two_pi_mul_I n
lemma exp_two_pi_mul_int (n : β€) : exp (2 * Ο * n) = 1 := by
simpa only [mul_comm] using exp_int_mul_two_pi n
lemma exp_eq_one {r : β} : exp r = 1 β β n : β€, r = n * (2 * Ο) := by
simp [Circle.ext_iff, Complex.exp_eq_one_iff, β mul_assoc, Complex.I_ne_zero,
β Complex.ofReal_inj]
lemma exp_inj {r s : β} : exp r = exp s β r β‘ s [PMOD (2 * Ο)] := by
simp [AddCommGroup.ModEq, β exp_eq_one, div_eq_one, eq_comm (a := exp r)]
lemma exp_sub_two_pi (x : β) : exp (x - 2 * Ο) = exp x := periodic_exp.sub_eq x
lemma exp_add_two_pi (x : β) : exp (x + 2 * Ο) = exp x := periodic_exp x
end Circle
namespace Real.Angle
/-- `Circle.exp`, applied to a `Real.Angle`. -/
noncomputable def toCircle (ΞΈ : Angle) : Circle := Circle.periodic_exp.lift ΞΈ
@[simp] lemma toCircle_coe (x : β) : toCircle x = .exp x := rfl
lemma coe_toCircle (ΞΈ : Angle) : (ΞΈ.toCircle : β) = ΞΈ.cos + ΞΈ.sin * I := by
induction ΞΈ using Real.Angle.induction_on
simp [exp_mul_I]
@[simp] lemma toCircle_zero : toCircle 0 = 1 := by rw [β coe_zero, toCircle_coe, Circle.exp_zero]
@[simp] lemma toCircle_neg (ΞΈ : Angle) : toCircle (-ΞΈ) = (toCircle ΞΈ)β»ΒΉ := by
induction ΞΈ using Real.Angle.induction_on
simp_rw [β coe_neg, toCircle_coe, Circle.exp_neg]
@[simp] lemma toCircle_add (ΞΈβ ΞΈβ : Angle) : toCircle (ΞΈβ + ΞΈβ) = toCircle ΞΈβ * toCircle ΞΈβ := by
induction ΞΈβ using Real.Angle.induction_on
induction ΞΈβ using Real.Angle.induction_on
exact Circle.exp_add _ _
@[simp] lemma arg_toCircle (ΞΈ : Real.Angle) : (arg ΞΈ.toCircle : Angle) = ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
rw [toCircle_coe, Circle.coe_exp, exp_mul_I, β ofReal_cos, β ofReal_sin, β
Real.Angle.cos_coe, β Real.Angle.sin_coe, arg_cos_add_sin_mul_I_coe_angle]
end Real.Angle
namespace AddCircle
variable {T : β}
/-! ### Map from `AddCircle` to `Circle` -/
theorem scaled_exp_map_periodic : Function.Periodic (fun x => Circle.exp (2 * Ο / T * x)) T := by
-- The case T = 0 is not interesting, but it is true, so we prove it to save hypotheses
rcases eq_or_ne T 0 with (rfl | hT)
Β· simp
Β· intro x; simp_rw [mul_add]; rw [div_mul_cancelβ _ hT, Circle.periodic_exp]
/-- The canonical map `fun x => exp (2 Ο i x / T)` from `β / β€ β’ T` to the unit circle in `β`.
If `T = 0` we understand this as the constant function 1. -/
noncomputable def toCircle : AddCircle T β Circle :=
(@scaled_exp_map_periodic T).lift
theorem toCircle_apply_mk (x : β) : @toCircle T x = Circle.exp (2 * Ο / T * x) :=
rfl
theorem toCircle_add (x : AddCircle T) (y : AddCircle T) :
@toCircle T (x + y) = toCircle x * toCircle y := by
induction x using QuotientAddGroup.induction_on
induction y using QuotientAddGroup.induction_on
simp_rw [β coe_add, toCircle_apply_mk, mul_add, Circle.exp_add]
@[simp] lemma toCircle_zero : toCircle (0 : AddCircle T) = 1 := by
rw [β QuotientAddGroup.mk_zero, toCircle_apply_mk, mul_zero, Circle.exp_zero]
theorem continuous_toCircle : Continuous (@toCircle T) :=
continuous_coinduced_dom.mpr (Circle.exp.continuous.comp <| continuous_const.mul continuous_id')
theorem injective_toCircle (hT : T β 0) : Function.Injective (@toCircle T) := by
intro a b h
induction a using QuotientAddGroup.induction_on
induction b using QuotientAddGroup.induction_on
simp_rw [toCircle_apply_mk] at h
obtain β¨m, hmβ© := Circle.exp_eq_exp.mp h.symm
rw [QuotientAddGroup.eq]; simp_rw [AddSubgroup.mem_zmultiples_iff, zsmul_eq_mul]
use m
field_simp at hm
linarith
/-- The homeomorphism between `AddCircle (2 * Ο)` and `Circle`. -/
@[simps] noncomputable def homeomorphCircle' : AddCircle (2 * Ο) ββ Circle where
toFun := Angle.toCircle
invFun := fun x β¦ arg x
left_inv := Angle.arg_toCircle
right_inv := Circle.exp_arg
continuous_toFun := continuous_coinduced_dom.mpr Circle.exp.continuous
continuous_invFun := by
rw [continuous_iff_continuousAt]
intro x
exact (continuousAt_arg_coe_angle x.coe_ne_zero).comp continuousAt_subtype_val
theorem homeomorphCircle'_apply_mk (x : β) : homeomorphCircle' x = Circle.exp x := rfl
/-- The homeomorphism between `AddCircle` and `Circle`. -/
noncomputable def homeomorphCircle (hT : T β 0) : AddCircle T ββ Circle :=
(homeomorphAddCircle T (2 * Ο) hT (by positivity)).trans homeomorphCircle'
theorem homeomorphCircle_apply (hT : T β 0) (x : AddCircle T) :
homeomorphCircle hT x = toCircle x := by
cases x using QuotientAddGroup.induction_on
rw [homeomorphCircle, Homeomorph.trans_apply,
homeomorphAddCircle_apply_mk, homeomorphCircle'_apply_mk, toCircle_apply_mk]
ring_nf
end AddCircle
open AddCircle
-- todo: upgrade this to `IsCoveringMap Circle.exp`.
lemma isLocalHomeomorph_circleExp : IsLocalHomeomorph Circle.exp := by
have : Fact (0 < 2 * Ο) := β¨by positivityβ©
exact homeomorphCircle'.isLocalHomeomorph.comp (isLocalHomeomorph_coe (2 * Ο)) |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Integrability/Basic.lean | import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog
import Mathlib.Analysis.SpecialFunctions.NonIntegrable
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv
/-!
# Integrability of Special Functions
This file establishes basic facts about the interval integrability of special functions, including
powers and the logarithm.
-/
open Interval MeasureTheory Real Set
variable {a b c d : β} (n : β) {f : β β β} {ΞΌ : Measure β} [IsLocallyFiniteMeasure ΞΌ]
namespace intervalIntegral
@[simp]
theorem intervalIntegrable_pow : IntervalIntegrable (fun x => x ^ n) ΞΌ a b :=
(continuous_pow n).intervalIntegrable a b
theorem intervalIntegrable_zpow {n : β€} (h : 0 β€ n β¨ (0 : β) β [[a, b]]) :
IntervalIntegrable (fun x => x ^ n) ΞΌ a b :=
(continuousOn_id.zpowβ n fun _ hx => h.symm.imp (ne_of_mem_of_not_mem hx) id).intervalIntegrable
/-- See `intervalIntegrable_rpow'` for a version with a weaker hypothesis on `r`, but assuming the
measure is volume. -/
theorem intervalIntegrable_rpow {r : β} (h : 0 β€ r β¨ (0 : β) β [[a, b]]) :
IntervalIntegrable (fun x => x ^ r) ΞΌ a b :=
(continuousOn_id.rpow_const fun _ hx =>
h.symm.imp (ne_of_mem_of_not_mem hx) id).intervalIntegrable
/-- See `intervalIntegrable_rpow` for a version applying to any locally finite measure, but with a
stronger hypothesis on `r`. -/
theorem intervalIntegrable_rpow' {r : β} (h : -1 < r) :
IntervalIntegrable (fun x => x ^ r) volume a b := by
suffices β c : β, IntervalIntegrable (fun x => x ^ r) volume 0 c by
exact IntervalIntegrable.trans (this a).symm (this b)
have : β c : β, 0 β€ c β IntervalIntegrable (fun x => x ^ r) volume 0 c := by
intro c hc
rw [intervalIntegrable_iff, uIoc_of_le hc]
have hderiv : β x β Ioo 0 c, HasDerivAt (fun x : β => x ^ (r + 1) / (r + 1)) (x ^ r) x := by
intro x hx
convert (Real.hasDerivAt_rpow_const (p := r + 1) (Or.inl hx.1.ne')).div_const (r + 1) using 1
simp [(by linarith : r + 1 β 0)]
apply integrableOn_deriv_of_nonneg _ hderiv
Β· intro x hx; apply rpow_nonneg hx.1.le
Β· refine (continuousOn_id.rpow_const ?_).div_const _; intro x _; right; linarith
intro c; rcases le_total 0 c with (hc | hc)
Β· exact this c hc
Β· rw [IntervalIntegrable.iff_comp_neg, neg_zero]
have m := (this (-c) (by linarith)).smul (cos (r * Ο))
rw [intervalIntegrable_iff] at m β’
refine m.congr_fun ?_ measurableSet_Ioc; intro x hx
rw [uIoc_of_le (by linarith : 0 β€ -c)] at hx
simp only [Pi.smul_apply, Algebra.id.smul_eq_mul, log_neg_eq_log, mul_comm,
rpow_def_of_pos hx.1, rpow_def_of_neg (by linarith [hx.1] : -x < 0)]
/-- The power function `x β¦ x^s` is integrable on `(0, t)` iff `-1 < s`. -/
lemma integrableOn_Ioo_rpow_iff {s t : β} (ht : 0 < t) :
IntegrableOn (fun x β¦ x ^ s) (Ioo (0 : β) t) β -1 < s := by
refine β¨fun h β¦ ?_, fun h β¦ ?_β©
swap
Β· rw [β intervalIntegrable_iff_integrableOn_Ioo_of_le ht.le]
apply intervalIntegrable_rpow' h (a := 0) (b := t)
contrapose! h
intro H
have I : 0 < min 1 t := lt_min zero_lt_one ht
have H' : IntegrableOn (fun x β¦ x ^ s) (Ioo 0 (min 1 t)) :=
H.mono (Set.Ioo_subset_Ioo le_rfl (min_le_right _ _)) le_rfl
have : IntegrableOn (fun x β¦ xβ»ΒΉ) (Ioo 0 (min 1 t)) := by
apply H'.mono' measurable_inv.aestronglyMeasurable
filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx
simp only [norm_inv, Real.norm_eq_abs, abs_of_nonneg (le_of_lt hx.1)]
rwa [β Real.rpow_neg_one x, Real.rpow_le_rpow_left_iff_of_base_lt_one hx.1]
exact lt_of_lt_of_le hx.2 (min_le_left _ _)
have : IntervalIntegrable (fun x β¦ xβ»ΒΉ) volume 0 (min 1 t) := by
rwa [intervalIntegrable_iff_integrableOn_Ioo_of_le I.le]
simp [intervalIntegrable_inv_iff, I.ne] at this
/-- See `intervalIntegrable_cpow'` for a version with a weaker hypothesis on `r`, but assuming the
measure is volume. -/
theorem intervalIntegrable_cpow {r : β} (h : 0 β€ r.re β¨ (0 : β) β [[a, b]]) :
IntervalIntegrable (fun x : β => (x : β) ^ r) ΞΌ a b := by
by_cases h2 : (0 : β) β [[a, b]]
Β· -- Easy case #1: 0 β [a, b] -- use continuity.
refine (continuousOn_of_forall_continuousAt fun x hx => ?_).intervalIntegrable
exact Complex.continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_mem_of_not_mem hx h2)
rw [eq_false h2, or_false] at h
rcases lt_or_eq_of_le h with (h' | h')
Β· -- Easy case #2: 0 < re r -- again use continuity
exact (Complex.continuous_ofReal_cpow_const h').intervalIntegrable _ _
-- Now the hard case: re r = 0 and 0 is in the interval.
refine (IntervalIntegrable.intervalIntegrable_norm_iff ?_).mp ?_
Β· refine (measurable_of_continuousOn_compl_singleton (0 : β) ?_).aestronglyMeasurable
exact continuousOn_of_forall_continuousAt fun x hx =>
Complex.continuousAt_ofReal_cpow_const x r (Or.inr hx)
-- reduce to case of integral over `[0, c]`
suffices β c : β, IntervalIntegrable (fun x : β => β(x : β) ^ rβ) ΞΌ 0 c from
(this a).symm.trans (this b)
intro c
rcases le_or_gt 0 c with (hc | hc)
Β· -- case `0 β€ c`: integrand is identically 1
have : IntervalIntegrable (fun _ => 1 : β β β) ΞΌ 0 c := intervalIntegrable_const
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hc] at this β’
refine IntegrableOn.congr_fun this (fun x hx => ?_) measurableSet_Ioc
dsimp only
rw [Complex.norm_cpow_eq_rpow_re_of_pos hx.1, β h', rpow_zero]
Β· -- case `c < 0`: integrand is identically constant, *except* at `x = 0` if `r β 0`.
apply IntervalIntegrable.symm
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hc.le]
rw [β Ioo_union_right hc, integrableOn_union, and_comm]; constructor
Β· exact integrableOn_singleton (by simp) <|
isFiniteMeasureOnCompacts_of_isLocallyFiniteMeasure.lt_top_of_isCompact isCompact_singleton
Β· have : β x : β, x β Ioo c 0 β βComplex.exp (βΟ * Complex.I * r)β = β(x : β) ^ rβ := by
intro x hx
rw [Complex.ofReal_cpow_of_nonpos hx.2.le, norm_mul, β Complex.ofReal_neg,
Complex.norm_cpow_eq_rpow_re_of_pos (neg_pos.mpr hx.2), β h',
rpow_zero, one_mul]
refine IntegrableOn.congr_fun ?_ this measurableSet_Ioo
rw [integrableOn_const_iff]
right
refine (measure_mono Set.Ioo_subset_Icc_self).trans_lt ?_
exact isFiniteMeasureOnCompacts_of_isLocallyFiniteMeasure.lt_top_of_isCompact isCompact_Icc
/-- See `intervalIntegrable_cpow` for a version applying to any locally finite measure, but with a
stronger hypothesis on `r`. -/
theorem intervalIntegrable_cpow' {r : β} (h : -1 < r.re) :
IntervalIntegrable (fun x : β => (x : β) ^ r) volume a b := by
suffices β c : β, IntervalIntegrable (fun x => (x : β) ^ r) volume 0 c by
exact IntervalIntegrable.trans (this a).symm (this b)
have : β c : β, 0 β€ c β IntervalIntegrable (fun x => (x : β) ^ r) volume 0 c := by
intro c hc
rw [β IntervalIntegrable.intervalIntegrable_norm_iff]
Β· rw [intervalIntegrable_iff]
apply IntegrableOn.congr_fun
Β· rw [β intervalIntegrable_iff]; exact intervalIntegral.intervalIntegrable_rpow' h
Β· intro x hx
rw [uIoc_of_le hc] at hx
dsimp only
rw [Complex.norm_cpow_eq_rpow_re_of_pos hx.1]
Β· exact measurableSet_uIoc
Β· refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_uIoc
refine continuousOn_of_forall_continuousAt fun x hx => ?_
rw [uIoc_of_le hc] at hx
refine (continuousAt_cpow_const (Or.inl ?_)).comp Complex.continuous_ofReal.continuousAt
rw [Complex.ofReal_re]
exact hx.1
intro c; rcases le_total 0 c with (hc | hc)
Β· exact this c hc
Β· rw [IntervalIntegrable.iff_comp_neg, neg_zero]
have m := (this (-c) (by linarith)).const_mul (Complex.exp (Ο * Complex.I * r))
rw [intervalIntegrable_iff, uIoc_of_le (by linarith : 0 β€ -c)] at m β’
refine m.congr_fun (fun x hx => ?_) measurableSet_Ioc
dsimp only
have : -x β€ 0 := by linarith [hx.1]
rw [Complex.ofReal_cpow_of_nonpos this, mul_comm]
simp
/-- The complex power function `x β¦ x^s` is integrable on `(0, t)` iff `-1 < s.re`. -/
theorem integrableOn_Ioo_cpow_iff {s : β} {t : β} (ht : 0 < t) :
IntegrableOn (fun x : β β¦ (x : β) ^ s) (Ioo (0 : β) t) β -1 < s.re := by
refine β¨fun h β¦ ?_, fun h β¦ ?_β©
swap
Β· rw [β intervalIntegrable_iff_integrableOn_Ioo_of_le ht.le]
exact intervalIntegrable_cpow' h (a := 0) (b := t)
have B : IntegrableOn (fun a β¦ a ^ s.re) (Ioo 0 t) := by
apply (integrableOn_congr_fun _ measurableSet_Ioo).1 h.norm
intro a ha
simp [Complex.norm_cpow_eq_rpow_re_of_pos ha.1]
rwa [integrableOn_Ioo_rpow_iff ht] at B
@[simp]
theorem intervalIntegrable_id : IntervalIntegrable (fun x => x) ΞΌ a b :=
continuous_id.intervalIntegrable a b
theorem intervalIntegrable_const : IntervalIntegrable (fun _ => c) ΞΌ a b :=
continuous_const.intervalIntegrable a b
theorem intervalIntegrable_one_div (h : β x : β, x β [[a, b]] β f x β 0)
(hf : ContinuousOn f [[a, b]]) : IntervalIntegrable (fun x => 1 / f x) ΞΌ a b :=
(continuousOn_const.div hf h).intervalIntegrable
@[simp]
theorem intervalIntegrable_inv (h : β x : β, x β [[a, b]] β f x β 0)
(hf : ContinuousOn f [[a, b]]) : IntervalIntegrable (fun x => (f x)β»ΒΉ) ΞΌ a b := by
simpa only [one_div] using intervalIntegrable_one_div h hf
@[simp]
theorem intervalIntegrable_sin : IntervalIntegrable sin ΞΌ a b :=
continuous_sin.intervalIntegrable a b
@[simp]
theorem intervalIntegrable_cos : IntervalIntegrable cos ΞΌ a b :=
continuous_cos.intervalIntegrable a b
@[simp]
theorem intervalIntegrable_exp : IntervalIntegrable exp ΞΌ a b :=
continuous_exp.intervalIntegrable a b
@[simp]
theorem _root_.IntervalIntegrable.log (hf : ContinuousOn f [[a, b]])
(h : β x : β, x β [[a, b]] β f x β 0) :
IntervalIntegrable (fun x => log (f x)) ΞΌ a b :=
(ContinuousOn.log hf h).intervalIntegrable
/--
The real logarithm is interval integrable (with respect to every locally finite measure) over every
interval that does not contain zero. See `intervalIntegrable_log'` for a version without any
hypothesis on the interval, but assuming the measure is the volume.
-/
@[simp]
theorem intervalIntegrable_log (h : (0 : β) β [[a, b]]) : IntervalIntegrable log ΞΌ a b :=
IntervalIntegrable.log continuousOn_id fun _ hx => ne_of_mem_of_not_mem hx h
/--
The real logarithm is interval integrable (with respect to the volume measure) on every interval.
See `intervalIntegrable_log` for a version applying to any locally finite measure, but with an
additional hypothesis on the interval.
-/
@[simp]
theorem intervalIntegrable_log' : IntervalIntegrable log volume a b := by
-- Log is even, so it suffices to consider the case 0 < a and b = 0
apply intervalIntegrable_of_even (log_neg_eq_log Β· |>.symm)
intro x hx
-- Split integral
apply IntervalIntegrable.trans (b := 1)
Β· -- Show integrability on [0β¦1] using non-negativity of the derivative
rw [β neg_neg log]
apply IntervalIntegrable.neg
apply intervalIntegrable_deriv_of_nonneg (g := fun x β¦ -(x * log x - x))
Β· exact (continuous_mul_log.continuousOn.sub continuous_id.continuousOn).neg
Β· intro s β¨hs, _β©
norm_num at *
simpa using (hasDerivAt_id s).sub (hasDerivAt_mul_log hs.ne.symm)
Β· intro s β¨hsβ, hsββ©
norm_num at *
exact (log_nonpos_iff hsβ.le).mpr hsβ.le
Β· -- Show integrability on [1β¦t] by continuity
apply ContinuousOn.intervalIntegrable
apply Real.continuousOn_log.mono
apply Set.notMem_uIcc_of_lt zero_lt_one at hx
simpa
theorem intervalIntegrable_one_div_one_add_sq :
IntervalIntegrable (fun x : β => 1 / (β1 + x ^ 2)) ΞΌ a b := by
refine (continuous_const.div ?_ fun x => ?_).intervalIntegrable a b
Β· fun_prop
Β· nlinarith
@[simp]
theorem intervalIntegrable_inv_one_add_sq :
IntervalIntegrable (fun x : β => (β1 + x ^ 2)β»ΒΉ) ΞΌ a b := by
simp [β one_div, intervalIntegrable_one_div_one_add_sq]
end intervalIntegral |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Integrability/LogMeromorphic.lean | import Mathlib.Analysis.Meromorphic.FactorizedRational
import Mathlib.Analysis.NormedSpace.Connected
import Mathlib.Analysis.SpecialFunctions.Integrability.Basic
import Mathlib.Analysis.SpecialFunctions.Log.PosLog
import Mathlib.LinearAlgebra.Complex.FiniteDimensional
import Mathlib.MeasureTheory.Integral.CircleIntegral
/-!
# Integrability for Logarithms of Meromorphic Functions
We establish integrability for functions of the form `log βmeromorphicβ`. In the real setting, these
functions are interval integrable over every interval of the real line. This implies in particular
that logarithms of trigonometric functions are interval integrable. In the complex setting, the
functions are circle integrable over every circle in the complex plane.
-/
open Filter Interval MeasureTheory MeromorphicOn Metric Real
/-!
## Interval Integrability for Logarithms of Real Meromorphic Functions
-/
section IntervalIntegrable
variable
{E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
{f : β β E} {a b : β}
/--
If `f` is real-meromorphic on a compact interval, then `log βf Β·β` is interval integrable on this
interval.
-/
theorem intervalIntegrable_log_norm_meromorphicOn (hf : MeromorphicOn f [[a, b]]) :
IntervalIntegrable (log βf Β·β) volume a b := by
by_cases tβ : β u : [[a, b]], meromorphicOrderAt f u β β€
Β· obtain β¨g, hβg, hβg, hβgβ© := hf.extract_zeros_poles tβ
((MeromorphicOn.divisor f [[a, b]]).finiteSupport isCompact_uIcc)
have hβg := MeromorphicOn.extract_zeros_poles_log hβg hβg
rw [intervalIntegrable_congr_codiscreteWithin
(hβg.filter_mono (Filter.codiscreteWithin.mono Set.uIoc_subset_uIcc))]
apply IntervalIntegrable.add
Β· apply IntervalIntegrable.finsum
intro i
apply IntervalIntegrable.const_mul
rw [(by ring : a = ((a - i) + i)), (by ring : b = ((b - i) + i))]
apply IntervalIntegrable.comp_sub_right (f := (log βΒ·β)) _ i
simp [norm_eq_abs, log_abs]
Β· apply ContinuousOn.intervalIntegrable
apply hβg.continuousOn.norm.log
simp_all
Β· rw [β hf.exists_meromorphicOrderAt_ne_top_iff_forall (isConnected_Icc inf_le_sup)] at tβ
push_neg at tβ
have : (log βf Β·β) =αΆ [Filter.codiscreteWithin (Ξ a b)] 0 := by
apply Filter.EventuallyEq.filter_mono _ (Filter.codiscreteWithin.mono Set.uIoc_subset_uIcc)
filter_upwards [hf.meromorphicNFAt_mem_codiscreteWithin,
Filter.self_mem_codiscreteWithin [[a, b]]] with x hβx hβx
simp only [Pi.zero_apply, log_eq_zero, norm_eq_zero]
left
by_contra hCon
simp_all [β hβx.meromorphicOrderAt_eq_zero_iff, tβ β¨x, hβxβ©]
rw [intervalIntegrable_congr_codiscreteWithin this]
apply Iff.mpr _root_.intervalIntegrable_const_iff
tauto
/--
If `f` is real-meromorphic on a compact interval, then `log βf Β·β` is interval integrable on this
interval.
-/
theorem intervalIntegrable_posLog_norm_meromorphicOn (hf : MeromorphicOn f [[a, b]]) :
IntervalIntegrable (logβΊ βf Β·β) volume a b := by
simp_rw [β half_mul_log_add_log_abs, mul_add]
apply IntervalIntegrable.add
Β· apply (intervalIntegrable_log_norm_meromorphicOn hf).const_mul
Β· apply (intervalIntegrable_log_norm_meromorphicOn hf).abs.const_mul
/--
If `f` is real-meromorphic on a compact interval, then `log β f` is interval integrable on this
interval.
-/
theorem _root_.MeromorphicOn.intervalIntegrable_log {f : β β β} (hf : MeromorphicOn f [[a, b]]) :
IntervalIntegrable (log β f) volume a b := by
rw [(by aesop : log β f = (log βf Β·β))]
exact intervalIntegrable_log_norm_meromorphicOn hf
/--
Special case of `MeromorphicOn.intervalIntegrable_log`: The function `log β sin` is interval
integrable over every interval.
-/
theorem intervalIntegrable_log_sin : IntervalIntegrable (log β sin) volume a b :=
analyticOnNhd_sin.meromorphicOn.intervalIntegrable_log
/--
Special case of `MeromorphicOn.intervalIntegrable_log`: The function `log β cos` is interval
integrable over every interval.
-/
theorem intervalIntegrable_log_cos : IntervalIntegrable (log β cos) volume a b :=
analyticOnNhd_cos.meromorphicOn.intervalIntegrable_log
end IntervalIntegrable
/-!
## Circle Integrability for Logarithms of Complex Meromorphic Functions
-/
section CircleIntegrable
variable
{E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
{c : β} {R : β} {f : β β E}
/--
If `f` is complex meromorphic on a circle in the complex plane, then `log βf Β·β` is circle
integrable over that circle.
-/
theorem circleIntegrable_log_norm_meromorphicOn (hf : MeromorphicOn f (sphere c |R|)) :
CircleIntegrable (log βf Β·β) c R := by
by_cases tβ : β u : (sphere c |R|), meromorphicOrderAt f u β β€
Β· obtain β¨g, hβg, hβg, hβgβ© := hf.extract_zeros_poles tβ
((divisor f (sphere c |R|)).finiteSupport (isCompact_sphere c |R|))
have hβg := MeromorphicOn.extract_zeros_poles_log hβg hβg
apply CircleIntegrable.congr_codiscreteWithin hβg.symm
apply CircleIntegrable.add
Β· apply CircleIntegrable.finsum
intro i
apply IntervalIntegrable.const_mul
apply intervalIntegrable_log_norm_meromorphicOn
apply AnalyticOnNhd.meromorphicOn
apply AnalyticOnNhd.sub _ analyticOnNhd_const
apply (analyticOnNhd_circleMap c R).mono (by tauto)
Β· apply ContinuousOn.intervalIntegrable
apply ContinuousOn.log
Β· apply ContinuousOn.norm
apply hβg.continuousOn.comp (t := sphere c |R|) (continuous_circleMap c R).continuousOn
intro x hx
simp
Β· intro x hx
rw [ne_eq, norm_eq_zero]
apply hβg β¨circleMap c R x, circleMap_mem_sphere' c R xβ©
Β· rw [β hf.exists_meromorphicOrderAt_ne_top_iff_forall (isConnected_sphere (by simp) c
(abs_nonneg R))] at tβ
push_neg at tβ
have : (log βf Β·β) =αΆ [codiscreteWithin (sphere c |R|)] 0 := by
filter_upwards [hf.meromorphicNFAt_mem_codiscreteWithin,
self_mem_codiscreteWithin (sphere c |R|)] with x hβx hβx
simp only [Pi.zero_apply, log_eq_zero, norm_eq_zero]
left
by_contra hCon
simp_all [β hβx.meromorphicOrderAt_eq_zero_iff, tβ β¨x, hβxβ©]
apply CircleIntegrable.congr_codiscreteWithin this.symm (circleIntegrable_const 0 c R)
/--
Variant of `circleIntegrable_log_norm_meromorphicOn` for non-negative radii.
-/
theorem circleIntegrable_log_norm_meromorphicOn_of_nonneg (hf : MeromorphicOn f (sphere c R))
(hR : 0 β€ R) :
CircleIntegrable (log βf Β·β) c R := by
rw [β abs_of_nonneg hR] at hf
exact circleIntegrable_log_norm_meromorphicOn hf
/--
Variant of `circleIntegrable_log_norm_meromorphicOn` for factorized rational functions.
-/
theorem circleIntegrable_log_norm_factorizedRational {R : β} {c : β} (D : β β β€) :
CircleIntegrable (βαΆ u, ((D u) * log βΒ· - uβ)) c R :=
CircleIntegrable.finsum (fun _ β¦ (circleIntegrable_log_norm_meromorphicOn
(analyticOnNhd_id.sub analyticOnNhd_const).meromorphicOn).const_smul)
/--
If `f` is complex meromorphic on a circle in the complex plane, then `logβΊ βf Β·β` is circle
integrable over that circle.
-/
theorem circleIntegrable_posLog_norm_meromorphicOn (hf : MeromorphicOn f (sphere c |R|)) :
CircleIntegrable (logβΊ βf Β·β) c R := by
simp_rw [β half_mul_log_add_log_abs, mul_add]
apply CircleIntegrable.add
Β· apply (circleIntegrable_log_norm_meromorphicOn hf).const_mul
Β· apply (circleIntegrable_log_norm_meromorphicOn hf).abs.const_mul
/--
Variant of `circleIntegrable_posLog_norm_meromorphicOn` for non-negative radii.
-/
theorem circleIntegrable_posLog_norm_meromorphicOn_of_nonneg (hf : MeromorphicOn f (sphere c R))
(hR : 0 β€ R) :
CircleIntegrable (logβΊ βf Β·β) c R := by
rw [β abs_of_nonneg hR] at hf
exact circleIntegrable_posLog_norm_meromorphicOn hf
end CircleIntegrable |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Integrals/PosLogEqCircleAverage.lean | import Mathlib.Analysis.Complex.Harmonic.MeanValue
import Mathlib.Analysis.InnerProductSpace.Harmonic.Constructions
import Mathlib.Analysis.SpecialFunctions.Integrals.Basic
import Mathlib.Analysis.SpecialFunctions.Integrals.LogTrigonometric
import Mathlib.MeasureTheory.Integral.CircleAverage
/-!
# Representation of `logβΊ` as a Circle Average
If `a` is any complex number, `circleAverage_log_norm_sub_const_eq_posLog` represents `logβΊ a` as
the circle average of `log βΒ· - aβ` over the unit circle.
-/
open Filter Interval intervalIntegral MeasureTheory Metric Real
variable {a c : β} {R : β}
/-!
## Circle Integrability
-/
/--
If `a` is any complex number, the function `(log βΒ· - aβ)` is circle integrable over every circle.
-/
lemma circleIntegrable_log_norm_sub_const (r : β) : CircleIntegrable (log βΒ· - aβ) c r :=
circleIntegrable_log_norm_meromorphicOn (fun z hz β¦ by fun_prop)
/-!
## Computing `circleAverage (log βΒ· - aβ) 0 1` in case where `βaβ < 1`.
-/
/--
If `a : β` has norm smaller than one, then `circleAverage (log βΒ· - aβ) 0 1` vanishes.
-/
@[simp]
theorem circleAverage_log_norm_sub_constβ (h : βaβ < 1) : circleAverage (log βΒ· - aβ) 0 1 = 0 := by
calc circleAverage (log βΒ· - aβ) 0 1
_ = circleAverage (log β1 - Β·β»ΒΉ * aβ) 0 1 := by
apply circleAverage_congr_sphere
intro z hz
simp_all only [abs_one, mem_sphere_iff_norm, sub_zero]
congr 1
have : z β 0 := fun h β¦ by simp [h] at hz
calc βz - aβ
_ = βzβ»ΒΉ * (z - a)β := by simp [hz]
_ = β1 - zβ»ΒΉ * aβ := by field_simp
_ = 0 := by
rw [circleAverage_zero_one_congr_inv (f := fun x β¦ log β1 - x * aβ),
HarmonicOnNhd.circleAverage_eq, zero_mul, sub_zero,
CStarRing.norm_of_mem_unitary (unitary β).one_mem, log_one]
intro x hx
have : βx * aβ < 1 := by
calc βx * aβ
_ = βxβ * βaβ := by simp
_ β€ βaβ := mul_le_of_le_one_left (norm_nonneg _) (by aesop)
_ < 1 := h
apply AnalyticAt.harmonicAt_log_norm (by fun_prop)
rw [sub_ne_zero]
by_contra! hCon
rwa [β hCon, CStarRing.norm_of_mem_unitary (unitary β).one_mem, lt_self_iff_false] at this
/-!
## Computing `circleAverage (log βΒ· - aβ) 0 1` in case where `βaβ = 1`.
-/
-- Integral computation used in `circleAverage_log_norm_id_sub_constβ`
private lemma circleAverage_log_norm_sub_constβ_integral :
β« x in 0..(2 * Ο), log (4 * sin (x / 2) ^ 2) / 2 = 0 := by
calc β« x in 0..(2 * Ο), log (4 * sin (x / 2) ^ 2) / 2
_ = β« (x : β) in 0..Ο, log (4 * sin x ^ 2) := by
have {x : β} : x / 2 = 2β»ΒΉ * x := by ring
rw [intervalIntegral.integral_div, this, inv_mul_integral_comp_div
(f := fun x β¦ log (4 * sin x ^ 2))]
simp
_ = β« (x : β) in 0..Ο, log 4 + 2 * log (sin x) := by
apply integral_congr_codiscreteWithin
apply codiscreteWithin.mono (by tauto : Ξ 0 Ο β Set.univ)
have : AnalyticOnNhd β (4 * sin Β· ^ 2) Set.univ := fun _ _ β¦ by fun_prop
have := this.preimage_zero_mem_codiscrete (x := Ο / 2)
simp only [sin_pi_div_two, one_pow, mul_one, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true,
Set.preimage_compl, forall_const] at this
filter_upwards [this] with a ha
simp only [Set.mem_compl_iff, Set.mem_preimage, Set.mem_singleton_iff, mul_eq_zero,
OfNat.ofNat_ne_zero, ne_eq, not_false_eq_true, pow_eq_zero_iff, false_or] at ha
rw [log_mul (by simp) (by simp_all), log_pow, Nat.cast_ofNat]
_ = (β« (x : β) in 0..Ο, log 4) + 2 * β« (x : β) in 0..Ο, log (sin x) := by
rw [integral_add _root_.intervalIntegrable_const
(by apply intervalIntegrable_log_sin.const_mul 2), intervalIntegral.integral_const_mul]
_ = 0 := by
simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul, integral_log_sin_zero_pi,
(by norm_num : (4 : β) = 2 * 2), log_mul two_ne_zero two_ne_zero]
ring
/--
If `a : β` has norm one, then the circle average `circleAverage (log βΒ· - aβ) 0 1` vanishes.
-/
theorem circleAverage_log_norm_sub_constβ (h : βaβ = 1) :
circleAverage (log βΒ· - aβ) 0 1 = 0 := by
-- Observing that the problem is rotation invariant, we rotate by an angle of `ΞΆ = - arg a` and
-- reduce the problem to the case where `a = 1`. The integral can then be evaluated by a direct
-- computation.
simp only [circleAverage, mul_inv_rev, smul_eq_mul, mul_eq_zero, inv_eq_zero, OfNat.ofNat_ne_zero,
or_false]
right
obtain β¨ΞΆ, hΞΆβ© : β ΞΆ, aβ»ΒΉ = circleMap 0 1 ΞΆ := by simp [Set.exists_range_iff.1, h]
calc β« x in 0..(2 * Ο), log βcircleMap 0 1 x - aβ
_ = β« x in 0..(2 * Ο), log β(circleMap 0 1 ΞΆ) * (circleMap 0 1 x - a)β := by
simp
_ = β« x in 0..(2 * Ο), log βcircleMap 0 1 (ΞΆ + x) - (circleMap 0 1 ΞΆ) * aβ := by
simp [mul_sub, circleMap, add_mul, Complex.exp_add]
_ = β« x in 0..(2 * Ο), log βcircleMap 0 1 (ΞΆ + x) - 1β := by
simp [β hΞΆ, inv_mul_cancelβ (by aesop : a β 0)]
_ = β« x in 0..(2 * Ο), log βcircleMap 0 1 x - 1β := by
have : Function.Periodic (log βcircleMap 0 1 Β· - 1β) (2 * Ο) :=
fun x β¦ by simp [periodic_circleMap 0 1 x]
have := this.intervalIntegral_add_eq (t := 0) (s := ΞΆ)
simp_all [integral_comp_add_left (log βcircleMap 0 1 Β· - 1β)]
_ = β« x in 0..(2 * Ο), log (4 * sin (x / 2) ^ 2) / 2 := by
apply integral_congr
intro x hx
simp only []
rw [Complex.norm_def, log_sqrt (circleMap 0 1 x - 1).normSq_nonneg]
congr
calc Complex.normSq (circleMap 0 1 x - 1)
_ = (cos x - 1) * (cos x - 1) + sin x * sin x := by
simp [circleMap, Complex.normSq_apply]
_ = sin x ^ 2 + cos x ^ 2 + 1 - 2 * cos x := by
ring
_ = 2 - 2 * cos x := by
rw [sin_sq_add_cos_sq]
norm_num
_ = 2 - 2 * cos (2 * (x / 2)) := by
rw [β mul_div_assoc]
simp
_ = 4 - 4 * cos (x / 2) ^ 2 := by
rw [cos_two_mul]
ring
_ = 4 * sin (x / 2) ^ 2 := by
nth_rw 1 [β mul_one 4, β sin_sq_add_cos_sq (x / 2)]
ring
_ = 0 := circleAverage_log_norm_sub_constβ_integral
/-!
## Computing `circleAverage (log βΒ· - aβ) 0 1` in case where `1 < βaβ`.
-/
/--
If `a : β` has norm greater than one, then `circleAverage (log βΒ· - aβ) 0 1` equals `log βaβ`.
-/
@[simp]
theorem circleAverage_log_norm_sub_constβ (h : 1 < βaβ) :
circleAverage (log βΒ· - aβ) 0 1 = log βaβ := by
rw [HarmonicOnNhd.circleAverage_eq, zero_sub, norm_neg]
intro x hx
apply AnalyticAt.harmonicAt_log_norm (by fun_prop)
rw [sub_ne_zero]
by_contra!
simp_all only [abs_one, Metric.mem_closedBall, dist_zero_right]
linarith
/-!
## Presentation of `logβΊ` in Terms of Circle Averages
-/
/--
The `circleAverage (log βΒ· - aβ) 0 1` equals `logβΊ βaβ`.
-/
@[simp]
theorem circleAverage_log_norm_sub_const_eq_posLog :
circleAverage (log βΒ· - aβ) 0 1 = logβΊ βaβ := by
rcases lt_trichotomy 1 βaβ with h | h | h
Β· rw [circleAverage_log_norm_sub_constβ h]
apply (posLog_eq_log _).symm
simp_all [le_of_lt h]
Β· rw [eq_comm, circleAverage_log_norm_sub_constβ h.symm, posLog_eq_zero_iff]
simp_all
Β· rw [eq_comm, circleAverage_log_norm_sub_constβ h, posLog_eq_zero_iff]
simp_all [le_of_lt h]
/--
The `circleAverage (log βΒ· + aβ) 0 1` equals `logβΊ βaβ`.
-/
@[simp]
theorem circleAverage_log_norm_add_const_eq_posLog :
circleAverage (log βΒ· + aβ) 0 1 = logβΊ βaβ := by
have : (log βΒ· + aβ) = (log βΒ· - -aβ) := by simp
simp [this]
/--
Generalization of `circleAverage_log_norm_sub_const_eq_posLog`: The
`circleAverage (log βΒ· - aβ) c R` equals `log R + logβΊ (|R|β»ΒΉ * βc - aβ)`.
-/
theorem circleAverage_log_norm_sub_const_eq_log_radius_add_posLog (hR : R β 0) :
circleAverage (log βΒ· - aβ) c R = log R + logβΊ (Rβ»ΒΉ * βc - aβ) := by
calc circleAverage (log βΒ· - aβ) c R
_ = circleAverage (fun z β¦ log βR * (z + Rβ»ΒΉ * (c - a))β) 0 1 := by
rw [circleAverage_eq_circleAverage_zero_one]
congr
ext z
congr
rw [Complex.ofReal_inv R]
field [Complex.ofReal_ne_zero.mpr hR]
_ = circleAverage (fun z β¦ log βRβ + log βz + Rβ»ΒΉ * (c - a)β) 0 1 := by
apply circleAverage_congr_codiscreteWithin _ (zero_ne_one' β).symm
have : {z | βz + βRβ»ΒΉ * (c - a)β β 0} β codiscreteWithin (Metric.sphere (0 : β) |1|) := by
apply codiscreteWithin_iff_locallyFiniteComplementWithin.2
intro z hz
use Set.univ
simp only [univ_mem, abs_one, Complex.ofReal_inv, ne_eq, norm_eq_zero, Set.univ_inter,
true_and]
apply Set.Subsingleton.finite
intro zβ hzβ zβ hzβ
simp_all only [ne_eq, abs_one, mem_sphere_iff_norm, sub_zero, Set.mem_diff, Set.mem_setOf_eq,
Decidable.not_not]
rw [add_eq_zero_iff_eq_neg.1 hzβ.2, add_eq_zero_iff_eq_neg.1 hzβ.2]
filter_upwards [this] with z hz
rw [norm_mul, log_mul (norm_ne_zero_iff.2 (Complex.ofReal_ne_zero.mpr hR)) hz]
simp
_ = log R + logβΊ (|R|β»ΒΉ * βc - aβ) := by
rw [β Pi.add_def, circleAverage_add (circleIntegrable_const (log βRβ) 0 1)
(circleIntegrable_log_norm_meromorphicOn (fun _ _ β¦ by fun_prop)), circleAverage_const]
simp
_ = log R + logβΊ (Rβ»ΒΉ * βc - aβ) := by
congr 1
rcases hR.lt_or_gt with h | h
Β· simp [abs_of_neg h]
Β· rw [abs_of_pos h]
/--
Trivial corollary of
`circleAverage_log_norm_sub_const_eq_log_radius_add_posLog`: If `u : β` lies within the closed ball
with center `c` and radius `R`, then the circle average
`circleAverage (log βΒ· - uβ) c R` equals `log R`.
-/
lemma circleAverage_log_norm_sub_const_of_mem_closedBall (hu : a β closedBall c |R|) :
circleAverage (log βΒ· - aβ) c R = log R := by
by_cases hR : R = 0
Β· simp_all
rw [circleAverage_log_norm_sub_const_eq_log_radius_add_posLog hR, add_eq_left,
posLog_eq_zero_iff, abs_mul, abs_inv, abs_of_nonneg (norm_nonneg (c - a))]
rw [mem_closedBall, dist_eq_norm'] at hu
apply inv_mul_le_one_of_leβ hu (abs_nonneg R) |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean | import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog
import Mathlib.Analysis.SpecialFunctions.NonIntegrable
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv
import Mathlib.Analysis.SpecialFunctions.Integrability.Basic
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Sinc
import Mathlib.MeasureTheory.Integral.IntervalIntegral.IntegrationByParts
/-!
# Integration of specific interval integrals
This file contains proofs of the integrals of various specific functions. This includes:
* Integrals of simple functions, such as `id`, `pow`, `inv`, `exp`, `log`
* Integrals of some trigonometric functions, such as `sin`, `cos`, `1 / (1 + x^2)`
* The integral of `cos x ^ 2 - sin x ^ 2`
* Reduction formulae for the integrals of `sin x ^ n` and `cos x ^ n` for `n β₯ 2`
* The computation of `β« x in 0..Ο, sin x ^ n` as a product for even and odd `n` (used in proving the
Wallis product for pi)
* Integrals of the form `sin x ^ m * cos x ^ n`
With these lemmas, many simple integrals can be computed by `simp` or `norm_num`.
This file is still being developed.
## Tags
integrate, integration, integrable
-/
open Real Set Finset
open scoped Real Interval
variable {a b : β} (n : β)
namespace intervalIntegral
open MeasureTheory
variable {f : β β β} {ΞΌ : Measure β} [IsLocallyFiniteMeasure ΞΌ] (c d : β)
/-! ### Integrals of the form `c * β« x in a..b, f (c * x + d)` -/
section
@[simp]
theorem mul_integral_comp_mul_right : (c * β« x in a..b, f (x * c)) = β« x in a * c..b * c, f x :=
smul_integral_comp_mul_right f c
@[simp]
theorem mul_integral_comp_mul_left : (c * β« x in a..b, f (c * x)) = β« x in c * a..c * b, f x :=
smul_integral_comp_mul_left f c
@[simp]
theorem inv_mul_integral_comp_div : (cβ»ΒΉ * β« x in a..b, f (x / c)) = β« x in a / c..b / c, f x :=
inv_smul_integral_comp_div f c
@[simp]
theorem mul_integral_comp_mul_add :
(c * β« x in a..b, f (c * x + d)) = β« x in c * a + d..c * b + d, f x :=
smul_integral_comp_mul_add f c d
@[simp]
theorem mul_integral_comp_add_mul :
(c * β« x in a..b, f (d + c * x)) = β« x in d + c * a..d + c * b, f x :=
smul_integral_comp_add_mul f c d
@[simp]
theorem inv_mul_integral_comp_div_add :
(cβ»ΒΉ * β« x in a..b, f (x / c + d)) = β« x in a / c + d..b / c + d, f x :=
inv_smul_integral_comp_div_add f c d
@[simp]
theorem inv_mul_integral_comp_add_div :
(cβ»ΒΉ * β« x in a..b, f (d + x / c)) = β« x in d + a / c..d + b / c, f x :=
inv_smul_integral_comp_add_div f c d
@[simp]
theorem mul_integral_comp_mul_sub :
(c * β« x in a..b, f (c * x - d)) = β« x in c * a - d..c * b - d, f x :=
smul_integral_comp_mul_sub f c d
@[simp]
theorem mul_integral_comp_sub_mul :
(c * β« x in a..b, f (d - c * x)) = β« x in d - c * b..d - c * a, f x :=
smul_integral_comp_sub_mul f c d
@[simp]
theorem inv_mul_integral_comp_div_sub :
(cβ»ΒΉ * β« x in a..b, f (x / c - d)) = β« x in a / c - d..b / c - d, f x :=
inv_smul_integral_comp_div_sub f c d
@[simp]
theorem inv_mul_integral_comp_sub_div :
(cβ»ΒΉ * β« x in a..b, f (d - x / c)) = β« x in d - b / c..d - a / c, f x :=
inv_smul_integral_comp_sub_div f c d
end
end intervalIntegral
open intervalIntegral
/-! ### Integrals of simple functions -/
theorem integral_cpow {r : β} (h : -1 < r.re β¨ r β -1 β§ (0 : β) β [[a, b]]) :
(β« x : β in a..b, (x : β) ^ r) = ((b : β) ^ (r + 1) - (a : β) ^ (r + 1)) / (r + 1) := by
rw [sub_div]
have hr : r + 1 β 0 := by
rcases h with h | h
Β· apply_fun Complex.re
rw [Complex.add_re, Complex.one_re, Complex.zero_re, Ne, add_eq_zero_iff_eq_neg]
exact h.ne'
Β· rw [Ne, β add_eq_zero_iff_eq_neg] at h; exact h.1
by_cases hab : (0 : β) β [[a, b]]
Β· apply integral_eq_sub_of_hasDerivAt (fun x hx => ?_)
(intervalIntegrable_cpow (r := r) <| Or.inr hab)
refine hasDerivAt_ofReal_cpow_const' (ne_of_mem_of_not_mem hx hab) ?_
contrapose! hr; rwa [add_eq_zero_iff_eq_neg]
replace h : -1 < r.re := by tauto
suffices β c : β, (β« x : β in 0..c, (x : β) ^ r) =
(c : β) ^ (r + 1) / (r + 1) - (0 : β) ^ (r + 1) / (r + 1) by
rw [β integral_add_adjacent_intervals (@intervalIntegrable_cpow' a 0 r h)
(@intervalIntegrable_cpow' 0 b r h), integral_symm, this a, this b, Complex.zero_cpow hr]
ring
intro c
apply integral_eq_sub_of_hasDeriv_right
Β· refine ((Complex.continuous_ofReal_cpow_const ?_).div_const _).continuousOn
rwa [Complex.add_re, Complex.one_re, β neg_lt_iff_pos_add]
Β· refine fun x hx => (hasDerivAt_ofReal_cpow_const' ?_ ?_).hasDerivWithinAt
Β· rcases le_total c 0 with (hc | hc)
Β· rw [max_eq_left hc] at hx; exact hx.2.ne
Β· rw [min_eq_left hc] at hx; exact hx.1.ne'
Β· contrapose! hr; rw [hr]; ring
Β· exact intervalIntegrable_cpow' h
theorem integral_rpow {r : β} (h : -1 < r β¨ r β -1 β§ (0 : β) β [[a, b]]) :
β« x in a..b, x ^ r = (b ^ (r + 1) - a ^ (r + 1)) / (r + 1) := by
have h' : -1 < (r : β).re β¨ (r : β) β -1 β§ (0 : β) β [[a, b]] := by
cases h
Β· left; rwa [Complex.ofReal_re]
Β· right; rwa [β Complex.ofReal_one, β Complex.ofReal_neg, Ne, Complex.ofReal_inj]
have :
(β« x in a..b, (x : β) ^ (r : β)) = ((b : β) ^ (r + 1 : β) - (a : β) ^ (r + 1 : β)) / (r + 1) :=
integral_cpow h'
apply_fun Complex.re at this; convert this
Β· simp_rw [intervalIntegral_eq_integral_uIoc, Complex.real_smul, Complex.re_ofReal_mul, rpow_def,
β RCLike.re_eq_complex_re, smul_eq_mul]
rw [integral_re]
refine intervalIntegrable_iff.mp ?_
rcases h' with h' | h'
Β· exact intervalIntegrable_cpow' h'
Β· exact intervalIntegrable_cpow (Or.inr h'.2)
Β· rw [(by push_cast; rfl : (r : β) + 1 = ((r + 1 : β) : β))]
simp_rw [div_eq_inv_mul, β Complex.ofReal_inv, Complex.re_ofReal_mul, Complex.sub_re, rpow_def]
theorem integral_zpow {n : β€} (h : 0 β€ n β¨ n β -1 β§ (0 : β) β [[a, b]]) :
β« x in a..b, x ^ n = (b ^ (n + 1) - a ^ (n + 1)) / (n + 1) := by
replace h : -1 < (n : β) β¨ (n : β) β -1 β§ (0 : β) β [[a, b]] := mod_cast h
exact mod_cast integral_rpow h
@[simp]
theorem integral_pow : β« x in a..b, x ^ n = (b ^ (n + 1) - a ^ (n + 1)) / (n + 1) := by
simpa only [β Int.natCast_succ, zpow_natCast] using integral_zpow (Or.inl n.cast_nonneg)
/-- Integral of `|x - a| ^ n` over `Ξ a b`. This integral appears in the proof of the
Picard-LindelΓΆf/Cauchy-Lipschitz theorem. -/
theorem integral_pow_abs_sub_uIoc : β« x in Ξ a b, |x - a| ^ n = |b - a| ^ (n + 1) / (n + 1) := by
rcases le_or_gt a b with hab | hab
Β· calc
β« x in Ξ a b, |x - a| ^ n = β« x in a..b, |x - a| ^ n := by
rw [uIoc_of_le hab, β integral_of_le hab]
_ = β« x in 0..(b - a), x ^ n := by
simp only [integral_comp_sub_right fun x => |x| ^ n, sub_self]
refine integral_congr fun x hx => congr_argβ Pow.pow (abs_of_nonneg <| ?_) rfl
rw [uIcc_of_le (sub_nonneg.2 hab)] at hx
exact hx.1
_ = |b - a| ^ (n + 1) / (n + 1) := by simp [abs_of_nonneg (sub_nonneg.2 hab)]
Β· calc
β« x in Ξ a b, |x - a| ^ n = β« x in b..a, |x - a| ^ n := by
rw [uIoc_of_ge hab.le, β integral_of_le hab.le]
_ = β« x in b - a..0, (-x) ^ n := by
simp only [integral_comp_sub_right fun x => |x| ^ n, sub_self]
refine integral_congr fun x hx => congr_argβ Pow.pow (abs_of_nonpos <| ?_) rfl
rw [uIcc_of_le (sub_nonpos.2 hab.le)] at hx
exact hx.2
_ = |b - a| ^ (n + 1) / (n + 1) := by
simp [integral_comp_neg fun x => x ^ n, abs_of_neg (sub_neg.2 hab)]
@[simp]
theorem integral_id : β« x in a..b, x = (b ^ 2 - a ^ 2) / 2 := by
have := @integral_pow a b 1
norm_num at this
exact this
theorem integral_one : (β« _ in a..b, (1 : β)) = b - a := by
simp only [mul_one, smul_eq_mul, integral_const]
theorem integral_const_on_unit_interval : β« _ in a..a + 1, b = b := by simp
@[simp]
theorem integral_inv (h : (0 : β) β [[a, b]]) : β« x in a..b, xβ»ΒΉ = log (b / a) := by
have h' := fun x (hx : x β [[a, b]]) => ne_of_mem_of_not_mem hx h
rw [integral_deriv_eq_sub' _ deriv_log' (fun x hx => differentiableAt_log (h' x hx))
(continuousOn_invβ.mono <| subset_compl_singleton_iff.mpr h),
log_div (h' b right_mem_uIcc) (h' a left_mem_uIcc)]
@[simp]
theorem integral_inv_of_pos (ha : 0 < a) (hb : 0 < b) : β« x in a..b, xβ»ΒΉ = log (b / a) :=
integral_inv <| notMem_uIcc_of_lt ha hb
@[simp]
theorem integral_inv_of_neg (ha : a < 0) (hb : b < 0) : β« x in a..b, xβ»ΒΉ = log (b / a) :=
integral_inv <| notMem_uIcc_of_gt ha hb
theorem integral_one_div (h : (0 : β) β [[a, b]]) : β« x : β in a..b, 1 / x = log (b / a) := by
simp only [one_div, integral_inv h]
theorem integral_one_div_of_pos (ha : 0 < a) (hb : 0 < b) :
β« x : β in a..b, 1 / x = log (b / a) := by simp only [one_div, integral_inv_of_pos ha hb]
theorem integral_one_div_of_neg (ha : a < 0) (hb : b < 0) :
β« x : β in a..b, 1 / x = log (b / a) := by simp only [one_div, integral_inv_of_neg ha hb]
@[simp]
theorem integral_exp : β« x in a..b, exp x = exp b - exp a := by
rw [integral_deriv_eq_sub']
Β· simp
Β· exact fun _ _ => differentiableAt_exp
Β· exact continuousOn_exp
theorem integral_exp_mul_complex {c : β} (hc : c β 0) :
(β« x in a..b, Complex.exp (c * x)) = (Complex.exp (c * b) - Complex.exp (c * a)) / c := by
have D : β x : β, HasDerivAt (fun y : β => Complex.exp (c * y) / c) (Complex.exp (c * x)) x := by
intro x
conv => congr
rw [β mul_div_cancel_rightβ (Complex.exp (c * x)) hc]
apply ((Complex.hasDerivAt_exp _).comp x _).div_const c
simpa only [mul_one] using ((hasDerivAt_id (x : β)).const_mul _).comp_ofReal
rw [integral_deriv_eq_sub' _ (funext fun x => (D x).deriv) fun x _ => (D x).differentiableAt]
Β· ring
Β· fun_prop
lemma integral_exp_mul_I_eq_sin (r : β) :
β« t in -r..r, Complex.exp (t * Complex.I) = 2 * Real.sin r :=
calc β« t in -r..r, Complex.exp (t * Complex.I)
_ = (Complex.exp (Complex.I * r) - Complex.exp (Complex.I * (-r))) / Complex.I := by
simp_rw [mul_comm _ Complex.I]
rw [integral_exp_mul_complex]
Β· simp
Β· simp
_ = 2 * Real.sin r := by
simp only [mul_comm Complex.I, Complex.exp_mul_I, Complex.cos_neg, Complex.sin_neg,
add_sub_add_left_eq_sub, Complex.div_I, Complex.ofReal_sin]
rw [sub_mul, mul_assoc, mul_assoc, two_mul]
simp
lemma integral_exp_mul_I_eq_sinc (r : β) :
β« t in -r..r, Complex.exp (t * Complex.I) = 2 * r * sinc r := by
rw [integral_exp_mul_I_eq_sin]
by_cases hr : r = 0
Β· simp [hr]
rw [sinc_of_ne_zero hr]
norm_cast
field
/-- Helper lemma for `integral_log`: case where `a = 0` and `b` is positive. -/
lemma integral_log_from_zero_of_pos (ht : 0 < b) : β« s in 0..b, log s = b * log b - b := by
-- Compute the integral by giving a primitive and considering it limit as x approaches 0 from the
-- right. The following lines were suggested by Gareth Ma on Zulip.
rw [integral_eq_sub_of_hasDerivAt_of_tendsto (f := fun x β¦ x * log x - x)
(fa := 0) (fb := b * log b - b) (hint := intervalIntegrable_log')]
Β· abel
Β· exact ht
Β· intro s β¨hs, _ β©
simpa using (hasDerivAt_mul_log hs.ne.symm).sub (hasDerivAt_id s)
Β· simpa [mul_comm] using ((tendsto_log_mul_rpow_nhdsGT_zero zero_lt_one).sub
(tendsto_nhdsWithin_of_tendsto_nhds Filter.tendsto_id))
Β· exact tendsto_nhdsWithin_of_tendsto_nhds (ContinuousAt.tendsto (by fun_prop))
/-- Helper lemma for `integral_log`: case where `a = 0`. -/
lemma integral_log_from_zero {b : β} : β« s in 0..b, log s = b * log b - b := by
rcases lt_trichotomy b 0 with h | h | h
Β· -- If t is negative, use that log is an even function to reduce to the positive case.
conv => arg 1; arg 1; intro t; rw [β log_neg_eq_log]
rw [intervalIntegral.integral_comp_neg, intervalIntegral.integral_symm, neg_zero,
integral_log_from_zero_of_pos (Left.neg_pos_iff.mpr h), log_neg_eq_log]
ring
Β· simp [h]
Β· exact integral_log_from_zero_of_pos h
@[simp]
theorem integral_log : β« s in a..b, log s = b * log b - a * log a - b + a := by
rw [β intervalIntegral.integral_add_adjacent_intervals (b := 0)]
Β· rw [intervalIntegral.integral_symm, integral_log_from_zero, integral_log_from_zero]
ring
all_goals exact intervalIntegrable_log'
@[simp]
theorem integral_sin : β« x in a..b, sin x = cos a - cos b := by
rw [integral_deriv_eq_sub' fun x => -cos x]
Β· ring
Β· simp
Β· simp only [differentiableAt_fun_neg_iff, differentiableAt_cos, implies_true]
Β· exact continuousOn_sin
@[simp]
theorem integral_cos : β« x in a..b, cos x = sin b - sin a := by
rw [integral_deriv_eq_sub']
Β· simp
Β· simp only [differentiableAt_sin, implies_true]
Β· exact continuousOn_cos
theorem integral_cos_mul_complex {z : β} (hz : z β 0) (a b : β) :
(β« x in a..b, Complex.cos (z * x)) = Complex.sin (z * b) / z - Complex.sin (z * a) / z := by
apply integral_eq_sub_of_hasDerivAt
swap
Β· apply Continuous.intervalIntegrable
exact Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)
intro x _
have a := Complex.hasDerivAt_sin (βx * z)
have b : HasDerivAt (fun y => y * z : β β β) z βx := hasDerivAt_mul_const _
have c : HasDerivAt (Complex.sin β fun y : β => (y * z)) _ βx := HasDerivAt.comp (π := β) x a b
have d := HasDerivAt.comp_ofReal (c.div_const z)
simp only [mul_comm] at d
convert d using 1
conv_rhs => arg 1; rw [mul_comm]
rw [mul_div_cancel_rightβ _ hz]
theorem integral_cos_sq_sub_sin_sq :
β« x in a..b, cos x ^ 2 - sin x ^ 2 = sin b * cos b - sin a * cos a := by
simpa only [sq, sub_eq_add_neg, neg_mul_eq_mul_neg] using
integral_deriv_mul_eq_sub (fun x _ => hasDerivAt_sin x) (fun x _ => hasDerivAt_cos x)
continuousOn_cos.intervalIntegrable continuousOn_sin.neg.intervalIntegrable
theorem integral_one_div_one_add_sq :
(β« x : β in a..b, β1 / (β1 + x ^ 2)) = arctan b - arctan a := by
refine integral_deriv_eq_sub' _ Real.deriv_arctan (fun _ _ => differentiableAt_arctan _)
(continuous_const.div ?_ fun x => ?_).continuousOn
Β· fun_prop
Β· nlinarith
@[simp]
theorem integral_inv_one_add_sq : (β« x : β in a..b, (β1 + x ^ 2)β»ΒΉ) = arctan b - arctan a := by
simp only [β one_div, integral_one_div_one_add_sq]
section RpowCpow
open Complex
theorem integral_mul_cpow_one_add_sq {t : β} (ht : t β -1) :
(β« x : β in a..b, (x : β) * ((1 : β) + βx ^ 2) ^ t) =
((1 : β) + (b : β) ^ 2) ^ (t + 1) / (2 * (t + β1)) -
((1 : β) + (a : β) ^ 2) ^ (t + 1) / (2 * (t + β1)) := by
have : t + 1 β 0 := by contrapose! ht; rwa [add_eq_zero_iff_eq_neg] at ht
apply integral_eq_sub_of_hasDerivAt
Β· intro x _
have f : HasDerivAt (fun y : β => 1 + y ^ 2) (2 * x : β) x := by
convert (hasDerivAt_pow 2 (x : β)).const_add 1
simp
have g :
β {z : β}, 0 < z.re β HasDerivAt (fun z => z ^ (t + 1) / (2 * (t + 1))) (z ^ t / 2) z := by
intro z hz
convert (HasDerivAt.cpow_const (c := t + 1) (hasDerivAt_id _)
(Or.inl hz)).div_const (2 * (t + 1)) using 1
simp [field]
convert (HasDerivAt.comp (βx) (g _) f).comp_ofReal using 1
Β· ring
Β· exact mod_cast add_pos_of_pos_of_nonneg zero_lt_one (sq_nonneg x)
Β· apply Continuous.intervalIntegrable
refine continuous_ofReal.mul ?_
apply Continuous.cpow
Β· exact continuous_const.add (continuous_ofReal.pow 2)
Β· exact continuous_const
Β· intro a
norm_cast
exact ofReal_mem_slitPlane.2 <| add_pos_of_pos_of_nonneg one_pos <| sq_nonneg a
theorem integral_mul_rpow_one_add_sq {t : β} (ht : t β -1) :
(β« x : β in a..b, x * (β1 + x ^ 2) ^ t) =
(β1 + b ^ 2) ^ (t + 1) / (β2 * (t + β1)) - (β1 + a ^ 2) ^ (t + 1) / (β2 * (t + β1)) := by
have : β x s : β, (((β1 + x ^ 2) ^ s : β) : β) = (1 + (x : β) ^ 2) ^ (s : β) := by
intro x s
norm_cast
rw [ofReal_cpow, ofReal_add, ofReal_pow, ofReal_one]
exact add_nonneg zero_le_one (sq_nonneg x)
rw [β ofReal_inj]
convert integral_mul_cpow_one_add_sq (_ : (t : β) β -1)
Β· rw [β intervalIntegral.integral_ofReal]
congr with x : 1
rw [ofReal_mul, this x t]
Β· simp_rw [ofReal_sub, ofReal_div, this a (t + 1), this b (t + 1)]
push_cast; rfl
Β· rw [β ofReal_one, β ofReal_neg, Ne, ofReal_inj]
exact ht
end RpowCpow
open Nat
/-! ### Integral of `sin x ^ n` -/
theorem integral_sin_pow_aux :
(β« x in a..b, sin x ^ (n + 2)) =
(sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b + (βn + 1) * β« x in a..b, sin x ^ n) -
(βn + 1) * β« x in a..b, sin x ^ (n + 2) := by
let C := sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b
have h : β Ξ± Ξ² Ξ³ : β, Ξ² * Ξ± * Ξ³ * Ξ± = Ξ² * (Ξ± * Ξ± * Ξ³) := fun Ξ± Ξ² Ξ³ => by ring
have hu : β x β [[a, b]],
HasDerivAt (fun y => sin y ^ (n + 1)) ((n + 1 : β) * cos x * sin x ^ n) x :=
fun x _ => by simpa only [mul_right_comm] using (hasDerivAt_sin x).pow (n + 1)
have hv : β x β [[a, b]], HasDerivAt (-cos) (sin x) x := fun x _ => by
simpa only [neg_neg] using (hasDerivAt_cos x).neg
have H := integral_mul_deriv_eq_deriv_mul hu hv ?_ ?_
Β· calc
(β« x in a..b, sin x ^ (n + 2)) = β« x in a..b, sin x ^ (n + 1) * sin x := by
simp only [_root_.pow_succ]
_ = C + (βn + 1) * β« x in a..b, cos x ^ 2 * sin x ^ n := by simp [H, h, sq]; ring
_ = C + (βn + 1) * β« x in a..b, sin x ^ n - sin x ^ (n + 2) := by
simp [cos_sq', sub_mul, β pow_add, add_comm]
_ = (C + (βn + 1) * β« x in a..b, sin x ^ n) - (βn + 1) * β« x in a..b, sin x ^ (n + 2) := by
rw [integral_sub, mul_sub, add_sub_assoc] <;>
apply Continuous.intervalIntegrable <;> fun_prop
all_goals apply Continuous.intervalIntegrable; fun_prop
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n β₯ 2`. -/
theorem integral_sin_pow :
(β« x in a..b, sin x ^ (n + 2)) =
(sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
(n + 1) / (n + 2) * β« x in a..b, sin x ^ n := by
field_simp
convert eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1
ring
@[simp]
theorem integral_sin_sq : β« x in a..b, sin x ^ 2 = (sin a * cos a - sin b * cos b + b - a) / 2 := by
simp [field, integral_sin_pow, add_sub_assoc]
theorem integral_sin_pow_odd :
(β« x in 0..Ο, sin x ^ (2 * n + 1)) = 2 * β i β range n, (2 * (i : β) + 2) / (2 * i + 3) := by
induction n with
| zero => norm_num
| succ k ih =>
rw [prod_range_succ_comm, mul_left_comm, β ih, mul_succ, integral_sin_pow]
norm_cast
field_simp
simp
theorem integral_sin_pow_even :
(β« x in 0..Ο, sin x ^ (2 * n)) = Ο * β i β range n, (2 * (i : β) + 1) / (2 * i + 2) := by
induction n with
| zero => simp
| succ k ih =>
rw [prod_range_succ_comm, mul_left_comm, β ih, mul_succ, integral_sin_pow]
norm_cast
field_simp
simp
theorem integral_sin_pow_pos : 0 < β« x in 0..Ο, sin x ^ n := by
rcases even_or_odd' n with β¨k, rfl | rflβ© <;>
simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
refine mul_pos (by simp [pi_pos]) (prod_pos fun n _ => div_pos ?_ ?_) <;>
norm_cast <;>
omega
theorem integral_sin_pow_succ_le : (β« x in 0..Ο, sin x ^ (n + 1)) β€ β« x in 0..Ο, sin x ^ n := by
let H x h := pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (n.le_add_right 1)
refine integral_mono_on pi_pos.le ?_ ?_ H <;> exact (continuous_sin.pow _).intervalIntegrable 0 Ο
theorem integral_sin_pow_antitone : Antitone fun n : β => β« x in 0..Ο, sin x ^ n :=
antitone_nat_of_succ_le integral_sin_pow_succ_le
/-! ### Integral of `cos x ^ n` -/
theorem integral_cos_pow_aux :
(β« x in a..b, cos x ^ (n + 2)) =
(cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * β« x in a..b, cos x ^ n) -
(n + 1) * β« x in a..b, cos x ^ (n + 2) := by
let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
have h : β Ξ± Ξ² Ξ³ : β, Ξ² * Ξ± * Ξ³ * Ξ± = Ξ² * (Ξ± * Ξ± * Ξ³) := fun Ξ± Ξ² Ξ³ => by ring
have hu : β x β [[a, b]],
HasDerivAt (fun y => cos y ^ (n + 1)) (-(n + 1 : β) * sin x * cos x ^ n) x :=
fun x _ => by
simpa only [mul_right_comm, neg_mul, mul_neg] using (hasDerivAt_cos x).pow (n + 1)
have hv : β x β [[a, b]], HasDerivAt sin (cos x) x := fun x _ => hasDerivAt_sin x
have H := integral_mul_deriv_eq_deriv_mul hu hv ?_ ?_
Β· calc
(β« x in a..b, cos x ^ (n + 2)) = β« x in a..b, cos x ^ (n + 1) * cos x := by
simp only [_root_.pow_succ]
_ = C + (n + 1) * β« x in a..b, sin x ^ 2 * cos x ^ n := by simp [C, H, h, sq, -neg_add_rev]
_ = C + (n + 1) * β« x in a..b, cos x ^ n - cos x ^ (n + 2) := by
simp [sin_sq, sub_mul, β pow_add, add_comm]
_ = (C + (n + 1) * β« x in a..b, cos x ^ n) - (n + 1) * β« x in a..b, cos x ^ (n + 2) := by
rw [integral_sub, mul_sub, add_sub_assoc] <;>
apply Continuous.intervalIntegrable <;> fun_prop
all_goals apply Continuous.intervalIntegrable; fun_prop
/-- The reduction formula for the integral of `cos x ^ n` for any natural `n β₯ 2`. -/
theorem integral_cos_pow :
(β« x in a..b, cos x ^ (n + 2)) =
(cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a) / (n + 2) +
(n + 1) / (n + 2) * β« x in a..b, cos x ^ n := by
field_simp
convert eq_sub_iff_add_eq.mp (integral_cos_pow_aux n) using 1
ring
@[simp]
theorem integral_cos_sq : β« x in a..b, cos x ^ 2 = (cos b * sin b - cos a * sin a + b - a) / 2 := by
simp [field, integral_cos_pow, add_sub_assoc]
/-! ### Integral of `sin x ^ m * cos x ^ n` -/
/-- Simplification of the integral of `sin x ^ m * cos x ^ n`, case `n` is odd. -/
theorem integral_sin_pow_mul_cos_pow_odd (m n : β) :
(β« x in a..b, sin x ^ m * cos x ^ (2 * n + 1)) = β« u in sin a..sin b, u^m * (β1 - u ^ 2) ^ n :=
have hc : Continuous fun u : β => u ^ m * (β1 - u ^ 2) ^ n := by fun_prop
calc
(β« x in a..b, sin x ^ m * cos x ^ (2 * n + 1)) =
β« x in a..b, sin x ^ m * (β1 - sin x ^ 2) ^ n * cos x := by
simp only [_root_.pow_zero, _root_.pow_succ, mul_assoc, pow_mul, one_mul]
congr! 5
rw [β sq, β sq, cos_sq']
_ = β« u in sin a..sin b, u ^ m * (1 - u ^ 2) ^ n :=
integral_comp_mul_deriv (fun x _ => hasDerivAt_sin x) continuousOn_cos hc
/-- The integral of `sin x * cos x`, given in terms of sinΒ².
See `integral_sin_mul_cosβ` below for the integral given in terms of cosΒ². -/
@[simp]
theorem integral_sin_mul_cosβ : β« x in a..b, sin x * cos x = (sin b ^ 2 - sin a ^ 2) / 2 := by
simpa using integral_sin_pow_mul_cos_pow_odd 1 0
@[simp]
theorem integral_sin_sq_mul_cos :
β« x in a..b, sin x ^ 2 * cos x = (sin b ^ 3 - sin a ^ 3) / 3 := by
have := @integral_sin_pow_mul_cos_pow_odd a b 2 0
norm_num at this; exact this
@[simp]
theorem integral_cos_pow_three :
β« x in a..b, cos x ^ 3 = sin b - sin a - (sin b ^ 3 - sin a ^ 3) / 3 := by
have := @integral_sin_pow_mul_cos_pow_odd a b 0 1
norm_num at this; exact this
/-- Simplification of the integral of `sin x ^ m * cos x ^ n`, case `m` is odd. -/
theorem integral_sin_pow_odd_mul_cos_pow (m n : β) :
(β« x in a..b, sin x ^ (2 * m + 1) * cos x ^ n) = β« u in cos b..cos a, u^n * (β1 - u ^ 2) ^ m :=
have hc : Continuous fun u : β => u ^ n * (β1 - u ^ 2) ^ m := by fun_prop
calc
(β« x in a..b, sin x ^ (2 * m + 1) * cos x ^ n) =
-β« x in b..a, sin x ^ (2 * m + 1) * cos x ^ n := by rw [integral_symm]
_ = β« x in b..a, (β1 - cos x ^ 2) ^ m * -sin x * cos x ^ n := by
simp only [_root_.pow_succ, pow_mul, _root_.pow_zero, one_mul, mul_neg, neg_mul,
integral_neg, neg_inj]
congr! 5
rw [β sq, β sq, sin_sq]
_ = β« x in b..a, cos x ^ n * (β1 - cos x ^ 2) ^ m * -sin x := by congr; ext; ring
_ = β« u in cos b..cos a, u ^ n * (β1 - u ^ 2) ^ m :=
integral_comp_mul_deriv (fun x _ => hasDerivAt_cos x) continuousOn_sin.neg hc
/-- The integral of `sin x * cos x`, given in terms of cosΒ².
See `integral_sin_mul_cosβ` above for the integral given in terms of sinΒ². -/
theorem integral_sin_mul_cosβ : β« x in a..b, sin x * cos x = (cos a ^ 2 - cos b ^ 2) / 2 := by
simpa using integral_sin_pow_odd_mul_cos_pow 0 1
@[simp]
theorem integral_sin_mul_cos_sq :
β« x in a..b, sin x * cos x ^ 2 = (cos a ^ 3 - cos b ^ 3) / 3 := by
have := @integral_sin_pow_odd_mul_cos_pow a b 0 2
norm_num at this; exact this
@[simp]
theorem integral_sin_pow_three :
β« x in a..b, sin x ^ 3 = cos a - cos b - (cos a ^ 3 - cos b ^ 3) / 3 := by
have := @integral_sin_pow_odd_mul_cos_pow a b 1 0
norm_num at this; exact this
/-- Simplification of the integral of `sin x ^ m * cos x ^ n`, case `m` and `n` are both even. -/
theorem integral_sin_pow_even_mul_cos_pow_even (m n : β) :
(β« x in a..b, sin x ^ (2 * m) * cos x ^ (2 * n)) =
β« x in a..b, ((1 - cos (2 * x)) / 2) ^ m * ((1 + cos (2 * x)) / 2) ^ n := by
simp [pow_mul, sin_sq, cos_sq, β sub_sub]
field_simp
norm_num
@[simp]
theorem integral_sin_sq_mul_cos_sq :
β« x in a..b, sin x ^ 2 * cos x ^ 2 = (b - a) / 8 - (sin (4 * b) - sin (4 * a)) / 32 := by
convert integral_sin_pow_even_mul_cos_pow_even 1 1 using 1
have h1 : β c : β, (β1 - c) / β2 * ((β1 + c) / β2) = (β1 - c ^ 2) / 4 := fun c => by ring
have h2 : Continuous fun x => cos (2 * x) ^ 2 := by fun_prop
have h3 : β x, cos x * sin x = sin (2 * x) / 2 := by intro; rw [sin_two_mul]; ring
have h4 : β d : β, 2 * (2 * d) = 4 * d := fun d => by ring
simp [h1, h2.intervalIntegrable, integral_comp_mul_left fun x => cos x ^ 2, h3, h4]
ring
/-! ### Integral of miscellaneous functions -/
theorem integral_sqrt_one_sub_sq : β« x in (-1 : β)..1, β(1 - x ^ 2 : β) = Ο / 2 :=
calc
_ = β« x in sin (-(Ο / 2)).. sin (Ο / 2), β(1 - x ^ 2 : β) := by rw [sin_neg, sin_pi_div_two]
_ = β« x in (-(Ο / 2))..(Ο / 2), β(1 - sin x ^ 2 : β) * cos x :=
(integral_comp_mul_deriv (fun x _ => hasDerivAt_sin x) continuousOn_cos
(by fun_prop)).symm
_ = β« x in (-(Ο / 2))..(Ο / 2), cos x ^ 2 := by
refine integral_congr_ae (MeasureTheory.ae_of_all _ fun _ h => ?_)
rw [uIoc_of_le (neg_le_self (le_of_lt (half_pos Real.pi_pos))), Set.mem_Ioc] at h
rw [β Real.cos_eq_sqrt_one_sub_sin_sq (le_of_lt h.1) h.2, pow_two]
_ = Ο / 2 := by simp |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Integrals/LogTrigonometric.lean | import Mathlib.Analysis.SpecialFunctions.Integrability.LogMeromorphic
/-!
# Integral of `log β sin`
This file computes special values of the integral of `log β sin`. Given that the indefinite integral
involves the dilogarithm, this can be seen as computing special values of `Liβ`.
-/
open Filter Interval Real
/-
Helper lemma for `integral_log_sin_zero_pi_div_two`: The integral of `log β sin` on `0 β¦ Ο` is
double the integral on `0 β¦ Ο/2`.
-/
private lemma integral_log_sin_zero_pi_eq_two_mul_integral_log_sin_zero_pi_div_two :
β« x in 0..Ο, log (sin x) = 2 * β« x in 0..(Ο / 2), log (sin x) := by
rw [β intervalIntegral.integral_add_adjacent_intervals (a := 0) (b := Ο / 2) (c := Ο)
(by apply intervalIntegrable_log_sin) (by apply intervalIntegrable_log_sin)]
conv =>
left; right; arg 1
intro x
rw [β sin_pi_sub]
rw [intervalIntegral.integral_comp_sub_left (fun x β¦ log (sin x)), sub_self,
(by linarith : Ο - Ο / 2 = Ο / 2)]
ring!
/--
The integral of `log β sin` on `0 β¦ Ο/2` equals `-log 2 * Ο / 2`.
-/
theorem integral_log_sin_zero_pi_div_two : β« x in 0..(Ο / 2), log (sin x) = -log 2 * Ο / 2 := by
calc β« x in 0..(Ο / 2), log (sin x)
_ = β« x in 0..(Ο / 2), (log (sin (2 * x)) - log 2 - log (cos x)) := by
apply intervalIntegral.integral_congr_codiscreteWithin
apply Filter.codiscreteWithin.mono (by tauto : Ξ 0 (Ο / 2) β Set.univ)
have tβ : sin β»ΒΉ' {0}αΆ β Filter.codiscrete β := by
apply analyticOnNhd_sin.preimage_zero_mem_codiscrete (x := Ο / 2)
simp
have tβ : cos β»ΒΉ' {0}αΆ β Filter.codiscrete β := by
apply analyticOnNhd_cos.preimage_zero_mem_codiscrete (x := 0)
simp
filter_upwards [tβ, tβ] with y hβy hβy
simp_all only [Set.preimage_compl, Set.mem_compl_iff, Set.mem_preimage, Set.mem_singleton_iff,
sin_two_mul, ne_eq, mul_eq_zero, OfNat.ofNat_ne_zero, or_self, not_false_eq_true, log_mul]
ring
_ = (β« x in 0..(Ο / 2), log (sin (2 * x))) - Ο / 2 * log 2
- β« x in 0..(Ο / 2), log (cos x) := by
rw [intervalIntegral.integral_sub _ _,
intervalIntegral.integral_sub _ intervalIntegrable_const,
intervalIntegral.integral_const]
Β· simp
Β· simpa using (intervalIntegrable_log_sin (a := 0) (b := Ο)).comp_mul_left
Β· apply IntervalIntegrable.sub _ intervalIntegrable_const
simpa using (intervalIntegrable_log_sin (a := 0) (b := Ο)).comp_mul_left
Β· exact intervalIntegrable_log_cos
_ = (β« x in 0..(Ο / 2), log (sin (2 * x)))
- Ο / 2 * log 2 - β« x in 0..(Ο / 2), log (sin x) := by
simp [β sin_pi_div_two_sub,
intervalIntegral.integral_comp_sub_left (fun x β¦ log (sin x)) (Ο / 2)]
_ = -log 2 * Ο / 2 := by
simp only [intervalIntegral.integral_comp_mul_left (f := fun x β¦ log (sin x)) two_ne_zero,
mul_zero, (by linarith : 2 * (Ο / 2) = Ο),
integral_log_sin_zero_pi_eq_two_mul_integral_log_sin_zero_pi_div_two, smul_eq_mul, ne_eq,
OfNat.ofNat_ne_zero, not_false_eq_true, inv_mul_cancel_leftβ, sub_sub_cancel_left, neg_mul]
linarith
/--
The integral of `log β sin` on `0 β¦ Ο` equals `-log 2 * Ο`.
-/
theorem integral_log_sin_zero_pi : β« x in 0..Ο, log (sin x) = -log 2 * Ο := by
rw [integral_log_sin_zero_pi_eq_two_mul_integral_log_sin_zero_pi_div_two,
integral_log_sin_zero_pi_div_two]
ring |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/ExpLog.lean | import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.ExpLog.Basic
deprecated_module (since := "2025-11-15") |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Abs.lean | import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.Rpow.Basic
import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.PosPart.Basic
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Commute
/-!
# Absolute value defined via the continuous functional calculus
This file defines the absolute value via the non-unital continuous functional calculus
and provides basic API.
## Main declarations
+ `CFC.abs`: The absolute value as `abs a := CFC.sqrt (star a * a)`.
-/
variable {π A : Type*}
open scoped NNReal
open CFC
namespace CFC
section NonUnital
section Real
variable [NonUnitalRing A] [StarRing A] [TopologicalSpace A]
[Module β A] [SMulCommClass β A A] [IsScalarTower β A A]
[NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
[PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A]
/-- The absolute value defined via the non-unital continuous functional calculus. -/
noncomputable def abs (a : A) := sqrt (star a * a)
@[simp, grind =]
lemma abs_neg (a : A) : abs (-a) = abs a := by
simp [abs]
@[simp, grind β]
lemma abs_nonneg (a : A) : 0 β€ abs a := sqrt_nonneg _
lemma abs_star (a : A) (ha : IsStarNormal a := by cfc_tac) : abs (star a) = abs a := by
simp [abs, star_comm_self']
@[simp, grind =]
lemma abs_zero : abs (0 : A) = 0 := by
simp [abs]
variable [IsTopologicalRing A] [T2Space A]
lemma abs_mul_abs (a : A) : abs a * abs a = star a * a :=
sqrt_mul_sqrt_self _ <| star_mul_self_nonneg _
/- The hypotheses could be weakened to `Commute (star a * a) b`, but
in that case one should simply use `Commute.cfcβ_nnreal` directly.
The point of this theorem is to have simpler hypotheses. -/
lemma _root_.Commute.cfcAbs_left {a b : A} (hβ : Commute a b) (hβ : Commute a (star b)) :
Commute (abs a) b :=
.cfcβ_nnreal (by simp_all [hβ.star_left]) _
/- The hypotheses could be weakened to `Commute (star a * a) b`, but
in that case one should simply use `Commute.cfcβ_nnreal` directly.
The point of this theorem is to have simpler hypotheses. -/
lemma _root_.Commute.cfcAbs_right {a b : A} (hβ : Commute a b) (hβ : Commute a (star b)) :
Commute b (abs a) :=
hβ.cfcAbs_left hβ |>.symm
/- The hypotheses could be weakened to `Commute (star a * a) (star b * b)`, but
in that case one should simply use `Commute.cfcβ_nnreal` (twice) directly.
The point of this theorem is to have simpler hypotheses. -/
lemma _root_.Commute.cfcAbs_cfcAbs {a b : A} (hβ : Commute a b) (hβ : Commute a (star b)) :
Commute (abs a) (abs b) :=
Commute.cfcβ_nnreal (by simp_all [hβ.star_left]) _ |>.symm.cfcβ_nnreal _ |>.symm
/-- Normal elements commute with their absolute value. -/
lemma commute_abs_self (a : A) (ha : IsStarNormal a := by cfc_tac) :
Commute (abs a) a :=
.cfcAbs_left (.refl a) ha.star_comm_self.symm
lemma _root_.Commute.cfcAbs_mul_eq {a b : A} (hβ : Commute a b) (hβ : Commute a (star b)) :
abs (a * b) = abs a * abs b := by
have hab := hβ.cfcAbs_cfcAbs hβ
rw [abs, CFC.sqrt_eq_iff _ _ (star_mul_self_nonneg _)
(hab.mul_nonneg (abs_nonneg a) (abs_nonneg b)), hab.eq, hab.mul_mul_mul_comm,
abs_mul_abs, abs_mul_abs, star_mul, hβ.star_left.symm.mul_mul_mul_comm, hβ.eq]
lemma abs_mul_self (a : A) (ha : IsStarNormal a := by cfc_tac) :
abs (a * a) = star a * a := by
rw [Commute.cfcAbs_mul_eq (.refl a) ha.star_comm_self.symm, abs_mul_abs]
lemma abs_nnrpow_two (a : A) : abs a ^ (2 : ββ₯0) = star a * a := by
simp only [abs_nonneg, nnrpow_two]
apply abs_mul_abs
lemma abs_nnrpow_two_mul (a : A) (x : ββ₯0) :
abs a ^ (2 * x) = (star a * a) ^ x := by rw [β nnrpow_nnrpow, abs_nnrpow_two]
lemma abs_nnrpow (a : A) (x : ββ₯0) :
abs a ^ x = (star a * a) ^ (x / 2) := by
simp only [β abs_nnrpow_two_mul, mul_div_left_comm, ne_eq, OfNat.ofNat_ne_zero,
not_false_eq_true, div_self, mul_one]
@[grind =]
lemma abs_of_nonneg (a : A) (ha : 0 β€ a := by cfc_tac) : abs a = a := by
rw [abs, ha.star_eq, sqrt_mul_self a ha]
lemma abs_of_nonpos (a : A) (ha : a β€ 0 := by cfc_tac) : abs a = -a := by
simpa using abs_of_nonneg (-a)
lemma abs_eq_cfcβ_norm (a : A) (ha : IsSelfAdjoint a := by cfc_tac) :
abs a = cfcβ (βΒ·β) a := by
conv_lhs =>
rw [abs, ha.star_eq, sqrt_eq_real_sqrt .., β cfcβ_id' β a, β cfcβ_mul .., β cfcβ_comp' ..]
simp [β sq, Real.sqrt_sq_eq_abs]
protected lemma posPart_add_negPart (a : A) (ha : IsSelfAdjoint a := by cfc_tac) :
aβΊ + aβ» = abs a := by
rw [CFC.posPart_def, CFC.negPart_def, β cfcβ_add .., abs_eq_cfcβ_norm a ha]
exact cfcβ_congr fun x hx β¦ posPart_add_negPart x
lemma abs_sub_self (a : A) (ha : IsSelfAdjoint a := by cfc_tac) : abs a - a = 2 β’ aβ» := by
simpa [two_smul] using
congr($(CFC.posPart_add_negPart a) - $(CFC.posPart_sub_negPart a)).symm
lemma abs_add_self (a : A) (ha : IsSelfAdjoint a := by cfc_tac) : abs a + a = 2 β’ aβΊ := by
simpa [two_smul] using
congr($(CFC.posPart_add_negPart a) + $(CFC.posPart_sub_negPart a)).symm
@[simp, grind =]
lemma cfcAbs_cfcAbs (a : A) : abs (abs a) = abs a := abs_of_nonneg ..
variable [StarModule β A]
@[simp, grind =]
lemma abs_smul_nonneg {R : Type*} [Semiring R] [SMulWithZero R ββ₯0] [SMul R A]
[IsScalarTower R ββ₯0 A] (r : R) (a : A) :
abs (r β’ a) = r β’ abs a := by
suffices β r : ββ₯0, abs (r β’ a) = r β’ abs a by simpa using this (r β’ 1)
intro r
rw [abs, sqrt_eq_iff _ _ (star_mul_self_nonneg _) (smul_nonneg (by positivity) (abs_nonneg _))]
simp [mul_smul_comm, smul_mul_assoc, abs_mul_abs]
end Real
section RCLike
variable {p : A β Prop} [RCLike π]
[NonUnitalRing A] [TopologicalSpace A] [Module π A]
[StarRing A] [PartialOrder A] [StarOrderedRing A]
[IsScalarTower π A A] [SMulCommClass π A A]
[NonUnitalContinuousFunctionalCalculus π A p]
open ComplexOrder
lemma _root_.cfcβ_norm_sq_nonneg (f : π β π) (a : A) : 0 β€ cfcβ (fun z β¦ star (f z) * (f z)) a :=
cfcβ_nonneg fun _ _ β¦ star_mul_self_nonneg _
lemma _root_.cfcβ_norm_nonneg (f : π β π) (a : A) : 0 β€ cfcβ (βf Β·β : π β π) a :=
cfcβ_nonneg fun _ _ β¦ by simp
variable [Module β A] [SMulCommClass β A A] [IsScalarTower β A A]
[NonnegSpectrumClass β A] [IsTopologicalRing A] [T2Space A]
[NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
variable [StarModule π A] [StarModule β A] [IsScalarTower β π A] in
@[simp]
lemma abs_smul (r : π) (a : A) : abs (r β’ a) = βrβ β’ abs a := by
trans abs (βrβ β’ a)
Β· simp only [abs, mul_smul_comm, smul_mul_assoc, star_smul, β smul_assoc,
RCLike.real_smul_eq_coe_smul (K := π)]
simp [-algebraMap_smul, β smul_mul_assoc, β mul_comm (starRingEnd _ _), RCLike.conj_mul, sq]
Β· lift βrβ to ββ₯0 using norm_nonneg _ with r
simp [β NNReal.smul_def]
variable (π) in
lemma abs_eq_cfcβ_coe_norm (a : A) (ha : p a := by cfc_tac) :
abs a = cfcβ (fun z : π β¦ (βzβ : π)) a := by
rw [abs, sqrt_eq_iff _ _ (hb := cfcβ_norm_nonneg _ _), β cfcβ_mul ..]
conv_rhs => rw [β cfcβ_id' π a, β cfcβ_star, β cfcβ_mul ..]
simp [RCLike.conj_mul, sq]
lemma _root_.cfcβ_comp_norm (f : π β π) (a : A) (ha : p a := by cfc_tac)
(hf : ContinuousOn f ((fun z β¦ (βzβ : π)) '' quasispectrum π a) := by cfc_cont_tac) :
cfcβ (f βΒ·β) a = cfcβ f (abs a) := by
obtain (hf0 | hf0) := em (f 0 = 0)
Β· rw [cfcβ_comp' f (βΒ·β) a, β abs_eq_cfcβ_coe_norm _ a]
Β· rw [cfcβ_apply_of_not_map_zero _ hf0,
cfcβ_apply_of_not_map_zero _ (fun h β¦ (hf0 <| by simpa using h).elim)]
lemma quasispectrum_abs (a : A) (ha : p a := by cfc_tac) :
quasispectrum π (abs a) = (fun z β¦ (βzβ : π)) '' quasispectrum π a := by
rw [abs_eq_cfcβ_coe_norm π a ha, cfcβ_map_quasispectrum ..]
end RCLike
end NonUnital
section Unital
section Real
variable [Ring A] [StarRing A] [TopologicalSpace A] [Algebra β A]
[ContinuousFunctionalCalculus β A IsSelfAdjoint]
[PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A]
[IsTopologicalRing A] [T2Space A]
lemma abs_eq_cfc_norm (a : A) (ha : IsSelfAdjoint a := by cfc_tac) :
abs a = cfc (βΒ·β) a := by
rw [abs_eq_cfcβ_norm _, cfcβ_eq_cfc]
@[simp]
lemma abs_one : abs (1 : A) = 1 := by
simp [abs]
variable [StarModule β A]
@[simp]
lemma abs_algebraMap_nnreal (x : ββ₯0) : abs (algebraMap ββ₯0 A x) = algebraMap ββ₯0 A x := by
simp [Algebra.algebraMap_eq_smul_one]
@[simp]
lemma abs_natCast (n : β) : abs (n : A) = n := by
simpa only [map_natCast, Nat.abs_cast] using abs_algebraMap_nnreal (n : ββ₯0)
@[simp]
lemma abs_ofNat (n : β) [n.AtLeastTwo] : abs (ofNat(n) : A) = ofNat(n) := by
simpa using abs_natCast n
@[simp]
lemma abs_intCast (n : β€) : abs (n : A) = |n| := by
cases n with
| ofNat _ => simp
| negSucc n =>
rw [Int.cast_negSucc, abs_neg, abs_natCast, β Int.cast_natCast]
congr
end Real
section RCLike
variable {p : A β Prop} [RCLike π]
[Ring A] [TopologicalSpace A] [StarRing A] [PartialOrder A]
[StarOrderedRing A] [Algebra π A]
[ContinuousFunctionalCalculus π A p]
[Algebra β A] [NonnegSpectrumClass β A] [IsTopologicalRing A] [T2Space A]
[ContinuousFunctionalCalculus β A IsSelfAdjoint]
variable [StarModule π A] [StarModule β A] [IsScalarTower β π A] in
@[simp]
lemma abs_algebraMap (c : π) : abs (algebraMap π A c) = algebraMap β A βcβ := by
simp [Algebra.algebraMap_eq_smul_one]
lemma _root_.cfc_comp_norm (f : π β π) (a : A) (ha : p a := by cfc_tac)
(hf : ContinuousOn f ((fun z β¦ (βzβ : π)) '' spectrum π a) := by cfc_cont_tac) :
cfc (f βΒ·β) a = cfc f (abs a) := by
rw [abs_eq_cfcβ_coe_norm π a, cfcβ_eq_cfc, β cfc_comp' ..]
lemma abs_sq (a : A) : (abs a) ^ 2 = star a * a := by
rw [sq, abs_mul_abs]
lemma spectrum_abs (a : A) (ha : p a := by cfc_tac) :
spectrum π (abs a) = (fun z β¦ (βzβ : π)) '' spectrum π a := by
rw [abs_eq_cfcβ_coe_norm π a, cfcβ_eq_cfc, cfc_map_spectrum ..]
end RCLike
end Unital
section CStar
/- This section requires `A` to be a `CStarRing` -/
variable [NonUnitalNormedRing A] [StarRing A] [CStarRing A]
[NormedSpace β A] [SMulCommClass β A A] [IsScalarTower β A A]
[NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
[PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A]
open CFC
@[simp, grind =]
lemma abs_eq_zero_iff {a : A} : abs a = 0 β a = 0 := by
rw [CFC.abs, sqrt_eq_zero_iff _, CStarRing.star_mul_self_eq_zero_iff]
@[simp, grind =]
lemma norm_abs {a : A} : βabs aβ = βaβ := by
rw [β sq_eq_sqβ (norm_nonneg _) (norm_nonneg _), sq, sq, β CStarRing.norm_star_mul_self,
(abs_nonneg _).star_eq, CFC.abs_mul_abs, CStarRing.norm_star_mul_self]
end CStar
end CFC |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/ExpLog/Basic.lean | import Mathlib.Analysis.SpecialFunctions.Exponential
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unique
import Mathlib.Topology.ContinuousMap.ContinuousSqrt
import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# The exponential and logarithm based on the continuous functional calculus
This file defines the logarithm via the continuous functional calculus (CFC) and builds its API.
This allows one to take logs of matrices, operators, elements of a Cβ-algebra, etc.
It also shows that exponentials defined via the continuous functional calculus are equal to
`NormedSpace.exp` (defined via power series) whenever the former are not junk values.
## Main declarations
+ `CFC.log`: the real log function based on the CFC, i.e. `cfc Real.log`
+ `CFC.exp_eq_normedSpace_exp`: exponentials based on the CFC are equal to exponentials based
on power series.
+ `CFC.log_exp` and `CFC.exp_log`: `CFC.log` and `NormedSpace.exp β` are inverses of each other.
## Implementation notes
Since `cfc Real.exp` and `cfc Complex.exp` are strictly less general than `NormedSpace.exp`
(defined via power series), we only give minimal API for these here in order to relate
`NormedSpace.exp` to functions defined via the CFC. In particular, we don't give separate
definitions for them.
## TODO
+ Show that `log (a * b) = log a + log b` whenever `a` and `b` commute (and the same for indexed
products).
+ Relate `CFC.log` to `rpow`, `zpow`, `sqrt`, `inv`.
-/
open NormedSpace
section general_exponential
variable {π : Type*} {Ξ± : Type*} [RCLike π] [TopologicalSpace Ξ±] [CompactSpace Ξ±]
lemma NormedSpace.exp_continuousMap_eq (f : C(Ξ±, π)) :
exp π f = (β¨exp π β f, exp_continuous.comp f.continuousβ© : C(Ξ±, π)) := by
ext a
simp only [NormedSpace.exp, FormalMultilinearSeries.sum]
have h_sum := NormedSpace.expSeries_summable (π := π) f
simp_rw [β ContinuousMap.tsum_apply h_sum a, NormedSpace.expSeries_apply_eq]
simp [NormedSpace.exp_eq_tsum]
end general_exponential
namespace CFC
section RCLikeNormed
variable {π : Type*} {A : Type*} [RCLike π] {p : A β Prop} [NormedRing A]
[StarRing A] [IsTopologicalRing A] [NormedAlgebra π A] [ContinuousFunctionalCalculus π A p]
open scoped ContinuousFunctionalCalculus in
lemma exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
cfc (exp π : π β π) a = exp π a := by
conv_rhs => rw [β cfc_id π a ha, cfc_apply id a ha]
have h := (cfcHom_isClosedEmbedding (R := π) (show p a from ha)).continuous
have _ : ContinuousOn (exp π) (spectrum π a) := exp_continuous.continuousOn
simp_rw [β map_exp π _ h, cfc_apply (exp π) a ha]
congr 1
ext
simp [exp_continuousMap_eq]
end RCLikeNormed
section RealNormed
variable {A : Type*} [NormedRing A] [StarRing A]
[IsTopologicalRing A] [NormedAlgebra β A]
[ContinuousFunctionalCalculus β A IsSelfAdjoint]
lemma real_exp_eq_normedSpace_exp {a : A} (ha : IsSelfAdjoint a := by cfc_tac) :
cfc Real.exp a = exp β a :=
Real.exp_eq_exp_β βΈ exp_eq_normedSpace_exp ha
@[aesop safe apply (rule_sets := [CStarAlgebra])]
lemma _root_.IsSelfAdjoint.exp_nonneg {π : Type*} [Field π] [Algebra π A]
[PartialOrder A] [StarOrderedRing A] {a : A} (ha : IsSelfAdjoint a) :
0 β€ exp π a := by
rw [exp_eq_exp π β, β real_exp_eq_normedSpace_exp]
exact cfc_nonneg fun x _ => Real.exp_nonneg x
end RealNormed
section ComplexNormed
variable {A : Type*} {p : A β Prop} [NormedRing A] [StarRing A]
[NormedAlgebra β A] [ContinuousFunctionalCalculus β A p]
lemma complex_exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
cfc Complex.exp a = exp β a :=
Complex.exp_eq_exp_β βΈ exp_eq_normedSpace_exp ha
end ComplexNormed
section real_log
open scoped ComplexOrder
variable {A : Type*} [NormedRing A] [StarRing A] [NormedAlgebra β A]
[ContinuousFunctionalCalculus β A IsSelfAdjoint]
/-- The real logarithm, defined via the continuous functional calculus. This can be used on
matrices, operators on a Hilbert space, elements of a Cβ-algebra, etc. -/
noncomputable def log (a : A) : A := cfc Real.log a
@[simp, grind =>]
protected lemma _root_.IsSelfAdjoint.log {a : A} : IsSelfAdjoint (log a) := cfc_predicate _ a
@[simp, grind =] lemma log_zero : log (0 : A) = 0 := by simp [log]
@[simp, grind =] lemma log_one : log (1 : A) = 0 := by simp [log]
@[simp, grind =]
lemma log_algebraMap {r : β} : log (algebraMap β A r) = algebraMap β A (Real.log r) := by
simp [log]
lemma log_smul {r : β} (a : A) (haβ : β x β spectrum β a, x β 0) (hr : r β 0)
(haβ : IsSelfAdjoint a := by cfc_tac) :
log (r β’ a) = algebraMap β A (Real.log r) + log a := by
rw [log, β cfc_smul_id (R := β) r a, β cfc_comp Real.log (r β’ Β·) a, log]
calc
_ = cfc (fun z => Real.log r + Real.log z) a :=
cfc_congr (Real.log_mul hr <| haβ Β· Β·)
_ = _ := by rw [cfc_const_add _ _ _]
@[grind =]
lemma log_smul' [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A] {r : β} (a : A)
(hr : 0 < r) (ha : IsStrictlyPositive a := by cfc_tac) :
log (r β’ a) = algebraMap β A (Real.log r) + log a := by
grind [log_smul]
lemma log_pow (n : β) (a : A) (haβ : β x β spectrum β a, x β 0)
(haβ : IsSelfAdjoint a := by cfc_tac) : log (a ^ n) = n β’ log a := by
have haβ' : ContinuousOn Real.log (spectrum β a) := by fun_prop (disch := assumption)
have haβ'' : ContinuousOn Real.log ((Β· ^ n) '' spectrum β a) := by fun_prop (disch := aesop)
rw [log, β cfc_pow_id (R := β) a n haβ, β cfc_comp' Real.log (Β· ^ n) a haβ'', log]
simp_rw [Real.log_pow, β Nat.cast_smul_eq_nsmul β n, cfc_const_mul (n : β) Real.log a haβ']
@[grind =]
lemma log_pow' [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A] (n : β) (a : A)
(ha : IsStrictlyPositive a := by cfc_tac) :
log (a ^ n) = n β’ log a := by
grind [log_pow]
open NormedSpace in
@[grind =]
lemma log_exp (a : A) (ha : IsSelfAdjoint a := by cfc_tac) : log (exp β a) = a := by
have hcont : ContinuousOn Real.log (Real.exp '' spectrum β a) := by fun_prop (disch := simp)
rw [log, β real_exp_eq_normedSpace_exp, β cfc_comp' Real.log Real.exp a hcont]
simp [cfc_id' (R := β) a]
open NormedSpace in
@[grind =]
lemma exp_log [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A] (a : A)
(ha : IsStrictlyPositive a := by cfc_tac) : exp β (log a) = a := by
have haβ : β x β spectrum β a, x β 0 := by grind
rw [β real_exp_eq_normedSpace_exp .log, log, β cfc_comp' Real.exp Real.log a (by fun_prop)]
conv_rhs => rw [β cfc_id (R := β) a]
refine cfc_congr fun x hx => ?_
grind [Real.exp_log]
end real_log
end CFC |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/PosPart/Isometric.lean | import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.PosPart.Basic
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric
/-! # Facts about `CFC.posPart` and `CFC.negPart` involving norms
This file collects various facts about the positive and negative parts of elements of a
Cβ-algebra that involve the norm.
## Main results
* `CFC.norm_eq_max_norm_posPart_negPart`: states that `βaβ = max βaβΊβ βaβ»β`
* `CFC.norm_posPart_le` and `CFC.norm_negPart_le`: state that `βaβΊβ β€ βaβ` and `βaβ»β β€ βaβ`
respectively.
-/
variable {A : Type*} [NonUnitalNormedRing A] [NormedSpace β A] [SMulCommClass β A A]
[IsScalarTower β A A] [StarRing A]
[NonUnitalIsometricContinuousFunctionalCalculus β A IsSelfAdjoint]
@[simp]
lemma CStarAlgebra.norm_posPart_le (a : A) : βaβΊβ β€ βaβ := by
by_cases ha : IsSelfAdjoint a
case neg => simp [CFC.posPart_def, cfcβ_apply_of_not_predicate a ha]
refine norm_cfcβ_le fun x hx β¦ ?_
obtain (h | h) := le_or_gt x 0
Β· simp [posPart_def, max_eq_right h]
Β· simp only [posPart_def, max_eq_left h.le]
exact NonUnitalIsometricContinuousFunctionalCalculus.norm_quasispectrum_le a hx ha
@[simp]
lemma CStarAlgebra.norm_negPart_le (a : A) : βaβ»β β€ βaβ := by
simpa [CFC.negPart_neg] using norm_posPart_le (-a)
open CStarAlgebra in
lemma IsSelfAdjoint.norm_eq_max_norm_posPart_negPart (a : A) (ha : IsSelfAdjoint a := by cfc_tac) :
βaβ = max βaβΊβ βaβ»β := by
refine le_antisymm ?_ <| max_le (norm_posPart_le a) (norm_negPart_le a)
conv_lhs => rw [β cfcβ_id' β a]
rw [norm_cfcβ_le_iff ..]
intro x hx
obtain (hx' | hx') := le_total 0 x
Β· apply le_max_of_le_left
refine le_of_eq_of_le ?_ <| norm_apply_le_norm_cfcβ _ a hx
rw [posPart_eq_self.mpr hx']
Β· apply le_max_of_le_right
refine le_of_eq_of_le ?_ <| norm_apply_le_norm_cfcβ _ a hx
rw [negPart_eq_neg.mpr hx', norm_neg] |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/PosPart/Basic.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unique
import Mathlib.Topology.ContinuousMap.ContinuousSqrt
import Mathlib.Topology.ContinuousMap.StoneWeierstrass
/-! # The positive (and negative) parts of a selfadjoint element in a Cβ-algebra
This file defines the positive and negative parts of a selfadjoint element in a Cβ-algebra via
the continuous functional calculus and develops the basic API, including the uniqueness of the
positive and negative parts.
-/
open scoped NNReal
section NonUnital
variable {A : Type*} [NonUnitalRing A] [Module β A] [SMulCommClass β A A] [IsScalarTower β A A]
variable [StarRing A] [TopologicalSpace A]
variable [NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
namespace CStarAlgebra
noncomputable instance : PosPart A where
posPart := cfcβ (Β·βΊ : β β β)
noncomputable instance : NegPart A where
negPart := cfcβ (Β·β» : β β β)
end CStarAlgebra
namespace CFC
lemma posPart_def (a : A) : aβΊ = cfcβ (Β·βΊ : β β β) a := rfl
lemma negPart_def (a : A) : aβ» = cfcβ (Β·β» : β β β) a := rfl
@[simp]
lemma posPart_zero : (0 : A)βΊ = 0 := by simp [posPart_def]
@[simp]
lemma negPart_zero : (0 : A)β» = 0 := by simp [negPart_def]
lemma posPart_eq_zero_of_not_isSelfAdjoint {a : A} (ha : Β¬IsSelfAdjoint a) : aβΊ = 0 :=
cfcβ_apply_of_not_predicate a ha
lemma negPart_eq_zero_of_not_isSelfAdjoint {a : A} (ha : Β¬IsSelfAdjoint a) : aβ» = 0 :=
cfcβ_apply_of_not_predicate a ha
@[simp]
lemma posPart_mul_negPart (a : A) : aβΊ * aβ» = 0 := by
rw [posPart_def, negPart_def]
by_cases ha : IsSelfAdjoint a
Β· rw [β cfcβ_mul _ _, β cfcβ_zero β a]
refine cfcβ_congr (fun x _ β¦ ?_)
simp only [_root_.posPart_def, _root_.negPart_def]
simpa using le_total x 0
Β· simp [cfcβ_apply_of_not_predicate a ha]
@[simp]
lemma negPart_mul_posPart (a : A) : aβ» * aβΊ = 0 := by
rw [posPart_def, negPart_def]
by_cases ha : IsSelfAdjoint a
Β· rw [β cfcβ_mul _ _, β cfcβ_zero β a]
refine cfcβ_congr (fun x _ β¦ ?_)
simp only [_root_.posPart_def, _root_.negPart_def]
simpa using le_total 0 x
Β· simp [cfcβ_apply_of_not_predicate a ha]
lemma posPart_sub_negPart (a : A) (ha : IsSelfAdjoint a := by cfc_tac) : aβΊ - aβ» = a := by
rw [posPart_def, negPart_def]
rw [β cfcβ_sub _ _]
conv_rhs => rw [β cfcβ_id β a]
congr! 2 with
exact _root_.posPart_sub_negPart _
section Unique
variable [T2Space A]
@[simp]
lemma posPart_neg (a : A) : (-a)βΊ = aβ» := by
by_cases ha : IsSelfAdjoint a
Β· rw [posPart_def, negPart_def, β cfcβ_comp_neg _ _]
congr! 2
Β· have ha' : Β¬ IsSelfAdjoint (-a) := fun h β¦ ha (by simpa using h.neg)
rw [posPart_def, negPart_def, cfcβ_apply_of_not_predicate a ha,
cfcβ_apply_of_not_predicate _ ha']
@[simp]
lemma negPart_neg (a : A) : (-a)β» = aβΊ := by
rw [β eq_comm, β sub_eq_zero, β posPart_neg, neg_neg, sub_self]
section SMul
variable [StarModule β A]
@[simp]
lemma posPart_smul {r : ββ₯0} {a : A} : (r β’ a)βΊ = r β’ aβΊ := by
by_cases ha : IsSelfAdjoint a
Β· simp only [CFC.posPart_def, NNReal.smul_def]
rw [β cfcβ_comp_smul .., β cfcβ_smul ..]
refine cfcβ_congr fun x hx β¦ ?_
simp [_root_.posPart_def, mul_max_of_nonneg]
Β· obtain (rfl | hr) := eq_or_ne r 0
Β· simp
Β· have := (not_iff_not.mpr <| (IsSelfAdjoint.all r).smul_iff hr.isUnit (x := a)) |>.mpr ha
simp [CFC.posPart_def, cfcβ_apply_of_not_predicate a ha,
cfcβ_apply_of_not_predicate _ this]
@[simp]
lemma negPart_smul {r : ββ₯0} {a : A} : (r β’ a)β» = r β’ aβ» := by
simpa using posPart_smul (r := r) (a := -a)
lemma posPart_smul_of_nonneg {r : β} (hr : 0 β€ r) {a : A} : (r β’ a)βΊ = r β’ aβΊ :=
posPart_smul (r := β¨r, hrβ©)
lemma posPart_smul_of_nonpos {r : β} (hr : r β€ 0) {a : A} : (r β’ a)βΊ = -r β’ aβ» := by
nth_rw 1 [β neg_neg r]
rw [neg_smul, β smul_neg, posPart_smul_of_nonneg (neg_nonneg.mpr hr), posPart_neg]
lemma negPart_smul_of_nonneg {r : β} (hr : 0 β€ r) {a : A} : (r β’ a)β» = r β’ aβ» := by
conv_lhs => rw [β neg_neg r, neg_smul, negPart_neg, posPart_smul_of_nonpos (by simpa), neg_neg]
lemma negPart_smul_of_nonpos {r : β} (hr : r β€ 0) {a : A} : (r β’ a)β» = -r β’ aβΊ := by
conv_lhs => rw [β neg_neg r, neg_smul, negPart_neg, posPart_smul_of_nonneg (by simpa)]
end SMul
end Unique
variable [PartialOrder A] [StarOrderedRing A]
@[aesop norm apply (rule_sets := [CStarAlgebra])]
lemma posPart_nonneg (a : A) :
0 β€ aβΊ :=
cfcβ_nonneg (fun x _ β¦ by positivity)
@[aesop norm apply (rule_sets := [CStarAlgebra])]
lemma negPart_nonneg (a : A) :
0 β€ aβ» :=
cfcβ_nonneg (fun x _ β¦ by positivity)
lemma posPart_eq_of_eq_sub_negPart {a b : A} (hab : a = b - aβ») (hb : 0 β€ b := by cfc_tac) :
aβΊ = b := by
have ha := hab.symm βΈ hb.isSelfAdjoint.sub (negPart_nonneg a).isSelfAdjoint
nth_rw 1 [β posPart_sub_negPart a] at hab
simpa using hab
lemma negPart_eq_of_eq_PosPart_sub {a c : A} (hac : a = aβΊ - c) (hc : 0 β€ c := by cfc_tac) :
aβ» = c := by
have ha := hac.symm βΈ (posPart_nonneg a).isSelfAdjoint.sub hc.isSelfAdjoint
nth_rw 1 [β posPart_sub_negPart a] at hac
simpa using hac
lemma le_posPart {a : A} (ha : IsSelfAdjoint a := by cfc_tac) : a β€ aβΊ := by
simpa [posPart_sub_negPart a] using sub_le_self aβΊ (negPart_nonneg a)
lemma neg_negPart_le {a : A} (ha : IsSelfAdjoint a := by cfc_tac) : -aβ» β€ a := by
simpa only [posPart_sub_negPart a, β sub_eq_add_neg]
using le_add_of_nonneg_left (a := -aβ») (posPart_nonneg a)
variable [NonnegSpectrumClass β A]
lemma posPart_eq_self (a : A) : aβΊ = a β 0 β€ a := by
refine β¨fun ha β¦ ha βΈ posPart_nonneg a, fun ha β¦ ?_β©
conv_rhs => rw [β cfcβ_id β a]
rw [posPart_def]
refine cfcβ_congr (fun x hx β¦ ?_)
simpa [_root_.posPart_def] using quasispectrum_nonneg_of_nonneg a ha x hx
lemma negPart_eq_zero_iff (a : A) (ha : IsSelfAdjoint a := by cfc_tac) :
aβ» = 0 β 0 β€ a := by
rw [β posPart_eq_self, eq_comm (b := a)]
nth_rw 2 [β posPart_sub_negPart a]
simp
lemma negPart_eq_neg (a : A) : aβ» = -a β a β€ 0 := by
rw [β neg_inj, neg_neg, eq_comm]
refine β¨fun ha β¦ by rw [ha, neg_nonpos]; exact negPart_nonneg a, fun ha β¦ ?_β©
rw [β neg_nonneg] at ha
rw [negPart_def, β cfcβ_neg]
have _ : IsSelfAdjoint a := neg_neg a βΈ (IsSelfAdjoint.neg <| .of_nonneg ha)
conv_lhs => rw [β cfcβ_id β a]
refine cfcβ_congr fun x hx β¦ ?_
rw [Unitization.quasispectrum_eq_spectrum_inr β, β neg_neg x, β Set.mem_neg,
spectrum.neg_eq, β Unitization.inr_neg, β Unitization.quasispectrum_eq_spectrum_inr β] at hx
rw [β neg_eq_iff_eq_neg, eq_comm]
simpa using quasispectrum_nonneg_of_nonneg _ ha _ hx
lemma posPart_eq_zero_iff (a : A) (ha : IsSelfAdjoint a := by cfc_tac) :
aβΊ = 0 β a β€ 0 := by
rw [β negPart_eq_neg, eq_comm (b := -a)]
nth_rw 2 [β posPart_sub_negPart a]
simp
local notation "Οβ" => quasispectrum
open ContinuousMapZero
variable [IsTopologicalRing A] [T2Space A]
open NonUnitalContinuousFunctionalCalculus in
/-- The positive and negative parts of a selfadjoint element `a` are unique. That is, if
`a = b - c` is the difference of nonnegative elements whose product is zero, then these are
precisely `aβΊ` and `aβ»`. -/
lemma posPart_negPart_unique {a b c : A} (habc : a = b - c) (hbc : b * c = 0)
(hb : 0 β€ b := by cfc_tac) (hc : 0 β€ c := by cfc_tac) :
aβΊ = b β§ aβ» = c := by
/- The key idea is to show that `cfcβ f a = cfcβ f b + cfcβ f (-c)` for all real-valued `f`
continuous on the union of the spectra of `a`, `b`, and `-c`. Then apply this to `f = (Β·βΊ)`.
The equality holds because both sides constitute star homomorphisms which agree on `f = id` since
`a = b - c`. -/
/- `a`, `b`, `-c` are selfadjoint. -/
have hb' : IsSelfAdjoint b := .of_nonneg hb
have hc' : IsSelfAdjoint (-c) := .neg <| .of_nonneg hc
have ha : IsSelfAdjoint a := habc βΈ hb'.sub <| .of_nonneg hc
/- It suffices to show `b = aβΊ` since `aβΊ - aβ» = a = b - c` -/
rw [and_iff_left_of_imp ?of_b_eq]
case of_b_eq =>
rintro rfl
exact negPart_eq_of_eq_PosPart_sub habc hc
/- `s := Οβ β a βͺ Οβ β b βͺ Οβ β (-c)` is compact and each of these sets are subsets of `s`.
Moreover, `0 β s`. -/
let s := Οβ β a βͺ Οβ β b βͺ Οβ β (-c)
have hs : CompactSpace s := by
refine isCompact_iff_compactSpace.mp <| (IsCompact.union ?_ ?_).union ?_
all_goals exact isCompact_quasispectrum _
obtain β¨has, hbs, hcsβ© : Οβ β a β s β§ Οβ β b β s β§ Οβ β (-c) β s := by grind
have : Fact (0 β s) := β¨by aesopβ©
/- The continuous functional calculi for functions `f g : C(s, β)β` applied to `b` and `(-c)`
are orthogonal (i.e., the product is always zero). -/
have mulβ (f g : C(s, β)β) :
(cfcβHomSuperset hb' hbs f) * (cfcβHomSuperset hc' hcs g) = 0 := by
refine f.nonUnitalStarAlgHom_apply_mul_eq_zero _ _ ?id ?star_id
(cfcβHomSuperset_continuous hb' hbs)
case' star_id => rw [star_trivial]
all_goals
refine g.mul_nonUnitalStarAlgHom_apply_eq_zero _ _ ?_ ?_
(cfcβHomSuperset_continuous hc' hcs)
all_goals simp only [star_trivial, cfcβHomSuperset_id hb' hbs,
cfcβHomSuperset_id hc' hcs, mul_neg, hbc, neg_zero]
have mulβ (f g : C(s, β)β) : (cfcβHomSuperset hc' hcs f) * (cfcβHomSuperset hb' hbs g) = 0 := by
simpa only [star_mul, star_zero, β map_star, star_trivial] using congr(star $(mulβ g f))
/- `fun f β¦ cfcβ f b + cfcβ f (-c)` defines a star homomorphism `Ο : C(s, β)β ββββ[β] A` which
agrees with the star homomorphism `cfcβ Β· a : C(s, β)β ββββ[β] A` since
`cfcβ id a = a = b - c = cfcβ id b + cfcβ id (-c)`. -/
let Ο : C(s, β)β ββββ[β] A :=
{ (cfcβHomSuperset hb' hbs : C(s, β)β ββ[β] A) + (cfcβHomSuperset hc' hcs : C(s, β)β ββ[β] A)
with
toFun := cfcβHomSuperset hb' hbs + cfcβHomSuperset hc' hcs
map_zero' := by simp [-cfcβHomSuperset_apply]
map_mul' := fun f g β¦ by
simp only [Pi.add_apply, map_mul, mul_add, add_mul, mulβ, add_zero, mulβ,
zero_add]
map_star' := fun f β¦ by simp [β map_star] }
have key : (cfcβHomSuperset ha has) = Ο :=
have : ContinuousMapZero.UniqueHom β A := inferInstance
ContinuousMapZero.UniqueHom.eq_of_continuous_of_map_id s
(cfcβHomSuperset ha has) Ο (cfcβHomSuperset_continuous ha has)
((cfcβHomSuperset_continuous hb' hbs).add (cfcβHomSuperset_continuous hc' hcs))
(by simpa [Ο, -cfcβHomSuperset_apply, cfcβHomSuperset_id, sub_eq_add_neg] using habc)
/- Applying the equality of star homomorphisms to the function `(Β·βΊ : β β β)` we find that
`b = cfcβ id b + cfcβ 0 (-c) = cfcβ (Β·βΊ) b - cfcβ (Β·βΊ) (-c) = cfcβ (Β·βΊ) a = aβΊ`, where the
second equality follows because these functions are equal on the spectra of `b` and `-c`,
respectively, since `0 β€ b` and `-c β€ 0`. -/
let f : C(s, β)β := β¨β¨(Β·βΊ), by fun_propβ©, by simp; exact le_rflβ©
replace key := congr($key f)
simp only [cfcβHomSuperset_apply, NonUnitalStarAlgHom.coe_mk', NonUnitalAlgHom.coe_mk, Ο,
Pi.add_apply, cfcβHom_eq_cfcβ_extend (Β·βΊ)] at key
symm
calc
b = cfcβ (id : β β β) b + cfcβ (0 : β β β) (-c) := by simp [cfcβ_id β b]
_ = _ := by
congr! 1
all_goals
refine cfcβ_congr fun x hx β¦ Eq.symm ?_
lift x to Οβ β _ using hx
simp only [Subtype.val_injective.extend_apply, comp_apply, coe_mk,
ContinuousMap.coe_mk, Subtype.map_coe, id_eq, _root_.posPart_eq_self, f, Pi.zero_apply,
posPart_eq_zero]
Β· exact quasispectrum_nonneg_of_nonneg b hb x.val x.property
Β· obtain β¨x, hxβ© := x
simp only [β neg_nonneg]
rw [Unitization.quasispectrum_eq_spectrum_inr β (-c), Unitization.inr_neg,
β spectrum.neg_eq, Set.mem_neg, β Unitization.quasispectrum_eq_spectrum_inr β c]
at hx
exact quasispectrum_nonneg_of_nonneg c hc _ hx
_ = _ := key.symm
_ = aβΊ := by
refine cfcβ_congr fun x hx β¦ ?_
lift x to Οβ β a using hx
simp [f]
end CFC
end NonUnital
section Unital
namespace CFC
variable {A : Type*} [Ring A] [Algebra β A] [StarRing A] [TopologicalSpace A]
variable [ContinuousFunctionalCalculus β A IsSelfAdjoint]
variable [T2Space A]
@[simp]
lemma posPart_one : (1 : A)βΊ = 1 := by
rw [CFC.posPart_def, cfcβ_eq_cfc]
simp
@[simp]
lemma negPart_one : (1 : A)β» = 0 := by
rw [CFC.negPart_def, cfcβ_eq_cfc]
simp
@[simp]
lemma posPart_algebraMap (r : β) : (algebraMap β A r)βΊ = algebraMap β A rβΊ := by
rw [CFC.posPart_def, cfcβ_eq_cfc]
simp
@[simp]
lemma negPart_algebraMap (r : β) : (algebraMap β A r)β» = algebraMap β A rβ» := by
rw [CFC.negPart_def, cfcβ_eq_cfc]
simp
open NNReal in
@[simp]
lemma posPart_algebraMap_nnreal (r : ββ₯0) : (algebraMap ββ₯0 A r)βΊ = algebraMap ββ₯0 A r := by
rw [CFC.posPart_def, cfcβ_eq_cfc, IsScalarTower.algebraMap_apply ββ₯0 β A]
simp
open NNReal in
@[simp]
lemma posPart_natCast (n : β) : (n : A)βΊ = n := by
rw [β map_natCast (algebraMap ββ₯0 A), posPart_algebraMap_nnreal]
end CFC
end Unital
section SpanNonneg
variable {A : Type*} [NonUnitalRing A] [Module β A] [SMulCommClass β A A] [IsScalarTower β A A]
variable [StarRing A] [TopologicalSpace A] [StarModule β A]
variable [NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
open Submodule Complex
open scoped ComplexStarModule
lemma CStarAlgebra.linear_combination_nonneg (x : A) :
((β x : A)βΊ - (β x : A)β») + (I β’ (β x : A)βΊ - I β’ (β x : A)β») = x := by
rw [CFC.posPart_sub_negPart _ (β x).2, β smul_sub, CFC.posPart_sub_negPart _ (β x).2,
realPart_add_I_smul_imaginaryPart x]
variable [PartialOrder A] [StarOrderedRing A]
/-- A Cβ-algebra is spanned by its nonnegative elements. -/
lemma CStarAlgebra.span_nonneg : Submodule.span β {a : A | 0 β€ a} = β€ := by
refine eq_top_iff.mpr fun x _ => ?_
rw [β CStarAlgebra.linear_combination_nonneg x]
apply_rules [sub_mem, Submodule.smul_mem, add_mem]
all_goals
refine subset_span ?_
first | apply CFC.negPart_nonneg | apply CFC.posPart_nonneg
end SpanNonneg |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/Isometric.lean | import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.Rpow.Basic
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric
/-! # Properties of `rpow` and `sqrt` over an algebra with an isometric CFC
This file collects results about `CFC.rpow`, `CFC.nnrpow` and `CFC.sqrt` that use facts that
rely on an isometric continuous functional calculus.
## Main theorems
* Various versions of `βa ^ rβ = βaβ ^ r` and `βCFC.sqrt aβ = sqrt βaβ`.
## Tags
continuous functional calculus, rpow, sqrt
-/
open scoped NNReal
namespace CFC
section nonunital
variable {A : Type*} [NonUnitalNormedRing A] [StarRing A] [NormedSpace β A] [IsScalarTower β A A]
[SMulCommClass β A A] [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A]
[NonUnitalIsometricContinuousFunctionalCalculus β A IsSelfAdjoint]
lemma nnnorm_nnrpow (a : A) {r : ββ₯0} (hr : 0 < r) (ha : 0 β€ a := by cfc_tac) :
βa ^ rββ = βaββ ^ (r : β) :=
NNReal.monotone_nnrpow_const r |>.monotoneOn _ |>.nnnorm_cfcβ _ _
lemma norm_nnrpow (a : A) {r : ββ₯0} (hr : 0 < r) (ha : 0 β€ a := by cfc_tac) :
βa ^ rβ = βaβ ^ (r : β) :=
congr(NNReal.toReal $(nnnorm_nnrpow a hr ha))
lemma nnnorm_sqrt (a : A) (ha : 0 β€ a := by cfc_tac) : βsqrt aββ = NNReal.sqrt βaββ := by
rw [sqrt_eq_nnrpow, NNReal.sqrt_eq_rpow]
exact nnnorm_nnrpow a (by simp) ha
lemma norm_sqrt (a : A) (ha : 0 β€ a := by cfc_tac) : βsqrt aβ = ββaβ := by
simpa using congr(NNReal.toReal $(nnnorm_sqrt a ha))
end nonunital
section unital
variable {A : Type*} [NormedRing A] [StarRing A] [NormedAlgebra β A]
[PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A]
[IsometricContinuousFunctionalCalculus β A IsSelfAdjoint]
lemma nnnorm_rpow (a : A) {r : β} (hr : 0 < r) (ha : 0 β€ a := by cfc_tac) :
βa ^ rββ = βaββ ^ r := by
lift r to ββ₯0 using hr.le
rw [β nnrpow_eq_rpow, β nnnorm_nnrpow a]
all_goals simpa
lemma norm_rpow (a : A) {r : β} (hr : 0 < r) (ha : 0 β€ a := by cfc_tac) :
βa ^ rβ = βaβ ^ r :=
congr(NNReal.toReal $(nnnorm_rpow a hr ha))
end unital
end CFC |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/Basic.lean | import Mathlib.Algebra.Order.Star.Prod
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Instances
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Pi
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unique
import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.PosPart.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Topology.ContinuousMap.ContinuousSqrt
/-!
# Real powers defined via the continuous functional calculus
This file defines real powers via the continuous functional calculus (CFC) and builds its API.
This allows one to take real powers of matrices, operators, elements of a Cβ-algebra, etc. The
square root is also defined via the non-unital CFC.
## Main declarations
+ `CFC.nnrpow`: the `ββ₯0` power function based on the non-unital CFC, i.e. `cfcβ NNReal.rpow`
composed with `(β) : ββ₯0 β β`.
+ `CFC.sqrt`: the square root function based on the non-unital CFC, i.e. `cfcβ NNReal.sqrt`
+ `CFC.rpow`: the real power function based on the unital CFC, i.e. `cfc NNReal.rpow`
## Implementation notes
We define two separate versions `CFC.nnrpow` and `CFC.rpow` due to what happens at 0. Since
`NNReal.rpow 0 0 = 1`, this means that this function does not map zero to zero when the exponent
is zero, and hence `CFC.nnrpow a 0 = 0` whereas `CFC.rpow a 0 = 1`. Note that the non-unital version
only makes sense for nonnegative exponents, and hence we define it such that the exponent is in
`ββ₯0`.
## Notation
+ We define a `Pow A β` instance for `CFC.rpow`, i.e `a ^ y` with `A` an operator and `y : β` works
as expected. Likewise, we define a `Pow A ββ₯0` instance for `CFC.nnrpow`. Note that these are
low-priority instances, in order to avoid overriding instances such as `Pow β β`,
`Pow (A Γ B) β` or `Pow (β i, A i) β`.
## TODO
+ Relate these to the log and exp functions
+ Lemmas about how these functions interact with commuting `a` and `b`.
+ Prove the order properties (operator monotonicity and concavity/convexity)
-/
open scoped NNReal
namespace NNReal
/-- Taking a nonnegative power of a nonnegative number. This is defined as a standalone definition
in order to speed up automation such as `cfc_cont_tac`. -/
noncomputable abbrev nnrpow (a : ββ₯0) (b : ββ₯0) : ββ₯0 := a ^ (b : β)
@[simp] lemma nnrpow_def (a b : ββ₯0) : nnrpow a b = a ^ (b : β) := rfl
@[fun_prop]
lemma continuous_nnrpow_const (y : ββ₯0) : Continuous (nnrpow Β· y) :=
continuous_rpow_const zero_le_coe
/- This is a "redeclaration" of the attribute to speed up the proofs in this file. -/
attribute [fun_prop] continuousOn_rpow_const
lemma monotone_nnrpow_const (y : ββ₯0) : Monotone (nnrpow Β· y) :=
monotone_rpow_of_nonneg zero_le_coe
end NNReal
namespace CFC
section NonUnital
variable {A : Type*} [PartialOrder A] [NonUnitalRing A] [TopologicalSpace A] [StarRing A]
[Module β A] [SMulCommClass β A A] [IsScalarTower β A A] [StarOrderedRing A]
[NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
[NonnegSpectrumClass β A]
/- ## `nnrpow` -/
/-- Real powers of operators, based on the non-unital continuous functional calculus. -/
noncomputable def nnrpow (a : A) (y : ββ₯0) : A := cfcβ (NNReal.nnrpow Β· y) a
/-- Enable `a ^ y` notation for `CFC.nnrpow`. This is a low-priority instance to make sure it does
not take priority over other instances when they are available. -/
noncomputable instance (priority := 100) : Pow A ββ₯0 where
pow a y := nnrpow a y
@[simp]
lemma nnrpow_eq_pow {a : A} {y : ββ₯0} : nnrpow a y = a ^ y := rfl
@[simp]
lemma nnrpow_nonneg {a : A} {x : ββ₯0} : 0 β€ a ^ x := cfcβ_predicate _ a
grind_pattern nnrpow_nonneg => NonnegSpectrumClass β A, a ^ x
lemma nnrpow_def {a : A} {y : ββ₯0} : a ^ y = cfcβ (NNReal.nnrpow Β· y) a := rfl
lemma nnrpow_eq_cfcβ_real [T2Space A] [IsTopologicalRing A] (a : A)
(y : ββ₯0) (ha : 0 β€ a := by cfc_tac) : a ^ y = cfcβ (fun x : β => x ^ (y : β)) a := by
rw [nnrpow_def, cfcβ_nnreal_eq_real ..]
refine cfcβ_congr ?_
intro x hx
have : 0 β€ x := by grind
simp [this]
lemma nnrpow_add {a : A} {x y : ββ₯0} (hx : 0 < x) (hy : 0 < y) :
a ^ (x + y) = a ^ x * a ^ y := by
simp only [nnrpow_def]
rw [β cfcβ_mul _ _ a]
congr! 2 with z
exact mod_cast z.rpow_add' <| ne_of_gt (add_pos hx hy)
@[simp]
lemma nnrpow_zero {a : A} : a ^ (0 : ββ₯0) = 0 := by
simp [nnrpow_def, cfcβ_apply_of_not_map_zero]
lemma nnrpow_one (a : A) (ha : 0 β€ a := by cfc_tac) : a ^ (1 : ββ₯0) = a := by
simp only [nnrpow_def, NNReal.nnrpow_def, NNReal.coe_one, NNReal.rpow_one]
change cfcβ (id : ββ₯0 β ββ₯0) a = a
rw [cfcβ_id ββ₯0 a]
lemma nnrpow_two (a : A) (ha : 0 β€ a := by cfc_tac) : a ^ (2 : ββ₯0) = a * a := by
simp only [nnrpow_def, NNReal.nnrpow_def, NNReal.coe_ofNat, NNReal.rpow_ofNat, pow_two]
change cfcβ (fun z : ββ₯0 => id z * id z) a = a * a
rw [cfcβ_mul id id a, cfcβ_id ββ₯0 a]
lemma nnrpow_three (a : A) (ha : 0 β€ a := by cfc_tac) : a ^ (3 : ββ₯0) = a * a * a := by
simp only [nnrpow_def, NNReal.nnrpow_def, NNReal.coe_ofNat, NNReal.rpow_ofNat, pow_three]
change cfcβ (fun z : ββ₯0 => id z * (id z * id z)) a = a * a * a
rw [cfcβ_mul id _ a, cfcβ_mul id _ a, β mul_assoc, cfcβ_id ββ₯0 a]
@[simp]
lemma zero_nnrpow {x : ββ₯0} : (0 : A) ^ x = 0 := by simp [nnrpow_def]
section Unique
variable [IsTopologicalRing A] [T2Space A]
@[simp]
lemma nnrpow_nnrpow {a : A} {x y : ββ₯0} : (a ^ x) ^ y = a ^ (x * y) := by
by_cases ha : 0 β€ a
case pos =>
obtain (rfl | hx) := eq_zero_or_pos x <;> obtain (rfl | hy) := eq_zero_or_pos y
all_goals try simp
simp only [nnrpow_def]
rw [β cfcβ_comp _ _ a]
congr! 2 with u
ext
simp [Real.rpow_mul]
case neg =>
simp [nnrpow_def, cfcβ_apply_of_not_predicate a ha]
lemma nnrpow_nnrpow_inv (a : A) {x : ββ₯0} (hx : x β 0) (ha : 0 β€ a := by cfc_tac) :
(a ^ x) ^ xβ»ΒΉ = a := by
simp [mul_inv_cancelβ hx, nnrpow_one _ ha]
lemma nnrpow_inv_nnrpow (a : A) {x : ββ₯0} (hx : x β 0) (ha : 0 β€ a := by cfc_tac) :
(a ^ xβ»ΒΉ) ^ x = a := by
simp [inv_mul_cancelβ hx, nnrpow_one _ ha]
lemma nnrpow_inv_eq (a b : A) {x : ββ₯0} (hx : x β 0) (ha : 0 β€ a := by cfc_tac)
(hb : 0 β€ b := by cfc_tac) : a ^ xβ»ΒΉ = b β b ^ x = a :=
β¨fun h β¦ nnrpow_inv_nnrpow a hx βΈ congr($(h) ^ x).symm,
fun h β¦ nnrpow_nnrpow_inv b hx βΈ congr($(h) ^ xβ»ΒΉ).symmβ©
section prod
variable {B : Type*} [PartialOrder B] [NonUnitalRing B] [TopologicalSpace B] [StarRing B]
[Module β B] [SMulCommClass β B B] [IsScalarTower β B B]
[NonUnitalContinuousFunctionalCalculus β B IsSelfAdjoint]
[NonUnitalContinuousFunctionalCalculus β (A Γ B) IsSelfAdjoint]
[IsTopologicalRing B] [T2Space B]
[NonnegSpectrumClass β B] [NonnegSpectrumClass β (A Γ B)]
[StarOrderedRing B]
/- Note that there is higher-priority instance of `Pow (A Γ B) ββ₯0` coming from the `Pow` instance
for products, hence the direct use of `nnrpow` here. -/
lemma nnrpow_map_prod {a : A} {b : B} {x : ββ₯0}
(ha : 0 β€ a := by cfc_tac) (hb : 0 β€ b := by cfc_tac) :
nnrpow (a, b) x = (a ^ x, b ^ x) := by
simp only [nnrpow_def]
unfold nnrpow
refine cfcβ_map_prod (S := β) _ a b (by fun_prop) ?_
rw [Prod.le_def]
constructor <;> simp [ha, hb]
lemma nnrpow_eq_nnrpow_prod {a : A} {b : B} {x : ββ₯0}
(ha : 0 β€ a := by cfc_tac) (hb : 0 β€ b := by cfc_tac) :
nnrpow (a, b) x = (a, b) ^ x := nnrpow_map_prod
end prod
section pi
variable {ΞΉ : Type*} {C : ΞΉ β Type*} [β i, PartialOrder (C i)] [β i, NonUnitalRing (C i)]
[β i, TopologicalSpace (C i)] [β i, StarRing (C i)]
[β i, StarOrderedRing (C i)] [StarOrderedRing (β i, C i)]
[β i, Module β (C i)] [β i, SMulCommClass β (C i) (C i)] [β i, IsScalarTower β (C i) (C i)]
[β i, NonUnitalContinuousFunctionalCalculus β (C i) IsSelfAdjoint]
[NonUnitalContinuousFunctionalCalculus β (β i, C i) IsSelfAdjoint]
[β i, IsTopologicalRing (C i)] [β i, T2Space (C i)]
[NonnegSpectrumClass β (β i, C i)] [β i, NonnegSpectrumClass β (C i)]
/- Note that there is higher-priority instance of `Pow (β i, C i) ββ₯0` coming from the `Pow`
instance for pi types, hence the direct use of `nnrpow` here. -/
lemma nnrpow_map_pi {c : β i, C i} {x : ββ₯0} (hc : β i, 0 β€ c i := by cfc_tac) :
nnrpow c x = fun i => (c i) ^ x := by
simp only [nnrpow_def]
unfold nnrpow
exact cfcβ_map_pi (S := β) _ c
lemma nnrpow_eq_nnrpow_pi {c : β i, C i} {x : ββ₯0} (hc : β i, 0 β€ c i := by cfc_tac) :
nnrpow c x = c ^ x := nnrpow_map_pi
end pi
end Unique
/- ## `sqrt` -/
section sqrt
/-- Square roots of operators, based on the non-unital continuous functional calculus. -/
noncomputable def sqrt (a : A) : A := cfcβ NNReal.sqrt a
@[simp]
lemma sqrt_nonneg (a : A) : 0 β€ sqrt a := cfcβ_predicate _ a
grind_pattern sqrt_nonneg => NonnegSpectrumClass β A, sqrt a
lemma sqrt_eq_nnrpow (a : A) : sqrt a = a ^ (1 / 2 : ββ₯0) := by
simp only [sqrt]
congr
ext
exact_mod_cast NNReal.sqrt_eq_rpow _
@[simp]
lemma sqrt_zero : sqrt (0 : A) = 0 := by simp [sqrt]
variable [IsTopologicalRing A] [T2Space A]
@[simp]
lemma nnrpow_sqrt {a : A} {x : ββ₯0} : (sqrt a) ^ x = a ^ (x / 2) := by
rw [sqrt_eq_nnrpow, nnrpow_nnrpow, one_div_mul_eq_div 2 x]
lemma nnrpow_sqrt_two (a : A) (ha : 0 β€ a := by cfc_tac) : (sqrt a) ^ (2 : ββ₯0) = a := by
simp only [nnrpow_sqrt, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, div_self]
rw [nnrpow_one a]
lemma sqrt_mul_sqrt_self (a : A) (ha : 0 β€ a := by cfc_tac) : sqrt a * sqrt a = a := by
rw [β nnrpow_two _, nnrpow_sqrt_two _]
@[simp]
lemma sqrt_nnrpow {a : A} {x : ββ₯0} : sqrt (a ^ x) = a ^ (x / 2) := by
simp [sqrt_eq_nnrpow, div_eq_mul_inv]
lemma sqrt_nnrpow_two (a : A) (ha : 0 β€ a := by cfc_tac) : sqrt (a ^ (2 : ββ₯0)) = a := by
simp only [sqrt_nnrpow, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, div_self]
rw [nnrpow_one _]
lemma sqrt_mul_self (a : A) (ha : 0 β€ a := by cfc_tac) : sqrt (a * a) = a := by
rw [β nnrpow_two _, sqrt_nnrpow_two _]
lemma mul_self_eq {a b : A} (h : sqrt a = b) (ha : 0 β€ a := by cfc_tac) :
b * b = a :=
h βΈ sqrt_mul_sqrt_self _ ha
lemma sqrt_unique {a b : A} (h : b * b = a) (hb : 0 β€ b := by cfc_tac) :
sqrt a = b :=
h βΈ sqrt_mul_self b
lemma sqrt_eq_iff (a b : A) (ha : 0 β€ a := by cfc_tac) (hb : 0 β€ b := by cfc_tac) :
sqrt a = b β b * b = a :=
β¨(mul_self_eq Β·), (sqrt_unique Β·)β©
lemma sqrt_eq_zero_iff (a : A) (ha : 0 β€ a := by cfc_tac) : sqrt a = 0 β a = 0 := by
rw [sqrt_eq_iff a _, mul_zero, eq_comm]
lemma mul_self_eq_mul_self_iff (a b : A) (ha : 0 β€ a := by cfc_tac) (hb : 0 β€ b := by cfc_tac) :
a * a = b * b β a = b :=
β¨fun h => sqrt_mul_self a βΈ sqrt_unique h.symm, fun h => h βΈ rflβ©
/-- Note that the hypothesis `0 β€ a` is necessary because the continuous functional calculi over
`ββ₯0` (for the left-hand side) and `β` (for the right-hand side) use different predicates (i.e.,
`(0 β€ Β·)` versus `IsSelfAdjoint`). Consequently, if `a` is selfadjoint but not nonnegative, then
the left-hand side is zero, but the right-hand side is (provably equal to) `CFC.sqrt aβΊ`. -/
lemma sqrt_eq_real_sqrt (a : A) (ha : 0 β€ a := by cfc_tac) :
CFC.sqrt a = cfcβ Real.sqrt a := by
suffices cfcβ (fun x : β β¦ βx * βx) a = cfcβ (fun x : β β¦ x) a by
rwa [cfcβ_mul .., cfcβ_id' ..,
β sqrt_eq_iff _ (hb := cfcβ_nonneg (fun x _ β¦ Real.sqrt_nonneg x))] at this
exact cfcβ_congr fun x hx β¦ Real.mul_self_sqrt <| quasispectrum_nonneg_of_nonneg a ha x hx
section prod
variable {B : Type*} [PartialOrder B] [NonUnitalRing B] [TopologicalSpace B] [StarRing B]
[Module β B] [SMulCommClass β B B] [IsScalarTower β B B] [StarOrderedRing B]
[NonUnitalContinuousFunctionalCalculus β B IsSelfAdjoint]
[NonUnitalContinuousFunctionalCalculus β (A Γ B) IsSelfAdjoint]
[IsTopologicalRing B] [T2Space B]
[NonnegSpectrumClass β B] [NonnegSpectrumClass β (A Γ B)]
lemma sqrt_map_prod {a : A} {b : B} (ha : 0 β€ a := by cfc_tac) (hb : 0 β€ b := by cfc_tac) :
sqrt (a, b) = (sqrt a, sqrt b) := by
simp only [sqrt_eq_nnrpow]
exact nnrpow_map_prod
end prod
section pi
variable {ΞΉ : Type*} {C : ΞΉ β Type*} [β i, PartialOrder (C i)] [β i, NonUnitalRing (C i)]
[β i, TopologicalSpace (C i)] [β i, StarRing (C i)]
[β i, StarOrderedRing (C i)] [StarOrderedRing (β i, C i)]
[β i, Module β (C i)] [β i, SMulCommClass β (C i) (C i)] [β i, IsScalarTower β (C i) (C i)]
[β i, NonUnitalContinuousFunctionalCalculus β (C i) IsSelfAdjoint]
[NonUnitalContinuousFunctionalCalculus β (β i, C i) IsSelfAdjoint]
[β i, IsTopologicalRing (C i)] [β i, T2Space (C i)]
[NonnegSpectrumClass β (β i, C i)] [β i, NonnegSpectrumClass β (C i)]
lemma sqrt_map_pi {c : β i, C i} (hc : β i, 0 β€ c i := by cfc_tac) :
sqrt c = fun i => sqrt (c i) := by
simp only [sqrt_eq_nnrpow]
exact nnrpow_map_pi
end pi
/-- For an element `a` in a Cβ-algebra, TFAE:
1. `0 β€ a`
2. `a = sqrt a * sqrt a`
3. `a = b * b` for some nonnegative `b`
4. `a = b * b` for some self-adjoint `b`
5. `a = star b * b` for some `b`
6. `a = b * star b` for some `b`
7. `a = aβΊ`
8. `a` is self-adjoint and `aβ» = 0`
9. `a` is self-adjoint and has nonnegative spectrum -/
theorem _root_.CStarAlgebra.nonneg_TFAE {a : A} :
[ 0 β€ a,
a = sqrt a * sqrt a,
β b : A, 0 β€ b β§ a = b * b,
β b : A, IsSelfAdjoint b β§ a = b * b,
β b : A, a = star b * b,
β b : A, a = b * star b,
a = aβΊ,
IsSelfAdjoint a β§ aβ» = 0,
IsSelfAdjoint a β§ QuasispectrumRestricts a ContinuousMap.realToNNReal ].TFAE := by
tfae_have 1 β 9 := nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts
tfae_have 1 β 7 := eq_comm.eq βΈ (CFC.posPart_eq_self a).symm
tfae_have 1 β 8 := β¨fun h => β¨h.isSelfAdjoint, negPart_eq_zero_iff a |>.mpr hβ©,
fun h => negPart_eq_zero_iff a |>.mp h.2β©
tfae_have 1 β 2 := fun h => sqrt_mul_sqrt_self a |>.symm
tfae_have 2 β 3 := fun h => β¨sqrt a, sqrt_nonneg a, hβ©
tfae_have 3 β 4 := fun β¨b, hbβ© => β¨b, hb.1.isSelfAdjoint, hb.2β©
tfae_have 4 β 5 := fun β¨b, hbβ© => β¨b, hb.1.symm βΈ hb.2β©
tfae_have 5 β 6 := fun β¨b, hbβ© => β¨star b, star_star b |>.symm βΈ hbβ©
tfae_have 6 β 1 := fun β¨b, hbβ© => hb βΈ mul_star_self_nonneg _
tfae_finish
theorem _root_.CStarAlgebra.nonneg_iff_eq_sqrt_mul_sqrt {a : A} :
0 β€ a β a = sqrt a * sqrt a := CStarAlgebra.nonneg_TFAE.out 0 1
theorem _root_.CStarAlgebra.nonneg_iff_exists_nonneg_and_eq_mul_self {a : A} :
0 β€ a β β b, 0 β€ b β§ a = b * b := CStarAlgebra.nonneg_TFAE.out 0 2
theorem _root_.CStarAlgebra.nonneg_iff_exists_isSelfAdjoint_and_eq_mul_self {a : A} :
0 β€ a β β b, IsSelfAdjoint b β§ a = b * b := CStarAlgebra.nonneg_TFAE.out 0 3
theorem _root_.CStarAlgebra.nonneg_iff_eq_star_mul_self {a : A} :
0 β€ a β β b, a = star b * b := CStarAlgebra.nonneg_TFAE.out 0 4
theorem _root_.CStarAlgebra.nonneg_iff_eq_mul_star_self {a : A} :
0 β€ a β β b, a = b * star b := CStarAlgebra.nonneg_TFAE.out 0 5
theorem _root_.CStarAlgebra.nonneg_iff_isSelfAdjoint_and_negPart_eq_zero {a : A} :
0 β€ a β IsSelfAdjoint a β§ aβ» = 0 := CStarAlgebra.nonneg_TFAE.out 0 7
end sqrt
end NonUnital
section Unital
variable {A : Type*} [PartialOrder A] [Ring A] [StarRing A] [TopologicalSpace A]
[StarOrderedRing A] [Algebra β A] [ContinuousFunctionalCalculus β A IsSelfAdjoint]
[NonnegSpectrumClass β A]
/- ## `rpow` -/
/-- Real powers of operators, based on the unital continuous functional calculus. -/
noncomputable def rpow (a : A) (y : β) : A := cfc (fun x : ββ₯0 => x ^ y) a
/-- Enable `a ^ y` notation for `CFC.rpow`. This is a low-priority instance to make sure it does
not take priority over other instances when they are available (such as `Pow β β`). -/
noncomputable instance (priority := 100) : Pow A β where
pow a y := rpow a y
@[simp]
lemma rpow_eq_pow {a : A} {y : β} : rpow a y = a ^ y := rfl
@[simp]
lemma rpow_nonneg {a : A} {y : β} : 0 β€ a ^ y := cfc_predicate _ a
grind_pattern rpow_nonneg => NonnegSpectrumClass β A, a ^ y
lemma rpow_def {a : A} {y : β} : a ^ y = cfc (fun x : ββ₯0 => x ^ y) a := rfl
lemma rpow_one (a : A) (ha : 0 β€ a := by cfc_tac) : a ^ (1 : β) = a := by
simp only [rpow_def, NNReal.rpow_one, cfc_id' ββ₯0 a]
@[simp]
lemma one_rpow {x : β} : (1 : A) ^ x = (1 : A) := by simp [rpow_def]
lemma rpow_zero (a : A) (ha : 0 β€ a := by cfc_tac) : a ^ (0 : β) = 1 := by
simp [rpow_def, cfc_const_one ββ₯0 a]
lemma zero_rpow {x : β} (hx : x β 0) : rpow (0 : A) x = 0 := by simp [rpow, NNReal.zero_rpow hx]
lemma rpow_natCast (a : A) (n : β) (ha : 0 β€ a := by cfc_tac) : a ^ (n : β) = a ^ n := by
rw [β cfc_pow_id (R := ββ₯0) a n, rpow_def]
congr
simp
@[simp]
lemma rpow_algebraMap {x : ββ₯0} {y : β} :
(algebraMap ββ₯0 A x) ^ y = algebraMap ββ₯0 A (x ^ y) := by
rw [rpow_def, cfc_algebraMap ..]
lemma rpow_add {a : A} {x y : β} (ha : IsUnit a) :
a ^ (x + y) = a ^ x * a ^ y := by
have ha' : 0 β spectrum ββ₯0 a := spectrum.zero_notMem _ ha
simp only [rpow_def]
rw [β cfc_mul _ _ a]
refine cfc_congr ?_
intro z hz
have : z β 0 := by aesop
simp [NNReal.rpow_add this _ _]
lemma rpow_rpow [IsTopologicalRing A] [T2Space A]
(a : A) (x y : β) (haβ : IsUnit a) (hx : x β 0) (haβ : 0 β€ a := by cfc_tac) :
(a ^ x) ^ y = a ^ (x * y) := by
have haβ' : 0 β spectrum ββ₯0 a := spectrum.zero_notMem _ haβ
simp only [rpow_def]
rw [β cfc_comp _ _ a haβ]
refine cfc_congr fun _ _ => ?_
simp [NNReal.rpow_mul]
lemma rpow_rpow_inv [IsTopologicalRing A] [T2Space A]
(a : A) (x : β) (haβ : IsUnit a) (hx : x β 0) (haβ : 0 β€ a := by cfc_tac) :
(a ^ x) ^ xβ»ΒΉ = a := by
rw [rpow_rpow a x xβ»ΒΉ haβ hx haβ, mul_inv_cancelβ hx, rpow_one a haβ]
lemma rpow_inv_rpow [IsTopologicalRing A] [T2Space A]
(a : A) (x : β) (haβ : IsUnit a) (hx : x β 0) (haβ : 0 β€ a := by cfc_tac) :
(a ^ xβ»ΒΉ) ^ x = a := by
simpa using rpow_rpow_inv a xβ»ΒΉ haβ (inv_ne_zero hx) haβ
lemma rpow_rpow_of_exponent_nonneg [IsTopologicalRing A] [T2Space A] (a : A) (x y : β)
(hx : 0 β€ x) (hy : 0 β€ y) (haβ : 0 β€ a := by cfc_tac) : (a ^ x) ^ y = a ^ (x * y) := by
simp only [rpow_def]
rw [β cfc_comp _ _ a]
refine cfc_congr fun _ _ => ?_
simp [NNReal.rpow_mul]
lemma rpow_mul_rpow_neg {a : A} (x : β) (ha : IsUnit a)
(ha' : 0 β€ a := by cfc_tac) : a ^ x * a ^ (-x) = 1 := by
rw [β rpow_add ha, add_neg_cancel, rpow_zero a]
lemma rpow_neg_mul_rpow {a : A} (x : β) (ha : IsUnit a)
(ha' : 0 β€ a := by cfc_tac) : a ^ (-x) * a ^ x = 1 := by
rw [β rpow_add ha, neg_add_cancel, rpow_zero a]
lemma rpow_neg_one_eq_inv (a : AΛ£) (ha : (0 : A) β€ a := by cfc_tac) :
a ^ (-1 : β) = (βaβ»ΒΉ : A) := by
refine a.inv_eq_of_mul_eq_one_left ?_ |>.symm
simpa [rpow_one (a : A)] using rpow_neg_mul_rpow 1 a.isUnit
lemma rpow_neg_one_eq_cfc_inv {A : Type*} [PartialOrder A] [NormedRing A] [StarRing A]
[StarOrderedRing A] [NormedAlgebra β A] [NonnegSpectrumClass β A]
[ContinuousFunctionalCalculus β A IsSelfAdjoint] (a : A) :
a ^ (-1 : β) = cfc (Β·β»ΒΉ : ββ₯0 β ββ₯0) a :=
cfc_congr fun x _ β¦ NNReal.rpow_neg_one x
lemma rpow_neg [IsTopologicalRing A] [T2Space A] (a : AΛ£) (x : β)
(ha' : (0 : A) β€ a := by cfc_tac) : (a : A) ^ (-x) = (βaβ»ΒΉ : A) ^ x := by
suffices hβ : ContinuousOn (fun z β¦ z ^ x) (Inv.inv '' (spectrum ββ₯0 (a : A))) by
rw [β cfc_inv_id (R := ββ₯0) a, rpow_def, rpow_def,
β cfc_comp' (fun z => z ^ x) (Inv.inv : ββ₯0 β ββ₯0) (a : A) hβ]
refine cfc_congr fun _ _ => ?_
simp [NNReal.rpow_neg, NNReal.inv_rpow]
refine NNReal.continuousOn_rpow_const (.inl ?_)
rintro β¨z, hz, hz'β©
exact spectrum.zero_notMem ββ₯0 a.isUnit <| inv_eq_zero.mp hz' βΈ hz
lemma rpow_intCast (a : AΛ£) (n : β€) (ha : (0 : A) β€ a := by cfc_tac) :
(a : A) ^ (n : β) = (β(a ^ n) : A) := by
rw [β cfc_zpow (R := ββ₯0) a n, rpow_def]
refine cfc_congr fun _ _ => ?_
simp
/-- `a ^ x` bundled as an element of `AΛ£` for `a : AΛ£`. -/
@[simps]
noncomputable def _root_.Units.cfcRpow (a : AΛ£) (x : β) (ha : (0 : A) β€ a := by cfc_tac) : AΛ£ :=
β¨(a : A) ^ x, (a : A) ^ (-x), rpow_mul_rpow_neg x (by simp), rpow_neg_mul_rpow x (by simp)β©
@[aesop safe apply, grind β]
lemma _root_.IsUnit.cfcRpow {a : A} (ha : IsUnit a) (x : β) (ha_nonneg : 0 β€ a := by cfc_tac) :
IsUnit (a ^ x) :=
ha.unit.cfcRpow x |>.isUnit
lemma spectrum_rpow (a : A) (x : β)
(h : ContinuousOn (Β· ^ x) (spectrum ββ₯0 a) := by cfc_cont_tac)
(ha : 0 β€ a := by cfc_tac) :
spectrum ββ₯0 (a ^ x) = (Β· ^ x) '' spectrum ββ₯0 a :=
cfc_map_spectrum (Β· ^ x : ββ₯0 β ββ₯0) a ha h
@[grind =]
lemma isUnit_rpow_iff (a : A) (y : β) (hy : y β 0) (ha : 0 β€ a := by cfc_tac) :
IsUnit (a ^ y) β IsUnit a := by
nontriviality A
refine β¨fun h => ?_, fun h => h.cfcRpow y haβ©
rw [rpow_def] at h
by_cases hf : ContinuousOn (fun x : ββ₯0 => x ^ y) (spectrum ββ₯0 a)
Β· rw [isUnit_cfc_iff _ a hf] at h
refine spectrum.isUnit_of_zero_notMem ββ₯0 ?_
intro h0
specialize h 0 h0
simp only [ne_eq, NNReal.rpow_eq_zero_iff, true_and, Decidable.not_not] at h
exact hy h
Β· rw [cfc_apply_of_not_continuousOn a hf] at h
exact False.elim <| not_isUnit_zero h
section prod
variable [IsTopologicalRing A] [T2Space A]
variable {B : Type*} [PartialOrder B] [Ring B] [StarRing B] [TopologicalSpace B]
[StarOrderedRing B]
[Algebra β B] [ContinuousFunctionalCalculus β B IsSelfAdjoint]
[ContinuousFunctionalCalculus β (A Γ B) IsSelfAdjoint]
[IsTopologicalRing B] [T2Space B] [StarOrderedRing (A Γ B)]
[NonnegSpectrumClass β B] [NonnegSpectrumClass β (A Γ B)]
/- Note that there is higher-priority instance of `Pow (A Γ B) β` coming from the `Pow` instance for
products, hence the direct use of `rpow` here. -/
lemma rpow_map_prod {a : A} {b : B} {x : β} (ha : IsUnit a) (hb : IsUnit b)
(ha' : 0 β€ a := by cfc_tac) (hb' : 0 β€ b := by cfc_tac) :
rpow (a, b) x = (a ^ x, b ^ x) := by
have ha'' : 0 β spectrum ββ₯0 a := spectrum.zero_notMem _ ha
have hb'' : 0 β spectrum ββ₯0 b := spectrum.zero_notMem _ hb
simp only [rpow_def]
unfold rpow
refine cfc_map_prod (R := ββ₯0) (S := β) _ a b (by cfc_cont_tac) ?_
rw [Prod.le_def]
constructor <;> simp [ha', hb']
lemma rpow_eq_rpow_prod {a : A} {b : B} {x : β} (ha : IsUnit a) (hb : IsUnit b)
(ha' : 0 β€ a := by cfc_tac) (hb' : 0 β€ b := by cfc_tac) :
rpow (a, b) x = (a, b) ^ x := rpow_map_prod ha hb
@[deprecated (since := "2025-05-13")] alias rpow_eq_rpow_rpod := rpow_eq_rpow_prod
end prod
section pi
variable [IsTopologicalRing A] [T2Space A]
variable {ΞΉ : Type*} {C : ΞΉ β Type*} [β i, PartialOrder (C i)] [β i, Ring (C i)]
[β i, StarRing (C i)] [β i, TopologicalSpace (C i)] [β i, StarOrderedRing (C i)]
[StarOrderedRing (β i, C i)]
[β i, Algebra β (C i)] [β i, ContinuousFunctionalCalculus β (C i) IsSelfAdjoint]
[ContinuousFunctionalCalculus β (β i, C i) IsSelfAdjoint]
[β i, IsTopologicalRing (C i)] [β i, T2Space (C i)]
[NonnegSpectrumClass β (β i, C i)] [β i, NonnegSpectrumClass β (C i)]
/- Note that there is a higher-priority instance of `Pow (β i, B i) β` coming from the `Pow`
instance for pi types, hence the direct use of `rpow` here. -/
lemma rpow_map_pi {c : β i, C i} {x : β} (hc : β i, IsUnit (c i))
(hc' : β i, 0 β€ c i := by cfc_tac) :
rpow c x = fun i => (c i) ^ x := by
have hc'' : β i, 0 β spectrum ββ₯0 (c i) := fun i => spectrum.zero_notMem _ (hc i)
simp only [rpow_def]
unfold rpow
exact cfc_map_pi (S := β) _ c
lemma rpow_eq_rpow_pi {c : β i, C i} {x : β} (hc : β i, IsUnit (c i))
(hc' : β i, 0 β€ c i := by cfc_tac) :
rpow c x = c ^ x := rpow_map_pi hc
end pi
section unital_vs_nonunital
variable [IsTopologicalRing A] [T2Space A]
-- provides instance `ContinuousFunctionalCalculus.compactSpace_spectrum`
open scoped ContinuousFunctionalCalculus
lemma nnrpow_eq_rpow {a : A} {x : ββ₯0} (hx : 0 < x) : a ^ x = a ^ (x : β) := by
rw [nnrpow_def (A := A), rpow_def, cfcβ_eq_cfc]
lemma sqrt_eq_rpow {a : A} : sqrt a = a ^ (1 / 2 : β) := by
have : a ^ (1 / 2 : β) = a ^ ((1 / 2 : ββ₯0) : β) := rfl
rw [this, β nnrpow_eq_rpow (by simp), sqrt_eq_nnrpow a]
lemma sqrt_eq_cfc {a : A} : sqrt a = cfc NNReal.sqrt a := by
unfold sqrt
rw [cfcβ_eq_cfc]
lemma sqrt_sq (a : A) (ha : 0 β€ a := by cfc_tac) : sqrt (a ^ 2) = a := by
rw [pow_two, sqrt_mul_self (A := A) a]
lemma sq_sqrt (a : A) (ha : 0 β€ a := by cfc_tac) : (sqrt a) ^ 2 = a := by
rw [pow_two, sqrt_mul_sqrt_self (A := A) a]
lemma sq_eq_sq_iff (a b : A) (ha : 0 β€ a := by cfc_tac) (hb : 0 β€ b := by cfc_tac) :
a ^ 2 = b ^ 2 β a = b := by
simp_rw [sq, mul_self_eq_mul_self_iff a b]
@[simp]
lemma sqrt_algebraMap {r : ββ₯0} : sqrt (algebraMap ββ₯0 A r) = algebraMap ββ₯0 A (NNReal.sqrt r) := by
rw [sqrt_eq_cfc, cfc_algebraMap]
@[simp]
lemma sqrt_one : sqrt (1 : A) = 1 := by simp [sqrt_eq_cfc]
lemma sqrt_eq_one_iff (a : A) (ha : 0 β€ a := by cfc_tac) :
sqrt a = 1 β a = 1 := by
rw [sqrt_eq_iff a _, mul_one, eq_comm]
lemma sqrt_eq_one_iff' [Nontrivial A] (a : A) :
sqrt a = 1 β a = 1 := by
refine β¨fun h β¦ sqrt_eq_one_iff a ?_ |>.mp h, fun h β¦ h βΈ sqrt_oneβ©
rw [sqrt, cfcβ] at h
cfc_tac
-- TODO: relate to a strict positivity condition
lemma sqrt_rpow {a : A} {x : β} (h : IsUnit a)
(hx : x β 0) : sqrt (a ^ x) = a ^ (x / 2) := by
by_cases hnonneg : 0 β€ a
case pos =>
simp only [sqrt_eq_rpow, div_eq_mul_inv, one_mul, rpow_rpow _ _ _ h hx]
case neg =>
simp [sqrt_eq_cfc, rpow_def, cfc_apply_of_not_predicate a hnonneg]
-- TODO: relate to a strict positivity condition
lemma rpow_sqrt (a : A) (x : β) (h : IsUnit a)
(ha : 0 β€ a := by cfc_tac) : (sqrt a) ^ x = a ^ (x / 2) := by
rw [sqrt_eq_rpow, div_eq_mul_inv, one_mul,
rpow_rpow _ _ _ h (by simp), inv_mul_eq_div]
lemma sqrt_rpow_nnreal {a : A} {x : ββ₯0} : sqrt (a ^ (x : β)) = a ^ (x / 2 : β) := by
by_cases htriv : 0 β€ a
case neg => simp [sqrt_eq_cfc, rpow_def, cfc_apply_of_not_predicate a htriv]
case pos =>
cases eq_zero_or_pos x with
| inl hx => simp [hx, rpow_zero _ htriv]
| inr hβ =>
have hβ : (x : β) / 2 = NNReal.toReal (x / 2) := by simp
have hβ : 0 < x / 2 := by positivity
rw [β nnrpow_eq_rpow hβ, hβ, β nnrpow_eq_rpow hβ, sqrt_nnrpow (A := A)]
lemma rpow_sqrt_nnreal {a : A} {x : ββ₯0}
(ha : 0 β€ a := by cfc_tac) : (sqrt a) ^ (x : β) = a ^ (x / 2 : β) := by
by_cases hx : x = 0
case pos =>
have ha' : 0 β€ sqrt a := sqrt_nonneg _
simp [hx, rpow_zero _ ha', rpow_zero _ ha]
case neg =>
have hβ : 0 β€ (x : β) := NNReal.zero_le_coe
rw [sqrt_eq_rpow, rpow_rpow_of_exponent_nonneg _ _ _ (by simp) hβ, one_div_mul_eq_div]
@[grind =]
lemma isUnit_nnrpow_iff (a : A) (y : ββ₯0) (hy : y β 0) (ha : 0 β€ a := by cfc_tac) :
IsUnit (a ^ y) β IsUnit a := by
rw [nnrpow_eq_rpow (pos_of_ne_zero hy)]
refine isUnit_rpow_iff a y ?_ ha
exact_mod_cast hy
@[aesop safe apply]
lemma _root_.IsUnit.cfcNNRpow (a : A) (y : ββ₯0) (ha_unit : IsUnit a) (hy : y β 0)
(ha : 0 β€ a := by cfc_tac) : IsUnit (a ^ y) :=
(isUnit_nnrpow_iff a y hy ha).mpr ha_unit
@[grind =]
lemma isUnit_sqrt_iff (a : A) (ha : 0 β€ a := by cfc_tac) : IsUnit (sqrt a) β IsUnit a := by
rw [sqrt_eq_rpow]
exact isUnit_rpow_iff a _ (by simp) ha
@[aesop safe apply]
lemma _root_.IsUnit.cfcSqrt (a : A) (ha_unit : IsUnit a) (ha : 0 β€ a := by cfc_tac) :
IsUnit (sqrt a) :=
(isUnit_sqrt_iff a ha).mpr ha_unit
@[aesop safe apply]
lemma _root_.IsStrictlyPositive.nnrpow {a : A} {y : ββ₯0} (ha : IsStrictlyPositive a) (hy : y β 0) :
IsStrictlyPositive (a ^ y) := by grind
@[aesop safe apply]
lemma _root_.IsStrictlyPositive.sqrt {a : A} (ha : IsStrictlyPositive a) :
IsStrictlyPositive (sqrt a) := by grind
omit [T2Space A] [IsTopologicalRing A] in
@[aesop safe apply]
lemma _root_.IsStrictlyPositive.rpow {a : A} {y : β} (ha : IsStrictlyPositive a) :
IsStrictlyPositive (a ^ y) := by grind
/-- For an element `a` in a Cβ-algebra, TFAE:
1. `a` is strictly positive,
2. `sqrt a` is strictly positive and `a = sqrt a * sqrt a`,
3. `sqrt a` is invertible and `a = sqrt a * sqrt a`,
4. `a = b * b` for some strictly positive `b`,
5. `a = b * b` for some self-adjoint and invertible `b`,
6. `a = star b * b` for some invertible `b`,
7. `a = b * star b` for some invertible `b`,
8. `0 β€ a` and `a` is invertible,
9. `a` is self-adjoint and has positive spectrum. -/
theorem _root_.CStarAlgebra.isStrictlyPositive_TFAE {a : A} :
[IsStrictlyPositive a,
IsStrictlyPositive (sqrt a) β§ a = sqrt a * sqrt a,
IsUnit (sqrt a) β§ a = sqrt a * sqrt a,
β b, IsStrictlyPositive b β§ a = b * b,
β b, IsUnit b β§ IsSelfAdjoint b β§ a = b * b,
β b, IsUnit b β§ a = star b * b,
β b, IsUnit b β§ a = b * star b,
0 β€ a β§ IsUnit a,
IsSelfAdjoint a β§ β x β spectrum β a, 0 < x].TFAE := by
tfae_have 1 β 8 := IsStrictlyPositive.iff_of_unital
tfae_have 1 β 9 := β¨fun h => β¨h.isSelfAdjoint,
StarOrderedRing.isStrictlyPositive_iff_spectrum_pos a |>.mp hβ©,
fun h => (StarOrderedRing.isStrictlyPositive_iff_spectrum_pos a).mpr h.2β©
tfae_have 1 β 2 := fun h => β¨h.sqrt, sqrt_mul_sqrt_self a |>.symmβ©
tfae_have 2 β 3 := fun h => β¨h.1.isUnit, h.2β©
tfae_have 3 β 4 := fun h => β¨sqrt a, h.1.isStrictlyPositive (sqrt_nonneg _), h.2β©
tfae_have 4 β 5 := fun β¨b, hb, habβ© => β¨b, hb.isUnit, hb.isSelfAdjoint, habβ©
tfae_have 5 β 6 := fun β¨b, hb, hbsa, habβ© => β¨b, hb, hbsa.symm βΈ habβ©
tfae_have 6 β 7 := fun β¨b, hb, habβ© => β¨star b, hb.star, star_star b |>.symm βΈ habβ©
tfae_have 7 β 8 := fun β¨b, hb, habβ© => β¨hab βΈ mul_star_self_nonneg _, hab βΈ hb.mul hb.starβ©
tfae_finish
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_isStrictlyPositive_sqrt_and_eq_sqrt_mul_sqrt
{a : A} : IsStrictlyPositive a β IsStrictlyPositive (sqrt a) β§ a = sqrt a * sqrt a :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 1
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_isUnit_sqrt_and_eq_sqrt_mul_sqrt
{a : A} : IsStrictlyPositive a β IsUnit (sqrt a) β§ a = sqrt a * sqrt a :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 2
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_exists_isStrictlyPositive_and_eq_mul_self
{a : A} : IsStrictlyPositive a β β b, IsStrictlyPositive b β§ a = b * b :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 3
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_exists_isUnit_and_isSelfAdjoint_and_eq_mul_self
{a : A} : IsStrictlyPositive a β β b, IsUnit b β§ IsSelfAdjoint b β§ a = b * b :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 4
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_eq_star_mul_self
{a : A} : IsStrictlyPositive a β β b, IsUnit b β§ a = star b * b :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 5
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_eq_mul_star_self
{a : A} : IsStrictlyPositive a β β b, IsUnit b β§ a = b * star b :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 6
theorem _root_.CStarAlgebra.isStrictlyPositive_iff_isSelfAdjoint_and_spectrum_pos
{a : A} : IsStrictlyPositive a β IsSelfAdjoint a β§ β x β spectrum β a, 0 < x :=
CStarAlgebra.isStrictlyPositive_TFAE.out 0 8
end unital_vs_nonunital
end Unital
end CFC |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/IntegralRepresentation.lean | import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Integral
import Mathlib.Analysis.CStarAlgebra.ApproximateUnit
/-!
# Integral representations of `rpow`
This file contains an integral representation of the `rpow` function between 0 and 1: we show
that there exists a measure on β such that `x ^ p = β« t, rpowIntegrandββ p t x βΞΌ` for
the integrand `rpowIntegrandββ p t x := t ^ p * (tβ»ΒΉ - (t + x)β»ΒΉ)`.
This representation is useful for showing that `rpow` is operator monotone and operator concave
in this range; that is, `cfc rpow` is monotone/concave. The integrand can be shown to be
operator monotone and concave through direct means, and this integral lifts these properties
to `rpow`.
## Notes
Here we only compute the integral up to a constant, even though the actual constant can be
computed via contour integration. We chose to avoid this, as the constant is seldom if ever
relevant in applications, and would needlessly complicate the proof.
## Main declarations
+ `rpowIntegrandββ p t x := t ^ p * (tβ»ΒΉ - (t + x)β»ΒΉ)`
+ `exists_measure_rpow_eq_integral`: there exists a measure on `β` such that
`x ^ p = β« t, rpowIntegrandββ p t x βΞΌ`
+ `CFC.exists_measure_nnrpow_eq_integral_cfcβ_rpowIntegrandββ`: the corresponding statement where
`x ^ p` is defined via the CFC.
+ `CFC.monotone_nnrpow`, `CFC.monotone_rpow`: `a β¦ a ^ p` is operator monotone for `p β [0,1]`
+ `CFC.monotone_sqrt`: `CFC.sqrt` is operator monotone
## TODO
+ Show operator concavity of `rpow` over `Icc 0 1`
+ Give analogous representations for the ranges `Ioo (-1) 0` and `Ioo 1 2`.
## References
+ [carlen2010] Eric A. Carlen, "Trace inequalities and quantum entropies: An introductory course"
(see Lemma 2.8)
-/
open MeasureTheory Set Filter
open scoped NNReal Topology
namespace Real
/-- Integrand for representing `x β¦ x ^ p` for `p β (0,1)` -/
noncomputable def rpowIntegrandββ (p t x : β) : β := t ^ p * (tβ»ΒΉ - (t + x)β»ΒΉ)
variable {p t x : β}
@[simp]
lemma rpowIntegrandββ_zero_right : rpowIntegrandββ p t 0 = 0 := by simp [rpowIntegrandββ]
lemma rpowIntegrandββ_zero_left (hp : 0 < p) : rpowIntegrandββ p 0 x = 0 := by
simp [rpowIntegrandββ, Real.zero_rpow hp.ne']
lemma rpowIntegrandββ_nonneg (hp : 0 < p) (ht : 0 β€ t) (hx : 0 β€ x) :
0 β€ rpowIntegrandββ p t x := by
unfold rpowIntegrandββ
cases eq_or_lt_of_le' ht with
| inl ht_zero => simp [ht_zero, Real.zero_rpow (ne_of_gt hp)]
| inr ht_pos =>
refine mul_nonneg (by positivity) ?_
rw [sub_nonneg]
gcongr
linarith
lemma rpowIntegrandββ_eq_pow_div (hp : p β Ioo 0 1) (ht : 0 β€ t) (hx : 0 β€ x) :
rpowIntegrandββ p t x = t ^ (p - 1) * x / (t + x) := by
by_cases ht' : t = 0
case neg =>
have hxt : t + x β 0 := by positivity
calc _ = (t : β) ^ p * (tβ»ΒΉ - (t + x)β»ΒΉ) := rfl
_ = (t : β) ^ p * ((t + x - t) / (t * (t + x))) := by
simp only [inv_eq_one_div]
rw [div_sub_div _ _ (by cutsat) (by cutsat)]
simp
_ = t ^ p / t * x / (t + x) := by simp [field]
_ = t ^ (p - 1) * x / (t + x) := by congr; exact (Real.rpow_sub_one ht' p).symm
case pos =>
simp only [mem_Ioo] at hp
have hpβ : p - 1 β 0 := by linarith
simp [rpowIntegrandββ, ht', hp.1.ne', hpβ]
lemma rpowIntegrandββ_eqOn_pow_div (hp : p β Ioo 0 1) (hx : 0 β€ x) :
Set.EqOn (rpowIntegrandββ p Β· x) (fun t => t ^ (p - 1) * x / (t + x)) (Ioi 0) := by
intro t ht
simp [rpowIntegrandββ_eq_pow_div hp (le_of_lt ht) hx]
lemma rpowIntegrandββ_apply_mul (hp : p β Ioo 0 1) (ht : 0 β€ t) (hx : 0 β€ x) :
rpowIntegrandββ p (x * t) x = (rpowIntegrandββ p t 1) * x ^ (p - 1) := by
have hxt : 0 β€ x * t := by positivity
rw [rpowIntegrandββ_eq_pow_div hp hxt hx, rpowIntegrandββ_eq_pow_div hp ht zero_le_one]
by_cases hx_zero : x = 0
case neg =>
calc _ = x ^ (p - 1) * (t ^ (p - 1) * (x / (x * t + x))) := by
rw [β mul_assoc, mul_div_assoc, Real.mul_rpow hx ht]
_ = x ^ (p - 1) * (t ^ (p - 1) * 1 / (t + 1)) := by
have : x * t + x = x * (t + 1) := by ring
rw [mul_div_assoc, this, div_mul_eq_div_mul_one_div, div_self hx_zero, one_mul]
_ = t ^ (p - 1) * 1 / (t + 1) * x ^ (p - 1) := by rw [mul_comm]
case pos =>
rw [mem_Ioo] at hp
simp [hx_zero, Real.zero_rpow (by linarith : p - 1 β 0)]
lemma rpowIntegrandββ_apply_mul' (hp : p β Ioo 0 1) (ht : 0 β€ t) (hx : 0 β€ x) :
rpowIntegrandββ p (x * t) x * x = (rpowIntegrandββ p t 1) * x ^ p := by
simp only [rpowIntegrandββ_apply_mul hp ht hx, mul_assoc]
congr
simpa using Eq.symm <| Real.rpow_add' hx (by aesop : (p - 1) + 1 β 0)
lemma rpowIntegrandββ_apply_mul_eqOn_Ici (hp : p β Ioo 0 1) (hx : 0 β€ x) :
(Ici 0).EqOn (fun t => rpowIntegrandββ p (x * t) x * x)
(fun t => (rpowIntegrandββ p t 1) * x ^ p) :=
fun _ ht => rpowIntegrandββ_apply_mul' hp ht hx
lemma continuousOn_rpowIntegrandββ (hp : p β Ioo 0 1) (hx : 0 β€ x) :
ContinuousOn (rpowIntegrandββ p Β· x) (Ioi 0) := by
refine ContinuousOn.congr ?_ <| rpowIntegrandββ_eqOn_pow_div hp hx
have hβ : ContinuousOn (Β· ^ (p - 1) : β β β) (Ioi 0) := .rpow_const (by fun_prop) <|
fun t ht => .inl ht.ne'
fun_prop (disch := intros; simp_all; positivity)
lemma aestronglyMeasurable_rpowIntegrandββ (hp : p β Ioo 0 1) (hx : 0 β€ x) :
AEStronglyMeasurable (rpowIntegrandββ p Β· x) (volume.restrict (Ioi 0)) :=
(continuousOn_rpowIntegrandββ hp hx).aestronglyMeasurable measurableSet_Ioi
lemma rpowIntegrandββ_monotoneOn (hp : p β Ioo 0 1) (ht : 0 β€ t) :
MonotoneOn (rpowIntegrandββ p t) (Ici 0) := by
intro x hx y hy hxy
by_cases h : x = 0
case pos => simpa [h, rpowIntegrandββ] using rpowIntegrandββ_nonneg hp.1 ht hy
case neg =>
simp only [rpowIntegrandββ, mem_Ici] at hx h β’
gcongr
lemma continuousOn_rpowIntegrandββ_uncurry (hp : p β Ioo 0 1) (s : Set β) (hs : s β Ici 0) :
ContinuousOn (rpowIntegrandββ p).uncurry (Ioi 0 ΓΛ’ s) := by
let g : β Γ β β β := fun q => q.1 ^ (p - 1) * q.2 / (q.1 + q.2)
refine ContinuousOn.congr (f := g) ?_ fun q => ?_
Β· simp only [g]
refine ContinuousOn.mul ?_ ?_
Β· refine ContinuousOn.mul ?_ (by fun_prop)
exact ContinuousOn.rpow_const (by fun_prop) (by grind)
Β· exact ContinuousOn.invβ (by fun_prop) (by grind)
Β· intro hq
simp [Function.uncurry, g, rpowIntegrandββ_eq_pow_div hp (le_of_lt hq.1) (hs hq.2)]
lemma continuousOn_rpowIntegrandββ_Ici (hp : p β Ioo 0 1) (ht : 0 < t) :
ContinuousOn (rpowIntegrandββ p t) (Ici 0) :=
(continuousOn_rpowIntegrandββ_uncurry hp _ fun _ a => a).uncurry_left _ ht
lemma rpowIntegrandββ_le_rpow_sub_two_mul_self (hp : p β Ioo 0 1) (ht : 0 < t) (hx : 0 β€ x) :
rpowIntegrandββ p t x β€ t ^ (p - 2) * x := calc
_ = t ^ (p - 1) * x / (t + x) := by rw [rpowIntegrandββ_eq_pow_div hp (le_of_lt ht) hx]
_ β€ t ^ (p - 1) * x / t := by gcongr; linarith
_ = t ^ (p - 1) / t * x := by ring
_ = t ^ (p - 2) * x := by
congr
rw [β Real.rpow_sub_one (by positivity)]
congr 1
ring
lemma rpowIntegrandββ_le_rpow_sub_one (hp : p β Ioo 0 1) (ht : 0 β€ t) (hx : 0 β€ x) :
rpowIntegrandββ p t x β€ t ^ (p - 1) := by
by_cases hx_zero : x = 0
case pos =>
simp only [rpowIntegrandββ, hx_zero, add_zero, sub_self, mul_zero]
positivity
case neg =>
calc
_ = t ^ (p - 1) * x / (t + x) := by rw [rpowIntegrandββ_eq_pow_div hp ht hx]
_ β€ t ^ (p - 1) * x / x := by gcongr; linarith
_ = t ^ (p - 1) * (x / x) := by ring
_ = t ^ (p - 1) * 1 := by congr; exact (div_eq_one_iff_eq hx_zero).mpr rfl
_ = _ := by simp
lemma rpowIntegrandββ_one_ge_rpow_sub_two (hp : p β Ioo 0 1) (ht : 1 β€ t) :
(1 : β) / 2 * t ^ (p - 2) β€ rpowIntegrandββ p t 1 := calc
_ = t ^ (p - 1) * (1 / 2 * 1 / t) := by
have : p - 2 = p - 1 - 1 := by ring
rw [this, Real.rpow_sub (by linarith), Real.rpow_one]
ring
_ β€ t ^ (p - 1) * (1 / (t + 1)) := by
gcongr t ^ (p - 1) * ?_
rw [mul_div_assoc, one_div_mul_one_div,
one_div_le_one_div (by positivity) (by positivity)]
linarith
_ = rpowIntegrandββ p t 1 := by
rw [rpowIntegrandββ_eq_pow_div hp (by linarith) zero_le_one, mul_div_assoc]
lemma rpowIntegrandββ_eqOn_mul_rpowIntegrandββ_one (ht : 0 < t) :
(Ici 0).EqOn (rpowIntegrandββ p t)
(fun x => t ^ (p - 1) * (rpowIntegrandββ p 1 (tβ»ΒΉ β’ x))) := by
intro x hx
calc _ = t ^ p * (tβ»ΒΉ - tβ»ΒΉ * (1 + x * tβ»ΒΉ)β»ΒΉ) := by simp [field, rpowIntegrandββ]
_ = t ^ (p - 1) * (1 - (1 + x * tβ»ΒΉ)β»ΒΉ) := by
rw [Real.rpow_sub_one ht.ne']
ring
_ = _ := by simp [mul_comm, smul_eq_mul, rpowIntegrandββ]
/- This lemma is private because it is strictly weaker than `integrableOn_rpowIntegrandββ_Ioi` -/
private lemma integrableOn_rpowIntegrandββ_Ioc (hp : p β Ioo 0 1) (hx : 0 β€ x) :
IntegrableOn (rpowIntegrandββ p Β· x) (Ioc 0 1) := by
refine IntegrableOn.congr_set_ae (t := Ioo 0 1) ?_ (Filter.EventuallyEq.symm Ioo_ae_eq_Ioc)
refine β¨?meas, ?finiteβ©
case meas =>
refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_Ioo
exact ContinuousOn.mono (continuousOn_rpowIntegrandββ hp hx) Ioo_subset_Ioi_self
case finite =>
refine HasFiniteIntegral.mono' (g := fun t => t ^ (p - 1)) ?finitebound ?ae_le
case finitebound =>
apply Integrable.hasFiniteIntegral
rw [Set.mem_Ioo] at hp
rw [β IntegrableOn, intervalIntegral.integrableOn_Ioo_rpow_iff]
Β· linarith
Β· exact zero_lt_one
case ae_le =>
refine ae_restrict_of_forall_mem measurableSet_Ioo fun t ht => ?_
rw [Real.norm_of_nonneg (rpowIntegrandββ_nonneg hp.1 (le_of_lt ht.1) hx)]
exact rpowIntegrandββ_le_rpow_sub_one hp (le_of_lt ht.1) hx
/- This lemma is private because it is strictly weaker than `integrableOn_rpowIntegrandββ_Ioi` -/
private lemma integrableOn_rpowIntegrandββ_Ioi_one (hp : p β Ioo 0 1) (hx : 0 β€ x) :
IntegrableOn (rpowIntegrandββ p Β· x) (Ioi 1) := by
refine β¨?meas, ?finiteβ©
case meas =>
refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_Ioi
exact continuousOn_rpowIntegrandββ hp hx |>.mono (Set.Ioi_subset_Ioi zero_le_one)
case finite =>
refine HasFiniteIntegral.mono' (g := fun t => t ^ (p - 2) * x) ?finitebound ?ae_le
case finitebound =>
refine HasFiniteIntegral.mul_const ?_ _
apply Integrable.hasFiniteIntegral
rw [Set.mem_Ioo] at hp
refine integrableOn_Ioi_rpow_of_lt ?_ zero_lt_one
linarith
case ae_le =>
refine ae_restrict_of_forall_mem measurableSet_Ioi fun t (ht : 1 < t) => ?_
rw [Real.norm_of_nonneg (rpowIntegrandββ_nonneg hp.1 (by positivity) hx)]
exact rpowIntegrandββ_le_rpow_sub_two_mul_self hp (by positivity) hx
lemma integrableOn_rpowIntegrandββ_Ioi (hp : p β Ioo 0 1) (hx : 0 β€ x) :
IntegrableOn (rpowIntegrandββ p Β· x) (Ioi 0) := by
/- The integral converges because it is `O(t ^ (p-1))` at the origin and `O(t ^ (p-2))` at
infinity. Hence we break the integral into two parts. -/
rw [β Set.Ioc_union_Ioi_eq_Ioi zero_le_one]
exact IntegrableOn.union (integrableOn_rpowIntegrandββ_Ioc hp hx)
(integrableOn_rpowIntegrandββ_Ioi_one hp hx)
lemma integrableOn_rpowIntegrandββ_Ici (hp : p β Ioo 0 1) (hx : 0 β€ x) :
IntegrableOn (rpowIntegrandββ p Β· x) (Ici 0) :=
integrableOn_rpowIntegrandββ_Ioi hp hx |>.congr_set_ae Ioi_ae_eq_Ici.symm
lemma integral_rpowIntegrandββ_eq_rpow_mul_const (hp : p β Ioo 0 1) (hx : 0 β€ x) :
(β« t in Ioi 0, rpowIntegrandββ p t x) = x ^ p * (β« t in Ioi 0, rpowIntegrandββ p t 1) := by
-- We use the change of variables formula with `f t = x * t`. Here `g = rpowIntegrandββ p Β· x`.
obtain (rfl | hx) := hx.eq_or_lt
Β· simp [rpowIntegrandββ, Real.zero_rpow hp.1.ne']
suffices β« t in Ioi 0, ((rpowIntegrandββ p Β· x) β (x * Β·)) t * x =
x ^ p * (β« t in Ioi 0, rpowIntegrandββ p t 1) by
rwa [integral_comp_mul_deriv_Ioi (by fun_prop), mul_zero] at this
Β· exact tendsto_id.const_mul_atTop hx
Β· simpa using fun t _ β¦ hasDerivWithinAt_id t (Ioi t) |>.const_mul x
Β· simpa [Set.image_mul_left_Ioi hx] using continuousOn_rpowIntegrandββ hp hx.le
Β· simpa [Set.image_mul_left_Ici hx] using integrableOn_rpowIntegrandββ_Ici hp hx.le
Β· simp only [Function.comp]
rw [integrableOn_congr_fun (rpowIntegrandββ_apply_mul_eqOn_Ici hp hx.le) measurableSet_Ici]
exact Integrable.mul_const (integrableOn_rpowIntegrandββ_Ici hp zero_le_one) _
have heqOn : EqOn (fun t => rpowIntegrandββ p (x * t) x * x)
(fun t => (rpowIntegrandββ p t 1) * x ^ p) (Ioi 0) :=
EqOn.mono Ioi_subset_Ici_self (rpowIntegrandββ_apply_mul_eqOn_Ici hp hx.le)
simp only [Function.comp, setIntegral_congr_fun measurableSet_Ioi heqOn,
β smul_eq_mul (b := x ^ p), integral_smul_const]
rw [smul_eq_mul, mul_comm]
lemma le_integral_rpowIntegrandββ_one (hp : p β Ioo 0 1) :
-1 / (2 * (p - 1)) β€ β« t in Ioi 0, rpowIntegrandββ p t 1 := calc
_ = (1 / 2) * -((1 : β) ^ (p - 1)) / (p - 1) := by rw [β div_div]; simp [neg_div]
_ = β« t in Ioi 1, (1 / 2) * t ^ (p - 2) := by
simp only [mem_Ioo] at hp
rw [integral_const_mul, integral_Ioi_rpow_of_lt (by linarith) zero_lt_one]
ring_nf -- ring alone succeeds but gives a warning
_ β€ β« t in Ioi 1, rpowIntegrandββ p t 1 := by
refine setIntegral_mono_on ?_ ?_ measurableSet_Ioi ?_
Β· refine Integrable.const_mul ?_ _
simp only [mem_Ioo] at hp
exact integrableOn_Ioi_rpow_of_lt (by linarith) zero_lt_one
Β· exact integrableOn_rpowIntegrandββ_Ioi_one hp zero_le_one
Β· exact fun t ht => rpowIntegrandββ_one_ge_rpow_sub_two hp (le_of_lt ht)
_ β€ β« t in Ioi 0, rpowIntegrandββ p t 1 := by
refine setIntegral_mono_set (integrableOn_rpowIntegrandββ_Ioi hp zero_le_one) ?_ ?_
Β· refine ae_restrict_of_forall_mem measurableSet_Ioi fun t ht => ?_
exact rpowIntegrandββ_nonneg hp.1 (le_of_lt ht) zero_le_one
Β· exact .of_forall <| Set.Ioi_subset_Ioi zero_le_one
lemma integral_rpowIntegrandββ_one_pos (hp : p β Ioo 0 1) :
0 < β« t in Ioi 0, rpowIntegrandββ p t 1 := calc
0 < -1 / (2 * (p - 1)) := by
rw [neg_div, neg_pos, one_div_neg]
simp only [mem_Ioo] at hp
linarith
_ β€ β« t in Ioi 0, rpowIntegrandββ p t 1 := le_integral_rpowIntegrandββ_one hp
/-- The integral representation of the function `x β¦ x^p` (where `p β (0, 1)`) . -/
lemma rpow_eq_const_mul_integral (hp : p β Ioo 0 1) (hx : 0 β€ x) :
x ^ p = (β« t in Ioi 0, rpowIntegrandββ p t 1)β»ΒΉ * β« t in Ioi 0, rpowIntegrandββ p t x := by
rcases eq_or_lt_of_le' hx with hx_zero|_
case inl =>
simp only [mem_Ioo] at hp
simp [hx_zero, Real.zero_rpow (by linarith)]
case inr =>
have : β« t in Ioi 0, rpowIntegrandββ p t 1 β 0 :=
ne_of_gt <| integral_rpowIntegrandββ_one_pos hp
rw [integral_rpowIntegrandββ_eq_rpow_mul_const hp hx, mul_comm, mul_assoc, mul_inv_cancelβ
this, mul_one]
/-- The integral representation of the function `x β¦ x ^ p` (where `p β (0, 1)`) . -/
lemma exists_measure_rpow_eq_integral (hp : p β Ioo 0 1) :
β ΞΌ : Measure β, β x β Ici 0,
(IntegrableOn (fun t => rpowIntegrandββ p t x) (Ioi 0) ΞΌ)
β§ x ^ p = β« t in Ioi 0, rpowIntegrandββ p t x βΞΌ := by
let C : ββ₯0 :=
{ val := (β« t in Ioi 0, rpowIntegrandββ p t 1)β»ΒΉ
property := by
rw [inv_nonneg]
exact le_of_lt <| integral_rpowIntegrandββ_one_pos hp }
refine β¨C β’ volume, fun x hx => β¨?_, ?_β©β©
Β· unfold IntegrableOn
rw [Measure.restrict_smul]
exact Integrable.smul_measure_nnreal <| integrableOn_rpowIntegrandββ_Ioi hp hx
Β· simp_rw [Measure.restrict_smul, integral_smul_nnreal_measure, rpow_eq_const_mul_integral hp hx,
NNReal.smul_def, C, NNReal.coe_mk, smul_eq_mul]
end Real
namespace CFC
open Real
section NonUnitalCFC
variable {A : Type*} [NonUnitalNormedRing A] [StarRing A] [NormedSpace β A] [SMulCommClass β A A]
[IsScalarTower β A A] [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass β A]
[NonUnitalContinuousFunctionalCalculus β A IsSelfAdjoint]
lemma cfcβ_rpowIntegrandββ_eq_cfcβ_rpowIntegrandββ_one {p t : β} (hp : p β Ioo 0 1) (ht : 0 < t)
(a : A) (ha : 0 β€ a) :
cfcβ (rpowIntegrandββ p t) a = t ^ (p - 1) β’ cfcβ (rpowIntegrandββ p 1) (tβ»ΒΉ β’ a) := by
have hspec : quasispectrum β a β Ici 0 := by intro; grind
have h_mapsTo : MapsTo (tβ»ΒΉ β’ Β· : β β β) (Ici 0) (Ici 0) := by
intro x hx
simp only [mem_Ici, smul_eq_mul] at hx β’
positivity
calc _ = cfcβ (fun x => t ^ ((p : β) - 1) * (rpowIntegrandββ p 1 (tβ»ΒΉ β’ x))) a := by
refine cfcβ_congr ?_
refine Set.EqOn.mono hspec (rpowIntegrandββ_eqOn_mul_rpowIntegrandββ_one ht)
_ = t ^ ((p : β) - 1) β’ cfcβ (fun x => rpowIntegrandββ p 1 (tβ»ΒΉ β’ x)) a := by
refine cfcβ_smul (R := β) (t ^ ((p : β) - 1)) _ a ?_
refine ContinuousOn.mono ?_ hspec
have := continuousOn_rpowIntegrandββ_Ici hp zero_lt_one
fun_prop (disch := assumption)
_ = t ^ ((p : β) - 1) β’ cfcβ (rpowIntegrandββ p 1) (tβ»ΒΉ β’ a) := by
congr! 1
refine cfcβ_comp_smul (R := β) tβ»ΒΉ (fun x => rpowIntegrandββ p 1 x) a ?_
exact continuousOn_rpowIntegrandββ_Ici hp zero_lt_one |>.mono <|
(h_mapsTo.mono_left hspec).image_subset
variable (A) in
/-- The integral representation of the function `x β¦ x ^ p` (where `p β (0, 1)`). -/
lemma exists_measure_nnrpow_eq_integral_cfcβ_rpowIntegrandββ [CompleteSpace A] {p : ββ₯0}
(hp : p β Ioo 0 1) :
β ΞΌ : Measure β, β a β Ici (0 : A),
(IntegrableOn (fun t => cfcβ (rpowIntegrandββ p t) a) (Ioi 0) ΞΌ)
β§ a ^ p = β« t in Ioi 0, cfcβ (rpowIntegrandββ p t) a βΞΌ := by
obtain β¨ΞΌ, hΞΌβ© := exists_measure_rpow_eq_integral hp
refine β¨ΞΌ, fun a (ha : 0 β€ a) => ?_β©
nontriviality A
have p_pos : 0 < (p : β) := by exact_mod_cast hp.1
let f t := rpowIntegrandββ p t
let maxr := sSup (quasispectrum β a)
have maxr_nonneg : 0 β€ maxr :=
le_csSup_of_le (b := 0) (IsCompact.bddAbove (by grind)) (by simp) (by simp)
let bound (t : β) := βf t maxrβ
have hf : ContinuousOn (Function.uncurry f) (Ioi (0 : β) ΓΛ’ quasispectrum β a) := by
refine continuousOn_rpowIntegrandββ_uncurry hp (quasispectrum β a) ?_
grind
have hbound : βα΅ t βΞΌ.restrict (Ioi 0), β z β quasispectrum β a, βf t zβ β€ bound t := by
filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht
intro z hz
have hz' : 0 β€ z := by grind
unfold bound f
rw [Real.norm_of_nonneg (rpowIntegrandββ_nonneg p_pos (le_of_lt ht) hz'),
Real.norm_of_nonneg (rpowIntegrandββ_nonneg p_pos (le_of_lt ht) maxr_nonneg)]
refine rpowIntegrandββ_monotoneOn hp (le_of_lt ht) hz' maxr_nonneg ?_
exact le_csSup (IsCompact.bddAbove (quasispectrum.isCompact _)) hz
have hbound_finite_integral : HasFiniteIntegral bound (ΞΌ.restrict (Ioi 0)) := by
rw [hasFiniteIntegral_norm_iff]
exact (hΞΌ maxr maxr_nonneg).1.2
have hmapzero : βα΅ (x : β) βΞΌ.restrict (Ioi 0), rpowIntegrandββ p x 0 = 0 := by
filter_upwards [ae_restrict_mem measurableSet_Ioi]
simp
refine β¨?integrable, ?integralβ©
case integrable =>
exact integrableOn_cfcβ measurableSet_Ioi _ bound a hf hmapzero hbound hbound_finite_integral
case integral => calc
a ^ p = cfcβ (fun r => β« t in Ioi 0, rpowIntegrandββ p t r βΞΌ) a := by
rw [nnrpow_eq_cfcβ_real _ _]
exact cfcβ_congr fun r _ β¦ (hΞΌ r (by grind)).2
_ = _ := cfcβ_setIntegral measurableSet_Ioi _ bound a hf hmapzero hbound
hbound_finite_integral ha.isSelfAdjoint
end NonUnitalCFC
section NonUnitalCStarAlgebra
variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
/-- `rpowIntegrandββ p t` is operator monotone for all `p β Ioo 0 1` and all `t β Ioi 0`. -/
lemma monotoneOn_cfcβ_rpowIntegrandββ {p : β} {t : β} (hp : p β Ioo 0 1) (ht : 0 < t) :
MonotoneOn (cfcβ (rpowIntegrandββ p t)) (Ici (0 : A)) := by
intro a (ha : 0 β€ a) b (hb : 0 β€ b) hab
calc
_ = t ^ ((p : β) - 1) β’ cfcβ (rpowIntegrandββ p 1) (tβ»ΒΉ β’ a) := by
rw [cfcβ_rpowIntegrandββ_eq_cfcβ_rpowIntegrandββ_one hp ht a ha]
_ β€ t ^ ((p : β) - 1) β’ cfcβ (rpowIntegrandββ p 1) (tβ»ΒΉ β’ b) := by
gcongr
unfold rpowIntegrandββ
simp only [Real.one_rpow, one_mul, inv_one]
refine CFC.monotoneOn_one_sub_one_add_inv_real
(?_ : 0 β€ tβ»ΒΉ β’ a) (?_ : 0 β€ tβ»ΒΉ β’ b) (by gcongr)
all_goals positivity
_ = cfcβ (rpowIntegrandββ p t) b := by
rw [cfcβ_rpowIntegrandββ_eq_cfcβ_rpowIntegrandββ_one hp ht b hb]
/-- This is an intermediate result; use the more general `CFC.monotone_nnrpow` instead. -/
private lemma monotoneOn_nnrpow_Ioo {p : ββ₯0} (hp : p β Ioo 0 1) :
MonotoneOn (fun a : A => a ^ p) (Ici 0) := by
obtain β¨ΞΌ, hΞΌβ© := exists_measure_nnrpow_eq_integral_cfcβ_rpowIntegrandββ A hp
have hβ' : (Ici 0).EqOn (fun a : A => a ^ p)
(fun a : A => β« t in Ioi 0, cfcβ (rpowIntegrandββ p t) a βΞΌ) :=
fun a ha => (hΞΌ a ha).2
refine MonotoneOn.congr ?_ hβ'.symm
refine integral_monotoneOn_of_integrand_ae ?_ fun a ha => (hΞΌ a ha).1
filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht
exact monotoneOn_cfcβ_rpowIntegrandββ hp ht
/-- `a β¦ a ^ p` is operator monotone for `p β [0,1]`. -/
lemma monotone_nnrpow {p : ββ₯0} (hp : p β Icc 0 1) :
Monotone (fun a : A => a ^ p) := by
intro a b hab
by_cases ha : 0 β€ a
Β· have hb : 0 β€ b := ha.trans hab
have hIcc : Icc (0 : ββ₯0) 1 = Ioo 0 1 βͺ {0} βͺ {1} := by ext; simp
rw [hIcc] at hp
obtain (hp|hp)|hp := hp
Β· exact monotoneOn_nnrpow_Ioo hp ha hb hab
Β· simp_all [mem_singleton_iff]
Β· simp_all [mem_singleton_iff, nnrpow_one a, nnrpow_one b]
Β· have : a ^ p = 0 := cfcβ_apply_of_not_predicate a ha
simp [this]
/-- `CFC.sqrt` is operator monotone. -/
lemma monotone_sqrt : Monotone (sqrt : A β A) := by
intro a b hab
rw [CFC.sqrt_eq_nnrpow a, CFC.sqrt_eq_nnrpow b]
refine (monotone_nnrpow (A := A) ?_) hab
constructor <;> norm_num
@[gcongr]
lemma nnrpow_le_nnrpow {p : ββ₯0} (hp : p β Icc 0 1) {a b : A} (hab : a β€ b) :
a ^ p β€ b ^ p := monotone_nnrpow hp hab
@[gcongr]
lemma sqrt_le_sqrt (a b : A) (hab : a β€ b) : sqrt a β€ sqrt b :=
monotone_sqrt hab
end NonUnitalCStarAlgebra
section UnitalCStarAlgebra
variable {A : Type*} [CStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
/-- `a β¦ a ^ p` is operator monotone for `p β [0,1]`. -/
lemma monotone_rpow {p : β} (hp : p β Icc 0 1) : Monotone (fun a : A => a ^ p) := by
let q : ββ₯0 := β¨p, hp.1β©
change Monotone (fun a : A => a ^ (q : β))
cases (zero_le q).lt_or_eq' with
| inl hq =>
simp_rw [β CFC.nnrpow_eq_rpow hq]
exact monotone_nnrpow hp
| inr hq =>
simp only [hq, NNReal.coe_zero]
intro a b hab
by_cases ha : 0 β€ a
Β· have hb : 0 β€ b := ha.trans hab
simp [CFC.rpow_zero a, CFC.rpow_zero b]
Β· have : a ^ (0 : β) = 0 := cfc_apply_of_not_predicate a ha
simp [this]
@[gcongr]
lemma rpow_le_rpow {p : β} (hp : p β Icc 0 1) {a b : A} (hab : a β€ b) :
a ^ p β€ b ^ p := monotone_rpow hp hab
end UnitalCStarAlgebra
end CFC |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/Summable.lean | import Mathlib.Analysis.SpecialFunctions.Complex.LogBounds
import Mathlib.Topology.Algebra.InfiniteSum.Field
/-!
# Summability of logarithms
We give conditions under which the logarithms of a summble sequence is summable. We also use this
to relate summability of `f` to multipliability of `1 + f`.
-/
variable {ΞΉ : Type*}
open Filter Topology NNReal SummationFilter
namespace Complex
variable {f : ΞΉ β β} {a : β}
lemma hasProd_of_hasSum_log (hfn : β i, f i β 0) (hf : HasSum (fun i β¦ log (f i)) a) :
HasProd f (exp a) :=
hf.cexp.congr (by simp [exp_log, hfn])
lemma multipliable_of_summable_log (hf : Summable fun i β¦ log (f i)) :
Multipliable f := by
by_cases! hfn : β n, f n = 0
Β· exact multipliable_of_exists_eq_zero hfn
Β· exact β¨_, hasProd_of_hasSum_log hfn hf.hasSumβ©
/-- The exponential of a convergent sum of complex logs is the corresponding infinite product. -/
lemma cexp_tsum_eq_tprod (hfn : β i, f i β 0) (hf : Summable fun i β¦ log (f i)) :
cexp (β' i, log (f i)) = β' i, f i :=
(hasProd_of_hasSum_log hfn hf.hasSum).tprod_eq.symm
lemma summable_log_one_add_of_summable {f : ΞΉ β β} (hf : Summable f) :
Summable (fun i β¦ log (1 + f i)) := by
apply (hf.norm.mul_left (3 / 2)).of_norm_bounded_eventually
filter_upwards [hf.norm.tendsto_cofinite_zero.eventually_le_const one_half_pos] with i hi
using norm_log_one_add_half_le_self hi
protected lemma multipliable_one_add_of_summable (hf : Summable f) :
Multipliable (fun i β¦ 1 + f i) :=
multipliable_of_summable_log (summable_log_one_add_of_summable hf)
end Complex
namespace Real
variable {f : ΞΉ β β} {a : β}
lemma hasProd_of_hasSum_log (hfn : β i, 0 < f i) (hf : HasSum (fun i β¦ log (f i)) a) :
HasProd f (rexp a) :=
hf.rexp.congr (by simp [exp_log, hfn])
lemma multipliable_of_summable_log (hfn : β i, 0 < f i) (hf : Summable fun i β¦ log (f i)) :
Multipliable f :=
β¨_, hasProd_of_hasSum_log hfn hf.hasSumβ©
/-- Alternate version of `Real.multipliable_of_summable_log` assuming only that positivity holds
eventually. -/
lemma multipliable_of_summable_log' (hfn : βαΆ i in cofinite, 0 < f i)
(hf : Summable fun i β¦ log (f i)) : Multipliable f := by
have : Summable fun i β¦ log (if 0 < f i then f i else 1) := by
apply hf.congr_cofinite
filter_upwards [hfn] with i hi using by simp [hi]
have : Multipliable fun i β¦ if 0 < f i then f i else 1 := by
refine multipliable_of_summable_log (fun i β¦ ?_) this
split_ifs with h <;> simp [h]
refine this.congr_cofiniteβ (fun i β¦ ?_) ?_
Β· split_ifs with h <;> simp [h, ne_of_gt]
Β· filter_upwards [hfn] with i hi using by simp [hi]
/-- The exponential of a convergent sum of real logs is the corresponding infinite product. -/
lemma rexp_tsum_eq_tprod (hfn : β i, 0 < f i) (hf : Summable fun i β¦ log (f i)) :
rexp (β' i, log (f i)) = β' i, f i :=
(hasProd_of_hasSum_log hfn hf.hasSum).tprod_eq.symm
open Complex in
lemma summable_log_one_add_of_summable (hf : Summable f) :
Summable (fun i β¦ log (1 + f i)) := by
rw [β summable_ofReal]
apply (Complex.summable_log_one_add_of_summable (summable_ofReal.mpr hf)).congr_cofinite
filter_upwards [hf.tendsto_cofinite_zero.eventually_const_le neg_one_lt_zero] with i hi
rw [ofReal_log, ofReal_add, ofReal_one]
linarith
protected lemma multipliable_one_add_of_summable (hf : Summable f) :
Multipliable (fun i β¦ 1 + f i) := by
refine multipliable_of_summable_log' ?_ (summable_log_one_add_of_summable hf)
filter_upwards [hf.tendsto_cofinite_zero.eventually_const_lt neg_one_lt_zero] with i hi
linarith
end Real
section NormedRing
lemma Multipliable.eventually_bounded_finset_prod {v : ΞΉ β β} (hv : Multipliable v) :
β rβ > 0, β sβ, β t, sβ β t β β i β t, v i β€ rβ := by
obtain β¨rβ, hrββ© := exists_gt (max 0 <| β' i, v i)
rw [max_lt_iff] at hrβ
have := hv.hasProd.eventually_le_const hrβ.2
rw [unconditional, eventually_atTop] at this
exact β¨rβ, hrβ.1, thisβ©
variable {R : Type*} [NormedCommRing R] [NormOneClass R] {f : ΞΉ β R}
lemma multipliable_norm_one_add_of_summable_norm (hf : Summable fun i β¦ βf iβ) :
Multipliable fun i β¦ β1 + f iβ := by
conv => enter [1, i]; rw [β sub_add_cancel β1 + f iβ 1, add_comm]
refine Real.multipliable_one_add_of_summable <| hf.of_norm_bounded (fun i β¦ ?_)
simpa using abs_norm_sub_norm_le (1 + f i) 1
lemma Finset.norm_prod_one_add_sub_one_le (t : Finset ΞΉ) (f : ΞΉ β R) :
ββ i β t, (1 + f i) - 1β β€ Real.exp (β i β t, βf iβ) - 1 := by
classical
induction t using Finset.induction_on with
| empty => simp
| insert x t hx IH =>
rw [Finset.prod_insert hx, Finset.sum_insert hx, Real.exp_add,
show (1 + f x) * β i β t, (1 + f i) - 1 =
(β i β t, (1 + f i) - 1) + f x * β x β t, (1 + f x) by ring]
refine (norm_add_le_of_le IH (norm_mul_le _ _)).trans ?_
generalize h : Real.exp (β i β t, βf iβ) = A at β’ IH
rw [sub_add_eq_add_sub, sub_le_sub_iff_right]
transitivity A + βf xβ * A
Β· grw [norm_le_norm_sub_add (β x β t, (1 + f x)) 1, IH, norm_one, sub_add_cancel]
rw [β one_add_mul, add_comm]
exact mul_le_mul_of_nonneg_right (Real.add_one_le_exp _) (h βΈ Real.exp_nonneg _)
lemma prod_vanishing_of_summable_norm (hf : Summable fun i β¦ βf iβ) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) :
β sβ, β t, Disjoint t sβ β ββ i β t, (1 + f i) - 1β < Ξ΅ := by
suffices β s, β t, Disjoint t s β Real.exp (β i β t, βf iβ) - 1 < Ξ΅ from
this.imp fun s hs t ht β¦ (t.norm_prod_one_add_sub_one_le _).trans_lt (hs t ht)
suffices {x | Real.exp x - 1 < Ξ΅} β π 0 from hf.vanishing this
let f (x) := Real.exp x - 1
have : Set.Iio Ξ΅ β nhds (f 0) := by simpa [f] using Iio_mem_nhds hΞ΅
exact ContinuousAt.preimage_mem_nhds (by fun_prop) this
open Finset in
/-- In a complete normed ring, `β' i, (1 + f i)` is convergent if the sum of real numbers
`β' i, βf iβ` is convergent. -/
lemma multipliable_one_add_of_summable [CompleteSpace R]
(hf : Summable fun i β¦ βf iβ) : Multipliable fun i β¦ (1 + f i) := by
classical
refine CompleteSpace.complete <| Metric.cauchy_iff.mpr β¨by infer_instance, fun Ξ΅ hΞ΅ β¦ ?_β©
obtain β¨rβ, hrβ, sβ, hsββ© :=
(multipliable_norm_one_add_of_summable_norm hf).eventually_bounded_finset_prod
obtain β¨sβ, hsββ© := prod_vanishing_of_summable_norm hf (show 0 < Ξ΅ / (2 * rβ) by positivity)
simp only [unconditional, Filter.mem_map, mem_atTop_sets, ge_iff_le, le_eq_subset,
Set.mem_preimage]
let s := sβ βͺ sβ
-- The idea here is that if `s` is a large enough finset, then the product over `s` is bounded
-- by some `r`, and the product over finsets disjoint from `s` is within `Ξ΅ / (2 * r)` of 1.
-- From this it follows that the products over any two finsets containing `s` are within `Ξ΅` of
-- each other.
-- Here `sβ β s` guarantees that the product over `s` is bounded, and `sβ β s` guarantees that
-- the product over terms not in `s` is small.
refine β¨Metric.ball (β i β s, (1 + f i)) (Ξ΅ / 2), β¨s, fun b hb β¦ ?_β©, ?_β©
Β· rw [β union_sdiff_of_subset hb, prod_union sdiff_disjoint.symm,
Metric.mem_ball, dist_eq_norm_sub, β mul_sub_one,
show Ξ΅ / 2 = rβ * (Ξ΅ / (2 * rβ)) by field]
apply (norm_mul_le _ _).trans_lt
refine lt_of_le_of_lt (b := rβ * ββ x β b \ s, (1 + f x) - 1β) ?_ ?_
Β· refine mul_le_mul_of_nonneg_right ?_ (norm_nonneg _)
exact (Finset.norm_prod_le _ _).trans (hsβ _ subset_union_left)
Β· refine mul_lt_mul_of_pos_left (hsβ _ ?_) hrβ
simp [s, sdiff_union_distrib, disjoint_iff_inter_eq_empty]
Β· intro x hx y hy
exact (dist_triangle_right _ _ (β i β s, (1 + f i))).trans_lt (add_halves Ξ΅ βΈ add_lt_add hx hy)
lemma Summable.summable_log_norm_one_add (hu : Summable fun n β¦ βf nβ) :
Summable fun i β¦ Real.log β1 + f iβ := by
suffices Summable (β1 + f Β·β - 1) from
(Real.summable_log_one_add_of_summable this).congr (by simp)
refine .of_norm (hu.of_nonneg_of_le (fun i β¦ by positivity) fun i β¦ ?_)
simp only [Real.norm_eq_abs, abs_le]
constructor
Β· simpa using norm_add_le (1 + f i) (-f i)
Β· simpa [add_comm] using norm_add_le (f i) 1
lemma tprod_one_add_ne_zero_of_summable [CompleteSpace R] [NormMulClass R]
(hf : β i, 1 + f i β 0)
(hu : Summable (βf Β·β)) : β' i : ΞΉ, (1 + f i) β 0 := by
rw [β norm_ne_zero_iff, Multipliable.norm_tprod]
Β· rw [β Real.rexp_tsum_eq_tprod (fun i β¦ norm_pos_iff.mpr <| hf i) hu.summable_log_norm_one_add]
apply Real.exp_ne_zero
Β· exact multipliable_one_add_of_summable hu
end NormedRing |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/ERealExp.lean | import Mathlib.Analysis.Complex.Exponential
import Mathlib.Data.EReal.Basic
/-!
# Extended Nonnegative Real Exponential
We define `exp` as an extension of the exponential of a real
to the extended reals `EReal`. The function takes values
in the extended nonnegative reals `ββ₯0β`, with `exp β₯ = 0` and `exp β€ = β€`.
## Main Definitions
- `EReal.exp`: The extension of the real exponential to `EReal`.
## Main Results
- `EReal.exp_strictMono`: `exp` is increasing;
- `EReal.exp_neg`, `EReal.exp_add`: `exp` satisfies
the identities `exp (-x) = (exp x)β»ΒΉ` and `exp (x + y) = exp x * exp y`.
## Tags
ENNReal, EReal, exponential
-/
namespace EReal
open scoped ENNReal
/-! ### Definition -/
section Definition
/-- Exponential as a function from `EReal` to `ββ₯0β`. -/
noncomputable
def exp : EReal β ββ₯0β
| β₯ => 0
| β€ => β
| (x : β) => ENNReal.ofReal (Real.exp x)
@[simp] lemma exp_bot : exp β₯ = 0 := rfl
@[simp] lemma exp_zero : exp 0 = 1 := by simp [exp]
@[simp] lemma exp_top : exp β€ = β := rfl
@[simp] lemma exp_coe (x : β) : exp x = ENNReal.ofReal (Real.exp x) := rfl
@[simp] lemma exp_eq_zero_iff {x : EReal} : exp x = 0 β x = β₯ := by
induction x <;> simp [Real.exp_pos]
@[simp] lemma exp_eq_top_iff {x : EReal} : exp x = β β x = β€ := by
induction x <;> simp
end Definition
/-! ### Monotonicity -/
section Monotonicity
@[gcongr]
lemma exp_strictMono : StrictMono exp := by
intro x y h
induction x
Β· rw [exp_bot, pos_iff_ne_zero, ne_eq, exp_eq_zero_iff]
exact h.ne'
Β· induction y
Β· simp at h
Β· simp_rw [exp_coe]
exact ENNReal.ofReal_lt_ofReal_iff'.mpr β¨Real.exp_strictMono (mod_cast h), Real.exp_pos _β©
Β· simp
Β· exact (not_top_lt h).elim
@[gcongr]
lemma exp_monotone : Monotone exp := exp_strictMono.monotone
@[simp] lemma exp_lt_exp_iff {a b : EReal} : exp a < exp b β a < b := exp_strictMono.lt_iff_lt
@[simp] lemma zero_lt_exp_iff {a : EReal} : 0 < exp a β β₯ < a := exp_bot βΈ @exp_lt_exp_iff β₯ a
@[simp] lemma exp_lt_top_iff {a : EReal} : exp a < β€ β a < β€ := exp_top βΈ @exp_lt_exp_iff a β€
@[simp] lemma exp_lt_one_iff {a : EReal} : exp a < 1 β a < 0 := exp_zero βΈ @exp_lt_exp_iff a 0
@[simp] lemma one_lt_exp_iff {a : EReal} : 1 < exp a β 0 < a := exp_zero βΈ @exp_lt_exp_iff 0 a
@[simp] lemma exp_le_exp_iff {a b : EReal} : exp a β€ exp b β a β€ b := exp_strictMono.le_iff_le
@[simp] lemma exp_le_one_iff {a : EReal} : exp a β€ 1 β a β€ 0 := exp_zero βΈ @exp_le_exp_iff a 0
@[simp] lemma one_le_exp_iff {a : EReal} : 1 β€ exp a β 0 β€ a := exp_zero βΈ @exp_le_exp_iff 0 a
@[deprecated exp_monotone (since := "2025-10-20")]
lemma exp_le_exp {a b : EReal} (h : a β€ b) : exp a β€ exp b := by simpa
@[deprecated exp_strictMono (since := "2025-10-20")]
lemma exp_lt_exp {a b : EReal} (h : a < b) : exp a < exp b := by simpa
end Monotonicity
/-! ### Algebraic properties -/
section Morphism
lemma exp_neg (x : EReal) : exp (-x) = (exp x)β»ΒΉ := by
induction x
Β· simp
Β· rw [exp_coe, β EReal.coe_neg, exp_coe, β ENNReal.ofReal_inv_of_pos (Real.exp_pos _),
Real.exp_neg]
Β· simp
lemma exp_add (x y : EReal) : exp (x + y) = exp x * exp y := by
induction x
Β· simp
Β· induction y
Β· simp
Β· simp only [β EReal.coe_add, exp_coe]
rw [β ENNReal.ofReal_mul (Real.exp_nonneg _), Real.exp_add]
Β· simp only [EReal.coe_add_top, exp_top, exp_coe]
rw [ENNReal.mul_top]
simp [Real.exp_pos]
Β· induction y
Β· simp
Β· simp only [EReal.top_add_coe, exp_top, exp_coe]
rw [ENNReal.top_mul]
simp [Real.exp_pos]
Β· simp
end Morphism
end EReal |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean | import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.LogDeriv
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Tactic.AdaptationNote
/-!
# Derivative and series expansion of real logarithm
In this file we prove that `Real.log` is infinitely smooth at all nonzero `x : β`. We also prove
that the series `β' n : β, x ^ (n + 1) / (n + 1)` converges to `(-Real.log (1 - x))` for all
`x : β`, `|x| < 1`.
## Tags
logarithm, derivative
-/
open Filter Finset Set
open scoped Topology ContDiff
namespace Real
variable {x : β}
theorem hasStrictDerivAt_log_of_pos (hx : 0 < x) : HasStrictDerivAt log xβ»ΒΉ x := by
have : HasStrictDerivAt log (exp <| log x)β»ΒΉ x :=
(hasStrictDerivAt_exp <| log x).of_local_left_inverse (continuousAt_log hx.ne')
(ne_of_gt <| exp_pos _) <|
Eventually.mono (lt_mem_nhds hx) @exp_log
rwa [exp_log hx] at this
theorem hasStrictDerivAt_log (hx : x β 0) : HasStrictDerivAt log xβ»ΒΉ x := by
rcases hx.lt_or_gt with hx | hx
Β· convert (hasStrictDerivAt_log_of_pos (neg_pos.mpr hx)).comp x (hasStrictDerivAt_neg x) using 1
Β· ext y; exact (log_neg_eq_log y).symm
Β· ring
Β· exact hasStrictDerivAt_log_of_pos hx
theorem hasDerivAt_log (hx : x β 0) : HasDerivAt log xβ»ΒΉ x :=
(hasStrictDerivAt_log hx).hasDerivAt
@[fun_prop] theorem differentiableAt_log (hx : x β 0) : DifferentiableAt β log x :=
(hasDerivAt_log hx).differentiableAt
theorem differentiableOn_log : DifferentiableOn β log {0}αΆ := fun _x hx =>
(differentiableAt_log hx).differentiableWithinAt
@[simp]
theorem differentiableAt_log_iff : DifferentiableAt β log x β x β 0 :=
β¨fun h => continuousAt_log_iff.1 h.continuousAt, differentiableAt_logβ©
theorem deriv_log (x : β) : deriv log x = xβ»ΒΉ :=
if hx : x = 0 then by
rw [deriv_zero_of_not_differentiableAt (differentiableAt_log_iff.not_left.2 hx), hx, inv_zero]
else (hasDerivAt_log hx).deriv
@[simp]
theorem deriv_log' : deriv log = Inv.inv :=
funext deriv_log
theorem contDiffAt_log {n : WithTop ββ} {x : β} : ContDiffAt β n log x β x β 0 := by
refine β¨fun h β¦ continuousAt_log_iff.1 h.continuousAt, fun hx β¦ ?_β©
have A y (hy : 0 < y) : ContDiffAt β n log y := by
apply expPartialHomeomorph.contDiffAt_symm_deriv (fβ' := y) hy.ne' (by simpa)
Β· convert hasDerivAt_exp (log y)
rw [exp_log hy]
Β· exact analyticAt_rexp.contDiffAt
rcases hx.lt_or_gt with hx | hx
Β· have : ContDiffAt β n (log β (fun y β¦ -y)) x := by
apply ContDiffAt.comp
Β· apply A _ (Left.neg_pos_iff.mpr hx)
apply contDiffAt_id.neg
convert this
ext x
simp
Β· exact A x hx
@[fun_prop]
theorem contDiffOn_log {n : WithTop ββ} : ContDiffOn β n log {0}αΆ := by
intro x hx
simp only [mem_compl_iff, mem_singleton_iff] at hx
exact (contDiffAt_log.2 hx).contDiffWithinAt
end Real
section LogDifferentiable
open Real
section deriv
variable {f : β β β} {x f' : β} {s : Set β}
theorem HasDerivWithinAt.log (hf : HasDerivWithinAt f f' s x) (hx : f x β 0) :
HasDerivWithinAt (fun y => log (f y)) (f' / f x) s x := by
rw [div_eq_inv_mul]
exact (hasDerivAt_log hx).comp_hasDerivWithinAt x hf
theorem HasDerivAt.log (hf : HasDerivAt f f' x) (hx : f x β 0) :
HasDerivAt (fun y => log (f y)) (f' / f x) x := by
rw [β hasDerivWithinAt_univ] at *
exact hf.log hx
theorem HasStrictDerivAt.log (hf : HasStrictDerivAt f f' x) (hx : f x β 0) :
HasStrictDerivAt (fun y => log (f y)) (f' / f x) x := by
rw [div_eq_inv_mul]
exact (hasStrictDerivAt_log hx).comp x hf
theorem derivWithin.log (hf : DifferentiableWithinAt β f s x) (hx : f x β 0)
(hxs : UniqueDiffWithinAt β s x) :
derivWithin (fun x => log (f x)) s x = derivWithin f s x / f x :=
(hf.hasDerivWithinAt.log hx).derivWithin hxs
@[simp]
theorem deriv.log (hf : DifferentiableAt β f x) (hx : f x β 0) :
deriv (fun x => log (f x)) x = deriv f x / f x :=
(hf.hasDerivAt.log hx).deriv
/-- The derivative of `log β f` is the logarithmic derivative provided `f` is differentiable and
`f x β 0`. -/
lemma Real.deriv_log_comp_eq_logDeriv {f : β β β} {x : β} (hβ : DifferentiableAt β f x)
(hβ : f x β 0) : deriv (log β f) x = logDeriv f x := by
simp only [logDeriv, Pi.div_apply, β deriv.log hβ hβ, Function.comp_def]
end deriv
section fderiv
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] {f : E β β} {x : E}
{f' : StrongDual β E} {s : Set E}
theorem HasFDerivWithinAt.log (hf : HasFDerivWithinAt f f' s x) (hx : f x β 0) :
HasFDerivWithinAt (fun x => log (f x)) ((f x)β»ΒΉ β’ f') s x :=
(hasDerivAt_log hx).comp_hasFDerivWithinAt x hf
theorem HasFDerivAt.log (hf : HasFDerivAt f f' x) (hx : f x β 0) :
HasFDerivAt (fun x => log (f x)) ((f x)β»ΒΉ β’ f') x :=
(hasDerivAt_log hx).comp_hasFDerivAt x hf
theorem HasStrictFDerivAt.log (hf : HasStrictFDerivAt f f' x) (hx : f x β 0) :
HasStrictFDerivAt (fun x => log (f x)) ((f x)β»ΒΉ β’ f') x :=
(hasStrictDerivAt_log hx).comp_hasStrictFDerivAt x hf
theorem DifferentiableWithinAt.log (hf : DifferentiableWithinAt β f s x) (hx : f x β 0) :
DifferentiableWithinAt β (fun x => log (f x)) s x :=
(hf.hasFDerivWithinAt.log hx).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.log (hf : DifferentiableAt β f x) (hx : f x β 0) :
DifferentiableAt β (fun x => log (f x)) x :=
(hf.hasFDerivAt.log hx).differentiableAt
@[fun_prop]
theorem ContDiffAt.log {n} (hf : ContDiffAt β n f x) (hx : f x β 0) :
ContDiffAt β n (fun x => log (f x)) x :=
(contDiffAt_log.2 hx).comp x hf
@[fun_prop]
theorem ContDiffWithinAt.log {n} (hf : ContDiffWithinAt β n f s x) (hx : f x β 0) :
ContDiffWithinAt β n (fun x => log (f x)) s x :=
(contDiffAt_log.2 hx).comp_contDiffWithinAt x hf
@[fun_prop]
theorem ContDiffOn.log {n} (hf : ContDiffOn β n f s) (hs : β x β s, f x β 0) :
ContDiffOn β n (fun x => log (f x)) s := fun x hx => (hf x hx).log (hs x hx)
@[fun_prop]
theorem ContDiff.log {n} (hf : ContDiff β n f) (h : β x, f x β 0) :
ContDiff β n fun x => log (f x) :=
contDiff_iff_contDiffAt.2 fun x => hf.contDiffAt.log (h x)
@[fun_prop]
theorem DifferentiableOn.log (hf : DifferentiableOn β f s) (hx : β x β s, f x β 0) :
DifferentiableOn β (fun x => log (f x)) s := fun x h => (hf x h).log (hx x h)
@[simp, fun_prop]
theorem Differentiable.log (hf : Differentiable β f) (hx : β x, f x β 0) :
Differentiable β fun x => log (f x) := fun x => (hf x).log (hx x)
theorem fderivWithin.log (hf : DifferentiableWithinAt β f s x) (hx : f x β 0)
(hxs : UniqueDiffWithinAt β s x) :
fderivWithin β (fun x => log (f x)) s x = (f x)β»ΒΉ β’ fderivWithin β f s x :=
(hf.hasFDerivWithinAt.log hx).fderivWithin hxs
@[simp]
theorem fderiv.log (hf : DifferentiableAt β f x) (hx : f x β 0) :
fderiv β (fun x => log (f x)) x = (f x)β»ΒΉ β’ fderiv β f x :=
(hf.hasFDerivAt.log hx).fderiv
end fderiv
end LogDifferentiable
namespace Real
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
/-- A crude lemma estimating the difference between `log (1-x)` and its Taylor series at `0`,
where the main point of the bound is that it tends to `0`. The goal is to deduce the series
expansion of the logarithm, in `hasSum_pow_div_log_of_abs_lt_1`.
TODO: use one of generic theorems about Taylor's series to prove this estimate.
-/
theorem abs_log_sub_add_sum_range_le {x : β} (h : |x| < 1) (n : β) :
|(β i β range n, x ^ (i + 1) / (i + 1)) + log (1 - x)| β€ |x| ^ (n + 1) / (1 - |x|) := by
/- For the proof, we show that the derivative of the function to be estimated is small,
and then apply the mean value inequality. -/
let F : β β β := fun x => (β i β range n, x ^ (i + 1) / (i + 1)) + log (1 - x)
let F' : β β β := fun x β¦ -x ^ n / (1 - x)
-- Porting note: In `mathlib3`, the proof used `deriv`/`DifferentiableAt`. `simp` failed to
-- compute `deriv`, so I changed the proof to use `HasDerivAt` instead
-- First step: compute the derivative of `F`
have A : β y β Ioo (-1 : β) 1, HasDerivAt F (F' y) y := fun y hy β¦ by
have : HasDerivAt F ((β i β range n, β(i + 1) * y ^ i / (βi + 1)) + (-1) / (1 - y)) y :=
.add (.fun_sum fun i _ β¦ (hasDerivAt_pow (i + 1) y).div_const ((i : β) + 1))
(((hasDerivAt_id y).const_sub _).log <| sub_ne_zero.2 hy.2.ne')
convert this using 1
calc
-y ^ n / (1 - y) = β i β Finset.range n, y ^ i + -1 / (1 - y) := by
simp [field, geom_sum_eq hy.2.ne, sub_ne_zero.2 hy.2.ne, sub_ne_zero.2 hy.2.ne']
ring
_ = β i β Finset.range n, β(i + 1) * y ^ i / (βi + 1) + -1 / (1 - y) := by
congr with i
rw [Nat.cast_succ, mul_div_cancel_leftβ _ (Nat.cast_add_one_pos i).ne']
-- second step: show that the derivative of `F` is small
have B : β y β Icc (-|x|) |x|, |F' y| β€ |x| ^ n / (1 - |x|) := fun y hy β¦
calc
|F' y| = |y| ^ n / |1 - y| := by simp [F', abs_div]
_ β€ |x| ^ n / (1 - |x|) := by
have : |y| β€ |x| := abs_le.2 hy
have : 1 - |x| β€ |1 - y| := le_trans (by linarith [hy.2]) (le_abs_self _)
gcongr
exact sub_pos.2 h
-- third step: apply the mean value inequality
have C : βF x - F 0β β€ |x| ^ n / (1 - |x|) * βx - 0β := by
refine Convex.norm_image_sub_le_of_norm_hasDerivWithin_le
(fun y hy β¦ (A _ ?_).hasDerivWithinAt) B (convex_Icc _ _) ?_ ?_
Β· exact Icc_subset_Ioo (neg_lt_neg h) h hy
Β· simp
Β· simp [le_abs_self x, neg_le.mp (neg_le_abs x)]
-- fourth step: conclude by massaging the inequality of the third step
simpa [F, div_mul_eq_mul_div, pow_succ] using C
/-- Power series expansion of the logarithm around `1`. -/
theorem hasSum_pow_div_log_of_abs_lt_one {x : β} (h : |x| < 1) :
HasSum (fun n : β => x ^ (n + 1) / (n + 1)) (-log (1 - x)) := by
rw [Summable.hasSum_iff_tendsto_nat]
Β· show Tendsto (fun n : β => β i β range n, x ^ (i + 1) / (i + 1)) atTop (π (-log (1 - x)))
rw [tendsto_iff_norm_sub_tendsto_zero]
simp only [norm_eq_abs, sub_neg_eq_add]
refine squeeze_zero (fun n => abs_nonneg _) (abs_log_sub_add_sum_range_le h) ?_
suffices Tendsto (fun t : β => |x| ^ (t + 1) / (1 - |x|)) atTop (π (|x| * 0 / (1 - |x|))) by
simpa
simp only [pow_succ']
refine (tendsto_const_nhds.mul ?_).div_const _
exact tendsto_pow_atTop_nhds_zero_of_lt_one (abs_nonneg _) h
show Summable fun n : β => x ^ (n + 1) / (n + 1)
refine .of_norm_bounded (summable_geometric_of_lt_one (abs_nonneg _) h) fun i => ?_
calc
βx ^ (i + 1) / (i + 1)β = |x| ^ (i + 1) / (i + 1) := by
have : (0 : β) β€ i + 1 := le_of_lt (Nat.cast_add_one_pos i)
rw [norm_eq_abs, abs_div, β pow_abs, abs_of_nonneg this]
_ β€ |x| ^ (i + 1) / (0 + 1) := by
gcongr
exact i.cast_nonneg
_ β€ |x| ^ i := by
simpa [pow_succ] using mul_le_of_le_one_right (pow_nonneg (abs_nonneg x) i) (le_of_lt h)
/-- Power series expansion of `log(1 + x) - log(1 - x)` for `|x| < 1`. -/
theorem hasSum_log_sub_log_of_abs_lt_one {x : β} (h : |x| < 1) :
HasSum (fun k : β => (2 : β) * (1 / (2 * k + 1)) * x ^ (2 * k + 1))
(log (1 + x) - log (1 - x)) := by
set term := fun n : β => -1 * ((-x) ^ (n + 1) / ((n : β) + 1)) + x ^ (n + 1) / (n + 1)
have h_term_eq_goal :
term β (2 * Β·) = fun k : β => 2 * (1 / (2 * k + 1)) * x ^ (2 * k + 1) := by
ext n
dsimp only [term, (Β· β Β·)]
rw [Odd.neg_pow (β¨n, rflβ© : Odd (2 * n + 1)) x]
push_cast
ring_nf
rw [β h_term_eq_goal, (mul_right_injectiveβ (two_ne_zero' β)).hasSum_iff]
Β· have hβ := (hasSum_pow_div_log_of_abs_lt_one (Eq.trans_lt (abs_neg x) h)).mul_left (-1)
convert hβ.add (hasSum_pow_div_log_of_abs_lt_one h) using 1
ring_nf
Β· intro m hm
rw [range_two_mul, Set.mem_setOf_eq, β Nat.even_add_one] at hm
dsimp [term]
rw [Even.neg_pow hm, neg_one_mul, neg_add_cancel]
/-- Expansion of `log (1 + aβ»ΒΉ)` as a series in powers of `1 / (2 * a + 1)`. -/
theorem hasSum_log_one_add_inv {a : β} (h : 0 < a) :
HasSum (fun k : β => (2 : β) * (1 / (2 * k + 1)) * (1 / (2 * a + 1)) ^ (2 * k + 1))
(log (1 + aβ»ΒΉ)) := by
have hβ : |1 / (2 * a + 1)| < 1 := by
rw [abs_of_pos, div_lt_one]
Β· linarith
Β· linarith
Β· exact div_pos one_pos (by linarith)
convert hasSum_log_sub_log_of_abs_lt_one hβ using 1
have hβ : (2 : β) * a + 1 β 0 := by linarith
have hβ := h.ne'
rw [β log_div]
Β· congr
simp [field]
ring
Β· field_simp
positivity
Β· simp [field, hβ]
/-- Expansion of `log (1 + a)` as a series in powers of `a / (a + 2)`. -/
theorem hasSum_log_one_add {a : β} (h : 0 β€ a) :
HasSum (fun k : β => (2 : β) * (1 / (2 * k + 1)) * (a / (a + 2)) ^ (2 * k + 1))
(log (1 + a)) := by
obtain (rfl | ha0) := eq_or_ne a 0
Β· simp [hasSum_zero]
Β· convert hasSum_log_one_add_inv (inv_pos.mpr (lt_of_le_of_ne h ha0.symm)) using 4
all_goals simp [field, add_comm]
lemma le_log_one_add_of_nonneg {x : β} (hx : 0 β€ x) : 2 * x / (x + 2) β€ log (1 + x) := by
convert le_hasSum (hasSum_log_one_add hx) 0 (by intros; positivity) using 1
simp [field]
lemma lt_log_one_add_of_pos {x : β} (hx : 0 < x) : 2 * x / (x + 2) < log (1 + x) := by
convert lt_hasSum (hasSum_log_one_add hx.le) 0 (by intros; positivity)
1 (by positivity) (by positivity) using 1
simp [field]
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/Base.lean | import Mathlib.Algebra.BigOperators.Field
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Data.Int.Log
/-!
# Real logarithm base `b`
In this file we define `Real.logb` to be the logarithm of a real number in a given base `b`. We
define this as the division of the natural logarithms of the argument and the base, so that we have
a globally defined function with `logb b 0 = 0`, `logb b (-x) = logb b x` `logb 0 x = 0` and
`logb (-b) x = logb b x`.
We prove some basic properties of this function and its relation to `rpow`.
## Tags
logarithm, continuity
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {b x y : β}
/-- The real logarithm in a given base. As with the natural logarithm, we define `logb b x` to
be `logb b |x|` for `x < 0`, and `0` for `x = 0`. -/
@[pp_nodot]
noncomputable def logb (b x : β) : β :=
log x / log b
theorem log_div_log : log x / log b = logb b x :=
rfl
@[simp]
theorem logb_zero : logb b 0 = 0 := by simp [logb]
@[simp]
theorem logb_one : logb b 1 = 0 := by simp [logb]
theorem logb_zero_left : logb 0 x = 0 := by simp only [β log_div_log, log_zero, div_zero]
@[simp] theorem logb_zero_left_eq_zero : logb 0 = 0 := by ext; rw [logb_zero_left, Pi.zero_apply]
theorem logb_one_left : logb 1 x = 0 := by simp only [β log_div_log, log_one, div_zero]
@[simp] theorem logb_one_left_eq_zero : logb 1 = 0 := by ext; rw [logb_one_left, Pi.zero_apply]
@[simp]
lemma logb_self_eq_one (hb : 1 < b) : logb b b = 1 :=
div_self (log_pos hb).ne'
lemma logb_self_eq_one_iff : logb b b = 1 β b β 0 β§ b β 1 β§ b β -1 :=
Iff.trans β¨fun h h' => by simp [logb, h'] at h, div_selfβ© log_ne_zero
@[simp]
theorem logb_abs_base (b x : β) : logb |b| x = logb b x := by rw [logb, logb, log_abs]
@[simp]
theorem logb_abs (b x : β) : logb b |x| = logb b x := by rw [logb, logb, log_abs]
@[simp]
theorem logb_neg_base_eq_logb (b x : β) : logb (-b) x = logb b x := by
rw [β logb_abs_base b x, β logb_abs_base (-b) x, abs_neg]
@[simp]
theorem logb_neg_eq_logb (b x : β) : logb b (-x) = logb b x := by
rw [β logb_abs b x, β logb_abs b (-x), abs_neg]
theorem logb_mul (hx : x β 0) (hy : y β 0) : logb b (x * y) = logb b x + logb b y := by
simp_rw [logb, log_mul hx hy, add_div]
theorem logb_div (hx : x β 0) (hy : y β 0) : logb b (x / y) = logb b x - logb b y := by
simp_rw [logb, log_div hx hy, sub_div]
@[simp]
theorem logb_inv (b x : β) : logb b xβ»ΒΉ = -logb b x := by simp [logb, neg_div]
@[simp]
theorem logb_inv_base (b x : β) : logb bβ»ΒΉ x = -logb b x := by simp [logb, div_neg]
theorem inv_logb (a b : β) : (logb a b)β»ΒΉ = logb b a := by simp_rw [logb, inv_div]
theorem inv_logb_mul_base {a b : β} (hβ : a β 0) (hβ : b β 0) (c : β) :
(logb (a * b) c)β»ΒΉ = (logb a c)β»ΒΉ + (logb b c)β»ΒΉ := by
simp_rw [inv_logb]; exact logb_mul hβ hβ
theorem inv_logb_div_base {a b : β} (hβ : a β 0) (hβ : b β 0) (c : β) :
(logb (a / b) c)β»ΒΉ = (logb a c)β»ΒΉ - (logb b c)β»ΒΉ := by
simp_rw [inv_logb]; exact logb_div hβ hβ
theorem logb_mul_base {a b : β} (hβ : a β 0) (hβ : b β 0) (c : β) :
logb (a * b) c = ((logb a c)β»ΒΉ + (logb b c)β»ΒΉ)β»ΒΉ := by rw [β inv_logb_mul_base hβ hβ c, inv_inv]
theorem logb_div_base {a b : β} (hβ : a β 0) (hβ : b β 0) (c : β) :
logb (a / b) c = ((logb a c)β»ΒΉ - (logb b c)β»ΒΉ)β»ΒΉ := by rw [β inv_logb_div_base hβ hβ c, inv_inv]
theorem mul_logb {a b c : β} (hβ : b β 0) (hβ : b β 1) (hβ : b β -1) :
logb a b * logb b c = logb a c := by
unfold logb
rw [mul_comm, div_mul_div_cancelβ (log_ne_zero.mpr β¨hβ, hβ, hββ©)]
theorem div_logb {a b c : β} (hβ : c β 0) (hβ : c β 1) (hβ : c β -1) :
logb a c / logb b c = logb a b :=
div_div_div_cancel_left' _ _ <| log_ne_zero.mpr β¨hβ, hβ, hββ©
theorem logb_rpow_eq_mul_logb_of_pos (hx : 0 < x) : logb b (x ^ y) = y * logb b x := by
rw [logb, log_rpow hx, logb, mul_div_assoc]
theorem logb_pow (b x : β) (k : β) : logb b (x ^ k) = k * logb b x := by
rw [logb, logb, log_pow, mul_div_assoc]
section BPosAndNeOne
variable (b_pos : 0 < b) (b_ne_one : b β 1)
include b_pos b_ne_one
@[simp]
theorem logb_rpow : logb b (b ^ x) = x := by
rw [logb, div_eq_iff, log_rpow b_pos]
exact log_ne_zero_of_pos_of_ne_one b_pos b_ne_one
theorem rpow_logb_eq_abs (hx : x β 0) : b ^ logb b x = |x| := by
apply log_injOn_pos
Β· simp only [Set.mem_Ioi]
apply rpow_pos_of_pos b_pos
Β· simp only [abs_pos, mem_Ioi, Ne, hx, not_false_iff]
rw [log_rpow b_pos, logb, log_abs]
field [log_ne_zero_of_pos_of_ne_one b_pos b_ne_one]
@[simp]
theorem rpow_logb (hx : 0 < x) : b ^ logb b x = x := by
rw [rpow_logb_eq_abs b_pos b_ne_one hx.ne']
exact abs_of_pos hx
theorem rpow_logb_of_neg (hx : x < 0) : b ^ logb b x = -x := by
rw [rpow_logb_eq_abs b_pos b_ne_one (ne_of_lt hx)]
exact abs_of_neg hx
theorem logb_eq_iff_rpow_eq (hy : 0 < y) : logb b y = x β b ^ x = y := by
constructor <;> rintro rfl
Β· exact rpow_logb b_pos b_ne_one hy
Β· exact logb_rpow b_pos b_ne_one
theorem surjOn_logb : SurjOn (logb b) (Ioi 0) univ := fun x _ =>
β¨b ^ x, rpow_pos_of_pos b_pos x, logb_rpow b_pos b_ne_oneβ©
theorem logb_surjective : Surjective (logb b) := fun x => β¨b ^ x, logb_rpow b_pos b_ne_oneβ©
@[simp]
theorem range_logb : range (logb b) = univ :=
(logb_surjective b_pos b_ne_one).range_eq
theorem surjOn_logb' : SurjOn (logb b) (Iio 0) univ := by
intro x _
use -b ^ x
constructor
Β· simp only [Right.neg_neg_iff, Set.mem_Iio]
apply rpow_pos_of_pos b_pos
Β· rw [logb_neg_eq_logb, logb_rpow b_pos b_ne_one]
end BPosAndNeOne
section OneLtB
variable (hb : 1 < b)
include hb
private theorem b_pos : 0 < b := by linarith
-- Name has a prime added to avoid clashing with `b_ne_one` further down the file
private theorem b_ne_one' : b β 1 := by linarith
@[simp]
theorem logb_le_logb (h : 0 < x) (hβ : 0 < y) : logb b x β€ logb b y β x β€ y := by
rw [logb, logb, div_le_div_iff_of_pos_right (log_pos hb), log_le_log_iff h hβ]
@[gcongr]
theorem logb_le_logb_of_le (h : 0 < x) (hxy : x β€ y) : logb b x β€ logb b y :=
(logb_le_logb hb h (by linarith)).mpr hxy
@[gcongr]
theorem logb_lt_logb (hx : 0 < x) (hxy : x < y) : logb b x < logb b y := by
rw [logb, logb, div_lt_div_iff_of_pos_right (log_pos hb)]
exact log_lt_log hx hxy
@[simp]
theorem logb_lt_logb_iff (hx : 0 < x) (hy : 0 < y) : logb b x < logb b y β x < y := by
rw [logb, logb, div_lt_div_iff_of_pos_right (log_pos hb)]
exact log_lt_log_iff hx hy
theorem logb_le_iff_le_rpow (hx : 0 < x) : logb b x β€ y β x β€ b ^ y := by
rw [β rpow_le_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hx]
theorem logb_lt_iff_lt_rpow (hx : 0 < x) : logb b x < y β x < b ^ y := by
rw [β rpow_lt_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hx]
theorem le_logb_iff_rpow_le (hy : 0 < y) : x β€ logb b y β b ^ x β€ y := by
rw [β rpow_le_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hy]
theorem lt_logb_iff_rpow_lt (hy : 0 < y) : x < logb b y β b ^ x < y := by
rw [β rpow_lt_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hy]
theorem logb_pos_iff (hx : 0 < x) : 0 < logb b x β 1 < x := by
rw [β @logb_one b]
rw [logb_lt_logb_iff hb zero_lt_one hx]
theorem logb_pos (hx : 1 < x) : 0 < logb b x := by
rw [logb_pos_iff hb (lt_trans zero_lt_one hx)]
exact hx
theorem logb_neg_iff (h : 0 < x) : logb b x < 0 β x < 1 := by
rw [β logb_one]
exact logb_lt_logb_iff hb h zero_lt_one
theorem logb_neg (h0 : 0 < x) (h1 : x < 1) : logb b x < 0 :=
(logb_neg_iff hb h0).2 h1
theorem logb_nonneg_iff (hx : 0 < x) : 0 β€ logb b x β 1 β€ x := by
rw [β not_lt, logb_neg_iff hb hx, not_lt]
theorem logb_nonneg (hx : 1 β€ x) : 0 β€ logb b x :=
(logb_nonneg_iff hb (zero_lt_one.trans_le hx)).2 hx
theorem logb_nonpos_iff (hx : 0 < x) : logb b x β€ 0 β x β€ 1 := by
rw [β not_lt, logb_pos_iff hb hx, not_lt]
theorem logb_nonpos_iff' (hx : 0 β€ x) : logb b x β€ 0 β x β€ 1 := by
rcases hx.eq_or_lt with (rfl | hx)
Β· simp [le_refl, zero_le_one]
exact logb_nonpos_iff hb hx
theorem logb_nonpos (hx : 0 β€ x) (h'x : x β€ 1) : logb b x β€ 0 :=
(logb_nonpos_iff' hb hx).2 h'x
theorem strictMonoOn_logb : StrictMonoOn (logb b) (Set.Ioi 0) := fun _ hx _ _ hxy =>
logb_lt_logb hb hx hxy
theorem strictAntiOn_logb : StrictAntiOn (logb b) (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [β logb_abs b y, β logb_abs b x]
refine logb_lt_logb hb (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem logb_injOn_pos : Set.InjOn (logb b) (Set.Ioi 0) :=
(strictMonoOn_logb hb).injOn
theorem eq_one_of_pos_of_logb_eq_zero (hβ : 0 < x) (hβ : logb b x = 0) : x = 1 :=
logb_injOn_pos hb (Set.mem_Ioi.2 hβ) (Set.mem_Ioi.2 zero_lt_one) (hβ.trans Real.logb_one.symm)
theorem logb_ne_zero_of_pos_of_ne_one (hx_pos : 0 < x) (hx : x β 1) : logb b x β 0 :=
mt (eq_one_of_pos_of_logb_eq_zero hb hx_pos) hx
theorem tendsto_logb_atTop : Tendsto (logb b) atTop atTop :=
Tendsto.atTop_div_const (log_pos hb) tendsto_log_atTop
end OneLtB
section BPosAndBLtOne
variable (b_pos : 0 < b) (b_lt_one : b < 1)
include b_lt_one
private theorem b_ne_one : b β 1 := by linarith
include b_pos
@[simp]
theorem logb_le_logb_of_base_lt_one (h : 0 < x) (hβ : 0 < y) : logb b x β€ logb b y β y β€ x := by
rw [logb, logb, div_le_div_right_of_neg (log_neg b_pos b_lt_one), log_le_log_iff hβ h]
theorem logb_lt_logb_of_base_lt_one (hx : 0 < x) (hxy : x < y) : logb b y < logb b x := by
rw [logb, logb, div_lt_div_right_of_neg (log_neg b_pos b_lt_one)]
exact log_lt_log hx hxy
@[simp]
theorem logb_lt_logb_iff_of_base_lt_one (hx : 0 < x) (hy : 0 < y) :
logb b x < logb b y β y < x := by
rw [logb, logb, div_lt_div_right_of_neg (log_neg b_pos b_lt_one)]
exact log_lt_log_iff hy hx
theorem logb_le_iff_le_rpow_of_base_lt_one (hx : 0 < x) : logb b x β€ y β b ^ y β€ x := by
rw [β rpow_le_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hx]
theorem logb_lt_iff_lt_rpow_of_base_lt_one (hx : 0 < x) : logb b x < y β b ^ y < x := by
rw [β rpow_lt_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hx]
theorem le_logb_iff_rpow_le_of_base_lt_one (hy : 0 < y) : x β€ logb b y β y β€ b ^ x := by
rw [β rpow_le_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hy]
theorem lt_logb_iff_rpow_lt_of_base_lt_one (hy : 0 < y) : x < logb b y β y < b ^ x := by
rw [β rpow_lt_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hy]
theorem logb_pos_iff_of_base_lt_one (hx : 0 < x) : 0 < logb b x β x < 1 := by
rw [β @logb_one b, logb_lt_logb_iff_of_base_lt_one b_pos b_lt_one zero_lt_one hx]
theorem logb_pos_of_base_lt_one (hx : 0 < x) (hx' : x < 1) : 0 < logb b x := by
rw [logb_pos_iff_of_base_lt_one b_pos b_lt_one hx]
exact hx'
theorem logb_neg_iff_of_base_lt_one (h : 0 < x) : logb b x < 0 β 1 < x := by
rw [β @logb_one b, logb_lt_logb_iff_of_base_lt_one b_pos b_lt_one h zero_lt_one]
theorem logb_neg_of_base_lt_one (h1 : 1 < x) : logb b x < 0 :=
(logb_neg_iff_of_base_lt_one b_pos b_lt_one (lt_trans zero_lt_one h1)).2 h1
theorem logb_nonneg_iff_of_base_lt_one (hx : 0 < x) : 0 β€ logb b x β x β€ 1 := by
rw [β not_lt, logb_neg_iff_of_base_lt_one b_pos b_lt_one hx, not_lt]
theorem logb_nonneg_of_base_lt_one (hx : 0 < x) (hx' : x β€ 1) : 0 β€ logb b x := by
rw [logb_nonneg_iff_of_base_lt_one b_pos b_lt_one hx]
exact hx'
theorem logb_nonpos_iff_of_base_lt_one (hx : 0 < x) : logb b x β€ 0 β 1 β€ x := by
rw [β not_lt, logb_pos_iff_of_base_lt_one b_pos b_lt_one hx, not_lt]
theorem strictAntiOn_logb_of_base_lt_one : StrictAntiOn (logb b) (Set.Ioi 0) := fun _ hx _ _ hxy =>
logb_lt_logb_of_base_lt_one b_pos b_lt_one hx hxy
theorem strictMonoOn_logb_of_base_lt_one : StrictMonoOn (logb b) (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [β logb_abs b y, β logb_abs b x]
refine logb_lt_logb_of_base_lt_one b_pos b_lt_one (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem logb_injOn_pos_of_base_lt_one : Set.InjOn (logb b) (Set.Ioi 0) :=
(strictAntiOn_logb_of_base_lt_one b_pos b_lt_one).injOn
theorem eq_one_of_pos_of_logb_eq_zero_of_base_lt_one (hβ : 0 < x) (hβ : logb b x = 0) : x = 1 :=
logb_injOn_pos_of_base_lt_one b_pos b_lt_one (Set.mem_Ioi.2 hβ) (Set.mem_Ioi.2 zero_lt_one)
(hβ.trans Real.logb_one.symm)
theorem logb_ne_zero_of_pos_of_ne_one_of_base_lt_one (hx_pos : 0 < x) (hx : x β 1) : logb b x β 0 :=
mt (eq_one_of_pos_of_logb_eq_zero_of_base_lt_one b_pos b_lt_one hx_pos) hx
theorem tendsto_logb_atTop_of_base_lt_one : Tendsto (logb b) atTop atBot := by
rw [tendsto_atTop_atBot]
intro e
use 1 β b ^ e
intro a
simp only [and_imp, sup_le_iff]
intro ha
rw [logb_le_iff_le_rpow_of_base_lt_one b_pos b_lt_one]
Β· tauto
Β· exact lt_of_lt_of_le zero_lt_one ha
end BPosAndBLtOne
@[norm_cast]
theorem floor_logb_natCast {b : β} {r : β} (hr : 0 β€ r) :
βlogb b rβ = Int.log b r := by
obtain rfl | hr := hr.eq_or_lt
Β· rw [logb_zero, Int.log_zero_right, Int.floor_zero]
by_cases hb : 1 < b
Β· have hb1' : 1 < (b : β) := Nat.one_lt_cast.mpr hb
apply le_antisymm
Β· rw [β Int.zpow_le_iff_le_log hb hr, β rpow_intCast b]
refine le_of_le_of_eq ?_ (rpow_logb (zero_lt_one.trans hb1') hb1'.ne' hr)
exact rpow_le_rpow_of_exponent_le hb1'.le (Int.floor_le _)
Β· rw [Int.le_floor, le_logb_iff_rpow_le hb1' hr, rpow_intCast]
exact Int.zpow_log_le_self hb hr
Β· rw [Nat.one_lt_iff_ne_zero_and_ne_one, β or_iff_not_and_not] at hb
cases hb
Β· simp_all only [CharP.cast_eq_zero, logb_zero_left, Int.floor_zero, Int.log_zero_left]
Β· simp_all only [Nat.cast_one, logb_one_left, Int.floor_zero, Int.log_one_left]
@[norm_cast]
theorem ceil_logb_natCast {b : β} {r : β} (hr : 0 β€ r) :
βlogb b rβ = Int.clog b r := by
obtain rfl | hr := hr.eq_or_lt
Β· rw [logb_zero, Int.clog_zero_right, Int.ceil_zero]
by_cases hb : 1 < b
Β· have hb1' : 1 < (b : β) := Nat.one_lt_cast.mpr hb
apply le_antisymm
Β· rw [Int.ceil_le, logb_le_iff_le_rpow hb1' hr, rpow_intCast]
exact Int.self_le_zpow_clog hb r
Β· rw [β Int.le_zpow_iff_clog_le hb hr, β rpow_intCast b]
refine (rpow_logb (zero_lt_one.trans hb1') hb1'.ne' hr).symm.trans_le ?_
exact rpow_le_rpow_of_exponent_le hb1'.le (Int.le_ceil _)
Β· rw [Nat.one_lt_iff_ne_zero_and_ne_one, β or_iff_not_and_not] at hb
cases hb
Β· simp_all only [CharP.cast_eq_zero, logb_zero_left, Int.ceil_zero, Int.clog_zero_left]
Β· simp_all only [Nat.cast_one, logb_one_left, Int.ceil_zero, Int.clog_one_left]
@[norm_cast]
theorem natFloor_logb_natCast (b : β) (n : β) : βlogb b nββ = Nat.log b n := by
obtain _ | _ | b := b
Β· simp [Real.logb]
Β· simp [Real.logb]
obtain rfl | hn := eq_or_ne n 0
Β· simp
rw [β Nat.cast_inj (R := β€), Int.natCast_floor_eq_floor, floor_logb_natCast (by simp),
Int.log_natCast]
exact logb_nonneg (by simp [Nat.cast_add_one_pos]) (Nat.one_le_cast.2 (by cutsat))
@[norm_cast]
theorem natCeil_logb_natCast (b : β) (n : β) : βlogb b nββ = Nat.clog b n := by
obtain _ | _ | b := b
Β· simp [Real.logb]
Β· simp [Real.logb]
obtain rfl | hn := eq_or_ne n 0
Β· simp
rw [β Nat.cast_inj (R := β€), Int.natCast_ceil_eq_ceil, ceil_logb_natCast (by simp),
Int.clog_natCast]
exact logb_nonneg (by simp [Nat.cast_add_one_pos]) (Nat.one_le_cast.2 (by cutsat))
lemma natLog_le_logb (a b : β) : Nat.log b a β€ Real.logb b a := by
apply le_trans _ (Int.floor_le ((b : β).logb a))
rw [Real.floor_logb_natCast (Nat.cast_nonneg a), Int.log_natCast, Int.cast_natCast]
lemma log2_le_logb (n : β) : Nat.log2 n β€ Real.logb 2 n := by
calc (Nat.log2 n : β) = Nat.log 2 n := mod_cast Nat.log2_eq_log_two
_ β€ Real.logb 2 n := natLog_le_logb _ _
@[simp]
theorem logb_eq_zero : logb b x = 0 β b = 0 β¨ b = 1 β¨ b = -1 β¨ x = 0 β¨ x = 1 β¨ x = -1 := by
simp_rw [logb, div_eq_zero_iff, log_eq_zero]
tauto
theorem tendsto_logb_nhdsNE_zero (hb : 1 < b) : Tendsto (logb b) (π[β ] 0) atBot :=
tendsto_log_nhdsNE_zero.atBot_div_const (log_pos hb)
theorem tendsto_logb_nhdsNE_zero_of_base_lt_one (hbβ : 0 < b) (hb : b < 1) :
Tendsto (logb b) (π[β ] 0) atTop :=
tendsto_log_nhdsNE_zero.atBot_mul_const_of_neg (inv_lt_zero.2 (log_neg hbβ hb))
lemma tendsto_logb_nhdsGT_zero (hb : 1 < b) : Tendsto (logb b) (π[>] 0) atBot :=
tendsto_log_nhdsGT_zero.atBot_div_const (log_pos hb)
lemma tendsto_logb_nhdsGT_zero_of_base_lt_one (hbβ : 0 < b) (hb : b < 1) :
Tendsto (logb b) (π[>] 0) atTop :=
tendsto_log_nhdsGT_zero.atBot_mul_const_of_neg (inv_lt_zero.2 (log_neg hbβ hb))
/--
The function `|logb b x|` tends to `+β` as `x` tendsto `+β`.
See also `tendsto_logb_atTop` and `tendsto_logb_atTop_of_base_lt_one`.
-/
lemma tendsto_abs_logb_atTop (hb : b β -1 β§ b β 0 β§ b β 1) :
Tendsto (|logb b Β·|) atTop atTop := by
wlog hbβ : 0 < b generalizing b
Β· exact (this (b := -b) (by simp [hb, neg_eq_iff_eq_neg]) (by linarith +splitNe)).congr (by simp)
wlog hbβ : 1 < b generalizing b
Β· exact (this (b := bβ»ΒΉ) (by simp [hb, inv_eq_iff_eq_inv, inv_neg]) (by simpa)
((one_lt_invβ hbβ).2 (by linarith +splitNe))).congr (by simp)
refine (tendsto_logb_atTop hbβ).congr' ?_
filter_upwards [eventually_ge_atTop 1] with x hxβ
rw [abs_of_nonneg]
exact logb_nonneg hbβ hxβ
theorem continuousOn_logb : ContinuousOn (logb b) {0}αΆ := continuousOn_log.div_const _
/-- The real logarithm base b is continuous as a function from nonzero reals. -/
@[fun_prop]
theorem continuous_logb : Continuous fun x : { x : β // x β 0 } => logb b x :=
continuous_log.div_const _
/-- The real logarithm base b is continuous as a function from positive reals. -/
@[fun_prop]
theorem continuous_logb' : Continuous fun x : { x : β // 0 < x } => logb b x :=
continuous_log'.div_const _
theorem continuousAt_logb (hx : x β 0) : ContinuousAt (logb b) x :=
(continuousAt_log hx).div_const _
@[simp]
theorem continuousAt_logb_iff (hbβ : 0 < b) (hb : b β 1) : ContinuousAt (logb b) x β x β 0 := by
refine β¨?_, continuousAt_logbβ©
rintro h rfl
cases lt_or_gt_of_ne hb with
| inl hbβ =>
exact not_tendsto_nhds_of_tendsto_atTop (tendsto_logb_nhdsNE_zero_of_base_lt_one hbβ hbβ)
_ (h.tendsto.mono_left inf_le_left)
| inr hbβ =>
exact not_tendsto_nhds_of_tendsto_atBot (tendsto_logb_nhdsNE_zero hbβ)
_ (h.tendsto.mono_left inf_le_left)
theorem logb_prod {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β β) (hf : β x β s, f x β 0) :
logb b (β i β s, f i) = β i β s, logb b (f i) := by
induction s using Finset.cons_induction_on with
| empty => simp
| cons => simp_all [logb_mul, Finset.prod_ne_zero_iff]
protected theorem _root_.Finsupp.logb_prod {Ξ± Ξ² : Type*} [Zero Ξ²] (f : Ξ± ββ Ξ²) (g : Ξ± β Ξ² β β)
(hg : β a, g a (f a) = 0 β f a = 0) : logb b (f.prod g) = f.sum fun a c β¦ logb b (g a c) :=
logb_prod _ _ fun _x hx hβ β¦ Finsupp.mem_support_iff.1 hx <| hg _ hβ
theorem logb_nat_eq_sum_factorization (n : β) :
logb b n = n.factorization.sum fun p t => t * logb b p := by
simp only [logb, mul_div_assoc', log_nat_eq_sum_factorization n, Finsupp.sum, Finset.sum_div]
theorem tendsto_pow_logb_div_mul_add_atTop (a c : β) (n : β) (ha : a β 0) :
Tendsto (fun x => logb b x ^ n / (a * x + c)) atTop (π 0) := by
cases eq_or_ne (log b) 0 with
| inl h => simpa [logb, h] using ((tendsto_mul_add_inv_atTop_nhds_zero _ _ ha).const_mul _)
| inr h => apply (tendsto_pow_log_div_mul_add_atTop (a * (log b) ^ n) (c * (log b) ^ n) n
(by positivity)).congr fun x β¦ by simp [field, div_pow, logb]
theorem isLittleO_pow_logb_id_atTop {n : β} : (fun x => logb b x ^ n) =o[atTop] id := by
rw [Asymptotics.isLittleO_iff_tendsto']
Β· simpa using tendsto_pow_logb_div_mul_add_atTop 1 0 n one_ne_zero
Β· filter_upwards [eventually_ne_atTop (0 : β)] with x hβ hβ using (hβ hβ).elim
theorem isLittleO_logb_id_atTop : logb b =o[atTop] id :=
isLittleO_pow_logb_id_atTop.congr_left fun _ => pow_one _
theorem isLittleO_const_logb_atTop {c : β} (hb : b β -1 β§ b β 0 β§ b β 1) :
(fun _ => c) =o[atTop] logb b := by
rw [Asymptotics.isLittleO_const_left, or_iff_not_imp_left]
intro hc
exact tendsto_abs_logb_atTop hb
end Real
section Continuity
open Real
variable {Ξ± : Type*}
variable {b : β}
theorem Filter.Tendsto.logb {f : Ξ± β β} {l : Filter Ξ±} {x : β}
(h : Tendsto f l (π x)) (hx : x β 0) :
Tendsto (fun y => logb b (f y)) l (π (logb b x)) :=
(continuousAt_logb hx).tendsto.comp h
variable [TopologicalSpace Ξ±] {f : Ξ± β β} {s : Set Ξ±} {a : Ξ±}
@[fun_prop]
theorem Continuous.logb (hf : Continuous f) (hβ : β x, f x β 0) :
Continuous fun x => logb b (f x) :=
continuousOn_logb.comp_continuous hf hβ
@[fun_prop]
nonrec theorem ContinuousAt.logb (hf : ContinuousAt f a) (hβ : f a β 0) :
ContinuousAt (fun x => logb b (f x)) a :=
hf.logb hβ
nonrec theorem ContinuousWithinAt.logb (hf : ContinuousWithinAt f s a) (hβ : f a β 0) :
ContinuousWithinAt (fun x => logb b (f x)) s a :=
hf.logb hβ
@[fun_prop]
theorem ContinuousOn.logb (hf : ContinuousOn f s) (hβ : β x β s, f x β 0) :
ContinuousOn (fun x => logb b (f x)) s := fun x hx => (hf x hx).logb (hβ x hx)
end Continuity
section TendstoCompAddSub
open Filter
namespace Real
variable {b : β}
theorem tendsto_logb_comp_add_sub_logb (y : β) :
Tendsto (fun x : β => logb b (x + y) - logb b x) atTop (π 0) := by
simpa [sub_div] using (tendsto_log_comp_add_sub_log y).div_const (log b)
theorem tendsto_logb_nat_add_one_sub_logb :
Tendsto (fun k : β => logb b (k + 1) - logb b k) atTop (π 0) :=
(tendsto_logb_comp_add_sub_logb 1).comp tendsto_natCast_atTop_atTop
end Real
end TendstoCompAddSub
section Induction
/-- Induction principle for intervals of real numbers: if a proposition `P` is true
on `[xβ, r * xβ)` and if `P` for `[xβ, r^n * xβ)` implies `P` for `[r^n * xβ, r^(n+1) * xβ)`,
then `P` is true for all `x β₯ xβ`. -/
lemma Real.induction_Ico_mul {P : β β Prop} (xβ r : β) (hr : 1 < r) (hxβ : 0 < xβ)
(base : β x β Set.Ico xβ (r * xβ), P x)
(step : β n : β, n β₯ 1 β (β z β Set.Ico xβ (r ^ n * xβ), P z) β
(β z β Set.Ico (r ^ n * xβ) (r ^ (n + 1) * xβ), P z)) :
β x β₯ xβ, P x := by
suffices β n : β, β x β Set.Ico xβ (r ^ (n + 1) * xβ), P x by
intro x hx
have hx' : 0 < x / xβ := div_pos (hxβ.trans_le hx) hxβ
refine this βlogb r (x / xβ)ββ x ?_
rw [mem_Ico, β div_lt_iffβ hxβ, β rpow_natCast, β logb_lt_iff_lt_rpow hr hx', Nat.cast_add,
Nat.cast_one]
exact β¨hx, Nat.lt_floor_add_one _β©
intro n
induction n with
| zero => simpa using base
| succ n ih =>
exact fun x hx => (Ico_subset_Ico_union_Ico hx).elim (ih x) (step (n + 1) (by simp) ih _)
end Induction |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/ENNRealLog.lean | import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Data.EReal.Basic
/-!
# Extended Nonnegative Real Logarithm
We define `log` as an extension of the logarithm of a positive real
to the extended nonnegative reals `ββ₯0β`. The function takes values
in the extended reals `EReal`, with `log 0 = β₯` and `log β€ = β€`.
## Main Definitions
- `ENNReal.log`: The extension of the real logarithm to `ββ₯0β`.
## Main Results
- `ENNReal.log_strictMono`: `log` is increasing;
- `ENNReal.log_injective`, `ENNReal.log_surjective`, `ENNReal.log_bijective`: `log` is
injective, surjective, and bijective;
- `ENNReal.log_mul_add`, `ENNReal.log_pow`, `ENNReal.log_rpow`: `log` satisfies
the identities `log (x * y) = log x + log y` and `log (x ^ y) = y * log x`
(with either `y β β` or `y β β`).
## Tags
ENNReal, EReal, logarithm
-/
namespace ENNReal
open scoped NNReal
/-! ### Definition -/
section Definition
/-- The logarithm function defined on the extended nonnegative reals `ββ₯0β`
to the extended reals `EReal`. Coincides with the usual logarithm function
and with `Real.log` on positive reals, and takes values `log 0 = β₯` and `log β€ = β€`.
Conventions about multiplication in `ββ₯0β` and addition in `EReal` make the identity
`log (x * y) = log x + log y` unconditional. -/
noncomputable def log (x : ββ₯0β) : EReal :=
if x = 0 then β₯
else if x = β€ then β€
else Real.log x.toReal
@[simp] lemma log_zero : log 0 = β₯ := if_pos rfl
@[simp] lemma log_one : log 1 = 0 := by simp [log]
@[simp] lemma log_top : log β€ = β€ := rfl
@[simp]
lemma log_ofReal (x : β) : log (ENNReal.ofReal x) = if x β€ 0 then β₯ else β(Real.log x) := by
simp only [log, ENNReal.ofReal_ne_top,
ENNReal.ofReal_eq_zero, if_false]
split_ifs with h_nonpos
Β· rfl
Β· rw [ENNReal.toReal_ofReal (not_le.mp h_nonpos).le]
lemma log_ofReal_of_pos {x : β} (hx : 0 < x) : log (ENNReal.ofReal x) = Real.log x := by
rw [log_ofReal, if_neg hx.not_ge]
theorem log_pos_real {x : ββ₯0β} (h : x β 0) (h' : x β β€) :
log x = Real.log (ENNReal.toReal x) := by simp [log, h, h']
theorem log_pos_real' {x : ββ₯0β} (h : 0 < x.toReal) :
log x = Real.log (ENNReal.toReal x) := by
simp [log, (ENNReal.toReal_pos_iff.1 h).1.ne', (ENNReal.toReal_pos_iff.1 h).2.ne]
theorem log_of_nnreal {x : ββ₯0} (h : x β 0) :
log (x : ββ₯0β) = Real.log x := by simp [log, h]
end Definition
/-! ### Monotonicity -/
section Monotonicity
theorem log_strictMono : StrictMono log := by
intro x y h
unfold log
split_ifs <;> simp_all [Real.log_lt_log, toReal_pos_iff, pos_iff_ne_zero, lt_top_iff_ne_top]
theorem log_monotone : Monotone log := log_strictMono.monotone
theorem log_injective : Function.Injective log := log_strictMono.injective
theorem log_surjective : Function.Surjective log := by
intro y
cases y with
| bot => use 0; simp
| top => use β€; simp
| coe y => use ENNReal.ofReal (Real.exp y); simp [Real.exp_pos]
theorem log_bijective : Function.Bijective log := β¨log_injective, log_surjectiveβ©
@[simp]
theorem log_eq_iff {x y : ββ₯0β} : log x = log y β x = y :=
log_injective.eq_iff
@[simp] theorem log_eq_bot_iff {x : ββ₯0β} : log x = β₯ β x = 0 := log_zero βΈ @log_eq_iff x 0
@[simp] theorem log_eq_one_iff {x : ββ₯0β} : log x = 0 β x = 1 := log_one βΈ @log_eq_iff x 1
@[simp] theorem log_eq_top_iff {x : ββ₯0β} : log x = β€ β x = β€ := log_top βΈ @log_eq_iff x β€
@[simp] lemma log_lt_log_iff {x y : ββ₯0β} : log x < log y β x < y := log_strictMono.lt_iff_lt
@[simp] lemma bot_lt_log_iff {x : ββ₯0β} : β₯ < log x β 0 < x := log_zero βΈ @log_lt_log_iff 0 x
@[simp] lemma log_lt_top_iff {x : ββ₯0β} : log x < β€ β x < β€ := log_top βΈ @log_lt_log_iff x β€
@[simp] lemma log_lt_zero_iff {x : ββ₯0β} : log x < 0 β x < 1 := log_one βΈ @log_lt_log_iff x 1
@[simp] lemma zero_lt_log_iff {x : ββ₯0β} : 0 < log x β 1 < x := log_one βΈ @log_lt_log_iff 1 x
@[simp] lemma log_le_log_iff {x y : ββ₯0β} : log x β€ log y β x β€ y := log_strictMono.le_iff_le
@[simp] lemma log_le_zero_iff {x : ββ₯0β} : log x β€ 0 β x β€ 1 := log_one βΈ @log_le_log_iff x 1
@[simp] lemma zero_le_log_iff {x : ββ₯0β} : 0 β€ log x β 1 β€ x := log_one βΈ @log_le_log_iff 1 x
@[gcongr] lemma log_le_log {x y : ββ₯0β} (h : x β€ y) : log x β€ log y := log_monotone h
@[gcongr] lemma log_lt_log {x y : ββ₯0β} (h : x < y) : log x < log y := log_strictMono h
end Monotonicity
/-! ### Algebraic properties -/
section Morphism
theorem log_mul_add {x y : ββ₯0β} : log (x * y) = log x + log y := by
rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
Β· simp
Β· rw [log_top]
rcases ENNReal.trichotomy y with (rfl | rfl | y_real)
Β· rw [mul_zero, log_zero, EReal.add_bot]
Β· simp
Β· rw [log_pos_real' y_real, ENNReal.top_mul', EReal.top_add_coe, log_eq_top_iff]
simp only [ite_eq_right_iff, zero_ne_top, imp_false]
exact (ENNReal.toReal_pos_iff.1 y_real).1.ne'
Β· rw [log_pos_real' x_real]
rcases ENNReal.trichotomy y with (rfl | rfl | y_real)
Β· simp
Β· simp [(ENNReal.toReal_pos_iff.1 x_real).1.ne']
Β· rw_mod_cast [log_pos_real', log_pos_real' y_real, ENNReal.toReal_mul]
Β· exact Real.log_mul x_real.ne' y_real.ne'
rw [toReal_mul]
positivity
theorem log_rpow {x : ββ₯0β} {y : β} : log (x ^ y) = y * log x := by
rcases lt_trichotomy y 0 with (y_neg | rfl | y_pos)
Β· rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
Β· simp only [ENNReal.zero_rpow_def y, not_lt_of_gt y_neg, y_neg.ne, if_false, log_top,
log_zero, EReal.coe_mul_bot_of_neg y_neg]
Β· rw [ENNReal.top_rpow_of_neg y_neg, log_zero, log_top, EReal.coe_mul_top_of_neg y_neg]
Β· have x_ne_zero := (ENNReal.toReal_pos_iff.1 x_real).1.ne'
have x_ne_top := (ENNReal.toReal_pos_iff.1 x_real).2.ne
simp only [log, rpow_eq_zero_iff, x_ne_zero, false_and, x_ne_top, or_self, βreduceIte,
rpow_eq_top_iff]
norm_cast
exact ENNReal.toReal_rpow x y βΈ Real.log_rpow x_real y
Β· simp
Β· rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
Β· rw [ENNReal.zero_rpow_of_pos y_pos, log_zero, EReal.mul_bot_of_pos]; norm_cast
Β· rw [ENNReal.top_rpow_of_pos y_pos, log_top, EReal.mul_top_of_pos]; norm_cast
Β· have x_ne_zero := (ENNReal.toReal_pos_iff.1 x_real).1.ne'
have x_ne_top := (ENNReal.toReal_pos_iff.1 x_real).2.ne
simp only [log, rpow_eq_zero_iff, x_ne_zero, false_and, x_ne_top, or_self, βreduceIte,
rpow_eq_top_iff]
norm_cast
exact ENNReal.toReal_rpow x y βΈ Real.log_rpow x_real y
theorem log_pow {x : ββ₯0β} {n : β} : log (x ^ n) = n * log x := by
rw [β rpow_natCast, log_rpow, EReal.coe_natCast]
lemma log_inv {x : ββ₯0β} : log xβ»ΒΉ = - log x := by
simp [β rpow_neg_one, log_rpow]
end Morphism
end ENNReal |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/Basic.lean | import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Data.Nat.Factorization.Defs
import Mathlib.Analysis.Normed.Module.RCLike.Real
import Mathlib.Data.Rat.Cast.CharZero
/-!
# Real logarithm
In this file we define `Real.log` to be the logarithm of a real number. As usual, we extend it from
its domain `(0, +β)` to a globally defined function. We choose to do it so that `log 0 = 0` and
`log (-x) = log x`.
We prove some basic properties of this function and show that it is continuous.
## Tags
logarithm, continuity
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {x y : β}
/-- The real logarithm function, equal to the inverse of the exponential for `x > 0`,
to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to
`(-β, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and
the derivative of `log` is `1/x` away from `0`. -/
@[pp_nodot]
noncomputable def log (x : β) : β :=
if hx : x = 0 then 0 else expOrderIso.symm β¨|x|, abs_pos.2 hxβ©
theorem log_of_ne_zero (hx : x β 0) : log x = expOrderIso.symm β¨|x|, abs_pos.2 hxβ© :=
dif_neg hx
theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm β¨x, hxβ© := by
rw [log_of_ne_zero hx.ne']
congr
exact abs_of_pos hx
theorem exp_log_eq_abs (hx : x β 0) : exp (log x) = |x| := by
rw [log_of_ne_zero hx, β coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk]
theorem exp_log (hx : 0 < x) : exp (log x) = x := by
rw [exp_log_eq_abs hx.ne']
exact abs_of_pos hx
theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by
rw [exp_log_eq_abs (ne_of_lt hx)]
exact abs_of_neg hx
theorem le_exp_log (x : β) : x β€ exp (log x) := by
by_cases h_zero : x = 0
Β· rw [h_zero, log, dif_pos rfl, exp_zero]
exact zero_le_one
Β· rw [exp_log_eq_abs h_zero]
exact le_abs_self _
@[simp]
theorem log_exp (x : β) : log (exp x) = x :=
exp_injective <| exp_log (exp_pos x)
theorem exp_one_mul_le_exp {x : β} : exp 1 * x β€ exp x := by
by_cases hx0 : x β€ 0
Β· apply le_trans (mul_nonpos_of_nonneg_of_nonpos (exp_pos 1).le hx0) (exp_nonneg x)
Β· have h := add_one_le_exp (log x)
rwa [β exp_le_exp, exp_add, exp_log (lt_of_not_ge hx0), mul_comm] at h
theorem two_mul_le_exp {x : β} : 2 * x β€ exp x := by
by_cases hx0 : x < 0
Β· exact le_trans (mul_nonpos_of_nonneg_of_nonpos (by simp only [Nat.ofNat_nonneg]) hx0.le)
(exp_nonneg x)
Β· apply le_trans (mul_le_mul_of_nonneg_right _ (le_of_not_gt hx0)) exp_one_mul_le_exp
have := Real.add_one_le_exp 1
rwa [one_add_one_eq_two] at this
theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => β¨exp x, exp_pos x, log_exp xβ©
theorem log_surjective : Surjective log := fun x => β¨exp x, log_exp xβ©
@[simp]
theorem range_log : range log = univ :=
log_surjective.range_eq
@[simp]
theorem log_zero : log 0 = 0 :=
dif_pos rfl
@[simp]
theorem log_one : log 1 = 0 :=
exp_injective <| by rw [exp_log zero_lt_one, exp_zero]
/-- This holds true for all `x : β` because of the junk values `0 / 0 = 0` and `log 0 = 0`. -/
@[simp] lemma log_div_self (x : β) : log (x / x) = 0 := by
obtain rfl | hx := eq_or_ne x 0 <;> simp [*]
@[simp]
theorem log_abs (x : β) : log |x| = log x := by
by_cases h : x = 0
Β· simp [h]
Β· rw [β exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs]
@[simp]
theorem log_neg_eq_log (x : β) : log (-x) = log x := by rw [β log_abs x, β log_abs (-x), abs_neg]
theorem sinh_log {x : β} (hx : 0 < x) : sinh (log x) = (x - xβ»ΒΉ) / 2 := by
rw [sinh_eq, exp_neg, exp_log hx]
theorem cosh_log {x : β} (hx : 0 < x) : cosh (log x) = (x + xβ»ΒΉ) / 2 := by
rw [cosh_eq, exp_neg, exp_log hx]
theorem surjOn_log' : SurjOn log (Iio 0) univ := fun x _ =>
β¨-exp x, neg_lt_zero.2 <| exp_pos x, by rw [log_neg_eq_log, log_exp]β©
theorem log_mul (hx : x β 0) (hy : y β 0) : log (x * y) = log x + log y :=
exp_injective <| by
rw [exp_log_eq_abs (mul_ne_zero hx hy), exp_add, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_mul]
theorem log_div (hx : x β 0) (hy : y β 0) : log (x / y) = log x - log y :=
exp_injective <| by
rw [exp_log_eq_abs (div_ne_zero hx hy), exp_sub, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_div]
@[simp]
theorem log_inv (x : β) : log xβ»ΒΉ = -log x := by
by_cases hx : x = 0; Β· simp [hx]
rw [β exp_eq_exp, exp_log_eq_abs (inv_ne_zero hx), exp_neg, exp_log_eq_abs hx, abs_inv]
theorem log_le_log_iff (h : 0 < x) (hβ : 0 < y) : log x β€ log y β x β€ y := by
rw [β exp_le_exp, exp_log h, exp_log hβ]
@[gcongr, bound]
lemma log_le_log (hx : 0 < x) (hxy : x β€ y) : log x β€ log y :=
(log_le_log_iff hx (hx.trans_le hxy)).2 hxy
@[gcongr, bound]
theorem log_lt_log (hx : 0 < x) (h : x < y) : log x < log y := by
rwa [β exp_lt_exp, exp_log hx, exp_log (lt_trans hx h)]
theorem log_lt_log_iff (hx : 0 < x) (hy : 0 < y) : log x < log y β x < y := by
rw [β exp_lt_exp, exp_log hx, exp_log hy]
theorem log_le_iff_le_exp (hx : 0 < x) : log x β€ y β x β€ exp y := by rw [β exp_le_exp, exp_log hx]
theorem log_lt_iff_lt_exp (hx : 0 < x) : log x < y β x < exp y := by rw [β exp_lt_exp, exp_log hx]
theorem le_log_iff_exp_le (hy : 0 < y) : x β€ log y β exp x β€ y := by rw [β exp_le_exp, exp_log hy]
theorem lt_log_iff_exp_lt (hy : 0 < y) : x < log y β exp x < y := by rw [β exp_lt_exp, exp_log hy]
theorem log_pos_iff (hx : 0 β€ x) : 0 < log x β 1 < x := by
rcases hx.eq_or_lt with (rfl | hx)
Β· simp [zero_le_one]
rw [β log_one]
exact log_lt_log_iff zero_lt_one hx
@[bound]
theorem log_pos (hx : 1 < x) : 0 < log x :=
(log_pos_iff (lt_trans zero_lt_one hx).le).2 hx
theorem log_pos_of_lt_neg_one (hx : x < -1) : 0 < log x := by
rw [β neg_neg x, log_neg_eq_log]
have : 1 < -x := by linarith
exact log_pos this
theorem log_neg_iff (h : 0 < x) : log x < 0 β x < 1 := by
rw [β log_one]
exact log_lt_log_iff h zero_lt_one
@[bound]
theorem log_neg (h0 : 0 < x) (h1 : x < 1) : log x < 0 :=
(log_neg_iff h0).2 h1
theorem log_neg_of_lt_zero (h0 : x < 0) (h1 : -1 < x) : log x < 0 := by
rw [β neg_neg x, log_neg_eq_log]
have h0' : 0 < -x := by linarith
have h1' : -x < 1 := by linarith
exact log_neg h0' h1'
theorem log_nonneg_iff (hx : 0 < x) : 0 β€ log x β 1 β€ x := by rw [β not_lt, log_neg_iff hx, not_lt]
@[bound]
theorem log_nonneg (hx : 1 β€ x) : 0 β€ log x :=
(log_nonneg_iff (zero_lt_one.trans_le hx)).2 hx
theorem log_nonpos_iff (hx : 0 β€ x) : log x β€ 0 β x β€ 1 := by
rcases hx.eq_or_lt with (rfl | hx)
Β· simp [le_refl, zero_le_one]
rw [β not_lt, log_pos_iff hx.le, not_lt]
@[bound]
theorem log_nonpos (hx : 0 β€ x) (h'x : x β€ 1) : log x β€ 0 :=
(log_nonpos_iff hx).2 h'x
theorem log_natCast_nonneg (n : β) : 0 β€ log n := by
if hn : n = 0 then
simp [hn]
else
have : (1 : β) β€ n := mod_cast Nat.one_le_of_lt <| Nat.pos_of_ne_zero hn
exact log_nonneg this
theorem log_neg_natCast_nonneg (n : β) : 0 β€ log (-n) := by
rw [β log_neg_eq_log, neg_neg]
exact log_natCast_nonneg _
theorem log_intCast_nonneg (n : β€) : 0 β€ log n := by
cases lt_trichotomy 0 n with
| inl hn =>
have : (1 : β) β€ n := mod_cast hn
exact log_nonneg this
| inr hn =>
cases hn with
| inl hn => simp [hn.symm]
| inr hn =>
have : (1 : β) β€ -n := by rw [β neg_zero, β lt_neg] at hn; exact mod_cast hn
rw [β log_neg_eq_log]
exact log_nonneg this
theorem strictMonoOn_log : StrictMonoOn log (Set.Ioi 0) := fun _ hx _ _ hxy => log_lt_log hx hxy
theorem strictAntiOn_log : StrictAntiOn log (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [β log_abs y, β log_abs x]
refine log_lt_log (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem log_injOn_pos : Set.InjOn log (Set.Ioi 0) :=
strictMonoOn_log.injOn
theorem log_lt_sub_one_of_pos (hx1 : 0 < x) (hx2 : x β 1) : log x < x - 1 := by
have h : log x β 0 := by
rwa [β log_one, log_injOn_pos.ne_iff hx1]
exact mem_Ioi.mpr zero_lt_one
linarith [add_one_lt_exp h, exp_log hx1]
theorem eq_one_of_pos_of_log_eq_zero {x : β} (hβ : 0 < x) (hβ : log x = 0) : x = 1 :=
log_injOn_pos (Set.mem_Ioi.2 hβ) (Set.mem_Ioi.2 zero_lt_one) (hβ.trans Real.log_one.symm)
theorem log_ne_zero_of_pos_of_ne_one {x : β} (hx_pos : 0 < x) (hx : x β 1) : log x β 0 :=
mt (eq_one_of_pos_of_log_eq_zero hx_pos) hx
@[simp]
theorem log_eq_zero {x : β} : log x = 0 β x = 0 β¨ x = 1 β¨ x = -1 := by
constructor
Β· intro h
rcases lt_trichotomy x 0 with (x_lt_zero | rfl | x_gt_zero)
Β· refine Or.inr (Or.inr (neg_eq_iff_eq_neg.mp ?_))
rw [β log_neg_eq_log x] at h
exact eq_one_of_pos_of_log_eq_zero (neg_pos.mpr x_lt_zero) h
Β· exact Or.inl rfl
Β· exact Or.inr (Or.inl (eq_one_of_pos_of_log_eq_zero x_gt_zero h))
Β· rintro (rfl | rfl | rfl) <;> simp only [log_one, log_zero, log_neg_eq_log]
theorem log_ne_zero {x : β} : log x β 0 β x β 0 β§ x β 1 β§ x β -1 := by
simpa only [not_or] using log_eq_zero.not
@[simp]
theorem log_pow (x : β) (n : β) : log (x ^ n) = n * log x := by
induction n with
| zero => simp
| succ n ih =>
rcases eq_or_ne x 0 with (rfl | hx)
Β· simp
Β· rw [pow_succ, log_mul (pow_ne_zero _ hx) hx, ih, Nat.cast_succ, add_mul, one_mul]
@[simp]
theorem log_zpow (x : β) (n : β€) : log (x ^ n) = n * log x := by
cases n
Β· rw [Int.ofNat_eq_coe, zpow_natCast, log_pow, Int.cast_natCast]
Β· rw [zpow_negSucc, log_inv, log_pow, Int.cast_negSucc, Nat.cast_add_one, neg_mul_eq_neg_mul]
theorem log_sqrt {x : β} (hx : 0 β€ x) : log (βx) = log x / 2 := by
rw [eq_div_iff, mul_comm, β Nat.cast_two, β log_pow, sq_sqrt hx]
exact two_ne_zero
theorem log_le_sub_one_of_pos {x : β} (hx : 0 < x) : log x β€ x - 1 := by
rw [le_sub_iff_add_le]
convert add_one_le_exp (log x)
rw [exp_log hx]
lemma one_sub_inv_le_log_of_pos (hx : 0 < x) : 1 - xβ»ΒΉ β€ log x := by
simpa [add_comm] using log_le_sub_one_of_pos (inv_pos.2 hx)
/-- See `Real.log_le_sub_one_of_pos` for the stronger version when `x β 0`. -/
lemma log_le_self (hx : 0 β€ x) : log x β€ x := by
obtain rfl | hx := hx.eq_or_lt
Β· simp
Β· exact (log_le_sub_one_of_pos hx).trans (by linarith)
/-- See `Real.one_sub_inv_le_log_of_pos` for the stronger version when `x β 0`. -/
lemma neg_inv_le_log (hx : 0 β€ x) : -xβ»ΒΉ β€ log x := by
rw [neg_le, β log_inv]; exact log_le_self <| inv_nonneg.2 hx
/-- Bound for `|log x * x|` in the interval `(0, 1]`. -/
theorem abs_log_mul_self_lt (x : β) (h1 : 0 < x) (h2 : x β€ 1) : |log x * x| < 1 := by
have : 0 < 1 / x := by simpa only [one_div, inv_pos] using h1
replace := log_le_sub_one_of_pos this
replace : log (1 / x) < 1 / x := by linarith
rw [log_div one_ne_zero h1.ne', log_one, zero_sub, lt_div_iffβ h1] at this
have aux : 0 β€ -log x * x := by
refine mul_nonneg ?_ h1.le
rw [β log_inv]
apply log_nonneg
rw [β le_inv_commβ h1 zero_lt_one, inv_one]
exact h2
rw [β abs_of_nonneg aux, neg_mul, abs_neg] at this
exact this
/-- The real logarithm function tends to `+β` at `+β`. -/
theorem tendsto_log_atTop : Tendsto log atTop atTop :=
tendsto_comp_exp_atTop.1 <| by simpa only [log_exp] using tendsto_id
lemma tendsto_log_nhdsGT_zero : Tendsto log (π[>] 0) atBot := by
simpa [β tendsto_comp_exp_atBot] using tendsto_id
theorem tendsto_log_nhdsNE_zero : Tendsto log (π[β ] 0) atBot := by
simpa [comp_def] using tendsto_log_nhdsGT_zero.comp tendsto_abs_nhdsNE_zero
lemma tendsto_log_nhdsLT_zero : Tendsto log (π[<] 0) atBot :=
tendsto_log_nhdsNE_zero.mono_left <| nhdsWithin_mono _ fun _ h β¦ ne_of_lt h
theorem continuousOn_log : ContinuousOn log {0}αΆ := by
simp +unfoldPartialApp only [continuousOn_iff_continuous_restrict,
restrict]
conv in log _ => rw [log_of_ne_zero (show (x : β) β 0 from x.2)]
exact expOrderIso.symm.continuous.comp (continuous_subtype_val.norm.subtype_mk _)
/-- The real logarithm is continuous as a function from nonzero reals. -/
@[fun_prop]
theorem continuous_log : Continuous fun x : { x : β // x β 0 } => log x :=
continuousOn_iff_continuous_restrict.1 <| continuousOn_log.mono fun _ => id
/-- The real logarithm is continuous as a function from positive reals. -/
@[fun_prop]
theorem continuous_log' : Continuous fun x : { x : β // 0 < x } => log x :=
continuousOn_iff_continuous_restrict.1 <| continuousOn_log.mono fun _ hx => ne_of_gt hx
theorem continuousAt_log (hx : x β 0) : ContinuousAt log x :=
(continuousOn_log x hx).continuousAt <| isOpen_compl_singleton.mem_nhds hx
@[simp]
theorem continuousAt_log_iff : ContinuousAt log x β x β 0 := by
refine β¨?_, continuousAt_logβ©
rintro h rfl
exact not_tendsto_nhds_of_tendsto_atBot tendsto_log_nhdsNE_zero _ <|
h.tendsto.mono_left nhdsWithin_le_nhds
open List in
lemma log_list_prod {l : List β} (h : β x β l, x β 0) :
log l.prod = (l.map (fun x β¦ log x)).sum := by
induction l with
| nil => simp
| cons a l ih =>
simp_all only [ne_eq, mem_cons, or_true, not_false_eq_true, forall_const, forall_eq_or_imp,
prod_cons, map_cons, sum_cons]
have : l.prod β 0 := by grind [prod_ne_zero]
rw [log_mul h.1 this, add_right_inj, ih]
open Multiset in
lemma log_multiset_prod {s : Multiset β} (h : β x β s, x β 0) :
log s.prod = (s.map (fun x β¦ log x)).sum := by
rw [β prod_toList, log_list_prod (by simp_all), sum_map_toList]
open Finset in
theorem log_prod {Ξ± : Type*} {s : Finset Ξ±} {f : Ξ± β β} (hf : β x β s, f x β 0) :
log (β i β s, f i) = β i β s, log (f i) := by
rw [β prod_map_toList, log_list_prod (by simp_all)]
simp
protected theorem _root_.Finsupp.log_prod {Ξ± Ξ² : Type*} [Zero Ξ²] (f : Ξ± ββ Ξ²) (g : Ξ± β Ξ² β β)
(hg : β a, g a (f a) = 0 β f a = 0) : log (f.prod g) = f.sum fun a b β¦ log (g a b) :=
log_prod fun _x hx hβ β¦ Finsupp.mem_support_iff.1 hx <| hg _ hβ
theorem log_nat_eq_sum_factorization (n : β) :
log n = n.factorization.sum fun p t => t * log p := by
rcases eq_or_ne n 0 with (rfl | hn)
Β· simp -- relies on junk values of `log` and `Nat.factorization`
Β· simp only [β log_pow, β Nat.cast_pow]
rw [β Finsupp.log_prod, β Nat.cast_finsuppProd, Nat.factorization_prod_pow_eq_self hn]
intro p hp
rw [eq_zero_of_pow_eq_zero (Nat.cast_eq_zero.1 hp), Nat.factorization_zero_right]
theorem tendsto_pow_log_div_mul_add_atTop (a b : β) (n : β) (ha : a β 0) :
Tendsto (fun x => log x ^ n / (a * x + b)) atTop (π 0) :=
((tendsto_div_pow_mul_exp_add_atTop a b n ha.symm).comp tendsto_log_atTop).congr' <| by
filter_upwards [eventually_gt_atTop (0 : β)] with x hx using by simp [exp_log hx]
theorem isLittleO_pow_log_id_atTop {n : β} : (fun x => log x ^ n) =o[atTop] id := by
rw [Asymptotics.isLittleO_iff_tendsto']
Β· simpa using tendsto_pow_log_div_mul_add_atTop 1 0 n one_ne_zero
filter_upwards [eventually_ne_atTop (0 : β)] with x hβ hβ using (hβ hβ).elim
theorem isLittleO_log_id_atTop : log =o[atTop] id :=
isLittleO_pow_log_id_atTop.congr_left fun _ => pow_one _
theorem isLittleO_const_log_atTop {c : β} : (fun _ => c) =o[atTop] log := by
refine Asymptotics.isLittleO_of_tendsto' ?_
<| Tendsto.div_atTop (a := c) (by simp) tendsto_log_atTop
filter_upwards [eventually_gt_atTop 1] with x hx
aesop (add safe forward log_pos)
/-- `Real.exp` as an `OpenPartialHomeomorph` with `source = univ` and `target = {z | 0 < z}`. -/
@[simps] noncomputable def expPartialHomeomorph : OpenPartialHomeomorph β β where
toFun := Real.exp
invFun := Real.log
source := univ
target := Ioi (0 : β)
map_source' x _ := exp_pos x
map_target' _ _ := mem_univ _
left_inv' _ _ := by simp
right_inv' _ hx := exp_log hx
open_source := isOpen_univ
open_target := isOpen_Ioi
continuousOn_toFun := continuousOn_exp
continuousOn_invFun x hx := (continuousAt_log (ne_of_gt hx)).continuousWithinAt
end Real
section Continuity
open Real
variable {Ξ± : Type*}
theorem Filter.Tendsto.log {f : Ξ± β β} {l : Filter Ξ±} {x : β} (h : Tendsto f l (π x)) (hx : x β 0) :
Tendsto (fun x => log (f x)) l (π (log x)) :=
(continuousAt_log hx).tendsto.comp h
variable [TopologicalSpace Ξ±] {f : Ξ± β β} {s : Set Ξ±} {a : Ξ±}
@[fun_prop]
theorem Continuous.log (hf : Continuous f) (hβ : β x, f x β 0) : Continuous fun x => log (f x) :=
continuousOn_log.comp_continuous hf hβ
@[fun_prop]
nonrec theorem ContinuousAt.log (hf : ContinuousAt f a) (hβ : f a β 0) :
ContinuousAt (fun x => log (f x)) a :=
hf.log hβ
nonrec theorem ContinuousWithinAt.log (hf : ContinuousWithinAt f s a) (hβ : f a β 0) :
ContinuousWithinAt (fun x => log (f x)) s a :=
hf.log hβ
@[fun_prop]
theorem ContinuousOn.log (hf : ContinuousOn f s) (hβ : β x β s, f x β 0) :
ContinuousOn (fun x => log (f x)) s := fun x hx => (hf x hx).log (hβ x hx)
end Continuity
section TendstoCompAddSub
open Filter
namespace Real
theorem tendsto_log_comp_add_sub_log (y : β) :
Tendsto (fun x : β => log (x + y) - log x) atTop (π 0) := by
have : Tendsto (fun x β¦ 1 + y / x) atTop (π (1 + 0)) :=
tendsto_const_nhds.add (tendsto_const_nhds.div_atTop tendsto_id)
rw [β comap_exp_nhds_exp, exp_zero, tendsto_comap_iff, β add_zero (1 : β)]
refine this.congr' ?_
filter_upwards [eventually_gt_atTop (0 : β), eventually_gt_atTop (-y)] with x hxβ hxy
rw [comp_apply, exp_sub, exp_log, exp_log, one_add_div] <;> linarith
theorem tendsto_log_nat_add_one_sub_log : Tendsto (fun k : β => log (k + 1) - log k) atTop (π 0) :=
(tendsto_log_comp_add_sub_log 1).comp tendsto_natCast_atTop_atTop
end Real
end TendstoCompAddSub
namespace Mathlib.Meta.Positivity
open Lean.Meta Qq
variable {e : β} {d : β}
lemma log_nonneg_of_isNat {n : β} (h : NormNum.IsNat e n) : 0 β€ Real.log (e : β) := by
rw [NormNum.IsNat.to_eq h rfl]
exact Real.log_natCast_nonneg _
lemma log_pos_of_isNat {n : β} (h : NormNum.IsNat e n) (w : Nat.blt 1 n = true) :
0 < Real.log (e : β) := by
rw [NormNum.IsNat.to_eq h rfl]
apply Real.log_pos
simpa using w
lemma log_nonneg_of_isNegNat {n : β} (h : NormNum.IsInt e (.negOfNat n)) :
0 β€ Real.log (e : β) := by
rw [NormNum.IsInt.neg_to_eq h rfl]
exact Real.log_neg_natCast_nonneg _
lemma log_pos_of_isNegNat {n : β} (h : NormNum.IsInt e (.negOfNat n)) (w : Nat.blt 1 n = true) :
0 < Real.log (e : β) := by
rw [NormNum.IsInt.neg_to_eq h rfl]
rw [Real.log_neg_eq_log]
apply Real.log_pos
simpa using w
lemma log_pos_of_isNNRat {n : β} :
(NormNum.IsNNRat e n d) β (decide ((1 : β) < n / d)) β (0 < Real.log (e : β))
| β¨inv, eqβ©, h => by
rw [eq, invOf_eq_inv, β div_eq_mul_inv]
have : 1 < (n : β) / d := by
simpa using (Rat.cast_lt (K := β)).2 (of_decide_eq_true h)
exact Real.log_pos this
lemma log_pos_of_isRat_neg {n : β€} :
(NormNum.IsRat e n d) β (decide (n / d < (-1 : β))) β (0 < Real.log (e : β))
| β¨inv, eqβ©, h => by
rw [eq, invOf_eq_inv, β div_eq_mul_inv]
have : (n : β) / d < -1 := by exact_mod_cast of_decide_eq_true h
exact Real.log_pos_of_lt_neg_one this
lemma log_nz_of_isNNRat {n : β} : (NormNum.IsNNRat e n d) β (decide ((0 : β) < n / d))
β (decide (n / d < (1 : β))) β (Real.log (e : β) β 0)
| β¨inv, eqβ©, hβ, hβ => by
rw [eq, invOf_eq_inv, β div_eq_mul_inv]
have hβ' : 0 < (n : β) / d := by
simpa using (Rat.cast_pos (K := β)).2 (of_decide_eq_true hβ)
have hβ' : (n : β) / d < 1 := by
simpa using (Rat.cast_lt (K := β)).2 (of_decide_eq_true hβ)
exact ne_of_lt <| Real.log_neg hβ' hβ'
lemma log_nz_of_isRat_neg {n : β€} : (NormNum.IsRat e n d) β (decide (n / d < (0 : β)))
β (decide ((-1 : β) < n / d)) β (Real.log (e : β) β 0)
| β¨inv, eqβ©, hβ, hβ => by
rw [eq, invOf_eq_inv, β div_eq_mul_inv]
have hβ' : (n : β) / d < 0 := by exact_mod_cast of_decide_eq_true hβ
have hβ' : -1 < (n : β) / d := by exact_mod_cast of_decide_eq_true hβ
exact ne_of_lt <| Real.log_neg_of_lt_zero hβ' hβ'
/-- Extension for the `positivity` tactic: `Real.log` of a natural number is always nonnegative. -/
@[positivity Real.log (Nat.cast _)]
def evalLogNatCast : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.log (Nat.cast $a)) =>
assertInstancesCommute
pure (.nonnegative q(Real.log_natCast_nonneg $a))
| _, _, _ => throwError "not Real.log"
/-- Extension for the `positivity` tactic: `Real.log` of an integer is always nonnegative. -/
@[positivity Real.log (Int.cast _)]
def evalLogIntCast : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.log (Int.cast $a)) =>
assertInstancesCommute
pure (.nonnegative q(Real.log_intCast_nonneg $a))
| _, _, _ => throwError "not Real.log"
/-- Extension for the `positivity` tactic: `Real.log` of a numeric literal. -/
@[positivity Real.log _]
def evalLogNatLit : PositivityExt where eval {u Ξ±} _ _ e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(Real.log $a) =>
match β NormNum.derive a with
| .isNat (_ : Q(AddMonoidWithOne β)) lit p =>
assumeInstancesCommute
have p : Q(NormNum.IsNat $a $lit) := p
if 1 < lit.natLit! then
let p' : Q(Nat.blt 1 $lit = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isNat $p $p'))
else
pure (.nonnegative q(log_nonneg_of_isNat $p))
| .isNegNat _ lit p =>
assumeInstancesCommute
have p : Q(NormNum.IsInt $a (Int.negOfNat $lit)) := p
if 1 < lit.natLit! then
let p' : Q(Nat.blt 1 $lit = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isNegNat $p $p'))
else
pure (.nonnegative q(log_nonneg_of_isNegNat $p))
| .isNNRat _ q n d p =>
assumeInstancesCommute
if q < 1 then
let wβ : Q(decide ((0 : β) < $n / $d) = true) := (q(Eq.refl true) : Lean.Expr)
let wβ : Q(decide ($n / $d < (1 : β)) = true) := (q(Eq.refl true) : Lean.Expr)
pure (.nonzero q(log_nz_of_isNNRat $p $wβ $wβ))
else if 1 < q then
let w : Q(decide ((1 : β) < $n / $d) = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isNNRat $p $w))
else
failure
| .isNegNNRat _ q n d p =>
assumeInstancesCommute
if -1 < q then
let wβ : Q(decide ((Int.negOfNat $n) / $d < (0 : β)) = true) :=
(q(Eq.refl true) : Lean.Expr)
let wβ : Q(decide ((-1 : β) < (Int.negOfNat $n) / $d) = true) :=
(q(Eq.refl true) : Lean.Expr)
pure (.nonzero q(log_nz_of_isRat_neg $p $wβ $wβ))
else if q < -1 then
let w : Q(decide ((Int.negOfNat $n) / $d < (-1 : β)) = true) :=
(q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isRat_neg $p $w))
else
failure
| _ => failure
| _, _, _ => throwError "not Real.log"
end Mathlib.Meta.Positivity |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/ENNRealLogExp.lean | import Mathlib.Analysis.SpecialFunctions.Log.ERealExp
import Mathlib.Analysis.SpecialFunctions.Log.ENNRealLog
import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
import Mathlib.Topology.MetricSpace.Polish
/-!
# Properties of the extended logarithm and exponential
We prove that `log` and `exp` define order isomorphisms between `ββ₯0β` and `EReal`.
## Main DefinitionsP
- `ENNReal.logOrderIso`: The order isomorphism between `ββ₯0β` and `EReal` defined by `log`
and `exp`.
- `EReal.expOrderIso`: The order isomorphism between `EReal` and `ββ₯0β` defined by `exp`
and `log`.
- `ENNReal.logHomeomorph`: `log` as a homeomorphism.
- `EReal.expHomeomorph`: `exp` as a homeomorphism.
## Main Results
- `EReal.log_exp`, `ENNReal.exp_log`: `log` and `exp` are inverses of each other.
- `EReal.exp_nmul`, `EReal.exp_mul`: `exp` satisfies the identities `exp (n * x) = (exp x) ^ n`
and `exp (x * y) = (exp x) ^ y`.
- `EReal` is a Polish space.
## Tags
ENNReal, EReal, logarithm, exponential
-/
open EReal ENNReal Topology
section LogExp
@[simp] lemma EReal.log_exp (x : EReal) : log (exp x) = x := by
induction x
Β· simp
Β· rw [exp_coe, log_ofReal, if_neg (not_le.mpr (Real.exp_pos _)), Real.log_exp]
Β· simp
@[simp] lemma ENNReal.exp_log (x : ββ₯0β) : exp (log x) = x := by
by_cases hx_top : x = β
Β· simp [hx_top]
by_cases hx_zero : x = 0
Β· simp [hx_zero]
have hx_pos : 0 < x.toReal := ENNReal.toReal_pos hx_zero hx_top
rw [β ENNReal.ofReal_toReal hx_top, log_ofReal_of_pos hx_pos, exp_coe, Real.exp_log hx_pos]
end LogExp
section Exp
namespace EReal
lemma exp_nmul (x : EReal) (n : β) : exp (n * x) = (exp x) ^ n := by
simp_rw [β log_eq_iff, log_pow, log_exp]
lemma exp_mul (x : EReal) (y : β) : exp (x * y) = (exp x) ^ y := by
rw [β log_eq_iff, log_rpow, log_exp, log_exp, mul_comm]
lemma ENNReal.rpow_eq_exp_mul_log (x : ββ₯0β) (y : β) : x ^ y = exp (y * log x) := by
rw [mul_comm, EReal.exp_mul, exp_log]
end EReal
end Exp
namespace ENNReal
section OrderIso
/-- `ENNReal.log` and its inverse `EReal.exp` are an order isomorphism between `ββ₯0β` and
`EReal`. -/
noncomputable
def logOrderIso : ββ₯0β βo EReal where
toFun := log
invFun := exp
left_inv x := exp_log x
right_inv x := log_exp x
map_rel_iff' := by simp only [Equiv.coe_fn_mk, log_le_log_iff, forall_const]
@[simp] lemma logOrderIso_apply (x : ββ₯0β) : logOrderIso x = log x := rfl
/-- `EReal.exp` and its inverse `ENNReal.log` are an order isomorphism between `EReal` and
`ββ₯0β`. -/
noncomputable
def _root_.EReal.expOrderIso := logOrderIso.symm
@[simp] lemma _root_.EReal.expOrderIso_apply (x : EReal) : expOrderIso x = exp x := rfl
@[simp] lemma logOrderIso_symm : logOrderIso.symm = expOrderIso := rfl
@[simp] lemma _root_.EReal.expOrderIso_symm : expOrderIso.symm = logOrderIso := rfl
end OrderIso
section Continuity
/-- `log` as a homeomorphism. -/
noncomputable def logHomeomorph : ββ₯0β ββ EReal := logOrderIso.toHomeomorph
@[simp] lemma logHomeomorph_apply (x : ββ₯0β) : logHomeomorph x = log x := rfl
/-- `exp` as a homeomorphism. -/
noncomputable def _root_.EReal.expHomeomorph : EReal ββ ββ₯0β := expOrderIso.toHomeomorph
@[simp] lemma _root_.EReal.expHomeomorph_apply (x : EReal) : expHomeomorph x = exp x := rfl
@[simp] lemma logHomeomorph_symm : logHomeomorph.symm = expHomeomorph := rfl
@[simp] lemma _root_.EReal.expHomeomorph_symm : expHomeomorph.symm = logHomeomorph := rfl
@[continuity, fun_prop]
lemma continuous_log : Continuous log := logOrderIso.continuous
@[continuity, fun_prop]
lemma continuous_exp : Continuous exp := expOrderIso.continuous
lemma _root_.EReal.tendsto_exp_nhds_top_nhds_top : Filter.Tendsto exp (π β€) (π β€) :=
continuous_exp.tendsto β€
lemma _root_.EReal.tendsto_exp_nhds_zero_nhds_one : Filter.Tendsto exp (π 0) (π 1) := by
convert continuous_exp.tendsto 0
simp
lemma _root_.EReal.tendsto_exp_nhds_bot_nhds_zero : Filter.Tendsto exp (π β₯) (π 0) :=
continuous_exp.tendsto β₯
lemma tendsto_rpow_atTop_of_one_lt_base {b : ββ₯0β} (hb : 1 < b) :
Filter.Tendsto (b ^ Β· : β β ββ₯0β) Filter.atTop (π β€) := by
simp_rw [ENNReal.rpow_eq_exp_mul_log]
refine EReal.tendsto_exp_nhds_top_nhds_top.comp ?_
convert EReal.Tendsto.mul_const tendsto_coe_atTop _ _
Β· rw [EReal.top_mul_of_pos (zero_lt_log_iff.2 hb)]
all_goals simp
lemma tendsto_rpow_atTop_of_base_lt_one {b : ββ₯0β} (hb : b < 1) :
Filter.Tendsto (b ^ Β· : β β ββ₯0β) Filter.atTop (π 0) := by
simp_rw [ENNReal.rpow_eq_exp_mul_log]
refine EReal.tendsto_exp_nhds_bot_nhds_zero.comp ?_
convert EReal.Tendsto.mul_const tendsto_coe_atTop _ _
Β· rw [EReal.top_mul_of_neg (log_lt_zero_iff.2 hb)]
all_goals simp
lemma tendsto_rpow_atBot_of_one_lt_base {b : ββ₯0β} (hb : 1 < b) :
Filter.Tendsto (b ^ Β· : β β ββ₯0β) Filter.atBot (π 0) := by
simp_rw [ENNReal.rpow_eq_exp_mul_log]
refine EReal.tendsto_exp_nhds_bot_nhds_zero.comp ?_
convert EReal.Tendsto.mul_const tendsto_coe_atBot _ _
Β· rw [EReal.bot_mul_of_pos (zero_lt_log_iff.2 hb)]
all_goals simp
lemma tendsto_rpow_atBot_of_base_lt_one {b : ββ₯0β} (hb : b < 1) :
Filter.Tendsto (b ^ Β· : β β ββ₯0β) Filter.atBot (π β€) := by
simp_rw [ENNReal.rpow_eq_exp_mul_log]
refine EReal.tendsto_exp_nhds_top_nhds_top.comp ?_
convert EReal.Tendsto.mul_const tendsto_coe_atBot _ _
Β· rw [EReal.bot_mul_of_neg (log_lt_zero_iff.2 hb)]
all_goals simp
end Continuity
section Measurability
@[measurability, fun_prop]
lemma measurable_log : Measurable log := continuous_log.measurable
@[measurability, fun_prop]
lemma _root_.EReal.measurable_exp : Measurable exp := continuous_exp.measurable
@[measurability, fun_prop]
lemma _root_.Measurable.ennreal_log {Ξ± : Type*} {_ : MeasurableSpace Ξ±}
{f : Ξ± β ββ₯0β} (hf : Measurable f) :
Measurable fun x β¦ log (f x) := measurable_log.comp hf
@[measurability, fun_prop]
lemma _root_.Measurable.ereal_exp {Ξ± : Type*} {_ : MeasurableSpace Ξ±}
{f : Ξ± β EReal} (hf : Measurable f) :
Measurable fun x β¦ exp (f x) := measurable_exp.comp hf
end Measurability
end ENNReal
instance : PolishSpace EReal := ENNReal.logOrderIso.symm.toHomeomorph.isClosedEmbedding.polishSpace |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/PosLog.lean | import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# The Positive Part of the Logarithm
This file defines the function `Real.posLog = r β¦ max 0 (log r)` and introduces the notation
`logβΊ`. For a finite length-`n` sequence `f i` of reals, it establishes the following standard
estimates.
- `theorem posLog_prod : logβΊ (β i, f i) β€ β i, logβΊ (f i)`
- `theorem posLog_sum : logβΊ (β i, f i) β€ log n + β i, logβΊ (f i)`
See `Mathlib/Analysis/SpecialFunctions/Integrals/PosLogEqCircleAverage.lean` for the presentation of
`logβΊ` as a Circle Average.
-/
namespace Real
variable {x y : β}
/-!
## Definition, Notation and Reformulations
-/
/-- Definition: the positive part of the logarithm. -/
noncomputable def posLog : β β β := fun r β¦ max 0 (log r)
/-- Notation `logβΊ` for the positive part of the logarithm. -/
scoped notation "logβΊ" => posLog
/-- Definition of the positive part of the logarithm, formulated as a theorem. -/
theorem posLog_def : logβΊ x = max 0 (log x) := rfl
/-!
## Elementary Properties
-/
/-- Presentation of `log` in terms of its positive part. -/
theorem posLog_sub_posLog_inv : logβΊ x - logβΊ xβ»ΒΉ = log x := by
rw [posLog_def, posLog_def, log_inv]
by_cases! h : 0 β€ log x
Β· simp [h]
Β· simp [neg_nonneg.1 (Left.nonneg_neg_iff.2 h.le)]
/-- Presentation of `logβΊ` in terms of `log`. -/
theorem half_mul_log_add_log_abs : 2β»ΒΉ * (log x + |log x|) = logβΊ x := by
by_cases! hr : 0 β€ log x
Β· simp [posLog, hr, abs_of_nonneg]
ring
Β· simp [posLog, hr.le, abs_of_nonpos]
@[simp] lemma posLog_zero : logβΊ 0 = 0 := by simp [posLog]
@[simp] lemma posLog_one : logβΊ 1 = 0 := by simp [posLog]
/-- The positive part of `log` is never negative. -/
theorem posLog_nonneg : 0 β€ logβΊ x := by simp [posLog]
/-- The function `logβΊ` is even. -/
@[simp] theorem posLog_neg (x : β) : logβΊ (-x) = logβΊ x := by simp [posLog]
/-- The function `logβΊ` is even. -/
@[simp] theorem posLog_abs (x : β) : logβΊ |x| = logβΊ x := by simp [posLog]
/-- The function `logβΊ` is zero in the interval [-1,1]. -/
theorem posLog_eq_zero_iff (x : β) : logβΊ x = 0 β |x| β€ 1 := by
rw [β posLog_abs, β log_nonpos_iff (abs_nonneg x)]
simp [posLog]
/-- The function `logβΊ` equals `log` outside of the interval (-1,1). -/
theorem posLog_eq_log (hx : 1 β€ |x|) : logβΊ x = log x := by
simp only [posLog, sup_eq_right]
rw [β log_abs]
apply log_nonneg hx
/-- The function `logβΊ` equals `log` for all natural numbers. -/
theorem log_of_nat_eq_posLog {n : β} : logβΊ n = log n := by
by_cases hn : n = 0
Β· simp [hn, posLog]
Β· simp [posLog_eq_log, Nat.one_le_iff_ne_zero.2 hn]
/-- The function `logβΊ` equals `log (max 1 _)` for non-negative real numbers. -/
theorem posLog_eq_log_max_one (hx : 0 β€ x) : logβΊ x = log (max 1 x) := by
grind [le_abs, posLog_eq_log, log_one, max_eq_left, log_nonpos, posLog_def]
/-- The function `logβΊ` is monotone on the positive axis. -/
theorem monotoneOn_posLog : MonotoneOn logβΊ (Set.Ici 0) := by
intro x hx y hy hxy
simp only [posLog, le_sup_iff, sup_le_iff, le_refl, true_and]
by_cases! h : log x β€ 0
Β· tauto
Β· right
have := log_le_log (lt_trans Real.zero_lt_one ((log_pos_iff hx).1 h)) hxy
simp only [this, and_true, ge_iff_le]
linarith
@[gcongr]
lemma posLog_le_posLog (hx : 0 β€ x) (hxy : x β€ y) : logβΊ x β€ logβΊ y :=
monotoneOn_posLog hx (hx.trans hxy) hxy
/-- The function `logβΊ` commutes with taking powers. -/
@[simp] lemma posLog_pow (n : β) (x : β) : logβΊ (x ^ n) = n * logβΊ x := by
by_cases hn : n = 0
Β· simp_all
by_cases hx : |x| β€ 1
Β· simp_all [pow_le_oneβ, (posLog_eq_zero_iff _).2]
rw [not_le] at hx
have : 1 β€ |x ^ n| := by simp_all [one_le_powβ, hx.le]
simp [posLog_eq_log this, posLog_eq_log hx.le]
/-!
## Estimates for Products
-/
/-- Estimate for `logβΊ` of a product. See `Real.posLog_prod` for a variant involving
multiple factors. -/
theorem posLog_mul : logβΊ (x * y) β€ logβΊ x + logβΊ y := by
by_cases ha : x = 0
Β· simp [ha, posLog]
by_cases hb : y = 0
Β· simp [hb, posLog]
unfold posLog
nth_rw 1 [β add_zero 0, log_mul ha hb]
exact max_add_add_le_max_add_max
/-- Estimate for `logβΊ` of a product. Special case of `Real.posLog_mul` where one of
the factors is a natural number. -/
theorem posLog_nat_mul {n : β} : logβΊ (n * x) β€ log n + logβΊ x := by
rw [β log_of_nat_eq_posLog]
exact posLog_mul
/-- Estimate for `logβΊ` of a product. See `Real.posLog_mul` for a variant with
only two factors. -/
theorem posLog_prod {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β β) :
logβΊ (β t β s, f t) β€ β t β s, logβΊ (f t) := by
classical
induction s using Finset.induction with
| empty => simp [posLog]
| insert a s ha hs =>
calc logβΊ (β t β insert a s, f t)
_ = logβΊ (f a * β t β s, f t) := by rw [Finset.prod_insert ha]
_ β€ logβΊ (f a) + logβΊ (β t β s, f t) := posLog_mul
_ β€ logβΊ (f a) + β t β s, logβΊ (f t) := add_le_add (by rfl) hs
_ = β t β insert a s, logβΊ (f t) := by rw [Finset.sum_insert ha]
/-!
## Estimates for Sums
-/
/--
Estimate for `logβΊ` of a sum. See `Real.posLog_add` for a variant involving just two summands.
-/
theorem posLog_sum {Ξ± : Type*} (s : Finset Ξ±) (f : Ξ± β β) :
logβΊ (β t β s, f t) β€ log (s.card) + β t β s, logβΊ (f t) := by
-- Trivial case: empty sum
by_cases hs : s = β
Β· simp [hs, posLog]
-- Nontrivial case: Obtain maximal elementβ¦
obtain β¨t_max, ht_maxβ© := s.exists_max_image (fun t β¦ |f t|)
(Finset.nonempty_iff_ne_empty.mpr hs)
-- β¦then calculate
calc logβΊ (β t β s, f t)
_ = logβΊ |β t β s, f t| := by
rw [Real.posLog_abs]
_ β€ logβΊ (β t β s, |f t|) := by
apply monotoneOn_posLog (by simp) (by simp [Finset.sum_nonneg])
simp [Finset.abs_sum_le_sum_abs]
_ β€ logβΊ (β t β s, |f t_max|) := by
apply monotoneOn_posLog (by simp [Finset.sum_nonneg]) (by simp; positivity)
apply Finset.sum_le_sum (fun i ih β¦ ht_max.2 i ih)
_ = logβΊ (s.card * |f t_max|) := by
simp [Finset.sum_const]
_ β€ log s.card + logβΊ |f t_max| := posLog_nat_mul
_ β€ log s.card + β t β s, logβΊ (f t) := by
gcongr
rw [posLog_abs]
apply Finset.single_le_sum (fun _ _ β¦ posLog_nonneg) ht_max.1
/--
Variant of `posLog_sum` for norms of elements in normed additive commutative
groups, using monotonicity of `logβΊ` and the triangle inequality.
-/
lemma posLog_norm_sum_le {E : Type*} [SeminormedAddCommGroup E] {Ξ± : Type*} (s : Finset Ξ±)
(f : Ξ± β E) :
logβΊ ββ t β s, f tβ β€ log s.card + β t β s, logβΊ βf tβ := by
grw [norm_sum_le, posLog_sum]
/--
Estimate for `logβΊ` of a sum. See `Real.posLog_sum` for a variant involving multiple summands.
-/
theorem posLog_add : logβΊ (x + y) β€ log 2 + logβΊ x + logβΊ y := by
convert posLog_sum Finset.univ ![x, y] using 1 <;> simp [add_assoc]
/--
Variant of `posLog_add` for norms of elements in normed additive commutative groups, using
monotonicity of `logβΊ` and the triangle inequality.
-/
lemma posLog_norm_add_le {E : Type*} [SeminormedAddCommGroup E] (a b : E) :
logβΊ βa + bβ β€ logβΊ βaβ + logβΊ βbβ + log 2 := by
grw [norm_add_le, posLog_add, add_rotate]
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean | import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Logarithm Tonality
In this file we describe the tonality of the logarithm function when multiplied by functions of the
form `x ^ a`.
## Tags
logarithm, tonality
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
theorem log_mul_self_monotoneOn : MonotoneOn (fun x : β => log x * x) { x | 1 β€ x } := by
-- TODO: can be strengthened to exp (-1) β€ x
simp only [MonotoneOn, mem_setOf_eq]
intro x hex y hey hxy
have y_pos : 0 < y := lt_of_lt_of_le zero_lt_one hey
gcongr
rwa [le_log_iff_exp_le y_pos, Real.exp_zero]
theorem log_div_self_antitoneOn : AntitoneOn (fun x : β => log x / x) { x | exp 1 β€ x } := by
simp only [AntitoneOn, mem_setOf_eq]
intro x hex y hey hxy
have x_pos : 0 < x := (exp_pos 1).trans_le hex
have y_pos : 0 < y := (exp_pos 1).trans_le hey
have hlogx : 1 β€ log x := by rwa [le_log_iff_exp_le x_pos]
have hyx : 0 β€ y / x - 1 := by rwa [le_sub_iff_add_le, le_div_iffβ x_pos, zero_add, one_mul]
rw [div_le_iffβ y_pos, β sub_le_sub_iff_right (log x)]
calc
log y - log x = log (y / x) := by rw [log_div y_pos.ne' x_pos.ne']
_ β€ y / x - 1 := log_le_sub_one_of_pos (div_pos y_pos x_pos)
_ β€ log x * (y / x - 1) := le_mul_of_one_le_left hyx hlogx
_ = log x / x * y - log x := by ring
theorem log_div_self_rpow_antitoneOn {a : β} (ha : 0 < a) :
AntitoneOn (fun x : β => log x / x ^ a) { x | exp (1 / a) β€ x } := by
simp only [AntitoneOn, mem_setOf_eq]
intro x hex y _ hxy
have x_pos : 0 < x := lt_of_lt_of_le (exp_pos (1 / a)) hex
have y_pos : 0 < y := by linarith
nth_rw 1 [β rpow_one y]
nth_rw 1 [β rpow_one x]
rw [β div_self (ne_of_lt ha).symm, div_eq_mul_one_div a a, rpow_mul y_pos.le, rpow_mul x_pos.le,
log_rpow (rpow_pos_of_pos y_pos a), log_rpow (rpow_pos_of_pos x_pos a), mul_div_assoc,
mul_div_assoc, mul_le_mul_iff_rightβ (one_div_pos.mpr ha)]
refine log_div_self_antitoneOn ?_ ?_ ?_
Β· simp only [Set.mem_setOf_eq]
convert rpow_le_rpow _ hex (le_of_lt ha) using 1
Β· rw [β exp_mul]
simp only [Real.exp_eq_exp]
field
positivity
Β· simp only [Set.mem_setOf_eq]
convert rpow_le_rpow _ (_root_.trans hex hxy) (le_of_lt ha) using 1
Β· rw [β exp_mul]
simp only [Real.exp_eq_exp]
field
positivity
gcongr
theorem log_div_sqrt_antitoneOn : AntitoneOn (fun x : β => log x / βx) { x | exp 2 β€ x } := by
simp_rw [sqrt_eq_rpow]
convert log_div_self_rpow_antitoneOn one_half_pos
norm_num
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecialFunctions/Log/NegMulLog.lean | import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
import Mathlib.Analysis.Convex.Deriv
/-!
# The function `x β¦ - x * log x`
The purpose of this file is to record basic analytic properties of the function `x β¦ - x * log x`,
which is notably used in the theory of Shannon entropy.
## Main definitions
* `negMulLog`: the function `x β¦ - x * log x` from `β` to `β`.
-/
open scoped Topology
namespace Real
@[fun_prop]
lemma continuous_mul_log : Continuous fun x β¦ x * log x := by
rw [continuous_iff_continuousAt]
intro x
obtain hx | rfl := ne_or_eq x 0
Β· exact (continuous_id'.continuousAt).mul (continuousAt_log hx)
rw [ContinuousAt, zero_mul]
simp_rw [mul_comm _ (log _)]
nth_rewrite 1 [β nhdsWithin_univ]
have : (Set.univ : Set β) = Set.Iio 0 βͺ Set.Ioi 0 βͺ {0} := by ext; simp [em]
rw [this, nhdsWithin_union, nhdsWithin_union]
simp only [nhdsWithin_singleton, Filter.tendsto_sup]
refine β¨β¨tendsto_log_mul_self_nhdsLT_zero, ?_β©, ?_β©
Β· simpa only [rpow_one] using tendsto_log_mul_rpow_nhdsGT_zero zero_lt_one
Β· convert tendsto_pure_nhds (fun x β¦ log x * x) 0
simp
@[fun_prop]
lemma Continuous.mul_log {Ξ± : Type*} [TopologicalSpace Ξ±] {f : Ξ± β β} (hf : Continuous f) :
Continuous fun a β¦ f a * log (f a) := continuous_mul_log.comp hf
lemma differentiableOn_mul_log : DifferentiableOn β (fun x β¦ x * log x) {0}αΆ :=
differentiable_id.differentiableOn.mul differentiableOn_log
lemma deriv_mul_log {x : β} (hx : x β 0) : deriv (fun x β¦ x * log x) x = log x + 1 := by
simp [hx]
lemma hasDerivAt_mul_log {x : β} (hx : x β 0) : HasDerivAt (fun x β¦ x * log x) (log x + 1) x := by
rw [β deriv_mul_log hx, hasDerivAt_deriv_iff]
refine DifferentiableOn.differentiableAt differentiableOn_mul_log ?_
simp [hx]
@[simp]
lemma rightDeriv_mul_log {x : β} (hx : x β 0) :
derivWithin (fun x β¦ x * log x) (Set.Ioi x) x = log x + 1 :=
(hasDerivAt_mul_log hx).hasDerivWithinAt.derivWithin (uniqueDiffWithinAt_Ioi x)
@[simp]
lemma leftDeriv_mul_log {x : β} (hx : x β 0) :
derivWithin (fun x β¦ x * log x) (Set.Iio x) x = log x + 1 :=
(hasDerivAt_mul_log hx).hasDerivWithinAt.derivWithin (uniqueDiffWithinAt_Iio x)
open Filter in
private lemma tendsto_deriv_mul_log_nhdsWithin_zero :
Tendsto (deriv (fun x β¦ x * log x)) (π[>] 0) atBot := by
have : (deriv (fun x β¦ x * log x)) =αΆ [π[>] 0] (fun x β¦ log x + 1) := by
apply eventuallyEq_nhdsWithin_of_eqOn
intro x hx
rw [Set.mem_Ioi] at hx
exact deriv_mul_log hx.ne'
simp only [tendsto_congr' this, tendsto_atBot_add_const_right, tendsto_log_nhdsGT_zero]
open Filter in
lemma tendsto_deriv_mul_log_atTop :
Tendsto (fun x β¦ deriv (fun x β¦ x * log x) x) atTop atTop := by
refine (tendsto_congr' ?_).mpr (tendsto_log_atTop.atTop_add (tendsto_const_nhds (x := 1)))
rw [EventuallyEq, eventually_atTop]
exact β¨1, fun _ hx β¦ deriv_mul_log (zero_lt_one.trans_le hx).ne'β©
open Filter in
lemma tendsto_rightDeriv_mul_log_atTop :
Tendsto (fun x β¦ derivWithin (fun x β¦ x * log x) (Set.Ioi x) x) atTop atTop := by
refine (tendsto_congr' ?_).mpr (tendsto_log_atTop.atTop_add (tendsto_const_nhds (x := 1)))
rw [EventuallyEq, eventually_atTop]
exact β¨1, fun _ hx β¦ rightDeriv_mul_log (zero_lt_one.trans_le hx).ne'β©
/-- At `x=0`, `(fun x β¦ x * log x)` is not differentiable
(but note that it is continuous, see `continuous_mul_log`). -/
lemma not_DifferentiableAt_log_mul_zero :
Β¬ DifferentiableAt β (fun x β¦ x * log x) 0 := fun h β¦
(not_differentiableWithinAt_of_deriv_tendsto_atBot_Ioi (fun x : β β¦ x * log x) (a := 0))
tendsto_deriv_mul_log_nhdsWithin_zero
(h.differentiableWithinAt (s := Set.Ioi 0))
/-- Not differentiable, hence `deriv` has junk value zero. -/
lemma deriv_mul_log_zero : deriv (fun x β¦ x * log x) 0 = 0 :=
deriv_zero_of_not_differentiableAt not_DifferentiableAt_log_mul_zero
lemma not_continuousAt_deriv_mul_log_zero :
Β¬ ContinuousAt (deriv (fun (x : β) β¦ x * log x)) 0 :=
not_continuousAt_of_tendsto tendsto_deriv_mul_log_nhdsWithin_zero nhdsWithin_le_nhds (by simp)
lemma deriv2_mul_log (x : β) : deriv^[2] (fun x β¦ x * log x) x = xβ»ΒΉ := by
simp only [Function.iterate_succ, Function.iterate_zero, Function.id_comp, Function.comp_apply]
by_cases hx : x = 0
Β· rw [hx, inv_zero]
exact deriv_zero_of_not_differentiableAt
(fun h β¦ not_continuousAt_deriv_mul_log_zero h.continuousAt)
Β· suffices βαΆ y in (π x), deriv (fun x β¦ x * log x) y = log y + 1 by
refine (Filter.EventuallyEq.deriv_eq this).trans ?_
rw [deriv_add_const, deriv_log x]
filter_upwards [eventually_ne_nhds hx] with y hy using deriv_mul_log hy
lemma strictConvexOn_mul_log : StrictConvexOn β (Set.Ici (0 : β)) (fun x β¦ x * log x) := by
refine strictConvexOn_of_deriv2_pos (convex_Ici 0) (continuous_mul_log.continuousOn) ?_
intro x hx
simp only [Set.nonempty_Iio, interior_Ici', Set.mem_Ioi] at hx
rw [deriv2_mul_log]
positivity
lemma convexOn_mul_log : ConvexOn β (Set.Ici (0 : β)) (fun x β¦ x * log x) :=
strictConvexOn_mul_log.convexOn
lemma mul_log_nonneg {x : β} (hx : 1 β€ x) : 0 β€ x * log x :=
mul_nonneg (zero_le_one.trans hx) (log_nonneg hx)
lemma mul_log_nonpos {x : β} (hxβ : 0 β€ x) (hxβ : x β€ 1) : x * log x β€ 0 :=
mul_nonpos_of_nonneg_of_nonpos hxβ (log_nonpos hxβ hxβ)
section negMulLog
/-- The function `x β¦ - x * log x` from `β` to `β`. -/
noncomputable def negMulLog (x : β) : β := - x * log x
lemma negMulLog_def : negMulLog = fun x β¦ - x * log x := rfl
lemma negMulLog_eq_neg : negMulLog = fun x β¦ - (x * log x) := by simp [negMulLog_def]
@[simp] lemma negMulLog_zero : negMulLog (0 : β) = 0 := by simp [negMulLog]
@[simp] lemma negMulLog_one : negMulLog (1 : β) = 0 := by simp [negMulLog]
lemma negMulLog_nonneg {x : β} (h1 : 0 β€ x) (h2 : x β€ 1) : 0 β€ negMulLog x := by
simpa only [negMulLog_eq_neg, neg_nonneg] using mul_log_nonpos h1 h2
lemma negMulLog_mul (x y : β) : negMulLog (x * y) = y * negMulLog x + x * negMulLog y := by
simp only [negMulLog, neg_mul]
by_cases hx : x = 0
Β· simp [hx]
by_cases hy : y = 0
Β· simp [hy]
rw [log_mul hx hy]
ring
@[fun_prop] lemma continuous_negMulLog : Continuous negMulLog := by
simpa only [negMulLog_eq_neg] using continuous_mul_log.neg
lemma differentiableOn_negMulLog : DifferentiableOn β negMulLog {0}αΆ := by
simpa only [negMulLog_eq_neg] using differentiableOn_mul_log.neg
lemma differentiableAt_negMulLog_iff {x : β} : DifferentiableAt β negMulLog x β x β 0 := by
constructor
Β· unfold negMulLog
intro h eq0
simp only [neg_mul, differentiableAt_fun_neg_iff, eq0] at h
exact not_DifferentiableAt_log_mul_zero h
Β· intro hx
have : x β ({0} : Set β)αΆ := by
simp_all only [ne_eq, Set.mem_compl_iff, Set.mem_singleton_iff, not_false_eq_true]
have := differentiableOn_negMulLog x this
apply DifferentiableWithinAt.differentiableAt (s := {0}αΆ) <;>
simp_all only [ne_eq, Set.mem_compl_iff, Set.mem_singleton_iff, not_false_eq_true,
compl_singleton_mem_nhds_iff]
@[fun_prop] alias β¨_, differentiableAt_negMulLogβ© := differentiableAt_negMulLog_iff
lemma deriv_negMulLog {x : β} (hx : x β 0) : deriv negMulLog x = - log x - 1 := by
rw [negMulLog_eq_neg, deriv.fun_neg, deriv_mul_log hx]
ring
lemma hasDerivAt_negMulLog {x : β} (hx : x β 0) : HasDerivAt negMulLog (- log x - 1) x := by
rw [β deriv_negMulLog hx, hasDerivAt_deriv_iff]
refine DifferentiableOn.differentiableAt differentiableOn_negMulLog ?_
simp [hx]
lemma deriv2_negMulLog (x : β) : deriv^[2] negMulLog x = - xβ»ΒΉ := by
rw [negMulLog_eq_neg]
have h := deriv2_mul_log
simp only [Function.iterate_succ, Function.iterate_zero, Function.id_comp, deriv.fun_neg',
Function.comp_apply] at h β’
rw [h]
lemma strictConcaveOn_negMulLog : StrictConcaveOn β (Set.Ici (0 : β)) negMulLog := by
simpa only [negMulLog_eq_neg] using strictConvexOn_mul_log.neg
lemma concaveOn_negMulLog : ConcaveOn β (Set.Ici (0 : β)) negMulLog :=
strictConcaveOn_negMulLog.concaveOn
end negMulLog
end Real |
.lake/packages/mathlib/Mathlib/Analysis/SpecificLimits/RCLike.lean | import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Analysis.RCLike.Basic
/-!
# A collection of specific limit computations for `RCLike`
-/
open Set Algebra Filter
open scoped Topology
namespace RCLike
variable (π : Type*) [RCLike π]
theorem tendsto_ofReal_cobounded_cobounded :
Tendsto ofReal (Bornology.cobounded β) (Bornology.cobounded π) :=
tendsto_norm_atTop_iff_cobounded.mp (mod_cast tendsto_norm_cobounded_atTop)
theorem tendsto_ofReal_atTop_cobounded :
Tendsto ofReal atTop (Bornology.cobounded π) :=
tendsto_norm_atTop_iff_cobounded.mp (mod_cast tendsto_abs_atTop_atTop)
theorem tendsto_ofReal_atBot_cobounded :
Tendsto ofReal atBot (Bornology.cobounded π) :=
tendsto_norm_atTop_iff_cobounded.mp (mod_cast tendsto_abs_atBot_atTop)
end RCLike
@[deprecated (since := "2025-10-27")]
alias RCLike.tendsto_inverse_atTop_nhds_zero_nat := tendsto_inv_atTop_nhds_zero_nat
@[deprecated (since := "2025-10-27")]
alias RCLike.tendsto_add_mul_div_add_mul_atTop_nhds := tendsto_add_mul_div_add_mul_atTop_nhds |
.lake/packages/mathlib/Mathlib/Analysis/SpecificLimits/Normed.lean | import Mathlib.Algebra.BigOperators.Module
import Mathlib.Algebra.Order.Field.Power
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Analysis.Asymptotics.Lemmas
import Mathlib.Analysis.Normed.Ring.InfiniteSum
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Analysis.Normed.Order.Lattice
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.List.TFAE
import Mathlib.Data.Nat.Choose.Bounds
import Mathlib.Order.Filter.AtTopBot.ModEq
import Mathlib.RingTheory.Polynomial.Pochhammer
import Mathlib.Tactic.NoncommRing
/-!
# A collection of specific limit computations
This file contains important specific limit computations in (semi-)normed groups/rings/spaces, as
well as such computations in `β` when the natural proof passes through a fact about normed spaces.
-/
noncomputable section
open Set Function Filter Finset Metric Asymptotics Topology Nat NNReal ENNReal
variable {Ξ± : Type*}
theorem tendsto_natCast_atTop_cobounded
[NormedRing Ξ±] [NormSMulClass β€ Ξ±] [Nontrivial Ξ±] :
Tendsto Nat.cast atTop (Bornology.cobounded Ξ±) := by
rw [β tendsto_norm_atTop_iff_cobounded]
simpa [norm_natCast_eq_mul_norm_one] using tendsto_natCast_atTop_atTop
|>.atTop_mul_const (norm_pos_iff.mpr one_ne_zero)
theorem tendsto_intCast_atBot_sup_atTop_cobounded
[NormedRing Ξ±] [NormSMulClass β€ Ξ±] [Nontrivial Ξ±] :
Tendsto Int.cast (atBot β atTop) (Bornology.cobounded Ξ±) := by
rw [β tendsto_norm_atTop_iff_cobounded]
simpa [norm_intCast_eq_abs_mul_norm_one] using tendsto_intCast_atTop_atTop
|>.comp (tendsto_abs_atBot_atTop.sup tendsto_abs_atTop_atTop)
|>.atTop_mul_const (norm_pos_iff.mpr one_ne_zero)
theorem tendsto_intCast_atBot_cobounded
[NormedRing Ξ±] [NormSMulClass β€ Ξ±] [Nontrivial Ξ±] :
Tendsto Int.cast atBot (Bornology.cobounded Ξ±) :=
tendsto_intCast_atBot_sup_atTop_cobounded.mono_left le_sup_left
theorem tendsto_intCast_atTop_cobounded
[NormedRing Ξ±] [NormSMulClass β€ Ξ±] [Nontrivial Ξ±] :
Tendsto Int.cast atTop (Bornology.cobounded Ξ±) :=
tendsto_intCast_atBot_sup_atTop_cobounded.mono_left le_sup_right
/-! ### Powers -/
theorem isLittleO_pow_pow_of_lt_left {rβ rβ : β} (hβ : 0 β€ rβ) (hβ : rβ < rβ) :
(fun n : β β¦ rβ ^ n) =o[atTop] fun n β¦ rβ ^ n :=
have H : 0 < rβ := hβ.trans_lt hβ
(isLittleO_of_tendsto fun _ hn β¦ False.elim <| H.ne' <| eq_zero_of_pow_eq_zero hn) <|
(tendsto_pow_atTop_nhds_zero_of_lt_one
(div_nonneg hβ (hβ.trans hβ.le)) ((div_lt_one H).2 hβ)).congr fun _ β¦ div_pow _ _ _
theorem isBigO_pow_pow_of_le_left {rβ rβ : β} (hβ : 0 β€ rβ) (hβ : rβ β€ rβ) :
(fun n : β β¦ rβ ^ n) =O[atTop] fun n β¦ rβ ^ n :=
hβ.eq_or_lt.elim (fun h β¦ h βΈ isBigO_refl _ _) fun h β¦ (isLittleO_pow_pow_of_lt_left hβ h).isBigO
theorem isLittleO_pow_pow_of_abs_lt_left {rβ rβ : β} (h : |rβ| < |rβ|) :
(fun n : β β¦ rβ ^ n) =o[atTop] fun n β¦ rβ ^ n := by
refine (IsLittleO.of_norm_left ?_).of_norm_right
exact (isLittleO_pow_pow_of_lt_left (abs_nonneg rβ) h).congr (pow_abs rβ) (pow_abs rβ)
open List in
/-- Various statements equivalent to the fact that `f n` grows exponentially slower than `R ^ n`.
* 0: $f n = o(a ^ n)$ for some $-R < a < R$;
* 1: $f n = o(a ^ n)$ for some $0 < a < R$;
* 2: $f n = O(a ^ n)$ for some $-R < a < R$;
* 3: $f n = O(a ^ n)$ for some $0 < a < R$;
* 4: there exist `a < R` and `C` such that one of `C` and `R` is positive and $|f n| β€ Ca^n$
for all `n`;
* 5: there exists `0 < a < R` and a positive `C` such that $|f n| β€ Ca^n$ for all `n`;
* 6: there exists `a < R` such that $|f n| β€ a ^ n$ for sufficiently large `n`;
* 7: there exists `0 < a < R` such that $|f n| β€ a ^ n$ for sufficiently large `n`.
NB: For backwards compatibility, if you add more items to the list, please append them at the end of
the list. -/
theorem TFAE_exists_lt_isLittleO_pow (f : β β β) (R : β) :
TFAE
[β a β Ioo (-R) R, f =o[atTop] (a ^ Β·), β a β Ioo 0 R, f =o[atTop] (a ^ Β·),
β a β Ioo (-R) R, f =O[atTop] (a ^ Β·), β a β Ioo 0 R, f =O[atTop] (a ^ Β·),
β a < R, β C : β, (0 < C β¨ 0 < R) β§ β n, |f n| β€ C * a ^ n,
β a β Ioo 0 R, β C > 0, β n, |f n| β€ C * a ^ n, β a < R, βαΆ n in atTop, |f n| β€ a ^ n,
β a β Ioo 0 R, βαΆ n in atTop, |f n| β€ a ^ n] := by
have A : Ico 0 R β Ioo (-R) R :=
fun x hx β¦ β¨(neg_lt_zero.2 (hx.1.trans_lt hx.2)).trans_le hx.1, hx.2β©
have B : Ioo 0 R β Ioo (-R) R := Subset.trans Ioo_subset_Ico_self A
-- First we prove that 1-4 are equivalent using 2 β 3 β 4, 1 β 3, and 2 β 1
tfae_have 1 β 3 := fun β¨a, ha, Hβ© β¦ β¨a, ha, H.isBigOβ©
tfae_have 2 β 1 := fun β¨a, ha, Hβ© β¦ β¨a, B ha, Hβ©
tfae_have 3 β 2
| β¨a, ha, Hβ© => by
rcases exists_between (abs_lt.2 ha) with β¨b, hab, hbRβ©
exact β¨b, β¨(abs_nonneg a).trans_lt hab, hbRβ©,
H.trans_isLittleO (isLittleO_pow_pow_of_abs_lt_left (hab.trans_le (le_abs_self b)))β©
tfae_have 2 β 4 := fun β¨a, ha, Hβ© β¦ β¨a, ha, H.isBigOβ©
tfae_have 4 β 3 := fun β¨a, ha, Hβ© β¦ β¨a, B ha, Hβ©
-- Add 5 and 6 using 4 β 6 β 5 β 3
tfae_have 4 β 6
| β¨a, ha, Hβ© => by
rcases bound_of_isBigO_nat_atTop H with β¨C, hCβ, hCβ©
refine β¨a, ha, C, hCβ, fun n β¦ ?_β©
simpa only [Real.norm_eq_abs, abs_pow, abs_of_nonneg ha.1.le] using hC (pow_ne_zero n ha.1.ne')
tfae_have 6 β 5 := fun β¨a, ha, C, Hβ, Hβ© β¦ β¨a, ha.2, C, Or.inl Hβ, Hβ©
tfae_have 5 β 3
| β¨a, ha, C, hβ, Hβ© => by
rcases sign_cases_of_C_mul_pow_nonneg fun n β¦ (abs_nonneg _).trans (H n) with (rfl | β¨hCβ, haββ©)
Β· obtain rfl : f = 0 := by
ext n
simpa using H n
simp only [lt_irrefl, false_or] at hβ
exact β¨0, β¨neg_lt_zero.2 hβ, hββ©, isBigO_zero _ _β©
exact β¨a, A β¨haβ, haβ©,
isBigO_of_le' _ fun n β¦ (H n).trans <| mul_le_mul_of_nonneg_left (le_abs_self _) hCβ.leβ©
-- Add 7 and 8 using 2 β 8 β 7 β 3
tfae_have 2 β 8
| β¨a, ha, Hβ© => by
refine β¨a, ha, (H.def zero_lt_one).mono fun n hn β¦ ?_β©
rwa [Real.norm_eq_abs, Real.norm_eq_abs, one_mul, abs_pow, abs_of_pos ha.1] at hn
tfae_have 8 β 7 := fun β¨a, ha, Hβ© β¦ β¨a, ha.2, Hβ©
tfae_have 7 β 3
| β¨a, ha, Hβ© => by
refine β¨a, A β¨?_, haβ©, .of_norm_eventuallyLE Hβ©
exact nonneg_of_eventually_pow_nonneg (H.mono fun n β¦ (abs_nonneg _).trans)
tfae_finish
/-- For any natural `k` and a real `r > 1` we have `n ^ k = o(r ^ n)` as `n β β`. -/
theorem isLittleO_pow_const_const_pow_of_one_lt {R : Type*} [NormedRing R] (k : β) {r : β}
(hr : 1 < r) : (fun n β¦ (n : R) ^ k : β β R) =o[atTop] fun n β¦ r ^ n := by
have : Tendsto (fun x : β β¦ x ^ k) (π[>] 1) (π 1) :=
((continuous_id.pow k).tendsto' (1 : β) 1 (one_pow _)).mono_left inf_le_left
obtain β¨r' : β, hr' : r' ^ k < r, h1 : 1 < r'β© :=
((this.eventually (gt_mem_nhds hr)).and self_mem_nhdsWithin).exists
have h0 : 0 β€ r' := zero_le_one.trans h1.le
suffices (fun n β¦ (n : R) ^ k : β β R) =O[atTop] fun n : β β¦ (r' ^ k) ^ n from
this.trans_isLittleO (isLittleO_pow_pow_of_lt_left (pow_nonneg h0 _) hr')
conv in (r' ^ _) ^ _ => rw [β pow_mul, mul_comm, pow_mul]
suffices β n : β, β(n : R)β β€ (r' - 1)β»ΒΉ * β(1 : R)β * βr' ^ nβ from
(isBigO_of_le' _ this).pow _
intro n
rw [mul_right_comm]
refine n.norm_cast_le.trans (mul_le_mul_of_nonneg_right ?_ (norm_nonneg _))
simpa [_root_.div_eq_inv_mul, Real.norm_eq_abs, abs_of_nonneg h0] using n.cast_le_pow_div_sub h1
/-- For a real `r > 1` we have `n = o(r ^ n)` as `n β β`. -/
theorem isLittleO_coe_const_pow_of_one_lt {R : Type*} [NormedRing R] {r : β} (hr : 1 < r) :
((β) : β β R) =o[atTop] fun n β¦ r ^ n := by
simpa only [pow_one] using @isLittleO_pow_const_const_pow_of_one_lt R _ 1 _ hr
/-- If `βrββ < rβ`, then for any natural `k` we have `n ^ k rβ ^ n = o (rβ ^ n)` as `n β β`. -/
theorem isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type*} [NormedRing R] (k : β)
{rβ : R} {rβ : β} (h : βrββ < rβ) :
(fun n β¦ (n : R) ^ k * rβ ^ n : β β R) =o[atTop] fun n β¦ rβ ^ n := by
by_cases h0 : rβ = 0
Β· refine (isLittleO_zero _ _).congr' (mem_atTop_sets.2 <| β¨1, fun n hn β¦ ?_β©) EventuallyEq.rfl
simp [zero_pow (one_le_iff_ne_zero.1 hn), h0]
rw [β Ne, β norm_pos_iff] at h0
have A : (fun n β¦ (n : R) ^ k : β β R) =o[atTop] fun n β¦ (rβ / βrββ) ^ n :=
isLittleO_pow_const_const_pow_of_one_lt k ((one_lt_div h0).2 h)
suffices (fun n β¦ rβ ^ n) =O[atTop] fun n β¦ βrββ ^ n by
simpa [div_mul_cancelβ _ (pow_pos h0 _).ne', div_pow] using A.mul_isBigO this
exact .of_norm_eventuallyLE <| eventually_norm_pow_le rβ
theorem tendsto_pow_const_div_const_pow_of_one_lt (k : β) {r : β} (hr : 1 < r) :
Tendsto (fun n β¦ (n : β) ^ k / r ^ n : β β β) atTop (π 0) :=
(isLittleO_pow_const_const_pow_of_one_lt k hr).tendsto_div_nhds_zero
/-- If `|r| < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`. -/
theorem tendsto_pow_const_mul_const_pow_of_abs_lt_one (k : β) {r : β} (hr : |r| < 1) :
Tendsto (fun n β¦ (n : β) ^ k * r ^ n : β β β) atTop (π 0) := by
by_cases h0 : r = 0
Β· exact tendsto_const_nhds.congr'
(mem_atTop_sets.2 β¨1, fun n hn β¦ by simp [zero_lt_one.trans_le hn |>.ne', h0]β©)
have hr' : 1 < |r|β»ΒΉ := (one_lt_invβ (abs_pos.2 h0)).2 hr
rw [tendsto_zero_iff_norm_tendsto_zero]
simpa [div_eq_mul_inv] using tendsto_pow_const_div_const_pow_of_one_lt k hr'
/-- For `k β 0` and a constant `r` the function `r / n ^ k` tends to zero. -/
lemma tendsto_const_div_pow (r : β) (k : β) (hk : k β 0) :
Tendsto (fun n : β => r / n ^ k) atTop (π 0) := by
simpa using Filter.Tendsto.const_div_atTop (tendsto_natCast_atTop_atTop (R := β).comp
(tendsto_pow_atTop hk) ) r
/-- If `0 β€ r < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`.
This is a specialized version of `tendsto_pow_const_mul_const_pow_of_abs_lt_one`, singled out
for ease of application. -/
theorem tendsto_pow_const_mul_const_pow_of_lt_one (k : β) {r : β} (hr : 0 β€ r) (h'r : r < 1) :
Tendsto (fun n β¦ (n : β) ^ k * r ^ n : β β β) atTop (π 0) :=
tendsto_pow_const_mul_const_pow_of_abs_lt_one k (abs_lt.2 β¨neg_one_lt_zero.trans_le hr, h'rβ©)
/-- If `|r| < 1`, then `n * r ^ n` tends to zero. -/
theorem tendsto_self_mul_const_pow_of_abs_lt_one {r : β} (hr : |r| < 1) :
Tendsto (fun n β¦ n * r ^ n : β β β) atTop (π 0) := by
simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_abs_lt_one 1 hr
/-- If `0 β€ r < 1`, then `n * r ^ n` tends to zero. This is a specialized version of
`tendsto_self_mul_const_pow_of_abs_lt_one`, singled out for ease of application. -/
theorem tendsto_self_mul_const_pow_of_lt_one {r : β} (hr : 0 β€ r) (h'r : r < 1) :
Tendsto (fun n β¦ n * r ^ n : β β β) atTop (π 0) := by
simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_lt_one 1 hr h'r
/-- In a normed ring, the powers of an element x with `βxβ < 1` tend to zero. -/
theorem tendsto_pow_atTop_nhds_zero_of_norm_lt_one {R : Type*} [SeminormedRing R] {x : R}
(h : βxβ < 1) :
Tendsto (fun n : β β¦ x ^ n) atTop (π 0) := by
apply squeeze_zero_norm' (eventually_norm_pow_le x)
exact tendsto_pow_atTop_nhds_zero_of_lt_one (norm_nonneg _) h
theorem tendsto_pow_atTop_nhds_zero_of_abs_lt_one {r : β} (h : |r| < 1) :
Tendsto (fun n : β β¦ r ^ n) atTop (π 0) :=
tendsto_pow_atTop_nhds_zero_of_norm_lt_one h
lemma tendsto_pow_atTop_nhds_zero_iff_norm_lt_one {R : Type*} [SeminormedRing R] [NormMulClass R]
{x : R} : Tendsto (fun n : β β¦ x ^ n) atTop (π 0) β βxβ < 1 := by
-- this proof is slightly fiddly since `βx ^ nβ = βxβ ^ n` might not hold for `n = 0`
refine β¨?_, tendsto_pow_atTop_nhds_zero_of_norm_lt_oneβ©
rw [β abs_of_nonneg (norm_nonneg _), β tendsto_pow_atTop_nhds_zero_iff,
tendsto_zero_iff_norm_tendsto_zero]
apply Tendsto.congr'
filter_upwards [eventually_ge_atTop 1] with n hn
induction n, hn using Nat.le_induction with
| base => simp
| succ n hn IH => simp [pow_succ, IH]
variable {R S : Type*} [Field R] [Field S] [LinearOrder S] {v w : AbsoluteValue R S}
[TopologicalSpace S] [IsStrictOrderedRing S] [Archimedean S] [_i : OrderTopology S]
/-- `v (1 / (1 + a ^n))` tends to `1` for all `v : AbsoluteValue R S` for fields `R` and `S`,
provided `v a < 1`. -/
theorem AbsoluteValue.tendsto_div_one_add_pow_nhds_one {v : AbsoluteValue R S} {a : R}
(ha : v a < 1) : atTop.Tendsto (fun (n : β) β¦ v (1 / (1 + a ^ n))) (π 1) := by
simp_rw [map_divβ v, v.map_one]
apply one_div_one (G := S) βΈ Tendsto.div tendsto_const_nhds _ one_ne_zero
have h_add := (tendsto_pow_atTop_nhds_zero_of_lt_one (v.nonneg _) ha).const_add 1
have h_sub := (tendsto_pow_atTop_nhds_zero_of_lt_one (v.nonneg _) ha).const_sub 1
exact tendsto_of_tendsto_of_tendsto_of_le_of_le (by simpa using h_sub) (by simpa using h_add)
(fun n β¦ le_trans (by simp) (v.le_add _ _))
(fun n β¦ le_trans (v.add_le _ _) (by simp))
/-- `v (1 / (1 + a ^n))` tends to `0` whenever `v : AbsoluteValue R S` for fields `R` and `S`,
provided `1 < v a`. -/
theorem AbsoluteValue.tendsto_div_one_add_pow_nhds_zero {v : AbsoluteValue R S} {a : R}
(ha : 1 < v a) : Filter.Tendsto (fun (n : β) β¦ v (1 / (1 + a ^ n))) Filter.atTop (π 0) := by
simp_rw [div_eq_mul_inv, one_mul, map_invβ, fun n β¦ add_comm 1 (a ^ n)]
refine (tendsto_atTop_mono (fun n β¦ v.le_add _ _) ?_).inv_tendsto_atTop
simpa using (tendsto_atTop_add_right_of_le _ _ (tendsto_pow_atTop_atTop_of_one_lt ha)
(fun _ β¦ le_rfl)).congr fun n β¦ (sub_eq_add_neg (v a ^ n) 1).symm
/-! ### Geometric series -/
/-- A normed ring has summable geometric series if, for all `ΞΎ` of norm `< 1`, the geometric series
`β ΞΎ ^ n` converges. This holds both in complete normed rings and in normed fields, providing a
convenient abstraction of these two classes to avoid repeating the same proofs. -/
class HasSummableGeomSeries (K : Type*) [NormedRing K] : Prop where
summable_geometric_of_norm_lt_one : β (ΞΎ : K), βΞΎβ < 1 β Summable (fun n β¦ ΞΎ ^ n)
lemma summable_geometric_of_norm_lt_one {K : Type*} [NormedRing K] [HasSummableGeomSeries K]
{x : K} (h : βxβ < 1) : Summable (fun n β¦ x ^ n) :=
HasSummableGeomSeries.summable_geometric_of_norm_lt_one x h
instance {R : Type*} [NormedRing R] [CompleteSpace R] : HasSummableGeomSeries R := by
constructor
intro x hx
have h1 : Summable fun n : β β¦ βxβ ^ n := summable_geometric_of_lt_one (norm_nonneg _) hx
exact h1.of_norm_bounded_eventually_nat (eventually_norm_pow_le x)
section HasSummableGeometricSeries
variable {R : Type*} [NormedRing R]
open NormedSpace
/-- Bound for the sum of a geometric series in a normed ring. This formula does not assume that the
normed ring satisfies the axiom `β1β = 1`. -/
theorem tsum_geometric_le_of_norm_lt_one (x : R) (h : βxβ < 1) :
ββ' n : β, x ^ nβ β€ β(1 : R)β - 1 + (1 - βxβ)β»ΒΉ := by
by_cases hx : Summable (fun n β¦ x ^ n)
Β· rw [hx.tsum_eq_zero_add]
simp only [_root_.pow_zero]
refine le_trans (norm_add_le _ _) ?_
have : ββ' b : β, (fun n β¦ x ^ (n + 1)) bβ β€ (1 - βxβ)β»ΒΉ - 1 := by
refine tsum_of_norm_bounded ?_ fun b β¦ norm_pow_le' _ (Nat.succ_pos b)
convert (hasSum_nat_add_iff' 1).mpr (hasSum_geometric_of_lt_one (norm_nonneg x) h)
simp
linarith
Β· simp only [tsum_eq_zero_of_not_summable hx, norm_zero]
nontriviality R
have : 1 β€ β(1 : R)β := one_le_norm_one R
have : 0 β€ (1 - βxβ) β»ΒΉ := inv_nonneg.2 (by linarith)
linarith
variable [HasSummableGeomSeries R]
theorem geom_series_mul_neg (x : R) (h : βxβ < 1) : (β' i : β, x ^ i) * (1 - x) = 1 :=
(summable_geometric_of_norm_lt_one h).tsum_pow_mul_one_sub
theorem mul_neg_geom_series (x : R) (h : βxβ < 1) : (1 - x) * β' i : β, x ^ i = 1 :=
(summable_geometric_of_norm_lt_one h).one_sub_mul_tsum_pow
theorem geom_series_succ (x : R) (h : βxβ < 1) : β' i : β, x ^ (i + 1) = β' i : β, x ^ i - 1 := by
rw [eq_sub_iff_add_eq, (summable_geometric_of_norm_lt_one h).tsum_eq_zero_add,
pow_zero, add_comm]
theorem geom_series_mul_shift (x : R) (h : βxβ < 1) :
x * β' i : β, x ^ i = β' i : β, x ^ (i + 1) := by
simp_rw [β (summable_geometric_of_norm_lt_one h).tsum_mul_left, β _root_.pow_succ']
theorem geom_series_mul_one_add (x : R) (h : βxβ < 1) :
(1 + x) * β' i : β, x ^ i = 2 * β' i : β, x ^ i - 1 := by
rw [add_mul, one_mul, geom_series_mul_shift x h, geom_series_succ x h, two_mul, add_sub_assoc]
/-- In a normed ring with summable geometric series, a perturbation of `1` by an element `t`
of distance less than `1` from `1` is a unit. Here we construct its `Units` structure. -/
@[simps val]
def Units.oneSub (t : R) (h : βtβ < 1) : RΛ£ where
val := 1 - t
inv := β' n : β, t ^ n
val_inv := mul_neg_geom_series t h
inv_val := geom_series_mul_neg t h
theorem geom_series_eq_inverse (x : R) (h : βxβ < 1) :
β' i, x ^ i = Ring.inverse (1 - x) := by
change (Units.oneSub x h) β»ΒΉ = Ring.inverse (1 - x)
rw [β Ring.inverse_unit]
rfl
theorem hasSum_geom_series_inverse (x : R) (h : βxβ < 1) :
HasSum (fun i β¦ x ^ i) (Ring.inverse (1 - x)) := by
convert (summable_geometric_of_norm_lt_one h).hasSum
exact (geom_series_eq_inverse x h).symm
lemma isUnit_one_sub_of_norm_lt_one {x : R} (h : βxβ < 1) : IsUnit (1 - x) :=
β¨Units.oneSub x h, rflβ©
end HasSummableGeometricSeries
section Geometric
variable {K : Type*} [NormedDivisionRing K] {ΞΎ : K}
theorem hasSum_geometric_of_norm_lt_one (h : βΞΎβ < 1) : HasSum (fun n : β β¦ ΞΎ ^ n) (1 - ΞΎ)β»ΒΉ := by
have xi_ne_one : ΞΎ β 1 := by
contrapose! h
simp [h]
have A : Tendsto (fun n β¦ (ΞΎ ^ n - 1) * (ΞΎ - 1)β»ΒΉ) atTop (π ((0 - 1) * (ΞΎ - 1)β»ΒΉ)) :=
((tendsto_pow_atTop_nhds_zero_of_norm_lt_one h).sub tendsto_const_nhds).mul tendsto_const_nhds
rw [hasSum_iff_tendsto_nat_of_summable_norm]
Β· simpa [geom_sum_eq, xi_ne_one, neg_inv, div_eq_mul_inv] using A
Β· simp [norm_pow, summable_geometric_of_lt_one (norm_nonneg _) h]
instance : HasSummableGeomSeries K :=
β¨fun _ h β¦ (hasSum_geometric_of_norm_lt_one h).summableβ©
theorem tsum_geometric_of_norm_lt_one (h : βΞΎβ < 1) : β' n : β, ΞΎ ^ n = (1 - ΞΎ)β»ΒΉ :=
(hasSum_geometric_of_norm_lt_one h).tsum_eq
theorem hasSum_geometric_of_abs_lt_one {r : β} (h : |r| < 1) :
HasSum (fun n : β β¦ r ^ n) (1 - r)β»ΒΉ :=
hasSum_geometric_of_norm_lt_one h
theorem summable_geometric_of_abs_lt_one {r : β} (h : |r| < 1) : Summable fun n : β β¦ r ^ n :=
summable_geometric_of_norm_lt_one h
theorem tsum_geometric_of_abs_lt_one {r : β} (h : |r| < 1) : β' n : β, r ^ n = (1 - r)β»ΒΉ :=
tsum_geometric_of_norm_lt_one h
/-- A geometric series in a normed field is summable iff the norm of the common ratio is less than
one. -/
@[simp]
theorem summable_geometric_iff_norm_lt_one : (Summable fun n : β β¦ ΞΎ ^ n) β βΞΎβ < 1 := by
refine β¨fun h β¦ ?_, summable_geometric_of_norm_lt_oneβ©
obtain β¨k : β, hk : dist (ΞΎ ^ k) 0 < 1β© :=
(h.tendsto_cofinite_zero.eventually (ball_mem_nhds _ zero_lt_one)).exists
simp only [norm_pow, dist_zero_right] at hk
rw [β one_pow k] at hk
exact lt_of_pow_lt_pow_leftβ _ zero_le_one hk
end Geometric
section MulGeometric
variable {R : Type*} [NormedRing R] {π : Type*} [NormedDivisionRing π]
theorem summable_norm_mul_geometric_of_norm_lt_one {k : β} {r : R}
(hr : βrβ < 1) {u : β β β} (hu : (fun n β¦ (u n : β)) =O[atTop] (fun n β¦ (β(n ^ k) : β))) :
Summable fun n : β β¦ β(u n * r ^ n : R)β := by
rcases exists_between hr with β¨r', hrr', hβ©
rw [β norm_norm] at hrr'
apply summable_of_isBigO_nat (summable_geometric_of_lt_one ((norm_nonneg _).trans hrr'.le) h)
calc
fun n β¦ ββ(u n) * r ^ nβ
_ =O[atTop] fun n β¦ u n * βrβ ^ n := by
apply (IsBigOWith.of_bound (c := β(1 : R)β) ?_).isBigO
filter_upwards [eventually_norm_pow_le r] with n hn
simp only [norm_mul, Real.norm_eq_abs, abs_cast, norm_pow, abs_norm]
apply (norm_mul_le _ _).trans
have : β(u n : R)β * βr ^ nβ β€ (u n * β(1 : R)β) * βrβ ^ n := by
gcongr; exact norm_cast_le (u n)
exact this.trans (le_of_eq (by ring))
_ =O[atTop] fun n β¦ β(n ^ k) * βrβ ^ n := hu.mul (isBigO_refl _ _)
_ =O[atTop] fun n β¦ r' ^ n := by
simp only [cast_pow]
exact (isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt k hrr').isBigO
theorem summable_norm_pow_mul_geometric_of_norm_lt_one (k : β) {r : R}
(hr : βrβ < 1) : Summable fun n : β β¦ β((n : R) ^ k * r ^ n : R)β := by
simp only [β cast_pow]
exact summable_norm_mul_geometric_of_norm_lt_one (k := k) (u := fun n β¦ n ^ k) hr
(isBigO_refl _ _)
theorem summable_norm_geometric_of_norm_lt_one {r : R}
(hr : βrβ < 1) : Summable fun n : β β¦ β(r ^ n : R)β := by
simpa using summable_norm_pow_mul_geometric_of_norm_lt_one 0 hr
variable [HasSummableGeomSeries R]
lemma hasSum_choose_mul_geometric_of_norm_lt_one'
(k : β) {r : R} (hr : βrβ < 1) :
HasSum (fun n β¦ (n + k).choose k * r ^ n) (Ring.inverse (1 - r) ^ (k + 1)) := by
induction k with
| zero => simpa using hasSum_geom_series_inverse r hr
| succ k ih =>
have I1 : Summable (fun (n : β) β¦ β(n + k).choose k * r ^ nβ) := by
apply summable_norm_mul_geometric_of_norm_lt_one (k := k) hr
apply isBigO_iff.2 β¨2 ^ k, ?_β©
filter_upwards [Ioi_mem_atTop k] with n (hn : k < n)
simp only [Real.norm_eq_abs, abs_cast, cast_pow, norm_pow]
norm_cast
calc (n + k).choose k
_ β€ (2 * n).choose k := choose_le_choose k (by cutsat)
_ β€ (2 * n) ^ k := Nat.choose_le_pow _ _
_ = 2 ^ k * n ^ k := Nat.mul_pow 2 n k
convert hasSum_sum_range_mul_of_summable_norm' I1 ih.summable
(summable_norm_geometric_of_norm_lt_one hr) (summable_geometric_of_norm_lt_one hr) with n
Β· have : β i β Finset.range (n + 1), β((i + k).choose k) * r ^ i * r ^ (n - i) =
β i β Finset.range (n + 1), β((i + k).choose k) * r ^ n := by
apply Finset.sum_congr rfl (fun i hi β¦ ?_)
simp only [Finset.mem_range] at hi
rw [mul_assoc, β pow_add, show i + (n - i) = n by cutsat]
simp [this, β sum_mul, β Nat.cast_sum, sum_range_add_choose n k, add_assoc]
Β· rw [ih.tsum_eq, (hasSum_geom_series_inverse r hr).tsum_eq, pow_succ]
lemma summable_choose_mul_geometric_of_norm_lt_one (k : β) {r : R} (hr : βrβ < 1) :
Summable (fun n β¦ (n + k).choose k * r ^ n) :=
(hasSum_choose_mul_geometric_of_norm_lt_one' k hr).summable
lemma tsum_choose_mul_geometric_of_norm_lt_one' (k : β) {r : R} (hr : βrβ < 1) :
β' n, (n + k).choose k * r ^ n = (Ring.inverse (1 - r)) ^ (k + 1) :=
(hasSum_choose_mul_geometric_of_norm_lt_one' k hr).tsum_eq
lemma hasSum_choose_mul_geometric_of_norm_lt_one
(k : β) {r : π} (hr : βrβ < 1) :
HasSum (fun n β¦ (n + k).choose k * r ^ n) (1 / (1 - r) ^ (k + 1)) := by
convert hasSum_choose_mul_geometric_of_norm_lt_one' k hr
simp
lemma tsum_choose_mul_geometric_of_norm_lt_one (k : β) {r : π} (hr : βrβ < 1) :
β' n, (n + k).choose k * r ^ n = 1/ (1 - r) ^ (k + 1) :=
(hasSum_choose_mul_geometric_of_norm_lt_one k hr).tsum_eq
lemma summable_descFactorial_mul_geometric_of_norm_lt_one (k : β) {r : R} (hr : βrβ < 1) :
Summable (fun n β¦ (n + k).descFactorial k * r ^ n) := by
convert (summable_choose_mul_geometric_of_norm_lt_one k hr).mul_left (k.factorial : R)
using 2 with n
simp [β mul_assoc, descFactorial_eq_factorial_mul_choose (n + k) k]
open Polynomial in
theorem summable_pow_mul_geometric_of_norm_lt_one (k : β) {r : R} (hr : βrβ < 1) :
Summable (fun n β¦ (n : R) ^ k * r ^ n : β β R) := by
refine Nat.strong_induction_on k fun k hk => ?_
obtain β¨a, haβ© : β (a : β β β), β n, (n + k).descFactorial k
= n ^ k + β i β range k, a i * n ^ i := by
let P : Polynomial β := (ascPochhammer β k).comp (Polynomial.X + C 1)
refine β¨fun i β¦ P.coeff i, fun n β¦ ?_β©
have mP : Monic P := Monic.comp_X_add_C (monic_ascPochhammer β k) _
have dP : P.natDegree = k := by
simp only [P, natDegree_comp, ascPochhammer_natDegree, mul_one, natDegree_X_add_C]
have A : (n + k).descFactorial k = P.eval n := by
have : n + 1 + k - 1 = n + k := by omega
simp [P, ascPochhammer_nat_eq_descFactorial, this]
conv_lhs => rw [A, mP.as_sum, dP]
simp [eval_finset_sum]
have : Summable (fun n β¦ (n + k).descFactorial k * r ^ n
- β i β range k, a i * n ^ (i : β) * r ^ n) := by
apply (summable_descFactorial_mul_geometric_of_norm_lt_one k hr).sub
apply summable_sum (fun i hi β¦ ?_)
simp_rw [mul_assoc]
simp only [Finset.mem_range] at hi
exact (hk _ hi).mul_left _
convert this using 1
ext n
simp [ha n, add_mul, sum_mul]
/-- If `βrβ < 1`, then `β' n : β, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version in a general ring
with summable geometric series. For a version in a field, using division instead of `Ring.inverse`,
see `hasSum_coe_mul_geometric_of_norm_lt_one`. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_one'
{x : R} (h : βxβ < 1) :
HasSum (fun n β¦ n * x ^ n : β β R) (x * (Ring.inverse (1 - x)) ^ 2) := by
have A : HasSum (fun (n : β) β¦ (n + 1) * x ^ n) (Ring.inverse (1 - x) ^ 2) := by
convert hasSum_choose_mul_geometric_of_norm_lt_one' 1 h with n
simp
have B : HasSum (fun (n : β) β¦ x ^ n) (Ring.inverse (1 - x)) := hasSum_geom_series_inverse x h
convert A.sub B using 1
Β· ext n
simp [add_mul]
Β· symm
calc Ring.inverse (1 - x) ^ 2 - Ring.inverse (1 - x)
_ = Ring.inverse (1 - x) ^ 2 - ((1 - x) * Ring.inverse (1 - x)) * Ring.inverse (1 - x) := by
simp [Ring.mul_inverse_cancel (1 - x) (isUnit_one_sub_of_norm_lt_one h)]
_ = x * Ring.inverse (1 - x) ^ 2 := by noncomm_ring
/-- If `βrβ < 1`, then `β' n : β, n * r ^ n = r / (1 - r) ^ 2`, version in a general ring with
summable geometric series. For a version in a field, using division instead of `Ring.inverse`,
see `tsum_coe_mul_geometric_of_norm_lt_one`. -/
theorem tsum_coe_mul_geometric_of_norm_lt_one'
{r : π} (hr : βrβ < 1) : (β' n : β, n * r ^ n : π) = r * Ring.inverse (1 - r) ^ 2 :=
(hasSum_coe_mul_geometric_of_norm_lt_one' hr).tsum_eq
/-- If `βrβ < 1`, then `β' n : β, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_one {r : π} (hr : βrβ < 1) :
HasSum (fun n β¦ n * r ^ n : β β π) (r / (1 - r) ^ 2) := by
convert hasSum_coe_mul_geometric_of_norm_lt_one' hr using 1
simp [div_eq_mul_inv]
/-- If `βrβ < 1`, then `β' n : β, n * r ^ n = r / (1 - r) ^ 2`. -/
theorem tsum_coe_mul_geometric_of_norm_lt_one {r : π} (hr : βrβ < 1) :
(β' n : β, n * r ^ n : π) = r / (1 - r) ^ 2 :=
(hasSum_coe_mul_geometric_of_norm_lt_one hr).tsum_eq
end MulGeometric
section SummableLeGeometric
variable [SeminormedAddCommGroup Ξ±] {r C : β} {f : β β Ξ±}
nonrec theorem SeminormedAddCommGroup.cauchySeq_of_le_geometric {C : β} {r : β} (hr : r < 1)
{u : β β Ξ±} (h : β n, βu n - u (n + 1)β β€ C * r ^ n) : CauchySeq u :=
cauchySeq_of_le_geometric r C hr (by simpa [dist_eq_norm] using h)
theorem dist_partial_sum_le_of_le_geometric (hf : β n, βf nβ β€ C * r ^ n) (n : β) :
dist (β i β range n, f i) (β i β range (n + 1), f i) β€ C * r ^ n := by
rw [sum_range_succ, dist_eq_norm, β norm_neg, neg_sub, add_sub_cancel_left]
exact hf n
/-- If `βf nβ β€ C * r ^ n` for all `n : β` and some `r < 1`, then the partial sums of `f` form a
Cauchy sequence. This lemma does not assume `0 β€ r` or `0 β€ C`. -/
theorem cauchySeq_finset_of_geometric_bound (hr : r < 1) (hf : β n, βf nβ β€ C * r ^ n) :
CauchySeq fun s : Finset β β¦ β x β s, f x :=
cauchySeq_finset_of_norm_bounded
(aux_hasSum_of_le_geometric hr (dist_partial_sum_le_of_le_geometric hf)).summable hf
/-- If `βf nβ β€ C * r ^ n` for all `n : β` and some `r < 1`, then the partial sums of `f` are within
distance `C * r ^ n / (1 - r)` of the sum of the series. This lemma does not assume `0 β€ r` or
`0 β€ C`. -/
theorem norm_sub_le_of_geometric_bound_of_hasSum (hr : r < 1) (hf : β n, βf nβ β€ C * r ^ n) {a : Ξ±}
(ha : HasSum f a) (n : β) : β(β x β Finset.range n, f x) - aβ β€ C * r ^ n / (1 - r) := by
rw [β dist_eq_norm]
apply dist_le_of_le_geometric_of_tendsto r C hr (dist_partial_sum_le_of_le_geometric hf)
exact ha.tendsto_sum_nat
@[simp]
theorem dist_partial_sum (u : β β Ξ±) (n : β) :
dist (β k β range (n + 1), u k) (β k β range n, u k) = βu nβ := by
simp [dist_eq_norm, sum_range_succ]
@[simp]
theorem dist_partial_sum' (u : β β Ξ±) (n : β) :
dist (β k β range n, u k) (β k β range (n + 1), u k) = βu nβ := by
simp [dist_eq_norm', sum_range_succ]
theorem cauchy_series_of_le_geometric {C : β} {u : β β Ξ±} {r : β} (hr : r < 1)
(h : β n, βu nβ β€ C * r ^ n) : CauchySeq fun n β¦ β k β range n, u k :=
cauchySeq_of_le_geometric r C hr (by simp [h])
theorem NormedAddCommGroup.cauchy_series_of_le_geometric' {C : β} {u : β β Ξ±} {r : β} (hr : r < 1)
(h : β n, βu nβ β€ C * r ^ n) : CauchySeq fun n β¦ β k β range (n + 1), u k :=
(cauchy_series_of_le_geometric hr h).comp_tendsto <| tendsto_add_atTop_nat 1
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : β} {u : β β Ξ±} {N : β} {r : β}
(hrβ : 0 < r) (hrβ : r < 1) (h : β n β₯ N, βu nβ β€ C * r ^ n) :
CauchySeq fun n β¦ β k β range (n + 1), u k := by
set v : β β Ξ± := fun n β¦ if n < N then 0 else u n
have hC : 0 β€ C :=
(mul_nonneg_iff_of_pos_right <| pow_pos hrβ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
have : β n β₯ N, u n = v n := by
intro n hn
simp [v, if_neg (not_lt.mpr hn)]
apply cauchySeq_sum_of_eventually_eq this
(NormedAddCommGroup.cauchy_series_of_le_geometric' hrβ _)
Β· exact C
intro n
simp only [v]
split_ifs with H
Β· rw [norm_zero]
exact mul_nonneg hC (pow_nonneg hrβ.le _)
Β· push_neg at H
exact h _ H
/-- The term norms of any convergent series are bounded by a constant. -/
lemma exists_norm_le_of_cauchySeq (h : CauchySeq fun n β¦ β k β range n, f k) :
β C, β n, βf nβ β€ C := by
obtain β¨b, β¨_, key, _β©β© := cauchySeq_iff_le_tendsto_0.mp h
refine β¨b 0, fun n β¦ ?_β©
simpa only [dist_partial_sum'] using key n (n + 1) 0 (_root_.zero_le _) (_root_.zero_le _)
end SummableLeGeometric
/-! ### Summability tests based on comparison with geometric series -/
theorem summable_of_ratio_norm_eventually_le {Ξ± : Type*} [SeminormedAddCommGroup Ξ±]
[CompleteSpace Ξ±] {f : β β Ξ±} {r : β} (hrβ : r < 1)
(h : βαΆ n in atTop, βf (n + 1)β β€ r * βf nβ) : Summable f := by
by_cases! hrβ : 0 β€ r
Β· rw [eventually_atTop] at h
rcases h with β¨N, hNβ©
rw [β @summable_nat_add_iff Ξ± _ _ _ _ N]
refine .of_norm_bounded (g := fun n β¦ βf Nβ * r ^ n)
(Summable.mul_left _ <| summable_geometric_of_lt_one hrβ hrβ) fun n β¦ ?_
simp only
conv_rhs => rw [mul_comm, β zero_add N]
refine le_geom (u := fun n β¦ βf (n + N)β) hrβ n fun i _ β¦ ?_
convert hN (i + N) (N.le_add_left i) using 3
ac_rfl
Β· refine .of_norm_bounded_eventually_nat summable_zero ?_
filter_upwards [h] with _ hn
by_contra! h
exact not_lt.mpr (norm_nonneg _) (lt_of_le_of_lt hn <| mul_neg_of_neg_of_pos hrβ h)
theorem summable_of_ratio_test_tendsto_lt_one {Ξ± : Type*} [NormedAddCommGroup Ξ±] [CompleteSpace Ξ±]
{f : β β Ξ±} {l : β} (hlβ : l < 1) (hf : βαΆ n in atTop, f n β 0)
(h : Tendsto (fun n β¦ βf (n + 1)β / βf nβ) atTop (π l)) : Summable f := by
rcases exists_between hlβ with β¨r, hrβ, hrββ©
refine summable_of_ratio_norm_eventually_le hrβ ?_
filter_upwards [h.eventually_le_const hrβ, hf] with _ _ hβ
rwa [β div_le_iffβ (norm_pos_iff.mpr hβ)]
theorem not_summable_of_ratio_norm_eventually_ge {Ξ± : Type*} [SeminormedAddCommGroup Ξ±] {f : β β Ξ±}
{r : β} (hr : 1 < r) (hf : βαΆ n in atTop, βf nβ β 0)
(h : βαΆ n in atTop, r * βf nβ β€ βf (n + 1)β) : Β¬Summable f := by
rw [eventually_atTop] at h
rcases h with β¨Nβ, hNββ©
rw [frequently_atTop] at hf
rcases hf Nβ with β¨N, hNNβ : Nβ β€ N, hNβ©
rw [β @summable_nat_add_iff Ξ± _ _ _ _ N]
refine mt Summable.tendsto_atTop_zero
fun h' β¦ not_tendsto_atTop_of_tendsto_nhds (tendsto_norm_zero.comp h') ?_
convert tendsto_atTop_of_geom_le _ hr _
Β· refine lt_of_le_of_ne (norm_nonneg _) ?_
intro h''
specialize hNβ N hNNβ
simp only [comp_apply, zero_add] at h''
exact hN h''.symm
Β· grind
theorem not_summable_of_ratio_test_tendsto_gt_one {Ξ± : Type*} [SeminormedAddCommGroup Ξ±]
{f : β β Ξ±} {l : β} (hl : 1 < l) (h : Tendsto (fun n β¦ βf (n + 1)β / βf nβ) atTop (π l)) :
Β¬Summable f := by
have key : βαΆ n in atTop, βf nβ β 0 := by
filter_upwards [h.eventually_const_le hl] with _ hn hc
rw [hc, _root_.div_zero] at hn
linarith
rcases exists_between hl with β¨r, hrβ, hrββ©
refine not_summable_of_ratio_norm_eventually_ge hrβ key.frequently ?_
filter_upwards [h.eventually_const_le hrβ, key] with _ _ hβ
rwa [β le_div_iffβ (lt_of_le_of_ne (norm_nonneg _) hβ.symm)]
section NormedDivisionRing
variable [NormedDivisionRing Ξ±] [CompleteSpace Ξ±] {f : β β Ξ±}
/-- If a power series converges at `w`, it converges absolutely at all `z` of smaller norm. -/
theorem summable_powerSeries_of_norm_lt {w z : Ξ±}
(h : CauchySeq fun n β¦ β i β range n, f i * w ^ i) (hz : βzβ < βwβ) :
Summable fun n β¦ f n * z ^ n := by
have hw : 0 < βwβ := (norm_nonneg z).trans_lt hz
obtain β¨C, hCβ© := exists_norm_le_of_cauchySeq h
rw [summable_iff_cauchySeq_finset]
refine cauchySeq_finset_of_geometric_bound (r := βzβ / βwβ) (C := C) ((div_lt_one hw).mpr hz)
(fun n β¦ ?_)
rw [norm_mul, norm_pow, div_pow, β mul_comm_div]
conv at hC => enter [n]; rw [norm_mul, norm_pow, β _root_.le_div_iffβ (by positivity)]
exact mul_le_mul_of_nonneg_right (hC n) (pow_nonneg (norm_nonneg z) n)
/-- If a power series converges at 1, it converges absolutely at all `z` of smaller norm. -/
theorem summable_powerSeries_of_norm_lt_one {z : Ξ±}
(h : CauchySeq fun n β¦ β i β range n, f i) (hz : βzβ < 1) :
Summable fun n β¦ f n * z ^ n :=
summable_powerSeries_of_norm_lt (w := 1) (by simp [h]) (by simp [hz])
end NormedDivisionRing
section
/-! ### Dirichlet and alternating series tests -/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
variable {b : β} {f : β β β} {z : β β E}
/-- **Dirichlet's test** for monotone sequences. -/
theorem Monotone.cauchySeq_series_mul_of_tendsto_zero_of_bounded (hfa : Monotone f)
(hf0 : Tendsto f atTop (π 0)) (hgb : β n, ββ i β range n, z iβ β€ b) :
CauchySeq fun n β¦ β i β range n, f i β’ z i := by
rw [β cauchySeq_shift 1]
simp_rw [Finset.sum_range_by_parts _ _ (Nat.succ _), sub_eq_add_neg, Nat.succ_sub_succ_eq_sub,
tsub_zero]
apply (NormedField.tendsto_zero_smul_of_tendsto_zero_of_bounded hf0
β¨b, eventually_map.mpr <| Eventually.of_forall fun n β¦ hgb <| n + 1β©).cauchySeq.add
refine CauchySeq.neg ?_
refine cauchySeq_range_of_norm_bounded ?_
(fun n β¦ ?_ : β n, β(f (n + 1) + -f n) β’ (Finset.range (n + 1)).sum zβ β€ b * |f (n + 1) - f n|)
Β· simp_rw [abs_of_nonneg (sub_nonneg_of_le (hfa (Nat.le_succ _))), β mul_sum]
apply Real.uniformContinuous_const_mul.comp_cauchySeq
simp_rw [sum_range_sub, sub_eq_add_neg]
exact (Tendsto.cauchySeq hf0).add_const
Β· rw [norm_smul, mul_comm]
exact mul_le_mul_of_nonneg_right (hgb _) (abs_nonneg _)
/-- **Dirichlet's test** for antitone sequences. -/
theorem Antitone.cauchySeq_series_mul_of_tendsto_zero_of_bounded (hfa : Antitone f)
(hf0 : Tendsto f atTop (π 0)) (hzb : β n, ββ i β range n, z iβ β€ b) :
CauchySeq fun n β¦ β i β range n, f i β’ z i := by
have hfa' : Monotone fun n β¦ -f n := fun _ _ hab β¦ neg_le_neg <| hfa hab
have hf0' : Tendsto (fun n β¦ -f n) atTop (π 0) := by
convert hf0.neg
simp
convert (hfa'.cauchySeq_series_mul_of_tendsto_zero_of_bounded hf0' hzb).neg
simp
theorem norm_sum_neg_one_pow_le (n : β) : ββ i β range n, (-1 : β) ^ iβ β€ 1 := by
rw [neg_one_geom_sum]
split_ifs <;> norm_num
/-- The **alternating series test** for monotone sequences.
See also `Monotone.tendsto_alternating_series_of_tendsto_zero`. -/
theorem Monotone.cauchySeq_alternating_series_of_tendsto_zero (hfa : Monotone f)
(hf0 : Tendsto f atTop (π 0)) : CauchySeq fun n β¦ β i β range n, (-1) ^ i * f i := by
simp_rw [mul_comm]
exact hfa.cauchySeq_series_mul_of_tendsto_zero_of_bounded hf0 norm_sum_neg_one_pow_le
/-- The **alternating series test** for monotone sequences. -/
theorem Monotone.tendsto_alternating_series_of_tendsto_zero (hfa : Monotone f)
(hf0 : Tendsto f atTop (π 0)) :
β l, Tendsto (fun n β¦ β i β range n, (-1) ^ i * f i) atTop (π l) :=
cauchySeq_tendsto_of_complete <| hfa.cauchySeq_alternating_series_of_tendsto_zero hf0
/-- The **alternating series test** for antitone sequences.
See also `Antitone.tendsto_alternating_series_of_tendsto_zero`. -/
theorem Antitone.cauchySeq_alternating_series_of_tendsto_zero (hfa : Antitone f)
(hf0 : Tendsto f atTop (π 0)) : CauchySeq fun n β¦ β i β range n, (-1) ^ i * f i := by
simp_rw [mul_comm]
exact hfa.cauchySeq_series_mul_of_tendsto_zero_of_bounded hf0 norm_sum_neg_one_pow_le
/-- The **alternating series test** for antitone sequences. -/
theorem Antitone.tendsto_alternating_series_of_tendsto_zero (hfa : Antitone f)
(hf0 : Tendsto f atTop (π 0)) :
β l, Tendsto (fun n β¦ β i β range n, (-1) ^ i * f i) atTop (π l) :=
cauchySeq_tendsto_of_complete <| hfa.cauchySeq_alternating_series_of_tendsto_zero hf0
end
/-! ### Partial sum bounds on alternating convergent series -/
section
variable {E : Type*} [Ring E] [PartialOrder E] [IsOrderedRing E]
[TopologicalSpace E] [OrderClosedTopology E]
{l : E} {f : β β E}
/-- Partial sums of an alternating monotone series with an even number of terms provide
upper bounds on the limit. -/
theorem Monotone.tendsto_le_alternating_series
(hfl : Tendsto (fun n β¦ β i β range n, (-1) ^ i * f i) atTop (π l))
(hfm : Monotone f) (k : β) : l β€ β i β range (2 * k), (-1) ^ i * f i := by
have ha : Antitone (fun n β¦ β i β range (2 * n), (-1) ^ i * f i) := by
refine antitone_nat_of_succ_le (fun n β¦ ?_)
rw [show 2 * (n + 1) = 2 * n + 1 + 1 by ring, sum_range_succ, sum_range_succ]
simp_rw [_root_.pow_succ', show (-1 : E) ^ (2 * n) = 1 by simp, neg_one_mul, one_mul,
β sub_eq_add_neg, sub_le_iff_le_add]
gcongr
exact hfm (by cutsat)
exact ha.le_of_tendsto (hfl.comp (tendsto_atTop_mono (fun n β¦ by dsimp; cutsat) tendsto_id)) _
/-- Partial sums of an alternating monotone series with an odd number of terms provide
lower bounds on the limit. -/
theorem Monotone.alternating_series_le_tendsto
(hfl : Tendsto (fun n β¦ β i β range n, (-1) ^ i * f i) atTop (π l))
(hfm : Monotone f) (k : β) : β i β range (2 * k + 1), (-1) ^ i * f i β€ l := by
have hm : Monotone (fun n β¦ β i β range (2 * n + 1), (-1) ^ i * f i) := by
refine monotone_nat_of_le_succ (fun n β¦ ?_)
rw [show 2 * (n + 1) = 2 * n + 1 + 1 by ring,
sum_range_succ _ (2 * n + 1 + 1), sum_range_succ _ (2 * n + 1)]
simp_rw [_root_.pow_succ', show (-1 : E) ^ (2 * n) = 1 by simp, neg_one_mul, neg_neg, one_mul,
β sub_eq_add_neg, sub_add_eq_add_sub, le_sub_iff_add_le]
gcongr
exact hfm (by cutsat)
exact hm.ge_of_tendsto (hfl.comp (tendsto_atTop_mono (fun n β¦ by dsimp; cutsat) tendsto_id)) _
/-- Partial sums of an alternating antitone series with an even number of terms provide
lower bounds on the limit. -/
theorem Antitone.alternating_series_le_tendsto
(hfl : Tendsto (fun n β¦ β i β range n, (-1) ^ i * f i) atTop (π l))
(hfa : Antitone f) (k : β) : β i β range (2 * k), (-1) ^ i * f i β€ l := by
have hm : Monotone (fun n β¦ β i β range (2 * n), (-1) ^ i * f i) := by
refine monotone_nat_of_le_succ (fun n β¦ ?_)
rw [show 2 * (n + 1) = 2 * n + 1 + 1 by ring, sum_range_succ, sum_range_succ]
simp_rw [_root_.pow_succ', show (-1 : E) ^ (2 * n) = 1 by simp, neg_one_mul, one_mul,
β sub_eq_add_neg, le_sub_iff_add_le]
gcongr
exact hfa (by cutsat)
exact hm.ge_of_tendsto (hfl.comp (tendsto_atTop_mono (fun n β¦ by dsimp; cutsat) tendsto_id)) _
/-- Partial sums of an alternating antitone series with an odd number of terms provide
upper bounds on the limit. -/
theorem Antitone.tendsto_le_alternating_series
(hfl : Tendsto (fun n β¦ β i β range n, (-1) ^ i * f i) atTop (π l))
(hfa : Antitone f) (k : β) : l β€ β i β range (2 * k + 1), (-1) ^ i * f i := by
have ha : Antitone (fun n β¦ β i β range (2 * n + 1), (-1) ^ i * f i) := by
refine antitone_nat_of_succ_le (fun n β¦ ?_)
rw [show 2 * (n + 1) = 2 * n + 1 + 1 by ring, sum_range_succ, sum_range_succ]
simp_rw [_root_.pow_succ', show (-1 : E) ^ (2 * n) = 1 by simp, neg_one_mul, neg_neg, one_mul,
β sub_eq_add_neg, sub_add_eq_add_sub, sub_le_iff_le_add]
gcongr
exact hfa (by cutsat)
exact ha.le_of_tendsto (hfl.comp (tendsto_atTop_mono (fun n β¦ by dsimp; cutsat) tendsto_id)) _
theorem Summable.tendsto_alternating_series_tsum
{E} [Ring E] [UniformSpace E] [IsUniformAddGroup E] [CompleteSpace E]
{f : β β E} (hfs : Summable f) :
Tendsto (fun n => (β i β range n, (-1) ^ i * f i)) atTop (π (β' i : β, (-1) ^ i * f i)) :=
Summable.tendsto_sum_tsum_nat hfs.alternating
-- TODO: generalize to conditionally-convergent sums
-- see https://github.com/leanprover-community/mathlib4/pull/29577#discussion_r2343447344
theorem alternating_series_error_bound
{E} [Ring E] [LinearOrder E] [IsOrderedRing E]
[UniformSpace E] [IsUniformAddGroup E] [CompleteSpace E] [OrderClosedTopology E]
(f : β β E) (hfa : Antitone f) (hfs : Summable f) (n : β) :
|(β' i : β, (-1) ^ i * f i) - (β i β range n, (-1) ^ i * f i)| β€ f n := by
obtain h := hfs.tendsto_alternating_series_tsum
have upper := hfa.alternating_series_le_tendsto h
have lower := hfa.tendsto_le_alternating_series h
have I (n : β) : 0 β€ f n := by
apply le_of_tendsto hfs.tendsto_atTop_zero
filter_upwards [Ici_mem_atTop n] with m hm using hfa hm
obtain (h | h) := even_or_odd n
Β· obtain β¨n, rflβ© := even_iff_exists_two_mul.mp h
specialize upper n
specialize lower n
simp only [sum_range_succ, even_two, Even.mul_right, Even.neg_pow, one_pow, one_mul] at lower
rw [abs_sub_le_iff]
constructor
Β· rwa [sub_le_iff_le_add, add_comm]
Β· rw [sub_le_iff_le_add, add_comm]
exact upper.trans (le_add_of_nonneg_right (I (2 * n)))
Β· obtain β¨n, rflβ© := odd_iff_exists_bit1.mp h
specialize upper (n + 1)
specialize lower n
rw [Nat.mul_add, Finset.sum_range_succ] at upper
rw [abs_sub_le_iff]
constructor
Β· rw [sub_le_iff_le_add, add_comm]
exact lower.trans (le_add_of_nonneg_right (I (2 * n + 1)))
Β· simpa [Finset.sum_range_succ, add_comm, pow_add] using upper
end
/-!
### Factorial
-/
/-- The series `β' n, x ^ n / n!` is summable of any `x : β`. See also `expSeries_div_summable`
for a version that also works in `β`, and `NormedSpace.expSeries_summable'` for a version
that works in any normed algebra over `β` or `β`. -/
theorem Real.summable_pow_div_factorial (x : β) : Summable (fun n β¦ x ^ n / n ! : β β β) := by
-- We start with trivial estimates
have A : (0 : β) < ββxβββ + 1 := zero_lt_one.trans_le (by simp)
have B : βxβ / (ββxβββ + 1) < 1 := (div_lt_one A).2 (Nat.lt_floor_add_one _)
-- Then we apply the ratio test. The estimate works for `n β₯ ββxβββ`.
suffices β n β₯ ββxβββ, βx ^ (n + 1) / (n + 1)!β β€ βxβ / (ββxβββ + 1) * βx ^ n / βn !β from
summable_of_ratio_norm_eventually_le B (eventually_atTop.2 β¨ββxβββ, thisβ©)
-- Finally, we prove the upper estimate
intro n hn
calc
βx ^ (n + 1) / (n + 1)!β = βxβ / (n + 1) * βx ^ n / (n !)β := by
rw [_root_.pow_succ', Nat.factorial_succ, Nat.cast_mul, β _root_.div_mul_div_comm, norm_mul,
norm_div, Real.norm_natCast, Nat.cast_succ]
_ β€ βxβ / (ββxβββ + 1) * βx ^ n / (n !)β := by gcongr
section
/-! Limits when `f x * g x` is bounded or convergent and `f` tends to the `cobounded` filter. -/
open Bornology
variable {R K : Type*}
lemma tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded [NormedAddGroup K]
[NormedAddGroup R] [SMulWithZero K R] [NoZeroSMulDivisors K R] [NormSMulClass K R]
{f : Ξ± β K} {g : Ξ± β R} {l : Filter Ξ±}
(hmul : IsBoundedUnder (Β· β€ Β·) l fun x β¦ βf x β’ g xβ)
(hf : Tendsto f l (cobounded K)) :
Tendsto g l (π 0) := by
obtain β¨c, hcβ© := hmul.eventually_le
refine Metric.nhds_basis_closedBall.tendsto_right_iff.mpr fun Ξ΅ hΞ΅0 β¦ ?_
filter_upwards [hc, hasBasis_cobounded_norm.tendsto_right_iff.mp hf (c / Ξ΅) trivial,
hf.eventually_ne_cobounded 0] with x hfgc hΞ΅f hf0
rcases eq_or_lt_of_le ((norm_nonneg _).trans hfgc) with rfl | hc0
Β· simpa [(smul_eq_zero_iff_right hf0).mp (norm_le_zero_iff.mp hfgc)] using hΞ΅0.le
calc
_ = βg xβ := by simp
_ β€ c / βf xβ := by rwa [norm_smul, β le_div_iffβ' (by positivity)] at hfgc
_ β€ c / (c / Ξ΅) := by gcongr
_ = Ξ΅ := div_div_cancelβ hc0.ne'
section
variable [NormedRing K] [NormedAddCommGroup R]
variable [Module K R] [NoZeroSMulDivisors K R] [NormSMulClass K R]
lemma tendsto_smul_congr_of_tendsto_left_cobounded_of_isBoundedUnder
{fβ fβ : Ξ± β K} {g : Ξ± β R} {t : R} {l : Filter Ξ±}
(hmul : Tendsto (fun x β¦ fβ x β’ g x) l (π t))
(hfβ : Tendsto fβ l (cobounded K))
(hbdd : IsBoundedUnder (Β· β€ Β·) l fun x β¦ βfβ x - fβ xβ) :
Tendsto (fun x β¦ fβ x β’ g x) l (π t) := by
apply hmul.congr_dist
dsimp
simp_rw [dist_eq_norm, β sub_smul, norm_smul]
apply isBoundedUnder_le_mul_tendsto_zero
Β· change IsBoundedUnder _ _ fun _ β¦ _
simpa using hbdd
Β· rw [β tendsto_zero_iff_norm_tendsto_zero]
exact tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded hmul.norm.isBoundedUnder_le hfβ
-- The use case in mind for this is when `K = β`, and `R = β` or `β`
lemma tendsto_smul_comp_nat_floor_of_tendsto_nsmul [NormSMulClass β€ K] [LinearOrder K]
[IsStrictOrderedRing K] [FloorSemiring K] [HasSolidNorm K] {g : β β R} {t : R}
(hg : Tendsto (fun n : β β¦ n β’ g n) atTop (π t)) :
Tendsto (fun x : K β¦ x β’ g βxββ) atTop (π t) := by
replace hg : Tendsto (fun n : β β¦ (n : K) β’ g n) atTop (π t) := mod_cast hg
apply tendsto_smul_congr_of_tendsto_left_cobounded_of_isBoundedUnder
(hg.comp tendsto_nat_floor_atTop)
Β· exact tendsto_natCast_atTop_cobounded.comp tendsto_nat_floor_atTop
Β· apply isBoundedUnder_of_eventually_le (a := β(1 : K)β)
apply Eventually.mono _ (fun x h β¦ norm_le_norm_of_abs_le_abs h)
simpa using β¨0, fun _ h β¦ mod_cast Nat.abs_floor_sub_le hβ©
end
lemma tendsto_smul_comp_nat_floor_of_tendsto_mul [NormedRing K] [NormedRing R]
[Module K R] [NoZeroSMulDivisors K R] [NormSMulClass K R] [NormSMulClass β€ K] [LinearOrder K]
[IsStrictOrderedRing K] [FloorSemiring K] [HasSolidNorm K] {g : β β R} {t : R}
(hg : Tendsto (fun n : β β¦ (n : R) * g n) atTop (π t)) :
Tendsto (fun x : K β¦ x β’ g βxββ) atTop (π t) :=
tendsto_smul_comp_nat_floor_of_tendsto_nsmul (by simpa only [nsmul_eq_mul] using hg)
end |
.lake/packages/mathlib/Mathlib/Analysis/SpecificLimits/Fibonacci.lean | import Mathlib.Analysis.SpecificLimits.Normed
import Mathlib.NumberTheory.Real.GoldenRatio
/-!
# The ratio of consecutive Fibonacci numbers
We prove that the ratio of consecutive Fibonacci numbers tends to the golden ratio.
-/
open Nat Real Filter Tendsto
open scoped Topology goldenRatio
/-- The limit of `fib (n + 1) / fib n` as `n β β` is the golden ratio. -/
theorem tendsto_fib_succ_div_fib_atTop :
Tendsto (fun n β¦ (fib (n + 1) / fib n : β)) atTop (π Ο) := by
have hβ n : (fib (n + 1) / fib n : β) = (Ο - Ο * (Ο / Ο) ^ n) / (1 - (Ο / Ο) ^ n) := by
simp only [coe_fib_eq, pow_succ, div_pow]
field
have hβ := tendsto_pow_atTop_nhds_zero_of_abs_lt_one (r := Ο / Ο) <| by
rw [abs_div, div_lt_one <| by positivity, abs_of_pos goldenRatio_pos, abs_lt]
ring_nf
bound
rw [show Ο = (Ο - Ο * 0) / (1 - 0) by ring, funext hβ]
exact const_sub _ (const_mul _ hβ) |>.div (const_sub _ hβ) <| by simp
/-- The limit of `fib n / fib (n + 1)` as `n β β` is the negative conjugate of the golden ratio. -/
theorem tendsto_fib_div_fib_succ_atTop :
Tendsto (fun n β¦ (fib n / fib (n + 1) : β)) atTop (π (-Ο)) := by
convert tendsto_fib_succ_div_fib_atTop.invβ (by positivity) using 2
Β· rw [inv_div]
Β· rw [inv_goldenRatio] |
.lake/packages/mathlib/Mathlib/Analysis/SpecificLimits/Basic.lean | import Mathlib.Algebra.Field.GeomSum
import Mathlib.Data.Nat.Factorial.BigOperators
import Mathlib.Order.Filter.AtTopBot.Archimedean
import Mathlib.Order.Iterate
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Topology.Algebra.InfiniteSum.Real
import Mathlib.Topology.Instances.EReal.Lemmas
import Mathlib.Topology.Instances.Rat
/-!
# A collection of specific limit computations
This file, by design, is independent of `NormedSpace` in the import hierarchy. It contains
important specific limit computations in metric spaces, in ordered rings/fields, and in specific
instances of these such as `β`, `ββ₯0` and `ββ₯0β`.
-/
assert_not_exists Module.Basis NormedSpace
noncomputable section
open Set Function Filter Finset Metric Topology Nat uniformity NNReal ENNReal
variable {Ξ± : Type*} {Ξ² : Type*} {ΞΉ : Type*}
theorem NNRat.tendsto_inv_atTop_nhds_zero_nat : Tendsto (fun n : β β¦ (n : ββ₯0)β»ΒΉ) atTop (π 0) :=
tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop
theorem NNRat.tendsto_algebraMap_inv_atTop_nhds_zero_nat (π : Type*) [Semiring π]
[Algebra ββ₯0 π] [TopologicalSpace π] [ContinuousSMul ββ₯0 π] :
Tendsto (algebraMap ββ₯0 π β fun n : β β¦ (n : ββ₯0)β»ΒΉ) atTop (π 0) := by
convert (continuous_algebraMap ββ₯0 π).continuousAt.tendsto.comp
tendsto_inv_atTop_nhds_zero_nat
rw [map_zero]
theorem tendsto_inv_atTop_nhds_zero_nat {π : Type*} [DivisionSemiring π] [CharZero π]
[TopologicalSpace π] [ContinuousSMul ββ₯0 π] :
Tendsto (fun n : β β¦ (n : π)β»ΒΉ) atTop (π 0) := by
convert NNRat.tendsto_algebraMap_inv_atTop_nhds_zero_nat π
simp
theorem tendsto_const_div_atTop_nhds_zero_nat {π : Type*} [DivisionSemiring π] [CharZero π]
[TopologicalSpace π] [ContinuousSMul ββ₯0 π] [ContinuousMul π] (C : π) :
Tendsto (fun n : β β¦ C / n) atTop (π 0) := by
simpa only [mul_zero, div_eq_mul_inv] using
(tendsto_const_nhds (x := C)).mul tendsto_inv_atTop_nhds_zero_nat
theorem tendsto_one_div_atTop_nhds_zero_nat {π : Type*} [DivisionSemiring π] [CharZero π]
[TopologicalSpace π] [ContinuousSMul ββ₯0 π] :
Tendsto (fun n : β β¦ 1 / (n : π)) atTop (π 0) := by
simp [tendsto_inv_atTop_nhds_zero_nat]
theorem EReal.tendsto_const_div_atTop_nhds_zero_nat {C : EReal} (h : C β β₯) (h' : C β β€) :
Tendsto (fun n : β β¦ C / n) atTop (π 0) := by
have : (fun n : β β¦ C / n) = fun n : β β¦ ((C.toReal / n : β) : EReal) := by
ext n
nth_rw 1 [β coe_toReal h' h, β coe_coe_eq_natCast n, β coe_div C.toReal n]
rw [this, β coe_zero, tendsto_coe]
exact _root_.tendsto_const_div_atTop_nhds_zero_nat C.toReal
theorem tendsto_one_div_add_atTop_nhds_zero_nat {π : Type*} [DivisionSemiring π] [CharZero π]
[TopologicalSpace π] [ContinuousSMul ββ₯0 π] :
Tendsto (fun n : β β¦ 1 / ((n : π) + 1)) atTop (π 0) :=
suffices Tendsto (fun n : β β¦ 1 / (β(n + 1) : π)) atTop (π 0) by simpa
(tendsto_add_atTop_iff_nat 1).2 tendsto_one_div_atTop_nhds_zero_nat
theorem tendsto_algebraMap_inv_atTop_nhds_zero_nat {π : Type*} (A : Type*)
[Semifield π] [CharZero π] [TopologicalSpace π] [ContinuousSMul ββ₯0 π]
[Semiring A] [Algebra π A] [TopologicalSpace A] [ContinuousSMul π A] :
Tendsto (algebraMap π A β fun n : β β¦ (n : π)β»ΒΉ) atTop (π 0) := by
convert (continuous_algebraMap π A).continuousAt.tendsto.comp tendsto_inv_atTop_nhds_zero_nat
rw [map_zero]
/-- The limit of `n / (n + x)` is 1, for any constant `x` (valid in `β` or any topological division
algebra over `ββ₯0`, e.g., `β`). -/
theorem tendsto_natCast_div_add_atTop {π : Type*} [DivisionSemiring π] [TopologicalSpace π]
[CharZero π] [ContinuousSMul ββ₯0 π] [IsTopologicalSemiring π] [ContinuousInvβ π] (x : π) :
Tendsto (fun n : β β¦ (n : π) / (n + x)) atTop (π 1) := by
convert Tendsto.congr' ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn β¦ _)) _
Β· exact fun n : β β¦ 1 / (1 + x / n)
Β· simp [Nat.cast_ne_zero.mpr hn, add_div']
Β· have : π (1 : π) = π (1 / (1 + x * (0 : π))) := by
rw [mul_zero, add_zero, div_one]
rw [this]
refine tendsto_const_nhds.div (tendsto_const_nhds.add ?_) (by simp)
simp_rw [div_eq_mul_inv]
refine tendsto_const_nhds.mul ?_
have := ((continuous_algebraMap ββ₯0 π).tendsto _).comp tendsto_inv_atTop_nhds_zero_nat
rw [map_zero, Filter.tendsto_atTop'] at this
refine Iff.mpr tendsto_atTop' ?_
intros
simp_all only [comp_apply, map_invβ, map_natCast]
theorem tendsto_add_mul_div_add_mul_atTop_nhds {π : Type*} [Semifield π] [CharZero π]
[TopologicalSpace π] [ContinuousSMul ββ₯0 π] [IsTopologicalSemiring π] [ContinuousInvβ π]
(a b c : π) {d : π} (hd : d β 0) :
Tendsto (fun k : β β¦ (a + c * k) / (b + d * k)) atTop (π (c / d)) := by
apply Filter.Tendsto.congr'
case fβ => exact fun k β¦ (a * (βk)β»ΒΉ + c) / (b * (βk)β»ΒΉ + d)
Β· refine (eventually_ne_atTop 0).mp (Eventually.of_forall ?_)
intro h hx
dsimp
field (discharger := norm_cast)
Β· apply Filter.Tendsto.div _ _ hd
all_goals
apply zero_add (_ : π) βΈ Filter.Tendsto.add_const _ _
apply mul_zero (_ : π) βΈ Filter.Tendsto.const_mul _ _
exact tendsto_inv_atTop_nhds_zero_nat
/-- For any positive `m : β`, `((n % m : β) : β) / (n : β)` tends to `0` as `n` tends to `β`. -/
theorem tendsto_mod_div_atTop_nhds_zero_nat {m : β} (hm : 0 < m) :
Tendsto (fun n : β => ((n % m : β) : β) / (n : β)) atTop (π 0) := by
have h0 : βαΆ n : β in atTop, 0 β€ (fun n : β => ((n % m : β) : β)) n := by aesop
exact tendsto_bdd_div_atTop_nhds_zero h0
(.of_forall (fun n β¦ cast_le.mpr (mod_lt n hm).le)) tendsto_natCast_atTop_atTop
/-- If `a β 0`, `(a * x + c)β»ΒΉ` tends to `0` as `x` tends to `β`. -/
theorem tendsto_mul_add_inv_atTop_nhds_zero (a c : β) (ha : a β 0) :
Tendsto (fun x => (a * x + c)β»ΒΉ) atTop (π 0) := by
obtain ha' | ha' := lt_or_gt_of_ne ha
Β· exact tendsto_inv_atBot_zero.comp
(tendsto_atBot_add_const_right _ c (tendsto_id.const_mul_atTop_of_neg ha'))
Β· exact tendsto_inv_atTop_zero.comp
(tendsto_atTop_add_const_right _ c (tendsto_id.const_mul_atTop ha'))
theorem Filter.EventuallyEq.div_mul_cancel {Ξ± G : Type*} [GroupWithZero G] {f g : Ξ± β G}
{l : Filter Ξ±} (hg : Tendsto g l (π {0}αΆ)) : (fun x β¦ f x / g x * g x) =αΆ [l] fun x β¦ f x := by
filter_upwards [hg.le_comap <| preimage_mem_comap (m := g) (mem_principal_self {0}αΆ)] with x hx
simp_all
/-- If `g` tends to `β`, then eventually for all `x` we have `(f x / g x) * g x = f x`. -/
theorem Filter.EventuallyEq.div_mul_cancel_atTop {Ξ± K : Type*}
[DivisionSemiring K] [LinearOrder K] [IsStrictOrderedRing K]
{f g : Ξ± β K} {l : Filter Ξ±} (hg : Tendsto g l atTop) :
(fun x β¦ f x / g x * g x) =αΆ [l] fun x β¦ f x :=
div_mul_cancel <| hg.mono_right <| le_principal_iff.mpr <|
mem_of_superset (Ioi_mem_atTop 0) <| by simp
/-- If when `x` tends to `β`, `g` tends to `β` and `f x / g x` tends to a positive
constant, then `f` tends to `β`. -/
theorem Filter.Tendsto.num {Ξ± K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K]
[TopologicalSpace K] [OrderTopology K]
{f g : Ξ± β K} {l : Filter Ξ±} (hg : Tendsto g l atTop) {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (π a)) :
Tendsto f l atTop :=
(hlim.pos_mul_atTop ha hg).congr' (EventuallyEq.div_mul_cancel_atTop hg)
/-- If when `x` tends to `β`, `g` tends to `β` and `f x / g x` tends to a positive
constant, then `f` tends to `β`. -/
theorem Filter.Tendsto.den {Ξ± K : Type*} [Field K] [LinearOrder K] [IsStrictOrderedRing K]
[TopologicalSpace K] [OrderTopology K]
[ContinuousInv K] {f g : Ξ± β K} {l : Filter Ξ±} (hf : Tendsto f l atTop) {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (π a)) :
Tendsto g l atTop :=
have hlim' : Tendsto (fun x => g x / f x) l (π aβ»ΒΉ) := by
simp_rw [β inv_div (f _)]
exact Filter.Tendsto.inv (f := fun x => f x / g x) hlim
(hlim'.pos_mul_atTop (inv_pos_of_pos ha) hf).congr' (.div_mul_cancel_atTop hf)
/-- If when `x` tends to `β`, `f x / g x` tends to a positive constant, then `f` tends to `β` if
and only if `g` tends to `β`. -/
theorem Filter.Tendsto.num_atTop_iff_den_atTop {Ξ± K : Type*}
[Field K] [LinearOrder K] [IsStrictOrderedRing K] [TopologicalSpace K]
[OrderTopology K] [ContinuousInv K] {f g : Ξ± β K} {l : Filter Ξ±} {a : K} (ha : 0 < a)
(hlim : Tendsto (fun x => f x / g x) l (π a)) :
Tendsto f l atTop β Tendsto g l atTop :=
β¨fun hf β¦ hf.den ha hlim, fun hg β¦ hg.num ha hlimβ©
/-! ### Powers -/
theorem tendsto_add_one_pow_atTop_atTop_of_pos
[Semiring Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±] [Archimedean Ξ±] {r : Ξ±}
(h : 0 < r) : Tendsto (fun n : β β¦ (r + 1) ^ n) atTop atTop :=
tendsto_atTop_atTop_of_monotone' (pow_right_monoβ <| le_add_of_nonneg_left h.le) <|
not_bddAbove_iff.2 fun _ β¦ Set.exists_range_iff.2 <| add_one_pow_unbounded_of_pos _ h
theorem tendsto_pow_atTop_atTop_of_one_lt
[Semiring Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±] [ExistsAddOfLE Ξ±] [Archimedean Ξ±] {r : Ξ±}
(h : 1 < r) : Tendsto (fun n : β β¦ r ^ n) atTop atTop := by
obtain β¨r, r0, rflβ© := exists_pos_add_of_lt' h
rw [add_comm]
exact tendsto_add_one_pow_atTop_atTop_of_pos r0
theorem tendsto_pow_atTop_nhds_zero_of_lt_one {π : Type*}
[Semifield π] [LinearOrder π] [IsStrictOrderedRing π] [ExistsAddOfLE π] [Archimedean π]
[TopologicalSpace π] [OrderTopology π] {r : π} (hβ : 0 β€ r) (hβ : r < 1) :
Tendsto (fun n : β β¦ r ^ n) atTop (π 0) :=
hβ.eq_or_lt.elim
(fun hr β¦ (tendsto_add_atTop_iff_nat 1).mp <| by
simp [_root_.pow_succ, β hr])
(fun hr β¦
have := (one_lt_invβ hr).2 hβ |> tendsto_pow_atTop_atTop_of_one_lt
(tendsto_inv_atTop_zero.comp this).congr fun n β¦ by simp)
@[simp] theorem tendsto_pow_atTop_nhds_zero_iff {π : Type*}
[Field π] [LinearOrder π] [IsStrictOrderedRing π] [Archimedean π]
[TopologicalSpace π] [OrderTopology π] {r : π} :
Tendsto (fun n : β β¦ r ^ n) atTop (π 0) β |r| < 1 := by
rw [tendsto_zero_iff_abs_tendsto_zero]
refine β¨fun h β¦ by_contra (fun hr_le β¦ ?_), fun h β¦ ?_β©
Β· by_cases hr : 1 = |r|
Β· replace h : Tendsto (fun n : β β¦ |r| ^ n) atTop (π 0) := by simpa only [β abs_pow, h]
simp only [hr.symm, one_pow] at h
exact zero_ne_one <| tendsto_nhds_unique h tendsto_const_nhds
Β· apply @not_tendsto_nhds_of_tendsto_atTop π β _ _ _ _ atTop _ (fun n β¦ |r| ^ n) _ 0 _
Β· refine (pow_right_strictMonoβ <| lt_of_le_of_ne (le_of_not_gt hr_le)
hr).monotone.tendsto_atTop_atTop (fun b β¦ ?_)
obtain β¨n, hnβ© := (pow_unbounded_of_one_lt b (lt_of_le_of_ne (le_of_not_gt hr_le) hr))
exact β¨n, le_of_lt hnβ©
Β· simpa only [β abs_pow]
Β· simpa only [β abs_pow] using (tendsto_pow_atTop_nhds_zero_of_lt_one (abs_nonneg r)) h
theorem tendsto_pow_atTop_nhdsWithin_zero_of_lt_one {π : Type*}
[Semifield π] [LinearOrder π] [IsStrictOrderedRing π] [ExistsAddOfLE π]
[Archimedean π] [TopologicalSpace π] [OrderTopology π] {r : π} (hβ : 0 < r) (hβ : r < 1) :
Tendsto (fun n : β β¦ r ^ n) atTop (π[>] 0) :=
tendsto_inf.2
β¨tendsto_pow_atTop_nhds_zero_of_lt_one hβ.le hβ,
tendsto_principal.2 <| Eventually.of_forall fun _ β¦ pow_pos hβ _β©
theorem uniformity_basis_dist_pow_of_lt_one {Ξ± : Type*} [PseudoMetricSpace Ξ±] {r : β} (hβ : 0 < r)
(hβ : r < 1) :
(uniformity Ξ±).HasBasis (fun _ : β β¦ True) fun k β¦ { p : Ξ± Γ Ξ± | dist p.1 p.2 < r ^ k } :=
Metric.mk_uniformity_basis (fun _ _ β¦ pow_pos hβ _) fun _ Ξ΅0 β¦
(exists_pow_lt_of_lt_one Ξ΅0 hβ).imp fun _ hk β¦ β¨trivial, hk.leβ©
theorem geom_lt {u : β β β} {c : β} (hc : 0 β€ c) {n : β} (hn : 0 < n)
(h : β k < n, c * u k < u (k + 1)) : c ^ n * u 0 < u n := by
apply (monotone_mul_left_of_nonneg hc).seq_pos_lt_seq_of_le_of_lt hn _ _ h
Β· simp
Β· simp [_root_.pow_succ', mul_assoc, le_refl]
theorem geom_le {u : β β β} {c : β} (hc : 0 β€ c) (n : β) (h : β k < n, c * u k β€ u (k + 1)) :
c ^ n * u 0 β€ u n := by
apply (monotone_mul_left_of_nonneg hc).seq_le_seq n _ _ h <;>
simp [_root_.pow_succ', mul_assoc, le_refl]
theorem lt_geom {u : β β β} {c : β} (hc : 0 β€ c) {n : β} (hn : 0 < n)
(h : β k < n, u (k + 1) < c * u k) : u n < c ^ n * u 0 := by
apply (monotone_mul_left_of_nonneg hc).seq_pos_lt_seq_of_lt_of_le hn _ h _
Β· simp
Β· simp [_root_.pow_succ', mul_assoc, le_refl]
theorem le_geom {u : β β β} {c : β} (hc : 0 β€ c) (n : β) (h : β k < n, u (k + 1) β€ c * u k) :
u n β€ c ^ n * u 0 := by
apply (monotone_mul_left_of_nonneg hc).seq_le_seq n _ h _ <;>
simp [_root_.pow_succ', mul_assoc, le_refl]
/-- If a sequence `v` of real numbers satisfies `k * v n β€ v (n+1)` with `1 < k`,
then it goes to +β. -/
theorem tendsto_atTop_of_geom_le {v : β β β} {c : β} (hβ : 0 < v 0) (hc : 1 < c)
(hu : β n, c * v n β€ v (n + 1)) : Tendsto v atTop atTop :=
(tendsto_atTop_mono fun n β¦ geom_le (zero_le_one.trans hc.le) n fun k _ β¦ hu k) <|
(tendsto_pow_atTop_atTop_of_one_lt hc).atTop_mul_const hβ
theorem NNReal.tendsto_pow_atTop_nhds_zero_of_lt_one {r : ββ₯0} (hr : r < 1) :
Tendsto (fun n : β β¦ r ^ n) atTop (π 0) :=
NNReal.tendsto_coe.1 <| by
simp only [NNReal.coe_pow, NNReal.coe_zero,
_root_.tendsto_pow_atTop_nhds_zero_of_lt_one r.coe_nonneg hr]
@[simp]
protected theorem NNReal.tendsto_pow_atTop_nhds_zero_iff {r : ββ₯0} :
Tendsto (fun n : β => r ^ n) atTop (π 0) β r < 1 :=
β¨fun h => by simpa [coe_pow, coe_zero, abs_eq, coe_lt_one, val_eq_coe] using
tendsto_pow_atTop_nhds_zero_iff.mp <| tendsto_coe.mpr h, tendsto_pow_atTop_nhds_zero_of_lt_oneβ©
theorem ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one {r : ββ₯0β} (hr : r < 1) :
Tendsto (fun n : β β¦ r ^ n) atTop (π 0) := by
rcases ENNReal.lt_iff_exists_coe.1 hr with β¨r, rfl, hr'β©
rw [β ENNReal.coe_zero]
norm_cast at *
apply NNReal.tendsto_pow_atTop_nhds_zero_of_lt_one hr
@[simp]
protected theorem ENNReal.tendsto_pow_atTop_nhds_zero_iff {r : ββ₯0β} :
Tendsto (fun n : β => r ^ n) atTop (π 0) β r < 1 := by
refine β¨fun h β¦ ?_, tendsto_pow_atTop_nhds_zero_of_lt_oneβ©
lift r to NNReal
Β· refine fun hr β¦ top_ne_zero (tendsto_nhds_unique (EventuallyEq.tendsto ?_) (hr βΈ h))
exact eventually_atTop.mpr β¨1, fun _ hn β¦ pow_eq_top_iff.mpr β¨rfl, Nat.pos_iff_ne_zero.mp hnβ©β©
rw [β coe_zero] at h
norm_cast at h β’
exact NNReal.tendsto_pow_atTop_nhds_zero_iff.mp h
@[simp]
protected theorem ENNReal.tendsto_pow_atTop_nhds_top_iff {r : ββ₯0β} :
Tendsto (fun n β¦ r ^ n) atTop (π β) β 1 < r := by
refine β¨?_, ?_β©
Β· contrapose!
intro r_le_one h_tends
specialize h_tends (Ioi_mem_nhds one_lt_top)
simp only [Filter.mem_map, mem_atTop_sets, ge_iff_le, Set.mem_preimage, Set.mem_Ioi] at h_tends
obtain β¨n, hnβ© := h_tends
exact lt_irrefl _ <| lt_of_lt_of_le (hn n le_rfl) <| pow_le_oneβ (zero_le _) r_le_one
Β· intro r_gt_one
have obs := @Tendsto.inv ββ₯0β β _ _ _ (fun n β¦ (rβ»ΒΉ) ^ n) atTop 0
simp only [ENNReal.tendsto_pow_atTop_nhds_zero_iff, inv_zero] at obs
simpa [β ENNReal.inv_pow] using obs <| ENNReal.inv_lt_one.mpr r_gt_one
lemma ENNReal.eq_zero_of_le_mul_pow {x r : ββ₯0β} {Ξ΅ : ββ₯0} (hr : r < 1)
(h : β n : β, x β€ Ξ΅ * r ^ n) : x = 0 := by
rw [β nonpos_iff_eq_zero]
refine ge_of_tendsto' (f := fun (n : β) β¦ Ξ΅ * r ^ n) (x := atTop) ?_ h
rw [β mul_zero (Mβ := ββ₯0β) (a := Ξ΅)]
exact Tendsto.const_mul (tendsto_pow_atTop_nhds_zero_of_lt_one hr) (Or.inr coe_ne_top)
/-! ### Geometric series -/
section Geometric
theorem hasSum_geometric_of_lt_one {r : β} (hβ : 0 β€ r) (hβ : r < 1) :
HasSum (fun n : β β¦ r ^ n) (1 - r)β»ΒΉ :=
have : r β 1 := ne_of_lt hβ
have : Tendsto (fun n β¦ (r ^ n - 1) * (r - 1)β»ΒΉ) atTop (π ((0 - 1) * (r - 1)β»ΒΉ)) :=
((tendsto_pow_atTop_nhds_zero_of_lt_one hβ hβ).sub tendsto_const_nhds).mul tendsto_const_nhds
(hasSum_iff_tendsto_nat_of_nonneg (pow_nonneg hβ) _).mpr <| by
simp_all [neg_inv, geom_sum_eq, div_eq_mul_inv]
theorem summable_geometric_of_lt_one {r : β} (hβ : 0 β€ r) (hβ : r < 1) :
Summable fun n : β β¦ r ^ n :=
β¨_, hasSum_geometric_of_lt_one hβ hββ©
theorem tsum_geometric_of_lt_one {r : β} (hβ : 0 β€ r) (hβ : r < 1) : β' n : β, r ^ n = (1 - r)β»ΒΉ :=
(hasSum_geometric_of_lt_one hβ hβ).tsum_eq
theorem hasSum_geometric_two : HasSum (fun n : β β¦ ((1 : β) / 2) ^ n) 2 := by
convert hasSum_geometric_of_lt_one _ _ <;> norm_num
theorem summable_geometric_two : Summable fun n : β β¦ ((1 : β) / 2) ^ n :=
β¨_, hasSum_geometric_twoβ©
theorem summable_geometric_two_encode {ΞΉ : Type*} [Encodable ΞΉ] :
Summable fun i : ΞΉ β¦ (1 / 2 : β) ^ Encodable.encode i :=
summable_geometric_two.comp_injective Encodable.encode_injective
theorem tsum_geometric_two : (β' n : β, ((1 : β) / 2) ^ n) = 2 :=
hasSum_geometric_two.tsum_eq
theorem sum_geometric_two_le (n : β) : (β i β range n, (1 / (2 : β)) ^ i) β€ 2 := by
have : β i, 0 β€ (1 / (2 : β)) ^ i := by
intro i
apply pow_nonneg
norm_num
convert summable_geometric_two.sum_le_tsum (range n) (fun i _ β¦ this i)
exact tsum_geometric_two.symm
theorem tsum_geometric_inv_two : (β' n : β, (2 : β)β»ΒΉ ^ n) = 2 :=
(inv_eq_one_div (2 : β)).symm βΈ tsum_geometric_two
/-- The sum of `2β»ΒΉ ^ i` for `n β€ i` equals `2 * 2β»ΒΉ ^ n`. -/
theorem tsum_geometric_inv_two_ge (n : β) :
(β' i, ite (n β€ i) ((2 : β)β»ΒΉ ^ i) 0) = 2 * 2β»ΒΉ ^ n := by
have A : Summable fun i : β β¦ ite (n β€ i) ((2β»ΒΉ : β) ^ i) 0 := by
simpa only [β piecewise_eq_indicator, one_div]
using summable_geometric_two.indicator {i | n β€ i}
have B : ((Finset.range n).sum fun i : β β¦ ite (n β€ i) ((2β»ΒΉ : β) ^ i) 0) = 0 :=
Finset.sum_eq_zero fun i hi β¦
ite_eq_right_iff.2 fun h β¦ (lt_irrefl _ ((Finset.mem_range.1 hi).trans_le h)).elim
simp only [β Summable.sum_add_tsum_nat_add n A, B, if_true, zero_add, zero_le',
le_add_iff_nonneg_left, pow_add, _root_.tsum_mul_right, tsum_geometric_inv_two]
theorem hasSum_geometric_two' (a : β) : HasSum (fun n : β β¦ a / 2 / 2 ^ n) a := by
convert HasSum.mul_left (a / 2)
(hasSum_geometric_of_lt_one (le_of_lt one_half_pos) one_half_lt_one) using 1
Β· funext n
simp only [one_div, inv_pow]
rfl
Β· norm_num
theorem summable_geometric_two' (a : β) : Summable fun n : β β¦ a / 2 / 2 ^ n :=
β¨a, hasSum_geometric_two' aβ©
theorem tsum_geometric_two' (a : β) : β' n : β, a / 2 / 2 ^ n = a :=
(hasSum_geometric_two' a).tsum_eq
/-- **Sum of a Geometric Series** -/
theorem NNReal.hasSum_geometric {r : ββ₯0} (hr : r < 1) : HasSum (fun n : β β¦ r ^ n) (1 - r)β»ΒΉ := by
apply NNReal.hasSum_coe.1
push_cast
rw [NNReal.coe_sub (le_of_lt hr)]
exact hasSum_geometric_of_lt_one r.coe_nonneg hr
theorem NNReal.summable_geometric {r : ββ₯0} (hr : r < 1) : Summable fun n : β β¦ r ^ n :=
β¨_, NNReal.hasSum_geometric hrβ©
theorem tsum_geometric_nnreal {r : ββ₯0} (hr : r < 1) : β' n : β, r ^ n = (1 - r)β»ΒΉ :=
(NNReal.hasSum_geometric hr).tsum_eq
/-- The series `pow r` converges to `(1-r)β»ΒΉ`. For `r < 1` the RHS is a finite number,
and for `1 β€ r` the RHS equals `β`. -/
@[simp]
theorem ENNReal.tsum_geometric (r : ββ₯0β) : β' n : β, r ^ n = (1 - r)β»ΒΉ := by
rcases lt_or_ge r 1 with hr | hr
Β· rcases ENNReal.lt_iff_exists_coe.1 hr with β¨r, rfl, hr'β©
norm_cast at *
convert ENNReal.tsum_coe_eq (NNReal.hasSum_geometric hr)
rw [ENNReal.coe_inv <| ne_of_gt <| tsub_pos_iff_lt.2 hr, coe_sub, coe_one]
Β· rw [tsub_eq_zero_iff_le.mpr hr, ENNReal.inv_zero, ENNReal.tsum_eq_iSup_nat, iSup_eq_top]
refine fun a ha β¦
(ENNReal.exists_nat_gt (lt_top_iff_ne_top.1 ha)).imp fun n hn β¦ lt_of_lt_of_le hn ?_
calc
(n : ββ₯0β) = β i β range n, 1 := by rw [sum_const, nsmul_one, card_range]
_ β€ β i β range n, r ^ i := by gcongr; apply one_le_powβ hr
theorem ENNReal.tsum_geometric_add_one (r : ββ₯0β) : β' n : β, r ^ (n + 1) = r * (1 - r)β»ΒΉ := by
simp only [_root_.pow_succ', ENNReal.tsum_mul_left, ENNReal.tsum_geometric]
lemma ENNReal.tsum_two_zpow_neg_add_one :
β' m : β, 2 ^ (-1 - m : β€) = (1 : ββ₯0β) := by
simp_rw [neg_sub_left, ENNReal.zpow_neg, β Nat.cast_one (R := β€), β Nat.cast_add, zpow_natCast,
ENNReal.inv_pow, ENNReal.tsum_geometric_add_one, one_sub_inv_two, inv_inv]
exact ENNReal.inv_mul_cancel (Ne.symm (NeZero.ne' 2)) (Ne.symm top_ne_ofNat)
open Encodable
protected lemma ENNReal.tsum_geometric_two : β' n, (2β»ΒΉ : ββ₯0β) ^ n = 2 := by simp
lemma ENNReal.tsum_geometric_two_encode_le_two {ΞΉ : Type*} [Encodable ΞΉ] :
β' i : ΞΉ, (2β»ΒΉ : ββ₯0β) ^ encode i β€ 2 :=
(ENNReal.tsum_comp_le_tsum_of_injective encode_injective _).trans_eq ENNReal.tsum_geometric_two
lemma tsum_geometric_lt_top {r : ββ₯0β} : β' n, r ^ n < β β r < 1 := by simp
lemma tsum_geometric_encode_lt_top {r : ββ₯0β} (hr : r < 1) {ΞΉ : Type*} [Encodable ΞΉ] :
β' i : ΞΉ, (r : ββ₯0β) ^ encode i < β :=
(ENNReal.tsum_comp_le_tsum_of_injective encode_injective _).trans_lt <| by simpa
end Geometric
/-!
### Sequences with geometrically decaying distance in metric spaces
In this paragraph, we discuss sequences in metric spaces or emetric spaces for which the distance
between two consecutive terms decays geometrically. We show that such sequences are Cauchy
sequences, and bound their distances to the limit. We also discuss series with geometrically
decaying terms.
-/
section EdistLeGeometric
variable [PseudoEMetricSpace Ξ±] (r C : ββ₯0β) (hr : r < 1) (hC : C β β€) {f : β β Ξ±}
(hu : β n, edist (f n) (f (n + 1)) β€ C * r ^ n)
include hr hC hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, `C β β`, `r < 1`,
then `f` is a Cauchy sequence. -/
theorem cauchySeq_of_edist_le_geometric : CauchySeq f := by
refine cauchySeq_of_edist_le_of_tsum_ne_top _ hu ?_
rw [ENNReal.tsum_mul_left, ENNReal.tsum_geometric]
have := (tsub_pos_iff_lt.2 hr).ne'
finiteness
include hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, then the distance from
`f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/
theorem edist_le_of_edist_le_geometric_of_tendsto {a : Ξ±} (ha : Tendsto f atTop (π a)) (n : β) :
edist (f n) a β€ C * r ^ n / (1 - r) := by
convert edist_le_tsum_of_edist_le_of_tendsto _ hu ha _
simp only [pow_add, ENNReal.tsum_mul_left, ENNReal.tsum_geometric, div_eq_mul_inv, mul_assoc]
include hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, then the distance from
`f 0` to the limit of `f` is bounded above by `C / (1 - r)`. -/
theorem edist_le_of_edist_le_geometric_of_tendstoβ {a : Ξ±} (ha : Tendsto f atTop (π a)) :
edist (f 0) a β€ C / (1 - r) := by
simpa only [_root_.pow_zero, mul_one] using edist_le_of_edist_le_geometric_of_tendsto r C hu ha 0
end EdistLeGeometric
section EdistLeGeometricTwo
variable [PseudoEMetricSpace Ξ±] (C : ββ₯0β) (hC : C β β€) {f : β β Ξ±}
(hu : β n, edist (f n) (f (n + 1)) β€ C / 2 ^ n) {a : Ξ±} (ha : Tendsto f atTop (π a))
include hC hu in
/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then `f` is a Cauchy sequence. -/
theorem cauchySeq_of_edist_le_geometric_two : CauchySeq f := by
simp only [div_eq_mul_inv, ENNReal.inv_pow] at hu
refine cauchySeq_of_edist_le_geometric 2β»ΒΉ C ?_ hC hu
simp
include hu ha in
/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then the distance from
`f n` to the limit of `f` is bounded above by `2 * C * 2^-n`. -/
theorem edist_le_of_edist_le_geometric_two_of_tendsto (n : β) : edist (f n) a β€ 2 * C / 2 ^ n := by
simp only [div_eq_mul_inv, ENNReal.inv_pow] at *
rw [mul_assoc, mul_comm]
convert edist_le_of_edist_le_geometric_of_tendsto 2β»ΒΉ C hu ha n using 1
rw [ENNReal.one_sub_inv_two, div_eq_mul_inv, inv_inv]
include hu ha in
/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then the distance from
`f 0` to the limit of `f` is bounded above by `2 * C`. -/
theorem edist_le_of_edist_le_geometric_two_of_tendstoβ : edist (f 0) a β€ 2 * C := by
simpa only [_root_.pow_zero, div_eq_mul_inv, inv_one, mul_one] using
edist_le_of_edist_le_geometric_two_of_tendsto C hu ha 0
end EdistLeGeometricTwo
section LeGeometric
variable [PseudoMetricSpace Ξ±] {r C : β} {f : β β Ξ±}
section
variable (hr : r < 1) (hu : β n, dist (f n) (f (n + 1)) β€ C * r ^ n)
include hr hu
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then `f` is a Cauchy sequence. -/
theorem aux_hasSum_of_le_geometric : HasSum (fun n : β β¦ C * r ^ n) (C / (1 - r)) := by
rcases sign_cases_of_C_mul_pow_nonneg fun n β¦ dist_nonneg.trans (hu n) with (rfl | β¨_, rββ©)
Β· simp [hasSum_zero]
Β· refine HasSum.mul_left C ?_
simpa using hasSum_geometric_of_lt_one rβ hr
variable (r C)
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then `f` is a Cauchy sequence.
Note that this lemma does not assume `0 β€ C` or `0 β€ r`. -/
theorem cauchySeq_of_le_geometric : CauchySeq f :=
cauchySeq_of_dist_le_of_summable _ hu β¨_, aux_hasSum_of_le_geometric hr huβ©
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then the distance from
`f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/
theorem dist_le_of_le_geometric_of_tendstoβ {a : Ξ±} (ha : Tendsto f atTop (π a)) :
dist (f 0) a β€ C / (1 - r) :=
(aux_hasSum_of_le_geometric hr hu).tsum_eq βΈ
dist_le_tsum_of_dist_le_of_tendstoβ _ hu β¨_, aux_hasSum_of_le_geometric hr huβ© ha
/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then the distance from
`f 0` to the limit of `f` is bounded above by `C / (1 - r)`. -/
theorem dist_le_of_le_geometric_of_tendsto {a : Ξ±} (ha : Tendsto f atTop (π a)) (n : β) :
dist (f n) a β€ C * r ^ n / (1 - r) := by
have := aux_hasSum_of_le_geometric hr hu
convert dist_le_tsum_of_dist_le_of_tendsto _ hu β¨_, thisβ© ha n
simp only [pow_add, mul_left_comm C, mul_div_right_comm]
rw [mul_comm]
exact (this.mul_left _).tsum_eq.symm
end
variable (huβ : β n, dist (f n) (f (n + 1)) β€ C / 2 / 2 ^ n)
include huβ
/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then `f` is a Cauchy sequence. -/
theorem cauchySeq_of_le_geometric_two : CauchySeq f :=
cauchySeq_of_dist_le_of_summable _ huβ <| β¨_, hasSum_geometric_two' Cβ©
/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then the distance from
`f 0` to the limit of `f` is bounded above by `C`. -/
theorem dist_le_of_le_geometric_two_of_tendstoβ {a : Ξ±} (ha : Tendsto f atTop (π a)) :
dist (f 0) a β€ C :=
tsum_geometric_two' C βΈ dist_le_tsum_of_dist_le_of_tendstoβ _ huβ (summable_geometric_two' C) ha
/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then the distance from
`f n` to the limit of `f` is bounded above by `C / 2^n`. -/
theorem dist_le_of_le_geometric_two_of_tendsto {a : Ξ±} (ha : Tendsto f atTop (π a)) (n : β) :
dist (f n) a β€ C / 2 ^ n := by
convert dist_le_tsum_of_dist_le_of_tendsto _ huβ (summable_geometric_two' C) ha n
simp only [add_comm n, pow_add, β div_div]
symm
exact ((hasSum_geometric_two' C).div_const _).tsum_eq
end LeGeometric
/-! ### Summability tests based on comparison with geometric series -/
/-- A series whose terms are bounded by the terms of a converging geometric series converges. -/
theorem summable_one_div_pow_of_le {m : β} {f : β β β} (hm : 1 < m) (fi : β i, i β€ f i) :
Summable fun i β¦ 1 / m ^ f i := by
refine .of_nonneg_of_le (fun a β¦ by positivity) (fun a β¦ ?_)
(summable_geometric_of_lt_one (one_div_nonneg.mpr (zero_le_one.trans hm.le))
((one_div_lt (zero_lt_one.trans hm) zero_lt_one).mpr (one_div_one.le.trans_lt hm)))
rw [div_pow, one_pow]
refine (one_div_le_one_div ?_ ?_).mpr (pow_right_monoβ hm.le (fi a)) <;>
exact pow_pos (zero_lt_one.trans hm) _
/-! ### Positive sequences with small sums on countable types -/
/-- For any positive `Ξ΅`, define on an encodable type a positive sequence with sum less than `Ξ΅` -/
def posSumOfEncodable {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) (ΞΉ) [Encodable ΞΉ] :
{ Ξ΅' : ΞΉ β β // (β i, 0 < Ξ΅' i) β§ β c, HasSum Ξ΅' c β§ c β€ Ξ΅ } := by
let f n := Ξ΅ / 2 / 2 ^ n
have hf : HasSum f Ξ΅ := hasSum_geometric_two' _
have f0 : β n, 0 < f n := fun n β¦ div_pos (half_pos hΞ΅) (pow_pos zero_lt_two _)
refine β¨f β Encodable.encode, fun i β¦ f0 _, ?_β©
rcases hf.summable.comp_injective (@Encodable.encode_injective ΞΉ _) with β¨c, hgβ©
refine β¨c, hg, hasSum_le_inj _ (@Encodable.encode_injective ΞΉ _) ?_ ?_ hg hfβ©
Β· intro i _
exact le_of_lt (f0 _)
Β· intro n
exact le_rfl
theorem Set.Countable.exists_pos_hasSum_le {ΞΉ : Type*} {s : Set ΞΉ} (hs : s.Countable) {Ξ΅ : β}
(hΞ΅ : 0 < Ξ΅) : β Ξ΅' : ΞΉ β β, (β i, 0 < Ξ΅' i) β§ β c, HasSum (fun i : s β¦ Ξ΅' i) c β§ c β€ Ξ΅ := by
classical
haveI := hs.toEncodable
rcases posSumOfEncodable hΞ΅ s with β¨f, hf0, β¨c, hfc, hcΞ΅β©β©
refine β¨fun i β¦ if h : i β s then f β¨i, hβ© else 1, fun i β¦ ?_, β¨c, ?_, hcΞ΅β©β©
Β· conv_rhs => simp
split_ifs
exacts [hf0 _, zero_lt_one]
Β· simpa only [Subtype.coe_prop, dif_pos, Subtype.coe_eta]
theorem Set.Countable.exists_pos_forall_sum_le {ΞΉ : Type*} {s : Set ΞΉ} (hs : s.Countable) {Ξ΅ : β}
(hΞ΅ : 0 < Ξ΅) : β Ξ΅' : ΞΉ β β,
(β i, 0 < Ξ΅' i) β§ β t : Finset ΞΉ, βt β s β β i β t, Ξ΅' i β€ Ξ΅ := by
classical
rcases hs.exists_pos_hasSum_le hΞ΅ with β¨Ξ΅', hpos, c, hΞ΅'c, hcΞ΅β©
refine β¨Ξ΅', hpos, fun t ht β¦ ?_β©
rw [β sum_subtype_of_mem _ ht]
refine (sum_le_hasSum _ ?_ hΞ΅'c).trans hcΞ΅
exact fun _ _ β¦ (hpos _).le
namespace NNReal
theorem exists_pos_sum_of_countable {Ξ΅ : ββ₯0} (hΞ΅ : Ξ΅ β 0) (ΞΉ) [Countable ΞΉ] :
β Ξ΅' : ΞΉ β ββ₯0, (β i, 0 < Ξ΅' i) β§ β c, HasSum Ξ΅' c β§ c < Ξ΅ := by
cases nonempty_encodable ΞΉ
obtain β¨a, a0, aΞ΅β© := exists_between (pos_iff_ne_zero.2 hΞ΅)
obtain β¨Ξ΅', hΞ΅', c, hc, hcΞ΅β© := posSumOfEncodable a0 ΞΉ
exact
β¨fun i β¦ β¨Ξ΅' i, (hΞ΅' i).leβ©, fun i β¦ NNReal.coe_lt_coe.1 <| hΞ΅' i,
β¨c, hasSum_le (fun i β¦ (hΞ΅' i).le) hasSum_zero hcβ©, NNReal.hasSum_coe.1 hc,
aΞ΅.trans_le' <| NNReal.coe_le_coe.1 hcΞ΅β©
end NNReal
namespace ENNReal
theorem exists_pos_sum_of_countable {Ξ΅ : ββ₯0β} (hΞ΅ : Ξ΅ β 0) (ΞΉ) [Countable ΞΉ] :
β Ξ΅' : ΞΉ β ββ₯0, (β i, 0 < Ξ΅' i) β§ (β' i, (Ξ΅' i : ββ₯0β)) < Ξ΅ := by
rcases exists_between (pos_iff_ne_zero.2 hΞ΅) with β¨r, h0r, hrΞ΅β©
rcases lt_iff_exists_coe.1 hrΞ΅ with β¨x, rfl, _β©
rcases NNReal.exists_pos_sum_of_countable (coe_pos.1 h0r).ne' ΞΉ with β¨Ξ΅', hp, c, hc, hcrβ©
exact β¨Ξ΅', hp, (ENNReal.tsum_coe_eq hc).symm βΈ lt_trans (coe_lt_coe.2 hcr) hrΞ΅β©
theorem exists_pos_sum_of_countable' {Ξ΅ : ββ₯0β} (hΞ΅ : Ξ΅ β 0) (ΞΉ) [Countable ΞΉ] :
β Ξ΅' : ΞΉ β ββ₯0β, (β i, 0 < Ξ΅' i) β§ β' i, Ξ΅' i < Ξ΅ :=
let β¨Ξ΄, Ξ΄pos, hΞ΄β© := exists_pos_sum_of_countable hΞ΅ ΞΉ
β¨fun i β¦ Ξ΄ i, fun i β¦ ENNReal.coe_pos.2 (Ξ΄pos i), hΞ΄β©
theorem exists_pos_tsum_mul_lt_of_countable {Ξ΅ : ββ₯0β} (hΞ΅ : Ξ΅ β 0) {ΞΉ} [Countable ΞΉ] (w : ΞΉ β ββ₯0β)
(hw : β i, w i β β) : β Ξ΄ : ΞΉ β ββ₯0, (β i, 0 < Ξ΄ i) β§ (β' i, (w i * Ξ΄ i : ββ₯0β)) < Ξ΅ := by
lift w to ΞΉ β ββ₯0 using hw
rcases exists_pos_sum_of_countable hΞ΅ ΞΉ with β¨Ξ΄', Hpos, Hsumβ©
have : β i, 0 < max 1 (w i) := fun i β¦ zero_lt_one.trans_le (le_max_left _ _)
refine β¨fun i β¦ Ξ΄' i / max 1 (w i), fun i β¦ div_pos (Hpos _) (this i), ?_β©
refine lt_of_le_of_lt (ENNReal.tsum_le_tsum fun i β¦ ?_) Hsum
rw [coe_div (this i).ne']
refine mul_le_of_le_div' ?_
grw [β le_max_right]
end ENNReal
/-!
### Factorial
-/
theorem factorial_tendsto_atTop : Tendsto Nat.factorial atTop atTop :=
tendsto_atTop_atTop_of_monotone (fun _ _ β¦ Nat.factorial_le) fun n β¦ β¨n, n.self_le_factorialβ©
theorem tendsto_factorial_div_pow_self_atTop :
Tendsto (fun n β¦ n ! / (n : β) ^ n : β β β) atTop (π 0) :=
tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds
(tendsto_const_div_atTop_nhds_zero_nat 1)
(Eventually.of_forall fun n β¦
div_nonneg (mod_cast n.factorial_pos.le)
(pow_nonneg (mod_cast n.zero_le) _))
(by
refine (eventually_gt_atTop 0).mono fun n hn β¦ ?_
rcases Nat.exists_eq_succ_of_ne_zero hn.ne.symm with β¨k, rflβ©
rw [factorial_eq_prod_range_add_one, pow_eq_prod_const, div_eq_mul_inv, β inv_eq_one_div,
prod_natCast, Nat.cast_succ, β Finset.prod_inv_distrib, β prod_mul_distrib,
Finset.prod_range_succ']
simp only [one_mul, Nat.cast_add, zero_add, Nat.cast_one]
refine
mul_le_of_le_one_left (inv_nonneg.mpr <| mod_cast hn.le) (prod_le_one ?_ ?_) <;>
intro x hx <;>
rw [Finset.mem_range] at hx
Β· positivity
Β· refine (div_le_one <| mod_cast hn).mpr ?_
norm_cast
cutsat)
/-!
### Ceil and floor
-/
section
theorem tendsto_nat_floor_atTop {Ξ± : Type*}
[Semiring Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±] [FloorSemiring Ξ±] :
Tendsto (fun x : Ξ± β¦ βxββ) atTop atTop :=
Nat.floor_mono.tendsto_atTop_atTop fun x β¦ β¨max 0 (x + 1), by simp [Nat.le_floor_iff]β©
lemma tendsto_nat_ceil_atTop {Ξ± : Type*}
[Semiring Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±] [FloorSemiring Ξ±] :
Tendsto (fun x : Ξ± β¦ βxββ) atTop atTop := by
refine Nat.ceil_mono.tendsto_atTop_atTop (fun x β¦ β¨x, ?_β©)
simp only [Nat.ceil_natCast, le_refl]
lemma tendsto_nat_floor_mul_atTop {Ξ± : Type _}
[Semifield Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±] [FloorSemiring Ξ±]
[Archimedean Ξ±] (a : Ξ±) (ha : 0 < a) : Tendsto (fun (x : β) => βa * xββ) atTop atTop :=
Tendsto.comp tendsto_nat_floor_atTop
<| Tendsto.const_mul_atTop ha tendsto_natCast_atTop_atTop
variable {R : Type*} [TopologicalSpace R] [Field R] [LinearOrder R] [IsStrictOrderedRing R]
[OrderTopology R] [FloorRing R]
theorem tendsto_nat_floor_mul_div_atTop {a : R} (ha : 0 β€ a) :
Tendsto (fun x β¦ (βa * xββ : R) / x) atTop (π a) := by
have A : Tendsto (fun x : R β¦ a - xβ»ΒΉ) atTop (π (a - 0)) :=
tendsto_const_nhds.sub tendsto_inv_atTop_zero
rw [sub_zero] at A
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' A tendsto_const_nhds
Β· refine eventually_atTop.2 β¨1, fun x hx β¦ ?_β©
simp only [le_div_iffβ (zero_lt_one.trans_le hx), _root_.sub_mul,
inv_mul_cancelβ (zero_lt_one.trans_le hx).ne']
have := Nat.lt_floor_add_one (a * x)
linarith
Β· refine eventually_atTop.2 β¨1, fun x hx β¦ ?_β©
rw [div_le_iffβ (zero_lt_one.trans_le hx)]
simp [Nat.floor_le (mul_nonneg ha (zero_le_one.trans hx))]
theorem tendsto_nat_floor_div_atTop : Tendsto (fun x β¦ (βxββ : R) / x) atTop (π 1) := by
simpa using tendsto_nat_floor_mul_div_atTop (zero_le_one' R)
theorem tendsto_nat_ceil_mul_div_atTop {a : R} (ha : 0 β€ a) :
Tendsto (fun x β¦ (βa * xββ : R) / x) atTop (π a) := by
have A : Tendsto (fun x : R β¦ a + xβ»ΒΉ) atTop (π (a + 0)) :=
tendsto_const_nhds.add tendsto_inv_atTop_zero
rw [add_zero] at A
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds A
Β· refine eventually_atTop.2 β¨1, fun x hx β¦ ?_β©
rw [le_div_iffβ (zero_lt_one.trans_le hx)]
exact Nat.le_ceil _
Β· refine eventually_atTop.2 β¨1, fun x hx β¦ ?_β©
simp [div_le_iffβ (zero_lt_one.trans_le hx), inv_mul_cancelβ (zero_lt_one.trans_le hx).ne',
(Nat.ceil_lt_add_one (mul_nonneg ha (zero_le_one.trans hx))).le, add_mul]
theorem tendsto_nat_ceil_div_atTop : Tendsto (fun x β¦ (βxββ : R) / x) atTop (π 1) := by
simpa using tendsto_nat_ceil_mul_div_atTop (zero_le_one' R)
lemma Nat.tendsto_div_const_atTop {n : β} (hn : n β 0) : Tendsto (Β· / n) atTop atTop := by
rw [Tendsto, map_div_atTop_eq_nat n hn.bot_lt]
end
@[deprecated (since := "2025-10-27")]
alias tendsto_inverse_atTop_nhds_zero_nat := tendsto_inv_atTop_nhds_zero_nat
@[deprecated (since := "2025-10-27")]
alias NNReal.tendsto_inverse_atTop_nhds_zero_nat := tendsto_inv_atTop_nhds_zero_nat
@[deprecated (since := "2025-10-27")]
alias NNReal.tendsto_const_div_atTop_nhds_zero_nat := tendsto_const_div_atTop_nhds_zero_nat
@[deprecated (since := "2025-10-27")]
alias NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat :=
tendsto_algebraMap_inv_atTop_nhds_zero_nat
@[deprecated (since := "2025-10-27")]
alias tendsto_algebraMap_inverse_atTop_nhds_zero_nat :=
tendsto_algebraMap_inv_atTop_nhds_zero_nat
@[deprecated (since := "2025-10-27")]
protected alias Nat.tendsto_pow_atTop_atTop_of_one_lt := tendsto_pow_atTop_atTop_of_one_lt |
.lake/packages/mathlib/Mathlib/Analysis/SpecificLimits/ArithmeticGeometric.lean | import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Arithmetic-geometric sequences
An arithmetic-geometric sequence is a sequence defined by the recurrence relation
`u (n + 1) = a * u n + b`.
## Main definitions
* `arithGeom a b uβ`: arithmetic-geometric sequence with starting value `uβ` and recurrence relation
`u (n + 1) = a * u n + b`.
## Main statements
* `arithGeom_eq`: for `a β 1`, `arithGeom a b uβ n = a ^ n * (uβ - (b / (1 - a))) + b / (1 - a)`
* `tendsto_arithGeom_atTop_of_one_lt`: if `1 < a` and `b / (1 - a) < uβ`, then `arithGeom a b uβ n`
tends to `+β` as `n` tends to `+β`.
`tendsto_arithGeom_nhds_of_lt_one`: if `0 β€ a < 1`, then `arithGeom a b uβ n` tends to
`b / (1 - a)` as `n` tends to `+β`.
* `arithGeom_strictMono`: if `1 < a` and `b / (1 - a) < uβ`, then `arithGeom a b uβ` is strictly
monotone.
-/
open Filter Topology
variable {R : Type*} {a b uβ : R}
/-- Arithmetic-geometric sequence with starting value `uβ` and recurrence relation
`u (n + 1) = a * u n + b`. -/
def arithGeom [Mul R] [Add R] (a b uβ : R) : β β R
| 0 => uβ
| n + 1 => a * arithGeom a b uβ n + b
@[simp] lemma arithGeom_zero [Mul R] [Add R] : arithGeom a b uβ 0 = uβ := rfl
lemma arithGeom_succ [Mul R] [Add R] (n : β) :
arithGeom a b uβ (n + 1) = a * arithGeom a b uβ n + b := rfl
lemma arithGeom_eq_add_sum [CommSemiring R] (n : β) :
arithGeom a b uβ n = a ^ n * uβ + b * β k β Finset.range n, a ^ k := by
induction n with
| zero => simp
| succ n hn =>
rw [arithGeom_succ, hn, mul_add, β mul_assoc, add_comm n, pow_add, pow_one, add_assoc]
congr
rw [add_comm _ n, Finset.sum_range_succ', Finset.mul_sum, pow_zero, mul_add, mul_one,
Finset.mul_sum, Finset.mul_sum]
congr with k
ring
lemma arithGeom_same_eq_sum [CommSemiring R] (n : β) :
arithGeom a b b n = b * β k β Finset.range (n + 1), a ^ k := by
rw [arithGeom_eq_add_sum, Finset.sum_range_succ, mul_add, add_comm, mul_comm _ b]
lemma arithGeom_zero_eq_sum [CommSemiring R] (n : β) :
arithGeom a b 0 n = b * β k β Finset.range n, a ^ k := by
simp [arithGeom_eq_add_sum]
variable [Field R]
lemma arithGeom_eq (ha : a β 1) (n : β) :
arithGeom a b uβ n = a ^ n * (uβ - (b / (1 - a))) + b / (1 - a) := by
induction n with
| zero => simp
| succ n hn => unfold arithGeom; grind
lemma arithGeom_eq' (ha : a β 1) :
arithGeom a b uβ = fun n β¦ a ^ n * (uβ - (b / (1 - a))) + b / (1 - a) := by
ext
exact arithGeom_eq ha _
lemma arithGeom_same_eq_mul_div' (ha : a β 1) (n : β) :
arithGeom a b b n = b * (1 - a ^ (n + 1)) / (1 - a) := by
rw [arithGeom_eq ha n]
field [sub_ne_zero.mpr ha.symm]
lemma arithGeom_same_eq_mul_div (ha : a β 1) (n : β) :
arithGeom a b b n = b * (a ^ (n + 1) - 1) / (a - 1) := by
rw [arithGeom_same_eq_mul_div' ha n, β neg_sub _ a, div_neg,
β neg_sub _ (a ^ (n + 1)), mul_neg, neg_div, neg_neg]
lemma arithGeom_zero_eq_mul_div' (ha : a β 1) (n : β) :
arithGeom a b 0 n = b * (1 - a ^ n) / (1 - a) := by
rw [arithGeom_eq ha n]
ring
lemma arithGeom_zero_eq_mul_div (ha : a β 1) (n : β) :
arithGeom a b 0 n = b * (a ^ n - 1) / (a - 1) := by
rw [arithGeom_zero_eq_mul_div' ha n, β neg_sub _ a, div_neg, β neg_sub _ (a ^ n), mul_neg,
neg_div, neg_neg]
variable [LinearOrder R] [IsStrictOrderedRing R]
lemma div_lt_arithGeom (ha_pos : 0 < a) (ha_ne : a β 1) (h0 : b / (1 - a) < uβ) (n : β) :
b / (1 - a) < arithGeom a b uβ n := by
induction n with
| zero => exact h0
| succ n hn =>
calc b / (1 - a)
_ = a * (b / (1 - a)) + b := by grind
_ < a * arithGeom a b uβ n + b := by gcongr
lemma arithGeom_strictMono (ha : 1 < a) (h0 : b / (1 - a) < uβ) :
StrictMono (arithGeom a b uβ) := by
refine strictMono_nat_of_lt_succ fun n β¦ ?_
have h_lt : b / (1 - a) < arithGeom a b uβ n := div_lt_arithGeom (by positivity) ha.ne' h0 n
rw [div_lt_iff_of_neg (sub_neg.mpr ha)] at h_lt
rw [arithGeom_succ]
linarith
lemma tendsto_arithGeom_atTop_of_one_lt [Archimedean R] (ha : 1 < a) (h0 : b / (1 - a) < uβ) :
Tendsto (arithGeom a b uβ) atTop atTop := by
rw [arithGeom_eq' ha.ne']
refine tendsto_atTop_add_const_right _ _ ?_
refine Tendsto.atTop_mul_const (sub_pos.mpr h0) ?_
exact tendsto_pow_atTop_atTop_of_one_lt ha
lemma tendsto_arithGeom_nhds_of_lt_one [Archimedean R] [TopologicalSpace R] [OrderTopology R]
(ha_pos : 0 β€ a) (ha : a < 1) :
Tendsto (arithGeom a b uβ) atTop (π (b / (1 - a))) := by
rw [arithGeom_eq' ha.ne]
conv_rhs => rw [β zero_add (b / (1 - a))]
refine Tendsto.add ?_ tendsto_const_nhds
conv_rhs => rw [β zero_mul (uβ - (b / (1 - a)))]
exact (tendsto_pow_atTop_nhds_zero_of_lt_one ha_pos ha).mul_const _ |
.lake/packages/mathlib/Mathlib/Analysis/SpecificLimits/FloorPow.lean | import Mathlib.Algebra.Order.Field.GeomSum
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Results on discretized exponentials
We state several auxiliary results pertaining to sequences of the form `βc^nββ`.
* `tendsto_div_of_monotone_of_tendsto_div_floor_pow`: If a monotone sequence `u` is such that
`u βc^nββ / βc^nββ` converges to a limit `l` for all `c > 1`, then `u n / n` tends to `l`.
* `sum_div_nat_floor_pow_sq_le_div_sq`: The sum of `1/βc^iββ^2` above a threshold `j` is comparable
to `1/j^2`, up to a multiplicative constant.
-/
open Filter Finset
open Topology
/-- If a monotone sequence `u` is such that `u n / n` tends to a limit `l` along subsequences with
exponential growth rate arbitrarily close to `1`, then `u n / n` tends to `l`. -/
theorem tendsto_div_of_monotone_of_exists_subseq_tendsto_div (u : β β β) (l : β)
(hmono : Monotone u)
(hlim : β a : β, 1 < a β β c : β β β, (βαΆ n in atTop, (c (n + 1) : β) β€ a * c n) β§
Tendsto c atTop atTop β§ Tendsto (fun n => u (c n) / c n) atTop (π l)) :
Tendsto (fun n => u n / n) atTop (π l) := by
/- To check the result up to some `Ξ΅ > 0`, we use a sequence `c` for which the ratio
`c (N+1) / c N` is bounded by `1 + Ξ΅`. Sandwiching a given `n` between two consecutive values of
`c`, say `c N` and `c (N+1)`, one can then bound `u n / n` from above by `u (c N) / c (N - 1)`
and from below by `u (c (N - 1)) / c N` (using that `u` is monotone), which are both comparable
to the limit `l` up to `1 + Ξ΅`.
We give a version of this proof by clearing out denominators first, to avoid discussing the sign
of different quantities. -/
have lnonneg : 0 β€ l := by
rcases hlim 2 one_lt_two with β¨c, _, ctop, climβ©
have : Tendsto (fun n => u 0 / c n) atTop (π 0) :=
tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_iff.2 ctop)
apply le_of_tendsto_of_tendsto' this clim fun n => ?_
gcongr
exact hmono (zero_le _)
have A : β Ξ΅ : β, 0 < Ξ΅ β βαΆ n in atTop, u n - n * l β€ Ξ΅ * (1 + Ξ΅ + l) * n := by
intro Ξ΅ Ξ΅pos
rcases hlim (1 + Ξ΅) ((lt_add_iff_pos_right _).2 Ξ΅pos) with β¨c, cgrowth, ctop, climβ©
have L : βαΆ n in atTop, u (c n) - c n * l β€ Ξ΅ * c n := by
rw [β tendsto_sub_nhds_zero_iff, β Asymptotics.isLittleO_one_iff β,
Asymptotics.isLittleO_iff] at clim
filter_upwards [clim Ξ΅pos, ctop (Ioi_mem_atTop 0)] with n hn cnpos'
have cnpos : 0 < c n := cnpos'
calc
u (c n) - c n * l = (u (c n) / c n - l) * c n := by field
_ β€ Ξ΅ * c n := by
gcongr
refine (le_abs_self _).trans ?_
simpa using hn
obtain β¨a, haβ© :
β a : β, β b : β, a β€ b β (c (b + 1) : β) β€ (1 + Ξ΅) * c b β§ u (c b) - c b * l β€ Ξ΅ * c b :=
eventually_atTop.1 (cgrowth.and L)
let M := ((Finset.range (a + 1)).image fun i => c i).max' (by simp)
filter_upwards [Ici_mem_atTop M] with n hn
have exN : β N, n < c N := by
rcases (tendsto_atTop.1 ctop (n + 1)).exists with β¨N, hNβ©
exact β¨N, by cutsatβ©
let N := Nat.find exN
have ncN : n < c N := Nat.find_spec exN
have aN : a + 1 β€ N := by
by_contra! h
have cNM : c N β€ M := by
apply le_max'
apply mem_image_of_mem
exact mem_range.2 h
exact lt_irrefl _ ((cNM.trans hn).trans_lt ncN)
have Npos : 0 < N := lt_of_lt_of_le Nat.succ_pos' aN
have cNn : c (N - 1) β€ n := by
have : N - 1 < N := Nat.pred_lt Npos.ne'
simpa only [not_lt] using Nat.find_min exN this
have IcN : (c N : β) β€ (1 + Ξ΅) * c (N - 1) := by
have A : a β€ N - 1 := by
apply @Nat.le_of_add_le_add_right a 1 (N - 1)
rw [Nat.sub_add_cancel Npos]
exact aN
have B : N - 1 + 1 = N := Nat.succ_pred_eq_of_pos Npos
have := (ha _ A).1
rwa [B] at this
calc
u n - n * l β€ u (c N) - c (N - 1) * l := by gcongr; exact hmono ncN.le
_ = u (c N) - c N * l + (c N - c (N - 1)) * l := by ring
_ β€ Ξ΅ * c N + Ξ΅ * c (N - 1) * l := by
gcongr
Β· exact (ha N (a.le_succ.trans aN)).2
Β· linarith only [IcN]
_ β€ Ξ΅ * ((1 + Ξ΅) * c (N - 1)) + Ξ΅ * c (N - 1) * l := by gcongr
_ = Ξ΅ * (1 + Ξ΅ + l) * c (N - 1) := by ring
_ β€ Ξ΅ * (1 + Ξ΅ + l) * n := by gcongr
have B : β Ξ΅ : β, 0 < Ξ΅ β βαΆ n : β in atTop, (n : β) * l - u n β€ Ξ΅ * (1 + l) * n := by
intro Ξ΅ Ξ΅pos
rcases hlim (1 + Ξ΅) ((lt_add_iff_pos_right _).2 Ξ΅pos) with β¨c, cgrowth, ctop, climβ©
have L : βαΆ n : β in atTop, (c n : β) * l - u (c n) β€ Ξ΅ * c n := by
rw [β tendsto_sub_nhds_zero_iff, β Asymptotics.isLittleO_one_iff β,
Asymptotics.isLittleO_iff] at clim
filter_upwards [clim Ξ΅pos, ctop (Ioi_mem_atTop 0)] with n hn cnpos'
have cnpos : 0 < c n := cnpos'
calc
(c n : β) * l - u (c n) = -(u (c n) / c n - l) * c n := by field
_ β€ Ξ΅ * c n := by
gcongr
refine le_trans (neg_le_abs _) ?_
simpa using hn
obtain β¨a, haβ© :
β a : β,
β b : β, a β€ b β (c (b + 1) : β) β€ (1 + Ξ΅) * c b β§ (c b : β) * l - u (c b) β€ Ξ΅ * c b :=
eventually_atTop.1 (cgrowth.and L)
let M := ((Finset.range (a + 1)).image fun i => c i).max' (by simp)
filter_upwards [Ici_mem_atTop M] with n hn
have exN : β N, n < c N := by
rcases (tendsto_atTop.1 ctop (n + 1)).exists with β¨N, hNβ©
exact β¨N, by cutsatβ©
let N := Nat.find exN
have ncN : n < c N := Nat.find_spec exN
have aN : a + 1 β€ N := by
by_contra! h
have cNM : c N β€ M := by
apply le_max'
apply mem_image_of_mem
exact mem_range.2 h
exact lt_irrefl _ ((cNM.trans hn).trans_lt ncN)
have Npos : 0 < N := lt_of_lt_of_le Nat.succ_pos' aN
have aN' : a β€ N - 1 := by
apply @Nat.le_of_add_le_add_right a 1 (N - 1)
rw [Nat.sub_add_cancel Npos]
exact aN
have cNn : c (N - 1) β€ n := by
have : N - 1 < N := Nat.pred_lt Npos.ne'
simpa only [not_lt] using Nat.find_min exN this
calc
(n : β) * l - u n β€ c N * l - u (c (N - 1)) := by
gcongr
exact hmono cNn
_ β€ (1 + Ξ΅) * c (N - 1) * l - u (c (N - 1)) := by
gcongr
have B : N - 1 + 1 = N := Nat.succ_pred_eq_of_pos Npos
simpa [B] using (ha _ aN').1
_ = c (N - 1) * l - u (c (N - 1)) + Ξ΅ * c (N - 1) * l := by ring
_ β€ Ξ΅ * c (N - 1) + Ξ΅ * c (N - 1) * l := add_le_add (ha _ aN').2 le_rfl
_ = Ξ΅ * (1 + l) * c (N - 1) := by ring
_ β€ Ξ΅ * (1 + l) * n := by gcongr
refine tendsto_order.2 β¨fun d hd => ?_, fun d hd => ?_β©
Β· obtain β¨Ξ΅, hΞ΅, Ξ΅posβ© : β Ξ΅ : β, d + Ξ΅ * (1 + l) < l β§ 0 < Ξ΅ := by
have L : Tendsto (fun Ξ΅ => d + Ξ΅ * (1 + l)) (π[>] 0) (π (d + 0 * (1 + l))) := by
apply Tendsto.mono_left _ nhdsWithin_le_nhds
exact tendsto_const_nhds.add (tendsto_id.mul tendsto_const_nhds)
simp only [zero_mul, add_zero] at L
exact (((tendsto_order.1 L).2 l hd).and self_mem_nhdsWithin).exists
filter_upwards [B Ξ΅ Ξ΅pos, Ioi_mem_atTop 0] with n hn npos
simp_rw [div_eq_inv_mul]
calc
d < (n : β)β»ΒΉ * n * (l - Ξ΅ * (1 + l)) := by
rw [inv_mul_cancelβ, one_mul]
Β· linarith only [hΞ΅]
Β· exact Nat.cast_ne_zero.2 (ne_of_gt npos)
_ = (n : β)β»ΒΉ * (n * l - Ξ΅ * (1 + l) * n) := by ring
_ β€ (n : β)β»ΒΉ * u n := by gcongr; linarith only [hn]
Β· obtain β¨Ξ΅, hΞ΅, Ξ΅posβ© : β Ξ΅ : β, l + Ξ΅ * (1 + Ξ΅ + l) < d β§ 0 < Ξ΅ := by
have L : Tendsto (fun Ξ΅ => l + Ξ΅ * (1 + Ξ΅ + l)) (π[>] 0) (π (l + 0 * (1 + 0 + l))) := by
apply Tendsto.mono_left _ nhdsWithin_le_nhds
exact
tendsto_const_nhds.add
(tendsto_id.mul ((tendsto_const_nhds.add tendsto_id).add tendsto_const_nhds))
simp only [zero_mul, add_zero] at L
exact (((tendsto_order.1 L).2 d hd).and self_mem_nhdsWithin).exists
filter_upwards [A Ξ΅ Ξ΅pos, Ioi_mem_atTop 0] with n hn (npos : 0 < n)
calc
u n / n β€ (n * l + Ξ΅ * (1 + Ξ΅ + l) * n) / n := by gcongr; linarith only [hn]
_ = (l + Ξ΅ * (1 + Ξ΅ + l)) := by field
_ < d := hΞ΅
/-- If a monotone sequence `u` is such that `u βc^nββ / βc^nββ` converges to a limit `l` for all
`c > 1`, then `u n / n` tends to `l`. It is even enough to have the assumption for a sequence of
`c`s converging to `1`. -/
theorem tendsto_div_of_monotone_of_tendsto_div_floor_pow (u : β β β) (l : β) (hmono : Monotone u)
(c : β β β) (cone : β k, 1 < c k) (clim : Tendsto c atTop (π 1))
(hc : β k, Tendsto (fun n : β => u βc k ^ nββ / βc k ^ nββ) atTop (π l)) :
Tendsto (fun n => u n / n) atTop (π l) := by
apply tendsto_div_of_monotone_of_exists_subseq_tendsto_div u l hmono
intro a ha
obtain β¨k, hkβ© : β k, c k < a := ((tendsto_order.1 clim).2 a ha).exists
refine
β¨fun n => βc k ^ nββ, ?_,
(tendsto_nat_floor_atTop (Ξ± := β)).comp (tendsto_pow_atTop_atTop_of_one_lt (cone k)), hc kβ©
have H : β n : β, (0 : β) < βc k ^ nββ := by
intro n
refine zero_lt_one.trans_le ?_
simp only [Nat.one_le_cast, Nat.one_le_floor_iff, one_le_powβ (cone k).le]
have A :
Tendsto (fun n : β => (βc k ^ (n + 1)ββ : β) / c k ^ (n + 1) * c k / (βc k ^ nββ / c k ^ n))
atTop (π (1 * c k / 1)) := by
refine Tendsto.div (Tendsto.mul ?_ tendsto_const_nhds) ?_ one_ne_zero
Β· refine tendsto_nat_floor_div_atTop.comp ?_
exact (tendsto_pow_atTop_atTop_of_one_lt (cone k)).comp (tendsto_add_atTop_nat 1)
Β· refine tendsto_nat_floor_div_atTop.comp ?_
exact tendsto_pow_atTop_atTop_of_one_lt (cone k)
have B : Tendsto (fun n : β => (βc k ^ (n + 1)ββ : β) / βc k ^ nββ) atTop (π (c k)) := by
simp only [one_mul, div_one] at A
convert A using 1
ext1 n
field [(zero_lt_one.trans (cone k)).ne']
filter_upwards [(tendsto_order.1 B).2 a hk] with n hn
exact (div_le_iffβ (H n)).1 hn.le
/-- The sum of `1/(c^i)^2` above a threshold `j` is comparable to `1/j^2`, up to a multiplicative
constant. -/
theorem sum_div_pow_sq_le_div_sq (N : β) {j : β} (hj : 0 < j) {c : β} (hc : 1 < c) :
(β i β range N with j < c ^ i, (1 : β) / (c ^ i) ^ 2) β€ c ^ 3 * (c - 1)β»ΒΉ / j ^ 2 := by
have cpos : 0 < c := zero_lt_one.trans hc
have A : (0 : β) < cβ»ΒΉ ^ 2 := sq_pos_of_pos (inv_pos.2 cpos)
have B : c ^ 2 * ((1 : β) - cβ»ΒΉ ^ 2)β»ΒΉ β€ c ^ 3 * (c - 1)β»ΒΉ := by
rw [β div_eq_mul_inv, β div_eq_mul_inv, div_le_div_iffβ _ (sub_pos.2 hc)]
swap
Β· exact sub_pos.2 (pow_lt_oneβ (inv_nonneg.2 cpos.le) (inv_lt_one_of_one_ltβ hc) two_ne_zero)
have : c ^ 3 = c ^ 2 * c := by ring
simp only [mul_sub, this, mul_one, inv_pow, sub_le_sub_iff_left]
rw [mul_assoc, mul_comm c, β mul_assoc, mul_inv_cancelβ (sq_pos_of_pos cpos).ne', one_mul]
simpa using pow_right_monoβ hc.le one_le_two
have C : cβ»ΒΉ ^ 2 < 1 := pow_lt_oneβ (inv_nonneg.2 cpos.le) (inv_lt_one_of_one_ltβ hc) two_ne_zero
calc
(β i β range N with j < c ^ i, (1 : β) / (c ^ i) ^ 2) β€
β i β Ico βReal.log j / Real.log cββ N, (1 : β) / (c ^ i) ^ 2 := by
gcongr
intro i hi
simp only [mem_filter, mem_range] at hi
simp only [hi.1, mem_Ico, and_true]
apply Nat.floor_le_of_le
apply le_of_lt
rw [div_lt_iffβ (Real.log_pos hc), β Real.log_pow]
exact Real.log_lt_log hj hi.2
_ = β i β Ico βReal.log j / Real.log cββ N, (cβ»ΒΉ ^ 2) ^ i := by
simp [β pow_mul, mul_comm]
_ β€ (cβ»ΒΉ ^ 2) ^ βReal.log j / Real.log cββ / ((1 : β) - cβ»ΒΉ ^ 2) :=
geom_sum_Ico_le_of_lt_one (sq_nonneg _) C
_ β€ (cβ»ΒΉ ^ 2) ^ (Real.log j / Real.log c - 1) / ((1 : β) - cβ»ΒΉ ^ 2) := by
gcongr
Β· exact sub_nonneg.2 C.le
Β· rw [β Real.rpow_natCast]
exact Real.rpow_le_rpow_of_exponent_ge A C.le (Nat.sub_one_lt_floor _).le
_ = c ^ 2 * ((1 : β) - cβ»ΒΉ ^ 2)β»ΒΉ / j ^ 2 := by
have I : (cβ»ΒΉ ^ 2) ^ (Real.log j / Real.log c) = (1 : β) / j ^ 2 := by
apply Real.log_injOn_pos (Real.rpow_pos_of_pos A _)
Β· rw [Set.mem_Ioi]; positivity
rw [Real.log_rpow A]
simp only [one_div, Real.log_inv, Real.log_pow, mul_neg, neg_inj]
field [(Real.log_pos hc).ne']
rw [Real.rpow_sub A, I]
simp
ring
_ β€ c ^ 3 * (c - 1)β»ΒΉ / j ^ 2 := by gcongr
theorem mul_pow_le_nat_floor_pow {c : β} (hc : 1 < c) (i : β) : (1 - cβ»ΒΉ) * c ^ i β€ βc ^ iββ := by
have cpos : 0 < c := zero_lt_one.trans hc
rcases eq_or_ne i 0 with (rfl | hi)
Β· simp only [pow_zero, Nat.floor_one, Nat.cast_one, mul_one, sub_le_self_iff, inv_nonneg, cpos.le]
calc
(1 - cβ»ΒΉ) * c ^ i = c ^ i - c ^ i * cβ»ΒΉ := by ring
_ β€ c ^ i - 1 := by
gcongr
simpa only [β div_eq_mul_inv, one_le_div cpos, pow_one] using le_self_powβ hc.le hi
_ β€ βc ^ iββ := (Nat.sub_one_lt_floor _).le
/-- The sum of `1/βc^iββ^2` above a threshold `j` is comparable to `1/j^2`, up to a multiplicative
constant. -/
theorem sum_div_nat_floor_pow_sq_le_div_sq (N : β) {j : β} (hj : 0 < j) {c : β} (hc : 1 < c) :
(β i β range N with j < βc ^ iββ, (1 : β) / (βc ^ iββ : β) ^ 2) β€
c ^ 5 * (c - 1)β»ΒΉ ^ 3 / j ^ 2 := by
have cpos : 0 < c := zero_lt_one.trans hc
have A : 0 < 1 - cβ»ΒΉ := sub_pos.2 (inv_lt_one_of_one_ltβ hc)
calc
(β i β range N with j < βc ^ iββ, (1 : β) / (βc ^ iββ : β) ^ 2) β€
β i β range N with j < c ^ i, (1 : β) / (βc ^ iββ : β) ^ 2 := by
gcongr with k hk; exact Nat.floor_le (by positivity)
_ β€ β i β range N with j < c ^ i, (1 - cβ»ΒΉ)β»ΒΉ ^ 2 * ((1 : β) / (c ^ i) ^ 2) := by
gcongr with i
rw [mul_div_assoc', mul_one, div_le_div_iffβ]; rotate_left
Β· apply sq_pos_of_pos
refine zero_lt_one.trans_le ?_
simp only [Nat.le_floor, one_le_powβ, hc.le, Nat.one_le_cast, Nat.cast_one]
Β· exact sq_pos_of_pos (pow_pos cpos _)
rw [one_mul, β mul_pow]
gcongr
rw [β div_eq_inv_mul, le_div_iffβ A, mul_comm]
exact mul_pow_le_nat_floor_pow hc i
_ β€ (1 - cβ»ΒΉ)β»ΒΉ ^ 2 * (c ^ 3 * (c - 1)β»ΒΉ) / j ^ 2 := by
rw [β mul_sum, β mul_div_assoc']
gcongr
exact sum_div_pow_sq_le_div_sq N hj hc
_ = c ^ 5 * (c - 1)β»ΒΉ ^ 3 / j ^ 2 := by
congr 1
field |
.lake/packages/mathlib/Mathlib/Analysis/AbsoluteValue/Equivalence.lean | import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Analysis.Normed.Field.WithAbs
/-!
# Equivalence of real-valued absolute values
Two absolute values `vβ, vβ : AbsoluteValue R β` are *equivalent* if there exists a
positive real number `c` such that `vβ x ^ c = vβ x` for all `x : R`.
-/
namespace AbsoluteValue
section OrderedSemiring
variable {R : Type*} [Semiring R] {S : Type*} [Semiring S] [PartialOrder S]
(v w : AbsoluteValue R S)
/-- Two absolute values `v` and `w` are *equivalent* if `v x β€ v y` precisely when
`w x β€ w y`.
Note that for real absolute values this condition is equivalent to the existence of a positive
real number `c` such that `v x ^ c = w x` for all `x`. See
`AbsoluteValue.isEquiv_iff_exists_rpow_eq`. -/
def IsEquiv : Prop := β x y, v x β€ v y β w x β€ w y
theorem IsEquiv.refl : v.IsEquiv v := fun _ _ β¦ .rfl
variable {v w}
theorem IsEquiv.rfl : v.IsEquiv v := fun _ _ β¦ .rfl
theorem IsEquiv.symm (h : v.IsEquiv w) : w.IsEquiv v := fun _ _ β¦ (h _ _).symm
theorem IsEquiv.trans {u : AbsoluteValue R S} (hβ : v.IsEquiv w)
(hβ : w.IsEquiv u) : v.IsEquiv u := fun _ _ β¦ (hβ _ _).trans (hβ _ _)
@[deprecated (since := "2025-09-12")] alias isEquiv_refl := IsEquiv.refl
@[deprecated (since := "2025-09-12")] alias isEquiv_symm := IsEquiv.symm
@[deprecated (since := "2025-09-12")] alias isEquiv_trans := IsEquiv.trans
instance : Setoid (AbsoluteValue R S) where
r := IsEquiv
iseqv := {
refl := .refl
symm := .symm
trans := .trans
}
theorem IsEquiv.le_iff_le (h : v.IsEquiv w) {x y : R} : v x β€ v y β w x β€ w y := h ..
theorem IsEquiv.lt_iff_lt (h : v.IsEquiv w) {x y : R} : v x < v y β w x < w y :=
lt_iff_lt_of_le_iff_le' (h y x) (h x y)
theorem IsEquiv.eq_iff_eq (h : v.IsEquiv w) {x y : R} : v x = v y β w x = w y := by
simp [le_antisymm_iff, h x y, h y x]
variable [IsDomain S] [Nontrivial R]
theorem IsEquiv.lt_one_iff (h : v.IsEquiv w) {x : R} :
v x < 1 β w x < 1 := by
simpa only [map_one] using h.lt_iff_lt (y := 1)
theorem IsEquiv.one_lt_iff (h : v.IsEquiv w) {x : R} :
1 < v x β 1 < w x := by
simpa only [map_one] using h.lt_iff_lt (x := 1)
theorem IsEquiv.le_one_iff (h : v.IsEquiv w) {x : R} :
v x β€ 1 β w x β€ 1 := by
simpa only [map_one] using h x 1
theorem IsEquiv.one_le_iff (h : v.IsEquiv w) {x : R} :
1 β€ v x β 1 β€ w x := by
simpa only [map_one] using h 1 x
theorem IsEquiv.eq_one_iff (h : v.IsEquiv w) {x : R} : v x = 1 β w x = 1 := by
simpa only [map_one] using h.eq_iff_eq (x := x) (y := 1)
theorem IsEquiv.isNontrivial_congr {w : AbsoluteValue R S} (h : v.IsEquiv w) :
v.IsNontrivial β w.IsNontrivial :=
not_iff_not.1 <| by aesop (add simp [not_isNontrivial_iff, h.eq_one_iff])
alias β¨IsEquiv.isNontrivial, _β© := IsEquiv.isNontrivial_congr
end OrderedSemiring
section LinearOrderedSemifield
variable {R S : Type*} [Field R] [Semifield S] [LinearOrder S] {v w : AbsoluteValue R S}
/-- An absolute value is equivalent to the trivial iff it is trivial itself. -/
@[simp]
lemma isEquiv_trivial_iff_eq_trivial [DecidablePred fun x : R β¦ x = 0] [NoZeroDivisors R]
[IsStrictOrderedRing S] {f : AbsoluteValue R S} :
f.IsEquiv .trivial β f = .trivial :=
β¨fun h β¦ by aesop (add simp [h.eq_one_iff, AbsoluteValue.trivial]), fun h β¦ h βΈ .rflβ©
@[deprecated (since := "2025-09-12")]
alias eq_trivial_of_isEquiv_trivial := isEquiv_trivial_iff_eq_trivial
variable [IsStrictOrderedRing S]
theorem isEquiv_iff_lt_one_iff :
v.IsEquiv w β β x, v x < 1 β w x < 1 := by
refine β¨fun h _ β¦ h.lt_one_iff, fun h x y β¦ ?_β©
rcases eq_or_ne (v x) 0 with (_ | hyβ) <;> simp_all
rw [le_iff_le_iff_lt_iff_lt, β one_mul (v x), β mul_inv_lt_iffβ (by simp_all), β one_mul (w x),
β mul_inv_lt_iffβ (by simp_all), β map_invβ, β map_mul, β map_invβ, β map_mul]
exact h _
variable [Archimedean S] [ExistsAddOfLE S]
theorem isEquiv_of_lt_one_imp (hv : v.IsNontrivial) (h : β x, v x < 1 β w x < 1) : v.IsEquiv w := by
refine isEquiv_iff_lt_one_iff.2 fun a β¦ ?_
rcases eq_or_ne a 0 with (rfl | haβ)
Β· simp
refine β¨h a, fun hw β¦ ?_β©
let β¨xβ, hxββ© := hv.exists_abv_lt_one
have hpow (n : β) (hv : 1 β€ v a) : w xβ < w a ^ n := by
rw [β one_mul (_ ^ _), β mul_inv_lt_iffβ (pow_pos (by simp_all) _),
β map_pow, β map_invβ, β map_mul]
apply h
rw [map_mul, map_invβ, map_pow, mul_inv_lt_iffβ (pow_pos (by simp [haβ]) _), one_mul]
exact lt_of_lt_of_le hxβ.2 <| one_le_powβ hv
obtain β¨n, hnβ© := exists_pow_lt_of_lt_one (w.pos hxβ.1) hw
exact not_le.1 <| mt (hpow n) <| not_lt.2 hn.le
/--
If `v` and `w` are inequivalent absolute values and `v` is non-trivial, then we can find an `a : R`
such that `v a < 1` while `1 β€ w a`.
-/
theorem exists_lt_one_one_le_of_not_isEquiv {v w : AbsoluteValue R S} (hv : v.IsNontrivial)
(h : Β¬v.IsEquiv w) : β a : R, v a < 1 β§ 1 β€ w a := by
contrapose! h
exact isEquiv_of_lt_one_imp hv h
/--
If `v` and `w` are two non-trivial and inequivalent absolute values then we can find an `a : R`
such that `1 < v a` while `w a < 1`.
-/
theorem exists_one_lt_lt_one_of_not_isEquiv {v w : AbsoluteValue R S} (hv : v.IsNontrivial)
(hw : w.IsNontrivial) (h : Β¬v.IsEquiv w) :
β a : R, 1 < v a β§ w a < 1 := by
let β¨a, hva, hwaβ© := exists_lt_one_one_le_of_not_isEquiv hv h
let β¨b, hwb, hvbβ© := exists_lt_one_one_le_of_not_isEquiv hw (mt .symm h)
exact β¨b / a, by simp [w.pos_iff.1 (lt_of_lt_of_le zero_lt_one hwa), one_lt_div, div_lt_one,
lt_of_le_of_lt' hvb hva, lt_of_le_of_lt' hwa hwb]β©
end LinearOrderedSemifield
section LinearOrderedField
open Filter
open scoped Topology
variable {R S : Type*} [Field R] [Field S] [LinearOrder S] {v w : AbsoluteValue R S}
[TopologicalSpace S] [IsStrictOrderedRing S] [Archimedean S] [OrderTopology S]
{ΞΉ : Type*} [Fintype ΞΉ] [DecidableEq ΞΉ] {v : ΞΉ β AbsoluteValue R S} {w : AbsoluteValue R S}
{a b : R} {i : ΞΉ}
/--
Suppose that
- `v i` and `w` are absolute values on a field `R`.
- `v i` is inequivalent to `v j` for all `j β i` via the divergent point `a : R`.
- `v i` is inequivalent to `w` via the divergent point `b : R`.
- `w a = 1`.
Then there is a common divergent point `k` causing both `v i` and `w` to be inequivalent to
each `v j` for `j β i`.
-/
private theorem exists_one_lt_lt_one_pi_of_eq_one (ha : 1 < v i a) (haj : β j β i, v j a < 1)
(haw : w a = 1) (hb : 1 < v i b) (hbw : w b < 1) :
β k : R, 1 < v i k β§ (β j β i, v j k < 1) β§ w k < 1 := by
let c : β β R := fun n β¦ a ^ n * b
have hcα΅’ : Tendsto (fun n β¦ (v i) (c n)) atTop atTop := by
simpa [c] using Tendsto.atTop_mul_const (by linarith) (tendsto_pow_atTop_atTop_of_one_lt ha)
have hcβ±Ό (j : ΞΉ) (hj : j β i) : Tendsto (fun n β¦ (v j) (c n)) atTop (π 0) := by
simpa [c] using (tendsto_pow_atTop_nhds_zero_of_lt_one ((v j).nonneg _) (haj j hj)).mul_const _
simp_rw [OrderTopology.topology_eq_generate_intervals,
TopologicalSpace.tendsto_nhds_generateFrom_iff, mem_atTop_sets, Set.mem_preimage] at hcβ±Ό
choose rβ hrβ using tendsto_atTop_atTop.1 hcα΅’ 2
choose rβ hrβ using fun j hj β¦ hcβ±Ό j hj (.Iio 1) (by simpa using β¨1, .inr rflβ©) (by simp)
let r := Finset.univ.sup fun j β¦ if h : j = i then rβ else rβ j h
refine β¨c r, lt_of_lt_of_le (by linarith) (hrβ r ?_), fun j hj β¦ ?_, by simpa [c, haw]β©
Β· exact Finset.le_sup_dite_pos (p := fun j β¦ j = i) (f := fun _ _ β¦ rβ) (Finset.mem_univ _) rfl
Β· simpa using hrβ j hj _ <| Finset.le_sup_dite_neg (fun j β¦ j = i) (Finset.mem_univ j) _
/--
Suppose that
- `v i` and `w` are absolute values on a field `R`.
- `v i` is inequivalent to `v j` for all `j β i` via the divergent point `a : R`.
- `v i` is inequivalent to `w` via the divergent point `b : R`.
- `1 < w a`.
Then there is a common divergent point `k : R` causing both `v i` and `w` to be inequivalent to
each `v j` for `j β i`.
-/
private theorem exists_one_lt_lt_one_pi_of_one_lt (ha : 1 < v i a) (haj : β j β i, v j a < 1)
(haw : 1 < w a) (hb : 1 < v i b) (hbw : w b < 1) :
β k : R, 1 < v i k β§ (β j β i, v j k < 1) β§ w k < 1 := by
let c : β β R := fun n β¦ 1 / (1 + aβ»ΒΉ ^ n) * b
have hcα΅’ : Tendsto (fun n β¦ v i (c n)) atTop (π (v i b)) := by
have : v i aβ»ΒΉ < 1 := map_invβ (v i) a βΈ inv_lt_one_of_one_ltβ ha
simpa [c] using (tendsto_div_one_add_pow_nhds_one this).mul_const (v i b)
have hcβ±Ό (j : ΞΉ) (hj : j β i) : atTop.Tendsto (fun n β¦ v j (c n)) (π 0) := by
have : 1 < v j aβ»ΒΉ := map_invβ (v j) _ βΈ
(one_lt_invβ <| (v j).pos fun h β¦ by linarith [map_zero (v _) βΈ h βΈ ha]).2 (haj j hj)
simpa [c] using (tendsto_div_one_add_pow_nhds_zero this).mul_const _
have hcβ : atTop.Tendsto (fun n β¦ w (c n)) (π (w b)) := by
have : w aβ»ΒΉ < 1 := map_invβ w _ βΈ inv_lt_one_of_one_ltβ haw
simpa [c] using (tendsto_div_one_add_pow_nhds_one this).mul_const (w b)
simp_rw [OrderTopology.topology_eq_generate_intervals,
TopologicalSpace.tendsto_nhds_generateFrom_iff, mem_atTop_sets, Set.mem_preimage] at hcβ±Ό
choose rβ hrβ using Filter.eventually_atTop.1 <| Filter.Tendsto.eventually_const_lt hb hcα΅’
choose rβ hrβ using fun j hj β¦ hcβ±Ό j hj (.Iio 1) (by simpa using β¨1, .inr rflβ©) (by simp)
choose rN hrN using Filter.eventually_atTop.1 <| Filter.Tendsto.eventually_lt_const hbw hcβ
let r := max (Finset.univ.sup fun j β¦ if h : j = i then rβ else rβ j h) rN
refine β¨c r, hrβ r ?_, fun j hj β¦ ?_, ?_β©
Β· exact le_max_iff.2 <| .inl <|
Finset.le_sup_dite_pos (p := fun j β¦ j = i) (f := fun _ _ β¦ rβ) (Finset.mem_univ _) rfl
Β· exact hrβ j hj _ <| le_max_iff.2 <| .inl <|
Finset.le_sup_dite_neg (fun j β¦ j = i) (Finset.mem_univ j) _
Β· exact hrN _ <| le_max_iff.2 (.inr le_rfl)
open Fintype Subtype in
/--
If `v : ΞΉ β AbsoluteValue R S` is a finite collection of non-trivial and pairwise inequivalent
absolute values, then for any `i` there is some `a : R` such that `1 < v i a` and
`v j a < 1` for all `j β i`.
-/
theorem exists_one_lt_lt_one_pi_of_not_isEquiv (h : β i, (v i).IsNontrivial)
(hv : Pairwise fun i j β¦ Β¬(v i).IsEquiv (v j)) :
β i, β (a : R), 1 < v i a β§ β j β i, v j a < 1 := by
let P (ΞΉ : Type _) [Fintype ΞΉ] : Prop := [DecidableEq ΞΉ] β
β v : ΞΉ β AbsoluteValue R S, (β i, (v i).IsNontrivial) β
(Pairwise fun i j β¦ Β¬(v i).IsEquiv (v j)) β β i, β (a : R), 1 < v i a β§ β j β i, v j a < 1
-- Use strong induction on the index.
revert hv h; refine induction_subsingleton_or_nontrivial (P := P) ΞΉ (fun ΞΉ _ _ _ v h hv i β¦ ?_)
(fun ΞΉ _ _ ih _ v h hv i β¦ ?_) v
Β· -- If `ΞΉ` is trivial this follows immediately from `(v i).IsNontrivial`.
let β¨a, haβ© := (h i).exists_abv_gt_one
exact β¨a, ha, fun j hij β¦ absurd (Subsingleton.elim i j) hij.symmβ©
Β· rcases eq_or_ne (card ΞΉ) 2 with (hc | hc)
Β· -- If `ΞΉ` has two elements this is `exists_one_lt_lt_one_of_not_isEquiv`.
let β¨j, hjβ© := (Nat.card_eq_two_iff' i).1 <| card_eq_nat_card βΈ hc
let β¨a, haβ© := (v i).exists_one_lt_lt_one_of_not_isEquiv (h i) (h j) (hv hj.1.symm)
exact β¨a, ha.1, fun _ h β¦ hj.2 _ h βΈ ha.2β©
have hlt : 2 < card ΞΉ := Nat.lt_of_le_of_ne (one_lt_card_iff_nontrivial.2 βΉ_βΊ) hc.symm
-- Otherwise, choose another distinguished index `j β i`.
let β¨j, hjβ© := exists_ne i
-- Apply induction first on the subcollection `v i` for `i β j` to get `a : K`
let β¨a, haβ© := ih {k : ΞΉ // k β j} (card_subtype_lt fun a β¦ a rfl) (restrict _ v)
(fun i β¦ h _) (hv.comp_of_injective val_injective) β¨i, hj.symmβ©
-- Then apply induction next to the subcollection `{v i, v j}` to get `b : K`.
let β¨b, hbβ© := ih {k : ΞΉ // k = i β¨ k = j} (by linarith [card_subtype_eq_or_eq_of_ne hj.symm])
(restrict _ v) (fun _ β¦ h _) (hv.comp_of_injective val_injective) β¨i, .inl rflβ©
rcases eq_or_ne (v j a) 1 with (haβ | haβ)
Β· -- If `v j a = 1` then take a large enough value from the sequence `a ^ n * b`.
let β¨c, hcβ© := exists_one_lt_lt_one_pi_of_eq_one ha.1 ha.2 haβ hb.1 (hb.2 β¨j, .inr rflβ©
(by grind))
refine β¨c, hc.1, fun k hk β¦ ?_β©
rcases eq_or_ne k j with (rfl | h); try exact hc.2.2; exact hc.2.1 β¨k, hβ© (by grind)
rcases haβ.lt_or_gt with (ha_lt | ha_gt)
Β· -- If `v j a < 1` then `a` works as the divergent point.
refine β¨a, ha.1, fun k hk β¦ ?_β©
rcases eq_or_ne k j with (rfl | h); try exact ha_lt; exact ha.2 β¨k, hβ© (by grind)
Β· -- If `1 < v j a` then take a large enough value from the sequence `b / (1 + a ^ (-n))`.
let β¨c, hcβ© := exists_one_lt_lt_one_pi_of_one_lt ha.1 ha.2 ha_gt hb.1 (hb.2 β¨j, .inr rflβ©
(by grind))
refine β¨c, hc.1, fun k hk β¦ ?_β©
rcases eq_or_ne k j with (rfl | h); try exact hc.2.2; exact hc.2.1 β¨k, hβ© (by grind)
end LinearOrderedField
section Real
open Real Topology
variable {F : Type*} [Field F] {v w : AbsoluteValue F β}
theorem IsEquiv.log_div_log_pos (h : v.IsEquiv w) {a : F} (haβ : a β 0) (haβ : w a β 1) :
0 < (w a).log / (v a).log := by
rcases haβ.lt_or_gt with hwa | hwa
Β· simpa using div_pos (neg_pos_of_neg <| log_neg (w.pos haβ) (hwa))
(neg_pos_of_neg <| log_neg (v.pos haβ) (h.lt_one_iff.2 hwa))
Β· exact div_pos (log_pos <| hwa) (log_pos (h.one_lt_iff.2 hwa))
/--
If $v$ and $w$ are two real absolute values on a field $F$, equivalent in the sense that
$v(x) \leq v(y)$ if and only if $w(x) \leq w(y)$, then $\frac{\log (v(a))}{\log (w(a))}$ is
constant for all $0 \neq a\in F$ with $v(a) \neq 1$.
-/
theorem IsEquiv.log_div_log_eq_log_div_log (h : v.IsEquiv w)
{a : F} (haβ : a β 0) (haβ : v a β 1) {b : F} (hbβ : b β 0) (hbβ : v b β 1) :
(v b).log / (w b).log = (v a).log / (w a).log := by
by_contra! h_ne
wlog ha : 1 < v a generalizing a b
Β· apply this (inv_ne_zero haβ) (by simpa) hbβ hbβ (by simpa)
simpa using one_lt_inv_iffβ.2 β¨v.pos haβ, haβ.lt_of_le (not_lt.1 ha)β©
wlog hb : 1 < v b generalizing a b
Β· apply this haβ haβ (inv_ne_zero hbβ) (by simpa) (by simpa) ha
simpa using one_lt_inv_iffβ.2 β¨v.pos hbβ, hbβ.lt_of_le (not_lt.1 hb)β©
wlog h_lt : (v b).log / (w b).log < (v a).log / (w a).log generalizing a b
Β· exact this hbβ hbβ haβ haβ h_ne.symm hb ha <| lt_of_le_of_ne (not_lt.1 h_lt) h_ne.symm
have hwa := h.one_lt_iff.1 ha
have hwb := h.one_lt_iff.1 hb
rw [div_lt_div_iffβ (log_pos hwb) (log_pos hwa), mul_comm (v a).log,
β div_lt_div_iffβ (log_pos ha) (log_pos hwa)] at h_lt
let β¨q, β¨hqβ, hqββ©β© := exists_rat_btwn h_lt
rw [β Rat.num_div_den q, Rat.cast_div, Rat.cast_intCast, Rat.cast_natCast] at hqβ hqβ
rw [div_lt_div_iffβ (log_pos ha) (by simp [q.den_pos]), mul_comm, β log_pow, β log_zpow,
log_lt_log_iff (pow_pos (by linarith) _) (zpow_pos (by linarith) _),
β div_lt_one (zpow_pos (by linarith) _), β map_pow, β map_zpowβ, β map_divβ] at hqβ
rw [div_lt_div_iffβ (by simp [q.den_pos]) (log_pos hwa), mul_comm (w _).log,
β log_pow, β log_zpow, log_lt_log_iff (zpow_pos (by linarith) _) (pow_pos (by linarith) _),
β one_lt_div (zpow_pos (by linarith) _), β map_pow, β map_zpowβ, β map_divβ] at hqβ
exact not_lt_of_gt (h.lt_one_iff.1 hqβ) hqβ
/--
If `v` and `w` are two real absolute values on a field `F`, then `v` and `w` are equivalent if
and only if there exists a positive real constant `c` such that for all `x : R`, `(f x)^c = g x`.
-/
theorem isEquiv_iff_exists_rpow_eq {v w : AbsoluteValue F β} :
v.IsEquiv w β β c : β, 0 < c β§ (v Β· ^ c) = w := by
refine β¨fun h β¦ ?_, fun β¨t, ht, hβ© β¦ isEquiv_iff_lt_one_iff.2
fun x β¦ h βΈ (rpow_lt_one_iff' (v.nonneg x) ht).symmβ©
by_cases hw : w.IsNontrivial
Β· let β¨a, haβ, haββ© := hw
refine β¨(w a).log / (v a).log, h.log_div_log_pos haβ haβ, funext fun b β¦ ?_β©
rcases eq_or_ne b 0 with rfl | hbβ; Β· simp [zero_rpow (by linarith [h.log_div_log_pos haβ haβ])]
rcases eq_or_ne (w b) 1 with hbβ | hbβ; Β· simp [hbβ, h.eq_one_iff.2 hbβ]
rw [β h.symm.log_div_log_eq_log_div_log haβ haβ hbβ hbβ, div_eq_inv_mul, rpow_mul (v.nonneg _),
rpow_inv_log (v.pos hbβ) (h.eq_one_iff.not.2 hbβ), exp_one_rpow, exp_log (w.pos hbβ)]
Β· exact β¨1, zero_lt_one, funext fun x β¦ by rcases eq_or_ne x 0 with rfl | hβ <;>
aesop (add simp [h.isNontrivial_congr])β©
theorem IsEquiv.equivWithAbs_image_mem_nhds_zero (h : v.IsEquiv w) {U : Set (WithAbs v)}
(hU : U β π 0) : WithAbs.equivWithAbs v w '' U β π 0 := by
rw [Metric.mem_nhds_iff] at hU β’
obtain β¨Ξ΅, hΞ΅, hUβ© := hU
obtain β¨c, hc, hvwβ© := isEquiv_iff_exists_rpow_eq.1 h
refine β¨Ξ΅ ^ c, rpow_pos_of_pos hΞ΅ _, fun x hx β¦ ?_β©
rw [β RingEquiv.apply_symm_apply (WithAbs.equivWithAbs v w) x]
refine Set.mem_image_of_mem _ (hU ?_)
rw [Metric.mem_ball, dist_zero_right, WithAbs.norm_eq_abv, β funext_iff.1 hvw,
rpow_lt_rpow_iff (v.nonneg _) hΞ΅.le hc] at hx
simpa [WithAbs.norm_eq_abv]
open Topology IsTopologicalAddGroup in
theorem IsEquiv.isEmbedding_equivWithAbs (h : v.IsEquiv w) :
IsEmbedding (WithAbs.equivWithAbs v w) := by
refine IsInducing.isEmbedding <| isInducing_iff_nhds_zero.2 <| Filter.ext fun U β¦
β¨fun hU β¦ ?_, fun hU β¦ ?_β©
Β· exact β¨WithAbs.equivWithAbs v w '' U, h.equivWithAbs_image_mem_nhds_zero hU,
by simp [RingEquiv.image_eq_preimage_symm, Set.preimage_preimage]β©
Β· rw [β RingEquiv.coe_toEquiv, β Filter.map_equiv_symm] at hU
obtain β¨s, hs, hssβ© := Filter.mem_map_iff_exists_image.1 hU
rw [β RingEquiv.coe_toEquiv_symm, WithAbs.equivWithAbs_symm] at hss
exact Filter.mem_of_superset (h.symm.equivWithAbs_image_mem_nhds_zero hs) hss
theorem isEquiv_iff_isHomeomorph (v w : AbsoluteValue F β) :
v.IsEquiv w β IsHomeomorph (WithAbs.equivWithAbs v w) := by
rw [isHomeomorph_iff_isEmbedding_surjective]
refine β¨fun h β¦ β¨h.isEmbedding_equivWithAbs, RingEquiv.surjective _β©, fun β¨hi, _β© β¦ ?_β©
refine isEquiv_iff_lt_one_iff.2 fun x β¦ ?_
conv_lhs => rw [β (WithAbs.equiv v).apply_symm_apply x]
conv_rhs => rw [β (WithAbs.equiv w).apply_symm_apply x]
simp_rw [β WithAbs.norm_eq_abv, β tendsto_pow_atTop_nhds_zero_iff_norm_lt_one]
exact β¨fun h β¦ by simpa [Function.comp_def] using (hi.continuous.tendsto 0).comp h, fun h β¦ by
simpa [Function.comp_def] using (hi.continuous_iff (f := (WithAbs.equivWithAbs v w).symm)).2
continuous_id |>.tendsto 0 |>.comp h β©
end Real
end AbsoluteValue |
.lake/packages/mathlib/Mathlib/Analysis/ODE/PicardLindelof.lean | import Mathlib.Analysis.SpecialFunctions.Integrals.Basic
import Mathlib.Topology.Algebra.Order.Floor
import Mathlib.Topology.MetricSpace.Contracting
/-!
# Picard-LindelΓΆf (Cauchy-Lipschitz) Theorem
We prove the (local) existence of integral curves and flows to time-dependent vector fields.
Let `f : β β E β E` be a time-dependent (local) vector field on a Banach space, and let `tβ : β`
and `xβ : E`. If `f` is Lipschitz continuous in `x` within a closed ball around `xβ` of radius
`a β₯ 0` at every `t` and continuous in `t` at every `x`, then there exists a (local) solution
`Ξ± : β β E` to the initial value problem `Ξ± tβ = xβ` and `deriv Ξ± t = f t (Ξ± t)` for all
`t β Icc tmin tmax`, where `L * max (tmax - tβ) (tβ - tmin) β€ a`.
We actually prove a more general version of this theorem for the existence of local flows. If there
is some `r β₯ 0` such that `L * max (tmax - tβ) (tβ - tmin) β€ a - r`, then for every
`x β closedBall xβ r`, there exists a (local) solution `Ξ± x` with the initial condition `Ξ± tβ = x`.
In other words, there exists a local flow `Ξ± : E β β β E` defined on `closedBall xβ r` and
`Icc tmin tmax`.
The proof relies on demonstrating the existence of a solution `Ξ±` to the following integral
equation:
$$\alpha(t) = x_0 + \int_{t_0}^t f(\tau, \alpha(\tau))\,\mathrm{d}\tau.$$
This is done via the contraction mapping theorem, applied to the space of Lipschitz continuous
functions from a closed interval to a Banach space. The needed contraction map is constructed by
repeated applications of the right-hand side of this equation.
## Main definitions and results
* `picard f tβ xβ Ξ± t`: the Picard iteration, applied to the curve `Ξ±`
* `IsPicardLindelof`: the structure holding the assumptions of the Picard-LindelΓΆf theorem
* `IsPicardLindelof.exists_eq_forall_mem_Icc_hasDerivWithinAt`: the existence theorem for local
solutions to time-dependent ODEs
* `IsPicardLindelof.exists_forall_mem_closedBall_eq_forall_mem_Icc_hasDerivWithinAt`: the existence
theorem for local flows to time-dependent vector fields
* `IsPicardLindelof.exists_forall_mem_closedBall_eq_hasDerivWithinAt_lipschitzOnWith`: there exists
a local flow to time-dependent vector fields, and it is Lipschitz-continuous with respect to the
starting point.
## Implementation notes
* The structure `FunSpace` and theorems within this namespace are implementation details of the
proof of the Picard-LindelΓΆf theorem and are not intended to be used outside of this file.
* Some sources, such as Lang, define `FunSpace` as the space of continuous functions from a closed
interval to a closed ball. We instead define `FunSpace` here as the space of Lipschitz continuous
functions from a closed interval. This slightly stronger condition allows us to postpone the usage
of the completeness condition on the space `E` until the application of the contraction mapping
theorem.
* We have chosen to formalise many of the real constants as `ββ₯0`, so that the non-negativity of
certain quantities constructed from them can be shown more easily. When subtraction is involved,
especially note whether it is the usual subtraction between two reals or the truncated subtraction
between two non-negative reals.
* In this file, We only prove the existence of a solution. For uniqueness, see `ODE_solution_unique`
and related theorems in `Mathlib/Analysis/ODE/Gronwall.lean`.
## Tags
differential equation, dynamical system, initial value problem, Picard-LindelΓΆf theorem,
Cauchy-Lipschitz theorem
-/
open Function intervalIntegral MeasureTheory Metric Set
open scoped Nat NNReal Topology
/-! ## Assumptions of the Picard-LindelΓΆf theorem-/
/-- Prop structure holding the assumptions of the Picard-LindelΓΆf theorem.
`IsPicardLindelof f tβ xβ a r L K`, where `tβ β Icc tmin tmax`, means that the time-dependent vector
field `f` satisfies the conditions to admit an integral curve `Ξ± : β β E` to `f` defined on
`Icc tmin tmax` with the initial condition `Ξ± tβ = x`, where `βx - xββ β€ r`. Note that the initial
point `x` is allowed to differ from the point `xβ` about which the conditions on `f` are stated. -/
structure IsPicardLindelof {E : Type*} [NormedAddCommGroup E]
(f : β β E β E) {tmin tmax : β} (tβ : Icc tmin tmax) (xβ : E) (a r L K : ββ₯0) : Prop where
/-- The vector field at any time is Lipschitz with constant `K` within a closed ball. -/
lipschitzOnWith : β t β Icc tmin tmax, LipschitzOnWith K (f t) (closedBall xβ a)
/-- The vector field is continuous in time within a closed ball. -/
continuousOn : β x β closedBall xβ a, ContinuousOn (f Β· x) (Icc tmin tmax)
/-- `L` is an upper bound of the norm of the vector field. -/
norm_le : β t β Icc tmin tmax, β x β closedBall xβ a, βf t xβ β€ L
/-- The time interval of validity -/
mul_max_le : L * max (tmax - tβ) (tβ - tmin) β€ a - r
namespace ODE
/-! ## Integral equation
For any time-dependent vector field `f : β β E β E`, we define an integral equation that is
equivalent to the initial value problem defined by `f`.
-/
section
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
{f : β β E β E} {Ξ± : β β E} {s : Set β} {u : Set E} {tβ tmin tmax : β}
/-- The Picard iteration. It will be shown that if `Ξ± : β β E` and `picard f tβ xβ Ξ±` agree on an
interval containing `tβ`, then `Ξ±` is a solution to `f` with `Ξ± tβ = xβ` on this interval. -/
noncomputable def picard (f : β β E β E) (tβ : β) (xβ : E) (Ξ± : β β E) : β β E :=
fun t β¦ xβ + β« Ο in tβ..t, f Ο (Ξ± Ο)
@[simp]
lemma picard_apply {xβ : E} {t : β} : picard f tβ xβ Ξ± t = xβ + β« Ο in tβ..t, f Ο (Ξ± Ο) := rfl
lemma picard_applyβ {xβ : E} : picard f tβ xβ Ξ± tβ = xβ := by simp
/-- Given a $C^n$ time-dependent vector field `f` and a $C^n$ curve `Ξ±`, the composition `f t (Ξ± t)`
is $C^n$ in `t`. -/
lemma contDiffOn_comp {n : WithTop ββ}
(hf : ContDiffOn β n (uncurry f) (s ΓΛ’ u))
(hΞ± : ContDiffOn β n Ξ± s) (hmem : β t β s, Ξ± t β u) :
ContDiffOn β n (fun t β¦ f t (Ξ± t)) s := by
have : (fun t β¦ f t (Ξ± t)) = (uncurry f) β fun t β¦ (t, Ξ± t) := rfl
rw [this]
apply hf.comp (by fun_prop)
intro _ ht
rw [mem_prod]
exact β¨ht, hmem _ htβ©
/-- Given a continuous time-dependent vector field `f` and a continuous curve `Ξ±`, the composition
`f t (Ξ± t)` is continuous in `t`. -/
lemma continuousOn_comp
(hf : ContinuousOn (uncurry f) (s ΓΛ’ u)) (hΞ± : ContinuousOn Ξ± s) (hmem : MapsTo Ξ± s u) :
ContinuousOn (fun t β¦ f t (Ξ± t)) s :=
contDiffOn_zero.mp <| (contDiffOn_comp (contDiffOn_zero.mpr hf) (contDiffOn_zero.mpr hΞ±) hmem)
end
/-! ## Space of Lipschitz functions on a closed interval
We define the space of Lipschitz continuous functions from a closed interval. This will be shown to
be a complete metric space on which `picard` is a contracting map, leading to a fixed point that
will serve as the solution to the ODE. The domain is a closed interval in order to easily inherit
the sup metric from continuous maps on compact spaces. We cannot use functions `β β E` with junk
values outside the domain, as the supremum within a closed interval will only be a pseudo-metric,
and the contracting map will fail to have a fixed point. In order to accommodate flows, we do not
require a specific initial condition. Rather, `FunSpace` contains curves whose initial condition is
within a closed ball.
-/
/-- The space of `L`-Lipschitz functions `Ξ± : Icc tmin tmax β E` -/
structure FunSpace {E : Type*} [NormedAddCommGroup E]
{tmin tmax : β} (tβ : Icc tmin tmax) (xβ : E) (r L : ββ₯0) where
/-- The domain is `Icc tmin tmax`. -/
toFun : Icc tmin tmax β E
lipschitzWith : LipschitzWith L toFun
mem_closedBallβ : toFun tβ β closedBall xβ r
namespace FunSpace
variable {E : Type*} [NormedAddCommGroup E]
section
variable {tmin tmax : β} {tβ : Icc tmin tmax} {xβ : E} {a r L : ββ₯0}
instance : CoeFun (FunSpace tβ xβ r L) fun _ β¦ Icc tmin tmax β E := β¨fun Ξ± β¦ Ξ±.toFunβ©
/-- `FunSpace tβ xβ r L` contains the constant map at `xβ`. -/
instance : Inhabited (FunSpace tβ xβ r L) :=
β¨fun _ β¦ xβ, (LipschitzWith.const _).weaken (zero_le _), mem_closedBall_self r.2β©
protected lemma continuous (Ξ± : FunSpace tβ xβ L r) : Continuous Ξ± := Ξ±.lipschitzWith.continuous
/-- The embedding of `FunSpace` into the space of continuous maps -/
def toContinuousMap : FunSpace tβ xβ r L βͺ C(Icc tmin tmax, E) :=
β¨fun Ξ± β¦ β¨Ξ±, Ξ±.continuousβ©, fun Ξ± Ξ² h β¦ by cases Ξ±; cases Ξ²; simpa using hβ©
@[simp]
lemma toContinuousMap_apply_eq_apply (Ξ± : FunSpace tβ xβ r L) (t : Icc tmin tmax) :
Ξ±.toContinuousMap t = Ξ± t := rfl
/-- The metric between two curves `Ξ±` and `Ξ²` is the supremum of the metric between `Ξ± t` and `Ξ² t`
over all `t` in the domain. This is finite when the domain is compact, such as a closed
interval in our case. -/
noncomputable instance : MetricSpace (FunSpace tβ xβ r L) :=
MetricSpace.induced toContinuousMap toContinuousMap.injective inferInstance
lemma isUniformInducing_toContinuousMap :
IsUniformInducing fun Ξ± : FunSpace tβ xβ r L β¦ Ξ±.toContinuousMap := β¨rflβ©
lemma range_toContinuousMap :
range (fun Ξ± : FunSpace tβ xβ r L β¦ Ξ±.toContinuousMap) =
{ Ξ± : C(Icc tmin tmax, E) | LipschitzWith L Ξ± β§ Ξ± tβ β closedBall xβ r } := by
ext Ξ±
constructor
Β· rintro β¨β¨Ξ±, hΞ±1, hΞ±2β©, rflβ©
exact β¨hΞ±1, hΞ±2β©
Β· rintro β¨hΞ±1, hΞ±2β©
exact β¨β¨Ξ±, hΞ±1, hΞ±2β©, rflβ©
/-- We show that `FunSpace` is complete in order to apply the contraction mapping theorem. -/
instance [CompleteSpace E] : CompleteSpace (FunSpace tβ xβ r L) := by
rw [completeSpace_iff_isComplete_range isUniformInducing_toContinuousMap]
apply IsClosed.isComplete
rw [range_toContinuousMap, setOf_and]
apply isClosed_setOf_lipschitzWith L |>.preimage continuous_coeFun |>.inter
simp_rw [mem_closedBall_iff_norm]
exact isClosed_le (by fun_prop) continuous_const
/-- Extend the domain of `Ξ±` from `Icc tmin tmax` to `β` such that `Ξ± t = Ξ± tmin` for all `t β€ tmin`
and `Ξ± t = Ξ± tmax` for all `t β₯ tmax`. -/
noncomputable def compProj (Ξ± : FunSpace tβ xβ r L) (t : β) : E :=
Ξ± <| projIcc tmin tmax (le_trans tβ.2.1 tβ.2.2) t
@[simp]
lemma compProj_apply {Ξ± : FunSpace tβ xβ r L} {t : β} :
Ξ±.compProj t = Ξ± (projIcc tmin tmax (le_trans tβ.2.1 tβ.2.2) t) := rfl
lemma compProj_val {Ξ± : FunSpace tβ xβ r L} {t : Icc tmin tmax} :
Ξ±.compProj t = Ξ± t := by simp only [compProj_apply, projIcc_val]
lemma compProj_of_mem {Ξ± : FunSpace tβ xβ r L} {t : β} (ht : t β Icc tmin tmax) :
Ξ±.compProj t = Ξ± β¨t, htβ© := by rw [compProj_apply, projIcc_of_mem]
@[continuity, fun_prop]
lemma continuous_compProj (Ξ± : FunSpace tβ xβ r L) : Continuous Ξ±.compProj :=
Ξ±.continuous.comp continuous_projIcc
/-- The image of a function in `FunSpace` is contained within a closed ball. -/
protected lemma mem_closedBall
{Ξ± : FunSpace tβ xβ r L} (h : L * max (tmax - tβ) (tβ - tmin) β€ a - r) {t : Icc tmin tmax} :
Ξ± t β closedBall xβ a := by
rw [mem_closedBall, dist_eq_norm]
calc
βΞ± t - xββ β€ βΞ± t - Ξ± tββ + βΞ± tβ - xββ := norm_sub_le_norm_sub_add_norm_sub ..
_ β€ L * |t.1 - tβ.1| + r := by
apply add_le_add _ <| mem_closedBall_iff_norm.mp Ξ±.mem_closedBallβ
rw [β dist_eq_norm]
exact Ξ±.lipschitzWith.dist_le_mul t tβ
_ β€ L * max (tmax - tβ) (tβ - tmin) + r := by
gcongr
exact abs_sub_le_max_sub t.2.1 t.2.2 _
_ β€ a - r + r := by gcongr
_ = a := sub_add_cancel _ _
lemma compProj_mem_closedBall
(Ξ± : FunSpace tβ xβ r L) (h : L * max (tmax - tβ) (tβ - tmin) β€ a - r) {t : β} :
Ξ±.compProj t β closedBall xβ a := by
rw [compProj_apply]
exact Ξ±.mem_closedBall h
end
/-! ## Contracting map on the space of Lipschitz functions -/
section
variable [NormedSpace β E]
{f : β β E β E} {tmin tmax : β} {tβ : Icc tmin tmax} {xβ x y : E} {a r L K : ββ₯0}
/-- The integrand in `next` is continuous. -/
lemma continuousOn_comp_compProj (hf : IsPicardLindelof f tβ xβ a r L K) (Ξ± : FunSpace tβ xβ r L) :
ContinuousOn (fun t' β¦ f t' (Ξ±.compProj t')) (Icc tmin tmax) :=
continuousOn_comp
(continuousOn_prod_of_continuousOn_lipschitzOnWith' (uncurry f) K hf.lipschitzOnWith
hf.continuousOn)
Ξ±.continuous_compProj.continuousOn
fun _ _ β¦ Ξ±.mem_closedBall hf.mul_max_le
/-- The integrand in `next` is integrable. -/
lemma intervalIntegrable_comp_compProj (hf : IsPicardLindelof f tβ xβ a r L K)
(Ξ± : FunSpace tβ xβ r L) (t : Icc tmin tmax) :
IntervalIntegrable (fun t' β¦ f t' (Ξ±.compProj t')) volume tβ t := by
apply ContinuousOn.intervalIntegrable
apply Ξ±.continuousOn_comp_compProj hf |>.mono
exact uIcc_subset_Icc tβ.2 t.2
/-- The map on `FunSpace` defined by `picard`, some `n`-th iterate of which will be a contracting
map -/
noncomputable def next (hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r)
(Ξ± : FunSpace tβ xβ r L) : FunSpace tβ xβ r L where
toFun t := picard f tβ x Ξ±.compProj t
lipschitzWith := LipschitzWith.of_dist_le_mul fun tβ tβ β¦ by
rw [dist_eq_norm, picard_apply, picard_apply, add_sub_add_left_eq_sub,
integral_interval_sub_left (intervalIntegrable_comp_compProj hf _ tβ)
(intervalIntegrable_comp_compProj hf _ tβ), Subtype.dist_eq, Real.dist_eq]
apply intervalIntegral.norm_integral_le_of_norm_le_const
intro t ht
-- Can `grind` do this in the future?
have ht : t β Icc tmin tmax := subset_trans uIoc_subset_uIcc (uIcc_subset_Icc tβ.2 tβ.2) ht
exact hf.norm_le _ ht _ <| Ξ±.mem_closedBall hf.mul_max_le
mem_closedBallβ := by simp [hx]
@[simp]
lemma next_apply (hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r)
(Ξ± : FunSpace tβ xβ r L) {t : Icc tmin tmax} :
next hf hx Ξ± t = picard f tβ x Ξ±.compProj t := rfl
lemma next_applyβ (hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r)
(Ξ± : FunSpace tβ xβ r L) : next hf hx Ξ± tβ = x := by simp
/-- A key step in the inductive case of `dist_iterate_next_apply_le` -/
lemma dist_comp_iterate_next_le (hf : IsPicardLindelof f tβ xβ a r L K)
(hx : x β closedBall xβ r) (n : β) (t : Icc tmin tmax)
{Ξ± Ξ² : FunSpace tβ xβ r L}
(h : dist ((next hf hx)^[n] Ξ± t) ((next hf hx)^[n] Ξ² t) β€
(K * |t - tβ.1|) ^ n / n ! * dist Ξ± Ξ²) :
dist (f t ((next hf hx)^[n] Ξ± t)) (f t ((next hf hx)^[n] Ξ² t)) β€
K ^ (n + 1) * |t - tβ.1| ^ n / n ! * dist Ξ± Ξ² :=
calc
_ β€ K * dist ((next hf hx)^[n] Ξ± t) ((next hf hx)^[n] Ξ² t) :=
hf.lipschitzOnWith t.1 t.2 |>.dist_le_mul
_ (FunSpace.mem_closedBall hf.mul_max_le) _ (FunSpace.mem_closedBall hf.mul_max_le)
_ β€ K ^ (n + 1) * |t - tβ.1| ^ n / n ! * dist Ξ± Ξ² := by
rw [pow_succ', mul_assoc, mul_div_assoc, mul_assoc]
gcongr
rwa [β mul_pow]
/-- A time-dependent bound on the distance between the `n`-th iterates of `next` on two curves -/
lemma dist_iterate_next_apply_le (hf : IsPicardLindelof f tβ xβ a r L K)
(hx : x β closedBall xβ r) (Ξ± Ξ² : FunSpace tβ xβ r L) (n : β) (t : Icc tmin tmax) :
dist ((next hf hx)^[n] Ξ± t) ((next hf hx)^[n] Ξ² t) β€
(K * |t.1 - tβ.1|) ^ n / n ! * dist Ξ± Ξ² := by
induction n generalizing t with
| zero => simpa using
ContinuousMap.dist_apply_le_dist (f := toContinuousMap Ξ±) (g := toContinuousMap Ξ²) _
| succ n hn =>
rw [iterate_succ_apply', iterate_succ_apply', dist_eq_norm, next_apply,
next_apply, picard_apply, picard_apply, add_sub_add_left_eq_sub,
β intervalIntegral.integral_sub (intervalIntegrable_comp_compProj hf _ t)
(intervalIntegrable_comp_compProj hf _ t)]
calc
_ β€ β« Ο in uIoc tβ.1 t.1, K ^ (n + 1) * |Ο - tβ| ^ n / n ! * dist Ξ± Ξ² := by
rw [intervalIntegral.norm_intervalIntegral_eq]
apply MeasureTheory.norm_integral_le_of_norm_le (Continuous.integrableOn_uIoc (by fun_prop))
apply ae_restrict_mem measurableSet_Ioc |>.mono
intro t' ht'
-- Can `grind` do this in the future?
have ht' : t' β Icc tmin tmax :=
subset_trans uIoc_subset_uIcc (uIcc_subset_Icc tβ.2 t.2) ht'
rw [β dist_eq_norm, compProj_of_mem, compProj_of_mem]
exact dist_comp_iterate_next_le hf hx _ β¨t', ht'β© (hn _)
_ β€ (K * |t.1 - tβ.1|) ^ (n + 1) / (n + 1) ! * dist Ξ± Ξ² := by
apply le_of_abs_le
-- critical: `integral_pow_abs_sub_uIoc`
rw [β intervalIntegral.abs_intervalIntegral_eq, intervalIntegral.integral_mul_const,
intervalIntegral.integral_div, intervalIntegral.integral_const_mul, abs_mul, abs_div,
abs_mul, intervalIntegral.abs_intervalIntegral_eq, integral_pow_abs_sub_uIoc, abs_div,
abs_pow, abs_pow, abs_dist, NNReal.abs_eq, abs_abs, mul_div, div_div, β abs_mul,
β Nat.cast_succ, β Nat.cast_mul, β Nat.factorial_succ, Nat.abs_cast, β mul_pow]
/-- The `n`-th iterate of `next` is Lipschitz continuous with respect to `FunSpace`, with constant
$(K \max(t_{\mathrm{max}}, t_{\mathrm{min}})^n / n!$. -/
lemma dist_iterate_next_iterate_next_le (hf : IsPicardLindelof f tβ xβ a r L K)
(hx : x β closedBall xβ r) (Ξ± Ξ² : FunSpace tβ xβ r L) (n : β) :
dist ((next hf hx)^[n] Ξ±) ((next hf hx)^[n] Ξ²) β€
(K * max (tmax - tβ) (tβ - tmin)) ^ n / n ! * dist Ξ± Ξ² := by
rw [β MetricSpace.isometry_induced FunSpace.toContinuousMap FunSpace.toContinuousMap.injective
|>.dist_eq, ContinuousMap.dist_le]
Β· intro t
apply le_trans <| dist_iterate_next_apply_le hf hx Ξ± Ξ² n t
gcongr
exact abs_sub_le_max_sub t.2.1 t.2.2 _
Β· have : 0 β€ max (tmax - tβ) (tβ - tmin) := le_max_of_le_left <| sub_nonneg_of_le tβ.2.2
positivity
/-- Some `n`-th iterate of `next` is a contracting map, and its associated Lipschitz constant is
independent of the initial point. -/
lemma exists_contractingWith_iterate_next (hf : IsPicardLindelof f tβ xβ a r L K) :
β (n : β) (C : ββ₯0), β (x : E) (hx : x β closedBall xβ r),
ContractingWith C (next hf hx)^[n] := by
obtain β¨n, hnβ© := FloorSemiring.tendsto_pow_div_factorial_atTop (K * max (tmax - tβ) (tβ - tmin))
|>.eventually (gt_mem_nhds zero_lt_one) |>.exists
have : (0 : β) β€ (K * max (tmax - tβ) (tβ - tmin)) ^ n / n ! := by
have : 0 β€ max (tmax - tβ) (tβ - tmin) := le_max_of_le_left <| sub_nonneg_of_le tβ.2.2
positivity
refine β¨n, β¨_, thisβ©, fun x hx β¦ ?_β©
exact β¨hn, LipschitzWith.of_dist_le_mul fun Ξ± Ξ² β¦ dist_iterate_next_iterate_next_le hf hx Ξ± Ξ² nβ©
/-- The map `next` has a fixed point in the space of curves. This will be used to construct a
solution `Ξ± : β β E` to the ODE. -/
lemma exists_isFixedPt_next [CompleteSpace E] (hf : IsPicardLindelof f tβ xβ a r L K)
(hx : x β closedBall xβ r) :
β Ξ± : FunSpace tβ xβ r L, IsFixedPt (next hf hx) Ξ± :=
let β¨_, _, hβ© := exists_contractingWith_iterate_next hf
β¨_, h x hx |>.isFixedPt_fixedPoint_iterateβ©
/-! ## Lipschitz continuity of the solution with respect to the initial condition
The proof relies on the fact that the repeated application of `next` to any curve `Ξ±` converges to
the fixed point of `next`, so it suffices to bound the distance between `Ξ±` and `next^[n] Ξ±`. Since
there is some `m : β` such that `next^[m]` is a contracting map, it further suffices to bound the
distance between `Ξ±` and `next^[m]^[n] Ξ±`.
-/
/-- A key step in the base case of `exists_forall_closedBall_funSpace_dist_le_mul` -/
lemma dist_next_next (hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r)
(hy : y β closedBall xβ r) (Ξ± : FunSpace tβ xβ r L) :
dist (next hf hx Ξ±) (next hf hy Ξ±) = dist x y := by
have : Nonempty (Icc tmin tmax) := β¨tββ© -- needed for `ciSup_const`
rw [β MetricSpace.isometry_induced FunSpace.toContinuousMap FunSpace.toContinuousMap.injective
|>.dist_eq, dist_eq_norm, ContinuousMap.norm_eq_iSup_norm]
simp [add_sub_add_right_eq_sub, dist_eq_norm]
lemma dist_iterate_next_le (hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r)
(Ξ± : FunSpace tβ xβ r L) (n : β) :
dist Ξ± ((next hf hx)^[n] Ξ±) β€
(β i β Finset.range n, (K * max (tmax - tβ) (tβ - tmin)) ^ i / i !)
* dist Ξ± (next hf hx Ξ±) := by
nth_rw 1 [β iterate_zero_apply (next hf hx) Ξ±]
rw [Finset.sum_mul]
apply dist_le_range_sum_of_dist_le (f := fun i β¦ (next hf hx)^[i] Ξ±)
intro i hi
rw [iterate_succ_apply]
exact dist_iterate_next_iterate_next_le hf hx _ _ i
lemma dist_iterate_iterate_next_le_of_lipschitzWith (hf : IsPicardLindelof f tβ xβ a r L K)
(hx : x β closedBall xβ r) (Ξ± : FunSpace tβ xβ r L) {m : β} {C : ββ₯0}
(hm : LipschitzWith C (next hf hx)^[m]) (n : β) :
dist Ξ± ((next hf hx)^[m]^[n] Ξ±) β€
(β i β Finset.range m, (K * max (tmax - tβ) (tβ - tmin)) ^ i / i !) *
(β i β Finset.range n, (C : β) ^ i) * dist Ξ± (next hf hx Ξ±) := by
nth_rw 1 [β iterate_zero_apply (next hf hx) Ξ±]
rw [Finset.mul_sum, Finset.sum_mul]
apply dist_le_range_sum_of_dist_le (f := fun i β¦ (next hf hx)^[m]^[i] Ξ±)
intro i hi
rw [iterate_succ_apply]
apply le_trans <| hm.dist_iterate_succ_le_geometric Ξ± i
rw [mul_assoc, mul_comm ((C : β) ^ i), β mul_assoc]
gcongr
exact dist_iterate_next_le hf hx Ξ± m
/-- The pointwise distance between any two integral curves `Ξ±` and `Ξ²` over their domains is bounded
by a constant `L'` times the distance between their respective initial points. This is the result of
taking the limit of `dist_iterate_iterate_next_le_of_lipschitzWith` as `n β β`. This implies that
the local solution of a vector field is Lipschitz continuous in the initial condition. -/
lemma exists_forall_closedBall_funSpace_dist_le_mul [CompleteSpace E]
(hf : IsPicardLindelof f tβ xβ a r L K) :
β L' : ββ₯0, β (x y : E) (hx : x β closedBall xβ r) (hy : y β closedBall xβ r)
(Ξ± Ξ² : FunSpace tβ xβ r L) (_ : IsFixedPt (next hf hx) Ξ±) (_ : IsFixedPt (next hf hy) Ξ²),
dist Ξ± Ξ² β€ L' * dist x y := by
obtain β¨m, C, hβ© := exists_contractingWith_iterate_next hf
let L' := (β i β Finset.range m, (K * max (tmax - tβ) (tβ - tmin)) ^ i / i !) * (1 - C)β»ΒΉ
have hL' : 0 β€ L' := by
have : 0 β€ max (tmax - tβ) (tβ - tmin) := le_max_of_le_left <| sub_nonneg_of_le tβ.2.2
positivity
refine β¨β¨L', hL'β©, fun x y hx hy Ξ± Ξ² hΞ± hΞ² β¦ ?_β©
rw [NNReal.coe_mk]
apply le_of_tendsto_of_tendsto' (b := Filter.atTop) _ _ <|
dist_iterate_iterate_next_le_of_lipschitzWith hf hy Ξ± (h y hy).2
Β· apply Filter.Tendsto.comp (y := π Ξ²) (tendsto_const_nhds.dist Filter.tendsto_id)
rw [h y hy |>.fixedPoint_unique (hΞ².iterate m)]
exact h y hy |>.tendsto_iterate_fixedPoint Ξ±
Β· nth_rw 1 [β hΞ±, dist_next_next]
apply Filter.Tendsto.mul_const
apply Filter.Tendsto.const_mul
convert hasSum_geometric_of_lt_one C.2 (h y hy).1 |>.tendsto_sum_nat
simp [NNReal.coe_sub <| le_of_lt (h y hy).1, NNReal.coe_one]
end
end FunSpace
/-! ## Properties of the integral equation -/
section
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E]
{f : β β E β E} {Ξ± : β β E} {s : Set β} {u : Set E} {tβ tmin tmax : β}
-- TODO: generalise to open sets and `Ici` and `Iic`
/-- If the time-dependent vector field `f` and the curve `Ξ±` are continuous, then `f t (Ξ± t)` is the
derivative of `picard f tβ xβ Ξ±`. -/
lemma hasDerivWithinAt_picard_Icc
(htβ : tβ β Icc tmin tmax)
(hf : ContinuousOn (uncurry f) ((Icc tmin tmax) ΓΛ’ u))
(hΞ± : ContinuousOn Ξ± (Icc tmin tmax))
(hmem : β t β Icc tmin tmax, Ξ± t β u) (xβ : E)
{t : β} (ht : t β Icc tmin tmax) :
HasDerivWithinAt (picard f tβ xβ Ξ±) (f t (Ξ± t)) (Icc tmin tmax) t := by
apply HasDerivWithinAt.const_add
have : Fact (t β Icc tmin tmax) := β¨htβ© -- needed to synthesise `FTCFilter` for `Icc`
apply intervalIntegral.integral_hasDerivWithinAt_right _ -- need `CompleteSpace E` and `Icc`
(continuousOn_comp hf hΞ± hmem |>.stronglyMeasurableAtFilter_nhdsWithin measurableSet_Icc t)
(continuousOn_comp hf hΞ± hmem _ ht)
apply ContinuousOn.intervalIntegrable
apply continuousOn_comp hf hΞ± hmem |>.mono
by_cases! h : t < tβ
Β· rw [uIcc_of_gt h]
exact Icc_subset_Icc ht.1 htβ.2
Β· rw [uIcc_of_le h]
exact Icc_subset_Icc htβ.1 ht.2
/-- Converse of `hasDerivWithinAt_picard_Icc`: if `f` is the derivative along `Ξ±`, then `Ξ±`
satisfies the integral equation. -/
lemma picard_eq_of_hasDerivAt {t : β}
(hf : ContinuousOn (uncurry f) ((uIcc tβ t) ΓΛ’ u))
(hΞ± : β t' β uIcc tβ t, HasDerivWithinAt Ξ± (f t' (Ξ± t')) (uIcc tβ t) t')
(hmap : MapsTo Ξ± (uIcc tβ t) u) :
picard f tβ (Ξ± tβ) Ξ± t = Ξ± t := by
rw [β add_sub_cancel (Ξ± tβ) (Ξ± t), picard_apply,
integral_eq_sub_of_hasDeriv_right (HasDerivWithinAt.continuousOn hΞ±) _
(continuousOn_comp hf (HasDerivWithinAt.continuousOn hΞ±) hmap |>.intervalIntegrable)]
intro t' ht'
apply HasDerivAt.hasDerivWithinAt
exact hΞ± t' (Ioo_subset_Icc_self ht') |>.hasDerivAt <| Icc_mem_nhds ht'.1 ht'.2
/-- If the time-dependent vector field `f` is $C^n$ and the curve `Ξ±` is continuous, then
`picard f tβ xβ Ξ±` is also $C^n$. This version works for `n : β`. -/
lemma contDiffOn_nat_picard_Icc
(htβ : tβ β Icc tmin tmax) {n : β}
(hf : ContDiffOn β n (uncurry f) ((Icc tmin tmax) ΓΛ’ u))
(hΞ± : ContinuousOn Ξ± (Icc tmin tmax))
(hmem : β t β Icc tmin tmax, Ξ± t β u) (xβ : E)
(heqon : β t β Icc tmin tmax, Ξ± t = picard f tβ xβ Ξ± t) :
ContDiffOn β n (picard f tβ xβ Ξ±) (Icc tmin tmax) := by
by_cases hlt : tmin < tmax
Β· have (t) (ht : t β Icc tmin tmax) :=
hasDerivWithinAt_picard_Icc htβ hf.continuousOn hΞ± hmem xβ ht
induction n with
| zero =>
simp only [Nat.cast_zero, contDiffOn_zero] at *
exact HasDerivWithinAt.continuousOn this
| succ n hn =>
simp only [Nat.cast_add, Nat.cast_one] at *
rw [contDiffOn_succ_iff_derivWithin <| uniqueDiffOn_Icc hlt]
refine β¨fun t ht β¦ HasDerivWithinAt.differentiableWithinAt (this t ht), by simp, ?_β©
apply contDiffOn_comp hf.of_succ (ContDiffOn.congr (hn hf.of_succ) heqon) hmem |>.congr
intro t ht
exact HasDerivWithinAt.derivWithin (this t ht) <| (uniqueDiffOn_Icc hlt).uniqueDiffWithinAt ht
Β· rw [(subsingleton_Icc_of_ge (not_lt.mp hlt)).eq_singleton_of_mem htβ]
intro t ht
rw [eq_of_mem_singleton ht]
exact contDiffWithinAt_singleton
/-- If the time-dependent vector field `f` is $C^n$ and the curve `Ξ±` is continuous, then
`picard f tβ xβ Ξ±` is also $C^n$. This version works for `n : ββ`.
TODO: Extend to the analytic `n = β€` case. -/
lemma contDiffOn_enat_picard_Icc
(htβ : tβ β Icc tmin tmax) {n : ββ}
(hf : ContDiffOn β n (uncurry f) ((Icc tmin tmax) ΓΛ’ u))
(hΞ± : ContinuousOn Ξ± (Icc tmin tmax))
(hmem : β t β Icc tmin tmax, Ξ± t β u) (xβ : E)
(heqon : β t β Icc tmin tmax, Ξ± t = picard f tβ xβ Ξ± t) :
ContDiffOn β n (picard f tβ xβ Ξ±) (Icc tmin tmax) := by
induction n with
| top =>
rw [contDiffOn_infty] at *
exact fun k β¦ contDiffOn_nat_picard_Icc htβ (hf k) hΞ± hmem xβ heqon
| coe n =>
simp only [WithTop.coe_natCast] at *
exact contDiffOn_nat_picard_Icc htβ hf hΞ± hmem xβ heqon
/-- Solutions to ODEs defined by $C^n$ vector fields are also $C^n$. -/
theorem contDiffOn_enat_Icc_of_hasDerivWithinAt {n : ββ}
(hf : ContDiffOn β n (uncurry f) ((Icc tmin tmax) ΓΛ’ u))
(hΞ± : β t β Icc tmin tmax, HasDerivWithinAt Ξ± (f t (Ξ± t)) (Icc tmin tmax) t)
(hmem : MapsTo Ξ± (Icc tmin tmax) u) :
ContDiffOn β n Ξ± (Icc tmin tmax) := by
by_cases hlt : tmin < tmax
Β· set tβ := (tmin + tmax) / 2 with h
have htβ : tβ β Icc tmin tmax := β¨by linarith, by linarithβ©
have : β t β Icc tmin tmax, Ξ± t = picard f tβ (Ξ± tβ) Ξ± t := by
intro t ht
have : uIcc tβ t β Icc tmin tmax := uIcc_subset_Icc htβ ht
rw [picard_eq_of_hasDerivAt (hf.continuousOn.mono (prod_subset_prod_left this))
(fun t' ht' β¦ hΞ± t' (this ht') |>.mono this) (hmem.mono_left this)]
exact contDiffOn_enat_picard_Icc htβ hf (HasDerivWithinAt.continuousOn hΞ±) hmem (Ξ± tβ) this
|>.congr this
Β· rw [not_lt, le_iff_lt_or_eq] at hlt
cases hlt with
| inl h =>
intro _ ht
rw [Icc_eq_empty (not_le.mpr h)] at ht
exfalso
exact notMem_empty _ ht
| inr h =>
rw [h, Icc_self]
intro _ ht
rw [eq_of_mem_singleton ht]
exact contDiffWithinAt_singleton
end
end ODE
namespace IsPicardLindelof
/-! ## Properties of `IsPicardLindelof` -/
section
variable {E : Type*} [NormedAddCommGroup E]
{f : β β E β E} {tmin tmax : β} {tβ : Icc tmin tmax} {xβ x : E} {a r L K : ββ₯0}
lemma continuousOn_uncurry (hf : IsPicardLindelof f tβ xβ a r L K) :
ContinuousOn (uncurry f) ((Icc tmin tmax) ΓΛ’ (closedBall xβ a)) :=
continuousOn_prod_of_continuousOn_lipschitzOnWith' _ K hf.lipschitzOnWith hf.continuousOn
/-- The special case where the vector field is independent of time -/
lemma of_time_independent
{f : E β E} {tmin tmax : β} {tβ : Icc tmin tmax} {xβ : E} {a r L K : ββ₯0}
(hb : β x β closedBall xβ a, βf xβ β€ L)
(hl : LipschitzOnWith K f (closedBall xβ a))
(hm : L * max (tmax - tβ) (tβ - tmin) β€ a - r) :
(IsPicardLindelof (fun _ β¦ f) tβ xβ a r L K) where
lipschitzOnWith := fun _ _ β¦ hl
continuousOn := fun _ _ β¦ continuousOn_const
norm_le := fun _ _ β¦ hb
mul_max_le := hm
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
Picard-LindelΓΆf theorem. -/
lemma of_contDiffAt_one [NormedSpace β E]
{f : E β E} {xβ : E} (hf : ContDiffAt β 1 f xβ) (tβ : β) :
β (Ξ΅ : β) (hΞ΅ : 0 < Ξ΅) (a r L K : ββ₯0) (_ : 0 < r), IsPicardLindelof (fun _ β¦ f)
(tmin := tβ - Ξ΅) (tmax := tβ + Ξ΅) β¨tβ, (by simp [le_of_lt hΞ΅])β© xβ a r L K := by
-- Obtain ball of radius `a` within the domain in which f is `K`-lipschitz
obtain β¨K, s, hs, hlβ© := hf.exists_lipschitzOnWith
obtain β¨a, ha : 0 < a, hasβ© := Metric.mem_nhds_iff.mp hs
set L := K * a + βf xββ + 1 with hL
have hL0 : 0 < L := by positivity
have hb (x : E) (hx : x β closedBall xβ (a / 2)) : βf xβ β€ L := by
rw [hL]
calc
βf xβ β€ βf x - f xββ + βf xββ := norm_le_norm_sub_add _ _
_ β€ K * βx - xββ + βf xββ := by
gcongr
rw [β dist_eq_norm, β dist_eq_norm]
apply hl.dist_le_mul x _ xβ (mem_of_mem_nhds hs)
apply subset_trans _ has hx
exact closedBall_subset_ball <| half_lt_self ha -- this is where we need `a / 2`
_ β€ K * a + βf xββ := by
gcongr
rw [β mem_closedBall_iff_norm]
exact closedBall_subset_closedBall (half_le_self (le_of_lt ha)) hx
_ β€ L := le_add_of_nonneg_right zero_le_one
let Ξ΅ := a / L / 2 / 2
have hΞ΅0 : 0 < Ξ΅ := by positivity
refine β¨Ξ΅, hΞ΅0,
β¨a / 2, le_of_lt <| half_pos haβ©, β¨a / 2, le_of_lt <| half_pos haβ© / 2,
β¨L, le_of_lt hL0β©, K, half_pos <| half_pos ha, ?_β©
apply of_time_independent hb <|
hl.mono <| subset_trans (closedBall_subset_ball (half_lt_self ha)) has
rw [NNReal.coe_mk, add_sub_cancel_left, sub_sub_cancel, max_self, NNReal.coe_div,
NNReal.coe_two, NNReal.coe_mk, mul_comm, β le_div_iffβ hL0, sub_half, div_right_comm (a / 2),
div_right_comm a]
end
/-! ## Existence of solutions to ODEs -/
open ODE
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E]
{f : β β E β E} {tmin tmax : β} {tβ : Icc tmin tmax} {xβ x : E} {a r L K : ββ₯0}
/-- **Picard-LindelΓΆf (Cauchy-Lipschitz) theorem**, integral form. This version shows the existence
of a local solution whose initial point `x` may be different from the centre `xβ` of the closed
ball within which the properties of the vector field hold. -/
theorem exists_eq_forall_mem_Icc_eq_picard
(hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r) :
β Ξ± : β β E, Ξ± tβ = x β§ β t β Icc tmin tmax, Ξ± t = ODE.picard f tβ x Ξ± t := by
obtain β¨Ξ±, hΞ±β© := FunSpace.exists_isFixedPt_next hf hx
refine β¨(FunSpace.next hf hx Ξ±).compProj, by simp, fun t ht β¦ ?_β©
rw [FunSpace.compProj_apply, FunSpace.next_apply, hΞ±, projIcc_of_mem _ ht]
/-- **Picard-LindelΓΆf (Cauchy-Lipschitz) theorem**, differential form. This version shows the
existence of a local solution whose initial point `x` may be different from the centre `xβ` of
the closed ball within which the properties of the vector field hold. -/
theorem exists_eq_forall_mem_Icc_hasDerivWithinAt
(hf : IsPicardLindelof f tβ xβ a r L K) (hx : x β closedBall xβ r) :
β Ξ± : β β E, Ξ± tβ = x β§
β t β Icc tmin tmax, HasDerivWithinAt Ξ± (f t (Ξ± t)) (Icc tmin tmax) t := by
obtain β¨Ξ±, hΞ±β© := FunSpace.exists_isFixedPt_next hf hx
refine β¨Ξ±.compProj, by rw [FunSpace.compProj_val, β hΞ±, FunSpace.next_applyβ], fun t ht β¦ ?_β©
apply hasDerivWithinAt_picard_Icc tβ.2 hf.continuousOn_uncurry
Ξ±.continuous_compProj.continuousOn (fun _ ht' β¦ Ξ±.compProj_mem_closedBall hf.mul_max_le)
x ht |>.congr_of_mem _ ht
intro t' ht'
nth_rw 1 [β hΞ±]
rw [FunSpace.compProj_of_mem ht', FunSpace.next_apply]
/-- **Picard-LindelΓΆf (Cauchy-Lipschitz) theorem**, differential form. -/
theorem exists_eq_forall_mem_Icc_hasDerivWithinAtβ
(hf : IsPicardLindelof f tβ xβ a 0 L K) :
β Ξ± : β β E, Ξ± tβ = xβ β§
β t β Icc tmin tmax, HasDerivWithinAt Ξ± (f t (Ξ± t)) (Icc tmin tmax) t :=
exists_eq_forall_mem_Icc_hasDerivWithinAt hf (mem_closedBall_self le_rfl)
@[deprecated (since := "2025-06-24")] alias exists_forall_hasDerivWithinAt_Icc_eq :=
exists_eq_forall_mem_Icc_hasDerivWithinAtβ
open Classical in
/-- **Picard-LindelΓΆf (Cauchy-Lipschitz) theorem**, differential form. This version shows the
existence of a local flow and that it is Lipschitz continuous in the initial point. -/
theorem exists_forall_mem_closedBall_eq_hasDerivWithinAt_lipschitzOnWith
(hf : IsPicardLindelof f tβ xβ a r L K) :
β Ξ± : E β β β E, (β x β closedBall xβ r, Ξ± x tβ = x β§
β t β Icc tmin tmax, HasDerivWithinAt (Ξ± x) (f t (Ξ± x t)) (Icc tmin tmax) t) β§
β L' : ββ₯0, β t β Icc tmin tmax, LipschitzOnWith L' (Ξ± Β· t) (closedBall xβ r) := by
have (x) (hx : x β closedBall xβ r) := FunSpace.exists_isFixedPt_next hf hx
choose Ξ± hΞ± using this
set Ξ±' := fun (x : E) β¦ if hx : x β closedBall xβ r then
Ξ± x hx |>.compProj else 0 with hΞ±'
refine β¨Ξ±', fun x hx β¦ β¨?_, fun t ht β¦ ?_β©, ?_β©
Β· rw [hΞ±']
beta_reduce
rw [dif_pos hx, FunSpace.compProj_val, β hΞ±, FunSpace.next_applyβ]
Β· rw [hΞ±']
beta_reduce
rw [dif_pos hx, FunSpace.compProj_apply]
apply hasDerivWithinAt_picard_Icc tβ.2 hf.continuousOn_uncurry
(Ξ± x hx |>.continuous_compProj.continuousOn)
(fun _ ht' β¦ Ξ± x hx |>.compProj_mem_closedBall hf.mul_max_le)
x ht |>.congr_of_mem _ ht
intro t' ht'
nth_rw 1 [β hΞ±]
rw [FunSpace.compProj_of_mem ht', FunSpace.next_apply]
Β· obtain β¨L', hβ© := FunSpace.exists_forall_closedBall_funSpace_dist_le_mul hf
refine β¨L', fun t ht β¦ LipschitzOnWith.of_dist_le_mul fun x hx y hy β¦ ?_β©
simp_rw [hΞ±']
rw [dif_pos hx, dif_pos hy, FunSpace.compProj_apply, FunSpace.compProj_apply,
β FunSpace.toContinuousMap_apply_eq_apply, β FunSpace.toContinuousMap_apply_eq_apply]
have : Nonempty (Icc tmin tmax) := β¨tββ©
apply ContinuousMap.dist_le_iff_of_nonempty.mp
exact h x y hx hy (Ξ± x hx) (Ξ± y hy) (hΞ± x hx) (hΞ± y hy)
/-- **Picard-LindelΓΆf (Cauchy-Lipschitz) theorem**, differential form. This version shows the
existence of a local flow and that it is continuous on its domain as a (partial) map `E Γ β β E`. -/
theorem exists_forall_mem_closedBall_eq_hasDerivWithinAt_continuousOn
(hf : IsPicardLindelof f tβ xβ a r L K) :
β Ξ± : E Γ β β E, (β x β closedBall xβ r, Ξ± β¨x, tββ© = x β§
β t β Icc tmin tmax, HasDerivWithinAt (Ξ± β¨x, Β·β©) (f t (Ξ± β¨x, tβ©)) (Icc tmin tmax) t) β§
ContinuousOn Ξ± (closedBall xβ r ΓΛ’ Icc tmin tmax) := by
obtain β¨Ξ±, hΞ±1, L', hΞ±2β© := hf.exists_forall_mem_closedBall_eq_hasDerivWithinAt_lipschitzOnWith
refine β¨uncurry Ξ±, hΞ±1, ?_β©
apply continuousOn_prod_of_continuousOn_lipschitzOnWith _ L' _ hΞ±2
exact fun x hx β¦ HasDerivWithinAt.continuousOn (hΞ±1 x hx).2
/-- **Picard-LindelΓΆf (Cauchy-Lipschitz) theorem**, differential form. This version shows the
existence of a local flow. -/
theorem exists_forall_mem_closedBall_eq_forall_mem_Icc_hasDerivWithinAt
(hf : IsPicardLindelof f tβ xβ a r L K) :
β Ξ± : E β β β E, β x β closedBall xβ r, Ξ± x tβ = x β§
β t β Icc tmin tmax, HasDerivWithinAt (Ξ± x) (f t (Ξ± x t)) (Icc tmin tmax) t :=
have β¨Ξ±, hΞ±β© := exists_forall_mem_closedBall_eq_hasDerivWithinAt_lipschitzOnWith hf
β¨Ξ±, hΞ±.1β©
end IsPicardLindelof
/-! ## $C^1$ vector field -/
namespace ContDiffAt
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] [CompleteSpace E]
{f : E β E} {xβ : E}
/-- If a vector field `f : E β E` is continuously differentiable at `xβ : E`, then it admits an
integral curve `Ξ± : β β E` defined on an open interval, with initial condition `Ξ± tβ = x`, where
`x` may be different from `xβ`. -/
theorem exists_forall_mem_closedBall_exists_eq_forall_mem_Ioo_hasDerivAt
(hf : ContDiffAt β 1 f xβ) (tβ : β) :
β r > (0 : β), β Ξ΅ > (0 : β), β x β closedBall xβ r, β Ξ± : β β E, Ξ± tβ = x β§
β t β Ioo (tβ - Ξ΅) (tβ + Ξ΅), HasDerivAt Ξ± (f (Ξ± t)) t := by
have β¨Ξ΅, hΞ΅, a, r, _, _, hr, hplβ© := IsPicardLindelof.of_contDiffAt_one hf tβ
refine β¨r, hr, Ξ΅, hΞ΅, fun x hx β¦ ?_β©
have β¨Ξ±, hΞ±1, hΞ±2β© := hpl.exists_eq_forall_mem_Icc_hasDerivWithinAt hx
refine β¨Ξ±, hΞ±1, fun t ht β¦ ?_β©
exact hΞ±2 t (Ioo_subset_Icc_self ht) |>.hasDerivAt (Icc_mem_nhds ht.1 ht.2)
/-- If a vector field `f : E β E` is continuously differentiable at `xβ : E`, then it admits an
integral curve `Ξ± : β β E` defined on an open interval, with initial condition `Ξ± tβ = xβ`. -/
theorem exists_forall_mem_closedBall_exists_eq_forall_mem_Ioo_hasDerivAtβ
(hf : ContDiffAt β 1 f xβ) (tβ : β) :
β Ξ± : β β E, Ξ± tβ = xβ β§ β Ξ΅ > (0 : β),
β t β Ioo (tβ - Ξ΅) (tβ + Ξ΅), HasDerivAt Ξ± (f (Ξ± t)) t :=
have β¨_, hr, Ξ΅, hΞ΅, Hβ© := exists_forall_mem_closedBall_exists_eq_forall_mem_Ioo_hasDerivAt hf tβ
have β¨Ξ±, hΞ±1, hΞ±2β© := H xβ (mem_closedBall_self (le_of_lt hr))
β¨Ξ±, hΞ±1, Ξ΅, hΞ΅, hΞ±2β©
@[deprecated (since := "2025-06-24")] alias exists_forall_hasDerivAt_Ioo_eq_of_contDiffAt :=
exists_forall_mem_closedBall_exists_eq_forall_mem_Ioo_hasDerivAtβ
open Classical in
/-- If a vector field `f : E β E` is continuously differentiable at `xβ : E`, then it admits a flow
`Ξ± : E β β β E` defined on an open domain, with initial condition `Ξ± x tβ = x` for all `x` within
the domain. -/
theorem exists_eventually_eq_hasDerivAt
(hf : ContDiffAt β 1 f xβ) (tβ : β) :
β Ξ± : E β β β E, βαΆ xt in π xβ ΓΛ’ π tβ,
Ξ± xt.1 tβ = xt.1 β§ HasDerivAt (Ξ± xt.1) (f (Ξ± xt.1 xt.2)) xt.2 := by
obtain β¨r, hr, Ξ΅, hΞ΅, Hβ© := exists_forall_mem_closedBall_exists_eq_forall_mem_Ioo_hasDerivAt hf tβ
choose Ξ± hΞ± using H
refine β¨fun (x : E) β¦ if hx : x β closedBall xβ r then Ξ± x hx else 0, ?_β©
rw [Filter.eventually_iff_exists_mem]
refine β¨closedBall xβ r ΓΛ’ Ioo (tβ - Ξ΅) (tβ + Ξ΅), ?_, ?_β©
Β· rw [Filter.prod_mem_prod_iff]
exact β¨closedBall_mem_nhds xβ hr, Ioo_mem_nhds (by linarith) (by linarith)β©
Β· grind
end ContDiffAt |
.lake/packages/mathlib/Mathlib/Analysis/ODE/Gronwall.lean | import Mathlib.Analysis.SpecialFunctions.ExpDeriv
/-!
# GrΓΆnwall's inequality
The main technical result of this file is the GrΓΆnwall-like inequality
`norm_le_gronwallBound_of_norm_deriv_right_le`. It states that if `f : β β E` satisfies `βf aβ β€ Ξ΄`
and `β x β [a, b), βf' xβ β€ K * βf xβ + Ξ΅`, then for all `x β [a, b]` we have `βf xβ β€ Ξ΄ * exp (K *
x) + (Ξ΅ / K) * (exp (K * x) - 1)`.
Then we use this inequality to prove some estimates on the possible rate of growth of the distance
between two approximate or exact solutions of an ordinary differential equation.
The proofs are based on [Hubbard and West, *Differential Equations: A Dynamical Systems Approach*,
Sec. 4.5][HubbardWest-ode], where `norm_le_gronwallBound_of_norm_deriv_right_le` is called
βFundamental Inequalityβ.
## TODO
- Once we have FTC, prove an inequality for a function satisfying `βf' xβ β€ K x * βf xβ + Ξ΅`,
or more generally `liminf_{yβx+0} (f y - f x)/(y - x) β€ K x * f x + Ξ΅` with any sign
of `K x` and `f x`.
-/
open Metric Set Asymptotics Filter Real
open scoped Topology NNReal
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
/-! ### Technical lemmas about `gronwallBound` -/
/-- Upper bound used in several GrΓΆnwall-like inequalities. -/
noncomputable def gronwallBound (Ξ΄ K Ξ΅ x : β) : β :=
if K = 0 then Ξ΄ + Ξ΅ * x else Ξ΄ * exp (K * x) + Ξ΅ / K * (exp (K * x) - 1)
theorem gronwallBound_K0 (Ξ΄ Ξ΅ : β) : gronwallBound Ξ΄ 0 Ξ΅ = fun x => Ξ΄ + Ξ΅ * x :=
funext fun _ => if_pos rfl
theorem gronwallBound_of_K_ne_0 {Ξ΄ K Ξ΅ : β} (hK : K β 0) :
gronwallBound Ξ΄ K Ξ΅ = fun x => Ξ΄ * exp (K * x) + Ξ΅ / K * (exp (K * x) - 1) :=
funext fun _ => if_neg hK
theorem hasDerivAt_gronwallBound (Ξ΄ K Ξ΅ x : β) :
HasDerivAt (gronwallBound Ξ΄ K Ξ΅) (K * gronwallBound Ξ΄ K Ξ΅ x + Ξ΅) x := by
by_cases hK : K = 0
Β· subst K
simp only [gronwallBound_K0, zero_mul, zero_add]
convert ((hasDerivAt_id x).const_mul Ξ΅).const_add Ξ΄
rw [mul_one]
Β· simp only [gronwallBound_of_K_ne_0 hK]
convert (((hasDerivAt_id x).const_mul K).exp.const_mul Ξ΄).add
((((hasDerivAt_id x).const_mul K).exp.sub_const 1).const_mul (Ξ΅ / K)) using 1
simp only [id, mul_add, (mul_assoc _ _ _).symm, mul_comm _ K, mul_div_cancelβ _ hK]
ring
theorem hasDerivAt_gronwallBound_shift (Ξ΄ K Ξ΅ x a : β) :
HasDerivAt (fun y => gronwallBound Ξ΄ K Ξ΅ (y - a)) (K * gronwallBound Ξ΄ K Ξ΅ (x - a) + Ξ΅) x := by
convert (hasDerivAt_gronwallBound Ξ΄ K Ξ΅ _).comp x ((hasDerivAt_id x).sub_const a) using 1
rw [id, mul_one]
theorem gronwallBound_x0 (Ξ΄ K Ξ΅ : β) : gronwallBound Ξ΄ K Ξ΅ 0 = Ξ΄ := by
by_cases hK : K = 0
Β· simp only [gronwallBound, if_pos hK, mul_zero, add_zero]
Β· simp only [gronwallBound, if_neg hK, mul_zero, exp_zero, sub_self, mul_one,
add_zero]
theorem gronwallBound_Ξ΅0 (Ξ΄ K x : β) : gronwallBound Ξ΄ K 0 x = Ξ΄ * exp (K * x) := by
by_cases hK : K = 0
Β· simp only [gronwallBound_K0, hK, zero_mul, exp_zero, add_zero, mul_one]
Β· simp only [gronwallBound_of_K_ne_0 hK, zero_div, zero_mul, add_zero]
theorem gronwallBound_Ξ΅0_Ξ΄0 (K x : β) : gronwallBound 0 K 0 x = 0 := by
simp only [gronwallBound_Ξ΅0, zero_mul]
theorem gronwallBound_continuous_Ξ΅ (Ξ΄ K x : β) : Continuous fun Ξ΅ => gronwallBound Ξ΄ K Ξ΅ x := by
by_cases hK : K = 0
Β· simp only [gronwallBound_K0, hK]
exact continuous_const.add (continuous_id.mul continuous_const)
Β· simp only [gronwallBound_of_K_ne_0 hK]
exact continuous_const.add ((continuous_id.mul continuous_const).mul continuous_const)
/-! ### Inequality and corollaries -/
/-- A GrΓΆnwall-like inequality: if `f : β β β` is continuous on `[a, b]` and satisfies
the inequalities `f a β€ Ξ΄` and
`β x β [a, b), liminf_{zβx+0} (f z - f x)/(z - x) β€ K * (f x) + Ξ΅`, then `f x`
is bounded by `gronwallBound Ξ΄ K Ξ΅ (x - a)` on `[a, b]`.
See also `norm_le_gronwallBound_of_norm_deriv_right_le` for a version bounding `βf xβ`,
`f : β β E`. -/
theorem le_gronwallBound_of_liminf_deriv_right_le {f f' : β β β} {Ξ΄ K Ξ΅ : β} {a b : β}
(hf : ContinuousOn f (Icc a b))
(hf' : β x β Ico a b, β r, f' x < r β βαΆ z in π[>] x, (z - x)β»ΒΉ * (f z - f x) < r)
(ha : f a β€ Ξ΄) (bound : β x β Ico a b, f' x β€ K * f x + Ξ΅) :
β x β Icc a b, f x β€ gronwallBound Ξ΄ K Ξ΅ (x - a) := by
have H : β x β Icc a b, β Ξ΅' β Ioi Ξ΅, f x β€ gronwallBound Ξ΄ K Ξ΅' (x - a) := by
intro x hx Ξ΅' (hΞ΅' : Ξ΅ < Ξ΅')
apply image_le_of_liminf_slope_right_lt_deriv_boundary hf hf'
Β· rwa [sub_self, gronwallBound_x0]
Β· exact fun x => hasDerivAt_gronwallBound_shift Ξ΄ K Ξ΅' x a
Β· intro x hx hfB
grw [β hfB, bound x hx]
gcongr
Β· exact hx
intro x hx
change f x β€ (fun Ξ΅' => gronwallBound Ξ΄ K Ξ΅' (x - a)) Ξ΅
convert continuousWithinAt_const.closure_le _ _ (H x hx)
Β· simp only [closure_Ioi, left_mem_Ici]
exact (gronwallBound_continuous_Ξ΅ Ξ΄ K (x - a)).continuousWithinAt
/-- A GrΓΆnwall-like inequality: if `f : β β E` is continuous on `[a, b]`, has right derivative
`f' x` at every point `x β [a, b)`, and satisfies the inequalities `βf aβ β€ Ξ΄`,
`β x β [a, b), βf' xβ β€ K * βf xβ + Ξ΅`, then `βf xβ` is bounded by `gronwallBound Ξ΄ K Ξ΅ (x - a)`
on `[a, b]`. -/
theorem norm_le_gronwallBound_of_norm_deriv_right_le {f f' : β β E} {Ξ΄ K Ξ΅ : β} {a b : β}
(hf : ContinuousOn f (Icc a b)) (hf' : β x β Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
(ha : βf aβ β€ Ξ΄) (bound : β x β Ico a b, βf' xβ β€ K * βf xβ + Ξ΅) :
β x β Icc a b, βf xβ β€ gronwallBound Ξ΄ K Ξ΅ (x - a) :=
le_gronwallBound_of_liminf_deriv_right_le (continuous_norm.comp_continuousOn hf)
(fun x hx _r hr => (hf' x hx).liminf_right_slope_norm_le hr) ha bound
/-- Let `f : [a, b] β E` be a differentiable function such that `f a = 0`
and `βf'(x)β β€ K βf(x)β` for some constant `K`. Then `f = 0` on `[a, b]`. -/
theorem eq_zero_of_abs_deriv_le_mul_abs_self_of_eq_zero_right {f f' : β β E} {K a b : β}
(hf : ContinuousOn f (Icc a b)) (hf' : β x β Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
(ha : f a = 0) (bound : β x β Ico a b, βf' xβ β€ K * βf xβ) :
β x β Set.Icc a b, f x = 0 := by
intro x hx
apply norm_le_zero_iff.mp
calc βf xβ
_ β€ gronwallBound 0 K 0 (x - a) :=
norm_le_gronwallBound_of_norm_deriv_right_le hf hf' (by simp [ha]) (by simpa using bound) _ hx
_ = 0 := by rw [gronwallBound_Ξ΅0_Ξ΄0]
variable {v : β β E β E} {s : β β Set E} {K : ββ₯0} {f g f' g' : β β E} {a b tβ : β} {Ξ΅f Ξ΅g Ξ΄ : β}
/-- If `f` and `g` are two approximate solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of GrΓΆnwall's inequality, and some
people call this GrΓΆnwall's inequality too.
This version assumes all inequalities to be true in some time-dependent set `s t`,
and assumes that the solutions never leave this set. -/
theorem dist_le_of_approx_trajectories_ODE_of_mem
(hv : β t β Ico a b, LipschitzOnWith K (v t) (s t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ico a b, HasDerivWithinAt f (f' t) (Ici t) t)
(f_bound : β t β Ico a b, dist (f' t) (v t (f t)) β€ Ξ΅f)
(hfs : β t β Ico a b, f t β s t)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ico a b, HasDerivWithinAt g (g' t) (Ici t) t)
(g_bound : β t β Ico a b, dist (g' t) (v t (g t)) β€ Ξ΅g)
(hgs : β t β Ico a b, g t β s t)
(ha : dist (f a) (g a) β€ Ξ΄) :
β t β Icc a b, dist (f t) (g t) β€ gronwallBound Ξ΄ K (Ξ΅f + Ξ΅g) (t - a) := by
simp only [dist_eq_norm] at ha β’
have h_deriv : β t β Ico a b, HasDerivWithinAt (fun t => f t - g t) (f' t - g' t) (Ici t) t :=
fun t ht => (hf' t ht).sub (hg' t ht)
apply norm_le_gronwallBound_of_norm_deriv_right_le (hf.sub hg) h_deriv ha
intro t ht
have := dist_triangle4_right (f' t) (g' t) (v t (f t)) (v t (g t))
have hv := (hv t ht).dist_le_mul _ (hfs t ht) _ (hgs t ht)
rw [β dist_eq_norm, β dist_eq_norm]
refine this.trans ((add_le_add (add_le_add (f_bound t ht) (g_bound t ht)) hv).trans ?_)
rw [add_comm]
/-- If `f` and `g` are two approximate solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of GrΓΆnwall's inequality, and some
people call this GrΓΆnwall's inequality too.
This version assumes all inequalities to be true in the whole space. -/
theorem dist_le_of_approx_trajectories_ODE
(hv : β t, LipschitzWith K (v t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ico a b, HasDerivWithinAt f (f' t) (Ici t) t)
(f_bound : β t β Ico a b, dist (f' t) (v t (f t)) β€ Ξ΅f)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ico a b, HasDerivWithinAt g (g' t) (Ici t) t)
(g_bound : β t β Ico a b, dist (g' t) (v t (g t)) β€ Ξ΅g)
(ha : dist (f a) (g a) β€ Ξ΄) :
β t β Icc a b, dist (f t) (g t) β€ gronwallBound Ξ΄ K (Ξ΅f + Ξ΅g) (t - a) :=
have hfs : β t β Ico a b, f t β @univ E := fun _ _ => trivial
dist_le_of_approx_trajectories_ODE_of_mem (fun t _ => (hv t).lipschitzOnWith) hf hf'
f_bound hfs hg hg' g_bound (fun _ _ => trivial) ha
/-- If `f` and `g` are two exact solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of GrΓΆnwall's inequality, and some
people call this GrΓΆnwall's inequality too.
This version assumes all inequalities to be true in some time-dependent set `s t`,
and assumes that the solutions never leave this set. -/
theorem dist_le_of_trajectories_ODE_of_mem
(hv : β t β Ico a b, LipschitzOnWith K (v t) (s t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hfs : β t β Ico a b, f t β s t)
(hg : ContinuousOn g (Icc a b)) (hg' : β t β Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(hgs : β t β Ico a b, g t β s t) (ha : dist (f a) (g a) β€ Ξ΄) :
β t β Icc a b, dist (f t) (g t) β€ Ξ΄ * exp (K * (t - a)) := by
have f_bound : β t β Ico a b, dist (v t (f t)) (v t (f t)) β€ 0 := by intros; rw [dist_self]
have g_bound : β t β Ico a b, dist (v t (g t)) (v t (g t)) β€ 0 := by intros; rw [dist_self]
intro t ht
have :=
dist_le_of_approx_trajectories_ODE_of_mem hv hf hf' f_bound hfs hg hg' g_bound hgs ha t ht
rwa [zero_add, gronwallBound_Ξ΅0] at this
/-- If `f` and `g` are two exact solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of GrΓΆnwall's inequality, and some
people call this GrΓΆnwall's inequality too.
This version assumes all inequalities to be true in the whole space. -/
theorem dist_le_of_trajectories_ODE
(hv : β t, LipschitzWith K (v t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(ha : dist (f a) (g a) β€ Ξ΄) :
β t β Icc a b, dist (f t) (g t) β€ Ξ΄ * exp (K * (t - a)) :=
have hfs : β t β Ico a b, f t β @univ E := fun _ _ => trivial
dist_le_of_trajectories_ODE_of_mem (fun t _ => (hv t).lipschitzOnWith) hf hf' hfs hg
hg' (fun _ _ => trivial) ha
/-- There exists only one solution of an ODE \(\dot x=v(t, x)\) in a set `s β β Γ E` with
a given initial value provided that the RHS is Lipschitz continuous in `x` within `s`,
and we consider only solutions included in `s`.
This version shows uniqueness in a closed interval `Icc a b`, where `a` is the initial time. -/
theorem ODE_solution_unique_of_mem_Icc_right
(hv : β t β Ico a b, LipschitzOnWith K (v t) (s t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hfs : β t β Ico a b, f t β s t)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(hgs : β t β Ico a b, g t β s t)
(ha : f a = g a) :
EqOn f g (Icc a b) := fun t ht β¦ by
have := dist_le_of_trajectories_ODE_of_mem hv hf hf' hfs hg hg' hgs (dist_le_zero.2 ha) t ht
rwa [zero_mul, dist_le_zero] at this
/-- A time-reversed version of `ODE_solution_unique_of_mem_Icc_right`. Uniqueness is shown in a
closed interval `Icc a b`, where `b` is the "initial" time. -/
theorem ODE_solution_unique_of_mem_Icc_left
(hv : β t β Ioc a b, LipschitzOnWith K (v t) (s t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ioc a b, HasDerivWithinAt f (v t (f t)) (Iic t) t)
(hfs : β t β Ioc a b, f t β s t)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ioc a b, HasDerivWithinAt g (v t (g t)) (Iic t) t)
(hgs : β t β Ioc a b, g t β s t)
(hb : f b = g b) :
EqOn f g (Icc a b) := by
have hv' : β t β Ico (-b) (-a), LipschitzOnWith K (Neg.neg β (v (-t))) (s (-t)) := by
intro t ht
replace ht : -t β Ioc a b := by
simp only [mem_Ico, mem_Ioc] at ht β’
constructor <;> linarith
rw [β one_mul K]
exact LipschitzWith.id.neg.comp_lipschitzOnWith (hv _ ht)
have hmt1 : MapsTo Neg.neg (Icc (-b) (-a)) (Icc a b) :=
fun _ ht β¦ β¨le_neg.mp ht.2, neg_le.mp ht.1β©
have hmt2 : MapsTo Neg.neg (Ico (-b) (-a)) (Ioc a b) :=
fun _ ht β¦ β¨lt_neg.mp ht.2, neg_le.mp ht.1β©
have hmt3 (t : β) : MapsTo Neg.neg (Ici t) (Iic (-t)) :=
fun _ ht' β¦ mem_Iic.mpr <| neg_le_neg ht'
suffices EqOn (f β Neg.neg) (g β Neg.neg) (Icc (-b) (-a)) by
rw [eqOn_comp_right_iff] at this
convert this
simp
apply ODE_solution_unique_of_mem_Icc_right hv'
(hf.comp continuousOn_neg hmt1) _ (fun _ ht β¦ hfs _ (hmt2 ht))
(hg.comp continuousOn_neg hmt1) _ (fun _ ht β¦ hgs _ (hmt2 ht)) (by simp [hb])
Β· intro t ht
convert HasFDerivWithinAt.comp_hasDerivWithinAt t (hf' (-t) (hmt2 ht))
(hasDerivAt_neg t).hasDerivWithinAt (hmt3 t)
simp
Β· intro t ht
convert HasFDerivWithinAt.comp_hasDerivWithinAt t (hg' (-t) (hmt2 ht))
(hasDerivAt_neg t).hasDerivWithinAt (hmt3 t)
simp
/-- A version of `ODE_solution_unique_of_mem_Icc_right` for uniqueness in a closed interval whose
interior contains the initial time. -/
theorem ODE_solution_unique_of_mem_Icc
(hv : β t β Ioo a b, LipschitzOnWith K (v t) (s t))
(ht : tβ β Ioo a b)
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ioo a b, HasDerivAt f (v t (f t)) t)
(hfs : β t β Ioo a b, f t β s t)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ioo a b, HasDerivAt g (v t (g t)) t)
(hgs : β t β Ioo a b, g t β s t)
(heq : f tβ = g tβ) :
EqOn f g (Icc a b) := by
rw [β Icc_union_Icc_eq_Icc (le_of_lt ht.1) (le_of_lt ht.2)]
apply EqOn.union
Β· have hss : Ioc a tβ β Ioo a b := Ioc_subset_Ioo_right ht.2
exact ODE_solution_unique_of_mem_Icc_left (fun t ht β¦ hv t (hss ht))
(hf.mono <| Icc_subset_Icc_right <| le_of_lt ht.2)
(fun _ ht' β¦ (hf' _ (hss ht')).hasDerivWithinAt) (fun _ ht' β¦ (hfs _ (hss ht')))
(hg.mono <| Icc_subset_Icc_right <| le_of_lt ht.2)
(fun _ ht' β¦ (hg' _ (hss ht')).hasDerivWithinAt) (fun _ ht' β¦ (hgs _ (hss ht'))) heq
Β· have hss : Ico tβ b β Ioo a b := Ico_subset_Ioo_left ht.1
exact ODE_solution_unique_of_mem_Icc_right (fun t ht β¦ hv t (hss ht))
(hf.mono <| Icc_subset_Icc_left <| le_of_lt ht.1)
(fun _ ht' β¦ (hf' _ (hss ht')).hasDerivWithinAt) (fun _ ht' β¦ (hfs _ (hss ht')))
(hg.mono <| Icc_subset_Icc_left <| le_of_lt ht.1)
(fun _ ht' β¦ (hg' _ (hss ht')).hasDerivWithinAt) (fun _ ht' β¦ (hgs _ (hss ht'))) heq
/-- A version of `ODE_solution_unique_of_mem_Icc` for uniqueness in an open interval. -/
theorem ODE_solution_unique_of_mem_Ioo
(hv : β t β Ioo a b, LipschitzOnWith K (v t) (s t))
(ht : tβ β Ioo a b)
(hf : β t β Ioo a b, HasDerivAt f (v t (f t)) t β§ f t β s t)
(hg : β t β Ioo a b, HasDerivAt g (v t (g t)) t β§ g t β s t)
(heq : f tβ = g tβ) :
EqOn f g (Ioo a b) := by
intro t' ht'
rcases lt_or_ge t' tβ with (h | h)
Β· have hss : Icc t' tβ β Ioo a b :=
fun _ ht'' β¦ β¨lt_of_lt_of_le ht'.1 ht''.1, lt_of_le_of_lt ht''.2 ht.2β©
exact ODE_solution_unique_of_mem_Icc_left
(fun t'' ht'' β¦ hv t'' ((Ioc_subset_Icc_self.trans hss) ht''))
(HasDerivAt.continuousOn fun _ ht'' β¦ (hf _ <| hss ht'').1)
(fun _ ht'' β¦ (hf _ <| hss <| Ioc_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' β¦ (hf _ <| hss <| Ioc_subset_Icc_self ht'').2)
(HasDerivAt.continuousOn fun _ ht'' β¦ (hg _ <| hss ht'').1)
(fun _ ht'' β¦ (hg _ <| hss <| Ioc_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' β¦ (hg _ <| hss <| Ioc_subset_Icc_self ht'').2) heq
β¨le_rfl, le_of_lt hβ©
Β· have hss : Icc tβ t' β Ioo a b :=
fun _ ht'' β¦ β¨lt_of_lt_of_le ht.1 ht''.1, lt_of_le_of_lt ht''.2 ht'.2β©
exact ODE_solution_unique_of_mem_Icc_right
(fun t'' ht'' β¦ hv t'' ((Ico_subset_Icc_self.trans hss) ht''))
(HasDerivAt.continuousOn fun _ ht'' β¦ (hf _ <| hss ht'').1)
(fun _ ht'' β¦ (hf _ <| hss <| Ico_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' β¦ (hf _ <| hss <| Ico_subset_Icc_self ht'').2)
(HasDerivAt.continuousOn fun _ ht'' β¦ (hg _ <| hss ht'').1)
(fun _ ht'' β¦ (hg _ <| hss <| Ico_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' β¦ (hg _ <| hss <| Ico_subset_Icc_self ht'').2) heq
β¨h, le_rflβ©
/-- Local uniqueness of ODE solutions. -/
theorem ODE_solution_unique_of_eventually
(hv : βαΆ t in π tβ, LipschitzOnWith K (v t) (s t))
(hf : βαΆ t in π tβ, HasDerivAt f (v t (f t)) t β§ f t β s t)
(hg : βαΆ t in π tβ, HasDerivAt g (v t (g t)) t β§ g t β s t)
(heq : f tβ = g tβ) : f =αΆ [π tβ] g := by
obtain β¨Ξ΅, hΞ΅, hβ© := eventually_nhds_iff_ball.mp (hv.and (hf.and hg))
rw [Filter.eventuallyEq_iff_exists_mem]
refine β¨ball tβ Ξ΅, ball_mem_nhds _ hΞ΅, ?_β©
simp_rw [Real.ball_eq_Ioo] at *
apply ODE_solution_unique_of_mem_Ioo (fun _ ht β¦ (h _ ht).1)
(Real.ball_eq_Ioo tβ Ξ΅ βΈ mem_ball_self hΞ΅)
(fun _ ht β¦ (h _ ht).2.1) (fun _ ht β¦ (h _ ht).2.2) heq
/-- There exists only one solution of an ODE \(\dot x=v(t, x)\) with
a given initial value provided that the RHS is Lipschitz continuous in `x`. -/
theorem ODE_solution_unique
(hv : β t, LipschitzWith K (v t))
(hf : ContinuousOn f (Icc a b))
(hf' : β t β Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hg : ContinuousOn g (Icc a b))
(hg' : β t β Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(ha : f a = g a) :
EqOn f g (Icc a b) :=
have hfs : β t β Ico a b, f t β univ := fun _ _ => trivial
ODE_solution_unique_of_mem_Icc_right (fun t _ => (hv t).lipschitzOnWith) hf hf' hfs hg hg'
(fun _ _ => trivial) ha
/-- There exists only one global solution to an ODE \(\dot x=v(t, x\) with a given initial value
provided that the RHS is Lipschitz continuous. -/
theorem ODE_solution_unique_univ
(hv : β t, LipschitzOnWith K (v t) (s t))
(hf : β t, HasDerivAt f (v t (f t)) t β§ f t β s t)
(hg : β t, HasDerivAt g (v t (g t)) t β§ g t β s t)
(heq : f tβ = g tβ) : f = g := by
ext t
obtain β¨A, B, Ht, Htββ© : β A B, t β Set.Ioo A B β§ tβ β Set.Ioo A B := by
use (min (-|t|) (-|tβ|) - 1), (max |t| |tβ| + 1)
rw [Set.mem_Ioo, Set.mem_Ioo]
refine β¨β¨?_, ?_β©, ?_, ?_β©
Β· exact sub_one_lt _ |>.trans_le <| min_le_left _ _ |>.trans <| neg_abs_le t
Β· exact le_abs_self _ |>.trans_lt <| le_max_left _ _ |>.trans_lt <| lt_add_one _
Β· exact sub_one_lt _ |>.trans_le <| min_le_right _ _ |>.trans <| neg_abs_le tβ
Β· exact le_abs_self _ |>.trans_lt <| le_max_right _ _ |>.trans_lt <| lt_add_one _
exact ODE_solution_unique_of_mem_Ioo
(fun t _ => hv t) Htβ (fun t _ => hf t) (fun t _ => hg t) heq Ht |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Integrability.lean | import Mathlib.Analysis.BoxIntegral.Basic
import Mathlib.MeasureTheory.Integral.Bochner.Set
import Mathlib.Tactic.Generalize
/-!
# McShane integrability vs Bochner integrability
In this file we prove that any Bochner integrable function is McShane integrable (hence, it is
Henstock and `GP` integrable) with the same integral. The proof is based on
[Russel A. Gordon, *The integrals of Lebesgue, Denjoy, Perron, and Henstock*][Gordon55].
We deduce that the same is true for the Riemann integral for continuous functions.
## Tags
integral, McShane integral, Bochner integral
-/
open scoped NNReal ENNReal Topology
universe u v
variable {ΞΉ : Type u} {E : Type v} [Fintype ΞΉ] [NormedAddCommGroup E] [NormedSpace β E]
open MeasureTheory Metric Set Finset Filter BoxIntegral
namespace BoxIntegral
/-- The indicator function of a measurable set is McShane integrable with respect to any
locally-finite measure. -/
theorem hasIntegralIndicatorConst (l : IntegrationParams) (hl : l.bRiemann = false)
{s : Set (ΞΉ β β)} (hs : MeasurableSet s) (I : Box ΞΉ) (y : E) (ΞΌ : Measure (ΞΉ β β))
[IsLocallyFiniteMeasure ΞΌ] :
HasIntegral.{u, v, v} I l (s.indicator fun _ => y) ΞΌ.toBoxAdditive.toSMul
(ΞΌ.real (s β© I) β’ y) := by
refine HasIntegral.of_mul βyβ fun Ξ΅ Ξ΅0 => ?_
lift Ξ΅ to ββ₯0 using Ξ΅0.le; rw [NNReal.coe_pos] at Ξ΅0
/- First we choose a closed set `F β s β© I.Icc` and an open set `U β s` such that
both `(s β© I.Icc) \ F` and `U \ s` have measure less than `Ξ΅`. -/
have A : ΞΌ (s β© Box.Icc I) β β :=
((measure_mono Set.inter_subset_right).trans_lt (I.measure_Icc_lt_top ΞΌ)).ne
have B : ΞΌ (s β© I) β β :=
((measure_mono Set.inter_subset_right).trans_lt (I.measure_coe_lt_top ΞΌ)).ne
obtain β¨F, hFs, hFc, hΞΌFβ© : β F, F β s β© Box.Icc I β§ IsClosed F β§ ΞΌ ((s β© Box.Icc I) \ F) < Ξ΅ :=
(hs.inter I.measurableSet_Icc).exists_isClosed_diff_lt A (ENNReal.coe_pos.2 Ξ΅0).ne'
obtain β¨U, hsU, hUo, hUt, hΞΌUβ© :
β U, s β© Box.Icc I β U β§ IsOpen U β§ ΞΌ U < β β§ ΞΌ (U \ (s β© Box.Icc I)) < Ξ΅ :=
(hs.inter I.measurableSet_Icc).exists_isOpen_diff_lt A (ENNReal.coe_pos.2 Ξ΅0).ne'
/- Then we choose `r` so that `closed_ball x (r x) β U` whenever `x β s β© I.Icc` and
`closed_ball x (r x)` is disjoint with `F` otherwise. -/
have : β x β s β© Box.Icc I, β r : Ioi (0 : β), closedBall x r β U := fun x hx => by
rcases nhds_basis_closedBall.mem_iff.1 (hUo.mem_nhds <| hsU hx) with β¨r, hrβ, hrβ©
exact β¨β¨r, hrββ©, hrβ©
choose! rs hrsU using this
have : β x β Box.Icc I \ s, β r : Ioi (0 : β), closedBall x r β FαΆ := fun x hx => by
obtain β¨r, hrβ, hrβ© :=
nhds_basis_closedBall.mem_iff.1 (hFc.isOpen_compl.mem_nhds fun hx' => hx.2 (hFs hx').1)
exact β¨β¨r, hrββ©, hrβ©
choose! rs' hrs'F using this
classical
set r : (ΞΉ β β) β Ioi (0 : β) := s.piecewise rs rs'
refine β¨fun _ => r, fun c => l.rCond_of_bRiemann_eq_false hl, fun c Ο hΟ hΟp => ?_β©; rw [mul_comm]
/- Then the union of boxes `J β Ο` such that `Ο.tag β s` includes `F` and is included by `U`,
hence its measure is `Ξ΅`-close to the measure of `s`. -/
dsimp [integralSum]
simp only [dist_eq_norm, β indicator_const_smul_apply, sum_indicator_eq_sum_filter, β sum_smul,
β sub_smul, norm_smul, Real.norm_eq_abs, β Prepartition.filter_boxes,
β Prepartition.measure_iUnion_toReal]
gcongr
set t := (Ο.filter (Ο.tag Β· β s)).iUnion
change abs (ΞΌ.real t - ΞΌ.real (s β© I)) β€ Ξ΅
have htU : t β U β© I := by
simp only [t, TaggedPrepartition.iUnion_def, iUnion_subset_iff, TaggedPrepartition.mem_filter,
and_imp]
refine fun J hJ hJs x hx => β¨hrsU _ β¨hJs, Ο.tag_mem_Icc Jβ© ?_, Ο.le_of_mem' J hJ hxβ©
simpa only [r, s.piecewise_eq_of_mem _ _ hJs] using hΟ.1 J hJ (Box.coe_subset_Icc hx)
refine abs_sub_le_iff.2 β¨?_, ?_β©
Β· refine (ENNReal.le_toReal_sub B).trans (ENNReal.toReal_le_coe_of_le_coe ?_)
refine (tsub_le_tsub (measure_mono htU) le_rfl).trans (le_measure_diff.trans ?_)
refine (measure_mono fun x hx => ?_).trans hΞΌU.le
exact β¨hx.1.1, fun hx' => hx.2 β¨hx'.1, hx.1.2β©β©
Β· have hΞΌt : ΞΌ t β β := ((measure_mono (htU.trans inter_subset_left)).trans_lt hUt).ne
refine (ENNReal.le_toReal_sub hΞΌt).trans (ENNReal.toReal_le_coe_of_le_coe ?_)
refine le_measure_diff.trans ((measure_mono ?_).trans hΞΌF.le)
rintro x β¨β¨hxs, hxIβ©, hxtβ©
refine β¨β¨hxs, Box.coe_subset_Icc hxIβ©, fun hxF => hxt ?_β©
simp only [t, TaggedPrepartition.iUnion_def, TaggedPrepartition.mem_filter, Set.mem_iUnion]
rcases hΟp x hxI with β¨J, hJΟ, hxJβ©
refine β¨J, β¨hJΟ, ?_β©, hxJβ©
contrapose hxF
refine hrs'F _ β¨Ο.tag_mem_Icc J, hxFβ© ?_
simpa only [r, s.piecewise_eq_of_notMem _ _ hxF] using hΟ.1 J hJΟ (Box.coe_subset_Icc hxJ)
/-- If `f` is a.e. equal to zero on a rectangular box, then it has McShane integral zero on this
box. -/
theorem HasIntegral.of_aeEq_zero {l : IntegrationParams} {I : Box ΞΉ} {f : (ΞΉ β β) β E}
{ΞΌ : Measure (ΞΉ β β)} [IsLocallyFiniteMeasure ΞΌ] (hf : f =α΅[ΞΌ.restrict I] 0)
(hl : l.bRiemann = false) : HasIntegral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul 0 := by
/- Each set `{x | n < βf xβ β€ n + 1}`, `n : β`, has measure zero. We cover it by an open set of
measure less than `Ξ΅ / 2 ^ n / (n + 1)`. Then the norm of the integral sum is less than `Ξ΅`. -/
refine hasIntegral_iff.2 fun Ξ΅ Ξ΅0 => ?_
lift Ξ΅ to ββ₯0 using Ξ΅0.lt.le; rw [gt_iff_lt, NNReal.coe_pos] at Ξ΅0
rcases NNReal.exists_pos_sum_of_countable Ξ΅0.ne' β with β¨Ξ΄, Ξ΄0, c, hΞ΄c, hcΞ΅β©
haveI := Fact.mk (I.measure_coe_lt_top ΞΌ)
change ΞΌ.restrict I {x | f x β 0} = 0 at hf
set N : (ΞΉ β β) β β := fun x => ββf xβββ
have N0 : β {x}, N x = 0 β f x = 0 := by simp [N]
have : β n, β U, N β»ΒΉ' {n} β U β§ IsOpen U β§ ΞΌ.restrict I U < Ξ΄ n / n := fun n β¦ by
refine (N β»ΒΉ' {n}).exists_isOpen_lt_of_lt _ ?_
rcases n with - | n
Β· simp [ENNReal.div_zero (ENNReal.coe_pos.2 (Ξ΄0 _)).ne']
Β· refine (measure_mono_null ?_ hf).le.trans_lt ?_
Β· exact fun x hxN hxf => n.succ_ne_zero ((Eq.symm hxN).trans <| N0.2 hxf)
Β· simp [(Ξ΄0 _).ne']
choose U hNU hUo hΞΌU using this
have : β x, β r : Ioi (0 : β), closedBall x r β U (N x) := fun x => by
obtain β¨r, hrβ, hrβ© := nhds_basis_closedBall.mem_iff.1 ((hUo _).mem_nhds (hNU _ rfl))
exact β¨β¨r, hrββ©, hrβ©
choose r hrU using this
refine β¨fun _ => r, fun c => l.rCond_of_bRiemann_eq_false hl, fun c Ο hΟ _ => ?_β©
rw [dist_eq_norm, sub_zero, β integralSum_fiberwise fun J => N (Ο.tag J)]
grw [β hcΞ΅, β sum_le_hasSum _ (fun n _ => (Ξ΄ n).2) (NNReal.hasSum_coe.2 hΞ΄c)]
apply norm_sum_le_of_le
rintro n -
dsimp [integralSum]
have : β J β Ο.filter fun J => N (Ο.tag J) = n,
βΞΌ.real βJ β’ f (Ο.tag J)β β€ ΞΌ.real J * n := fun J hJ β¦ by
rw [TaggedPrepartition.mem_filter] at hJ
rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg measureReal_nonneg]
gcongr
exact hJ.2 βΈ Nat.le_ceil _
refine (norm_sum_le_of_le _ this).trans ?_; clear this
rw [β sum_mul, β Prepartition.measure_iUnion_toReal]
let m := ΞΌ (Ο.filter fun J => N (Ο.tag J) = n).iUnion
change m.toReal * βn β€ β(Ξ΄ n)
have : m < Ξ΄ n / n := by
simp only [Measure.restrict_apply (hUo _).measurableSet] at hΞΌU
refine (measure_mono ?_).trans_lt (hΞΌU _)
simp only [Set.subset_def, TaggedPrepartition.mem_iUnion, TaggedPrepartition.mem_filter]
rintro x β¨J, β¨hJ, rflβ©, hxβ©
exact β¨hrU _ (hΟ.1 _ hJ (Box.coe_subset_Icc hx)), Ο.le_of_mem' J hJ hxβ©
clear_value m
lift m to ββ₯0 using ne_top_of_lt this
grw [ENNReal.coe_toReal, β NNReal.coe_natCast, β NNReal.coe_mul, NNReal.coe_le_coe, β
ENNReal.coe_le_coe, ENNReal.coe_mul, ENNReal.coe_natCast, mul_comm, this, ENNReal.mul_div_le]
/-- If `f` has integral `y` on a box `I` with respect to a locally finite measure `ΞΌ` and `g` is
a.e. equal to `f` on `I`, then `g` has the same integral on `I`. -/
theorem HasIntegral.congr_ae {l : IntegrationParams} {I : Box ΞΉ} {y : E} {f g : (ΞΉ β β) β E}
{ΞΌ : Measure (ΞΉ β β)} [IsLocallyFiniteMeasure ΞΌ]
(hf : HasIntegral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul y) (hfg : f =α΅[ΞΌ.restrict I] g)
(hl : l.bRiemann = false) : HasIntegral.{u, v, v} I l g ΞΌ.toBoxAdditive.toSMul y := by
have : g - f =α΅[ΞΌ.restrict I] 0 := hfg.mono fun x hx => sub_eq_zero.2 hx.symm
simpa using hf.add (HasIntegral.of_aeEq_zero this hl)
end BoxIntegral
namespace MeasureTheory
namespace SimpleFunc
/-- A simple function is McShane integrable w.r.t. any locally finite measure. -/
theorem hasBoxIntegral (f : SimpleFunc (ΞΉ β β) E) (ΞΌ : Measure (ΞΉ β β)) [IsLocallyFiniteMeasure ΞΌ]
(I : Box ΞΉ) (l : IntegrationParams) (hl : l.bRiemann = false) :
HasIntegral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul (f.integral (ΞΌ.restrict I)) := by
induction f using MeasureTheory.SimpleFunc.induction with
| @const y s hs =>
simpa [hs] using BoxIntegral.hasIntegralIndicatorConst l hl hs I y ΞΌ
| @add f g _ hfi hgi =>
borelize E; haveI := Fact.mk (I.measure_coe_lt_top ΞΌ)
rw [integral_add]
exacts [hfi.add hgi, integrable_iff.2 fun _ _ => measure_lt_top _ _,
integrable_iff.2 fun _ _ => measure_lt_top _ _]
/-- For a simple function, its McShane (or Henstock, or `β₯`) box integral is equal to its
integral in the sense of `MeasureTheory.SimpleFunc.integral`. -/
theorem box_integral_eq_integral (f : SimpleFunc (ΞΉ β β) E) (ΞΌ : Measure (ΞΉ β β))
[IsLocallyFiniteMeasure ΞΌ] (I : Box ΞΉ) (l : IntegrationParams) (hl : l.bRiemann = false) :
BoxIntegral.integral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul = f.integral (ΞΌ.restrict I) :=
(f.hasBoxIntegral ΞΌ I l hl).integral_eq
end SimpleFunc
open TopologicalSpace
/-- If `f : ββΏ β E` is Bochner integrable w.r.t. a locally finite measure `ΞΌ` on a rectangular box
`I`, then it is McShane integrable on `I` with the same integral. -/
theorem IntegrableOn.hasBoxIntegral [CompleteSpace E] {f : (ΞΉ β β) β E} {ΞΌ : Measure (ΞΉ β β)}
[IsLocallyFiniteMeasure ΞΌ] {I : Box ΞΉ} (hf : IntegrableOn f I ΞΌ) (l : IntegrationParams)
(hl : l.bRiemann = false) :
HasIntegral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul (β« x in I, f x βΞΌ) := by
borelize E
-- First we replace an `ae_strongly_measurable` function by a measurable one.
rcases hf.aestronglyMeasurable with β¨g, hg, hfgβ©
haveI : SeparableSpace (range g βͺ {0} : Set E) := hg.separableSpace_range_union_singleton
rw [integral_congr_ae hfg]; have hgi : IntegrableOn g I ΞΌ := (integrable_congr hfg).1 hf
refine BoxIntegral.HasIntegral.congr_ae ?_ hfg.symm hl
clear! f
/- Now consider the sequence of simple functions
`SimpleFunc.approxOn g hg.measurable (range g βͺ {0}) 0 (by simp)`
approximating `g`. Recall some properties of this sequence. -/
set f : β β SimpleFunc (ΞΉ β β) E :=
SimpleFunc.approxOn g hg.measurable (range g βͺ {0}) 0 (by simp)
have hfi : β n, IntegrableOn (f n) I ΞΌ :=
SimpleFunc.integrable_approxOn_range hg.measurable hgi
have hfi' := fun n => ((f n).hasBoxIntegral ΞΌ I l hl).integrable
have hfg_mono : β (x) {m n}, m β€ n β βf n x - g xβ β€ βf m x - g xβ := by
intro x m n hmn
rw [β dist_eq_norm, β dist_eq_norm, dist_nndist, dist_nndist, NNReal.coe_le_coe, β
ENNReal.coe_le_coe, β edist_nndist, β edist_nndist]
exact SimpleFunc.edist_approxOn_mono hg.measurable _ x hmn
/- Now consider `Ξ΅ > 0`. We need to find `r` such that for any tagged partition subordinate
to `r`, the integral sum is `(ΞΌ I + 1 + 1) * Ξ΅`-close to the Bochner integral. -/
refine HasIntegral.of_mul (ΞΌ.real I + 1 + 1) fun Ξ΅ Ξ΅0 => ?_
lift Ξ΅ to ββ₯0 using Ξ΅0.le; rw [NNReal.coe_pos] at Ξ΅0; have Ξ΅0' := ENNReal.coe_pos.2 Ξ΅0
-- Choose `N` such that the integral of `βf N x - g xβ` is less than or equal to `Ξ΅`.
obtain β¨Nβ, hNββ© : β N : β, β« x in I, βf N x - g xβ βΞΌ β€ Ξ΅ := by
have : Tendsto (fun n => β«β» x in I, βf n x - g xββ βΞΌ) atTop (π 0) :=
SimpleFunc.tendsto_approxOn_range_L1_enorm hg.measurable hgi
refine (this.eventually (ge_mem_nhds Ξ΅0')).exists.imp fun N hN => ?_
exact integral_coe_le_of_lintegral_coe_le hN
-- For each `x`, we choose `Nx x β₯ Nβ` such that `dist (f Nx x) (g x) β€ Ξ΅`.
have : β x, β Nβ, Nβ β€ Nβ β§ dist (f Nβ x) (g x) β€ Ξ΅ := fun x β¦ by
have : Tendsto (f Β· x) atTop (π <| g x) :=
SimpleFunc.tendsto_approxOn hg.measurable _ (subset_closure (by simp))
exact ((eventually_ge_atTop Nβ).and <| this <| closedBall_mem_nhds _ Ξ΅0).exists
choose Nx hNx hNxΞ΅ using this
-- We also choose a convergent series with `β' i : β, Ξ΄ i < Ξ΅`.
rcases NNReal.exists_pos_sum_of_countable Ξ΅0.ne' β with β¨Ξ΄, Ξ΄0, c, hΞ΄c, hcΞ΅β©
/- Since each simple function `fα΅’` is integrable, there exists `rα΅’ : ββΏ β (0, β)` such that
the integral sum of `f` over any tagged prepartition is `Ξ΄α΅’`-close to the sum of integrals
of `fα΅’` over the boxes of this prepartition. For each `x`, we choose `r (Nx x)` as the radius
at `x`. -/
set r : ββ₯0 β (ΞΉ β β) β Ioi (0 : β) := fun c x => (hfi' <| Nx x).convergenceR (Ξ΄ <| Nx x) c x
refine β¨r, fun c => l.rCond_of_bRiemann_eq_false hl, fun c Ο hΟ hΟp => ?_β©
/- Now we prove the estimate in 3 "jumps": first we replace `g x` in the formula for the
integral sum by `f (Nx x)`; then we replace each `ΞΌ J β’ f (Nx (Ο.tag J)) (Ο.tag J)`
by the Bochner integral of `f (Nx (Ο.tag J)) x` over `J`, then we jump to the Bochner
integral of `g`. -/
refine (dist_triangle4 _ (β J β Ο.boxes, ΞΌ.real J β’ f (Nx <| Ο.tag J) (Ο.tag J))
(β J β Ο.boxes, β« x in J, f (Nx <| Ο.tag J) x βΞΌ) _).trans ?_
rw [add_mul, add_mul, one_mul]
refine add_le_add_three ?_ ?_ ?_
Β· /- Since each `f (Nx <| Ο.tag J)` is `Ξ΅`-close to `g (Ο.tag J)`, replacing the latter with
the former in the formula for the integral sum changes the sum at most by `ΞΌ I * Ξ΅`. -/
rw [β hΟp.iUnion_eq, Ο.measure_iUnion_toReal, sum_mul, integralSum]
refine dist_sum_sum_le_of_le _ fun J _ => ?_; dsimp
rw [dist_eq_norm, β smul_sub, norm_smul, Real.norm_eq_abs, abs_of_nonneg measureReal_nonneg]
gcongr
rw [β dist_eq_norm']; exact hNxΞ΅ _
Β· /- We group the terms of both sums by the values of `Nx (Ο.tag J)`.
For each `N`, the sum of Bochner integrals over the boxes is equal
to the sum of box integrals, and the sum of box integrals is `Ξ΄α΅’`-close
to the corresponding integral sum due to the Henstock-Sacks inequality. -/
rw [β Ο.sum_fiberwise fun J => Nx (Ο.tag J), β Ο.sum_fiberwise fun J => Nx (Ο.tag J)]
grw [β hcΞ΅]
refine
(dist_sum_sum_le_of_le _ fun n hn => ?_).trans
(sum_le_hasSum _ (fun n _ => (Ξ΄ n).2) (NNReal.hasSum_coe.2 hΞ΄c))
have hNxn : β J β Ο.filter fun J => Nx (Ο.tag J) = n, Nx (Ο.tag J) = n := fun J hJ =>
(Ο.mem_filter.1 hJ).2
have hrn : β J β Ο.filter fun J => Nx (Ο.tag J) = n,
r c (Ο.tag J) = (hfi' n).convergenceR (Ξ΄ n) c (Ο.tag J) := fun J hJ β¦ by
obtain rfl := hNxn J hJ
rfl
have :
l.MemBaseSet I c ((hfi' n).convergenceR (Ξ΄ n) c) (Ο.filter fun J => Nx (Ο.tag J) = n) :=
(hΟ.filter _).mono' _ le_rfl le_rfl fun J hJ => (hrn J hJ).le
convert (hfi' n).dist_integralSum_sum_integral_le_of_memBaseSet (Ξ΄0 _) this using 2
Β· refine sum_congr rfl fun J hJ => ?_
simp [hNxn J hJ]
Β· refine sum_congr rfl fun J hJ => ?_
rw [β SimpleFunc.integral_eq_integral, SimpleFunc.box_integral_eq_integral _ _ _ _ hl,
hNxn J hJ]
exact (hfi _).mono_set (Prepartition.le_of_mem _ hJ)
Β· /- For the last jump, we use the fact that the distance between `f (Nx x) x` and `g x` is less
than or equal to the distance between `f Nβ x` and `g x` and the integral of
`βf Nβ x - g xβ` is less than or equal to `Ξ΅`. -/
refine le_trans ?_ hNβ
have hfi : β (n), β J β Ο, IntegrableOn (f n) (βJ) ΞΌ := fun n J hJ =>
(hfi n).mono_set (Ο.le_of_mem' J hJ)
have hgi : β J β Ο, IntegrableOn g (βJ) ΞΌ := fun J hJ => hgi.mono_set (Ο.le_of_mem' J hJ)
have hfgi : β (n), β J β Ο, IntegrableOn (fun x => βf n x - g xβ) J ΞΌ := fun n J hJ =>
((hfi n J hJ).sub (hgi J hJ)).norm
rw [β hΟp.iUnion_eq, Prepartition.iUnion_def',
integral_biUnion_finset Ο.boxes (fun J _ => J.measurableSet_coe) Ο.pairwiseDisjoint hgi,
integral_biUnion_finset Ο.boxes (fun J _ => J.measurableSet_coe) Ο.pairwiseDisjoint (hfgi _)]
refine dist_sum_sum_le_of_le _ fun J hJ => ?_
rw [dist_eq_norm, β integral_sub (hfi _ J hJ) (hgi J hJ)]
refine norm_integral_le_of_norm_le (hfgi _ J hJ) (Eventually.of_forall fun x => ?_)
exact hfg_mono x (hNx (Ο.tag J))
/-- If `f : ββΏ β E` is continuous on a rectangular box `I`, then it is Box integrable on `I`
w.r.t. a locally finite measure `ΞΌ` with the same integral. -/
theorem ContinuousOn.hasBoxIntegral [CompleteSpace E] {f : (ΞΉ β β) β E} (ΞΌ : Measure (ΞΉ β β))
[IsLocallyFiniteMeasure ΞΌ] {I : Box ΞΉ} (hc : ContinuousOn f (Box.Icc I))
(l : IntegrationParams) :
HasIntegral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul (β« x in I, f x βΞΌ) := by
obtain β¨y, hyβ© := BoxIntegral.integrable_of_continuousOn l hc ΞΌ
convert hy
have : IntegrableOn f I ΞΌ :=
IntegrableOn.mono_set (hc.integrableOn_compact I.isCompact_Icc) Box.coe_subset_Icc
exact HasIntegral.unique (IntegrableOn.hasBoxIntegral this β₯ rfl) (HasIntegral.mono hy bot_le)
/-- If `f : ββΏ β E` is a.e. continuous and bounded on a rectangular box `I`, then it is Box
integrable on `I` w.r.t. a locally finite measure `ΞΌ` with the same integral. -/
theorem AEContinuous.hasBoxIntegral [CompleteSpace E] {f : (ΞΉ β β) β E} (ΞΌ : Measure (ΞΉ β β))
[IsLocallyFiniteMeasure ΞΌ] {I : Box ΞΉ} (hb : β C : β, β x β Box.Icc I, βf xβ β€ C)
(hc : βα΅ x βΞΌ, ContinuousAt f x) (l : IntegrationParams) :
HasIntegral.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul (β« x in I, f x βΞΌ) := by
obtain β¨y, hyβ© := integrable_of_bounded_and_ae_continuous l hb ΞΌ hc
convert hy
refine HasIntegral.unique (IntegrableOn.hasBoxIntegral ?_ β₯ rfl) (HasIntegral.mono hy bot_le)
constructor
Β· let v := {x : (ΞΉ β β) | ContinuousAt f x}
have : AEStronglyMeasurable f (ΞΌ.restrict v) :=
(continuousOn_of_forall_continuousAt fun _ h β¦ h).aestronglyMeasurable
(measurableSet_of_continuousAt f)
refine this.mono_measure (Measure.le_iff.2 fun s hs β¦ ?_)
repeat rw [ΞΌ.restrict_apply hs]
apply le_of_le_of_eq <| ΞΌ.mono s.inter_subset_left
refine measure_eq_measure_of_null_diff s.inter_subset_left ?_ |>.symm
rw [diff_self_inter, Set.diff_eq]
refine (le_antisymm (zero_le (ΞΌ (s β© vαΆ))) ?_).symm
exact le_trans (ΞΌ.mono s.inter_subset_right) (nonpos_iff_eq_zero.2 hc)
Β· have : IsFiniteMeasure (ΞΌ.restrict (Box.Icc I)) :=
{ measure_univ_lt_top := by simp [I.isCompact_Icc.measure_lt_top (ΞΌ := ΞΌ)] }
have : IsFiniteMeasure (ΞΌ.restrict I) :=
isFiniteMeasure_of_le (ΞΌ.restrict (Box.Icc I))
(ΞΌ.restrict_mono Box.coe_subset_Icc (le_refl ΞΌ))
obtain β¨C, hCβ© := hb
refine .of_bounded (C := C) (Filter.eventually_iff_exists_mem.2 ?_)
use I, self_mem_ae_restrict I.measurableSet_coe, fun y hy β¦ hC y (I.coe_subset_Icc hy)
end MeasureTheory |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/UnitPartition.lean | import Mathlib.Algebra.Module.ZLattice.Basic
import Mathlib.Analysis.BoxIntegral.Integrability
import Mathlib.Analysis.BoxIntegral.Partition.Measure
import Mathlib.Analysis.BoxIntegral.Partition.Tagged
/-!
# Unit Partition
Fix `n` a positive integer. `BoxIntegral.unitPartition.box` are boxes in `ΞΉ β β` obtained by
dividing the unit box uniformly into boxes of side length `1 / n` and translating the boxes by
vectors `Ξ½ : ΞΉ β β€`.
Let `B` be a `BoxIntegral`. A `unitPartition.box` is admissible for `B` (more precisely its index is
admissible) if it is contained in `B`. There are finitely many admissible `unitPartition.box` for
`B` and thus we can form the corresponding tagged prepartition, see
`BoxIntegral.unitPartition.prepartition` (note that each `unitPartition.box` comes with its
tag situated at its "upper most" vertex). If `B` satisfies `hasIntegralVertices`, that
is its vertices are in `ΞΉ β β€`, then the corresponding prepartition is actually a partition.
## Main definitions and results
* `BoxIntegral.hasIntegralVertices`: a `Prop` that states that the vertices of the box have
coordinates in `β€`
* `BoxIntegral.unitPartition.box`: a `BoxIntegral`, indexed by `Ξ½ : ΞΉ β β€`, with vertices
`Ξ½ i / n` and of side length `1 / n`.
* `BoxIntegral.unitPartition.admissibleIndex`: For `B : BoxIntegral.Box`, the set of indices of
`unitPartition.box` that are subsets of `B`. This is a finite set.
* `BoxIntegral.unitPartition.prepartition_isPartition`: For `B : BoxIntegral.Box`, if `B`
has integral vertices, then the prepartition of `unitPartition.box` admissible for `B` is a
partition of `B`.
* `tendsto_tsum_div_pow_atTop_integral`: let `s` be a bounded, measurable set of `ΞΉ β β`
whose frontier has zero volume and let `F` be a continuous function. Then the limit as `n β β`
of `β F x / n ^ card ΞΉ`, where the sum is over the points in `s β© nβ»ΒΉ β’ (ΞΉ β β€)`, tends to the
integral of `F` over `s`.
* `tendsto_card_div_pow_atTop_volume`: let `s` be a bounded, measurable set of `ΞΉ β β` whose
frontier has zero volume. Then the limit as `n β β` of `card (s β© nβ»ΒΉ β’ (ΞΉ β β€)) / n ^ card ΞΉ`
tends to the volume of `s`.
* `tendsto_card_div_pow_atTop_volume'`: a version of `tendsto_card_div_pow_atTop_volume` where we
assume in addition that `x β’ s β y β’ s` whenever `0 < x β€ y`. Then we get the same limit
`card (s β© xβ»ΒΉ β’ (ΞΉ β β€)) / x ^ card ΞΉ β volume s` but the limit is over a real variable `x`.
-/
noncomputable section
variable {ΞΉ : Type*}
open scoped Topology
section hasIntegralVertices
open Bornology
/-- A `BoxIntegral.Box` has integral vertices if its vertices have coordinates in `β€`. -/
def BoxIntegral.hasIntegralVertices (B : Box ΞΉ) : Prop :=
β l u : ΞΉ β β€, (β i, B.lower i = l i) β§ (β i, B.upper i = u i)
/-- Any bounded set is contained in a `BoxIntegral.Box` with integral vertices. -/
theorem BoxIntegral.le_hasIntegralVertices_of_isBounded [Finite ΞΉ] {s : Set (ΞΉ β β)}
(h : IsBounded s) :
β B : BoxIntegral.Box ΞΉ, hasIntegralVertices B β§ s β€ B := by
have := Fintype.ofFinite ΞΉ
obtain β¨R, hRβ, hRββ© := IsBounded.subset_ball_lt h 0 0
let C : β := βRββ
have hC := Nat.ceil_pos.mpr hRβ
let I : Box ΞΉ := Box.mk (fun _ β¦ - C) (fun _ β¦ C )
(fun _ β¦ by simp [C, neg_lt_self_iff, Nat.cast_pos, hC])
refine β¨I, β¨fun _ β¦ - C, fun _ β¦ C, fun i β¦ (Int.cast_neg_natCast C).symm, fun _ β¦ rflβ©,
le_trans hRβ ?_β©
suffices Metric.ball (0 : ΞΉ β β) C β€ I from
le_trans (Metric.ball_subset_ball (Nat.le_ceil R)) this
intro x hx
simp_rw [C, mem_ball_zero_iff, pi_norm_lt_iff (Nat.cast_pos.mpr hC),
Real.norm_eq_abs, abs_lt] at hx
exact fun i β¦ β¨(hx i).1, le_of_lt (hx i).2β©
end hasIntegralVertices
namespace BoxIntegral.unitPartition
open Bornology MeasureTheory Fintype BoxIntegral
variable (n : β)
/-- A `BoxIntegral`, indexed by a positive integer `n` and `Ξ½ : ΞΉ β β€`, with corners `Ξ½ i / n`
and of side length `1 / n`. -/
def box [NeZero n] (Ξ½ : ΞΉ β β€) : Box ΞΉ where
lower := fun i β¦ Ξ½ i / n
upper := fun i β¦ (Ξ½ i + 1) / n
lower_lt_upper := fun _ β¦ by simp [add_div, n.pos_of_neZero]
@[simp]
theorem box_lower [NeZero n] (Ξ½ : ΞΉ β β€) :
(box n Ξ½).lower = fun i β¦ (Ξ½ i / n : β) := rfl
@[simp]
theorem box_upper [NeZero n] (Ξ½ : ΞΉ β β€) :
(box n Ξ½).upper = fun i β¦ ((Ξ½ i + 1) / n : β) := rfl
variable {n} in
@[simp]
theorem mem_box_iff [NeZero n] {Ξ½ : ΞΉ β β€} {x : ΞΉ β β} :
x β box n Ξ½ β β i, Ξ½ i / n < x i β§ x i β€ (Ξ½ i + 1) / n := by
simp_rw [Box.mem_def, box, Set.mem_Ioc]
variable {n} in
theorem mem_box_iff' [NeZero n] {Ξ½ : ΞΉ β β€} {x : ΞΉ β β} :
x β box n Ξ½ β β i, Ξ½ i < n * x i β§ n * x i β€ Ξ½ i + 1 := by
have h : 0 < (n : β) := Nat.cast_pos.mpr <| n.pos_of_neZero
simp_rw [mem_box_iff, β _root_.le_div_iffβ' h, β div_lt_iffβ' h]
/-- The tag of (the index of) a `unitPartition.box`. -/
abbrev tag (Ξ½ : ΞΉ β β€) : ΞΉ β β := fun i β¦ (Ξ½ i + 1) / n
@[simp]
theorem tag_apply (Ξ½ : ΞΉ β β€) (i : ΞΉ) : tag n Ξ½ i = (Ξ½ i + 1) / n := rfl
variable [NeZero n]
theorem tag_injective : Function.Injective (fun Ξ½ : ΞΉ β β€ β¦ tag n Ξ½) := by
refine fun _ _ h β¦ funext_iff.mpr fun i β¦ ?_
have := congr_arg (fun x β¦ x i) h
simp_rw [tag_apply, div_left_inj' (c := (n : β)) (Nat.cast_ne_zero.mpr (NeZero.ne n)),
add_left_inj, Int.cast_inj] at this
exact this
theorem tag_mem (Ξ½ : ΞΉ β β€) :
tag n Ξ½ β box n Ξ½ := by
refine mem_box_iff.mpr fun _ β¦ ?_
rw [tag, add_div]
have h : 0 < (n : β) := Nat.cast_pos.mpr <| n.pos_of_neZero
exact β¨lt_add_of_pos_right _ (by positivity), le_rflβ©
/-- For `x : ΞΉ β β`, its index is the index of the unique `unitPartition.box` to which
it belongs. -/
def index (x : ΞΉ β β) (i : ΞΉ) : β€ := βn * x iβ - 1
@[simp]
theorem index_apply (m : β) {x : ΞΉ β β} (i : ΞΉ) :
index m x i = βm * x iβ - 1 := rfl
variable {n} in
theorem mem_box_iff_index {x : ΞΉ β β} {Ξ½ : ΞΉ β β€} :
x β box n Ξ½ β index n x = Ξ½ := by
simp_rw [mem_box_iff', funext_iff, index_apply, sub_eq_iff_eq_add, Int.ceil_eq_iff,
Int.cast_add, Int.cast_one, add_sub_cancel_right]
@[simp]
theorem index_tag (Ξ½ : ΞΉ β β€) :
index n (tag n Ξ½) = Ξ½ := mem_box_iff_index.mp (tag_mem n Ξ½)
variable {n} in
theorem disjoint {Ξ½ Ξ½' : ΞΉ β β€} :
Ξ½ β Ξ½' β Disjoint (box n Ξ½).toSet (box n Ξ½').toSet := by
rw [not_iff_comm, Set.not_disjoint_iff]
refine β¨fun β¨x, hx, hx'β© β¦ ?_, fun h β¦ β¨tag n Ξ½, tag_mem n Ξ½, h βΈ tag_mem n Ξ½β©β©
rw [β mem_box_iff_index.mp hx, β mem_box_iff_index.mp hx']
theorem box_injective : Function.Injective (fun Ξ½ : ΞΉ β β€ β¦ box n Ξ½) := by
intro _ _ h
contrapose! h
exact Box.ne_of_disjoint_coe (disjoint.mp h)
lemma box.upper_sub_lower (Ξ½ : ΞΉ β β€) (i : ΞΉ) :
(box n Ξ½ ).upper i - (box n Ξ½).lower i = 1 / n := by
simp_rw [box, add_div, add_sub_cancel_left]
variable [Fintype ΞΉ]
theorem diam_boxIcc (Ξ½ : ΞΉ β β€) :
Metric.diam (Box.Icc (box n Ξ½)) β€ 1 / n := by
rw [BoxIntegral.Box.Icc_eq_pi]
refine ENNReal.toReal_le_of_le_ofReal (by positivity) <| EMetric.diam_pi_le_of_le (fun i β¦ ?_)
simp_rw [Real.ediam_Icc, box.upper_sub_lower, le_rfl]
@[simp]
theorem volume_box (Ξ½ : ΞΉ β β€) :
volume (box n Ξ½ : Set (ΞΉ β β)) = 1 / n ^ card ΞΉ := by
simp_rw [volume_pi, BoxIntegral.Box.coe_eq_pi, Measure.pi_pi, Real.volume_Ioc,
box.upper_sub_lower, Finset.prod_const, ENNReal.ofReal_div_of_pos (Nat.cast_pos.mpr
n.pos_of_neZero), ENNReal.ofReal_one, ENNReal.ofReal_natCast, one_div, ENNReal.inv_pow,
Finset.card_univ]
theorem setFinite_index {s : Set (ΞΉ β β)} (hsβ : NullMeasurableSet s) (hsβ : volume s β β€) :
Set.Finite {Ξ½ : ΞΉ β β€ | β(box n Ξ½) β s} := by
refine (Measure.finite_const_le_meas_of_disjoint_iUnionβ volume (Ξ΅ := 1 / n ^ card ΞΉ)
(by simp) (As := fun Ξ½ : ΞΉ β β€ β¦ (box n Ξ½) β© s) (fun Ξ½ β¦ ?_) (fun _ _ h β¦ ?_) ?_).subset
(fun _ hΞ½ β¦ ?_)
Β· refine NullMeasurableSet.inter ?_ hsβ
exact (box n Ξ½).measurableSet_coe.nullMeasurableSet
Β· exact ((Disjoint.inter_right _ (disjoint.mp h)).inter_left _ ).aedisjoint
Β· exact lt_top_iff_ne_top.mp <| measure_lt_top_of_subset
(by simp only [Set.iUnion_subset_iff, Set.inter_subset_right, implies_true]) hsβ
Β· rw [Set.mem_setOf, Set.inter_eq_self_of_subset_left hΞ½, volume_box]
/-- For `B : BoxIntegral.Box`, the set of indices of `unitPartition.box` that are subsets of `B`.
This is a finite set. These boxes cover `B` if it has integral vertices, see
`unitPartition.prepartition_isPartition`. -/
def admissibleIndex (B : Box ΞΉ) : Finset (ΞΉ β β€) := by
refine (setFinite_index n B.measurableSet_coe.nullMeasurableSet ?_).toFinset
exact lt_top_iff_ne_top.mp (IsBounded.measure_lt_top B.isBounded)
variable {n} in
theorem mem_admissibleIndex_iff {B : Box ΞΉ} {Ξ½ : ΞΉ β β€} :
Ξ½ β admissibleIndex n B β box n Ξ½ β€ B := by
rw [admissibleIndex, Set.Finite.mem_toFinset, Set.mem_setOf_eq, Box.coe_subset_coe]
open Classical in
/-- For `B : BoxIntegral.Box`, the `TaggedPrepartition` formed by the set of all
`unitPartition.box` whose index is `B`-admissible. -/
def prepartition (B : Box ΞΉ) : TaggedPrepartition B where
boxes := Finset.image (fun Ξ½ β¦ box n Ξ½) (admissibleIndex n B)
le_of_mem' _ hI := by
obtain β¨_, hΞ½, rflβ© := Finset.mem_image.mp hI
exact mem_admissibleIndex_iff.mp hΞ½
pairwiseDisjoint _ hIβ _ hIβ h := by
obtain β¨_, _, rflβ© := Finset.mem_image.mp hIβ
obtain β¨_, _, rflβ© := Finset.mem_image.mp hIβ
exact disjoint.mp fun x β¦ h (congrArg (box n) x)
tag I :=
if hI : β Ξ½ β admissibleIndex n B, I = box n Ξ½ then tag n hI.choose else B.exists_mem.choose
tag_mem_Icc I := by
by_cases hI : β Ξ½ β admissibleIndex n B, I = box n Ξ½
Β· simp_rw [dif_pos hI]
exact Box.coe_subset_Icc <| (mem_admissibleIndex_iff.mp hI.choose_spec.1) (tag_mem n _)
Β· simp_rw [dif_neg hI]
exact Box.coe_subset_Icc B.exists_mem.choose_spec
variable {n} in
@[simp]
theorem mem_prepartition_iff {B I : Box ΞΉ} :
I β prepartition n B β β Ξ½ β admissibleIndex n B, box n Ξ½ = I := by
classical
rw [prepartition, TaggedPrepartition.mem_mk, Prepartition.mem_mk, Finset.mem_image]
variable {n} in
theorem mem_prepartition_boxes_iff {B I : Box ΞΉ} :
I β (prepartition n B).boxes β β Ξ½ β admissibleIndex n B, box n Ξ½ = I :=
mem_prepartition_iff
theorem prepartition_tag {Ξ½ : ΞΉ β β€} {B : Box ΞΉ} (hΞ½ : Ξ½ β admissibleIndex n B) :
(prepartition n B).tag (box n Ξ½) = tag n Ξ½ := by
dsimp only [prepartition]
have h : β Ξ½' β admissibleIndex n B, box n Ξ½ = box n Ξ½' := β¨Ξ½, hΞ½, rflβ©
rw [dif_pos h, (tag_injective n).eq_iff, β (box_injective n).eq_iff]
exact h.choose_spec.2.symm
theorem box_index_tag_eq_self {B I : Box ΞΉ} (hI : I β (prepartition n B).boxes) :
box n (index n ((prepartition n B).tag I)) = I := by
obtain β¨Ξ½, hΞ½, rflβ© := mem_prepartition_boxes_iff.mp hI
rw [prepartition_tag n hΞ½, index_tag]
theorem prepartition_isHenstock (B : Box ΞΉ) :
(prepartition n B).IsHenstock := by
intro _ hI
obtain β¨Ξ½, hΞ½, rflβ© := mem_prepartition_iff.mp hI
rw [prepartition_tag n hΞ½]
exact Box.coe_subset_Icc (tag_mem _ _)
theorem prepartition_isSubordinate (B : Box ΞΉ) {r : β} (hr : 0 < r) (hn : 1 / n β€ r) :
(prepartition n B).IsSubordinate (fun _ β¦ β¨r, hrβ©) := by
intro _ hI
obtain β¨Ξ½, hΞ½, rflβ© := mem_prepartition_iff.mp hI
refine fun _ h β¦ le_trans (Metric.dist_le_diam_of_mem (Box.isBounded_Icc _) h ?_) ?_
Β· rw [prepartition_tag n hΞ½]
exact Box.coe_subset_Icc (tag_mem _ _)
Β· exact le_trans (diam_boxIcc n Ξ½) hn
private theorem mem_admissibleIndex_of_mem_box_auxβ (x : β) (a : β€) :
a < x β a β€ (βn * xβ - 1) / (n : β) := by
have h : 0 < (n : β) := Nat.cast_pos.mpr <| n.pos_of_neZero
rw [le_div_iffβ' h, le_sub_iff_add_le,
show (n : β) * a + 1 = (n * a + 1 : β€) by norm_cast,
Int.cast_le, Int.add_one_le_ceil_iff, Int.cast_mul, Int.cast_natCast, mul_lt_mul_iff_rightβ h]
private theorem mem_admissibleIndex_of_mem_box_auxβ (x : β) (a : β€) :
x β€ a β (βn * xβ - 1 + 1) / (n : β) β€ a := by
have h : 0 < (n : β) := Nat.cast_pos.mpr <| n.pos_of_neZero
rw [sub_add_cancel, div_le_iffβ' h,
show (n : β) * a = (n * a : β€) by norm_cast,
Int.cast_le, Int.ceil_le, Int.cast_mul, Int.cast_natCast, mul_le_mul_iff_rightβ h]
/-- If `B : BoxIntegral.Box` has integral vertices and contains the point `x`, then the index of
`x` is admissible for `B`. -/
theorem mem_admissibleIndex_of_mem_box {B : Box ΞΉ} (hB : hasIntegralVertices B) {x : ΞΉ β β}
(hx : x β B) : index n x β admissibleIndex n B := by
obtain β¨l, u, hl, huβ© := hB
simp_rw [mem_admissibleIndex_iff, Box.le_iff_bounds, box_lower, box_upper, Pi.le_def,
index_apply, hl, hu, β forall_and]
push_cast
refine fun i β¦ β¨?_, ?_β©
Β· exact (mem_admissibleIndex_of_mem_box_auxβ n (x i) (l i)).mp ((hl i) βΈ (hx i).1)
Β· exact (mem_admissibleIndex_of_mem_box_auxβ n (x i) (u i)).mp ((hu i) βΈ (hx i).2)
/-- If `B : BoxIntegral.Box` has integral vertices, then `prepartition n B` is a partition of
`B`. -/
theorem prepartition_isPartition {B : Box ΞΉ} (hB : hasIntegralVertices B) :
(prepartition n B).IsPartition := by
refine fun x hx β¦ β¨box n (index n x), ?_, mem_box_iff_index.mpr rflβ©
rw [TaggedPrepartition.mem_toPrepartition, mem_prepartition_iff]
exact β¨index n x, mem_admissibleIndex_of_mem_box n hB hx, rflβ©
open Submodule Pointwise BigOperators
open scoped Pointwise
variable (c : β) (s : Set (ΞΉ β β)) (F : (ΞΉ β β) β β)
-- The image of `ΞΉ β β€` inside `ΞΉ β β`
local notation "L" => span β€ (Set.range (Pi.basisFun β ΞΉ))
variable {n} in
theorem mem_smul_span_iff {v : ΞΉ β β} :
v β (n : β)β»ΒΉ β’ L β β i, n * v i β Set.range (algebraMap β€ β) := by
rw [ZSpan.smul _ (inv_ne_zero (NeZero.ne _)), Module.Basis.mem_span_iff_repr_mem]
simp_rw [Module.Basis.repr_isUnitSMul, Pi.basisFun_repr, Units.smul_def, Units.val_inv_eq_inv_val,
IsUnit.unit_spec, inv_inv, smul_eq_mul]
theorem tag_mem_smul_span (Ξ½ : ΞΉ β β€) :
tag n Ξ½ β (n : β)β»ΒΉ β’ L := by
refine mem_smul_span_iff.mpr fun i β¦ β¨Ξ½ i + 1, ?_β©
rw [tag_apply, div_eq_inv_mul, β mul_assoc, mul_inv_cancel_of_invertible, one_mul, map_add,
map_one, eq_intCast]
theorem tag_index_eq_self_of_mem_smul_span {x : ΞΉ β β} (hx : x β (n : β)β»ΒΉ β’ L) :
tag n (index n x) = x := by
rw [mem_smul_span_iff] at hx
ext i
obtain β¨a, haβ© : β a : β€, a = n * x i := hx i
rwa [tag_apply, index_apply, Int.cast_sub, Int.cast_one, sub_add_cancel, β ha, Int.ceil_intCast,
div_eq_iff (NeZero.ne _), mul_comm]
theorem eq_of_mem_smul_span_of_index_eq_index {x y : ΞΉ β β} (hx : x β (n : β)β»ΒΉ β’ L)
(hy : y β (n : β)β»ΒΉ β’ L) (h : index n x = index n y) : x = y := by
rw [β tag_index_eq_self_of_mem_smul_span n hx, β tag_index_eq_self_of_mem_smul_span n hy, h]
theorem integralSum_eq_tsum_div {B : Box ΞΉ} (hB : hasIntegralVertices B) (hsβ : s β€ B) :
integralSum (Set.indicator s F) (BoxAdditiveMap.toSMul (Measure.toBoxAdditive volume))
(prepartition n B) = (β' x : β(s β© (n : β)β»ΒΉ β’ L), F x) / n ^ card ΞΉ := by
classical
unfold integralSum
have : Fintype β(s β© (n : β)β»ΒΉ β’ L) := by
apply Set.Finite.fintype
rw [β coe_pointwise_smul, ZSpan.smul _ (inv_ne_zero (NeZero.ne _))]
exact ZSpan.setFinite_inter _ (B.isBounded.subset hsβ)
rw [tsum_fintype, Finset.sum_set_coe, Finset.sum_div, eq_comm]
simp_rw [Set.indicator_apply, apply_ite, BoxAdditiveMap.toSMul_apply, Measure.toBoxAdditive_apply,
smul_eq_mul, mul_zero, Finset.sum_ite, Finset.sum_const_zero, add_zero]
refine Finset.sum_bij (fun x _ β¦ box n (index n x)) (fun _ hx β¦ Finset.mem_filter.mpr ?_)
(fun _ hx _ hy h β¦ ?_) (fun I hI β¦ ?_) (fun _ hx β¦ ?_)
Β· rw [Set.mem_toFinset] at hx
refine β¨mem_prepartition_boxes_iff.mpr
β¨index n _, mem_admissibleIndex_of_mem_box n hB (hsβ hx.1), rflβ©, ?_β©
simp_rw [prepartition_tag n (mem_admissibleIndex_of_mem_box n hB (hsβ hx.1)),
tag_index_eq_self_of_mem_smul_span n hx.2, hx.1]
Β· rw [Set.mem_toFinset] at hx hy
exact eq_of_mem_smul_span_of_index_eq_index n hx.2 hy.2 (box_injective n h)
Β· rw [Finset.mem_filter] at hI
refine β¨(prepartition n B).tag I, Set.mem_toFinset.mpr β¨hI.2, ?_β©, box_index_tag_eq_self n hI.1β©
rw [β box_index_tag_eq_self n hI.1, prepartition_tag n
(mem_admissibleIndex_of_mem_box n hB (hsβ hI.2))]
exact tag_mem_smul_span _ _
Β· rw [Set.mem_toFinset] at hx
rw [measureReal_def, volume_box,
prepartition_tag n (mem_admissibleIndex_of_mem_box n hB (hsβ hx.1)),
tag_index_eq_self_of_mem_smul_span n hx.2, ENNReal.toReal_div,
ENNReal.toReal_one, ENNReal.toReal_pow, ENNReal.toReal_natCast, mul_comm_div, one_mul]
open Filter
/-- Let `s` be a bounded, measurable set of `ΞΉ β β` whose frontier has zero volume and let `F`
be a continuous function. Then the limit as `n β β` of `β F x / n ^ card ΞΉ`, where the sum is
over the points in `s β© nβ»ΒΉ β’ (ΞΉ β β€)`, tends to the integral of `F` over `s`. -/
theorem _root_.tendsto_tsum_div_pow_atTop_integral (hF : Continuous F) (hsβ : IsBounded s)
(hsβ : MeasurableSet s) (hsβ : volume (frontier s) = 0) :
Tendsto (fun n : β β¦ (β' x : β(s β© (n : β)β»ΒΉ β’ L), F x) / n ^ card ΞΉ)
atTop (nhds (β« x in s, F x)) := by
obtain β¨B, hB, hsββ© := le_hasIntegralVertices_of_isBounded hsβ
refine Metric.tendsto_atTop.mpr fun Ξ΅ hΞ΅ β¦ ?_
have hβ : β C, β x β Box.Icc B, βSet.indicator s F xβ β€ C := by
obtain β¨Cβ, hββ© := (Box.isCompact_Icc B).exists_bound_of_continuousOn hF.continuousOn
refine β¨max 0 Cβ, fun x hx β¦ ?_β©
rw [Set.indicator]
split_ifs with hs
Β· exact le_max_of_le_right (hβ x hx)
Β· exact norm_zero.trans_le <|le_max_left 0 _
have hβ : βα΅ x, ContinuousAt (s.indicator F) x := by
filter_upwards [compl_mem_ae_iff.mpr hsβ] with _ h
using (hF.continuousOn).continuousAt_indicator h
obtain β¨r, hrβ, hrββ© := (hasIntegral_iff.mp <|
AEContinuous.hasBoxIntegral (volume : Measure (ΞΉ β β)) hβ hβ
IntegrationParams.Riemann) (Ξ΅ / 2) (half_pos hΞ΅)
refine β¨β(r 0 0 : β)β»ΒΉββ, fun n hn β¦ lt_of_le_of_lt ?_ (half_lt_self_iff.mpr hΞ΅)β©
have : NeZero n :=
β¨Nat.ne_zero_iff_zero_lt.mpr <| (Nat.ceil_pos.mpr (inv_pos.mpr (r 0 0).prop)).trans_le hnβ©
rw [β integralSum_eq_tsum_div _ s F hB hsβ, β Measure.restrict_restrict_of_subset hsβ,
β integral_indicator hsβ]
refine hrβ 0 _ β¨?_, fun _ β¦ ?_, fun h β¦ ?_, fun h β¦ ?_β© (prepartition_isPartition _ hB)
Β· rw [show r 0 = fun _ β¦ r 0 0 from funext_iff.mpr (hrβ 0 rfl)]
apply prepartition_isSubordinate n B
rw [one_div, inv_le_commβ (mod_cast (Nat.pos_of_neZero n)) (r 0 0).prop]
exact le_trans (Nat.le_ceil _) (Nat.cast_le.mpr hn)
Β· exact prepartition_isHenstock n B
Β· simp only [IntegrationParams.Riemann, Bool.false_eq_true] at h
Β· simp only [IntegrationParams.Riemann, Bool.false_eq_true] at h
/-- Let `s` be a bounded, measurable set of `ΞΉ β β` whose frontier has zero volume. Then the limit
as `n β β` of `card (s β© nβ»ΒΉ β’ (ΞΉ β β€)) / n ^ card ΞΉ` tends to the volume of `s`. This is a
special case of `tendsto_card_div_pow` with `F = 1`. -/
theorem _root_.tendsto_card_div_pow_atTop_volume (hsβ : IsBounded s)
(hsβ : MeasurableSet s) (hsβ : volume (frontier s) = 0) :
Tendsto (fun n : β β¦ (Nat.card β(s β© (n : β)β»ΒΉ β’ L) : β) / n ^ card ΞΉ)
atTop (π (volume.real s)) := by
convert tendsto_tsum_div_pow_atTop_integral s (fun _ β¦ 1) continuous_const hsβ hsβ hsβ
Β· rw [tsum_const, nsmul_eq_mul, mul_one, Nat.cast_inj]
Β· rw [setIntegral_const, smul_eq_mul, mul_one]
private def tendsto_card_div_powβ {c : β} (hc : c β 0) :
β(s β© cβ»ΒΉ β’ L) β β(c β’ s β© L) :=
Equiv.subtypeEquiv (Equiv.smulRight hc) (fun x β¦ by
simp_rw [Set.mem_inter_iff, Equiv.smulRight_apply, Set.smul_mem_smul_set_iffβ hc,
β Set.mem_inv_smul_set_iffβ hc])
private theorem tendsto_card_div_powβ (hsβ : IsBounded s)
(hsβ : β β¦x y : ββ¦, 0 < x β x β€ y β x β’ s β y β’ s) {x y : β} (hx : 0 < x) (hy : x β€ y) :
Nat.card β(s β© xβ»ΒΉ β’ L) β€ Nat.card β(s β© yβ»ΒΉ β’ L) := by
rw [Nat.card_congr (tendsto_card_div_powβ s hx.ne'),
Nat.card_congr (tendsto_card_div_powβ s (hx.trans_le hy).ne')]
refine Nat.card_mono ?_ ?_
Β· exact ZSpan.setFinite_inter _ (IsBounded.smulβ hsβ y)
Β· exact Set.inter_subset_inter_left _ <| hsβ hx hy
private theorem tendsto_card_div_powβ (hsβ : IsBounded s)
(hsβ : β β¦x y : ββ¦, 0 < x β x β€ y β x β’ s β y β’ s) :
βαΆ x : β in atTop, (Nat.card β(s β© (βxββ : β)β»ΒΉ β’ L) : β) / x ^ card ΞΉ β€
(Nat.card β(s β© xβ»ΒΉ β’ L) : β) / x ^ card ΞΉ := by
filter_upwards [eventually_ge_atTop 1] with x hx
gcongr
exact tendsto_card_div_powβ s hsβ hsβ (Nat.cast_pos.mpr (Nat.floor_pos.mpr hx))
(Nat.floor_le (zero_le_one.trans hx))
private theorem tendsto_card_div_powβ (hsβ : IsBounded s)
(hsβ : β β¦x y : ββ¦, 0 < x β x β€ y β x β’ s β y β’ s) :
βαΆ x : β in atTop, (Nat.card β(s β© xβ»ΒΉ β’ L) : β) / x ^ card ΞΉ β€
(Nat.card β(s β© (βxββ : β)β»ΒΉ β’ L) : β) / x ^ card ΞΉ := by
filter_upwards [eventually_gt_atTop 0] with x hx
gcongr
exact tendsto_card_div_powβ s hsβ hsβ hx (Nat.le_ceil _)
private theorem tendsto_card_div_powβ
:
(fun x β¦ (Nat.card β(s β© (βxββ : β)β»ΒΉ β’ L) : β) / βxββ ^ card ΞΉ * (βxββ / x) ^ card ΞΉ)
=αΆ [atTop] (fun x β¦ (Nat.card β(s β© (βxββ : β)β»ΒΉ β’ L) : β) / x ^ card ΞΉ) := by
filter_upwards [eventually_ge_atTop 1] with x hx
have : 0 < βxββ := Nat.floor_pos.mpr hx
rw [div_pow, mul_div, div_mul_cancelβ _ (by positivity)]
private theorem tendsto_card_div_powβ :
(fun x β¦ (Nat.card β(s β© (βxββ : β)β»ΒΉ β’ L) : β) / βxββ ^ card ΞΉ * (βxββ / x) ^ card ΞΉ)
=αΆ [atTop] (fun x β¦ (Nat.card β(s β© (βxββ : β)β»ΒΉ β’ L) : β) / x ^ card ΞΉ) := by
filter_upwards [eventually_ge_atTop 1] with x hx
rw [div_pow, mul_div, div_mul_cancelβ _ (by positivity)]
/-- A version of `tendsto_card_div_pow_atTop_volume` for a real variable. -/
theorem _root_.tendsto_card_div_pow_atTop_volume' (hsβ : IsBounded s)
(hsβ : MeasurableSet s) (hsβ : volume (frontier s) = 0)
(hsβ : β β¦x y : ββ¦, 0 < x β x β€ y β x β’ s β y β’ s) :
Tendsto (fun x : β β¦ (Nat.card β(s β© xβ»ΒΉ β’ L) : β) / x ^ card ΞΉ)
atTop (π (volume.real s)) := by
rw [show volume.real s = volume.real s * 1 ^ card ΞΉ by ring]
refine tendsto_of_tendsto_of_tendsto_of_le_of_le' ?_ ?_
(tendsto_card_div_powβ s hsβ hsβ) (tendsto_card_div_powβ s hsβ hsβ)
Β· refine Tendsto.congr' (tendsto_card_div_powβ
s) (Tendsto.mul ?_ (Tendsto.pow ?_ _))
Β· exact Tendsto.comp (tendsto_card_div_pow_atTop_volume s hsβ hsβ hsβ) tendsto_nat_floor_atTop
Β· exact tendsto_nat_floor_div_atTop
Β· refine Tendsto.congr' (tendsto_card_div_powβ s) (Tendsto.mul ?_ (Tendsto.pow ?_ _))
Β· exact Tendsto.comp (tendsto_card_div_pow_atTop_volume s hsβ hsβ hsβ) tendsto_nat_ceil_atTop
Β· exact tendsto_nat_ceil_div_atTop
end BoxIntegral.unitPartition |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Basic.lean | import Mathlib.Analysis.BoxIntegral.Partition.Filter
import Mathlib.Analysis.BoxIntegral.Partition.Measure
import Mathlib.Analysis.Oscillation
import Mathlib.Data.Bool.Basic
import Mathlib.MeasureTheory.Measure.Real
import Mathlib.Topology.UniformSpace.Compact
/-!
# Integrals of Riemann, Henstock-Kurzweil, and McShane
In this file we define the integral of a function over a box in `ββΏ`. The same definition works for
Riemann, Henstock-Kurzweil, and McShane integrals.
As usual, we represent `ββΏ` as the type of functions `ΞΉ β β` for some finite type `ΞΉ`. A rectangular
box `(l, u]` in `ββΏ` is defined to be the set `{x : ΞΉ β β | β i, l i < x i β§ x i β€ u i}`, see
`BoxIntegral.Box`.
Let `vol` be a box-additive function on boxes in `ββΏ` with codomain `E βL[β] F`. Given a function
`f : ββΏ β E`, a box `I` and a tagged partition `Ο` of this box, the *integral sum* of `f` over `Ο`
with respect to the volume `vol` is the sum of `vol J (f (Ο.tag J))` over all boxes of `Ο`. Here
`Ο.tag J` is the point (tag) in `ββΏ` associated with the box `J`.
The integral is defined as the limit of integral sums along a filter. Different filters correspond
to different integration theories. In order to avoid code duplication, all our definitions and
theorems take an argument `l : BoxIntegral.IntegrationParams`. This is a type that holds three
Boolean values, and encodes eight filters including those corresponding to Riemann,
Henstock-Kurzweil, and McShane integrals.
Following the design of infinite sums (see `hasSum` and `tsum`), we define a predicate
`BoxIntegral.HasIntegral` and a function `BoxIntegral.integral` that returns a vector satisfying
the predicate or zero if the function is not integrable.
Then we prove some basic properties of box integrals (linearity, a formula for the integral of a
constant). We also prove a version of the Henstock-Sacks inequality (see
`BoxIntegral.Integrable.dist_integralSum_le_of_memBaseSet` and
`BoxIntegral.Integrable.dist_integralSum_sum_integral_le_of_memBaseSet_of_iUnion_eq`), prove
integrability of continuous functions, and provide a criterion for integrability w.r.t. a
non-Riemann filter (e.g., Henstock-Kurzweil and McShane).
## Notation
- `ββΏ`: local notation for `ΞΉ β β`
## Tags
integral
-/
open scoped Topology NNReal Filter Uniformity BoxIntegral
open Set Finset Function Filter Metric BoxIntegral.IntegrationParams
noncomputable section
namespace BoxIntegral
universe u v w
variable {ΞΉ : Type u} {E : Type v} {F : Type w} [NormedAddCommGroup E] [NormedSpace β E]
[NormedAddCommGroup F] [NormedSpace β F] {I J : Box ΞΉ} {Ο : TaggedPrepartition I}
open TaggedPrepartition
local notation "ββΏ" => ΞΉ β β
/-!
### Integral sum and its basic properties
-/
/-- The integral sum of `f : ββΏ β E` over a tagged prepartition `Ο` w.r.t. box-additive volume `vol`
with codomain `E βL[β] F` is the sum of `vol J (f (Ο.tag J))` over all boxes of `Ο`. -/
def integralSum (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (Ο : TaggedPrepartition I) : F :=
β J β Ο.boxes, vol J (f (Ο.tag J))
theorem integralSum_biUnionTagged (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (Ο : Prepartition I)
(Οi : β J, TaggedPrepartition J) :
integralSum f vol (Ο.biUnionTagged Οi) = β J β Ο.boxes, integralSum f vol (Οi J) := by
refine (Ο.sum_biUnion_boxes _ _).trans <| sum_congr rfl fun J hJ => sum_congr rfl fun J' hJ' => ?_
rw [Ο.tag_biUnionTagged hJ hJ']
theorem integralSum_biUnion_partition (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F)
(Ο : TaggedPrepartition I) (Οi : β J, Prepartition J) (hΟi : β J β Ο, (Οi J).IsPartition) :
integralSum f vol (Ο.biUnionPrepartition Οi) = integralSum f vol Ο := by
refine (Ο.sum_biUnion_boxes _ _).trans (sum_congr rfl fun J hJ => ?_)
calc
(β J' β (Οi J).boxes, vol J' (f (Ο.tag <| Ο.toPrepartition.biUnionIndex Οi J'))) =
β J' β (Οi J).boxes, vol J' (f (Ο.tag J)) :=
sum_congr rfl fun J' hJ' => by rw [Prepartition.biUnionIndex_of_mem _ hJ hJ']
_ = vol J (f (Ο.tag J)) :=
(vol.map β¨β¨fun g : E βL[β] F => g (f (Ο.tag J)), rflβ©, fun _ _ => rflβ©).sum_partition_boxes
le_top (hΟi J hJ)
theorem integralSum_inf_partition (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (Ο : TaggedPrepartition I)
{Ο' : Prepartition I} (h : Ο'.IsPartition) :
integralSum f vol (Ο.infPrepartition Ο') = integralSum f vol Ο :=
integralSum_biUnion_partition f vol Ο _ fun _J hJ => h.restrict (Prepartition.le_of_mem _ hJ)
open Classical in
theorem integralSum_fiberwise {Ξ±} (g : Box ΞΉ β Ξ±) (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F)
(Ο : TaggedPrepartition I) :
(β y β Ο.boxes.image g, integralSum f vol (Ο.filter (g Β· = y))) = integralSum f vol Ο :=
Ο.sum_fiberwise g fun J => vol J (f <| Ο.tag J)
theorem integralSum_sub_partitions (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F)
{Οβ Οβ : TaggedPrepartition I} (hβ : Οβ.IsPartition) (hβ : Οβ.IsPartition) :
integralSum f vol Οβ - integralSum f vol Οβ =
β J β (Οβ.toPrepartition β Οβ.toPrepartition).boxes,
(vol J (f <| (Οβ.infPrepartition Οβ.toPrepartition).tag J) -
vol J (f <| (Οβ.infPrepartition Οβ.toPrepartition).tag J)) := by
rw [β integralSum_inf_partition f vol Οβ hβ, β integralSum_inf_partition f vol Οβ hβ,
integralSum, integralSum, Finset.sum_sub_distrib]
simp only [infPrepartition_toPrepartition, inf_comm]
@[simp]
theorem integralSum_disjUnion (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) {Οβ Οβ : TaggedPrepartition I}
(h : Disjoint Οβ.iUnion Οβ.iUnion) :
integralSum f vol (Οβ.disjUnion Οβ h) = integralSum f vol Οβ + integralSum f vol Οβ := by
refine (Prepartition.sum_disj_union_boxes h _).trans
(congr_argβ (Β· + Β·) (sum_congr rfl fun J hJ => ?_) (sum_congr rfl fun J hJ => ?_))
Β· rw [disjUnion_tag_of_mem_left _ hJ]
Β· rw [disjUnion_tag_of_mem_right _ hJ]
@[simp]
theorem integralSum_add (f g : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (Ο : TaggedPrepartition I) :
integralSum (f + g) vol Ο = integralSum f vol Ο + integralSum g vol Ο := by
simp only [integralSum, Pi.add_apply, (vol _).map_add, Finset.sum_add_distrib]
@[simp]
theorem integralSum_neg (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (Ο : TaggedPrepartition I) :
integralSum (-f) vol Ο = -integralSum f vol Ο := by
simp only [integralSum, Pi.neg_apply, (vol _).map_neg, Finset.sum_neg_distrib]
@[simp]
theorem integralSum_smul (c : β) (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (Ο : TaggedPrepartition I) :
integralSum (c β’ f) vol Ο = c β’ integralSum f vol Ο := by
simp only [integralSum, Finset.smul_sum, Pi.smul_apply, ContinuousLinearMap.map_smul]
variable [Fintype ΞΉ]
/-!
### Basic integrability theory
-/
/-- The predicate `HasIntegral I l f vol y` says that `y` is the integral of `f` over `I` along `l`
w.r.t. volume `vol`. This means that integral sums of `f` tend to `π y` along
`BoxIntegral.IntegrationParams.toFilteriUnion I β€`. -/
def HasIntegral (I : Box ΞΉ) (l : IntegrationParams) (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) (y : F) :
Prop :=
Tendsto (integralSum f vol) (l.toFilteriUnion I β€) (π y)
/-- A function is integrable if there exists a vector that satisfies the `HasIntegral`
predicate. -/
def Integrable (I : Box ΞΉ) (l : IntegrationParams) (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) :=
β y, HasIntegral I l f vol y
open Classical in
/-- The integral of a function `f` over a box `I` along a filter `l` w.r.t. a volume `vol`.
Returns zero on non-integrable functions. -/
def integral (I : Box ΞΉ) (l : IntegrationParams) (f : ββΏ β E) (vol : ΞΉ βα΅α΅ E βL[β] F) :=
if h : Integrable I l f vol then h.choose else 0
-- Porting note: using the above notation ββΏ here causes the theorem below to be silently ignored
-- see https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Lean.204.20doesn't.20add.20lemma.20to.20the.20environment/near/363764522
-- and https://github.com/leanprover/lean4/issues/2257
variable {l : IntegrationParams} {f g : (ΞΉ β β) β E} {vol : ΞΉ βα΅α΅ E βL[β] F} {y y' : F}
/-- Reinterpret `BoxIntegral.HasIntegral` as `Filter.Tendsto`, e.g., dot-notation theorems
that are shadowed in the `BoxIntegral.HasIntegral` namespace. -/
theorem HasIntegral.tendsto (h : HasIntegral I l f vol y) :
Tendsto (integralSum f vol) (l.toFilteriUnion I β€) (π y) :=
h
/-- The `Ξ΅`-`Ξ΄` definition of `BoxIntegral.HasIntegral`. -/
theorem hasIntegral_iff : HasIntegral I l f vol y β
β Ξ΅ > (0 : β), β r : ββ₯0 β ββΏ β Ioi (0 : β), (β c, l.RCond (r c)) β§
β c Ο, l.MemBaseSet I c (r c) Ο β IsPartition Ο β dist (integralSum f vol Ο) y β€ Ξ΅ :=
((l.hasBasis_toFilteriUnion_top I).tendsto_iff nhds_basis_closedBall).trans <| by
simp [@forall_swap ββ₯0 (TaggedPrepartition I)]
/-- Quite often it is more natural to prove an estimate of the form `a * Ξ΅`, not `Ξ΅` in the RHS of
`BoxIntegral.hasIntegral_iff`, so we provide this auxiliary lemma. -/
theorem HasIntegral.of_mul (a : β)
(h : β Ξ΅ : β, 0 < Ξ΅ β β r : ββ₯0 β ββΏ β Ioi (0 : β), (β c, l.RCond (r c)) β§ β c Ο,
l.MemBaseSet I c (r c) Ο β IsPartition Ο β dist (integralSum f vol Ο) y β€ a * Ξ΅) :
HasIntegral I l f vol y := by
refine hasIntegral_iff.2 fun Ξ΅ hΞ΅ => ?_
rcases exists_pos_mul_lt hΞ΅ a with β¨Ξ΅', hΞ΅', haβ©
rcases h Ξ΅' hΞ΅' with β¨r, hr, Hβ©
exact β¨r, hr, fun c Ο hΟ hΟp => (H c Ο hΟ hΟp).trans ha.leβ©
theorem integrable_iff_cauchy [CompleteSpace F] :
Integrable I l f vol β Cauchy ((l.toFilteriUnion I β€).map (integralSum f vol)) :=
cauchy_map_iff_exists_tendsto.symm
/-- In a complete space, a function is integrable if and only if its integral sums form a Cauchy
net. Here we restate this fact in terms of `β Ξ΅ > 0, β r, ...`. -/
theorem integrable_iff_cauchy_basis [CompleteSpace F] : Integrable I l f vol β
β Ξ΅ > (0 : β), β r : ββ₯0 β ββΏ β Ioi (0 : β), (β c, l.RCond (r c)) β§
β cβ cβ Οβ Οβ, l.MemBaseSet I cβ (r cβ) Οβ β Οβ.IsPartition β l.MemBaseSet I cβ (r cβ) Οβ β
Οβ.IsPartition β dist (integralSum f vol Οβ) (integralSum f vol Οβ) β€ Ξ΅ := by
rw [integrable_iff_cauchy, cauchy_map_iff',
(l.hasBasis_toFilteriUnion_top _).prod_self.tendsto_iff uniformity_basis_dist_le]
refine forallβ_congr fun Ξ΅ _ => exists_congr fun r => ?_
simp only [Prod.forall, exists_imp, prodMk_mem_set_prod_eq, and_imp, mem_setOf_eq]
exact
and_congr Iff.rfl
β¨fun H cβ cβ Οβ Οβ hβ hUβ hβ hUβ => H Οβ Οβ cβ hβ hUβ cβ hβ hUβ,
fun H Οβ Οβ cβ hβ hUβ cβ hβ hUβ => H cβ cβ Οβ Οβ hβ hUβ hβ hUββ©
theorem HasIntegral.mono {lβ lβ : IntegrationParams} (h : HasIntegral I lβ f vol y) (hl : lβ β€ lβ) :
HasIntegral I lβ f vol y :=
h.mono_left <| IntegrationParams.toFilteriUnion_mono _ hl _
protected theorem Integrable.hasIntegral (h : Integrable I l f vol) :
HasIntegral I l f vol (integral I l f vol) := by
rw [integral, dif_pos h]
exact Classical.choose_spec h
theorem Integrable.mono {l'} (h : Integrable I l f vol) (hle : l' β€ l) : Integrable I l' f vol :=
β¨_, h.hasIntegral.mono hleβ©
theorem HasIntegral.unique (h : HasIntegral I l f vol y) (h' : HasIntegral I l f vol y') : y = y' :=
tendsto_nhds_unique h h'
theorem HasIntegral.integrable (h : HasIntegral I l f vol y) : Integrable I l f vol :=
β¨_, hβ©
theorem HasIntegral.integral_eq (h : HasIntegral I l f vol y) : integral I l f vol = y :=
h.integrable.hasIntegral.unique h
nonrec theorem HasIntegral.add (h : HasIntegral I l f vol y) (h' : HasIntegral I l g vol y') :
HasIntegral I l (f + g) vol (y + y') := by
simpa only [HasIntegral, β integralSum_add] using h.add h'
theorem Integrable.add (hf : Integrable I l f vol) (hg : Integrable I l g vol) :
Integrable I l (f + g) vol :=
(hf.hasIntegral.add hg.hasIntegral).integrable
theorem integral_add (hf : Integrable I l f vol) (hg : Integrable I l g vol) :
integral I l (f + g) vol = integral I l f vol + integral I l g vol :=
(hf.hasIntegral.add hg.hasIntegral).integral_eq
nonrec theorem HasIntegral.neg (hf : HasIntegral I l f vol y) : HasIntegral I l (-f) vol (-y) := by
simpa only [HasIntegral, β integralSum_neg] using hf.neg
theorem Integrable.neg (hf : Integrable I l f vol) : Integrable I l (-f) vol :=
hf.hasIntegral.neg.integrable
theorem Integrable.of_neg (hf : Integrable I l (-f) vol) : Integrable I l f vol :=
neg_neg f βΈ hf.neg
@[simp]
theorem integrable_neg : Integrable I l (-f) vol β Integrable I l f vol :=
β¨fun h => h.of_neg, fun h => h.negβ©
@[simp]
theorem integral_neg : integral I l (-f) vol = -integral I l f vol := by
classical
exact if h : Integrable I l f vol then h.hasIntegral.neg.integral_eq
else by rw [integral, integral, dif_neg h, dif_neg (mt Integrable.of_neg h), neg_zero]
theorem HasIntegral.sub (h : HasIntegral I l f vol y) (h' : HasIntegral I l g vol y') :
HasIntegral I l (f - g) vol (y - y') := by simpa only [sub_eq_add_neg] using h.add h'.neg
theorem Integrable.sub (hf : Integrable I l f vol) (hg : Integrable I l g vol) :
Integrable I l (f - g) vol :=
(hf.hasIntegral.sub hg.hasIntegral).integrable
theorem integral_sub (hf : Integrable I l f vol) (hg : Integrable I l g vol) :
integral I l (f - g) vol = integral I l f vol - integral I l g vol :=
(hf.hasIntegral.sub hg.hasIntegral).integral_eq
theorem hasIntegral_const (c : E) : HasIntegral I l (fun _ => c) vol (vol I c) :=
tendsto_const_nhds.congr' <| (l.eventually_isPartition I).mono fun _Ο hΟ => Eq.symm <|
(vol.map β¨β¨fun g : E βL[β] F β¦ g c, rflβ©, fun _ _ β¦ rflβ©).sum_partition_boxes le_top hΟ
@[simp]
theorem integral_const (c : E) : integral I l (fun _ => c) vol = vol I c :=
(hasIntegral_const c).integral_eq
theorem integrable_const (c : E) : Integrable I l (fun _ => c) vol :=
β¨_, hasIntegral_const cβ©
theorem hasIntegral_zero : HasIntegral I l (fun _ => (0 : E)) vol 0 := by
simpa only [β (vol I).map_zero] using hasIntegral_const (0 : E)
theorem integrable_zero : Integrable I l (fun _ => (0 : E)) vol :=
β¨0, hasIntegral_zeroβ©
theorem integral_zero : integral I l (fun _ => (0 : E)) vol = 0 :=
hasIntegral_zero.integral_eq
theorem HasIntegral.sum {Ξ± : Type*} {s : Finset Ξ±} {f : Ξ± β ββΏ β E} {g : Ξ± β F}
(h : β i β s, HasIntegral I l (f i) vol (g i)) :
HasIntegral I l (fun x => β i β s, f i x) vol (β i β s, g i) := by
classical
induction s using Finset.induction_on with
| empty => simp [hasIntegral_zero]
| insert a s ha ihs =>
simp only [Finset.sum_insert ha]; rw [Finset.forall_mem_insert] at h
exact h.1.add (ihs h.2)
theorem HasIntegral.smul (hf : HasIntegral I l f vol y) (c : β) :
HasIntegral I l (c β’ f) vol (c β’ y) := by
simpa only [HasIntegral, β integralSum_smul] using
(tendsto_const_nhds : Tendsto _ _ (π c)).smul hf
theorem Integrable.smul (hf : Integrable I l f vol) (c : β) : Integrable I l (c β’ f) vol :=
(hf.hasIntegral.smul c).integrable
theorem Integrable.of_smul {c : β} (hf : Integrable I l (c β’ f) vol) (hc : c β 0) :
Integrable I l f vol := by
simpa [inv_smul_smulβ hc] using hf.smul cβ»ΒΉ
@[simp]
theorem integral_smul (c : β) : integral I l (fun x => c β’ f x) vol = c β’ integral I l f vol := by
rcases eq_or_ne c 0 with (rfl | hc); Β· simp only [zero_smul, integral_zero]
by_cases hf : Integrable I l f vol
Β· exact (hf.hasIntegral.smul c).integral_eq
Β· have : Β¬Integrable I l (fun x => c β’ f x) vol := mt (fun h => h.of_smul hc) hf
rw [integral, integral, dif_neg hf, dif_neg this, smul_zero]
open MeasureTheory
/-- The integral of a nonnegative function w.r.t. a volume generated by a locally-finite measure is
nonnegative. -/
theorem integral_nonneg {g : ββΏ β β} (hg : β x β Box.Icc I, 0 β€ g x) (ΞΌ : Measure ββΏ)
[IsLocallyFiniteMeasure ΞΌ] : 0 β€ integral I l g ΞΌ.toBoxAdditive.toSMul := by
by_cases hgi : Integrable I l g ΞΌ.toBoxAdditive.toSMul
Β· refine ge_of_tendsto' hgi.hasIntegral fun Ο => sum_nonneg fun J _ => ?_
exact mul_nonneg ENNReal.toReal_nonneg (hg _ <| Ο.tag_mem_Icc _)
Β· rw [integral, dif_neg hgi]
/-- If `βf xβ β€ g x` on `[l, u]` and `g` is integrable, then the norm of the integral of `f` is less
than or equal to the integral of `g`. -/
theorem norm_integral_le_of_norm_le {g : ββΏ β β} (hle : β x β Box.Icc I, βf xβ β€ g x)
(ΞΌ : Measure ββΏ) [IsLocallyFiniteMeasure ΞΌ] (hg : Integrable I l g ΞΌ.toBoxAdditive.toSMul) :
β(integral I l f ΞΌ.toBoxAdditive.toSMul : E)β β€ integral I l g ΞΌ.toBoxAdditive.toSMul := by
by_cases hfi : Integrable.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul
Β· refine le_of_tendsto_of_tendsto' hfi.hasIntegral.norm hg.hasIntegral fun Ο => ?_
refine norm_sum_le_of_le _ fun J _ => ?_
simp only [BoxAdditiveMap.toSMul_apply, norm_smul, smul_eq_mul, Real.norm_eq_abs,
ΞΌ.toBoxAdditive_apply, abs_of_nonneg measureReal_nonneg]
gcongr
exact hle _ <| Ο.tag_mem_Icc _
Β· rw [integral, dif_neg hfi, norm_zero]
exact integral_nonneg (fun x hx => (norm_nonneg _).trans (hle x hx)) ΞΌ
theorem norm_integral_le_of_le_const {c : β}
(hc : β x β Box.Icc I, βf xβ β€ c) (ΞΌ : Measure ββΏ) [IsLocallyFiniteMeasure ΞΌ] :
β(integral I l f ΞΌ.toBoxAdditive.toSMul : E)β β€ ΞΌ.real I * c := by
simpa only [integral_const] using norm_integral_le_of_norm_le hc ΞΌ (integrable_const c)
/-!
### Henstock-Sacks inequality and integrability on subboxes
Henstock-Sacks inequality for Henstock-Kurzweil integral says the following. Let `f` be a function
integrable on a box `I`; let `r : ββΏ β (0, β)` be a function such that for any tagged partition of
`I` subordinate to `r`, the integral sum over this partition is `Ξ΅`-close to the integral. Then for
any tagged prepartition (i.e. a finite collections of pairwise disjoint subboxes of `I` with tagged
points) `Ο`, the integral sum over `Ο` differs from the integral of `f` over the part of `I` covered
by `Ο` by at most `Ξ΅`. The actual statement in the library is a bit more complicated to make it work
for any `BoxIntegral.IntegrationParams`. We formalize several versions of this inequality in
`BoxIntegral.Integrable.dist_integralSum_le_of_memBaseSet`,
`BoxIntegral.Integrable.dist_integralSum_sum_integral_le_of_memBaseSet_of_iUnion_eq`, and
`BoxIntegral.Integrable.dist_integralSum_sum_integral_le_of_memBaseSet`.
Instead of using predicate assumptions on `r`, we define
`BoxIntegral.Integrable.convergenceR (h : integrable I l f vol) (Ξ΅ : β) (c : ββ₯0) : ββΏ β (0, β)`
to be a function `r` such that
- if `l.bRiemann`, then `r` is a constant;
- if `Ξ΅ > 0`, then for any tagged partition `Ο` of `I` subordinate to `r` (more precisely,
satisfying the predicate `l.mem_base_set I c r`), the integral sum of `f` over `Ο` differs from
the integral of `f` over `I` by at most `Ξ΅`.
The proof is mostly based on
[Russel A. Gordon, *The integrals of Lebesgue, Denjoy, Perron, and Henstock*][Gordon55].
-/
namespace Integrable
/-- If `Ξ΅ > 0`, then `BoxIntegral.Integrable.convergenceR` is a function `r : ββ₯0 β ββΏ β (0, β)`
such that for every `c : ββ₯0`, for every tagged partition `Ο` subordinate to `r` (and satisfying
additional distortion estimates if `BoxIntegral.IntegrationParams.bDistortion l = true`), the
corresponding integral sum is `Ξ΅`-close to the integral.
If `BoxIntegral.IntegrationParams.bRiemann = true`, then `r c x` does not depend on `x`. If
`Ξ΅ β€ 0`, then we use `r c x = 1`. -/
def convergenceR (h : Integrable I l f vol) (Ξ΅ : β) : ββ₯0 β ββΏ β Ioi (0 : β) :=
if hΞ΅ : 0 < Ξ΅ then (hasIntegral_iff.1 h.hasIntegral Ξ΅ hΞ΅).choose
else fun _ _ => β¨1, Set.mem_Ioi.2 zero_lt_oneβ©
variable {c cβ cβ : ββ₯0} {Ξ΅ Ξ΅β Ξ΅β : β} {Οβ Οβ : TaggedPrepartition I}
theorem convergenceR_cond (h : Integrable I l f vol) (Ξ΅ : β) (c : ββ₯0) :
l.RCond (h.convergenceR Ξ΅ c) := by
rw [convergenceR]; split_ifs with hβ
exacts [(hasIntegral_iff.1 h.hasIntegral Ξ΅ hβ).choose_spec.1 _, fun _ x => rfl]
theorem dist_integralSum_integral_le_of_memBaseSet (h : Integrable I l f vol) (hβ : 0 < Ξ΅)
(hΟ : l.MemBaseSet I c (h.convergenceR Ξ΅ c) Ο) (hΟp : Ο.IsPartition) :
dist (integralSum f vol Ο) (integral I l f vol) β€ Ξ΅ := by
rw [convergenceR, dif_pos hβ] at hΟ
exact (hasIntegral_iff.1 h.hasIntegral Ξ΅ hβ).choose_spec.2 c _ hΟ hΟp
/-- **Henstock-Sacks inequality**. Let `rβ rβ : ββΏ β (0, β)` be a function such that for any tagged
*partition* of `I` subordinate to `rβ`, `k=1,2`, the integral sum of `f` over this partition differs
from the integral of `f` by at most `Ξ΅β`. Then for any two tagged *prepartition* `Οβ Οβ` subordinate
to `rβ` and `rβ` respectively and covering the same part of `I`, the integral sums of `f` over these
prepartitions differ from each other by at most `Ξ΅β + Ξ΅β`.
The actual statement
- uses `BoxIntegral.Integrable.convergenceR` instead of a predicate assumption on `r`;
- uses `BoxIntegral.IntegrationParams.MemBaseSet` instead of βsubordinate to `r`β to
account for additional requirements like being a Henstock partition or having a bounded
distortion.
See also `BoxIntegral.Integrable.dist_integralSum_sum_integral_le_of_memBaseSet_of_iUnion_eq` and
`BoxIntegral.Integrable.dist_integralSum_sum_integral_le_of_memBaseSet`.
-/
theorem dist_integralSum_le_of_memBaseSet (h : Integrable I l f vol) (hposβ : 0 < Ξ΅β)
(hposβ : 0 < Ξ΅β) (hβ : l.MemBaseSet I cβ (h.convergenceR Ξ΅β cβ) Οβ)
(hβ : l.MemBaseSet I cβ (h.convergenceR Ξ΅β cβ) Οβ) (HU : Οβ.iUnion = Οβ.iUnion) :
dist (integralSum f vol Οβ) (integralSum f vol Οβ) β€ Ξ΅β + Ξ΅β := by
rcases hβ.exists_common_compl hβ HU with β¨Ο, hΟU, hΟcβ, hΟcββ©
set r : ββΏ β Ioi (0 : β) := fun x => min (h.convergenceR Ξ΅β cβ x) (h.convergenceR Ξ΅β cβ x)
set Οr := Ο.toSubordinate r
have Hβ :
dist (integralSum f vol (Οβ.unionComplToSubordinate Ο hΟU r)) (integral I l f vol) β€ Ξ΅β :=
h.dist_integralSum_integral_le_of_memBaseSet hposβ
(hβ.unionComplToSubordinate (fun _ _ => min_le_left _ _) hΟU hΟcβ)
(isPartition_unionComplToSubordinate _ _ _ _)
rw [HU] at hΟU
have Hβ :
dist (integralSum f vol (Οβ.unionComplToSubordinate Ο hΟU r)) (integral I l f vol) β€ Ξ΅β :=
h.dist_integralSum_integral_le_of_memBaseSet hposβ
(hβ.unionComplToSubordinate (fun _ _ => min_le_right _ _) hΟU hΟcβ)
(isPartition_unionComplToSubordinate _ _ _ _)
simpa [unionComplToSubordinate] using (dist_triangle_right _ _ _).trans (add_le_add Hβ Hβ)
/-- If `f` is integrable on `I` along `l`, then for two sufficiently fine tagged prepartitions
(in the sense of the filter `BoxIntegral.IntegrationParams.toFilter l I`) such that they cover
the same part of `I`, the integral sums of `f` over `Οβ` and `Οβ` are very close to each other. -/
theorem tendsto_integralSum_toFilter_prod_self_inf_iUnion_eq_uniformity (h : Integrable I l f vol) :
Tendsto (fun Ο : TaggedPrepartition I Γ TaggedPrepartition I =>
(integralSum f vol Ο.1, integralSum f vol Ο.2))
((l.toFilter I ΓΛ’ l.toFilter I) β π {Ο | Ο.1.iUnion = Ο.2.iUnion}) (π€ F) := by
refine (((l.hasBasis_toFilter I).prod_self.inf_principal _).tendsto_iff
uniformity_basis_dist_le).2 fun Ξ΅ Ξ΅0 => ?_
replace Ξ΅0 := half_pos Ξ΅0
use h.convergenceR (Ξ΅ / 2), h.convergenceR_cond (Ξ΅ / 2); rintro β¨Οβ, Οββ© β¨β¨hβ, hββ©, hUβ©
rw [β add_halves Ξ΅]
exact h.dist_integralSum_le_of_memBaseSet Ξ΅0 Ξ΅0 hβ.choose_spec hβ.choose_spec hU
/-- If `f` is integrable on a box `I` along `l`, then for any fixed subset `s` of `I` that can be
represented as a finite union of boxes, the integral sums of `f` over tagged prepartitions that
cover exactly `s` form a Cauchy βsequenceβ along `l`. -/
theorem cauchy_map_integralSum_toFilteriUnion (h : Integrable I l f vol) (Οβ : Prepartition I) :
Cauchy ((l.toFilteriUnion I Οβ).map (integralSum f vol)) := by
refine β¨inferInstance, ?_β©
rw [prod_map_map_eq, β toFilter_inf_iUnion_eq, β prod_inf_prod, prod_principal_principal]
exact h.tendsto_integralSum_toFilter_prod_self_inf_iUnion_eq_uniformity.mono_left
(inf_le_inf_left _ <| principal_mono.2 fun Ο h => h.1.trans h.2.symm)
variable [CompleteSpace F]
theorem to_subbox_aux (h : Integrable I l f vol) (hJ : J β€ I) :
β y : F, HasIntegral J l f vol y β§
Tendsto (integralSum f vol) (l.toFilteriUnion I (Prepartition.single I J hJ)) (π y) := by
refine (cauchy_map_iff_exists_tendsto.1
(h.cauchy_map_integralSum_toFilteriUnion (.single I J hJ))).imp fun y hy β¦ β¨?_, hyβ©
convert hy.comp (l.tendsto_embedBox_toFilteriUnion_top hJ) -- faster than `exact` here
/-- If `f` is integrable on a box `I`, then it is integrable on any subbox of `I`. -/
theorem to_subbox (h : Integrable I l f vol) (hJ : J β€ I) : Integrable J l f vol :=
(h.to_subbox_aux hJ).imp fun _ => And.left
/-- If `f` is integrable on a box `I`, then integral sums of `f` over tagged prepartitions
that cover exactly a subbox `J β€ I` tend to the integral of `f` over `J` along `l`. -/
theorem tendsto_integralSum_toFilteriUnion_single (h : Integrable I l f vol) (hJ : J β€ I) :
Tendsto (integralSum f vol) (l.toFilteriUnion I (Prepartition.single I J hJ))
(π <| integral J l f vol) :=
let β¨_y, hβ, hββ© := h.to_subbox_aux hJ
hβ.integral_eq.symm βΈ hβ
/-- **Henstock-Sacks inequality**. Let `r : ββΏ β (0, β)` be a function such that for any tagged
*partition* of `I` subordinate to `r`, the integral sum of `f` over this partition differs from the
integral of `f` by at most `Ξ΅`. Then for any tagged *prepartition* `Ο` subordinate to `r`, the
integral sum of `f` over this prepartition differs from the integral of `f` over the part of `I`
covered by `Ο` by at most `Ξ΅`.
The actual statement
- uses `BoxIntegral.Integrable.convergenceR` instead of a predicate assumption on `r`;
- uses `BoxIntegral.IntegrationParams.MemBaseSet` instead of βsubordinate to `r`β to
account for additional requirements like being a Henstock partition or having a bounded
distortion;
- takes an extra argument `Οβ : prepartition I` and an assumption `Ο.Union = Οβ.Union` instead of
using `Ο.to_prepartition`.
-/
theorem dist_integralSum_sum_integral_le_of_memBaseSet_of_iUnion_eq (h : Integrable I l f vol)
(h0 : 0 < Ξ΅) (hΟ : l.MemBaseSet I c (h.convergenceR Ξ΅ c) Ο) {Οβ : Prepartition I}
(hU : Ο.iUnion = Οβ.iUnion) :
dist (integralSum f vol Ο) (β J β Οβ.boxes, integral J l f vol) β€ Ξ΅ := by
-- Let us prove that the distance is less than or equal to `Ξ΅ + Ξ΄` for all positive `Ξ΄`.
refine le_of_forall_pos_le_add fun Ξ΄ Ξ΄0 => ?_
-- First we choose some constants.
set Ξ΄' : β := Ξ΄ / (#Οβ.boxes + 1)
have H0 : 0 < (#Οβ.boxes + 1 : β) := Nat.cast_add_one_pos _
have Ξ΄'0 : 0 < Ξ΄' := div_pos Ξ΄0 H0
set C := max Οβ.distortion Οβ.compl.distortion
/- Next we choose a tagged partition of each `J β Οβ` such that the integral sum of `f` over this
partition is `Ξ΄'`-close to the integral of `f` over `J`. -/
have : β J β Οβ, β Οi : TaggedPrepartition J,
Οi.IsPartition β§ dist (integralSum f vol Οi) (integral J l f vol) β€ Ξ΄' β§
l.MemBaseSet J C (h.convergenceR Ξ΄' C) Οi := by
intro J hJ
have Hle : J β€ I := Οβ.le_of_mem hJ
have HJi : Integrable J l f vol := h.to_subbox Hle
set r := fun x => min (h.convergenceR Ξ΄' C x) (HJi.convergenceR Ξ΄' C x)
have hJd : J.distortion β€ C := le_trans (Finset.le_sup hJ) (le_max_left _ _)
rcases l.exists_memBaseSet_isPartition J hJd r with β¨ΟJ, hC, hpβ©
have hCβ : l.MemBaseSet J C (HJi.convergenceR Ξ΄' C) ΟJ := by
refine hC.mono J le_rfl le_rfl fun x _ => ?_; exact min_le_right _ _
have hCβ : l.MemBaseSet J C (h.convergenceR Ξ΄' C) ΟJ := by
refine hC.mono J le_rfl le_rfl fun x _ => ?_; exact min_le_left _ _
exact β¨ΟJ, hp, HJi.dist_integralSum_integral_le_of_memBaseSet Ξ΄'0 hCβ hp, hCββ©
/- Now we combine these tagged partitions into a tagged prepartition of `I` that covers the
same part of `I` as `Οβ` and apply `BoxIntegral.dist_integralSum_le_of_memBaseSet` to
`Ο` and this prepartition. -/
choose! Οi hΟip hΟiΞ΄' hΟiC using this
have : l.MemBaseSet I C (h.convergenceR Ξ΄' C) (Οβ.biUnionTagged Οi) :=
biUnionTagged_memBaseSet hΟiC hΟip fun _ => le_max_right _ _
have hU' : Ο.iUnion = (Οβ.biUnionTagged Οi).iUnion :=
hU.trans (Prepartition.iUnion_biUnion_partition _ hΟip).symm
have := h.dist_integralSum_le_of_memBaseSet h0 Ξ΄'0 hΟ this hU'
rw [integralSum_biUnionTagged] at this
calc
dist (integralSum f vol Ο) (β J β Οβ.boxes, integral J l f vol) β€
dist (integralSum f vol Ο) (β J β Οβ.boxes, integralSum f vol (Οi J)) +
dist (β J β Οβ.boxes, integralSum f vol (Οi J)) (β J β Οβ.boxes, integral J l f vol) :=
dist_triangle _ _ _
_ β€ Ξ΅ + Ξ΄' + β _J β Οβ.boxes, Ξ΄' := add_le_add this (dist_sum_sum_le_of_le _ hΟiΞ΄')
_ = Ξ΅ + Ξ΄ := by simp [field, Ξ΄']; ring
/-- **Henstock-Sacks inequality**. Let `r : ββΏ β (0, β)` be a function such that for any tagged
*partition* of `I` subordinate to `r`, the integral sum of `f` over this partition differs from the
integral of `f` by at most `Ξ΅`. Then for any tagged *prepartition* `Ο` subordinate to `r`, the
integral sum of `f` over this prepartition differs from the integral of `f` over the part of `I`
covered by `Ο` by at most `Ξ΅`.
The actual statement
- uses `BoxIntegral.Integrable.convergenceR` instead of a predicate assumption on `r`;
- uses `BoxIntegral.IntegrationParams.MemBaseSet` instead of βsubordinate to `r`β to
account for additional requirements like being a Henstock partition or having a bounded
distortion;
-/
theorem dist_integralSum_sum_integral_le_of_memBaseSet (h : Integrable I l f vol) (h0 : 0 < Ξ΅)
(hΟ : l.MemBaseSet I c (h.convergenceR Ξ΅ c) Ο) :
dist (integralSum f vol Ο) (β J β Ο.boxes, integral J l f vol) β€ Ξ΅ :=
h.dist_integralSum_sum_integral_le_of_memBaseSet_of_iUnion_eq h0 hΟ rfl
/-- Integral sum of `f` over a tagged prepartition `Ο` such that `Ο.Union = Οβ.Union` tends to the
sum of integrals of `f` over the boxes of `Οβ`. -/
theorem tendsto_integralSum_sum_integral (h : Integrable I l f vol) (Οβ : Prepartition I) :
Tendsto (integralSum f vol) (l.toFilteriUnion I Οβ)
(π <| β J β Οβ.boxes, integral J l f vol) := by
refine ((l.hasBasis_toFilteriUnion I Οβ).tendsto_iff nhds_basis_closedBall).2 fun Ξ΅ Ξ΅0 => ?_
refine β¨h.convergenceR Ξ΅, h.convergenceR_cond Ξ΅, ?_β©
simp only [mem_setOf_eq]
rintro Ο β¨c, hc, hUβ©
exact h.dist_integralSum_sum_integral_le_of_memBaseSet_of_iUnion_eq Ξ΅0 hc hU
/-- If `f` is integrable on `I`, then `fun J β¦ integral J l f vol` is box-additive on subboxes of
`I`: if `Οβ`, `Οβ` are two prepartitions of `I` covering the same part of `I`, the sum of integrals
of `f` over the boxes of `Οβ` is equal to the sum of integrals of `f` over the boxes of `Οβ`.
See also `BoxIntegral.Integrable.toBoxAdditive` for a bundled version. -/
theorem sum_integral_congr (h : Integrable I l f vol) {Οβ Οβ : Prepartition I}
(hU : Οβ.iUnion = Οβ.iUnion) :
β J β Οβ.boxes, integral J l f vol = β J β Οβ.boxes, integral J l f vol := by
refine tendsto_nhds_unique (h.tendsto_integralSum_sum_integral Οβ) ?_
rw [l.toFilteriUnion_congr _ hU]
exact h.tendsto_integralSum_sum_integral Οβ
/-- If `f` is integrable on `I`, then `fun J β¦ integral J l f vol` is box-additive on subboxes of
`I`: if `Οβ`, `Οβ` are two prepartitions of `I` covering the same part of `I`, the sum of integrals
of `f` over the boxes of `Οβ` is equal to the sum of integrals of `f` over the boxes of `Οβ`.
See also `BoxIntegral.Integrable.sum_integral_congr` for an unbundled version. -/
@[simps]
def toBoxAdditive (h : Integrable I l f vol) : ΞΉ βα΅α΅[I] F where
toFun J := integral J l f vol
sum_partition_boxes' J hJ Ο hΟ := by
replace hΟ := hΟ.iUnion_eq; rw [β Prepartition.iUnion_top] at hΟ
rw [(h.to_subbox (WithTop.coe_le_coe.1 hJ)).sum_integral_congr hΟ, Prepartition.top_boxes,
sum_singleton]
end Integrable
open MeasureTheory
/-!
### Integrability conditions
-/
open Prepartition EMetric ENNReal BoxAdditiveMap Finset Metric TaggedPrepartition
variable (l)
/-- A function that is bounded and a.e. continuous on a box `I` is integrable on `I`. -/
theorem integrable_of_bounded_and_ae_continuousWithinAt [CompleteSpace E] {I : Box ΞΉ} {f : ββΏ β E}
(hb : β C : β, β x β Box.Icc I, βf xβ β€ C) (ΞΌ : Measure ββΏ) [IsLocallyFiniteMeasure ΞΌ]
(hc : βα΅ x β(ΞΌ.restrict (Box.Icc I)), ContinuousWithinAt f (Box.Icc I) x) :
Integrable I l f ΞΌ.toBoxAdditive.toSMul := by
/- We prove that f is integrable by proving that we can ensure that the integrals over any
two tagged prepartitions Οβ and Οβ can be made Ξ΅-close by making the partitions
sufficiently fine.
Start by defining some constants C, Ξ΅β, Ξ΅β that will be useful later. -/
refine integrable_iff_cauchy_basis.2 fun Ξ΅ Ξ΅0 β¦ ?_
rcases exists_pos_mul_lt Ξ΅0 (2 * ΞΌ.toBoxAdditive I) with β¨Ξ΅β, Ξ΅β0, hΞ΅ββ©
rcases hb with β¨C, hCβ©
have C0 : 0 β€ C := by
obtain β¨x, hxβ© := BoxIntegral.Box.nonempty_coe I
exact le_trans (norm_nonneg (f x)) <| hC x (I.coe_subset_Icc hx)
rcases exists_pos_mul_lt Ξ΅0 (4 * C) with β¨Ξ΅β, Ξ΅β0, hΞ΅ββ©
have Ξ΅β0' : ENNReal.ofReal Ξ΅β β 0 := ne_of_gt <| ofReal_pos.2 Ξ΅β0
-- The set of discontinuities of f is contained in an open set U with ΞΌ U < Ξ΅β.
let D := { x β Box.Icc I | Β¬ ContinuousWithinAt f (Box.Icc I) x }
let ΞΌ' := ΞΌ.restrict (Box.Icc I)
have ΞΌ'D : ΞΌ' D = 0 := by
rcases eventually_iff_exists_mem.1 hc with β¨V, ae, hVβ©
exact eq_of_le_of_not_lt (mem_ae_iff.1 ae βΈ (ΞΌ'.mono <| fun x h xV β¦ h.2 (hV x xV))) not_lt_zero
obtain β¨U, UD, Uopen, hUβ© := Set.exists_isOpen_lt_add D (show ΞΌ' D β β€ by simp [ΞΌ'D]) Ξ΅β0'
rw [ΞΌ'D, zero_add] at hU
/- Box.Icc I \ U is compact and avoids discontinuities of f, so there exists r > 0 such that for
every x β Box.Icc I \ U, the oscillation (within Box.Icc I) of f on the ball of radius r
centered at x is β€ Ξ΅β -/
have comp : IsCompact (Box.Icc I \ U) :=
I.isCompact_Icc.of_isClosed_subset (I.isCompact_Icc.isClosed.sdiff Uopen) Set.diff_subset
have : β x β (Box.Icc I \ U), oscillationWithin f (Box.Icc I) x < (ENNReal.ofReal Ξ΅β) := by
intro x hx
suffices oscillationWithin f (Box.Icc I) x = 0 by rw [this]; exact ofReal_pos.2 Ξ΅β0
simpa [OscillationWithin.eq_zero_iff_continuousWithinAt, D, hx.1] using hx.2 β (fun a β¦ UD a)
rcases comp.uniform_oscillationWithin this with β¨r, r0, hrβ©
/- We prove the claim for partitions Οβ and Οβ subordinate to r/2, by writing the difference as
an integralSum over Οβ β Οβ and considering separately the boxes of Οβ β Οβ which are/aren't
fully contained within U. -/
refine β¨fun _ _ β¦ β¨r / 2, half_pos r0β©, fun _ _ _ β¦ rfl, fun cβ cβ Οβ Οβ hβ hβp hβ hβp β¦ ?_β©
simp only [dist_eq_norm, integralSum_sub_partitions _ _ hβp hβp, toSMul_apply, β smul_sub]
have ΞΌI : ΞΌ I < β€ := lt_of_le_of_lt (ΞΌ.mono I.coe_subset_Icc) I.isCompact_Icc.measure_lt_top
let tβ (J : Box ΞΉ) : ββΏ := (Οβ.infPrepartition Οβ.toPrepartition).tag J
let tβ (J : Box ΞΉ) : ββΏ := (Οβ.infPrepartition Οβ.toPrepartition).tag J
let B := (Οβ.toPrepartition β Οβ.toPrepartition).boxes
classical
let B' := {J β B | J.toSet β U}
have hB' : B' β B := B.filter_subset (fun J β¦ J.toSet β U)
have ΞΌJ_ne_top : β J β B, ΞΌ J β β€ :=
fun J hJ β¦ lt_top_iff_ne_top.1 <| lt_of_le_of_lt (ΞΌ.mono (Prepartition.le_of_mem' _ J hJ)) ΞΌI
have un : β S β B, β J β S, J.toSet β I.toSet :=
fun S hS β¦ iUnion_subset_iff.2 (fun J β¦ iUnion_subset_iff.2 fun hJ β¦ le_of_mem' _ J (hS hJ))
rw [β sum_sdiff hB', β add_halves Ξ΅]
apply le_trans (norm_add_le _ _) (add_le_add ?_ ?_)
/- If a box J is not contained within U, then the oscillation of f on J is small, which bounds
the contribution of J to the overall sum. -/
Β· have : β J β B \ B', βΞΌ.toBoxAdditive J β’ (f (tβ J) - f (tβ J))β β€ ΞΌ.toBoxAdditive J * Ξ΅β := by
intro J hJ
rw [mem_sdiff, B.mem_filter, not_and] at hJ
rw [norm_smul, ΞΌ.toBoxAdditive_apply, Real.norm_of_nonneg measureReal_nonneg]
gcongr _ * ?_
obtain β¨x, xJ, xnUβ© : β x β J, x β U := Set.not_subset.1 (hJ.2 hJ.1)
have hx : x β Box.Icc I \ U := β¨Box.coe_subset_Icc ((le_of_mem' _ J hJ.1) xJ), xnUβ©
have ineq : edist (f (tβ J)) (f (tβ J)) β€ EMetric.diam (f '' (ball x r β© (Box.Icc I))) := by
apply edist_le_diam_of_mem <;>
refine Set.mem_image_of_mem f β¨?_, tag_mem_Icc _ Jβ© <;>
refine closedBall_subset_ball (div_two_lt_of_pos r0) <| mem_closedBall_comm.1 ?_
Β· exact hβ.isSubordinate.infPrepartition Οβ.toPrepartition J hJ.1 (Box.coe_subset_Icc xJ)
Β· exact hβ.isSubordinate.infPrepartition Οβ.toPrepartition J
((Οβ.mem_infPrepartition_comm).1 hJ.1) (Box.coe_subset_Icc xJ)
rw [β emetric_ball] at ineq
simpa only [edist_le_ofReal (le_of_lt Ξ΅β0), dist_eq_norm, hJ.1] using ineq.trans (hr x hx)
refine (norm_sum_le _ _).trans <| (sum_le_sum this).trans ?_
rw [β sum_mul]
trans ΞΌ.toBoxAdditive I * Ξ΅β; swap
Β· linarith
simp_rw [mul_le_mul_iff_leftβ Ξ΅β0, ΞΌ.toBoxAdditive_apply]
refine le_trans ?_ <| toReal_mono (lt_top_iff_ne_top.1 ΞΌI) <| ΞΌ.mono <| un (B \ B') sdiff_subset
simp_rw [measureReal_def]
rw [β toReal_sum (fun J hJ β¦ ΞΌJ_ne_top J (mem_sdiff.1 hJ).1), β Finset.tsum_subtype]
refine (toReal_mono <| ne_of_lt <| lt_of_le_of_lt (ΞΌ.mono <| un (B \ B') sdiff_subset) ΞΌI) ?_
refine le_of_eq (measure_biUnion (countable_toSet _) ?_ (fun J _ β¦ J.measurableSet_coe)).symm
exact fun J hJ J' hJ' hJJ' β¦ pairwiseDisjoint _ (mem_sdiff.1 hJ).1 (mem_sdiff.1 hJ').1 hJJ'
-- The contribution of the boxes contained within U is bounded because f is bounded and ΞΌ U < Ξ΅β.
Β· have : β J β B', βΞΌ.toBoxAdditive J β’ (f (tβ J) - f (tβ J))β β€ ΞΌ.toBoxAdditive J * (2 * C) := by
intro J _
rw [norm_smul, ΞΌ.toBoxAdditive_apply, Real.norm_of_nonneg measureReal_nonneg, two_mul]
gcongr
apply norm_sub_le_of_le <;> exact hC _ (TaggedPrepartition.tag_mem_Icc _ J)
apply (norm_sum_le_of_le B' this).trans
simp_rw [β sum_mul, ΞΌ.toBoxAdditive_apply, measureReal_def,
β toReal_sum (fun J hJ β¦ ΞΌJ_ne_top J (hB' hJ))]
suffices (β J β B', ΞΌ J).toReal β€ Ξ΅β by
linarith [mul_le_mul_of_nonneg_right this <| (mul_nonneg_iff_of_pos_left two_pos).2 C0]
rw [β toReal_ofReal (le_of_lt Ξ΅β0)]
refine toReal_mono ofReal_ne_top (le_trans ?_ (le_of_lt hU))
trans ΞΌ' (β J β B', J)
Β· simp only [ΞΌ', ΞΌ.restrict_eq_self <| (un _ hB').trans I.coe_subset_Icc]
exact le_of_eq <| Eq.symm <| measure_biUnion_finset
(fun J hJ K hK hJK β¦ pairwiseDisjoint _ (hB' hJ) (hB' hK) hJK) fun J _ β¦ J.measurableSet_coe
Β· apply ΞΌ'.mono
simp_rw [iUnion_subset_iff]
exact fun J hJ β¦ (mem_filter.1 hJ).2
/-- A function that is bounded on a box `I` and a.e. continuous is integrable on `I`.
This is a version of `integrable_of_bounded_and_ae_continuousWithinAt` with a stronger continuity
assumption so that the user does not need to specialize the continuity assumption to each box on
which the theorem is to be applied. -/
theorem integrable_of_bounded_and_ae_continuous [CompleteSpace E] {I : Box ΞΉ} {f : ββΏ β E}
(hb : β C : β, β x β Box.Icc I, βf xβ β€ C) (ΞΌ : Measure ββΏ) [IsLocallyFiniteMeasure ΞΌ]
(hc : βα΅ x βΞΌ, ContinuousAt f x) : Integrable I l f ΞΌ.toBoxAdditive.toSMul :=
integrable_of_bounded_and_ae_continuousWithinAt l hb ΞΌ <|
Eventually.filter_mono (ae_mono ΞΌ.restrict_le_self) (hc.mono fun _ h β¦ h.continuousWithinAt)
/-- A continuous function is box-integrable with respect to any locally finite measure.
This is true for any volume with bounded variation. -/
theorem integrable_of_continuousOn [CompleteSpace E] {I : Box ΞΉ} {f : ββΏ β E}
(hc : ContinuousOn f (Box.Icc I)) (ΞΌ : Measure ββΏ) [IsLocallyFiniteMeasure ΞΌ] :
Integrable.{u, v, v} I l f ΞΌ.toBoxAdditive.toSMul := by
apply integrable_of_bounded_and_ae_continuousWithinAt
Β· obtain β¨C, hCβ© := (NormedSpace.isBounded_iff_subset_smul_closedBall β).1
(I.isCompact_Icc.image_of_continuousOn hc).isBounded
use βCβ, fun x hx β¦ by
simpa only [smul_unitClosedBall, mem_closedBall_zero_iff] using hC (Set.mem_image_of_mem f hx)
Β· refine eventually_of_mem ?_ (fun x hx β¦ hc.continuousWithinAt hx)
rw [mem_ae_iff, ΞΌ.restrict_apply] <;> simp [MeasurableSet.compl_iff.2 I.measurableSet_Icc]
variable {l}
/-- This is an auxiliary lemma used to prove two statements at once. Use one of the next two
lemmas instead. -/
theorem HasIntegral.of_bRiemann_eq_false_of_forall_isLittleO (hl : l.bRiemann = false)
(B : ΞΉ βα΅α΅[I] β) (hB0 : β J, 0 β€ B J) (g : ΞΉ βα΅α΅[I] F) (s : Set ββΏ) (hs : s.Countable)
(hlH : s.Nonempty β l.bHenstock = true)
(Hβ : β (c : ββ₯0), β x β Box.Icc I β© s, β Ξ΅ > (0 : β),
β Ξ΄ > 0, β J β€ I, Box.Icc J β Metric.closedBall x Ξ΄ β x β Box.Icc J β
(l.bDistortion β J.distortion β€ c) β dist (vol J (f x)) (g J) β€ Ξ΅)
(Hβ : β (c : ββ₯0), β x β Box.Icc I \ s, β Ξ΅ > (0 : β),
β Ξ΄ > 0, β J β€ I, Box.Icc J β Metric.closedBall x Ξ΄ β (l.bHenstock β x β Box.Icc J) β
(l.bDistortion β J.distortion β€ c) β dist (vol J (f x)) (g J) β€ Ξ΅ * B J) :
HasIntegral I l f vol (g I) := by
/- We choose `r x` differently for `x β s` and `x β s`.
For `x β s`, we choose `Ξ΅s` such that `β' x : s, Ξ΅s x < Ξ΅ / 2 / 2 ^ #ΞΉ`, then choose `r x` so
that `dist (vol J (f x)) (g J) β€ Ξ΅s x` for `J` in the `r x`-neighborhood of `x`. This guarantees
that the sum of these distances over boxes `J` such that `Ο.tag J β s` is less than `Ξ΅ / 2`. We
need an additional multiplier `2 ^ #ΞΉ` because different boxes can have the same tag.
For `x β s`, we choose `r x` so that `dist (vol (J (f x))) (g J) β€ (Ξ΅ / 2 / B I) * B J` for a
box `J` in the `Ξ΄`-neighborhood of `x`. -/
refine ((l.hasBasis_toFilteriUnion_top _).tendsto_iff Metric.nhds_basis_closedBall).2 ?_
intro Ξ΅ Ξ΅0
simp only [β exists_prop, gt_iff_lt, Subtype.exists'] at Hβ Hβ
choose! Ξ΄β HΞ΄β using Hβ
choose! Ξ΄β HΞ΄β using Hβ
have Ξ΅0' := half_pos Ξ΅0; have H0 : 0 < (2 : β) ^ Fintype.card ΞΉ := pow_pos zero_lt_two _
rcases hs.exists_pos_forall_sum_le (div_pos Ξ΅0' H0) with β¨Ξ΅s, hΞ΅s0, hΞ΅sβ©
simp only [le_div_iffβ' H0, mul_sum] at hΞ΅s
rcases exists_pos_mul_lt Ξ΅0' (B I) with β¨Ξ΅', Ξ΅'0, hΞ΅Iβ©
classical
set Ξ΄ : ββ₯0 β ββΏ β Ioi (0 : β) := fun c x => if x β s then Ξ΄β c x (Ξ΅s x) else (Ξ΄β c) x Ξ΅'
refine β¨Ξ΄, fun c => l.rCond_of_bRiemann_eq_false hl, ?_β©
simp only [mem_setOf_eq]
rintro Ο β¨c, hΟΞ΄, hΟpβ©
-- Now we split the sum into two parts based on whether `Ο.tag J` belongs to `s` or not.
rw [β g.sum_partition_boxes le_rfl hΟp, Metric.mem_closedBall, integralSum,
β sum_filter_add_sum_filter_not Ο.boxes fun J => Ο.tag J β s,
β sum_filter_add_sum_filter_not Ο.boxes fun J => Ο.tag J β s, β add_halves Ξ΅]
refine dist_add_add_le_of_le ?_ ?_
Β· rcases s.eq_empty_or_nonempty with (rfl | hsne); Β· simp [Ξ΅0'.le]
/- For the boxes such that `Ο.tag J β s`, we use the fact that at most `2 ^ #ΞΉ` boxes have the
same tag. -/
specialize hlH hsne
have : β J β {J β Ο.boxes | Ο.tag J β s},
dist (vol J (f <| Ο.tag J)) (g J) β€ Ξ΅s (Ο.tag J) := fun J hJ β¦ by
rw [Finset.mem_filter] at hJ; obtain β¨hJ, hJsβ© := hJ
refine HΞ΄β c _ β¨Ο.tag_mem_Icc _, hJsβ© _ (hΞ΅s0 _) _ (Ο.le_of_mem' _ hJ) ?_
(hΟΞ΄.2 hlH J hJ) fun hD => (Finset.le_sup hJ).trans (hΟΞ΄.3 hD)
convert hΟΞ΄.1 J hJ using 3; exact (if_pos hJs).symm
refine (dist_sum_sum_le_of_le _ this).trans ?_
rw [sum_comp]
refine (sum_le_sum ?_).trans (hΞ΅s _ ?_)
Β· rintro b -
rw [β Nat.cast_two, β Nat.cast_pow, β nsmul_eq_mul]
refine nsmul_le_nsmul_left (hΞ΅s0 _).le ?_
refine (Finset.card_le_card ?_).trans ((hΟΞ΄.isHenstock hlH).card_filter_tag_eq_le b)
exact filter_subset_filter _ (filter_subset _ _)
Β· rw [Finset.coe_image, Set.image_subset_iff]
exact fun J hJ => (Finset.mem_filter.1 hJ).2
/- Now we deal with boxes such that `Ο.tag J β s`.
In this case the estimate is straightforward. -/
calc
dist (β J β Ο.boxes with tag Ο J β s, vol J (f (tag Ο J)))
(β J β Ο.boxes with tag Ο J β s, g J)
β€ β J β Ο.boxes with tag Ο J β s, Ξ΅' * B J := dist_sum_sum_le_of_le _ fun J hJ β¦ by
rw [Finset.mem_filter] at hJ; obtain β¨hJ, hJsβ© := hJ
refine HΞ΄β c _ β¨Ο.tag_mem_Icc _, hJsβ© _ Ξ΅'0 _ (Ο.le_of_mem' _ hJ) ?_ (fun hH => hΟΞ΄.2 hH J hJ)
fun hD => (Finset.le_sup hJ).trans (hΟΞ΄.3 hD)
convert hΟΞ΄.1 J hJ using 3; exact (if_neg hJs).symm
_ β€ β J β Ο.boxes, Ξ΅' * B J := by
gcongr
Β· exact fun _ _ _ β¦ mul_nonneg Ξ΅'0.le (hB0 _)
Β· apply filter_subset
_ = B I * Ξ΅' := by rw [β mul_sum, B.sum_partition_boxes le_rfl hΟp, mul_comm]
_ β€ Ξ΅ / 2 := hΞ΅I.le
/-- A function `f` has Henstock (or `β₯`) integral over `I` is equal to the value of a box-additive
function `g` on `I` provided that `vol J (f x)` is sufficiently close to `g J` for sufficiently
small boxes `J β x`. This lemma is useful to prove, e.g., to prove the Divergence theorem for
integral along `β₯`.
Let `l` be either `BoxIntegral.IntegrationParams.Henstock` or `β₯`. Let `g` a box-additive function
on subboxes of `I`. Suppose that there exists a nonnegative box-additive function `B` and a
countable set `s` with the following property.
For every `c : ββ₯0`, a point `x β I.Icc`, and a positive `Ξ΅` there exists `Ξ΄ > 0` such that for any
box `J β€ I` such that
- `x β J.Icc β Metric.closedBall x Ξ΄`;
- if `l.bDistortion` (i.e., `l = β₯`), then the distortion of `J` is less than or equal to `c`,
the distance between the term `vol J (f x)` of an integral sum corresponding to `J` and `g J` is
less than or equal to `Ξ΅` if `x β s` and is less than or equal to `Ξ΅ * B J` otherwise.
Then `f` is integrable on `I` along `l` with integral `g I`. -/
theorem HasIntegral.of_le_Henstock_of_forall_isLittleO (hl : l β€ Henstock) (B : ΞΉ βα΅α΅[I] β)
(hB0 : β J, 0 β€ B J) (g : ΞΉ βα΅α΅[I] F) (s : Set ββΏ) (hs : s.Countable)
(Hβ : β (c : ββ₯0), β x β Box.Icc I β© s, β Ξ΅ > (0 : β),
β Ξ΄ > 0, β J β€ I, Box.Icc J β Metric.closedBall x Ξ΄ β x β Box.Icc J β
(l.bDistortion β J.distortion β€ c) β dist (vol J (f x)) (g J) β€ Ξ΅)
(Hβ : β (c : ββ₯0), β x β Box.Icc I \ s, β Ξ΅ > (0 : β),
β Ξ΄ > 0, β J β€ I, Box.Icc J β Metric.closedBall x Ξ΄ β x β Box.Icc J β
(l.bDistortion β J.distortion β€ c) β dist (vol J (f x)) (g J) β€ Ξ΅ * B J) :
HasIntegral I l f vol (g I) :=
have A : l.bHenstock := Bool.eq_true_of_true_le hl.2.1
HasIntegral.of_bRiemann_eq_false_of_forall_isLittleO (Bool.eq_false_of_le_false hl.1) B hB0 _ s hs
(fun _ => A) Hβ <| by simpa only [A, true_imp_iff] using Hβ
/-- Suppose that there exists a nonnegative box-additive function `B` with the following property.
For every `c : ββ₯0`, a point `x β I.Icc`, and a positive `Ξ΅` there exists `Ξ΄ > 0` such that for any
box `J β€ I` such that
- `J.Icc β Metric.closedBall x Ξ΄`;
- if `l.bDistortion` (i.e., `l = β₯`), then the distortion of `J` is less than or equal to `c`,
the distance between the term `vol J (f x)` of an integral sum corresponding to `J` and `g J` is
less than or equal to `Ξ΅ * B J`.
Then `f` is McShane integrable on `I` with integral `g I`. -/
theorem HasIntegral.mcShane_of_forall_isLittleO (B : ΞΉ βα΅α΅[I] β) (hB0 : β J, 0 β€ B J)
(g : ΞΉ βα΅α΅[I] F) (H : β (_ : ββ₯0), β x β Box.Icc I, β Ξ΅ > (0 : β), β Ξ΄ > 0, β J β€ I,
Box.Icc J β Metric.closedBall x Ξ΄ β dist (vol J (f x)) (g J) β€ Ξ΅ * B J) :
HasIntegral I McShane f vol (g I) :=
(HasIntegral.of_bRiemann_eq_false_of_forall_isLittleO (l := McShane) rfl B hB0 g β
countable_empty
(fun β¨_x, hxβ© => hx.elim) fun _ _ hx => hx.2.elim) <| by
simpa only [McShane, Bool.coe_sort_false, false_imp_iff, true_imp_iff, diff_empty] using H
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/DivergenceTheorem.lean | import Mathlib.Analysis.BoxIntegral.Basic
import Mathlib.Analysis.BoxIntegral.Partition.Additive
import Mathlib.Analysis.Calculus.FDeriv.Prod
/-!
# Divergence integral for Henstock-Kurzweil integral
In this file we prove the Divergence Theorem for a Henstock-Kurzweil style integral. The theorem
says the following. Let `f : ββΏ β EβΏ` be a function differentiable on a closed rectangular box
`I` with derivative `f' x : ββΏ βL[β] EβΏ` at `x β I`. Then the divergence `fun x β¦ β k, f' x eβ k`,
where `eβ = Pi.single k 1` is the `k`-th basis vector, is integrable on `I`, and its integral is
equal to the sum of integrals of `f` over the faces of `I` taken with appropriate signs.
To make the proof work, we had to ban tagged partitions with βlong and thinβ boxes. More precisely,
we use the following generalization of one-dimensional Henstock-Kurzweil integral to functions
defined on a box in `ββΏ` (it corresponds to the value `BoxIntegral.IntegrationParams.GP = β₯` of
`BoxIntegral.IntegrationParams` in the definition of `BoxIntegral.HasIntegral`).
We say that `f : ββΏ β E` has integral `y : E` over a box `I β ββΏ` if for an arbitrarily small
positive `Ξ΅` and an arbitrarily large `c`, there exists a function `r : ββΏ β (0, β)` such that for
any tagged partition `Ο` of `I` such that
* `Ο` is a Henstock partition, i.e., each tag belongs to its box;
* `Ο` is subordinate to `r`;
* for every box of `Ο`, the maximum of the ratios of its sides is less than or equal to `c`,
the integral sum of `f` over `Ο` is `Ξ΅`-close to `y`. In case of dimension one, the last condition
trivially holds for any `c β₯ 1`, so this definition is equivalent to the standard definition of
Henstock-Kurzweil integral.
## Tags
Henstock-Kurzweil integral, integral, Stokes theorem, divergence theorem
-/
open scoped NNReal ENNReal Topology BoxIntegral
open ContinuousLinearMap (lsmul)
open Filter Set Finset Metric
open BoxIntegral.IntegrationParams (GP gp_le)
noncomputable section
universe u
variable {E : Type u} [NormedAddCommGroup E] [NormedSpace β E] {n : β}
namespace BoxIntegral
variable [CompleteSpace E] (I : Box (Fin (n + 1))) {i : Fin (n + 1)}
open MeasureTheory
/-- Auxiliary lemma for the divergence theorem. -/
theorem norm_volume_sub_integral_face_upper_sub_lower_smul_le {f : (Fin (n + 1) β β) β E}
{f' : (Fin (n + 1) β β) βL[β] E} (hfc : ContinuousOn f (Box.Icc I)) {x : Fin (n + 1) β β}
(hxI : x β (Box.Icc I)) {a : E} {Ξ΅ : β} (h0 : 0 < Ξ΅)
(hΞ΅ : β y β (Box.Icc I), βf y - a - f' (y - x)β β€ Ξ΅ * βy - xβ) {c : ββ₯0}
(hc : I.distortion β€ c) :
β(β j, (I.upper j - I.lower j)) β’ f' (Pi.single i 1) -
(integral (I.face i) β₯ (f β i.insertNth (Ξ± := fun _ β¦ β) (I.upper i)) BoxAdditiveMap.volume -
integral (I.face i) β₯ (f β i.insertNth (Ξ± := fun _ β¦ β) (I.lower i))
BoxAdditiveMap.volume)β β€
2 * Ξ΅ * c * β j, (I.upper j - I.lower j) := by
-- Porting note: Lean fails to find `Ξ±` in the next line
set e : β β (Fin n β β) β (Fin (n + 1) β β) := i.insertNth (Ξ± := fun _ β¦ β)
/- **Plan of the proof**. The difference of the integrals of the affine function
`fun y β¦ a + f' (y - x)` over the faces `x i = I.upper i` and `x i = I.lower i` is equal to the
volume of `I` multiplied by `f' (Pi.single i 1)`, so it suffices to show that the integral of
`f y - a - f' (y - x)` over each of these faces is less than or equal to `Ξ΅ * c * vol I`. We
integrate a function of the norm `β€ Ξ΅ * diam I.Icc` over a box of volume
`β j β i, (I.upper j - I.lower j)`. Since `diam I.Icc β€ c * (I.upper i - I.lower i)`, we get the
required estimate. -/
have Hl : I.lower i β Icc (I.lower i) (I.upper i) := Set.left_mem_Icc.2 (I.lower_le_upper i)
have Hu : I.upper i β Icc (I.lower i) (I.upper i) := Set.right_mem_Icc.2 (I.lower_le_upper i)
have Hi : β x β Icc (I.lower i) (I.upper i),
Integrable.{0, u, u} (I.face i) β₯ (f β e x) BoxAdditiveMap.volume := fun x hx =>
integrable_of_continuousOn _ (Box.continuousOn_face_Icc hfc hx) volume
/- We start with an estimate: the difference of the values of `f` at the corresponding points
of the faces `x i = I.lower i` and `x i = I.upper i` is `(2 * Ξ΅ * diam I.Icc)`-close to the
value of `f'` on `Pi.single i (I.upper i - I.lower i) = lα΅’ β’ eα΅’`, where
`lα΅’ = I.upper i - I.lower i` is the length of `i`-th edge of `I` and `eα΅’ = Pi.single i 1` is the
`i`-th unit vector. -/
have : β y β Box.Icc (I.face i),
βf' (Pi.single i (I.upper i - I.lower i)) -
(f (e (I.upper i) y) - f (e (I.lower i) y))β β€
2 * Ξ΅ * diam (Box.Icc I) := fun y hy β¦ by
set g := fun y => f y - a - f' (y - x) with hg
change β y β (Box.Icc I), βg yβ β€ Ξ΅ * βy - xβ at hΞ΅
clear_value g; obtain rfl : f = fun y => a + f' (y - x) + g y := by simp [hg]
convert_to βg (e (I.lower i) y) - g (e (I.upper i) y)β β€ _
Β· congr 1
have := Fin.insertNth_sub_same (Ξ± := fun _ β¦ β) i (I.upper i) (I.lower i) y
simp only [β this, f'.map_sub]; abel
Β· have : β z β Icc (I.lower i) (I.upper i), e z y β (Box.Icc I) := fun z hz =>
I.mapsTo_insertNth_face_Icc hz hy
replace hΞ΅ : β y β (Box.Icc I), βg yβ β€ Ξ΅ * diam (Box.Icc I) := by
intro y hy
refine (hΞ΅ y hy).trans (mul_le_mul_of_nonneg_left ?_ h0.le)
rw [β dist_eq_norm]
exact dist_le_diam_of_mem I.isCompact_Icc.isBounded hy hxI
rw [two_mul, add_mul]
exact norm_sub_le_of_le (hΞ΅ _ (this _ Hl)) (hΞ΅ _ (this _ Hu))
calc
β(β j, (I.upper j - I.lower j)) β’ f' (Pi.single i 1) -
(integral (I.face i) β₯ (f β e (I.upper i)) BoxAdditiveMap.volume -
integral (I.face i) β₯ (f β e (I.lower i)) BoxAdditiveMap.volume)β =
βintegral.{0, u, u} (I.face i) β₯
(fun x : Fin n β β =>
f' (Pi.single i (I.upper i - I.lower i)) -
(f (e (I.upper i) x) - f (e (I.lower i) x)))
BoxAdditiveMap.volumeβ := by
rw [β integral_sub (Hi _ Hu) (Hi _ Hl), β Box.volume_face_mul i, mul_smul, β Box.volume_apply,
β BoxAdditiveMap.toSMul_apply, β integral_const, β BoxAdditiveMap.volume,
β integral_sub (integrable_const _) ((Hi _ Hu).sub (Hi _ Hl))]
simp only [(Β· β Β·), Pi.sub_def, β f'.map_smul, β Pi.single_smul', smul_eq_mul, mul_one]
_ β€ (volume (I.face i : Set (Fin n β β))).toReal * (2 * Ξ΅ * c * (I.upper i - I.lower i)) := by
-- The hard part of the estimate was done above, here we just replace `diam I.Icc`
-- with `c * (I.upper i - I.lower i)`
refine norm_integral_le_of_le_const (fun y hy => (this y hy).trans ?_) volume
rw [mul_assoc (2 * Ξ΅)]
gcongr
exact I.diam_Icc_le_of_distortion_le i hc
_ = 2 * Ξ΅ * c * β j, (I.upper j - I.lower j) := by
rw [β measureReal_def, β Measure.toBoxAdditive_apply, Box.volume_apply,
β I.volume_face_mul i]
ac_rfl
/-- If `f : ββΏβΊΒΉ β E` is differentiable on a closed rectangular box `I` with derivative `f'`, then
the partial derivative `fun x β¦ f' x (Pi.single i 1)` is Henstock-Kurzweil integrable with integral
equal to the difference of integrals of `f` over the faces `x i = I.upper i` and `x i = I.lower i`.
More precisely, we use a non-standard generalization of the Henstock-Kurzweil integral and
we allow `f` to be non-differentiable (but still continuous) at a countable set of points.
TODO: If `n > 0`, then the condition at `x β s` can be replaced by a much weaker estimate but this
requires either better integrability theorems, or usage of a filter depending on the countable set
`s` (we need to ensure that none of the faces of a partition contain a point from `s`). -/
theorem hasIntegral_GP_pderiv (f : (Fin (n + 1) β β) β E)
(f' : (Fin (n + 1) β β) β (Fin (n + 1) β β) βL[β] E) (s : Set (Fin (n + 1) β β))
(hs : s.Countable) (Hs : β x β s, ContinuousWithinAt f (Box.Icc I) x)
(Hd : β x β (Box.Icc I) \ s, HasFDerivWithinAt f (f' x) (Box.Icc I) x) (i : Fin (n + 1)) :
HasIntegral.{0, u, u} I GP (fun x => f' x (Pi.single i 1)) BoxAdditiveMap.volume
(integral.{0, u, u} (I.face i) GP (fun x => f (i.insertNth (I.upper i) x))
BoxAdditiveMap.volume -
integral.{0, u, u} (I.face i) GP (fun x => f (i.insertNth (I.lower i) x))
BoxAdditiveMap.volume) := by
/- Note that `f` is continuous on `I.Icc`, hence it is integrable on the faces of all boxes
`J β€ I`, thus the difference of integrals over `x i = J.upper i` and `x i = J.lower i` is a
box-additive function of `J β€ I`. -/
have Hc : ContinuousOn f (Box.Icc I) := fun x hx β¦ by
by_cases hxs : x β s
exacts [Hs x hxs, (Hd x β¨hx, hxsβ©).continuousWithinAt]
set fI : β β Box (Fin n) β E := fun y J =>
integral.{0, u, u} J GP (fun x => f (i.insertNth y x)) BoxAdditiveMap.volume
set fb : Icc (I.lower i) (I.upper i) β Fin n βα΅α΅[β(I.face i)] E := fun x =>
(integrable_of_continuousOn GP (Box.continuousOn_face_Icc Hc x.2) volume).toBoxAdditive
set F : Fin (n + 1) βα΅α΅[I] E := BoxAdditiveMap.upperSubLower I i fI fb fun x _ J => rfl
-- Thus our statement follows from some local estimates.
change HasIntegral I GP (fun x => f' x (Pi.single i 1)) _ (F I)
refine HasIntegral.of_le_Henstock_of_forall_isLittleO gp_le ?_ ?_ _ s hs ?_ ?_
Β·-- We use the volume as an upper estimate.
exact (volume : Measure (Fin (n + 1) β β)).toBoxAdditive.restrict _ le_top
Β· exact fun J => ENNReal.toReal_nonneg
Β· intro c x hx Ξ΅ Ξ΅0
/- Near `x β s` we choose `Ξ΄` so that both vectors are small. `volume J β’ eα΅’` is small because
`volume J β€ (2 * Ξ΄) ^ (n + 1)` is small, and the difference of the integrals is small
because each of the integrals is close to `volume (J.face i) β’ f x`.
TODO: there should be a shorter and more readable way to formalize this simple proof. -/
have : βαΆ Ξ΄ in π[>] (0 : β), Ξ΄ β Ioc (0 : β) (1 / 2) β§
(βα΅ (yβ β closedBall x Ξ΄ β© (Box.Icc I)) (yβ β closedBall x Ξ΄ β© (Box.Icc I)),
βf yβ - f yββ β€ Ξ΅ / 2) β§ (2 * Ξ΄) ^ (n + 1) * βf' x (Pi.single i 1)β β€ Ξ΅ / 2 := by
refine .and (Ioc_mem_nhdsGT one_half_pos) (.and ?_ ?_)
Β· rcases ((nhdsWithin_hasBasis nhds_basis_closedBall _).tendsto_iff nhds_basis_closedBall).1
(Hs x hx.2) _ (half_pos <| half_pos Ξ΅0) with β¨Ξ΄β, Ξ΄β0, hΞ΄ββ©
filter_upwards [Ioc_mem_nhdsGT Ξ΄β0] with Ξ΄ hΞ΄ yβ hyβ yβ hyβ
have : closedBall x Ξ΄ β© (Box.Icc I) β closedBall x Ξ΄β β© (Box.Icc I) := by gcongr; exact hΞ΄.2
rw [β dist_eq_norm]
calc
dist (f yβ) (f yβ) β€ dist (f yβ) (f x) + dist (f yβ) (f x) := dist_triangle_right _ _ _
_ β€ Ξ΅ / 2 / 2 + Ξ΅ / 2 / 2 := add_le_add (hΞ΄β _ <| this hyβ) (hΞ΄β _ <| this hyβ)
_ = Ξ΅ / 2 := add_halves _
Β· have : ContinuousWithinAt (fun Ξ΄ : β => (2 * Ξ΄) ^ (n + 1) * βf' x (Pi.single i 1)β)
(Ioi 0) 0 := ((continuousWithinAt_id.const_mul _).pow _).mul_const _
refine this.eventually (ge_mem_nhds ?_)
simpa using half_pos Ξ΅0
rcases this.exists with β¨Ξ΄, β¨hΞ΄0, hΞ΄12β©, hdfΞ΄, hΞ΄β©
refine β¨Ξ΄, hΞ΄0, fun J hJI hJΞ΄ _ _ => add_halves Ξ΅ βΈ ?_β©
have Hl : J.lower i β Icc (J.lower i) (J.upper i) := Set.left_mem_Icc.2 (J.lower_le_upper i)
have Hu : J.upper i β Icc (J.lower i) (J.upper i) := Set.right_mem_Icc.2 (J.lower_le_upper i)
have Hi : β x β Icc (J.lower i) (J.upper i),
Integrable.{0, u, u} (J.face i) GP (fun y => f (i.insertNth x y))
BoxAdditiveMap.volume := fun x hx =>
integrable_of_continuousOn _ (Box.continuousOn_face_Icc (Hc.mono <| Box.le_iff_Icc.1 hJI) hx)
volume
have hJΞ΄' : Box.Icc J β closedBall x Ξ΄ β© (Box.Icc I) := subset_inter hJΞ΄ (Box.le_iff_Icc.1 hJI)
have Hmaps : β z β Icc (J.lower i) (J.upper i),
MapsTo (i.insertNth z) (Box.Icc (J.face i)) (closedBall x Ξ΄ β© (Box.Icc I)) := fun z hz =>
(J.mapsTo_insertNth_face_Icc hz).mono Subset.rfl hJΞ΄'
simp only [dist_eq_norm]; dsimp [F]
rw [β integral_sub (Hi _ Hu) (Hi _ Hl)]
refine (norm_sub_le _ _).trans (add_le_add ?_ ?_)
Β· simp_rw [BoxAdditiveMap.volume_apply, norm_smul, Real.norm_eq_abs, abs_prod]
refine (mul_le_mul_of_nonneg_right ?_ <| norm_nonneg _).trans hΞ΄
have : β j, |J.upper j - J.lower j| β€ 2 * Ξ΄ := fun j β¦
calc
dist (J.upper j) (J.lower j) β€ dist J.upper J.lower := dist_le_pi_dist _ _ _
_ β€ dist J.upper x + dist J.lower x := dist_triangle_right _ _ _
_ β€ Ξ΄ + Ξ΄ := add_le_add (hJΞ΄ J.upper_mem_Icc) (hJΞ΄ J.lower_mem_Icc)
_ = 2 * Ξ΄ := (two_mul Ξ΄).symm
calc
β j, |J.upper j - J.lower j| β€ β j : Fin (n + 1), 2 * Ξ΄ :=
prod_le_prod (fun _ _ => abs_nonneg _) fun j _ => this j
_ = (2 * Ξ΄) ^ (n + 1) := by simp
Β· refine (norm_integral_le_of_le_const (fun y hy => hdfΞ΄ _ (Hmaps _ Hu hy) _
(Hmaps _ Hl hy)) volume).trans ?_
refine (mul_le_mul_of_nonneg_right ?_ (half_pos Ξ΅0).le).trans_eq (one_mul _)
rw [Box.coe_eq_pi, measureReal_def, Real.volume_pi_Ioc_toReal (Box.lower_le_upper _)]
refine prod_le_one (fun _ _ => sub_nonneg.2 <| Box.lower_le_upper _ _) fun j _ => ?_
calc
J.upper (i.succAbove j) - J.lower (i.succAbove j) β€
dist (J.upper (i.succAbove j)) (J.lower (i.succAbove j)) :=
le_abs_self _
_ β€ dist J.upper J.lower := dist_le_pi_dist J.upper J.lower (i.succAbove j)
_ β€ dist J.upper x + dist J.lower x := dist_triangle_right _ _ _
_ β€ Ξ΄ + Ξ΄ := add_le_add (hJΞ΄ J.upper_mem_Icc) (hJΞ΄ J.lower_mem_Icc)
_ β€ 1 / 2 + 1 / 2 := by gcongr
_ = 1 := add_halves 1
Β· intro c x hx Ξ΅ Ξ΅0
/- At a point `x β s`, we unfold the definition of FrΓ©chet differentiability, then use
an estimate we proved earlier in this file. -/
rcases exists_pos_mul_lt Ξ΅0 (2 * c) with β¨Ξ΅', Ξ΅'0, hltβ©
rcases (nhdsWithin_hasBasis nhds_basis_closedBall _).mem_iff.1
((Hd x hx).isLittleO.def Ξ΅'0) with β¨Ξ΄, Ξ΄0, HΞ΄β©
refine β¨Ξ΄, Ξ΄0, fun J hle hJΞ΄ hxJ hJc => ?_β©
simp only [BoxAdditiveMap.volume_apply, dist_eq_norm]
refine (norm_volume_sub_integral_face_upper_sub_lower_smul_le _
(Hc.mono <| Box.le_iff_Icc.1 hle) hxJ Ξ΅'0 (fun y hy => HΞ΄ ?_) (hJc rfl)).trans ?_
Β· exact β¨hJΞ΄ hy, Box.le_iff_Icc.1 hle hyβ©
Β· rw [mul_right_comm (2 : β), β Box.volume_apply]
exact mul_le_mul_of_nonneg_right hlt.le ENNReal.toReal_nonneg
/-- Divergence theorem for a Henstock-Kurzweil style integral.
If `f : ββΏβΊΒΉ β EβΏβΊΒΉ` is differentiable on a closed rectangular box `I` with derivative `f'`, then
the divergence `β i, f' x (Pi.single i 1) i` is Henstock-Kurzweil integrable with integral equal to
the sum of integrals of `f` over the faces of `I` taken with appropriate signs.
More precisely, we use a non-standard generalization of the Henstock-Kurzweil integral and
we allow `f` to be non-differentiable (but still continuous) at a countable set of points. -/
theorem hasIntegral_GP_divergence_of_forall_hasDerivWithinAt
(f : (Fin (n + 1) β β) β Fin (n + 1) β E)
(f' : (Fin (n + 1) β β) β (Fin (n + 1) β β) βL[β] (Fin (n + 1) β E))
(s : Set (Fin (n + 1) β β)) (hs : s.Countable)
(Hs : β x β s, ContinuousWithinAt f (Box.Icc I) x)
(Hd : β x β (Box.Icc I) \ s, HasFDerivWithinAt f (f' x) (Box.Icc I) x) :
HasIntegral.{0, u, u} I GP (fun x => β i, f' x (Pi.single i 1) i) BoxAdditiveMap.volume
(β i,
(integral.{0, u, u} (I.face i) GP (fun x => f (i.insertNth (I.upper i) x) i)
BoxAdditiveMap.volume -
integral.{0, u, u} (I.face i) GP (fun x => f (i.insertNth (I.lower i) x) i)
BoxAdditiveMap.volume)) := by
refine HasIntegral.sum fun i _ => ?_
simp only [hasFDerivWithinAt_pi', continuousWithinAt_pi] at Hd Hs
exact hasIntegral_GP_pderiv I _ _ s hs (fun x hx => Hs x hx i) (fun x hx => Hd x hx i) i
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Box/Basic.lean | import Mathlib.Data.NNReal.Basic
import Mathlib.Order.Fin.Tuple
import Mathlib.Order.Interval.Set.Monotone
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.MetricSpace.Bounded
import Mathlib.Topology.MetricSpace.Pseudo.Real
import Mathlib.Topology.Order.MonotoneConvergence
/-!
# Rectangular boxes in `ββΏ`
In this file we define rectangular boxes in `ββΏ`. As usual, we represent `ββΏ` as the type of
functions `ΞΉ β β` (usually `ΞΉ = Fin n` for some `n`). When we need to interpret a box `[l, u]` as a
set, we use the product `{x | β i, l i < x i β§ x i β€ u i}` of half-open intervals `(l i, u i]`. We
exclude `l i` because this way boxes of a partition are disjoint as sets in `ββΏ`.
Currently, the only use cases for these constructions are the definitions of Riemann-style integrals
(Riemann, Henstock-Kurzweil, McShane).
## Main definitions
We use the same structure `BoxIntegral.Box` both for ambient boxes and for elements of a partition.
Each box is stored as two points `lower upper : ΞΉ β β` and a proof of `β i, lower i < upper i`. We
define instances `Membership (ΞΉ β β) (Box ΞΉ)` and `CoeTC (Box ΞΉ) (Set <| ΞΉ β β)` so that each box is
interpreted as the set `{x | β i, x i β Set.Ioc (I.lower i) (I.upper i)}`. This way boxes of a
partition are pairwise disjoint and their union is exactly the original box.
We require boxes to be nonempty, because this way coercion to sets is injective. The empty box can
be represented as `β₯ : WithBot (BoxIntegral.Box ΞΉ)`.
We define the following operations on boxes:
* coercion to `Set (ΞΉ β β)` and `Membership (ΞΉ β β) (BoxIntegral.Box ΞΉ)` as described above;
* `PartialOrder` and `SemilatticeSup` instances such that `I β€ J` is equivalent to
`(I : Set (ΞΉ β β)) β J`;
* `Lattice` instances on `WithBot (BoxIntegral.Box ΞΉ)`;
* `BoxIntegral.Box.Icc`: the closed box `Set.Icc I.lower I.upper`; defined as a bundled monotone
map from `Box ΞΉ` to `Set (ΞΉ β β)`;
* `BoxIntegral.Box.face I i : Box (Fin n)`: a hyperface of `I : BoxIntegral.Box (Fin (n + 1))`;
* `BoxIntegral.Box.distortion`: the maximal ratio of two lengths of edges of a box; defined as the
supremum of `nndist I.lower I.upper / nndist (I.lower i) (I.upper i)`.
We also provide a convenience constructor `BoxIntegral.Box.mk' (l u : ΞΉ β β) : WithBot (Box ΞΉ)`
that returns the box `β¨l, u, _β©` if it is nonempty and `β₯` otherwise.
## Tags
rectangular box
-/
open Set Function Metric Filter
noncomputable section
open scoped NNReal Topology
namespace BoxIntegral
variable {ΞΉ : Type*}
/-!
### Rectangular box: definition and partial order
-/
/-- A nontrivial rectangular box in `ΞΉ β β` with corners `lower` and `upper`. Represents the product
of half-open intervals `(lower i, upper i]`. -/
structure Box (ΞΉ : Type*) where
/-- coordinates of the lower and upper corners of the box -/
(lower upper : ΞΉ β β)
/-- Each lower coordinate is less than its upper coordinate: i.e., the box is non-empty -/
lower_lt_upper : β i, lower i < upper i
attribute [simp] Box.lower_lt_upper
namespace Box
variable (I J : Box ΞΉ) {x y : ΞΉ β β}
instance : Inhabited (Box ΞΉ) :=
β¨β¨0, 1, fun _ β¦ zero_lt_oneβ©β©
theorem lower_le_upper : I.lower β€ I.upper :=
fun i β¦ (I.lower_lt_upper i).le
theorem lower_ne_upper (i) : I.lower i β I.upper i :=
(I.lower_lt_upper i).ne
instance : Membership (ΞΉ β β) (Box ΞΉ) :=
β¨fun I x β¦ β i, x i β Ioc (I.lower i) (I.upper i)β©
/-- The set of points in this box: this is the product of half-open intervals `(lower i, upper i]`,
where `lower` and `upper` are this box' corners. -/
@[coe]
def toSet (I : Box ΞΉ) : Set (ΞΉ β β) := { x | x β I }
instance : CoeTC (Box ΞΉ) (Set <| ΞΉ β β) :=
β¨toSetβ©
@[simp]
theorem mem_mk {l u x : ΞΉ β β} {H} : x β mk l u H β β i, x i β Ioc (l i) (u i) := Iff.rfl
@[simp, norm_cast]
theorem mem_coe : x β (I : Set (ΞΉ β β)) β x β I := Iff.rfl
theorem mem_def : x β I β β i, x i β Ioc (I.lower i) (I.upper i) := Iff.rfl
theorem mem_univ_Ioc {I : Box ΞΉ} : (x β pi univ fun i β¦ Ioc (I.lower i) (I.upper i)) β x β I :=
mem_univ_pi
theorem coe_eq_pi : (I : Set (ΞΉ β β)) = pi univ fun i β¦ Ioc (I.lower i) (I.upper i) :=
Set.ext fun _ β¦ mem_univ_Ioc.symm
@[simp]
theorem upper_mem : I.upper β I :=
fun i β¦ right_mem_Ioc.2 <| I.lower_lt_upper i
theorem exists_mem : β x, x β I :=
β¨_, I.upper_memβ©
theorem nonempty_coe : Set.Nonempty (I : Set (ΞΉ β β)) :=
I.exists_mem
@[simp]
theorem coe_ne_empty : (I : Set (ΞΉ β β)) β β
:=
I.nonempty_coe.ne_empty
@[simp]
theorem empty_ne_coe : β
β (I : Set (ΞΉ β β)) :=
I.coe_ne_empty.symm
instance : LE (Box ΞΉ) :=
β¨fun I J β¦ β β¦xβ¦, x β I β x β Jβ©
theorem le_def : I β€ J β β x β I, x β J := Iff.rfl
theorem le_TFAE : List.TFAE [I β€ J, (I : Set (ΞΉ β β)) β J,
Icc I.lower I.upper β Icc J.lower J.upper, J.lower β€ I.lower β§ I.upper β€ J.upper] := by
tfae_have 1 β 2 := Iff.rfl
tfae_have 2 β 3
| h => by simpa [coe_eq_pi, closure_pi_set, lower_ne_upper] using closure_mono h
tfae_have 3 β 4 := Icc_subset_Icc_iff I.lower_le_upper
tfae_have 4 β 2
| h, x, hx, i => Ioc_subset_Ioc (h.1 i) (h.2 i) (hx i)
tfae_finish
variable {I J}
@[simp, norm_cast]
theorem coe_subset_coe : (I : Set (ΞΉ β β)) β J β I β€ J := Iff.rfl
theorem le_iff_bounds : I β€ J β J.lower β€ I.lower β§ I.upper β€ J.upper :=
(le_TFAE I J).out 0 3
theorem injective_coe : Injective ((β) : Box ΞΉ β Set (ΞΉ β β)) := by
rintro β¨lβ, uβ, hββ© β¨lβ, uβ, hββ© h
simp only [Subset.antisymm_iff, coe_subset_coe, le_iff_bounds] at h
congr
exacts [le_antisymm h.2.1 h.1.1, le_antisymm h.1.2 h.2.2]
@[simp, norm_cast]
theorem coe_inj : (I : Set (ΞΉ β β)) = J β I = J :=
injective_coe.eq_iff
@[ext]
theorem ext (H : β x, x β I β x β J) : I = J :=
injective_coe <| Set.ext H
theorem ne_of_disjoint_coe (h : Disjoint (I : Set (ΞΉ β β)) J) : I β J :=
mt coe_inj.2 <| h.ne I.coe_ne_empty
instance : PartialOrder (Box ΞΉ) :=
{ PartialOrder.lift ((β) : Box ΞΉ β Set (ΞΉ β β)) injective_coe with le := (Β· β€ Β·) }
/-- Closed box corresponding to `I : BoxIntegral.Box ΞΉ`. -/
protected def Icc : Box ΞΉ βͺo Set (ΞΉ β β) :=
OrderEmbedding.ofMapLEIff (fun I : Box ΞΉ β¦ Icc I.lower I.upper) fun I J β¦ (le_TFAE I J).out 2 0
theorem Icc_def : Box.Icc I = Icc I.lower I.upper := rfl
@[simp]
theorem upper_mem_Icc (I : Box ΞΉ) : I.upper β Box.Icc I :=
right_mem_Icc.2 I.lower_le_upper
@[simp]
theorem lower_mem_Icc (I : Box ΞΉ) : I.lower β Box.Icc I :=
left_mem_Icc.2 I.lower_le_upper
protected theorem isCompact_Icc (I : Box ΞΉ) : IsCompact (Box.Icc I) :=
isCompact_Icc
theorem Icc_eq_pi : Box.Icc I = pi univ fun i β¦ Icc (I.lower i) (I.upper i) :=
(pi_univ_Icc _ _).symm
theorem le_iff_Icc : I β€ J β Box.Icc I β Box.Icc J :=
(le_TFAE I J).out 0 2
theorem antitone_lower : Antitone fun I : Box ΞΉ β¦ I.lower :=
fun _ _ H β¦ (le_iff_bounds.1 H).1
theorem monotone_upper : Monotone fun I : Box ΞΉ β¦ I.upper :=
fun _ _ H β¦ (le_iff_bounds.1 H).2
theorem coe_subset_Icc : βI β Box.Icc I :=
fun _ hx β¦ β¨fun i β¦ (hx i).1.le, fun i β¦ (hx i).2β©
theorem isBounded_Icc [Finite ΞΉ] (I : Box ΞΉ) : Bornology.IsBounded (Box.Icc I) := by
cases nonempty_fintype ΞΉ
exact Metric.isBounded_Icc _ _
theorem isBounded [Finite ΞΉ] (I : Box ΞΉ) : Bornology.IsBounded I.toSet :=
Bornology.IsBounded.subset I.isBounded_Icc coe_subset_Icc
/-!
### Supremum of two boxes
-/
/-- `I β J` is the least box that includes both `I` and `J`. Since `βI βͺ βJ` is usually not a box,
`β(I β J)` is larger than `βI βͺ βJ`. -/
instance : SemilatticeSup (Box ΞΉ) :=
{ sup := fun I J β¦ β¨I.lower β J.lower, I.upper β J.upper,
fun i β¦ (min_le_left _ _).trans_lt <| (I.lower_lt_upper i).trans_le (le_max_left _ _)β©
le_sup_left := fun _ _ β¦ le_iff_bounds.2 β¨inf_le_left, le_sup_leftβ©
le_sup_right := fun _ _ β¦ le_iff_bounds.2 β¨inf_le_right, le_sup_rightβ©
sup_le := fun _ _ _ hβ hβ β¦ le_iff_bounds.2
β¨le_inf (antitone_lower hβ) (antitone_lower hβ),
sup_le (monotone_upper hβ) (monotone_upper hβ)β© }
/-!
### `WithBot (Box ΞΉ)`
In this section we define coercion from `WithBot (Box ΞΉ)` to `Set (ΞΉ β β)` by sending `β₯` to `β
`.
-/
/-- The set underlying this box: `β₯` is mapped to `β
`. -/
@[coe]
def withBotToSet (o : WithBot (Box ΞΉ)) : Set (ΞΉ β β) := o.elim β
(β)
instance withBotCoe : CoeTC (WithBot (Box ΞΉ)) (Set (ΞΉ β β)) :=
β¨withBotToSetβ©
@[simp, norm_cast]
theorem coe_bot : ((β₯ : WithBot (Box ΞΉ)) : Set (ΞΉ β β)) = β
:= rfl
@[simp, norm_cast]
theorem coe_coe : ((I : WithBot (Box ΞΉ)) : Set (ΞΉ β β)) = I := rfl
theorem isSome_iff : β {I : WithBot (Box ΞΉ)}, I.isSome β (I : Set (ΞΉ β β)).Nonempty
| β₯ => by
unfold Option.isSome
simp
| (I : Box ΞΉ) => by
unfold Option.isSome
simp [I.nonempty_coe]
theorem biUnion_coe_eq_coe (I : WithBot (Box ΞΉ)) :
β (J : Box ΞΉ) (_ : βJ = I), (J : Set (ΞΉ β β)) = I := by
induction I <;> simp
@[simp, norm_cast]
theorem withBotCoe_subset_iff {I J : WithBot (Box ΞΉ)} : (I : Set (ΞΉ β β)) β J β I β€ J := by
induction I; Β· simp
induction J; Β· simp [subset_empty_iff]
simp [le_def]
@[simp, norm_cast]
theorem withBotCoe_inj {I J : WithBot (Box ΞΉ)} : (I : Set (ΞΉ β β)) = J β I = J := by
simp only [Subset.antisymm_iff, β le_antisymm_iff, withBotCoe_subset_iff]
open scoped Classical in
/-- Make a `WithBot (Box ΞΉ)` from a pair of corners `l u : ΞΉ β β`. If `l i < u i` for all `i`,
then the result is `β¨l, u, _β© : Box ΞΉ`, otherwise it is `β₯`. In any case, the result interpreted
as a set in `ΞΉ β β` is the set `{x : ΞΉ β β | β i, x i β Ioc (l i) (u i)}`. -/
def mk' (l u : ΞΉ β β) : WithBot (Box ΞΉ) :=
if h : β i, l i < u i then β(β¨l, u, hβ© : Box ΞΉ) else β₯
@[simp]
theorem mk'_eq_bot {l u : ΞΉ β β} : mk' l u = β₯ β β i, u i β€ l i := by
rw [mk']
split_ifs with h <;> simpa using h
@[simp]
theorem mk'_eq_coe {l u : ΞΉ β β} : mk' l u = I β l = I.lower β§ u = I.upper := by
obtain β¨lI, uI, hIβ© := I; rw [mk']; split_ifs with h
Β· simp
Β· suffices l = lI β u β uI by simpa
rintro rfl rfl
exact h hI
@[simp]
theorem coe_mk' (l u : ΞΉ β β) : (mk' l u : Set (ΞΉ β β)) = pi univ fun i β¦ Ioc (l i) (u i) := by
rw [mk']; split_ifs with h
Β· exact coe_eq_pi _
Β· rcases not_forall.mp h with β¨i, hiβ©
rw [coe_bot, univ_pi_eq_empty]
exact Ioc_eq_empty hi
instance WithBot.inf : Min (WithBot (Box ΞΉ)) :=
β¨fun I β¦
WithBot.recBotCoe (fun _ β¦ β₯)
(fun I J β¦ WithBot.recBotCoe β₯ (fun J β¦ mk' (I.lower β J.lower) (I.upper β J.upper)) J) Iβ©
@[simp]
theorem coe_inf (I J : WithBot (Box ΞΉ)) : (β(I β J) : Set (ΞΉ β β)) = (I : Set _) β© J := by
induction I
Β· change β
= _
simp
induction J
Β· change β
= _
simp
change ((mk' _ _ : WithBot (Box ΞΉ)) : Set (ΞΉ β β)) = _
simp only [coe_eq_pi, β pi_inter_distrib, Ioc_inter_Ioc, Pi.sup_apply, Pi.inf_apply, coe_mk',
coe_coe]
instance : Lattice (WithBot (Box ΞΉ)) :=
{ inf := min
inf_le_left := fun I J β¦ by
rw [β withBotCoe_subset_iff, coe_inf]
exact inter_subset_left
inf_le_right := fun I J β¦ by
rw [β withBotCoe_subset_iff, coe_inf]
exact inter_subset_right
le_inf := fun I Jβ Jβ hβ hβ β¦ by
simp only [β withBotCoe_subset_iff, coe_inf] at *
exact subset_inter hβ hβ }
@[simp, norm_cast]
theorem disjoint_withBotCoe {I J : WithBot (Box ΞΉ)} :
Disjoint (I : Set (ΞΉ β β)) J β Disjoint I J := by
simp only [disjoint_iff_inf_le, β withBotCoe_subset_iff, coe_inf]
rfl
theorem disjoint_coe : Disjoint (I : WithBot (Box ΞΉ)) J β Disjoint (I : Set (ΞΉ β β)) J :=
disjoint_withBotCoe.symm
theorem not_disjoint_coe_iff_nonempty_inter :
Β¬Disjoint (I : WithBot (Box ΞΉ)) J β (I β© J : Set (ΞΉ β β)).Nonempty := by
rw [disjoint_coe, Set.not_disjoint_iff_nonempty_inter]
/-!
### Hyperface of a box in `ββΏβΊΒΉ = Fin (n + 1) β β`
-/
/-- Face of a box in `ββΏβΊΒΉ = Fin (n + 1) β β`: the box in `ββΏ = Fin n β β` with corners at
`I.lower β Fin.succAbove i` and `I.upper β Fin.succAbove i`. -/
@[simps +simpRhs]
def face {n} (I : Box (Fin (n + 1))) (i : Fin (n + 1)) : Box (Fin n) :=
β¨I.lower β Fin.succAbove i, I.upper β Fin.succAbove i, fun _ β¦ I.lower_lt_upper _β©
@[simp]
theorem face_mk {n} (l u : Fin (n + 1) β β) (h : β i, l i < u i) (i : Fin (n + 1)) :
face β¨l, u, hβ© i = β¨l β Fin.succAbove i, u β Fin.succAbove i, fun _ β¦ h _β© := rfl
@[gcongr, mono]
theorem face_mono {n} {I J : Box (Fin (n + 1))} (h : I β€ J) (i : Fin (n + 1)) :
face I i β€ face J i :=
fun _ hx _ β¦ Ioc_subset_Ioc ((le_iff_bounds.1 h).1 _) ((le_iff_bounds.1 h).2 _) (hx _)
theorem monotone_face {n} (i : Fin (n + 1)) : Monotone fun I β¦ face I i :=
fun _ _ h β¦ face_mono h i
theorem mapsTo_insertNth_face_Icc {n} (I : Box (Fin (n + 1))) {i : Fin (n + 1)} {x : β}
(hx : x β Icc (I.lower i) (I.upper i)) :
MapsTo (i.insertNth x) (Box.Icc (I.face i)) (Box.Icc I) :=
fun _ hy β¦ Fin.insertNth_mem_Icc.2 β¨hx, hyβ©
theorem mapsTo_insertNth_face {n} (I : Box (Fin (n + 1))) {i : Fin (n + 1)} {x : β}
(hx : x β Ioc (I.lower i) (I.upper i)) :
MapsTo (i.insertNth x) (I.face i : Set (_ β _)) (I : Set (_ β _)) := by
intro y hy
simp_rw [mem_coe, mem_def, i.forall_iff_succAbove, Fin.insertNth_apply_same,
Fin.insertNth_apply_succAbove]
exact β¨hx, hyβ©
theorem continuousOn_face_Icc {X} [TopologicalSpace X] {n} {f : (Fin (n + 1) β β) β X}
{I : Box (Fin (n + 1))} (h : ContinuousOn f (Box.Icc I)) {i : Fin (n + 1)} {x : β}
(hx : x β Icc (I.lower i) (I.upper i)) :
ContinuousOn (f β i.insertNth x) (Box.Icc (I.face i)) :=
h.comp (continuousOn_const.finInsertNth i continuousOn_id) (I.mapsTo_insertNth_face_Icc hx)
/-!
### Covering of the interior of a box by a monotone sequence of smaller boxes
-/
/-- The interior of a box. -/
protected def Ioo : Box ΞΉ βo Set (ΞΉ β β) where
toFun I := pi univ fun i β¦ Ioo (I.lower i) (I.upper i)
monotone' _ _ h :=
pi_mono fun i _ β¦ Ioo_subset_Ioo ((le_iff_bounds.1 h).1 i) ((le_iff_bounds.1 h).2 i)
theorem Ioo_subset_coe (I : Box ΞΉ) : Box.Ioo I β I :=
fun _ hx i β¦ Ioo_subset_Ioc_self (hx i trivial)
protected theorem Ioo_subset_Icc (I : Box ΞΉ) : Box.Ioo I β Box.Icc I :=
I.Ioo_subset_coe.trans coe_subset_Icc
theorem iUnion_Ioo_of_tendsto [Finite ΞΉ] {I : Box ΞΉ} {J : β β Box ΞΉ} (hJ : Monotone J)
(hl : Tendsto (lower β J) atTop (π I.lower)) (hu : Tendsto (upper β J) atTop (π I.upper)) :
β n, Box.Ioo (J n) = Box.Ioo I :=
have hl' : β i, Antitone fun n β¦ (J n).lower i :=
fun i β¦ (monotone_eval i).comp_antitone (antitone_lower.comp_monotone hJ)
have hu' : β i, Monotone fun n β¦ (J n).upper i :=
fun i β¦ (monotone_eval i).comp (monotone_upper.comp hJ)
calc
β n, Box.Ioo (J n) = pi univ fun i β¦ β n, Ioo ((J n).lower i) ((J n).upper i) :=
iUnion_univ_pi_of_monotone fun i β¦ (hl' i).Ioo (hu' i)
_ = Box.Ioo I :=
pi_congr rfl fun i _ β¦
iUnion_Ioo_of_mono_of_isGLB_of_isLUB (hl' i) (hu' i)
(isGLB_of_tendsto_atTop (hl' i) (tendsto_pi_nhds.1 hl _))
(isLUB_of_tendsto_atTop (hu' i) (tendsto_pi_nhds.1 hu _))
theorem exists_seq_mono_tendsto (I : Box ΞΉ) :
β J : β βo Box ΞΉ,
(β n, Box.Icc (J n) β Box.Ioo I) β§
Tendsto (lower β J) atTop (π I.lower) β§ Tendsto (upper β J) atTop (π I.upper) := by
choose a b ha_anti hb_mono ha_mem hb_mem hab ha_tendsto hb_tendsto using
fun i β¦ exists_seq_strictAnti_strictMono_tendsto (I.lower_lt_upper i)
exact
β¨β¨fun k β¦ β¨flip a k, flip b k, fun i β¦ hab _ _ _β©, fun k l hkl β¦
le_iff_bounds.2 β¨fun i β¦ (ha_anti i).antitone hkl, fun i β¦ (hb_mono i).monotone hklβ©β©,
fun n x hx i _ β¦ β¨(ha_mem _ _).1.trans_le (hx.1 _), (hx.2 _).trans_lt (hb_mem _ _).2β©,
tendsto_pi_nhds.2 ha_tendsto, tendsto_pi_nhds.2 hb_tendstoβ©
section Distortion
variable [Fintype ΞΉ]
/-- The distortion of a box `I` is the maximum of the ratios of the lengths of its edges.
It is defined as the maximum of the ratios
`nndist I.lower I.upper / nndist (I.lower i) (I.upper i)`. -/
def distortion (I : Box ΞΉ) : ββ₯0 :=
Finset.univ.sup fun i : ΞΉ β¦ nndist I.lower I.upper / nndist (I.lower i) (I.upper i)
theorem distortion_eq_of_sub_eq_div {I J : Box ΞΉ} {r : β}
(h : β i, I.upper i - I.lower i = (J.upper i - J.lower i) / r) :
distortion I = distortion J := by
simp only [distortion, nndist_pi_def, Real.nndist_eq', h, map_divβ]
congr 1 with i
have : 0 < r := by
by_contra hr
have := div_nonpos_of_nonneg_of_nonpos (sub_nonneg.2 <| J.lower_le_upper i) (not_lt.1 hr)
rw [β h] at this
exact this.not_gt (sub_pos.2 <| I.lower_lt_upper i)
have hn0 := (map_ne_zero Real.nnabs).2 this.ne'
simp_rw [NNReal.finset_sup_div, div_div_div_cancel_rightβ hn0]
theorem nndist_le_distortion_mul (I : Box ΞΉ) (i : ΞΉ) :
nndist I.lower I.upper β€ I.distortion * nndist (I.lower i) (I.upper i) :=
calc
nndist I.lower I.upper =
nndist I.lower I.upper / nndist (I.lower i) (I.upper i) * nndist (I.lower i) (I.upper i) :=
(div_mul_cancelβ _ <| mt nndist_eq_zero.1 (I.lower_lt_upper i).ne).symm
_ β€ I.distortion * nndist (I.lower i) (I.upper i) := by
grw [distortion, β Finset.le_sup (Finset.mem_univ i)]
theorem dist_le_distortion_mul (I : Box ΞΉ) (i : ΞΉ) :
dist I.lower I.upper β€ I.distortion * (I.upper i - I.lower i) := by
have A : I.lower i - I.upper i < 0 := sub_neg.2 (I.lower_lt_upper i)
simpa only [β NNReal.coe_le_coe, β dist_nndist, NNReal.coe_mul, Real.dist_eq, abs_of_neg A,
neg_sub] using I.nndist_le_distortion_mul i
theorem diam_Icc_le_of_distortion_le (I : Box ΞΉ) (i : ΞΉ) {c : ββ₯0} (h : I.distortion β€ c) :
diam (Box.Icc I) β€ c * (I.upper i - I.lower i) :=
have : (0 : β) β€ c * (I.upper i - I.lower i) :=
mul_nonneg c.coe_nonneg (sub_nonneg.2 <| I.lower_le_upper _)
diam_le_of_forall_dist_le this fun x hx y hy β¦
calc
dist x y β€ dist I.lower I.upper := Real.dist_le_of_mem_pi_Icc hx hy
_ β€ I.distortion * (I.upper i - I.lower i) := I.dist_le_distortion_mul i
_ β€ c * (I.upper i - I.lower i) := by gcongr; exact sub_nonneg.2 (I.lower_le_upper i)
end Distortion
end Box
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Box/SubboxInduction.lean | import Mathlib.Analysis.BoxIntegral.Box.Basic
import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Induction on subboxes
In this file we prove the following induction principle for `BoxIntegral.Box`, see
`BoxIntegral.Box.subbox_induction_on`. Let `p` be a predicate on `BoxIntegral.Box ΞΉ`, let `I` be a
box. Suppose that the following two properties hold true.
* Consider a smaller box `J β€ I`. The hyperplanes passing through the center of `J` split it into
`2 ^ n` boxes. If `p` holds true on each of these boxes, then it is true on `J`.
* For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such
that for every box `J β€ I` such that `z β J.Icc β U`, if `J` is homothetic to `I` with a
coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.
Then `p I` is true.
## Tags
rectangular box, induction
-/
open Set Function Filter Topology
noncomputable section
namespace BoxIntegral
namespace Box
variable {ΞΉ : Type*} {I J : Box ΞΉ}
open Classical in
/-- For a box `I`, the hyperplanes passing through its center split `I` into `2 ^ card ΞΉ` boxes.
`BoxIntegral.Box.splitCenterBox I s` is one of these boxes. See also
`BoxIntegral.Partition.splitCenter` for the corresponding `BoxIntegral.Partition`. -/
def splitCenterBox (I : Box ΞΉ) (s : Set ΞΉ) : Box ΞΉ where
lower := s.piecewise (fun i β¦ (I.lower i + I.upper i) / 2) I.lower
upper := s.piecewise I.upper fun i β¦ (I.lower i + I.upper i) / 2
lower_lt_upper i := by
dsimp only [Set.piecewise]
split_ifs <;> simp only [left_lt_add_div_two, add_div_two_lt_right, I.lower_lt_upper]
theorem mem_splitCenterBox {s : Set ΞΉ} {y : ΞΉ β β} :
y β I.splitCenterBox s β y β I β§ β i, (I.lower i + I.upper i) / 2 < y i β i β s := by
simp only [splitCenterBox, mem_def, β forall_and]
refine forall_congr' fun i β¦ ?_
dsimp only [Set.piecewise]
split_ifs with hs <;> simp only [hs, iff_true, iff_false, not_lt]
exacts [β¨fun H β¦ β¨β¨(left_lt_add_div_two.2 (I.lower_lt_upper i)).trans H.1, H.2β©, H.1β©,
fun H β¦ β¨H.2, H.1.2β©β©,
β¨fun H β¦ β¨β¨H.1, H.2.trans (add_div_two_lt_right.2 (I.lower_lt_upper i)).leβ©, H.2β©,
fun H β¦ β¨H.1.1, H.2β©β©]
theorem splitCenterBox_le (I : Box ΞΉ) (s : Set ΞΉ) : I.splitCenterBox s β€ I :=
fun _ hx β¦ (mem_splitCenterBox.1 hx).1
theorem disjoint_splitCenterBox (I : Box ΞΉ) {s t : Set ΞΉ} (h : s β t) :
Disjoint (I.splitCenterBox s : Set (ΞΉ β β)) (I.splitCenterBox t) := by
rw [disjoint_iff_inf_le]
rintro y β¨hs, htβ©; apply h
ext i
rw [mem_coe, mem_splitCenterBox] at hs ht
rw [β hs.2, β ht.2]
theorem injective_splitCenterBox (I : Box ΞΉ) : Injective I.splitCenterBox := fun _ _ H β¦
by_contra fun Hne β¦ (I.disjoint_splitCenterBox Hne).ne (nonempty_coe _).ne_empty (H βΈ rfl)
@[simp]
theorem exists_mem_splitCenterBox {I : Box ΞΉ} {x : ΞΉ β β} : (β s, x β I.splitCenterBox s) β x β I :=
β¨fun β¨s, hsβ© β¦ I.splitCenterBox_le s hs, fun hx β¦
β¨{ i | (I.lower i + I.upper i) / 2 < x i }, mem_splitCenterBox.2 β¨hx, fun _ β¦ Iff.rflβ©β©β©
/-- `BoxIntegral.Box.splitCenterBox` bundled as a `Function.Embedding`. -/
@[simps]
def splitCenterBoxEmb (I : Box ΞΉ) : Set ΞΉ βͺ Box ΞΉ :=
β¨splitCenterBox I, injective_splitCenterBox Iβ©
@[simp]
theorem iUnion_coe_splitCenterBox (I : Box ΞΉ) : β s, (I.splitCenterBox s : Set (ΞΉ β β)) = I := by
ext x
simp
@[simp]
theorem upper_sub_lower_splitCenterBox (I : Box ΞΉ) (s : Set ΞΉ) (i : ΞΉ) :
(I.splitCenterBox s).upper i - (I.splitCenterBox s).lower i = (I.upper i - I.lower i) / 2 := by
by_cases i β s <;> simp [field, splitCenterBox, *] <;> ring
/-- Let `p` be a predicate on `Box ΞΉ`, let `I` be a box. Suppose that the following two properties
hold true.
* `H_ind` : Consider a smaller box `J β€ I`. The hyperplanes passing through the center of `J` split
it into `2 ^ n` boxes. If `p` holds true on each of these boxes, then it true on `J`.
* `H_nhds` : For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within
`I.Icc` such that for every box `J β€ I` such that `z β J.Icc β U`, if `J` is homothetic to `I`
with a coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.
Then `p I` is true. See also `BoxIntegral.Box.subbox_induction_on` for a version using
`BoxIntegral.Prepartition.splitCenter` instead of `BoxIntegral.Box.splitCenterBox`.
The proof still works if we assume `H_ind` only for subboxes `J β€ I` that are homothetic to `I` with
a coefficient of the form `2β»α΅` but we do not need this generalization yet. -/
@[elab_as_elim]
theorem subbox_induction_on' {p : Box ΞΉ β Prop} (I : Box ΞΉ)
(H_ind : β J β€ I, (β s, p (splitCenterBox J s)) β p J)
(H_nhds : β z β Box.Icc I, β U β π[Box.Icc I] z, β J β€ I, β (m : β), z β Box.Icc J β
Box.Icc J β U β (β i, J.upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) β p J) :
p I := by
by_contra hpI
-- First we use `H_ind` to construct a decreasing sequence of boxes such that `β m, Β¬p (J m)`.
replace H_ind := fun J hJ β¦ not_imp_not.2 (H_ind J hJ)
simp only [not_forall] at H_ind
choose! s hs using H_ind
set J : β β Box ΞΉ := fun m β¦ (fun J β¦ splitCenterBox J (s J))^[m] I
have J_succ : β m, J (m + 1) = splitCenterBox (J m) (s <| J m) :=
fun m β¦ iterate_succ_apply' _ _ _
-- Now we prove some properties of `J`
have hJmono : Antitone J :=
antitone_nat_of_succ_le fun n β¦ by simpa [J_succ] using splitCenterBox_le _ _
have hJle (m) : J m β€ I := hJmono (zero_le m)
have hJp (m) : Β¬p (J m) := Nat.recOn m hpI fun m β¦ by simpa only [J_succ] using hs (J m) (hJle m)
have hJsub (m i) : (J m).upper i - (J m).lower i = (I.upper i - I.lower i) / 2 ^ m := by
induction m with
| zero => simp [J]
| succ m ihm => simp only [pow_succ, J_succ, upper_sub_lower_splitCenterBox, ihm, div_div]
have h0 : J 0 = I := rfl
clear_value J
clear hpI hs J_succ s
-- Let `z` be the unique common point of all `(J m).Icc`. Then `H_nhds` proves `p (J m)` for
-- sufficiently large `m`. This contradicts `hJp`.
set z : ΞΉ β β := β¨ m, (J m).lower
have hzJ : β m, z β Box.Icc (J m) :=
mem_iInter.1 (ciSup_mem_iInter_Icc_of_antitone_Icc
((@Box.Icc ΞΉ).monotone.comp_antitone hJmono) fun m β¦ (J m).lower_le_upper)
have hJl_mem : β m, (J m).lower β Box.Icc I := fun m β¦ le_iff_Icc.1 (hJle m) (J m).lower_mem_Icc
have hJu_mem : β m, (J m).upper β Box.Icc I := fun m β¦ le_iff_Icc.1 (hJle m) (J m).upper_mem_Icc
have hJlz : Tendsto (fun m β¦ (J m).lower) atTop (π z) :=
tendsto_atTop_ciSup (antitone_lower.comp hJmono) β¨I.upper, fun x β¨m, hmβ© β¦ hm βΈ (hJl_mem m).2β©
have hJuz : Tendsto (fun m β¦ (J m).upper) atTop (π z) := by
suffices Tendsto (fun m β¦ (J m).upper - (J m).lower) atTop (π 0) by simpa using hJlz.add this
refine tendsto_pi_nhds.2 fun i β¦ ?_
simpa [hJsub] using
tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt _root_.one_lt_two)
replace hJlz : Tendsto (fun m β¦ (J m).lower) atTop (π[Icc I.lower I.upper] z) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hJlz (Eventually.of_forall hJl_mem)
replace hJuz : Tendsto (fun m β¦ (J m).upper) atTop (π[Icc I.lower I.upper] z) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ hJuz (Eventually.of_forall hJu_mem)
rcases H_nhds z (h0 βΈ hzJ 0) with β¨U, hUz, hUβ©
rcases (tendsto_lift'.1 (hJlz.Icc hJuz) U hUz).exists with β¨m, hUmβ©
exact hJp m (hU (J m) (hJle m) m (hzJ m) hUm (hJsub m))
end Box
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/Tagged.lean | import Mathlib.Analysis.BoxIntegral.Partition.Basic
/-!
# Tagged partitions
A tagged (pre)partition is a (pre)partition `Ο` enriched with a tagged point for each box of
`Ο`. For simplicity we require that the function `BoxIntegral.TaggedPrepartition.tag` is defined
on all boxes `J : Box ΞΉ` but use its values only on boxes of the partition. Given
`Ο : BoxIntegral.TaggedPrepartition I`, we require that each `BoxIntegral.TaggedPrepartition Ο J`
belongs to `BoxIntegral.Box.Icc I`. If for every `J β Ο`, `Ο.tag J` belongs to `J.Icc`, then `Ο` is
called a *Henstock* partition. We do not include this assumption into the definition of a tagged
(pre)partition because McShane integral is defined as a limit along tagged partitions without this
requirement.
## Tags
rectangular box, box partition
-/
noncomputable section
open Finset Function ENNReal NNReal Set
namespace BoxIntegral
variable {ΞΉ : Type*}
/-- A tagged prepartition is a prepartition enriched with a tagged point for each box of the
prepartition. For simplicity we require that `tag` is defined for all boxes in `ΞΉ β β` but
we will use only the values of `tag` on the boxes of the partition. -/
structure TaggedPrepartition (I : Box ΞΉ) extends Prepartition I where
/-- Choice of tagged point of each box in this prepartition:
we extend this to a total function, on all boxes in `ΞΉ β β`. -/
tag : Box ΞΉ β ΞΉ β β
/-- Each tagged point belongs to `I` -/
tag_mem_Icc : β J, tag J β Box.Icc I
namespace TaggedPrepartition
variable {I J Jβ Jβ : Box ΞΉ} (Ο : TaggedPrepartition I) {x : ΞΉ β β}
instance : Membership (Box ΞΉ) (TaggedPrepartition I) :=
β¨fun Ο J => J β Ο.boxesβ©
@[simp]
theorem mem_toPrepartition {Ο : TaggedPrepartition I} : J β Ο.toPrepartition β J β Ο := Iff.rfl
@[simp]
theorem mem_mk (Ο : Prepartition I) (f h) : J β mk Ο f h β J β Ο := Iff.rfl
/-- Union of all boxes of a tagged prepartition. -/
def iUnion : Set (ΞΉ β β) :=
Ο.toPrepartition.iUnion
theorem iUnion_def : Ο.iUnion = β J β Ο, βJ := rfl
@[simp]
theorem iUnion_mk (Ο : Prepartition I) (f h) : (mk Ο f h).iUnion = Ο.iUnion := rfl
@[simp]
theorem iUnion_toPrepartition : Ο.toPrepartition.iUnion = Ο.iUnion := rfl
@[simp]
theorem mem_iUnion : x β Ο.iUnion β β J β Ο, x β J := by
convert Set.mem_iUnionβ
rw [Box.mem_coe, mem_toPrepartition, exists_prop]
theorem subset_iUnion (h : J β Ο) : βJ β Ο.iUnion :=
subset_biUnion_of_mem h
theorem iUnion_subset : Ο.iUnion β I :=
iUnionβ_subset Ο.le_of_mem'
/-- A tagged prepartition is a partition if it covers the whole box. -/
def IsPartition :=
Ο.toPrepartition.IsPartition
theorem isPartition_iff_iUnion_eq : IsPartition Ο β Ο.iUnion = I :=
Prepartition.isPartition_iff_iUnion_eq
/-- The tagged partition made of boxes of `Ο` that satisfy predicate `p`. -/
@[simps! -fullyApplied]
def filter (p : Box ΞΉ β Prop) : TaggedPrepartition I :=
β¨Ο.1.filter p, Ο.2, Ο.3β©
@[simp]
theorem mem_filter {p : Box ΞΉ β Prop} : J β Ο.filter p β J β Ο β§ p J := by
classical exact Finset.mem_filter
@[simp]
theorem iUnion_filter_not (Ο : TaggedPrepartition I) (p : Box ΞΉ β Prop) :
(Ο.filter fun J => Β¬p J).iUnion = Ο.iUnion \ (Ο.filter p).iUnion :=
Ο.toPrepartition.iUnion_filter_not p
end TaggedPrepartition
namespace Prepartition
variable {I J : Box ΞΉ}
/-- Given a partition `Ο` of `I : BoxIntegral.Box ΞΉ` and a collection of tagged partitions
`Οi J` of all boxes `J β Ο`, returns the tagged partition of `I` into all the boxes of `Οi J`
with tags coming from `(Οi J).tag`. -/
def biUnionTagged (Ο : Prepartition I) (Οi : β J : Box ΞΉ, TaggedPrepartition J) :
TaggedPrepartition I where
toPrepartition := Ο.biUnion fun J => (Οi J).toPrepartition
tag J := (Οi (Ο.biUnionIndex (fun J => (Οi J).toPrepartition) J)).tag J
tag_mem_Icc _ := Box.le_iff_Icc.1 (Ο.biUnionIndex_le _ _) ((Οi _).tag_mem_Icc _)
@[simp]
theorem mem_biUnionTagged (Ο : Prepartition I) {Οi : β J, TaggedPrepartition J} :
J β Ο.biUnionTagged Οi β β J' β Ο, J β Οi J' :=
Ο.mem_biUnion
theorem tag_biUnionTagged (Ο : Prepartition I) {Οi : β J, TaggedPrepartition J} (hJ : J β Ο) {J'}
(hJ' : J' β Οi J) : (Ο.biUnionTagged Οi).tag J' = (Οi J).tag J' := by
rw [β Ο.biUnionIndex_of_mem (Οi := fun J => (Οi J).toPrepartition) hJ hJ']
rfl
@[simp]
theorem iUnion_biUnionTagged (Ο : Prepartition I) (Οi : β J, TaggedPrepartition J) :
(Ο.biUnionTagged Οi).iUnion = β J β Ο, (Οi J).iUnion :=
iUnion_biUnion _ _
theorem forall_biUnionTagged (p : (ΞΉ β β) β Box ΞΉ β Prop) (Ο : Prepartition I)
(Οi : β J, TaggedPrepartition J) :
(β J β Ο.biUnionTagged Οi, p ((Ο.biUnionTagged Οi).tag J) J) β
β J β Ο, β J' β Οi J, p ((Οi J).tag J') J' := by
simp only [mem_biUnionTagged]
refine β¨fun H J hJ J' hJ' => ?_, fun H J' β¨J, hJ, hJ'β© => ?_β©
Β· rw [β Ο.tag_biUnionTagged hJ hJ']
exact H J' β¨J, hJ, hJ'β©
Β· rw [Ο.tag_biUnionTagged hJ hJ']
exact H J hJ J' hJ'
theorem IsPartition.biUnionTagged {Ο : Prepartition I} (h : IsPartition Ο)
{Οi : β J, TaggedPrepartition J} (hi : β J β Ο, (Οi J).IsPartition) :
(Ο.biUnionTagged Οi).IsPartition :=
h.biUnion hi
end Prepartition
namespace TaggedPrepartition
variable {I J : Box ΞΉ} {Ο Οβ Οβ : TaggedPrepartition I} {x : ΞΉ β β}
/-- Given a tagged partition `Ο` of `I` and a (not tagged) partition `Οi J hJ` of each `J β Ο`,
returns the tagged partition of `I` into all the boxes of all `Οi J hJ`. The tag of a box `J`
is defined to be the `Ο.tag` of the box of the partition `Ο` that includes `J`.
Note that usually the result is not a Henstock partition. -/
@[simps -fullyApplied tag]
def biUnionPrepartition (Ο : TaggedPrepartition I) (Οi : β J : Box ΞΉ, Prepartition J) :
TaggedPrepartition I where
toPrepartition := Ο.toPrepartition.biUnion Οi
tag J := Ο.tag (Ο.toPrepartition.biUnionIndex Οi J)
tag_mem_Icc _ := Ο.tag_mem_Icc _
theorem IsPartition.biUnionPrepartition {Ο : TaggedPrepartition I} (h : IsPartition Ο)
{Οi : β J, Prepartition J} (hi : β J β Ο, (Οi J).IsPartition) :
(Ο.biUnionPrepartition Οi).IsPartition :=
h.biUnion hi
/-- Given two partitions `Οβ` and `Οβ`, one of them tagged and the other is not, returns the tagged
partition with `toPrepartition = Οβ.toPrepartition β Οβ` and tags coming from `Οβ`.
Note that usually the result is not a Henstock partition. -/
def infPrepartition (Ο : TaggedPrepartition I) (Ο' : Prepartition I) : TaggedPrepartition I :=
Ο.biUnionPrepartition fun J => Ο'.restrict J
@[simp]
theorem infPrepartition_toPrepartition (Ο : TaggedPrepartition I) (Ο' : Prepartition I) :
(Ο.infPrepartition Ο').toPrepartition = Ο.toPrepartition β Ο' := rfl
theorem mem_infPrepartition_comm :
J β Οβ.infPrepartition Οβ.toPrepartition β J β Οβ.infPrepartition Οβ.toPrepartition := by
simp only [β mem_toPrepartition, infPrepartition_toPrepartition, inf_comm]
theorem IsPartition.infPrepartition (hβ : Οβ.IsPartition) {Οβ : Prepartition I}
(hβ : Οβ.IsPartition) : (Οβ.infPrepartition Οβ).IsPartition :=
hβ.inf hβ
open Metric
/-- A tagged partition is said to be a Henstock partition if for each `J β Ο`, the tag of `J`
belongs to `J.Icc`. -/
def IsHenstock (Ο : TaggedPrepartition I) : Prop :=
β J β Ο, Ο.tag J β Box.Icc J
@[simp]
theorem isHenstock_biUnionTagged {Ο : Prepartition I} {Οi : β J, TaggedPrepartition J} :
IsHenstock (Ο.biUnionTagged Οi) β β J β Ο, (Οi J).IsHenstock :=
Ο.forall_biUnionTagged (fun x J => x β Box.Icc J) Οi
/-- In a Henstock prepartition, there are at most `2 ^ Fintype.card ΞΉ` boxes with a given tag. -/
theorem IsHenstock.card_filter_tag_eq_le [Fintype ΞΉ] (h : Ο.IsHenstock) (x : ΞΉ β β) :
#{J β Ο.boxes | Ο.tag J = x} β€ 2 ^ Fintype.card ΞΉ := by
classical
calc
#{J β Ο.boxes | Ο.tag J = x} β€ #{J β Ο.boxes | x β Box.Icc J} := by
refine Finset.card_le_card fun J hJ => ?_
rw [Finset.mem_filter] at hJ β’; rcases hJ with β¨hJ, rflβ©
exact β¨hJ, h J hJβ©
_ β€ 2 ^ Fintype.card ΞΉ := Ο.toPrepartition.card_filter_mem_Icc_le x
/-- A tagged partition `Ο` is subordinate to `r : (ΞΉ β β) β β` if each box `J β Ο` is included in
the closed ball with center `Ο.tag J` and radius `r (Ο.tag J)`. -/
def IsSubordinate [Fintype ΞΉ] (Ο : TaggedPrepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) : Prop :=
β J β Ο, Box.Icc J β closedBall (Ο.tag J) (r <| Ο.tag J)
variable {r rβ rβ : (ΞΉ β β) β Ioi (0 : β)}
@[simp]
theorem isSubordinate_biUnionTagged [Fintype ΞΉ] {Ο : Prepartition I}
{Οi : β J, TaggedPrepartition J} :
IsSubordinate (Ο.biUnionTagged Οi) r β β J β Ο, (Οi J).IsSubordinate r :=
Ο.forall_biUnionTagged (fun x J => Box.Icc J β closedBall x (r x)) Οi
theorem IsSubordinate.biUnionPrepartition [Fintype ΞΉ] (h : IsSubordinate Ο r)
(Οi : β J, Prepartition J) : IsSubordinate (Ο.biUnionPrepartition Οi) r :=
fun _ hJ => Subset.trans (Box.le_iff_Icc.1 <| Ο.toPrepartition.le_biUnionIndex hJ) <|
h _ <| Ο.toPrepartition.biUnionIndex_mem hJ
theorem IsSubordinate.infPrepartition [Fintype ΞΉ] (h : IsSubordinate Ο r) (Ο' : Prepartition I) :
IsSubordinate (Ο.infPrepartition Ο') r :=
h.biUnionPrepartition _
theorem IsSubordinate.mono' [Fintype ΞΉ] {Ο : TaggedPrepartition I} (hrβ : Ο.IsSubordinate rβ)
(h : β J β Ο, rβ (Ο.tag J) β€ rβ (Ο.tag J)) : Ο.IsSubordinate rβ :=
fun _ hJ _ hx => closedBall_subset_closedBall (h _ hJ) (hrβ _ hJ hx)
theorem IsSubordinate.mono [Fintype ΞΉ] {Ο : TaggedPrepartition I} (hrβ : Ο.IsSubordinate rβ)
(h : β x β Box.Icc I, rβ x β€ rβ x) : Ο.IsSubordinate rβ :=
hrβ.mono' fun J _ => h _ <| Ο.tag_mem_Icc J
theorem IsSubordinate.diam_le [Fintype ΞΉ] {Ο : TaggedPrepartition I} (h : Ο.IsSubordinate r)
(hJ : J β Ο.boxes) : diam (Box.Icc J) β€ 2 * r (Ο.tag J) :=
calc
diam (Box.Icc J) β€ diam (closedBall (Ο.tag J) (r <| Ο.tag J)) :=
diam_mono (h J hJ) isBounded_closedBall
_ β€ 2 * r (Ο.tag J) := diam_closedBall (le_of_lt (r _).2)
/-- Tagged prepartition with single box and prescribed tag. -/
@[simps! -fullyApplied]
def single (I J : Box ΞΉ) (hJ : J β€ I) (x : ΞΉ β β) (h : x β Box.Icc I) : TaggedPrepartition I :=
β¨Prepartition.single I J hJ, fun _ => x, fun _ => hβ©
@[simp]
theorem mem_single {J'} (hJ : J β€ I) (h : x β Box.Icc I) : J' β single I J hJ x h β J' = J :=
Finset.mem_singleton
instance (I : Box ΞΉ) : Inhabited (TaggedPrepartition I) :=
β¨single I I le_rfl I.upper I.upper_mem_Iccβ©
theorem isPartition_single_iff (hJ : J β€ I) (h : x β Box.Icc I) :
(single I J hJ x h).IsPartition β J = I :=
Prepartition.isPartition_single_iff hJ
theorem isPartition_single (h : x β Box.Icc I) : (single I I le_rfl x h).IsPartition :=
Prepartition.isPartitionTop I
theorem forall_mem_single (p : (ΞΉ β β) β Box ΞΉ β Prop) (hJ : J β€ I) (h : x β Box.Icc I) :
(β J' β single I J hJ x h, p ((single I J hJ x h).tag J') J') β p x J := by simp
@[simp]
theorem isHenstock_single_iff (hJ : J β€ I) (h : x β Box.Icc I) :
IsHenstock (single I J hJ x h) β x β Box.Icc J :=
forall_mem_single (fun x J => x β Box.Icc J) hJ h
theorem isHenstock_single (h : x β Box.Icc I) : IsHenstock (single I I le_rfl x h) :=
(isHenstock_single_iff (le_refl I) h).2 h
@[simp]
theorem isSubordinate_single [Fintype ΞΉ] (hJ : J β€ I) (h : x β Box.Icc I) :
IsSubordinate (single I J hJ x h) r β Box.Icc J β closedBall x (r x) :=
forall_mem_single (fun x J => Box.Icc J β closedBall x (r x)) hJ h
@[simp]
theorem iUnion_single (hJ : J β€ I) (h : x β Box.Icc I) : (single I J hJ x h).iUnion = J :=
Prepartition.iUnion_single hJ
open scoped Classical in
/-- Union of two tagged prepartitions with disjoint unions of boxes. -/
def disjUnion (Οβ Οβ : TaggedPrepartition I) (h : Disjoint Οβ.iUnion Οβ.iUnion) :
TaggedPrepartition I where
toPrepartition := Οβ.toPrepartition.disjUnion Οβ.toPrepartition h
tag := Οβ.boxes.piecewise Οβ.tag Οβ.tag
tag_mem_Icc J := by
dsimp only [Finset.piecewise]
split_ifs
exacts [Οβ.tag_mem_Icc J, Οβ.tag_mem_Icc J]
open scoped Classical in
@[simp]
theorem disjUnion_boxes (h : Disjoint Οβ.iUnion Οβ.iUnion) :
(Οβ.disjUnion Οβ h).boxes = Οβ.boxes βͺ Οβ.boxes := rfl
@[simp]
theorem mem_disjUnion (h : Disjoint Οβ.iUnion Οβ.iUnion) :
J β Οβ.disjUnion Οβ h β J β Οβ β¨ J β Οβ := by
classical exact Finset.mem_union
@[simp]
theorem iUnion_disjUnion (h : Disjoint Οβ.iUnion Οβ.iUnion) :
(Οβ.disjUnion Οβ h).iUnion = Οβ.iUnion βͺ Οβ.iUnion :=
Prepartition.iUnion_disjUnion h
theorem disjUnion_tag_of_mem_left (h : Disjoint Οβ.iUnion Οβ.iUnion) (hJ : J β Οβ) :
(Οβ.disjUnion Οβ h).tag J = Οβ.tag J :=
dif_pos hJ
theorem disjUnion_tag_of_mem_right (h : Disjoint Οβ.iUnion Οβ.iUnion) (hJ : J β Οβ) :
(Οβ.disjUnion Οβ h).tag J = Οβ.tag J :=
dif_neg fun hβ => h.le_bot β¨Οβ.subset_iUnion hβ J.upper_mem, Οβ.subset_iUnion hJ J.upper_memβ©
theorem IsSubordinate.disjUnion [Fintype ΞΉ] (hβ : IsSubordinate Οβ r) (hβ : IsSubordinate Οβ r)
(h : Disjoint Οβ.iUnion Οβ.iUnion) : IsSubordinate (Οβ.disjUnion Οβ h) r := by
classical
refine fun J hJ => (Finset.mem_union.1 hJ).elim (fun hJ => ?_) fun hJ => ?_
Β· rw [disjUnion_tag_of_mem_left _ hJ]
exact hβ _ hJ
Β· rw [disjUnion_tag_of_mem_right _ hJ]
exact hβ _ hJ
theorem IsHenstock.disjUnion (hβ : IsHenstock Οβ) (hβ : IsHenstock Οβ)
(h : Disjoint Οβ.iUnion Οβ.iUnion) : IsHenstock (Οβ.disjUnion Οβ h) := by
classical
refine fun J hJ => (Finset.mem_union.1 hJ).elim (fun hJ => ?_) fun hJ => ?_
Β· rw [disjUnion_tag_of_mem_left _ hJ]
exact hβ _ hJ
Β· rw [disjUnion_tag_of_mem_right _ hJ]
exact hβ _ hJ
/-- If `I β€ J`, then every tagged prepartition of `I` is a tagged prepartition of `J`. -/
def embedBox (I J : Box ΞΉ) (h : I β€ J) : TaggedPrepartition I βͺ TaggedPrepartition J where
toFun Ο :=
{ Ο with
le_of_mem' := fun J' hJ' => (Ο.le_of_mem' J' hJ').trans h
tag_mem_Icc := fun J => Box.le_iff_Icc.1 h (Ο.tag_mem_Icc J) }
inj' := by
rintro β¨β¨bβ, hβle, hβdβ©, tβ, htββ© β¨β¨bβ, hβle, hβdβ©, tβ, htββ© H
simpa using H
section Distortion
variable [Fintype ΞΉ] (Ο)
open Finset
/-- The distortion of a tagged prepartition is the maximum of distortions of its boxes. -/
def distortion : ββ₯0 :=
Ο.toPrepartition.distortion
theorem distortion_le_of_mem (h : J β Ο) : J.distortion β€ Ο.distortion :=
le_sup h
theorem distortion_le_iff {c : ββ₯0} : Ο.distortion β€ c β β J β Ο, Box.distortion J β€ c :=
Finset.sup_le_iff
@[simp]
theorem _root_.BoxIntegral.Prepartition.distortion_biUnionTagged (Ο : Prepartition I)
(Οi : β J, TaggedPrepartition J) :
(Ο.biUnionTagged Οi).distortion = Ο.boxes.sup fun J => (Οi J).distortion := by
classical exact sup_biUnion _ _
@[simp]
theorem distortion_biUnionPrepartition (Ο : TaggedPrepartition I) (Οi : β J, Prepartition J) :
(Ο.biUnionPrepartition Οi).distortion = Ο.boxes.sup fun J => (Οi J).distortion := by
classical exact sup_biUnion _ _
@[simp]
theorem distortion_disjUnion (h : Disjoint Οβ.iUnion Οβ.iUnion) :
(Οβ.disjUnion Οβ h).distortion = max Οβ.distortion Οβ.distortion := by
classical exact sup_union
theorem distortion_of_const {c} (hβ : Ο.boxes.Nonempty) (hβ : β J β Ο, Box.distortion J = c) :
Ο.distortion = c :=
(sup_congr rfl hβ).trans (sup_const hβ _)
@[simp]
theorem distortion_single (hJ : J β€ I) (h : x β Box.Icc I) :
distortion (single I J hJ x h) = J.distortion :=
sup_singleton
theorem distortion_filter_le (p : Box ΞΉ β Prop) : (Ο.filter p).distortion β€ Ο.distortion := by
classical exact sup_mono (filter_subset _ _)
end Distortion
end TaggedPrepartition
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/Additive.lean | import Mathlib.Analysis.BoxIntegral.Partition.Split
import Mathlib.Analysis.Normed.Operator.Mul
/-!
# Box additive functions
We say that a function `f : Box ΞΉ β M` from boxes in `ββΏ` to a commutative additive monoid `M` is
*box additive* on subboxes of `Iβ : WithTop (Box ΞΉ)` if for any box `J`, `βJ β€ Iβ`, and a partition
`Ο` of `J`, `f J = β J' β Ο.boxes, f J'`. We use `Iβ : WithTop (Box ΞΉ)` instead of `Iβ : Box ΞΉ` to
use the same definition for functions box additive on subboxes of a box and for functions box
additive on all boxes.
Examples of box-additive functions include the measure of a box and the integral of a fixed
integrable function over a box.
In this file we define box-additive functions and prove that a function such that
`f J = f (J β© {x | x i < y}) + f (J β© {x | y β€ x i})` is box-additive.
## Tags
rectangular box, additive function
-/
noncomputable section
open Function Set
namespace BoxIntegral
variable {ΞΉ M : Type*} {n : β}
/-- A function on `Box ΞΉ` is called box additive if for every box `J` and a partition `Ο` of `J`
we have `f J = β Ji β Ο.boxes, f Ji`. A function is called box additive on subboxes of `I : Box ΞΉ`
if the same property holds for `J β€ I`. We formalize these two notions in the same definition
using `I : WithBot (Box ΞΉ)`: the value `I = β€` corresponds to functions box additive on the whole
space. -/
structure BoxAdditiveMap (ΞΉ M : Type*) [AddCommMonoid M] (I : WithTop (Box ΞΉ)) where
/-- The function underlying this additive map. -/
toFun : Box ΞΉ β M
sum_partition_boxes' : β J : Box ΞΉ, βJ β€ I β β Ο : Prepartition J, Ο.IsPartition β
β Ji β Ο.boxes, toFun Ji = toFun J
/-- A function on `Box ΞΉ` is called box additive if for every box `J` and a partition `Ο` of `J`
we have `f J = β Ji β Ο.boxes, f Ji`. -/
scoped notation:25 ΞΉ " βα΅α΅ " M => BoxIntegral.BoxAdditiveMap ΞΉ M β€
@[inherit_doc] scoped notation:25 ΞΉ " βα΅α΅[" I "] " M => BoxIntegral.BoxAdditiveMap ΞΉ M I
namespace BoxAdditiveMap
open Box Prepartition Finset
variable {N : Type*} [AddCommMonoid M] [AddCommMonoid N] {Iβ : WithTop (Box ΞΉ)} {I : Box ΞΉ}
{i : ΞΉ}
instance : FunLike (ΞΉ βα΅α΅[Iβ] M) (Box ΞΉ) M where
coe := toFun
coe_injective' f g h := by cases f; cases g; congr
initialize_simps_projections BoxIntegral.BoxAdditiveMap (toFun β apply)
@[simp]
theorem coe_mk (f h) : β(mk f h : ΞΉ βα΅α΅[Iβ] M) = f := rfl
theorem coe_injective : Injective fun (f : ΞΉ βα΅α΅[Iβ] M) x => f x :=
DFunLike.coe_injective
theorem coe_inj {f g : ΞΉ βα΅α΅[Iβ] M} : (f : Box ΞΉ β M) = g β f = g := DFunLike.coe_fn_eq
theorem sum_partition_boxes (f : ΞΉ βα΅α΅[Iβ] M) (hI : βI β€ Iβ) {Ο : Prepartition I}
(h : Ο.IsPartition) : β J β Ο.boxes, f J = f I :=
f.sum_partition_boxes' I hI Ο h
@[simps -fullyApplied]
instance : Zero (ΞΉ βα΅α΅[Iβ] M) :=
β¨β¨0, fun _ _ _ _ => sum_const_zeroβ©β©
instance : Inhabited (ΞΉ βα΅α΅[Iβ] M) :=
β¨0β©
instance : Add (ΞΉ βα΅α΅[Iβ] M) :=
β¨fun f g =>
β¨f + g, fun I hI Ο hΟ => by
simp only [Pi.add_apply, sum_add_distrib, sum_partition_boxes _ hI hΟ]β©β©
instance {R} [Monoid R] [DistribMulAction R M] : SMul R (ΞΉ βα΅α΅[Iβ] M) :=
β¨fun r f =>
β¨r β’ (f : Box ΞΉ β M), fun I hI Ο hΟ => by
simp only [Pi.smul_apply, β smul_sum, sum_partition_boxes _ hI hΟ]β©β©
instance : AddCommMonoid (ΞΉ βα΅α΅[Iβ] M) :=
Function.Injective.addCommMonoid _ coe_injective rfl (fun _ _ => rfl) fun _ _ => rfl
@[simp]
theorem map_split_add (f : ΞΉ βα΅α΅[Iβ] M) (hI : βI β€ Iβ) (i : ΞΉ) (x : β) :
(I.splitLower i x).elim' 0 f + (I.splitUpper i x).elim' 0 f = f I := by
rw [β f.sum_partition_boxes hI (isPartitionSplit I i x), sum_split_boxes]
/-- If `f` is box-additive on subboxes of `Iβ`, then it is box-additive on subboxes of any
`I β€ Iβ`. -/
@[simps]
def restrict (f : ΞΉ βα΅α΅[Iβ] M) (I : WithTop (Box ΞΉ)) (hI : I β€ Iβ) : ΞΉ βα΅α΅[I] M :=
β¨f, fun J hJ => f.2 J (hJ.trans hI)β©
/-- If `f : Box ΞΉ β M` is box additive on partitions of the form `split I i x`, then it is box
additive. -/
def ofMapSplitAdd [Finite ΞΉ] (f : Box ΞΉ β M) (Iβ : WithTop (Box ΞΉ))
(hf : β I : Box ΞΉ, βI β€ Iβ β β {i x}, x β Ioo (I.lower i) (I.upper i) β
(I.splitLower i x).elim' 0 f + (I.splitUpper i x).elim' 0 f = f I) :
ΞΉ βα΅α΅[Iβ] M := by
classical
refine β¨f, ?_β©
replace hf (I : Box ΞΉ) (hI : βI β€ Iβ) (s) : β J β (splitMany I s).boxes, f J = f I := by
induction s using Finset.induction_on with
| empty => simp
| insert a s _ ihs =>
rw [splitMany_insert, inf_split, β ihs, biUnion_boxes, sum_biUnion_boxes]
refine Finset.sum_congr rfl fun J' hJ' => ?_
by_cases h : a.2 β Ioo (J'.lower a.1) (J'.upper a.1)
Β· rw [sum_split_boxes]
exact hf _ ((WithTop.coe_le_coe.2 <| le_of_mem _ hJ').trans hI) h
Β· rw [split_of_notMem_Ioo h, top_boxes, Finset.sum_singleton]
intro I hI Ο hΟ
have Hle : β J β Ο, βJ β€ Iβ := fun J hJ => (WithTop.coe_le_coe.2 <| Ο.le_of_mem hJ).trans hI
rcases hΟ.exists_splitMany_le with β¨s, hsβ©
rw [β hf _ hI, β inf_of_le_right hs, inf_splitMany, biUnion_boxes, sum_biUnion_boxes]
exact Finset.sum_congr rfl fun J hJ => (hf _ (Hle _ hJ) _).symm
/-- If `g : M β N` is an additive map and `f` is a box additive map, then `g β f` is a box additive
map. -/
@[simps -fullyApplied]
def map (f : ΞΉ βα΅α΅[Iβ] M) (g : M β+ N) : ΞΉ βα΅α΅[Iβ] N where
toFun := g β f
sum_partition_boxes' I hI Ο hΟ := by simp_rw [comp, β map_sum, f.sum_partition_boxes hI hΟ]
/-- If `f` is a box additive function on subboxes of `I` and `Οβ`, `Οβ` are two prepartitions of
`I` that cover the same part of `I`, then `β J β Οβ.boxes, f J = β J β Οβ.boxes, f J`. -/
theorem sum_boxes_congr [Finite ΞΉ] (f : ΞΉ βα΅α΅[Iβ] M) (hI : βI β€ Iβ) {Οβ Οβ : Prepartition I}
(h : Οβ.iUnion = Οβ.iUnion) : β J β Οβ.boxes, f J = β J β Οβ.boxes, f J := by
rcases exists_splitMany_inf_eq_filter_of_finite {Οβ, Οβ} ((finite_singleton _).insert _) with
β¨s, hsβ©
simp only [inf_splitMany] at hs
rcases hs _ (Or.inl rfl), hs _ (Or.inr rfl) with β¨hβ, hββ©; clear hs
rw [h] at hβ
calc
β J β Οβ.boxes, f J = β J β Οβ.boxes, β J' β (splitMany J s).boxes, f J' :=
Finset.sum_congr rfl fun J hJ => (f.sum_partition_boxes ?_ (isPartition_splitMany _ _)).symm
_ = β J β (Οβ.biUnion fun J => splitMany J s).boxes, f J := (sum_biUnion_boxes _ _ _).symm
_ = β J β (Οβ.biUnion fun J => splitMany J s).boxes, f J := by rw [hβ, hβ]
_ = β J β Οβ.boxes, β J' β (splitMany J s).boxes, f J' := sum_biUnion_boxes _ _ _
_ = β J β Οβ.boxes, f J :=
Finset.sum_congr rfl fun J hJ => f.sum_partition_boxes ?_ (isPartition_splitMany _ _)
exacts [(WithTop.coe_le_coe.2 <| Οβ.le_of_mem hJ).trans hI,
(WithTop.coe_le_coe.2 <| Οβ.le_of_mem hJ).trans hI]
section ToSMul
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
/-- If `f` is a box-additive map, then so is the map sending `I` to the scalar multiplication
by `f I` as a continuous linear map from `E` to itself. -/
def toSMul (f : ΞΉ βα΅α΅[Iβ] β) : ΞΉ βα΅α΅[Iβ] E βL[β] E :=
f.map (ContinuousLinearMap.lsmul β β).toLinearMap.toAddMonoidHom
@[simp]
theorem toSMul_apply (f : ΞΉ βα΅α΅[Iβ] β) (I : Box ΞΉ) (x : E) : f.toSMul I x = f I β’ x := rfl
end ToSMul
/-- Given a box `Iβ` in `ββΏβΊΒΉ`, `f x : Box (Fin n) β G` is a family of functions indexed by a real
`x` and for `x β [Iβ.lower i, Iβ.upper i]`, `f x` is box-additive on subboxes of the `i`-th face of
`Iβ`, then `fun J β¦ f (J.upper i) (J.face i) - f (J.lower i) (J.face i)` is box-additive on subboxes
of `Iβ`. -/
@[simps!]
def upperSubLower.{u} {G : Type u} [AddCommGroup G] (Iβ : Box (Fin (n + 1))) (i : Fin (n + 1))
(f : β β Box (Fin n) β G) (fb : Icc (Iβ.lower i) (Iβ.upper i) β Fin n βα΅α΅[Iβ.face i] G)
(hf : β (x) (hx : x β Icc (Iβ.lower i) (Iβ.upper i)) (J), f x J = fb β¨x, hxβ© J) :
Fin (n + 1) βα΅α΅[Iβ] G :=
ofMapSplitAdd (fun J : Box (Fin (n + 1)) => f (J.upper i) (J.face i) - f (J.lower i) (J.face i))
Iβ
(by
intro J hJ j x
rw [WithTop.coe_le_coe] at hJ
refine i.succAboveCases (fun hx => ?_) (fun j hx => ?_) j
Β· simp only [Box.splitLower_def hx, Box.splitUpper_def hx, update_self, β WithBot.some_eq_coe,
Option.elim', Box.face, Function.comp_def, update_of_ne (Fin.succAbove_ne _ _)]
abel
Β· have : (J.face i : WithTop (Box (Fin n))) β€ Iβ.face i :=
WithTop.coe_le_coe.2 (face_mono hJ i)
rw [le_iff_Icc, @Box.Icc_eq_pi _ Iβ] at hJ
simp only
rw [hf _ (hJ J.upper_mem_Icc _ trivial), hf _ (hJ J.lower_mem_Icc _ trivial),
β (fb _).map_split_add this j x, β (fb _).map_split_add this j x]
have hx' : x β Ioo ((J.face i).lower j) ((J.face i).upper j) := hx
simp only [Box.splitLower_def hx, Box.splitUpper_def hx, Box.splitLower_def hx',
Box.splitUpper_def hx', β WithBot.some_eq_coe, Option.elim', Box.face_mk,
update_of_ne (Fin.succAbove_ne _ _).symm, sub_add_sub_comm,
update_comp_eq_of_injective _ (Fin.strictMono_succAbove i).injective j x, β hf]
simp only [Box.face])
end BoxAdditiveMap
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/Split.lean | import Mathlib.Analysis.BoxIntegral.Partition.Basic
/-!
# Split a box along one or more hyperplanes
## Main definitions
A hyperplane `{x : ΞΉ β β | x i = a}` splits a rectangular box `I : BoxIntegral.Box ΞΉ` into two
smaller boxes. If `a β Ioo (I.lower i, I.upper i)`, then one of these boxes is empty, so it is not a
box in the sense of `BoxIntegral.Box`.
We introduce the following definitions.
* `BoxIntegral.Box.splitLower I i a` and `BoxIntegral.Box.splitUpper I i a` are these boxes (as
`WithBot (BoxIntegral.Box ΞΉ)`);
* `BoxIntegral.Prepartition.split I i a` is the partition of `I` made of these two boxes (or of one
box `I` if one of these boxes is empty);
* `BoxIntegral.Prepartition.splitMany I s`, where `s : Finset (ΞΉ Γ β)` is a finite set of
hyperplanes `{x : ΞΉ β β | x i = a}` encoded as pairs `(i, a)`, is the partition of `I` made by
cutting it along all the hyperplanes in `s`.
## Main results
The main result `BoxIntegral.Prepartition.exists_iUnion_eq_diff` says that any prepartition `Ο` of
`I` admits a prepartition `Ο'` of `I` that covers exactly `I \ Ο.iUnion`. One of these prepartitions
is available as `BoxIntegral.Prepartition.compl`.
## Tags
rectangular box, partition, hyperplane
-/
noncomputable section
open Function Set Filter
namespace BoxIntegral
variable {ΞΉ M : Type*} {n : β}
namespace Box
variable {I : Box ΞΉ} {i : ΞΉ} {x : β} {y : ΞΉ β β}
open scoped Classical in
/-- Given a box `I` and `x β (I.lower i, I.upper i)`, the hyperplane `{y : ΞΉ β β | y i = x}` splits
`I` into two boxes. `BoxIntegral.Box.splitLower I i x` is the box `I β© {y | y i β€ x}`
(if it is nonempty). As usual, we represent a box that may be empty as
`WithBot (BoxIntegral.Box ΞΉ)`. -/
def splitLower (I : Box ΞΉ) (i : ΞΉ) (x : β) : WithBot (Box ΞΉ) :=
mk' I.lower (update I.upper i (min x (I.upper i)))
@[simp]
theorem coe_splitLower : (splitLower I i x : Set (ΞΉ β β)) = βI β© { y | y i β€ x } := by
rw [splitLower, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and, β Pi.le_def,
le_update_iff, le_min_iff, and_assoc, and_forall_ne (p := fun j => y j β€ upper I j) i, mem_def]
rw [and_comm (a := y i β€ x)]
theorem splitLower_le : I.splitLower i x β€ I :=
withBotCoe_subset_iff.1 <| by simp
@[simp]
theorem splitLower_eq_bot {i x} : I.splitLower i x = β₯ β x β€ I.lower i := by
classical
rw [splitLower, mk'_eq_bot, exists_update_iff I.upper fun j y => y β€ I.lower j]
simp [(I.lower_lt_upper _).not_ge]
@[simp]
theorem splitLower_eq_self : I.splitLower i x = I β I.upper i β€ x := by
simp [splitLower]
theorem splitLower_def [DecidableEq ΞΉ] {i x} (h : x β Ioo (I.lower i) (I.upper i))
(h' : β j, I.lower j < update I.upper i x j :=
(forall_update_iff I.upper fun j y => I.lower j < y).2
β¨h.1, fun _ _ => I.lower_lt_upper _β©) :
I.splitLower i x = (β¨I.lower, update I.upper i x, h'β© : Box ΞΉ) := by
simp +unfoldPartialApp only [splitLower, mk'_eq_coe, min_eq_left h.2.le,
update, and_self]
open scoped Classical in
/-- Given a box `I` and `x β (I.lower i, I.upper i)`, the hyperplane `{y : ΞΉ β β | y i = x}` splits
`I` into two boxes. `BoxIntegral.Box.splitUpper I i x` is the box `I β© {y | x < y i}`
(if it is nonempty). As usual, we represent a box that may be empty as
`WithBot (BoxIntegral.Box ΞΉ)`. -/
def splitUpper (I : Box ΞΉ) (i : ΞΉ) (x : β) : WithBot (Box ΞΉ) :=
mk' (update I.lower i (max x (I.lower i))) I.upper
@[simp]
theorem coe_splitUpper : (splitUpper I i x : Set (ΞΉ β β)) = βI β© { y | x < y i } := by
classical
rw [splitUpper, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and,
forall_update_iff I.lower fun j z => z < y j, max_lt_iff, and_assoc (a := x < y i),
and_forall_ne (p := fun j => lower I j < y j) i, mem_def]
exact and_comm
theorem splitUpper_le : I.splitUpper i x β€ I :=
withBotCoe_subset_iff.1 <| by simp
@[simp]
theorem splitUpper_eq_bot {i x} : I.splitUpper i x = β₯ β I.upper i β€ x := by
classical
rw [splitUpper, mk'_eq_bot, exists_update_iff I.lower fun j y => I.upper j β€ y]
simp [(I.lower_lt_upper _).not_ge]
@[simp]
theorem splitUpper_eq_self : I.splitUpper i x = I β x β€ I.lower i := by
simp [splitUpper]
theorem splitUpper_def [DecidableEq ΞΉ] {i x} (h : x β Ioo (I.lower i) (I.upper i))
(h' : β j, update I.lower i x j < I.upper j :=
(forall_update_iff I.lower fun j y => y < I.upper j).2
β¨h.2, fun _ _ => I.lower_lt_upper _β©) :
I.splitUpper i x = (β¨update I.lower i x, I.upper, h'β© : Box ΞΉ) := by
simp +unfoldPartialApp only [splitUpper, mk'_eq_coe, max_eq_left h.1.le,
update, and_self]
theorem disjoint_splitLower_splitUpper (I : Box ΞΉ) (i : ΞΉ) (x : β) :
Disjoint (I.splitLower i x) (I.splitUpper i x) := by
rw [β disjoint_withBotCoe, coe_splitLower, coe_splitUpper]
refine (Disjoint.inf_left' _ ?_).inf_right' _
rw [Set.disjoint_left]
exact fun y (hle : y i β€ x) hlt => not_lt_of_ge hle hlt
theorem splitLower_ne_splitUpper (I : Box ΞΉ) (i : ΞΉ) (x : β) :
I.splitLower i x β I.splitUpper i x := by
rcases le_or_gt x (I.lower i) with h | _
Β· rw [splitUpper_eq_self.2 h, splitLower_eq_bot.2 h]
exact WithBot.bot_ne_coe
Β· refine (disjoint_splitLower_splitUpper I i x).ne ?_
rwa [Ne, splitLower_eq_bot, not_le]
end Box
namespace Prepartition
variable {I J : Box ΞΉ} {i : ΞΉ} {x : β}
open scoped Classical in
/-- The partition of `I : Box ΞΉ` into the boxes `I β© {y | y β€ x i}` and `I β© {y | x i < y}`.
One of these boxes can be empty, then this partition is just the single-box partition `β€`. -/
def split (I : Box ΞΉ) (i : ΞΉ) (x : β) : Prepartition I :=
ofWithBot {I.splitLower i x, I.splitUpper i x}
(by
simp only [Finset.mem_insert, Finset.mem_singleton]
rintro J (rfl | rfl)
exacts [Box.splitLower_le, Box.splitUpper_le])
(by
simp only [Finset.coe_insert, Finset.coe_singleton, true_and, Set.mem_singleton_iff,
pairwise_insert_of_symmetric symmetric_disjoint, pairwise_singleton]
rintro J rfl -
exact I.disjoint_splitLower_splitUpper i x)
@[simp]
theorem mem_split_iff : J β split I i x β βJ = I.splitLower i x β¨ βJ = I.splitUpper i x := by
simp [split]
theorem mem_split_iff' : J β split I i x β
(J : Set (ΞΉ β β)) = βI β© { y | y i β€ x } β¨ (J : Set (ΞΉ β β)) = βI β© { y | x < y i } := by
simp [mem_split_iff, β Box.withBotCoe_inj]
@[simp]
theorem iUnion_split (I : Box ΞΉ) (i : ΞΉ) (x : β) : (split I i x).iUnion = I := by
simp [split, β inter_union_distrib_left, β setOf_or, le_or_gt]
theorem isPartitionSplit (I : Box ΞΉ) (i : ΞΉ) (x : β) : IsPartition (split I i x) :=
isPartition_iff_iUnion_eq.2 <| iUnion_split I i x
theorem sum_split_boxes {M : Type*} [AddCommMonoid M] (I : Box ΞΉ) (i : ΞΉ) (x : β) (f : Box ΞΉ β M) :
(β J β (split I i x).boxes, f J) =
(I.splitLower i x).elim' 0 f + (I.splitUpper i x).elim' 0 f := by
classical
rw [split, sum_ofWithBot, Finset.sum_pair (I.splitLower_ne_splitUpper i x)]
/-- If `x β (I.lower i, I.upper i)`, then the hyperplane `{y | y i = x}` does not split `I`. -/
theorem split_of_notMem_Ioo (h : x β Ioo (I.lower i) (I.upper i)) : split I i x = β€ := by
refine ((isPartitionTop I).eq_of_boxes_subset fun J hJ => ?_).symm
rcases mem_top.1 hJ with rfl; clear hJ
rw [mem_boxes, mem_split_iff]
rw [mem_Ioo, not_and_or, not_lt, not_lt] at h
cases h <;> [right; left]
Β· rwa [eq_comm, Box.splitUpper_eq_self]
Β· rwa [eq_comm, Box.splitLower_eq_self]
@[deprecated (since := "2025-05-23")] alias split_of_not_mem_Ioo := split_of_notMem_Ioo
theorem coe_eq_of_mem_split_of_mem_le {y : ΞΉ β β} (hβ : J β split I i x) (hβ : y β J)
(hβ : y i β€ x) : (J : Set (ΞΉ β β)) = βI β© { y | y i β€ x } := by
refine (mem_split_iff'.1 hβ).resolve_right fun H => ?_
rw [β Box.mem_coe, H] at hβ
exact hβ.not_gt hβ.2
theorem coe_eq_of_mem_split_of_lt_mem {y : ΞΉ β β} (hβ : J β split I i x) (hβ : y β J)
(hβ : x < y i) : (J : Set (ΞΉ β β)) = βI β© { y | x < y i } := by
refine (mem_split_iff'.1 hβ).resolve_left fun H => ?_
rw [β Box.mem_coe, H] at hβ
exact hβ.not_ge hβ.2
@[simp]
theorem restrict_split (h : I β€ J) (i : ΞΉ) (x : β) : (split J i x).restrict I = split I i x := by
refine ((isPartitionSplit J i x).restrict h).eq_of_boxes_subset ?_
simp only [Finset.subset_iff, mem_boxes, mem_restrict', mem_split_iff']
have : β s, (I β© s : Set (ΞΉ β β)) β J := fun s => inter_subset_left.trans h
rintro Jβ β¨Jβ, Hβ | Hβ, Hββ© <;> [left; right] <;>
simp [Hβ, Hβ, inter_left_comm (I : Set (ΞΉ β β)), this]
theorem inf_split (Ο : Prepartition I) (i : ΞΉ) (x : β) :
Ο β split I i x = Ο.biUnion fun J => split J i x :=
biUnion_congr_of_le rfl fun _ hJ => restrict_split hJ i x
/-- Split a box along many hyperplanes `{y | y i = x}`; each hyperplane is given by the pair
`(i x)`. -/
def splitMany (I : Box ΞΉ) (s : Finset (ΞΉ Γ β)) : Prepartition I :=
s.inf fun p => split I p.1 p.2
@[simp]
theorem splitMany_empty (I : Box ΞΉ) : splitMany I β
= β€ :=
rfl
open scoped Classical in
@[simp]
theorem splitMany_insert (I : Box ΞΉ) (s : Finset (ΞΉ Γ β)) (p : ΞΉ Γ β) :
splitMany I (insert p s) = splitMany I s β split I p.1 p.2 := by
rw [splitMany, Finset.inf_insert, inf_comm, splitMany]
theorem splitMany_le_split (I : Box ΞΉ) {s : Finset (ΞΉ Γ β)} {p : ΞΉ Γ β} (hp : p β s) :
splitMany I s β€ split I p.1 p.2 :=
Finset.inf_le hp
theorem isPartition_splitMany (I : Box ΞΉ) (s : Finset (ΞΉ Γ β)) : IsPartition (splitMany I s) := by
classical
exact Finset.induction_on s (by simp only [splitMany_empty, isPartitionTop]) fun a s _ hs => by
simpa only [splitMany_insert, inf_split] using hs.biUnion fun J _ => isPartitionSplit _ _ _
@[simp]
theorem iUnion_splitMany (I : Box ΞΉ) (s : Finset (ΞΉ Γ β)) : (splitMany I s).iUnion = I :=
(isPartition_splitMany I s).iUnion_eq
theorem inf_splitMany {I : Box ΞΉ} (Ο : Prepartition I) (s : Finset (ΞΉ Γ β)) :
Ο β splitMany I s = Ο.biUnion fun J => splitMany J s := by
classical
induction s using Finset.induction_on with
| empty => simp
| insert p s _ ihp => simp_rw [splitMany_insert, β inf_assoc, ihp, inf_split, biUnion_assoc]
open scoped Classical in
/-- Let `s : Finset (ΞΉ Γ β)` be a set of hyperplanes `{x : ΞΉ β β | x i = r}` in `ΞΉ β β` encoded as
pairs `(i, r)`. Suppose that this set contains all faces of a box `J`. The hyperplanes of `s` split
a box `I` into subboxes. Let `Js` be one of them. If `J` and `Js` have nonempty intersection, then
`Js` is a subbox of `J`. -/
theorem not_disjoint_imp_le_of_subset_of_mem_splitMany {I J Js : Box ΞΉ} {s : Finset (ΞΉ Γ β)}
(H : β i, {(i, J.lower i), (i, J.upper i)} β s) (HJs : Js β splitMany I s)
(Hn : Β¬Disjoint (J : WithBot (Box ΞΉ)) Js) : Js β€ J := by
simp only [Finset.insert_subset_iff, Finset.singleton_subset_iff] at H
rcases Box.not_disjoint_coe_iff_nonempty_inter.mp Hn with β¨x, hx, hxsβ©
refine fun y hy i => β¨?_, ?_β©
Β· rcases splitMany_le_split I (H i).1 HJs with β¨Jl, Hmem : Jl β split I i (J.lower i), Hleβ©
have := Hle hxs
rw [β Box.coe_subset_coe, coe_eq_of_mem_split_of_lt_mem Hmem this (hx i).1] at Hle
exact (Hle hy).2
Β· rcases splitMany_le_split I (H i).2 HJs with β¨Jl, Hmem : Jl β split I i (J.upper i), Hleβ©
have := Hle hxs
rw [β Box.coe_subset_coe, coe_eq_of_mem_split_of_mem_le Hmem this (hx i).2] at Hle
exact (Hle hy).2
section Finite
variable [Finite ΞΉ]
/-- Let `s` be a finite set of boxes in `ββΏ = ΞΉ β β`. Then there exists a finite set `tβ` of
hyperplanes (namely, the set of all hyperfaces of boxes in `s`) such that for any `t β tβ`
and any box `I` in `ββΏ` the following holds. The hyperplanes from `t` split `I` into subboxes.
Let `J'` be one of them, and let `J` be one of the boxes in `s`. If these boxes have a nonempty
intersection, then `J' β€ J`. -/
theorem eventually_not_disjoint_imp_le_of_mem_splitMany (s : Finset (Box ΞΉ)) :
βαΆ t : Finset (ΞΉ Γ β) in atTop, β (I : Box ΞΉ), β J β s, β J' β splitMany I t,
Β¬Disjoint (J : WithBot (Box ΞΉ)) J' β J' β€ J := by
classical
cases nonempty_fintype ΞΉ
refine eventually_atTop.2
β¨s.biUnion fun J => Finset.univ.biUnion fun i => {(i, J.lower i), (i, J.upper i)},
fun t ht I J hJ J' hJ' => not_disjoint_imp_le_of_subset_of_mem_splitMany (fun i => ?_) hJ'β©
exact fun p hp =>
ht (Finset.mem_biUnion.2 β¨J, hJ, Finset.mem_biUnion.2 β¨i, Finset.mem_univ _, hpβ©β©)
theorem eventually_splitMany_inf_eq_filter (Ο : Prepartition I) :
βαΆ t : Finset (ΞΉ Γ β) in atTop,
Ο β splitMany I t = (splitMany I t).filter fun J => βJ β Ο.iUnion := by
refine (eventually_not_disjoint_imp_le_of_mem_splitMany Ο.boxes).mono fun t ht => ?_
refine le_antisymm ((biUnion_le_iff _).2 fun J hJ => ?_) (le_inf (fun J hJ => ?_) (filter_le _ _))
Β· refine ofWithBot_mono ?_
simp only [Finset.mem_image, mem_boxes, mem_filter]
rintro _ β¨Jβ, hβ, rflβ© hne
refine β¨_, β¨Jβ, β¨hβ, Subset.trans ?_ (Ο.subset_iUnion hJ)β©, rflβ©, le_rflβ©
exact ht I J hJ Jβ hβ (mt disjoint_iff.1 hne)
Β· rw [mem_filter] at hJ
rcases Set.mem_iUnionβ.1 (hJ.2 J.upper_mem) with β¨J', hJ', hmemβ©
refine β¨J', hJ', ht I _ hJ' _ hJ.1 <| Box.not_disjoint_coe_iff_nonempty_inter.2 ?_β©
exact β¨J.upper, hmem, J.upper_memβ©
theorem exists_splitMany_inf_eq_filter_of_finite (s : Set (Prepartition I)) (hs : s.Finite) :
β t : Finset (ΞΉ Γ β),
β Ο β s, Ο β splitMany I t = (splitMany I t).filter fun J => βJ β Ο.iUnion :=
haveI := fun Ο (_ : Ο β s) => eventually_splitMany_inf_eq_filter Ο
(hs.eventually_all.2 this).exists
/-- If `Ο` is a partition of `I`, then there exists a finite set `s` of hyperplanes such that
`splitMany I s β€ Ο`. -/
theorem IsPartition.exists_splitMany_le {I : Box ΞΉ} {Ο : Prepartition I} (h : IsPartition Ο) :
β s, splitMany I s β€ Ο := by
refine (eventually_splitMany_inf_eq_filter Ο).exists.imp fun s hs => ?_
rwa [h.iUnion_eq, filter_of_true, inf_eq_right] at hs
exact fun J hJ => le_of_mem _ hJ
/-- For every prepartition `Ο` of `I` there exists a prepartition that covers exactly
`I \ Ο.iUnion`. -/
theorem exists_iUnion_eq_diff (Ο : Prepartition I) :
β Ο' : Prepartition I, Ο'.iUnion = βI \ Ο.iUnion := by
rcases Ο.eventually_splitMany_inf_eq_filter.exists with β¨s, hsβ©
use (splitMany I s).filter fun J => Β¬(J : Set (ΞΉ β β)) β Ο.iUnion
simp [β hs]
/-- If `Ο` is a prepartition of `I`, then `Ο.compl` is a prepartition of `I`
such that `Ο.compl.iUnion = I \ Ο.iUnion`. -/
def compl (Ο : Prepartition I) : Prepartition I :=
Ο.exists_iUnion_eq_diff.choose
@[simp]
theorem iUnion_compl (Ο : Prepartition I) : Ο.compl.iUnion = βI \ Ο.iUnion :=
Ο.exists_iUnion_eq_diff.choose_spec
/-- Since the definition of `BoxIntegral.Prepartition.compl` uses `Exists.choose`,
the result depends only on `Ο.iUnion`. -/
theorem compl_congr {Οβ Οβ : Prepartition I} (h : Οβ.iUnion = Οβ.iUnion) : Οβ.compl = Οβ.compl := by
dsimp only [compl]
congr 1
rw [h]
theorem IsPartition.compl_eq_bot {Ο : Prepartition I} (h : IsPartition Ο) : Ο.compl = β₯ := by
rw [β iUnion_eq_empty, iUnion_compl, h.iUnion_eq, diff_self]
@[simp]
theorem compl_top : (β€ : Prepartition I).compl = β₯ :=
(isPartitionTop I).compl_eq_bot
end Finite
end Prepartition
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/Basic.lean | import Mathlib.Algebra.BigOperators.Option
import Mathlib.Analysis.BoxIntegral.Box.Basic
import Mathlib.Data.Set.Pairwise.Lattice
/-!
# Partitions of rectangular boxes in `ββΏ`
In this file we define (pre)partitions of rectangular boxes in `ββΏ`. A partition of a box `I` in
`ββΏ` (see `BoxIntegral.Prepartition` and `BoxIntegral.Prepartition.IsPartition`) is a finite set
of pairwise disjoint boxes such that their union is exactly `I`. We use `boxes : Finset (Box ΞΉ)` to
store the set of boxes.
Many lemmas about box integrals deal with pairwise disjoint collections of subboxes, so we define a
structure `BoxIntegral.Prepartition (I : BoxIntegral.Box ΞΉ)` that stores a collection of boxes
such that
* each box `J β boxes` is a subbox of `I`;
* the boxes are pairwise disjoint as sets in `ββΏ`.
Then we define a predicate `BoxIntegral.Prepartition.IsPartition`; `Ο.IsPartition` means that the
boxes of `Ο` actually cover the whole `I`. We also define some operations on prepartitions:
* `BoxIntegral.Prepartition.biUnion`: split each box of a partition into smaller boxes;
* `BoxIntegral.Prepartition.restrict`: restrict a partition to a smaller box.
We also define a `SemilatticeInf` structure on `BoxIntegral.Prepartition I` for all
`I : BoxIntegral.Box ΞΉ`.
## Tags
rectangular box, partition
-/
open Set Finset Function
open scoped NNReal
noncomputable section
namespace BoxIntegral
variable {ΞΉ : Type*}
/-- A prepartition of `I : BoxIntegral.Box ΞΉ` is a finite set of pairwise disjoint subboxes of
`I`. -/
structure Prepartition (I : Box ΞΉ) where
/-- The underlying set of boxes -/
boxes : Finset (Box ΞΉ)
/-- Each box is a sub-box of `I` -/
le_of_mem' : β J β boxes, J β€ I
/-- The boxes in a prepartition are pairwise disjoint. -/
pairwiseDisjoint : Set.Pairwise (βboxes) (Disjoint on ((β) : Box ΞΉ β Set (ΞΉ β β)))
namespace Prepartition
variable {I J Jβ Jβ : Box ΞΉ} (Ο : Prepartition I) {Οβ Οβ : Prepartition I} {x : ΞΉ β β}
instance : Membership (Box ΞΉ) (Prepartition I) :=
β¨fun Ο J => J β Ο.boxesβ©
@[simp]
theorem mem_boxes : J β Ο.boxes β J β Ο := Iff.rfl
@[simp]
theorem mem_mk {s hβ hβ} : J β (mk s hβ hβ : Prepartition I) β J β s := Iff.rfl
theorem disjoint_coe_of_mem (hβ : Jβ β Ο) (hβ : Jβ β Ο) (h : Jβ β Jβ) :
Disjoint (Jβ : Set (ΞΉ β β)) Jβ :=
Ο.pairwiseDisjoint hβ hβ h
theorem eq_of_mem_of_mem (hβ : Jβ β Ο) (hβ : Jβ β Ο) (hxβ : x β Jβ) (hxβ : x β Jβ) : Jβ = Jβ :=
by_contra fun H => (Ο.disjoint_coe_of_mem hβ hβ H).le_bot β¨hxβ, hxββ©
theorem eq_of_le_of_le (hβ : Jβ β Ο) (hβ : Jβ β Ο) (hleβ : J β€ Jβ) (hleβ : J β€ Jβ) : Jβ = Jβ :=
Ο.eq_of_mem_of_mem hβ hβ (hleβ J.upper_mem) (hleβ J.upper_mem)
theorem eq_of_le (hβ : Jβ β Ο) (hβ : Jβ β Ο) (hle : Jβ β€ Jβ) : Jβ = Jβ :=
Ο.eq_of_le_of_le hβ hβ le_rfl hle
theorem le_of_mem (hJ : J β Ο) : J β€ I :=
Ο.le_of_mem' J hJ
theorem lower_le_lower (hJ : J β Ο) : I.lower β€ J.lower :=
Box.antitone_lower (Ο.le_of_mem hJ)
theorem upper_le_upper (hJ : J β Ο) : J.upper β€ I.upper :=
Box.monotone_upper (Ο.le_of_mem hJ)
theorem injective_boxes : Function.Injective (boxes : Prepartition I β Finset (Box ΞΉ)) := by
rintro β¨sβ, hβ, hβ'β© β¨sβ, hβ, hβ'β© (rfl : sβ = sβ)
rfl
@[ext]
theorem ext (h : β J, J β Οβ β J β Οβ) : Οβ = Οβ :=
injective_boxes <| Finset.ext h
/-- The singleton prepartition `{J}`, `J β€ I`. -/
@[simps]
def single (I J : Box ΞΉ) (h : J β€ I) : Prepartition I :=
β¨{J}, by simpa, by simpβ©
@[simp]
theorem mem_single {J'} (h : J β€ I) : J' β single I J h β J' = J :=
mem_singleton
/-- We say that `Ο β€ Ο'` if each box of `Ο` is a subbox of some box of `Ο'`. -/
instance : LE (Prepartition I) :=
β¨fun Ο Ο' => β β¦Iβ¦, I β Ο β β I' β Ο', I β€ I'β©
instance partialOrder : PartialOrder (Prepartition I) where
le_refl _ I hI := β¨I, hI, le_rflβ©
le_trans _ _ _ hββ hββ _ hIβ :=
let β¨_, hIβ, hIβββ© := hββ hIβ
let β¨Iβ, hIβ, hIβββ© := hββ hIβ
β¨Iβ, hIβ, hIββ.trans hIβββ©
le_antisymm := by
suffices β {Οβ Οβ : Prepartition I}, Οβ β€ Οβ β Οβ β€ Οβ β Οβ.boxes β Οβ.boxes from
fun Οβ Οβ hβ hβ => injective_boxes (Subset.antisymm (this hβ hβ) (this hβ hβ))
intro Οβ Οβ hβ hβ J hJ
rcases hβ hJ with β¨J', hJ', hleβ©; rcases hβ hJ' with β¨J'', hJ'', hle'β©
obtain rfl : J = J'' := Οβ.eq_of_le hJ hJ'' (hle.trans hle')
obtain rfl : J' = J := le_antisymm βΉ_βΊ βΉ_βΊ
assumption
instance : OrderTop (Prepartition I) where
top := single I I le_rfl
le_top Ο _ hJ := β¨I, by simp, Ο.le_of_mem hJβ©
instance : OrderBot (Prepartition I) where
bot := β¨β
,
fun _ hJ => (Finset.notMem_empty _ hJ).elim,
fun _ hJ => (Set.notMem_empty _ <| Finset.coe_empty βΈ hJ).elimβ©
bot_le _ _ hJ := (Finset.notMem_empty _ hJ).elim
instance : Inhabited (Prepartition I) := β¨β€β©
theorem le_def : Οβ β€ Οβ β β J β Οβ, β J' β Οβ, J β€ J' := Iff.rfl
@[simp]
theorem mem_top : J β (β€ : Prepartition I) β J = I :=
mem_singleton
@[simp]
theorem top_boxes : (β€ : Prepartition I).boxes = {I} := rfl
@[simp]
theorem notMem_bot : J β (β₯ : Prepartition I) :=
Finset.notMem_empty _
@[deprecated (since := "2025-05-23")] alias not_mem_bot := notMem_bot
@[simp]
theorem bot_boxes : (β₯ : Prepartition I).boxes = β
:= rfl
/-- An auxiliary lemma used to prove that the same point can't belong to more than
`2 ^ Fintype.card ΞΉ` closed boxes of a prepartition. -/
theorem injOn_setOf_mem_Icc_setOf_lower_eq (x : ΞΉ β β) :
InjOn (fun J : Box ΞΉ => { i | J.lower i = x i }) { J | J β Ο β§ x β Box.Icc J } := by
rintro Jβ β¨hβ, hxββ© Jβ β¨hβ, hxββ© (H : { i | Jβ.lower i = x i } = { i | Jβ.lower i = x i })
suffices β i, (Ioc (Jβ.lower i) (Jβ.upper i) β© Ioc (Jβ.lower i) (Jβ.upper i)).Nonempty by
choose y hyβ hyβ using this
exact Ο.eq_of_mem_of_mem hβ hβ hyβ hyβ
intro i
simp only [Set.ext_iff, mem_setOf] at H
rcases (hxβ.1 i).eq_or_lt with hiβ | hiβ
Β· have hiβ : Jβ.lower i = x i := (H _).1 hiβ
have Hβ : x i < Jβ.upper i := by simpa only [hiβ] using Jβ.lower_lt_upper i
have Hβ : x i < Jβ.upper i := by simpa only [hiβ] using Jβ.lower_lt_upper i
rw [Set.Ioc_inter_Ioc, hiβ, hiβ, sup_idem, Set.nonempty_Ioc]
exact lt_min Hβ Hβ
Β· have hiβ : Jβ.lower i < x i := (hxβ.1 i).lt_of_ne (mt (H _).2 hiβ.ne)
exact β¨x i, β¨hiβ, hxβ.2 iβ©, β¨hiβ, hxβ.2 iβ©β©
open scoped Classical in
/-- The set of boxes of a prepartition that contain `x` in their closures has cardinality
at most `2 ^ Fintype.card ΞΉ`. -/
theorem card_filter_mem_Icc_le [Fintype ΞΉ] (x : ΞΉ β β) :
#{J β Ο.boxes | x β Box.Icc J} β€ 2 ^ Fintype.card ΞΉ := by
rw [β Fintype.card_set]
refine Finset.card_le_card_of_injOn (fun J : Box ΞΉ => { i | J.lower i = x i })
(fun _ _ => Finset.mem_univ _) ?_
simpa using Ο.injOn_setOf_mem_Icc_setOf_lower_eq x
/-- Given a prepartition `Ο : BoxIntegral.Prepartition I`, `Ο.iUnion` is the part of `I` covered by
the boxes of `Ο`. -/
protected def iUnion : Set (ΞΉ β β) :=
β J β Ο, βJ
theorem iUnion_def : Ο.iUnion = β J β Ο, βJ := rfl
theorem iUnion_def' : Ο.iUnion = β J β Ο.boxes, βJ := rfl
@[simp]
theorem mem_iUnion : x β Ο.iUnion β β J β Ο, x β J := by
convert Set.mem_iUnionβ
rw [Box.mem_coe, exists_prop]
@[simp]
theorem iUnion_single (h : J β€ I) : (single I J h).iUnion = J := by simp [iUnion_def]
@[simp]
theorem iUnion_top : (β€ : Prepartition I).iUnion = I := by simp [Prepartition.iUnion]
@[simp]
theorem iUnion_eq_empty : Οβ.iUnion = β
β Οβ = β₯ := by
simp [β injective_boxes.eq_iff, Finset.ext_iff, Prepartition.iUnion, imp_false]
@[simp]
theorem iUnion_bot : (β₯ : Prepartition I).iUnion = β
:=
iUnion_eq_empty.2 rfl
theorem subset_iUnion (h : J β Ο) : βJ β Ο.iUnion :=
subset_biUnion_of_mem h
theorem iUnion_subset : Ο.iUnion β I :=
iUnionβ_subset Ο.le_of_mem'
@[mono]
theorem iUnion_mono (h : Οβ β€ Οβ) : Οβ.iUnion β Οβ.iUnion := fun _ hx =>
let β¨_, hJβ, hxβ© := Οβ.mem_iUnion.1 hx
let β¨Jβ, hJβ, hleβ© := h hJβ
Οβ.mem_iUnion.2 β¨Jβ, hJβ, hle hxβ©
theorem disjoint_boxes_of_disjoint_iUnion (h : Disjoint Οβ.iUnion Οβ.iUnion) :
Disjoint Οβ.boxes Οβ.boxes :=
Finset.disjoint_left.2 fun J hβ hβ =>
Disjoint.le_bot (h.mono (Οβ.subset_iUnion hβ) (Οβ.subset_iUnion hβ)) β¨J.upper_mem, J.upper_memβ©
theorem le_iff_nonempty_imp_le_and_iUnion_subset :
Οβ β€ Οβ β
(β J β Οβ, β J' β Οβ, (J β© J' : Set (ΞΉ β β)).Nonempty β J β€ J') β§ Οβ.iUnion β Οβ.iUnion := by
constructor
Β· refine fun H => β¨fun J hJ J' hJ' Hne => ?_, iUnion_mono Hβ©
rcases H hJ with β¨J'', hJ'', Hleβ©
rcases Hne with β¨x, hx, hx'β©
rwa [Οβ.eq_of_mem_of_mem hJ' hJ'' hx' (Hle hx)]
Β· rintro β¨H, HUβ© J hJ
simp only [Set.subset_def, mem_iUnion] at HU
rcases HU J.upper β¨J, hJ, J.upper_memβ© with β¨Jβ, hJβ, hxβ©
exact β¨Jβ, hJβ, H _ hJ _ hJβ β¨_, J.upper_mem, hxβ©β©
theorem eq_of_boxes_subset_iUnion_superset (hβ : Οβ.boxes β Οβ.boxes) (hβ : Οβ.iUnion β Οβ.iUnion) :
Οβ = Οβ :=
le_antisymm (fun J hJ => β¨J, hβ hJ, le_rflβ©) <|
le_iff_nonempty_imp_le_and_iUnion_subset.2
β¨fun _ hJβ _ hJβ Hne =>
(Οβ.eq_of_mem_of_mem hJβ (hβ hJβ) Hne.choose_spec.1 Hne.choose_spec.2).le, hββ©
open scoped Classical in
/-- Given a prepartition `Ο` of a box `I` and a collection of prepartitions `Οi J` of all boxes
`J β Ο`, returns the prepartition of `I` into the union of the boxes of all `Οi J`.
Though we only use the values of `Οi` on the boxes of `Ο`, we require `Οi` to be a globally defined
function. -/
@[simps]
def biUnion (Οi : β J : Box ΞΉ, Prepartition J) : Prepartition I where
boxes := Ο.boxes.biUnion fun J => (Οi J).boxes
le_of_mem' J hJ := by
simp only [Finset.mem_biUnion, mem_boxes] at hJ
rcases hJ with β¨J', hJ', hJβ©
exact ((Οi J').le_of_mem hJ).trans (Ο.le_of_mem hJ')
pairwiseDisjoint := by
simp only [Set.Pairwise, Finset.mem_coe, Finset.mem_biUnion]
rintro Jβ' β¨Jβ, hJβ, hJβ'β© Jβ' β¨Jβ, hJβ, hJβ'β© Hne
rw [Function.onFun, Set.disjoint_left]
rintro x hxβ hxβ; apply Hne
obtain rfl : Jβ = Jβ :=
Ο.eq_of_mem_of_mem hJβ hJβ ((Οi Jβ).le_of_mem hJβ' hxβ) ((Οi Jβ).le_of_mem hJβ' hxβ)
exact (Οi Jβ).eq_of_mem_of_mem hJβ' hJβ' hxβ hxβ
variable {Οi Οiβ Οiβ : β J : Box ΞΉ, Prepartition J}
@[simp]
theorem mem_biUnion : J β Ο.biUnion Οi β β J' β Ο, J β Οi J' := by simp [biUnion]
theorem biUnion_le (Οi : β J, Prepartition J) : Ο.biUnion Οi β€ Ο := fun _ hJ =>
let β¨J', hJ', hJβ© := Ο.mem_biUnion.1 hJ
β¨J', hJ', (Οi J').le_of_mem hJβ©
@[simp]
theorem biUnion_top : (Ο.biUnion fun _ => β€) = Ο := by
ext
simp
@[congr]
theorem biUnion_congr (h : Οβ = Οβ) (hi : β J β Οβ, Οiβ J = Οiβ J) :
Οβ.biUnion Οiβ = Οβ.biUnion Οiβ := by
subst Οβ
ext J
simp only [mem_biUnion]
constructor <;> exact fun β¨J', hβ, hββ© => β¨J', hβ, hi J' hβ βΈ hββ©
theorem biUnion_congr_of_le (h : Οβ = Οβ) (hi : β J β€ I, Οiβ J = Οiβ J) :
Οβ.biUnion Οiβ = Οβ.biUnion Οiβ :=
biUnion_congr h fun J hJ => hi J (Οβ.le_of_mem hJ)
@[simp]
theorem iUnion_biUnion (Οi : β J : Box ΞΉ, Prepartition J) :
(Ο.biUnion Οi).iUnion = β J β Ο, (Οi J).iUnion := by simp [Prepartition.iUnion]
open scoped Classical in
@[simp]
theorem sum_biUnion_boxes {M : Type*} [AddCommMonoid M] (Ο : Prepartition I)
(Οi : β J, Prepartition J) (f : Box ΞΉ β M) :
(β J β Ο.boxes.biUnion fun J => (Οi J).boxes, f J) =
β J β Ο.boxes, β J' β (Οi J).boxes, f J' := by
refine Finset.sum_biUnion fun Jβ hβ Jβ hβ hne => Finset.disjoint_left.2 fun J' hβ' hβ' => ?_
exact hne (Ο.eq_of_le_of_le hβ hβ ((Οi Jβ).le_of_mem hβ') ((Οi Jβ).le_of_mem hβ'))
open scoped Classical in
/-- Given a box `J β Ο.biUnion Οi`, returns the box `J' β Ο` such that `J β Οi J'`.
For `J β Ο.biUnion Οi`, returns `I`. -/
def biUnionIndex (Οi : β (J : Box ΞΉ), Prepartition J) (J : Box ΞΉ) : Box ΞΉ :=
if hJ : J β Ο.biUnion Οi then (Ο.mem_biUnion.1 hJ).choose else I
theorem biUnionIndex_mem (hJ : J β Ο.biUnion Οi) : Ο.biUnionIndex Οi J β Ο := by
rw [biUnionIndex, dif_pos hJ]
exact (Ο.mem_biUnion.1 hJ).choose_spec.1
theorem biUnionIndex_le (Οi : β J, Prepartition J) (J : Box ΞΉ) : Ο.biUnionIndex Οi J β€ I := by
by_cases hJ : J β Ο.biUnion Οi
Β· exact Ο.le_of_mem (Ο.biUnionIndex_mem hJ)
Β· rw [biUnionIndex, dif_neg hJ]
theorem mem_biUnionIndex (hJ : J β Ο.biUnion Οi) : J β Οi (Ο.biUnionIndex Οi J) := by
convert (Ο.mem_biUnion.1 hJ).choose_spec.2 <;> exact dif_pos hJ
theorem le_biUnionIndex (hJ : J β Ο.biUnion Οi) : J β€ Ο.biUnionIndex Οi J :=
le_of_mem _ (Ο.mem_biUnionIndex hJ)
/-- Uniqueness property of `BoxIntegral.Prepartition.biUnionIndex`. -/
theorem biUnionIndex_of_mem (hJ : J β Ο) {J'} (hJ' : J' β Οi J) : Ο.biUnionIndex Οi J' = J :=
have : J' β Ο.biUnion Οi := Ο.mem_biUnion.2 β¨J, hJ, hJ'β©
Ο.eq_of_le_of_le (Ο.biUnionIndex_mem this) hJ (Ο.le_biUnionIndex this) (le_of_mem _ hJ')
theorem biUnion_assoc (Οi : β J, Prepartition J) (Οi' : Box ΞΉ β β J : Box ΞΉ, Prepartition J) :
(Ο.biUnion fun J => (Οi J).biUnion (Οi' J)) =
(Ο.biUnion Οi).biUnion fun J => Οi' (Ο.biUnionIndex Οi J) J := by
ext J
simp only [mem_biUnion]
constructor
Β· rintro β¨Jβ, hJβ, Jβ, hJβ, hJβ©
refine β¨Jβ, β¨Jβ, hJβ, hJββ©, ?_β©
rwa [Ο.biUnionIndex_of_mem hJβ hJβ]
Β· rintro β¨Jβ, β¨Jβ, hJβ, hJββ©, hJβ©
refine β¨Jβ, hJβ, Jβ, hJβ, ?_β©
rwa [Ο.biUnionIndex_of_mem hJβ hJβ] at hJ
/-- Create a `BoxIntegral.Prepartition` from a collection of possibly empty boxes by filtering out
the empty one if it exists. -/
def ofWithBot (boxes : Finset (WithBot (Box ΞΉ)))
(le_of_mem : β J β boxes, (J : WithBot (Box ΞΉ)) β€ I)
(pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ΞΉ))) Disjoint) :
Prepartition I where
boxes := Finset.eraseNone boxes
le_of_mem' J hJ := by
rw [mem_eraseNone] at hJ
simpa only [WithBot.some_eq_coe, WithBot.coe_le_coe] using le_of_mem _ hJ
pairwiseDisjoint Jβ hβ Jβ hβ hne := by
simp only [mem_coe, mem_eraseNone] at hβ hβ
exact Box.disjoint_coe.1 (pairwise_disjoint hβ hβ (mt Option.some_inj.1 hne))
@[simp]
theorem mem_ofWithBot {boxes : Finset (WithBot (Box ΞΉ))} {hβ hβ} :
J β (ofWithBot boxes hβ hβ : Prepartition I) β (J : WithBot (Box ΞΉ)) β boxes :=
mem_eraseNone
@[simp]
theorem iUnion_ofWithBot (boxes : Finset (WithBot (Box ΞΉ)))
(le_of_mem : β J β boxes, (J : WithBot (Box ΞΉ)) β€ I)
(pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ΞΉ))) Disjoint) :
(ofWithBot boxes le_of_mem pairwise_disjoint).iUnion = β J β boxes, βJ := by
suffices β (J : Box ΞΉ) (_ : βJ β boxes), βJ = β J β boxes, (J : Set (ΞΉ β β)) by
simpa [ofWithBot, Prepartition.iUnion]
simp only [β Box.biUnion_coe_eq_coe, @iUnion_comm _ _ (Box ΞΉ), @iUnion_comm _ _ (@Eq _ _ _),
iUnion_iUnion_eq_right]
theorem ofWithBot_le {boxes : Finset (WithBot (Box ΞΉ))}
{le_of_mem : β J β boxes, (J : WithBot (Box ΞΉ)) β€ I}
{pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ΞΉ))) Disjoint}
(H : β J β boxes, J β β₯ β β J' β Ο, J β€ βJ') :
ofWithBot boxes le_of_mem pairwise_disjoint β€ Ο := by
have : β J : Box ΞΉ, βJ β boxes β β J' β Ο, J β€ J' := fun J hJ => by
simpa only [WithBot.coe_le_coe] using H J hJ WithBot.coe_ne_bot
simpa [ofWithBot, le_def]
theorem le_ofWithBot {boxes : Finset (WithBot (Box ΞΉ))}
{le_of_mem : β J β boxes, (J : WithBot (Box ΞΉ)) β€ I}
{pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ΞΉ))) Disjoint}
(H : β J β Ο, β J' β boxes, βJ β€ J') : Ο β€ ofWithBot boxes le_of_mem pairwise_disjoint := by
intro J hJ
rcases H J hJ with β¨J', J'mem, hleβ©
lift J' to Box ΞΉ using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hle
exact β¨J', mem_ofWithBot.2 J'mem, WithBot.coe_le_coe.1 hleβ©
theorem ofWithBot_mono {boxesβ : Finset (WithBot (Box ΞΉ))}
{le_of_memβ : β J β boxesβ, (J : WithBot (Box ΞΉ)) β€ I}
{pairwise_disjointβ : Set.Pairwise (boxesβ : Set (WithBot (Box ΞΉ))) Disjoint}
{boxesβ : Finset (WithBot (Box ΞΉ))} {le_of_memβ : β J β boxesβ, (J : WithBot (Box ΞΉ)) β€ I}
{pairwise_disjointβ : Set.Pairwise (boxesβ : Set (WithBot (Box ΞΉ))) Disjoint}
(H : β J β boxesβ, J β β₯ β β J' β boxesβ, J β€ J') :
ofWithBot boxesβ le_of_memβ pairwise_disjointβ β€
ofWithBot boxesβ le_of_memβ pairwise_disjointβ :=
le_ofWithBot _ fun J hJ => H J (mem_ofWithBot.1 hJ) WithBot.coe_ne_bot
theorem sum_ofWithBot {M : Type*} [AddCommMonoid M] (boxes : Finset (WithBot (Box ΞΉ)))
(le_of_mem : β J β boxes, (J : WithBot (Box ΞΉ)) β€ I)
(pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ΞΉ))) Disjoint) (f : Box ΞΉ β M) :
(β J β (ofWithBot boxes le_of_mem pairwise_disjoint).boxes, f J) =
β J β boxes, Option.elim' 0 f J :=
Finset.sum_eraseNone _ _
open scoped Classical in
/-- Restrict a prepartition to a box. -/
def restrict (Ο : Prepartition I) (J : Box ΞΉ) : Prepartition J :=
ofWithBot (Ο.boxes.image fun J' : Box ΞΉ => J β J')
(fun J' hJ' => by
rcases Finset.mem_image.1 hJ' with β¨J', -, rflβ©
exact inf_le_left)
(by
simp only [Set.Pairwise, Finset.mem_coe, Finset.mem_image]
rintro _ β¨Jβ, hβ, rflβ© _ β¨Jβ, hβ, rflβ© Hne
have : Jβ β Jβ := by
rintro rfl
exact Hne rfl
exact ((Box.disjoint_coe.2 <| Ο.disjoint_coe_of_mem hβ hβ this).inf_left' _).inf_right' _)
@[simp]
theorem mem_restrict : Jβ β Ο.restrict J β β J' β Ο, (Jβ : WithBot (Box ΞΉ)) = βJ β βJ' := by
simp [restrict, eq_comm]
theorem mem_restrict' : Jβ β Ο.restrict J β β J' β Ο, (Jβ : Set (ΞΉ β β)) = βJ β© βJ' := by
simp only [mem_restrict, β Box.withBotCoe_inj, Box.coe_inf, Box.coe_coe]
@[mono]
theorem restrict_mono {Οβ Οβ : Prepartition I} (Hle : Οβ β€ Οβ) : Οβ.restrict J β€ Οβ.restrict J := by
classical
refine ofWithBot_mono fun Jβ hJβ hne => ?_
rw [Finset.mem_image] at hJβ; rcases hJβ with β¨Jβ, hJβ, rflβ©
rcases Hle hJβ with β¨Jβ, hJβ, hleβ©
exact β¨_, Finset.mem_image_of_mem _ hJβ, inf_le_inf_left _ <| WithBot.coe_le_coe.2 hleβ©
theorem monotone_restrict : Monotone fun Ο : Prepartition I => restrict Ο J :=
fun _ _ => restrict_mono
/-- Restricting to a larger box does not change the set of boxes. We cannot claim equality
of prepartitions because they have different types. -/
theorem restrict_boxes_of_le (Ο : Prepartition I) (h : I β€ J) : (Ο.restrict J).boxes = Ο.boxes := by
classical
simp only [restrict, ofWithBot, eraseNone_eq_biUnion]
refine Finset.image_biUnion.trans ?_
refine (Finset.biUnion_congr rfl ?_).trans Finset.biUnion_singleton_eq_self
intro J' hJ'
rw [inf_of_le_right, β WithBot.some_eq_coe, Option.toFinset_some]
exact WithBot.coe_le_coe.2 ((Ο.le_of_mem hJ').trans h)
@[simp]
theorem restrict_self : Ο.restrict I = Ο :=
injective_boxes <| restrict_boxes_of_le Ο le_rfl
@[simp]
theorem iUnion_restrict : (Ο.restrict J).iUnion = (J : Set (ΞΉ β β)) β© (Ο.iUnion) := by
simp [restrict, β inter_iUnion, β iUnion_def]
@[simp]
theorem restrict_biUnion (Οi : β J, Prepartition J) (hJ : J β Ο) :
(Ο.biUnion Οi).restrict J = Οi J := by
refine (eq_of_boxes_subset_iUnion_superset (fun Jβ hβ => ?_) ?_).symm
Β· refine (mem_restrict _).2 β¨Jβ, Ο.mem_biUnion.2 β¨J, hJ, hββ©, (inf_of_le_right ?_).symmβ©
exact WithBot.coe_le_coe.2 (le_of_mem _ hβ)
Β· simp only [iUnion_restrict, iUnion_biUnion, Set.subset_def, Set.mem_inter_iff, Set.mem_iUnion]
rintro x β¨hxJ, Jβ, hβ, hxβ©
obtain rfl : J = Jβ := Ο.eq_of_mem_of_mem hJ hβ hxJ (iUnion_subset _ hx)
exact hx
theorem biUnion_le_iff {Οi : β J, Prepartition J} {Ο' : Prepartition I} :
Ο.biUnion Οi β€ Ο' β β J β Ο, Οi J β€ Ο'.restrict J := by
constructor <;> intro H J hJ
Β· rw [β Ο.restrict_biUnion Οi hJ]
exact restrict_mono H
Β· rw [mem_biUnion] at hJ
rcases hJ with β¨Jβ, hβ, hJβ©
rcases H Jβ hβ hJ with β¨Jβ, hβ, Hleβ©
rcases Ο'.mem_restrict.mp hβ with β¨Jβ, hβ, Hβ©
exact β¨Jβ, hβ, Hle.trans <| WithBot.coe_le_coe.1 <| H.trans_le inf_le_rightβ©
theorem le_biUnion_iff {Οi : β J, Prepartition J} {Ο' : Prepartition I} :
Ο' β€ Ο.biUnion Οi β Ο' β€ Ο β§ β J β Ο, Ο'.restrict J β€ Οi J := by
refine β¨fun H => β¨H.trans (Ο.biUnion_le Οi), fun J hJ => ?_β©, ?_β©
Β· rw [β Ο.restrict_biUnion Οi hJ]
exact restrict_mono H
Β· rintro β¨H, Hiβ© J' hJ'
rcases H hJ' with β¨J, hJ, hleβ©
have : J' β Ο'.restrict J :=
Ο'.mem_restrict.2 β¨J', hJ', (inf_of_le_right <| WithBot.coe_le_coe.2 hle).symmβ©
rcases Hi J hJ this with β¨Ji, hJi, hleiβ©
exact β¨Ji, Ο.mem_biUnion.2 β¨J, hJ, hJiβ©, hleiβ©
instance : SemilatticeInf (Prepartition I) :=
{ inf := fun Οβ Οβ => Οβ.biUnion fun J => Οβ.restrict J
inf_le_left := fun Οβ _ => Οβ.biUnion_le _
inf_le_right := fun _ _ => (biUnion_le_iff _).2 fun _ _ => le_rfl
le_inf := fun _ Οβ _ hβ hβ => Οβ.le_biUnion_iff.2 β¨hβ, fun _ _ => restrict_mono hββ© }
theorem inf_def (Οβ Οβ : Prepartition I) : Οβ β Οβ = Οβ.biUnion fun J => Οβ.restrict J := rfl
@[simp]
theorem mem_inf {Οβ Οβ : Prepartition I} :
J β Οβ β Οβ β β Jβ β Οβ, β Jβ β Οβ, (J : WithBot (Box ΞΉ)) = βJβ β βJβ := by
simp only [inf_def, mem_biUnion, mem_restrict]
@[simp]
theorem iUnion_inf (Οβ Οβ : Prepartition I) : (Οβ β Οβ).iUnion = Οβ.iUnion β© Οβ.iUnion := by
simp only [inf_def, iUnion_biUnion, iUnion_restrict, β iUnion_inter, β iUnion_def]
open scoped Classical in
/-- The prepartition with boxes `{J β Ο | p J}`. -/
@[simps]
def filter (Ο : Prepartition I) (p : Box ΞΉ β Prop) : Prepartition I where
boxes := {J β Ο.boxes | p J}
le_of_mem' _ hJ := Ο.le_of_mem (mem_filter.1 hJ).1
pairwiseDisjoint _ hβ _ hβ := Ο.disjoint_coe_of_mem (mem_filter.1 hβ).1 (mem_filter.1 hβ).1
@[simp]
theorem mem_filter {p : Box ΞΉ β Prop} : J β Ο.filter p β J β Ο β§ p J := by
classical
exact Finset.mem_filter
theorem filter_le (Ο : Prepartition I) (p : Box ΞΉ β Prop) : Ο.filter p β€ Ο := fun J hJ =>
let β¨hΟ, _β© := Ο.mem_filter.1 hJ
β¨J, hΟ, le_rflβ©
theorem filter_of_true {p : Box ΞΉ β Prop} (hp : β J β Ο, p J) : Ο.filter p = Ο := by
ext J
simpa using hp J
@[simp]
theorem filter_true : (Ο.filter fun _ => True) = Ο :=
Ο.filter_of_true fun _ _ => trivial
@[simp]
theorem iUnion_filter_not (Ο : Prepartition I) (p : Box ΞΉ β Prop) :
(Ο.filter fun J => Β¬p J).iUnion = Ο.iUnion \ (Ο.filter p).iUnion := by
simp only [Prepartition.iUnion]
convert
(@Set.biUnion_diff_biUnion_eq (ΞΉ β β) (Box ΞΉ) Ο.boxes (Ο.filter p).boxes (β) _).symm using 4
Β· simp +contextual
Β· rw [Set.PairwiseDisjoint]
convert Ο.pairwiseDisjoint
rw [Set.union_eq_left, filter_boxes, coe_filter]
exact fun _ β¨h, _β© => h
open scoped Classical in
theorem sum_fiberwise {Ξ± M} [AddCommMonoid M] (Ο : Prepartition I) (f : Box ΞΉ β Ξ±) (g : Box ΞΉ β M) :
(β y β Ο.boxes.image f, β J β (Ο.filter fun J => f J = y).boxes, g J) =
β J β Ο.boxes, g J := by
convert sum_fiberwise_of_maps_to (fun _ => Finset.mem_image_of_mem f) g
open scoped Classical in
/-- Union of two disjoint prepartitions. -/
@[simps]
def disjUnion (Οβ Οβ : Prepartition I) (h : Disjoint Οβ.iUnion Οβ.iUnion) : Prepartition I where
boxes := Οβ.boxes βͺ Οβ.boxes
le_of_mem' _ hJ := (Finset.mem_union.1 hJ).elim Οβ.le_of_mem Οβ.le_of_mem
pairwiseDisjoint :=
suffices β Jβ β Οβ, β Jβ β Οβ, Jβ β Jβ β Disjoint (Jβ : Set (ΞΉ β β)) Jβ by
simpa [pairwise_union_of_symmetric (symmetric_disjoint.comap _), pairwiseDisjoint]
fun _ hβ _ hβ _ => h.mono (Οβ.subset_iUnion hβ) (Οβ.subset_iUnion hβ)
@[simp]
theorem mem_disjUnion (H : Disjoint Οβ.iUnion Οβ.iUnion) :
J β Οβ.disjUnion Οβ H β J β Οβ β¨ J β Οβ := by
classical exact Finset.mem_union
@[simp]
theorem iUnion_disjUnion (h : Disjoint Οβ.iUnion Οβ.iUnion) :
(Οβ.disjUnion Οβ h).iUnion = Οβ.iUnion βͺ Οβ.iUnion := by
simp [disjUnion, Prepartition.iUnion, iUnion_or, iUnion_union_distrib]
open scoped Classical in
@[simp]
theorem sum_disj_union_boxes {M : Type*} [AddCommMonoid M] (h : Disjoint Οβ.iUnion Οβ.iUnion)
(f : Box ΞΉ β M) :
β J β Οβ.boxes βͺ Οβ.boxes, f J = (β J β Οβ.boxes, f J) + β J β Οβ.boxes, f J :=
sum_union <| disjoint_boxes_of_disjoint_iUnion h
section Distortion
variable [Fintype ΞΉ]
/-- The distortion of a prepartition is the maximum of the distortions of the boxes of this
prepartition. -/
def distortion : ββ₯0 :=
Ο.boxes.sup Box.distortion
theorem distortion_le_of_mem (h : J β Ο) : J.distortion β€ Ο.distortion :=
le_sup h
theorem distortion_le_iff {c : ββ₯0} : Ο.distortion β€ c β β J β Ο, Box.distortion J β€ c :=
Finset.sup_le_iff
theorem distortion_biUnion (Ο : Prepartition I) (Οi : β J, Prepartition J) :
(Ο.biUnion Οi).distortion = Ο.boxes.sup fun J => (Οi J).distortion := by
classical exact sup_biUnion _ _
@[simp]
theorem distortion_disjUnion (h : Disjoint Οβ.iUnion Οβ.iUnion) :
(Οβ.disjUnion Οβ h).distortion = max Οβ.distortion Οβ.distortion := by
classical exact sup_union
theorem distortion_of_const {c} (hβ : Ο.boxes.Nonempty) (hβ : β J β Ο, Box.distortion J = c) :
Ο.distortion = c :=
(sup_congr rfl hβ).trans (sup_const hβ _)
@[simp]
theorem distortion_top (I : Box ΞΉ) : distortion (β€ : Prepartition I) = I.distortion :=
sup_singleton
@[simp]
theorem distortion_bot (I : Box ΞΉ) : distortion (β₯ : Prepartition I) = 0 :=
sup_empty
end Distortion
/-- A prepartition `Ο` of `I` is a partition if the boxes of `Ο` cover the whole `I`. -/
def IsPartition (Ο : Prepartition I) :=
β x β I, β J β Ο, x β J
theorem isPartition_iff_iUnion_eq {Ο : Prepartition I} : Ο.IsPartition β Ο.iUnion = I := by
simp_rw [IsPartition, Set.Subset.antisymm_iff, Ο.iUnion_subset, true_and, Set.subset_def,
mem_iUnion, Box.mem_coe]
@[simp]
theorem isPartition_single_iff (h : J β€ I) : IsPartition (single I J h) β J = I := by
simp [isPartition_iff_iUnion_eq]
theorem isPartitionTop (I : Box ΞΉ) : IsPartition (β€ : Prepartition I) :=
fun _ hx => β¨I, mem_top.2 rfl, hxβ©
namespace IsPartition
variable {Ο}
theorem iUnion_eq (h : Ο.IsPartition) : Ο.iUnion = I :=
isPartition_iff_iUnion_eq.1 h
theorem iUnion_subset (h : Ο.IsPartition) (Οβ : Prepartition I) : Οβ.iUnion β Ο.iUnion :=
h.iUnion_eq.symm βΈ Οβ.iUnion_subset
protected theorem existsUnique (h : Ο.IsPartition) (hx : x β I) :
β! J β Ο, x β J := by
rcases h x hx with β¨J, h, hxβ©
exact ExistsUnique.intro J β¨h, hxβ© fun J' β¨h', hx'β© => Ο.eq_of_mem_of_mem h' h hx' hx
theorem nonempty_boxes (h : Ο.IsPartition) : Ο.boxes.Nonempty :=
let β¨J, hJ, _β© := h _ I.upper_mem
β¨J, hJβ©
theorem eq_of_boxes_subset (hβ : Οβ.IsPartition) (hβ : Οβ.boxes β Οβ.boxes) : Οβ = Οβ :=
eq_of_boxes_subset_iUnion_superset hβ <| hβ.iUnion_subset _
theorem le_iff (h : Οβ.IsPartition) :
Οβ β€ Οβ β β J β Οβ, β J' β Οβ, (J β© J' : Set (ΞΉ β β)).Nonempty β J β€ J' :=
le_iff_nonempty_imp_le_and_iUnion_subset.trans <| and_iff_left <| h.iUnion_subset _
protected theorem biUnion (h : IsPartition Ο) (hi : β J β Ο, IsPartition (Οi J)) :
IsPartition (Ο.biUnion Οi) := fun x hx =>
let β¨J, hJ, hxiβ© := h x hx
let β¨Ji, hJi, hxβ© := hi J hJ x hxi
β¨Ji, Ο.mem_biUnion.2 β¨J, hJ, hJiβ©, hxβ©
protected theorem restrict (h : IsPartition Ο) (hJ : J β€ I) : IsPartition (Ο.restrict J) :=
isPartition_iff_iUnion_eq.2 <| by simp [h.iUnion_eq, hJ]
protected theorem inf (hβ : IsPartition Οβ) (hβ : IsPartition Οβ) : IsPartition (Οβ β Οβ) :=
isPartition_iff_iUnion_eq.2 <| by simp [hβ.iUnion_eq, hβ.iUnion_eq]
end IsPartition
theorem iUnion_biUnion_partition (h : β J β Ο, (Οi J).IsPartition) :
(Ο.biUnion Οi).iUnion = Ο.iUnion :=
(iUnion_biUnion _ _).trans <|
iUnion_congr_of_surjective id surjective_id fun J =>
iUnion_congr_of_surjective id surjective_id fun hJ => (h J hJ).iUnion_eq
theorem isPartitionDisjUnionOfEqDiff (h : Οβ.iUnion = βI \ Οβ.iUnion) :
IsPartition (Οβ.disjUnion Οβ <| h.symm βΈ disjoint_sdiff_self_right) :=
isPartition_iff_iUnion_eq.2 <| (iUnion_disjUnion _).trans <| by simp [h, Οβ.iUnion_subset]
end Prepartition
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/Filter.lean | import Mathlib.Analysis.BoxIntegral.Partition.SubboxInduction
import Mathlib.Analysis.BoxIntegral.Partition.Split
/-!
# Filters used in box-based integrals
First we define a structure `BoxIntegral.IntegrationParams`. This structure will be used as an
argument in the definition of `BoxIntegral.integral` in order to use the same definition for a few
well-known definitions of integrals based on partitions of a rectangular box into subboxes (Riemann
integral, Henstock-Kurzweil integral, and McShane integral).
This structure holds three Boolean values (see below), and encodes eight different sets of
parameters; only four of these values are used somewhere in `mathlib4`. Three of them correspond to
the integration theories listed above, and one is a generalization of the one-dimensional
Henstock-Kurzweil integral such that the divergence theorem works without additional integrability
assumptions.
Finally, for each set of parameters `l : BoxIntegral.IntegrationParams` and a rectangular box
`I : BoxIntegral.Box ΞΉ`, we define several `Filter`s that will be used either in the definition of
the corresponding integral, or in the proofs of its properties. We equip
`BoxIntegral.IntegrationParams` with a `BoundedOrder` structure such that larger
`IntegrationParams` produce larger filters.
## Main definitions
### Integration parameters
The structure `BoxIntegral.IntegrationParams` has 3 Boolean fields with the following meaning:
* `bRiemann`: the value `true` means that the filter corresponds to a Riemann-style integral, i.e.
in the definition of integrability we require a constant upper estimate `r` on the size of boxes
of a tagged partition; the value `false` means that the estimate may depend on the position of the
tag.
* `bHenstock`: the value `true` means that we require that each tag belongs to its own closed box;
the value `false` means that we only require that tags belong to the ambient box.
* `bDistortion`: the value `true` means that `r` can depend on the maximal ratio of sides of the
same box of a partition. Presence of this case make quite a few proofs harder but we can prove the
divergence theorem only for the filter `BoxIntegral.IntegrationParams.GP = β₯ =
{bRiemann := false, bHenstock := true, bDistortion := true}`.
### Well-known sets of parameters
Out of eight possible values of `BoxIntegral.IntegrationParams`, the following four are used in
the library.
* `BoxIntegral.IntegrationParams.Riemann` (`bRiemann = true`, `bHenstock = true`,
`bDistortion = false`): this value corresponds to the Riemann integral; in the corresponding
filter, we require that the diameters of all boxes `J` of a tagged partition are bounded from
above by a constant upper estimate that may not depend on the geometry of `J`, and each tag
belongs to the corresponding closed box.
* `BoxIntegral.IntegrationParams.Henstock` (`bRiemann = false`, `bHenstock = true`,
`bDistortion = false`): this value corresponds to the most natural generalization of
Henstock-Kurzweil integral to higher dimension; the only (but important!) difference between this
theory and Riemann integral is that instead of a constant upper estimate on the size of all boxes
of a partition, we require that the partition is *subordinate* to a possibly discontinuous
function `r : (ΞΉ β β) β {x : β | 0 < x}`, i.e. each box `J` is included in a closed ball with
center `Ο.tag J` and radius `r J`.
* `BoxIntegral.IntegrationParams.McShane` (`bRiemann = false`, `bHenstock = false`,
`bDistortion = false`): this value corresponds to the McShane integral; the only difference with
the Henstock integral is that we allow tags to be outside of their boxes; the tags still have to
be in the ambient closed box, and the partition still has to be subordinate to a function.
* `BoxIntegral.IntegrationParams.GP = β₯` (`bRiemann = false`, `bHenstock = true`,
`bDistortion = true`): this is the least integration theory in our list, i.e., all functions
integrable in any other theory is integrable in this one as well. This is a non-standard
generalization of the Henstock-Kurzweil integral to higher dimension. In dimension one, it
generates the same filter as `Henstock`. In higher dimension, this generalization defines an
integration theory such that the divergence of any FrΓ©chet differentiable function `f` is
integrable, and its integral is equal to the sum of integrals of `f` over the faces of the box,
taken with appropriate signs.
A function `f` is `GP`-integrable if for any `Ξ΅ > 0` and `c : ββ₯0` there exists
`r : (ΞΉ β β) β {x : β | 0 < x}` such that for any tagged partition `Ο` subordinate to `r`, if each
tag belongs to the corresponding closed box and for each box `J β Ο`, the maximal ratio of its
sides is less than or equal to `c`, then the integral sum of `f` over `Ο` is `Ξ΅`-close to the
integral.
### Filters and predicates on `TaggedPrepartition I`
For each value of `IntegrationParams` and a rectangular box `I`, we define a few filters on
`TaggedPrepartition I`. First, we define a predicate
```
structure BoxIntegral.IntegrationParams.MemBaseSet (l : BoxIntegral.IntegrationParams)
(I : BoxIntegral.Box ΞΉ) (c : ββ₯0) (r : (ΞΉ β β) β Ioi (0 : β))
(Ο : BoxIntegral.TaggedPrepartition I) : Prop where
```
This predicate says that
* if `l.bHenstock`, then `Ο` is a Henstock prepartition, i.e. each tag belongs to the corresponding
closed box;
* `Ο` is subordinate to `r`;
* if `l.bDistortion`, then the distortion of each box in `Ο` is less than or equal to `c`;
* if `l.bDistortion`, then there exists a prepartition `Ο'` with distortion `β€ c` that covers
exactly `I \ Ο.iUnion`.
The last condition is always true for `c > 1`, see TODO section for more details.
Then we define a predicate `BoxIntegral.IntegrationParams.RCond` on functions
`r : (ΞΉ β β) β {x : β | 0 < x}`. If `l.bRiemann`, then this predicate requires `r` to be a constant
function, otherwise it imposes no restrictions on `r`. We introduce this definition to prove a few
dot-notation lemmas: e.g., `BoxIntegral.IntegrationParams.RCond.min` says that the pointwise
minimum of two functions that satisfy this condition satisfies this condition as well.
Then we define four filters on `BoxIntegral.TaggedPrepartition I`.
* `BoxIntegral.IntegrationParams.toFilterDistortion`: an auxiliary filter that takes parameters
`(l : BoxIntegral.IntegrationParams) (I : BoxIntegral.Box ΞΉ) (c : ββ₯0)` and returns the
filter generated by all sets `{Ο | MemBaseSet l I c r Ο}`, where `r` is a function satisfying
the predicate `BoxIntegral.IntegrationParams.RCond l`;
* `BoxIntegral.IntegrationParams.toFilter l I`: the supremum of `l.toFilterDistortion I c`
over all `c : ββ₯0`;
* `BoxIntegral.IntegrationParams.toFilterDistortioniUnion l I c Οβ`, where `Οβ` is a
prepartition of `I`: the infimum of `l.toFilterDistortion I c` and the principal filter
generated by `{Ο | Ο.iUnion = Οβ.iUnion}`;
* `BoxIntegral.IntegrationParams.toFilteriUnion l I Οβ`: the supremum of
`l.toFilterDistortioniUnion l I c Οβ` over all `c : ββ₯0`. This is the filter (in the case
`Οβ = β€` is the one-box partition of `I`) used in the definition of the integral of a function
over a box.
## Implementation details
* Later we define the integral of a function over a rectangular box as the limit (if it exists) of
the integral sums along `BoxIntegral.IntegrationParams.toFilteriUnion l I β€`. While it is
possible to define the integral with a general filter on `BoxIntegral.TaggedPrepartition I` as a
parameter, many lemmas (e.g., Sacks-Henstock lemma and most results about integrability of
functions) require the filter to have a predictable structure. So, instead of adding assumptions
about the filter here and there, we define this auxiliary type that can encode all integration
theories we need in practice.
* While the definition of the integral only uses the filter
`BoxIntegral.IntegrationParams.toFilteriUnion l I β€` and partitions of a box, some lemmas
(e.g., the Henstock-Sacks lemmas) are best formulated in terms of the predicate `MemBaseSet` and
other filters defined above.
* We use `Bool` instead of `Prop` for the fields of `IntegrationParams` in order to have decidable
equality and inequalities.
## TODO
Currently, `BoxIntegral.IntegrationParams.MemBaseSet` explicitly requires that there exists a
partition of the complement `I \ Ο.iUnion` with distortion `β€ c`. For `c > 1`, this condition is
always true but the proof of this fact requires more API about
`BoxIntegral.Prepartition.splitMany`. We should formalize this fact, then either require `c > 1`
everywhere, or replace `β€ c` with `< c` so that we automatically get `c > 1` for a non-trivial
prepartition (and consider the special case `Ο = β₯` separately if needed).
## Tags
integral, rectangular box, partition, filter
-/
open Set Function Filter Metric Finset Bool
open scoped Topology Filter NNReal
noncomputable section
namespace BoxIntegral
variable {ΞΉ : Type*} [Fintype ΞΉ] {I J : Box ΞΉ} {c cβ cβ : ββ₯0}
open TaggedPrepartition
/-- An `IntegrationParams` is a structure holding 3 Boolean values used to define a filter to be
used in the definition of a box-integrable function.
-/
@[ext]
structure IntegrationParams : Type where
/-- `true` if the filter corresponds to a Riemann-style integral,
i.e. in the definition of integrability we require a constant upper estimate `r` on the size of
boxes of a tagged partition; the value `false` means that the estimate may depend on the position
of the tag. -/
(bRiemann : Bool)
/-- `true` if we require that each tag belongs to its own closed
box; the value `false` means that we only require that tags belong to the ambient box. -/
(bHenstock : Bool)
/-- `true` if `r` can depend on the maximal ratio of sides of the
same box of a partition. Presence of this case makes quite a few proofs harder but we can prove
the divergence theorem only for the filter `BoxIntegral.IntegrationParams.GP = β₯ =
{bRiemann := false, bHenstock := true, bDistortion := true}`. -/
(bDistortion : Bool)
variable {l lβ lβ : IntegrationParams}
namespace IntegrationParams
/-- Auxiliary equivalence with a product type used to lift an order. -/
def equivProd : IntegrationParams β Bool Γ Boolα΅α΅ Γ Boolα΅α΅ where
toFun l := β¨l.1, OrderDual.toDual l.2, OrderDual.toDual l.3β©
invFun l := β¨l.1, OrderDual.ofDual l.2.1, OrderDual.ofDual l.2.2β©
instance : PartialOrder IntegrationParams :=
PartialOrder.lift equivProd equivProd.injective
/-- Auxiliary `OrderIso` with a product type used to lift a `BoundedOrder` structure. -/
def isoProd : IntegrationParams βo Bool Γ Boolα΅α΅ Γ Boolα΅α΅ :=
β¨equivProd, Iff.rflβ©
instance : BoundedOrder IntegrationParams :=
isoProd.symm.toGaloisInsertion.liftBoundedOrder
/-- The value `BoxIntegral.IntegrationParams.GP = β₯`
(`bRiemann = false`, `bHenstock = true`, `bDistortion = true`)
corresponds to a generalization of the Henstock integral such that the Divergence theorem holds true
without additional integrability assumptions, see the module docstring for details. -/
instance : Inhabited IntegrationParams :=
β¨β₯β©
instance : DecidableLE (IntegrationParams) :=
fun _ _ => inferInstanceAs (Decidable (_ β§ _))
instance : DecidableEq IntegrationParams :=
fun _ _ => decidable_of_iff _ IntegrationParams.ext_iff.symm
/-- The `BoxIntegral.IntegrationParams` corresponding to the Riemann integral. In the
corresponding filter, we require that the diameters of all boxes `J` of a tagged partition are
bounded from above by a constant upper estimate that may not depend on the geometry of `J`, and each
tag belongs to the corresponding closed box. -/
def Riemann : IntegrationParams where
bRiemann := true
bHenstock := true
bDistortion := false
/-- The `BoxIntegral.IntegrationParams` corresponding to the Henstock-Kurzweil integral. In the
corresponding filter, we require that the tagged partition is subordinate to a (possibly,
discontinuous) positive function `r` and each tag belongs to the corresponding closed box. -/
def Henstock : IntegrationParams :=
β¨false, true, falseβ©
/-- The `BoxIntegral.IntegrationParams` corresponding to the McShane integral. In the
corresponding filter, we require that the tagged partition is subordinate to a (possibly,
discontinuous) positive function `r`; the tags may be outside of the corresponding closed box
(but still inside the ambient closed box `I.Icc`). -/
def McShane : IntegrationParams :=
β¨false, false, falseβ©
/-- The `BoxIntegral.IntegrationParams` corresponding to the generalized Perron integral. In the
corresponding filter, we require that the tagged partition is subordinate to a (possibly,
discontinuous) positive function `r` and each tag belongs to the corresponding closed box. We also
require an upper estimate on the distortion of all boxes of the partition. -/
def GP : IntegrationParams := β₯
theorem henstock_le_riemann : Henstock β€ Riemann := by trivial
theorem henstock_le_mcShane : Henstock β€ McShane := by trivial
theorem gp_le : GP β€ l :=
bot_le
/-- The predicate corresponding to a base set of the filter defined by an
`IntegrationParams`. It says that
* if `l.bHenstock`, then `Ο` is a Henstock prepartition, i.e. each tag belongs to the corresponding
closed box;
* `Ο` is subordinate to `r`;
* if `l.bDistortion`, then the distortion of each box in `Ο` is less than or equal to `c`;
* if `l.bDistortion`, then there exists a prepartition `Ο'` with distortion `β€ c` that covers
exactly `I \ Ο.iUnion`.
The last condition is automatically verified for partitions, and is used in the proof of the
Sacks-Henstock inequality to compare two prepartitions covering the same part of the box.
It is also automatically satisfied for any `c > 1`, see TODO section of the module docstring for
details. -/
structure MemBaseSet (l : IntegrationParams) (I : Box ΞΉ) (c : ββ₯0) (r : (ΞΉ β β) β Ioi (0 : β))
(Ο : TaggedPrepartition I) : Prop where
protected isSubordinate : Ο.IsSubordinate r
protected isHenstock : l.bHenstock β Ο.IsHenstock
protected distortion_le : l.bDistortion β Ο.distortion β€ c
protected exists_compl : l.bDistortion β β Ο' : Prepartition I,
Ο'.iUnion = βI \ Ο.iUnion β§ Ο'.distortion β€ c
/-- A predicate saying that in case `l.bRiemann = true`, the function `r` is a constant. -/
def RCond {ΞΉ : Type*} (l : IntegrationParams) (r : (ΞΉ β β) β Ioi (0 : β)) : Prop :=
l.bRiemann β β x, r x = r 0
/-- A set `s : Set (TaggedPrepartition I)` belongs to `l.toFilterDistortion I c` if there exists
a function `r : ββΏ β (0, β)` (or a constant `r` if `l.bRiemann = true`) such that `s` contains each
prepartition `Ο` such that `l.MemBaseSet I c r Ο`. -/
def toFilterDistortion (l : IntegrationParams) (I : Box ΞΉ) (c : ββ₯0) :
Filter (TaggedPrepartition I) :=
β¨
(r : (ΞΉ β β) β Ioi (0 : β)) (_ : l.RCond r), π { Ο | l.MemBaseSet I c r Ο }
/-- A set `s : Set (TaggedPrepartition I)` belongs to `l.toFilter I` if for any `c : ββ₯0` there
exists a function `r : ββΏ β (0, β)` (or a constant `r` if `l.bRiemann = true`) such that
`s` contains each prepartition `Ο` such that `l.MemBaseSet I c r Ο`. -/
def toFilter (l : IntegrationParams) (I : Box ΞΉ) : Filter (TaggedPrepartition I) :=
β¨ c : ββ₯0, l.toFilterDistortion I c
/-- A set `s : Set (TaggedPrepartition I)` belongs to `l.toFilterDistortioniUnion I c Οβ` if
there exists a function `r : ββΏ β (0, β)` (or a constant `r` if `l.bRiemann = true`) such that `s`
contains each prepartition `Ο` such that `l.MemBaseSet I c r Ο` and `Ο.iUnion = Οβ.iUnion`. -/
def toFilterDistortioniUnion (l : IntegrationParams) (I : Box ΞΉ) (c : ββ₯0) (Οβ : Prepartition I) :=
l.toFilterDistortion I c β π { Ο | Ο.iUnion = Οβ.iUnion }
/-- A set `s : Set (TaggedPrepartition I)` belongs to `l.toFilteriUnion I Οβ` if for any `c : ββ₯0`
there exists a function `r : ββΏ β (0, β)` (or a constant `r` if `l.bRiemann = true`) such that `s`
contains each prepartition `Ο` such that `l.MemBaseSet I c r Ο` and `Ο.iUnion = Οβ.iUnion`. -/
def toFilteriUnion (I : Box ΞΉ) (Οβ : Prepartition I) :=
β¨ c : ββ₯0, l.toFilterDistortioniUnion I c Οβ
theorem rCond_of_bRiemann_eq_false {ΞΉ} (l : IntegrationParams) (hl : l.bRiemann = false)
{r : (ΞΉ β β) β Ioi (0 : β)} : l.RCond r := by
simp [RCond, hl]
theorem toFilter_inf_iUnion_eq (l : IntegrationParams) (I : Box ΞΉ) (Οβ : Prepartition I) :
l.toFilter I β π { Ο | Ο.iUnion = Οβ.iUnion } = l.toFilteriUnion I Οβ :=
(iSup_inf_principal _ _).symm
variable {rβ rβ : (ΞΉ β β) β Ioi (0 : β)} {Ο Οβ Οβ : TaggedPrepartition I}
variable (I) in
theorem MemBaseSet.mono' (h : lβ β€ lβ) (hc : cβ β€ cβ)
(hr : β J β Ο, rβ (Ο.tag J) β€ rβ (Ο.tag J)) (hΟ : lβ.MemBaseSet I cβ rβ Ο) :
lβ.MemBaseSet I cβ rβ Ο :=
β¨hΟ.1.mono' hr, fun hβ => hΟ.2 (le_iff_imp.1 h.2.1 hβ),
fun hD => (hΟ.3 (le_iff_imp.1 h.2.2 hD)).trans hc,
fun hD => (hΟ.4 (le_iff_imp.1 h.2.2 hD)).imp fun _ hΟ => β¨hΟ.1, hΟ.2.trans hcβ©β©
variable (I) in
@[mono]
theorem MemBaseSet.mono (h : lβ β€ lβ) (hc : cβ β€ cβ)
(hr : β x β Box.Icc I, rβ x β€ rβ x) (hΟ : lβ.MemBaseSet I cβ rβ Ο) : lβ.MemBaseSet I cβ rβ Ο :=
hΟ.mono' I h hc fun J _ => hr _ <| Ο.tag_mem_Icc J
theorem MemBaseSet.exists_common_compl
(hβ : l.MemBaseSet I cβ rβ Οβ) (hβ : l.MemBaseSet I cβ rβ Οβ)
(hU : Οβ.iUnion = Οβ.iUnion) :
β Ο : Prepartition I, Ο.iUnion = βI \ Οβ.iUnion β§
(l.bDistortion β Ο.distortion β€ cβ) β§ (l.bDistortion β Ο.distortion β€ cβ) := by
wlog hc : cβ β€ cβ with H
Β· simpa [hU, _root_.and_comm] using
@H _ _ I cβ cβ l rβ rβ Οβ Οβ hβ hβ hU.symm (le_of_not_ge hc)
by_cases hD : (l.bDistortion : Prop)
Β· rcases hβ.4 hD with β¨Ο, hΟU, hΟcβ©
exact β¨Ο, hΟU, fun _ => hΟc, fun _ => hΟc.trans hcβ©
Β· exact β¨Οβ.toPrepartition.compl, Οβ.toPrepartition.iUnion_compl,
fun h => (hD h).elim, fun h => (hD h).elimβ©
protected theorem MemBaseSet.unionComplToSubordinate (hΟβ : l.MemBaseSet I c rβ Οβ)
(hle : β x β Box.Icc I, rβ x β€ rβ x) {Οβ : Prepartition I} (hU : Οβ.iUnion = βI \ Οβ.iUnion)
(hc : l.bDistortion β Οβ.distortion β€ c) :
l.MemBaseSet I c rβ (Οβ.unionComplToSubordinate Οβ hU rβ) :=
β¨hΟβ.1.disjUnion ((Οβ.isSubordinate_toSubordinate rβ).mono hle) _,
fun h => (hΟβ.2 h).disjUnion (Οβ.isHenstock_toSubordinate _) _,
fun h => (distortion_unionComplToSubordinate _ _ _ _).trans_le (max_le (hΟβ.3 h) (hc h)),
fun _ => β¨β₯, by simpβ©β©
variable {r : (ΞΉ β β) β Ioi (0 : β)}
protected theorem MemBaseSet.filter (hΟ : l.MemBaseSet I c r Ο) (p : Box ΞΉ β Prop) :
l.MemBaseSet I c r (Ο.filter p) := by
classical
refine β¨fun J hJ => hΟ.1 J (Ο.mem_filter.1 hJ).1, fun hH J hJ => hΟ.2 hH J (Ο.mem_filter.1 hJ).1,
fun hD => (distortion_filter_le _ _).trans (hΟ.3 hD), fun hD => ?_β©
rcases hΟ.4 hD with β¨Οβ, hΟβU, hcβ©
set Οβ := Ο.filter fun J => Β¬p J
have : Disjoint Οβ.iUnion Οβ.iUnion := by
simpa [Οβ, hΟβU] using disjoint_sdiff_self_left.mono_right sdiff_le
refine β¨Οβ.disjUnion Οβ.toPrepartition this, ?_, ?_β©
Β· suffices βI \ Ο.iUnion βͺ Ο.iUnion \ (Ο.filter p).iUnion = βI \ (Ο.filter p).iUnion by
simp [Οβ, *]
have h : (Ο.filter p).iUnion β Ο.iUnion :=
biUnion_subset_biUnion_left (Finset.filter_subset _ _)
ext x
fconstructor
Β· rintro (β¨hxI, hxΟβ© | β¨hxΟ, hxpβ©)
exacts [β¨hxI, mt (@h x) hxΟβ©, β¨Ο.iUnion_subset hxΟ, hxpβ©]
Β· rintro β¨hxI, hxpβ©
by_cases hxΟ : x β Ο.iUnion
exacts [Or.inr β¨hxΟ, hxpβ©, Or.inl β¨hxI, hxΟβ©]
Β· have : (Ο.filter fun J => Β¬p J).distortion β€ c := (distortion_filter_le _ _).trans (hΟ.3 hD)
simpa [hc]
theorem biUnionTagged_memBaseSet {Ο : Prepartition I} {Οi : β J, TaggedPrepartition J}
(h : β J β Ο, l.MemBaseSet J c r (Οi J)) (hp : β J β Ο, (Οi J).IsPartition)
(hc : l.bDistortion β Ο.compl.distortion β€ c) : l.MemBaseSet I c r (Ο.biUnionTagged Οi) := by
refine β¨TaggedPrepartition.isSubordinate_biUnionTagged.2 fun J hJ => (h J hJ).1,
fun hH => TaggedPrepartition.isHenstock_biUnionTagged.2 fun J hJ => (h J hJ).2 hH,
fun hD => ?_, fun hD => ?_β©
Β· rw [Prepartition.distortion_biUnionTagged, Finset.sup_le_iff]
exact fun J hJ => (h J hJ).3 hD
Β· refine β¨_, ?_, hc hDβ©
rw [Ο.iUnion_compl, β Ο.iUnion_biUnion_partition hp]
rfl
@[mono]
theorem RCond.mono {ΞΉ : Type*} {r : (ΞΉ β β) β Ioi (0 : β)} (h : lβ β€ lβ) (hr : lβ.RCond r) :
lβ.RCond r :=
fun hR => hr (le_iff_imp.1 h.1 hR)
nonrec theorem RCond.min {ΞΉ : Type*} {rβ rβ : (ΞΉ β β) β Ioi (0 : β)} (hβ : l.RCond rβ)
(hβ : l.RCond rβ) : l.RCond fun x => min (rβ x) (rβ x) :=
fun hR x => congr_argβ min (hβ hR x) (hβ hR x)
@[gcongr, mono]
theorem toFilterDistortion_mono (I : Box ΞΉ) (h : lβ β€ lβ) (hc : cβ β€ cβ) :
lβ.toFilterDistortion I cβ β€ lβ.toFilterDistortion I cβ :=
iInf_mono fun _ =>
iInf_mono' fun hr =>
β¨hr.mono h, principal_mono.2 fun _ => MemBaseSet.mono I h hc fun _ _ => le_rflβ©
@[gcongr, mono]
theorem toFilter_mono (I : Box ΞΉ) {lβ lβ : IntegrationParams} (h : lβ β€ lβ) :
lβ.toFilter I β€ lβ.toFilter I :=
iSup_mono fun _ => toFilterDistortion_mono I h le_rfl
@[gcongr, mono]
theorem toFilteriUnion_mono (I : Box ΞΉ) {lβ lβ : IntegrationParams} (h : lβ β€ lβ)
(Οβ : Prepartition I) : lβ.toFilteriUnion I Οβ β€ lβ.toFilteriUnion I Οβ :=
iSup_mono fun _ => inf_le_inf_right _ <| toFilterDistortion_mono _ h le_rfl
theorem toFilteriUnion_congr (I : Box ΞΉ) (l : IntegrationParams) {Οβ Οβ : Prepartition I}
(h : Οβ.iUnion = Οβ.iUnion) : l.toFilteriUnion I Οβ = l.toFilteriUnion I Οβ := by
simp only [toFilteriUnion, toFilterDistortioniUnion, h]
theorem hasBasis_toFilterDistortion (l : IntegrationParams) (I : Box ΞΉ) (c : ββ₯0) :
(l.toFilterDistortion I c).HasBasis l.RCond fun r => { Ο | l.MemBaseSet I c r Ο } :=
hasBasis_biInf_principal'
(fun _ hrβ _ hrβ =>
β¨_, hrβ.min hrβ, fun _ => MemBaseSet.mono _ le_rfl le_rfl fun _ _ => min_le_left _ _,
fun _ => MemBaseSet.mono _ le_rfl le_rfl fun _ _ => min_le_right _ _β©)
β¨fun _ => β¨1, Set.mem_Ioi.2 zero_lt_oneβ©, fun _ _ => rflβ©
theorem hasBasis_toFilterDistortioniUnion (l : IntegrationParams) (I : Box ΞΉ) (c : ββ₯0)
(Οβ : Prepartition I) :
(l.toFilterDistortioniUnion I c Οβ).HasBasis l.RCond fun r =>
{ Ο | l.MemBaseSet I c r Ο β§ Ο.iUnion = Οβ.iUnion } :=
(l.hasBasis_toFilterDistortion I c).inf_principal _
theorem hasBasis_toFilteriUnion (l : IntegrationParams) (I : Box ΞΉ) (Οβ : Prepartition I) :
(l.toFilteriUnion I Οβ).HasBasis (fun r : ββ₯0 β (ΞΉ β β) β Ioi (0 : β) => β c, l.RCond (r c))
fun r => { Ο | β c, l.MemBaseSet I c (r c) Ο β§ Ο.iUnion = Οβ.iUnion } := by
have := fun c => l.hasBasis_toFilterDistortioniUnion I c Οβ
simpa only [setOf_and, setOf_exists] using hasBasis_iSup this
theorem hasBasis_toFilteriUnion_top (l : IntegrationParams) (I : Box ΞΉ) :
(l.toFilteriUnion I β€).HasBasis (fun r : ββ₯0 β (ΞΉ β β) β Ioi (0 : β) => β c, l.RCond (r c))
fun r => { Ο | β c, l.MemBaseSet I c (r c) Ο β§ Ο.IsPartition } := by
simpa only [TaggedPrepartition.isPartition_iff_iUnion_eq, Prepartition.iUnion_top] using
l.hasBasis_toFilteriUnion I β€
theorem hasBasis_toFilter (l : IntegrationParams) (I : Box ΞΉ) :
(l.toFilter I).HasBasis (fun r : ββ₯0 β (ΞΉ β β) β Ioi (0 : β) => β c, l.RCond (r c))
fun r => { Ο | β c, l.MemBaseSet I c (r c) Ο } := by
simpa only [setOf_exists] using hasBasis_iSup (l.hasBasis_toFilterDistortion I)
theorem tendsto_embedBox_toFilteriUnion_top (l : IntegrationParams) (h : I β€ J) :
Tendsto (TaggedPrepartition.embedBox I J h) (l.toFilteriUnion I β€)
(l.toFilteriUnion J (Prepartition.single J I h)) := by
simp only [toFilteriUnion, tendsto_iSup]; intro c
set Οβ := Prepartition.single J I h
refine le_iSup_of_le (max c Οβ.compl.distortion) ?_
refine ((l.hasBasis_toFilterDistortioniUnion I c β€).tendsto_iff
(l.hasBasis_toFilterDistortioniUnion J _ _)).2 fun r hr => ?_
refine β¨r, hr, fun Ο hΟ => ?_β©
rw [mem_setOf_eq, Prepartition.iUnion_top] at hΟ
refine β¨β¨hΟ.1.1, hΟ.1.2, fun hD => le_trans (hΟ.1.3 hD) (le_max_left _ _), fun _ => ?_β©, ?_β©
Β· refine β¨_, Οβ.iUnion_compl.trans ?_, le_max_right _ _β©
congr 1
exact (Prepartition.iUnion_single h).trans hΟ.2.symm
Β· exact hΟ.2.trans (Prepartition.iUnion_single _).symm
theorem exists_memBaseSet_le_iUnion_eq (l : IntegrationParams) (Οβ : Prepartition I)
(hcβ : Οβ.distortion β€ c) (hcβ : Οβ.compl.distortion β€ c) (r : (ΞΉ β β) β Ioi (0 : β)) :
β Ο, l.MemBaseSet I c r Ο β§ Ο.toPrepartition β€ Οβ β§ Ο.iUnion = Οβ.iUnion := by
rcases Οβ.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r with β¨Ο, hle, hH, hr, hd, hUβ©
refine β¨Ο, β¨hr, fun _ => hH, fun _ => hd.trans_le hcβ, fun _ => β¨Οβ.compl, ?_, hcββ©β©, β¨hle, hUβ©β©
exact Prepartition.compl_congr hU βΈ Ο.toPrepartition.iUnion_compl
theorem exists_memBaseSet_isPartition (l : IntegrationParams) (I : Box ΞΉ) (hc : I.distortion β€ c)
(r : (ΞΉ β β) β Ioi (0 : β)) : β Ο, l.MemBaseSet I c r Ο β§ Ο.IsPartition := by
rw [β Prepartition.distortion_top] at hc
have hc' : (β€ : Prepartition I).compl.distortion β€ c := by simp
simpa [isPartition_iff_iUnion_eq] using l.exists_memBaseSet_le_iUnion_eq β€ hc hc' r
theorem toFilterDistortioniUnion_neBot (l : IntegrationParams) (I : Box ΞΉ) (Οβ : Prepartition I)
(hcβ : Οβ.distortion β€ c) (hcβ : Οβ.compl.distortion β€ c) :
(l.toFilterDistortioniUnion I c Οβ).NeBot :=
((l.hasBasis_toFilterDistortion I _).inf_principal _).neBot_iff.2
fun {r} _ => (l.exists_memBaseSet_le_iUnion_eq Οβ hcβ hcβ r).imp fun _ hΟ => β¨hΟ.1, hΟ.2.2β©
instance toFilterDistortioniUnion_neBot' (l : IntegrationParams) (I : Box ΞΉ) (Οβ : Prepartition I) :
(l.toFilterDistortioniUnion I (max Οβ.distortion Οβ.compl.distortion) Οβ).NeBot :=
l.toFilterDistortioniUnion_neBot I Οβ (le_max_left _ _) (le_max_right _ _)
instance toFilterDistortion_neBot (l : IntegrationParams) (I : Box ΞΉ) :
(l.toFilterDistortion I I.distortion).NeBot := by
simpa using (l.toFilterDistortioniUnion_neBot' I β€).mono inf_le_left
instance toFilter_neBot (l : IntegrationParams) (I : Box ΞΉ) : (l.toFilter I).NeBot :=
(l.toFilterDistortion_neBot I).mono <| le_iSup _ _
instance toFilteriUnion_neBot (l : IntegrationParams) (I : Box ΞΉ) (Οβ : Prepartition I) :
(l.toFilteriUnion I Οβ).NeBot :=
(l.toFilterDistortioniUnion_neBot' I Οβ).mono <|
le_iSup (fun c => l.toFilterDistortioniUnion I c Οβ) _
theorem eventually_isPartition (l : IntegrationParams) (I : Box ΞΉ) :
βαΆ Ο in l.toFilteriUnion I β€, TaggedPrepartition.IsPartition Ο :=
eventually_iSup.2 fun _ =>
eventually_inf_principal.2 <|
Eventually.of_forall fun Ο h =>
Ο.isPartition_iff_iUnion_eq.2 (h.trans Prepartition.iUnion_top)
end IntegrationParams
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/SubboxInduction.lean | import Mathlib.Analysis.BoxIntegral.Box.SubboxInduction
import Mathlib.Analysis.BoxIntegral.Partition.Tagged
/-!
# Induction on subboxes
In this file we prove (see
`BoxIntegral.Box.exists_taggedPartition_isHenstock_isSubordinate_homothetic`) that for every box `I`
in `ββΏ` and a function `r : ββΏ β β` positive on `I` there exists a tagged partition `Ο` of `I` such
that
* `Ο` is a Henstock partition;
* `Ο` is subordinate to `r`;
* each box in `Ο` is homothetic to `I` with coefficient of the form `1 / 2 ^ n`.
Later we will use this lemma to prove that the Henstock filter is nontrivial, hence the Henstock
integral is well-defined.
## Tags
partition, tagged partition, Henstock integral
-/
namespace BoxIntegral
open Set Metric
open Topology
noncomputable section
variable {ΞΉ : Type*} [Fintype ΞΉ] {I J : Box ΞΉ}
namespace Prepartition
/-- Split a box in `ββΏ` into `2 ^ n` boxes by hyperplanes passing through its center. -/
def splitCenter (I : Box ΞΉ) : Prepartition I where
boxes := Finset.univ.map (Box.splitCenterBoxEmb I)
le_of_mem' := by simp [I.splitCenterBox_le]
pairwiseDisjoint := by
rw [Finset.coe_map, Finset.coe_univ, image_univ]
rintro _ β¨s, rflβ© _ β¨t, rflβ© Hne
exact I.disjoint_splitCenterBox (mt (congr_arg _) Hne)
@[simp]
theorem mem_splitCenter : J β splitCenter I β β s, I.splitCenterBox s = J := by simp [splitCenter]
theorem isPartition_splitCenter (I : Box ΞΉ) : IsPartition (splitCenter I) := fun x hx => by
simp [hx]
theorem upper_sub_lower_of_mem_splitCenter (h : J β splitCenter I) (i : ΞΉ) :
J.upper i - J.lower i = (I.upper i - I.lower i) / 2 :=
let β¨s, hsβ© := mem_splitCenter.1 h
hs βΈ I.upper_sub_lower_splitCenterBox s i
end Prepartition
namespace Box
open Prepartition TaggedPrepartition
/-- Let `p` be a predicate on `Box ΞΉ`, let `I` be a box. Suppose that the following two properties
hold true.
* Consider a smaller box `J β€ I`. The hyperplanes passing through the center of `J` split it into
`2 ^ n` boxes. If `p` holds true on each of these boxes, then it true on `J`.
* For each `z` in the closed box `I.Icc` there exists a neighborhood `U` of `z` within `I.Icc` such
that for every box `J β€ I` such that `z β J.Icc β U`, if `J` is homothetic to `I` with a
coefficient of the form `1 / 2 ^ m`, then `p` is true on `J`.
Then `p I` is true. See also `BoxIntegral.Box.subbox_induction_on'` for a version using
`BoxIntegral.Box.splitCenterBox` instead of `BoxIntegral.Prepartition.splitCenter`. -/
@[elab_as_elim]
theorem subbox_induction_on {p : Box ΞΉ β Prop} (I : Box ΞΉ)
(H_ind : β J β€ I, (β J' β splitCenter J, p J') β p J)
(H_nhds : β z β Box.Icc I, β U β π[Box.Icc I] z, β J β€ I, β (m : β),
z β Box.Icc J β Box.Icc J β U β
(β i, J.upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) β p J) :
p I := by
refine subbox_induction_on' I (fun J hle hs => H_ind J hle fun J' h' => ?_) H_nhds
rcases mem_splitCenter.1 h' with β¨s, rflβ©
exact hs s
/-- Given a box `I` in `ββΏ` and a function `r : ββΏ β (0, β)`, there exists a tagged partition `Ο` of
`I` such that
* `Ο` is a Henstock partition;
* `Ο` is subordinate to `r`;
* each box in `Ο` is homothetic to `I` with coefficient of the form `1 / 2 ^ m`.
This lemma implies that the Henstock filter is nontrivial, hence the Henstock integral is
well-defined. -/
theorem exists_taggedPartition_isHenstock_isSubordinate_homothetic (I : Box ΞΉ)
(r : (ΞΉ β β) β Ioi (0 : β)) :
β Ο : TaggedPrepartition I, Ο.IsPartition β§ Ο.IsHenstock β§ Ο.IsSubordinate r β§
(β J β Ο, β m : β, β i, (J :).upper i - J.lower i = (I.upper i - I.lower i) / 2 ^ m) β§
Ο.distortion = I.distortion := by
refine subbox_induction_on I (fun J _ hJ => ?_) fun z _ => ?_
Β· choose! Οi hP hHen hr Hn _ using hJ
choose! n hn using Hn
have hP : ((splitCenter J).biUnionTagged Οi).IsPartition :=
(isPartition_splitCenter _).biUnionTagged hP
have hsub : β J' β (splitCenter J).biUnionTagged Οi, β n : β, β i,
(J' :).upper i - J'.lower i = (J.upper i - J.lower i) / 2 ^ n := by
intro J' hJ'
rcases (splitCenter J).mem_biUnionTagged.1 hJ' with β¨Jβ, hβ, hββ©
refine β¨n Jβ J' + 1, fun i => ?_β©
simp only [hn Jβ hβ J' hβ, upper_sub_lower_of_mem_splitCenter hβ, pow_succ', div_div]
refine β¨_, hP, isHenstock_biUnionTagged.2 hHen, isSubordinate_biUnionTagged.2 hr, hsub, ?_β©
refine TaggedPrepartition.distortion_of_const _ hP.nonempty_boxes fun J' h' => ?_
rcases hsub J' h' with β¨n, hnβ©
exact Box.distortion_eq_of_sub_eq_div hn
Β· refine β¨Box.Icc I β© closedBall z (r z),
inter_mem_nhdsWithin _ (closedBall_mem_nhds _ (r z).coe_prop), ?_β©
intro J _ n Hmem HIcc Hsub
rw [Set.subset_inter_iff] at HIcc
refine β¨single _ _ le_rfl _ Hmem, isPartition_single _, isHenstock_single _,
(isSubordinate_single _ _).2 HIcc.2, ?_, distortion_single _ _β©
simp only [TaggedPrepartition.mem_single, forall_eq]
refine β¨0, fun i => ?_β©
simp
end Box
namespace Prepartition
open TaggedPrepartition Finset Function
/-- Given a box `I` in `ββΏ`, a function `r : ββΏ β (0, β)`, and a prepartition `Ο` of `I`, there
exists a tagged prepartition `Ο'` of `I` such that
* each box of `Ο'` is included in some box of `Ο`;
* `Ο'` is a Henstock partition;
* `Ο'` is subordinate to `r`;
* `Ο'` covers exactly the same part of `I` as `Ο`;
* the distortion of `Ο'` is equal to the distortion of `Ο`.
-/
theorem exists_tagged_le_isHenstock_isSubordinate_iUnion_eq {I : Box ΞΉ} (r : (ΞΉ β β) β Ioi (0 : β))
(Ο : Prepartition I) :
β Ο' : TaggedPrepartition I, Ο'.toPrepartition β€ Ο β§ Ο'.IsHenstock β§ Ο'.IsSubordinate r β§
Ο'.distortion = Ο.distortion β§ Ο'.iUnion = Ο.iUnion := by
have := fun J => Box.exists_taggedPartition_isHenstock_isSubordinate_homothetic J r
choose! Οi Οip ΟiH Οir _ Οid using this
refine β¨Ο.biUnionTagged Οi, biUnion_le _ _, isHenstock_biUnionTagged.2 fun J _ => ΟiH J,
isSubordinate_biUnionTagged.2 fun J _ => Οir J, ?_, Ο.iUnion_biUnion_partition fun J _ => Οip Jβ©
rw [distortion_biUnionTagged]
exact sup_congr rfl fun J _ => Οid J
/-- Given a prepartition `Ο` of a box `I` and a function `r : ββΏ β (0, β)`, `Ο.toSubordinate r`
is a tagged partition `Ο'` such that
* each box of `Ο'` is included in some box of `Ο`;
* `Ο'` is a Henstock partition;
* `Ο'` is subordinate to `r`;
* `Ο'` covers exactly the same part of `I` as `Ο`;
* the distortion of `Ο'` is equal to the distortion of `Ο`.
-/
def toSubordinate (Ο : Prepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) : TaggedPrepartition I :=
(Ο.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r).choose
theorem toSubordinate_toPrepartition_le (Ο : Prepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Ο.toSubordinate r).toPrepartition β€ Ο :=
(Ο.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r).choose_spec.1
theorem isHenstock_toSubordinate (Ο : Prepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Ο.toSubordinate r).IsHenstock :=
(Ο.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r).choose_spec.2.1
theorem isSubordinate_toSubordinate (Ο : Prepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Ο.toSubordinate r).IsSubordinate r :=
(Ο.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r).choose_spec.2.2.1
@[simp]
theorem distortion_toSubordinate (Ο : Prepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Ο.toSubordinate r).distortion = Ο.distortion :=
(Ο.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r).choose_spec.2.2.2.1
@[simp]
theorem iUnion_toSubordinate (Ο : Prepartition I) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Ο.toSubordinate r).iUnion = Ο.iUnion :=
(Ο.exists_tagged_le_isHenstock_isSubordinate_iUnion_eq r).choose_spec.2.2.2.2
end Prepartition
namespace TaggedPrepartition
/-- Given a tagged prepartition `Οβ`, a prepartition `Οβ` that covers exactly `I \ Οβ.iUnion`, and
a function `r : ββΏ β (0, β)`, returns the union of `Οβ` and `Οβ.toSubordinate r`. This partition
`Ο` has the following properties:
* `Ο` is a partition, i.e. it covers the whole `I`;
* `Οβ.boxes β Ο.boxes`;
* `Ο.tag J = Οβ.tag J` whenever `J β Οβ`;
* `Ο` is Henstock outside of `Οβ`: `Ο.tag J β J.Icc` whenever `J β Ο`, `J β Οβ`;
* `Ο` is subordinate to `r` outside of `Οβ`;
* the distortion of `Ο` is equal to the maximum of the distortions of `Οβ` and `Οβ`.
-/
def unionComplToSubordinate (Οβ : TaggedPrepartition I) (Οβ : Prepartition I)
(hU : Οβ.iUnion = βI \ Οβ.iUnion) (r : (ΞΉ β β) β Ioi (0 : β)) : TaggedPrepartition I :=
Οβ.disjUnion (Οβ.toSubordinate r)
(((Οβ.iUnion_toSubordinate r).trans hU).symm βΈ disjoint_sdiff_self_right)
theorem isPartition_unionComplToSubordinate (Οβ : TaggedPrepartition I) (Οβ : Prepartition I)
(hU : Οβ.iUnion = βI \ Οβ.iUnion) (r : (ΞΉ β β) β Ioi (0 : β)) :
IsPartition (Οβ.unionComplToSubordinate Οβ hU r) :=
Prepartition.isPartitionDisjUnionOfEqDiff ((Οβ.iUnion_toSubordinate r).trans hU)
open scoped Classical in
@[simp]
theorem unionComplToSubordinate_boxes (Οβ : TaggedPrepartition I) (Οβ : Prepartition I)
(hU : Οβ.iUnion = βI \ Οβ.iUnion) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Οβ.unionComplToSubordinate Οβ hU r).boxes = Οβ.boxes βͺ (Οβ.toSubordinate r).boxes := rfl
@[simp]
theorem iUnion_unionComplToSubordinate_boxes (Οβ : TaggedPrepartition I) (Οβ : Prepartition I)
(hU : Οβ.iUnion = βI \ Οβ.iUnion) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Οβ.unionComplToSubordinate Οβ hU r).iUnion = I :=
(isPartition_unionComplToSubordinate _ _ _ _).iUnion_eq
@[simp]
theorem distortion_unionComplToSubordinate (Οβ : TaggedPrepartition I) (Οβ : Prepartition I)
(hU : Οβ.iUnion = βI \ Οβ.iUnion) (r : (ΞΉ β β) β Ioi (0 : β)) :
(Οβ.unionComplToSubordinate Οβ hU r).distortion = max Οβ.distortion Οβ.distortion := by
simp [unionComplToSubordinate]
end TaggedPrepartition
end
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/BoxIntegral/Partition/Measure.lean | import Mathlib.Analysis.BoxIntegral.Partition.Additive
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
/-!
# Box-additive functions defined by measures
In this file we prove a few simple facts about rectangular boxes, partitions, and measures:
- given a box `I : Box ΞΉ`, its coercion to `Set (ΞΉ β β)` and `I.Icc` are measurable sets;
- if `ΞΌ` is a locally finite measure, then `(I : Set (ΞΉ β β))` and `I.Icc` have finite measure;
- if `ΞΌ` is a locally finite measure, then `fun J β¦ ΞΌ.real J` is a box additive function.
For the last statement, we both prove it as a proposition and define a bundled
`BoxIntegral.BoxAdditiveMap` function.
## Tags
rectangular box, measure
-/
open Set
noncomputable section
open scoped ENNReal BoxIntegral
variable {ΞΉ : Type*}
namespace BoxIntegral
open MeasureTheory
namespace Box
variable (I : Box ΞΉ)
theorem measure_Icc_lt_top (ΞΌ : Measure (ΞΉ β β)) [IsLocallyFiniteMeasure ΞΌ] : ΞΌ (Box.Icc I) < β :=
show ΞΌ (Icc I.lower I.upper) < β from I.isCompact_Icc.measure_lt_top
theorem measure_coe_lt_top (ΞΌ : Measure (ΞΉ β β)) [IsLocallyFiniteMeasure ΞΌ] : ΞΌ I < β :=
(measure_mono <| coe_subset_Icc).trans_lt (I.measure_Icc_lt_top ΞΌ)
section Countable
variable [Countable ΞΉ]
theorem measurableSet_coe : MeasurableSet (I : Set (ΞΉ β β)) := by
rw [coe_eq_pi]
exact MeasurableSet.univ_pi fun i => measurableSet_Ioc
theorem measurableSet_Icc : MeasurableSet (Box.Icc I) :=
_root_.measurableSet_Icc
theorem measurableSet_Ioo : MeasurableSet (Box.Ioo I) :=
MeasurableSet.univ_pi fun _ => _root_.measurableSet_Ioo
end Countable
variable [Fintype ΞΉ]
theorem coe_ae_eq_Icc : (I : Set (ΞΉ β β)) =α΅[volume] Box.Icc I := by
rw [coe_eq_pi]
exact Measure.univ_pi_Ioc_ae_eq_Icc
theorem Ioo_ae_eq_Icc : Box.Ioo I =α΅[volume] Box.Icc I :=
Measure.univ_pi_Ioo_ae_eq_Icc
end Box
theorem Prepartition.measure_iUnion_toReal [Finite ΞΉ] {I : Box ΞΉ} (Ο : Prepartition I)
(ΞΌ : Measure (ΞΉ β β)) [IsLocallyFiniteMeasure ΞΌ] :
ΞΌ.real Ο.iUnion = β J β Ο.boxes, ΞΌ.real J := by
simp only [measureReal_def]
rw [β ENNReal.toReal_sum (fun J _ => (J.measure_coe_lt_top ΞΌ).ne), Ο.iUnion_def]
simp only [β mem_boxes]
rw [measure_biUnion_finset Ο.pairwiseDisjoint]
exact fun J _ => J.measurableSet_coe
end BoxIntegral
open BoxIntegral BoxIntegral.Box
namespace MeasureTheory
namespace Measure
/-- If `ΞΌ` is a locally finite measure on `ββΏ`, then `fun J β¦ ΞΌ.real J` is a box-additive
function. -/
@[simps]
def toBoxAdditive [Finite ΞΉ] (ΞΌ : Measure (ΞΉ β β)) [IsLocallyFiniteMeasure ΞΌ] : ΞΉ βα΅α΅[β€] β where
toFun J := ΞΌ.real J
sum_partition_boxes' J _ Ο hΟ := by rw [β Ο.measure_iUnion_toReal, hΟ.iUnion_eq]
end Measure
end MeasureTheory
namespace BoxIntegral
open MeasureTheory
namespace Box
variable [Fintype ΞΉ]
-- This is not a `simp` lemma because the left-hand side simplifies already.
-- See `volume_apply'` for the relevant `simp` lemma.
theorem volume_apply (I : Box ΞΉ) :
(volume : Measure (ΞΉ β β)).toBoxAdditive I = β i, (I.upper i - I.lower i) := by
rw [Measure.toBoxAdditive_apply, coe_eq_pi, measureReal_def,
Real.volume_pi_Ioc_toReal I.lower_le_upper]
@[simp]
theorem volume_apply' (I : Box ΞΉ) :
((volume : Measure (ΞΉ β β)) I).toReal = β i, (I.upper i - I.lower i) := by
rw [coe_eq_pi, Real.volume_pi_Ioc_toReal I.lower_le_upper]
theorem volume_face_mul {n} (i : Fin (n + 1)) (I : Box (Fin (n + 1))) :
(β j, ((I.face i).upper j - (I.face i).lower j)) * (I.upper i - I.lower i) =
β j, (I.upper j - I.lower j) := by
simp only [face_lower, face_upper, Fin.prod_univ_succAbove _ i, mul_comm]
end Box
namespace BoxAdditiveMap
variable [Fintype ΞΉ]
/-- Box-additive map sending each box `I` to the continuous linear endomorphism
`x β¦ (volume I).toReal β’ x`. -/
protected def volume {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] : ΞΉ βα΅α΅ E βL[β] E :=
(volume : Measure (ΞΉ β β)).toBoxAdditive.toSMul
theorem volume_apply {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] (I : Box ΞΉ) (x : E) :
BoxAdditiveMap.volume I x = (β j, (I.upper j - I.lower j)) β’ x := by
rw [BoxAdditiveMap.volume, toSMul_apply]
exact congr_argβ (Β· β’ Β·) I.volume_apply rfl
end BoxAdditiveMap
end BoxIntegral |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/FactorizedRational.lean | import Mathlib.Analysis.Meromorphic.Divisor
import Mathlib.Analysis.Meromorphic.IsolatedZeros
import Mathlib.Analysis.Meromorphic.NormalForm
import Mathlib.Analysis.Meromorphic.TrailingCoefficient
import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# Factorized Rational Functions
This file discusses functions `π β π` of the form `βαΆ u, (Β· - u) ^ d u`, where `d : π β β€` is
integer-valued. We show that these "factorized rational functions" are meromorphic in normal form,
with divisor equal to `d`.
Under suitable assumptions, we show that meromorphic functions are equivalent, modulo equality on
codiscrete sets, to the product of a factorized rational function and an analytic function without
zeros.
Implementation Note: For consistency, we use `βαΆ u, (Β· - u) ^ d u` throughout. If the support of `d`
is finite, then evaluation of functions commutes with finprod, and the helper lemma
`Function.FactorizedRational.finprod_eval` asserts that `βαΆ u, (Β· - u) ^ d u` equals the function
`fun x β¦ βαΆ u, (x - u) ^ d u`. If `d` has infinite support, this equality is wrong in general.
There are elementary examples of functions `d` where `βαΆ u, (Β· - u) ^ d u` is constant one, while
`fun x β¦ βαΆ u, (x - u) ^ d u` is not continuous.
-/
variable
{π : Type*} [NontriviallyNormedField π]
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
{U : Set π}
open Filter Function Real Set
namespace Function.FactorizedRational
/-!
## Elementary Properties of Factorized Rational Functions
-/
/--
Helper Lemma: Identify the support of `d` as the mulsupport of the product defining the factorized
rational function.
-/
lemma mulSupport (d : π β β€) :
(fun u β¦ (Β· - u) ^ d u).mulSupport = d.support := by
ext u
constructor <;> intro h
Β· simp_all only [mem_mulSupport, ne_eq, mem_support]
by_contra hCon
simp_all [zpow_zero]
Β· simp_all only [mem_mulSupport, ne_eq, ne_iff]
use u
simp_all [zero_zpow_eq_oneβ]
/--
Helper Lemma: If the support of `d` is finite, then evaluation of functions commutes with finprod,
and the function `βαΆ u, (Β· - u) ^ d u` equals `fun x β¦ βαΆ u, (x - u) ^ d u`.
-/
lemma finprod_eq_fun {d : π β β€} (h : d.support.Finite) :
(βαΆ u, (Β· - u) ^ d u) = fun x β¦ βαΆ u, (x - u) ^ d u := by
ext x
rw [finprod_eq_prod_of_mulSupport_subset (s := h.toFinset),
finprod_eq_prod_of_mulSupport_subset (s := h.toFinset)]
Β· simp
Β· intro u
contrapose
simp_all
Β· simp [mulSupport d]
/--
Factorized rational functions are analytic wherever the exponent is non-negative.
-/
theorem analyticAt {d : π β β€} {x : π} (h : 0 β€ d x) :
AnalyticAt π (βαΆ u, (Β· - u) ^ d u) x := by
apply analyticAt_finprod
intro u
by_cases hβ : x = u
Β· apply AnalyticAt.fun_zpow_nonneg (by fun_prop)
rwa [β hβ]
Β· apply AnalyticAt.fun_zpow (by fun_prop)
rwa [sub_ne_zero]
/--
Factorized rational functions are non-zero wherever the exponent is zero.
-/
theorem ne_zero {d : π β β€} {x : π} (h : d x = 0) :
(βαΆ u, (Β· - u) ^ d u) x β 0 := by
by_cases hβ : (fun u β¦ (Β· - u) ^ d u).mulSupport.Finite
Β· rw [finprod_eq_prod _ hβ, Finset.prod_apply, Finset.prod_ne_zero_iff]
intro z hz
simp only [Pi.pow_apply, ne_eq]
by_cases hβ : x = z <;> simp_all [zpow_ne_zero, sub_ne_zero]
Β· simp [finprod_of_infinite_mulSupport hβ]
open Classical in
/--
Helper Lemma for Computations: Extract one factor out of a factorized rational function.
-/
lemma extractFactor {d : π β β€} (uβ : π) (hd : d.support.Finite) :
(βαΆ u, (Β· - u) ^ d u) = ((Β· - uβ) ^ d uβ) * (βαΆ u, (Β· - u) ^ (update d uβ 0 u)) := by
by_cases hβd : d uβ = 0
Β· simp [β eq_update_self_iff.2 hβd, hβd]
Β· have : (fun u β¦ (fun x β¦ x - u) ^ d u).mulSupport β hd.toFinset := by
simp [mulSupport]
rw [finprod_eq_prod_of_mulSupport_subset _ this]
have : uβ β hd.toFinset := by simp_all
rw [β Finset.mul_prod_erase hd.toFinset _ this]
congr 1
have : (fun u β¦ (Β· - u) ^ (update d uβ 0 u)).mulSupport β hd.toFinset.erase uβ := by
rw [mulSupport]
intro x hx
by_cases hβx : x = uβ <;> simp_all
simp_all [finprod_eq_prod_of_mulSupport_subset _ this, Finset.prod_congr rfl]
/--
Factorized rational functions are meromorphic in normal form on `univ`.
-/
theorem meromorphicNFOn_univ (d : π β β€) :
MeromorphicNFOn (βαΆ u, (Β· - u) ^ d u) univ := by
classical
by_cases hd : d.support.Finite
Β· intro z hz
rw [extractFactor z hd]
right
use d z, (βαΆ u, (Β· - u) ^ update d z 0 u)
simp [analyticAt, ne_zero]
Β· rw [β mulSupport d] at hd
rw [finprod_of_infinite_mulSupport hd]
exact AnalyticOnNhd.meromorphicNFOn analyticOnNhd_const
/--
Factorized rational functions are meromorphic in normal form on arbitrary subsets of `π`.
-/
theorem meromorphicNFOn (d : π β β€) (U : Set π) :
MeromorphicNFOn (βαΆ u, (Β· - u) ^ d u) U := fun _ _ β¦ meromorphicNFOn_univ d (trivial)
/-!
## Orders and Divisors of Factorized Rational Functions
-/
/--
The order of the factorized rational function `(βαΆ u, fun z β¦ (z - u) ^ d u)` at `z` equals `d z`.
-/
theorem meromorphicOrderAt_eq {z : π} (d : π β β€) (hβd : d.support.Finite) :
meromorphicOrderAt (βαΆ u, (Β· - u) ^ d u) z = d z := by
classical
rw [meromorphicOrderAt_eq_int_iff ((meromorphicNFOn_univ d).meromorphicOn _ (mem_univ _))]
use βαΆ u, (Β· - u) ^ update d z 0 u
simp only [update_self, le_refl, analyticAt, ne_eq, ne_zero, not_false_eq_true, smul_eq_mul,
true_and]
filter_upwards
simp [extractFactor z hβd]
@[deprecated (since := "2025-05-22")] alias order := meromorphicOrderAt_eq
/--
Factorized rational functions are nowhere locally constant zero.
-/
theorem meromorphicOrderAt_ne_top {z : π} (d : π β β€) :
meromorphicOrderAt (βαΆ u, (Β· - u) ^ d u) z β β€ := by
classical
by_cases hd : d.support.Finite
Β· simp [meromorphicOrderAt_eq d hd]
Β· rw [β mulSupport] at hd
simp [finprod_of_infinite_mulSupport hd]
@[deprecated (since := "2025-05-22")] alias order_ne_top := meromorphicOrderAt_ne_top
/--
If `D` is a divisor, then the divisor of the factorized rational function equals `D`.
-/
theorem divisor {U : Set π} {D : locallyFinsuppWithin U β€} (hD : D.support.Finite) :
MeromorphicOn.divisor (βαΆ u, (Β· - u) ^ D u) U = D := by
ext z
by_cases hz : z β U
<;> simp [(meromorphicNFOn D U).meromorphicOn, hz, meromorphicOrderAt_eq D hD]
open Classical in
private lemma mulSupport_update {d : π β β€} {x : π}
(h : d.support.Finite) :
(fun u β¦ (x - u) ^ Function.update d x 0 u).mulSupport β h.toFinset := by
intro u
contrapose
simp only [mem_mulSupport, ne_eq, Decidable.not_not]
by_cases hβ : u = x
Β· rw [hβ]
simp
Β· simp_all
open Classical in
/--
Compute the trailing coefficient of the factorized rational function associated with `d : π β β€`.
-/
/-
Low-priority TODO: Using that non-trivially normed fields contain infinitely many elements that are
no roots of unity, it might be possible to drop assumption `h` here and in some of the theorems
below.
-/
theorem meromorphicTrailingCoeffAt_factorizedRational {d : π β β€} {x : π} (h : d.support.Finite) :
meromorphicTrailingCoeffAt (βαΆ u, (Β· - u) ^ d u) x = βαΆ u, (x - u) ^ update d x 0 u := by
have : (fun u β¦ (Β· - u) ^ d u).mulSupport β h.toFinset := by
simp [Function.FactorizedRational.mulSupport]
rw [finprod_eq_prod_of_mulSupport_subset _ this, meromorphicTrailingCoeffAt_prod
(fun _ β¦ by fun_prop), finprod_eq_prod_of_mulSupport_subset _ (mulSupport_update h)]
apply Finset.prod_congr rfl
intro y hy
rw [MeromorphicAt.meromorphicTrailingCoeffAt_zpow (by fun_prop)]
by_cases hxy : x = y
Β· rw [hxy, meromorphicTrailingCoeffAt_id_sub_const]
simp_all
Β· grind [meromorphicTrailingCoeffAt_id_sub_const]
/--
Variant of `meromorphicTrailingCoeffAt_factorizedRational`: Compute the trailing coefficient of the
factorized rational function associated with `d : π β β€` at points outside the support of `d`.
-/
theorem meromorphicTrailingCoeffAt_factorizedRational_off_support {d : π β β€} {x : π}
(hβ : d.support.Finite) (hβ : x β d.support) :
meromorphicTrailingCoeffAt (βαΆ u, (Β· - u) ^ d u) x = βαΆ u, (x - u) ^ d u := by
classical
rw [meromorphicTrailingCoeffAt_factorizedRational hβ,
finprod_eq_prod_of_mulSupport_subset _ (mulSupport_update hβ)]
have : (fun u β¦ (x - u) ^ d u).mulSupport β hβ.toFinset := by
intro u
contrapose
simp_all
rw [finprod_eq_prod_of_mulSupport_subset _ this, Finset.prod_congr rfl]
intro y hy
congr
apply Function.update_of_ne
by_contra hCon
simp_all
/--
Variant of `meromorphicTrailingCoeffAt_factorizedRational`: Compute log of the norm of the trailing
coefficient. The convention that `log 0 = 0` gives a closed formula easier than the one in
`meromorphicTrailingCoeffAt_factorizedRational`.
-/
theorem log_norm_meromorphicTrailingCoeffAt {d : π β β€} {x : π} (h : d.support.Finite) :
log βmeromorphicTrailingCoeffAt (βαΆ u, (Β· - u) ^ d u) xβ = βαΆ u, (d u) * log βx - uβ := by
classical
rw [meromorphicTrailingCoeffAt_factorizedRational h,
finprod_eq_prod_of_mulSupport_subset _ (mulSupport_update h)]
have : β y β h.toFinset, β(x - y) ^ update d x 0 yβ β 0 := by
intro y _
by_cases h : x = y
Β· rw [h]
simp_all
Β· simp_all [zpow_ne_zero, sub_ne_zero]
rw [norm_prod, log_prod this]
have : (fun u β¦ (d u) * log βx - uβ).support β h.toFinset := by
intro u
contrapose
simp_all
rw [finsum_eq_sum_of_support_subset _ this]
apply Finset.sum_congr rfl
intro y hy
rw [norm_zpow, Real.log_zpow]
by_cases h : x = y
Β· simp [h]
Β· rw [Function.update_of_ne (by tauto)]
end Function.FactorizedRational
open Function.FactorizedRational
/-!
## Elimination of Zeros and Poles
This section shows that every meromorphic function with finitely many zeros and poles is equivalent,
modulo equality on codiscrete sets, to the product of a factorized rational function and an analytic
function without zeros.
We provide analogous results for functions of the form `log βmeromorphicβ`.
-/
/-
TODO: Identify some of the terms that appear in the decomposition.
-/
/--
If `f` is meromorphic on an open set `U`, if `f` is nowhere locally constant zero, and if the
support of the divisor of `f` is finite, then there exists an analytic function `g` on `U` without
zeros such that `f` is equivalent, modulo equality on codiscrete sets, to the product of `g` and the
factorized rational function associated with the divisor of `f`.
-/
theorem MeromorphicOn.extract_zeros_poles {f : π β E} (hβf : MeromorphicOn f U)
(hβf : β u : U, meromorphicOrderAt f u β β€) (hβf : (divisor f U).support.Finite) :
β g : π β E, AnalyticOnNhd π g U β§ (β u : U, g u β 0) β§
f =αΆ [codiscreteWithin U] (βαΆ u, (Β· - u) ^ divisor f U u) β’ g := by
-- Take `g` as the inverse of the Laurent polynomial defined below, converted to a meromorphic
-- function in normal form. Then check all the properties.
let Ο := βαΆ u, (Β· - u) ^ (divisor f U u)
have hΟ : MeromorphicOn Ο U := (meromorphicNFOn (divisor f U) U).meromorphicOn
let g := toMeromorphicNFOn (Οβ»ΒΉ β’ f) U
have hg : MeromorphicNFOn g U := by apply meromorphicNFOn_toMeromorphicNFOn
refine β¨g, ?_, ?_, ?_β©
Β· -- AnalyticOnNhd π g U
rw [β hg.divisor_nonneg_iff_analyticOnNhd, divisor_of_toMeromorphicNFOn (hΟ.inv.smul hβf),
divisor_smul hΟ.inv hβf _ (fun z hz β¦ hβf β¨z, hzβ©), divisor_inv,
Function.FactorizedRational.divisor hβf, neg_add_cancel]
intro z hz
simpa [meromorphicOrderAt_inv] using meromorphicOrderAt_ne_top (divisor f U)
Β· -- β (u : βU), g βu β 0
intro β¨u, huβ©
rw [β (hg hu).meromorphicOrderAt_eq_zero_iff, β meromorphicOrderAt_congr
(toMeromorphicNFOn_eq_self_on_nhdsNE (hΟ.inv.smul hβf) hu).symm,
meromorphicOrderAt_smul (hΟ u hu).inv (hβf u hu), meromorphicOrderAt_inv,
meromorphicOrderAt_eq _ hβf]
simp only [hβf, hu, divisor_apply]
lift meromorphicOrderAt f u to β€ using (hβf β¨u, huβ©) with n hn
rw [WithTop.untopβ_coe, β WithTop.LinearOrderedAddCommGroup.coe_neg, β WithTop.coe_add]
simp
Β· -- f =αΆ [codiscreteWithin U] (βαΆ (u : π), fun z β¦ (z - u) ^ (divisor f U) u) * g
filter_upwards [(divisor f U).eq_zero_codiscreteWithin,
(hΟ.inv.smul hβf).meromorphicNFAt_mem_codiscreteWithin,
self_mem_codiscreteWithin U] with a hβa hβa hβa
unfold g
simp only [Pi.smul_apply', toMeromorphicNFOn_eq_toMeromorphicNFAt (hΟ.inv.smul hβf) hβa,
toMeromorphicNFAt_eq_self.2 hβa, Pi.inv_apply]
rw [β smul_assoc, smul_eq_mul, mul_inv_cancelβ _, one_smul]
rwa [β ((meromorphicNFOn_univ (divisor f U)) trivial).meromorphicOrderAt_eq_zero_iff,
meromorphicOrderAt_eq, hβa, Pi.zero_apply, WithTop.coe_zero]
/--
In the setting of `MeromorphicOn.extract_zeros_poles`, the function `log βfβ` is equivalent, modulo
equality on codiscrete subsets, to `βαΆ u, (divisor f U u * log βΒ· - uβ) + log βg Β·β`.
-/
theorem MeromorphicOn.extract_zeros_poles_log {f g : π β E} {D : Function.locallyFinsuppWithin U β€}
(hg : β u : U, g u β 0) (h : f =αΆ [codiscreteWithin U] (βαΆ u, (Β· - u) ^ D u) β’ g) :
(log βf Β·β) =αΆ [codiscreteWithin U] βαΆ u, (D u * log βΒ· - uβ) + (log βg Β·β) := by
-- Identify support of the sum in the goal
have tβ : (fun u β¦ (D u * log βΒ· - uβ)).support = D.support := by
ext u
rw [β not_iff_not]
simp only [ne_eq, not_not, Function.mem_support]
constructor <;> intro hx
Β· obtain β¨y, hyβ© := NormedField.exists_one_lt_norm π
have := congrFun hx (y + u)
simp only [add_sub_cancel_right, Pi.zero_apply, mul_eq_zero, Int.cast_eq_zero, log_eq_zero,
norm_eq_zero] at this
rcases this with h | h | h | h
Β· assumption
Β· simp only [h, norm_zero] at hy
linarith
Β· simp only [h, lt_self_iff_false] at hy
Β· simp only [h, lt_neg_self_iff] at hy
linarith
Β· simp_all [Pi.zero_def]
-- Trivial case: the support of D is infinite
by_cases hβf : D.support.Finite
case neg =>
rw [finsum_of_infinite_support (by simpa [tβ] using hβf)]
rw [finprod_of_infinite_mulSupport (by simpa [FactorizedRational.mulSupport] using hβf)] at h
filter_upwards [h] with x hx
simp [hx]
-- General case
filter_upwards [h, D.eq_zero_codiscreteWithin, self_mem_codiscreteWithin U] with z hz hβz hβz
rw [Pi.zero_apply] at hβz
rw [hz, finprod_eq_prod_of_mulSupport_subset (s := hβf.toFinset) _
(by simp_all [FactorizedRational.mulSupport]),
finsum_eq_sum_of_support_subset (s := hβf.toFinset) _ (by simp_all)]
have : β x β hβf.toFinset, βz - xβ ^ D x β 0 := by
intro x hx
rw [Finite.mem_toFinset, Function.mem_support] at hx
rw [ne_eq, zpow_eq_zero_iff hx, norm_eq_zero, sub_eq_zero, eq_comm]
apply ne_of_apply_ne D
rwa [hβz]
simp only [Pi.smul_apply', Finset.prod_apply, Pi.pow_apply, norm_smul, norm_prod, norm_zpow]
rw [log_mul (Finset.prod_ne_zero_iff.2 this) (by simp [hg β¨z, hβzβ©]), log_prod this]
simp [log_zpow]
open Classical in
/--
In the setting of `MeromorphicOn.extract_zeros_poles`, compute the trailing
coefficient of `f` in terms of `divisor f U` and `g x`.
-/
theorem MeromorphicOn.meromorphicTrailingCoeffAt_extract_zeros_poles
{x : π} {f g : π β E} {D : π β β€} (hD : D.support.Finite) (hβx : x β U) (hβx : AccPt x (π U))
(hf : MeromorphicAt f x) (hβg : AnalyticAt π g x) (hβg : g x β 0)
(h : f =αΆ [codiscreteWithin U] (βαΆ u, (Β· - u) ^ D u) β’ g) :
meromorphicTrailingCoeffAt f x = (βαΆ u, (x - u) ^ Function.update D x 0 u) β’ g x := by
have tβ : MeromorphicAt (βαΆ u, (Β· - u) ^ D u) x :=
(FactorizedRational.meromorphicNFOn D U).meromorphicOn x hβx
rw [meromorphicTrailingCoeffAt_congr_nhdsNE
(hf.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin (by fun_prop) hβx hβx h),
tβ.meromorphicTrailingCoeffAt_smul hβg.meromorphicAt,
hβg.meromorphicTrailingCoeffAt_of_ne_zero hβg]
simp [meromorphicTrailingCoeffAt_factorizedRational hD]
/--
In the setting of `MeromorphicOn.extract_zeros_poles`, compute the log of the
norm of the trailing coefficient of `f` in terms of `divisor f U` and `g x`.
-/
theorem MeromorphicOn.log_norm_meromorphicTrailingCoeffAt_extract_zeros_poles
{x : π} {f g : π β E} {D : π β β€} (hD : D.support.Finite) (hβx : x β U) (hβx : AccPt x (π U))
(hf : MeromorphicAt f x) (hβg : AnalyticAt π g x) (hβg : g x β 0)
(h : f =αΆ [codiscreteWithin U] (βαΆ u, (Β· - u) ^ D u) β’ g) :
log βmeromorphicTrailingCoeffAt f xβ = βαΆ u, (D u) * log βx - uβ + log βg xβ := by
rw [meromorphicTrailingCoeffAt_congr_nhdsNE
(hf.eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin
(((FactorizedRational.meromorphicNFOn D U).meromorphicOn x hβx).smul hβg.meromorphicAt)
hβx hβx h),
((FactorizedRational.meromorphicNFOn D U).meromorphicOn x hβx).meromorphicTrailingCoeffAt_smul
hβg.meromorphicAt, hβg.meromorphicTrailingCoeffAt_of_ne_zero hβg,
norm_smul, log_mul, log_norm_meromorphicTrailingCoeffAt hD]
Β· simp only [ne_eq, norm_eq_zero]
apply MeromorphicAt.meromorphicTrailingCoeffAt_ne_zero
((FactorizedRational.meromorphicNFOn D U).meromorphicOn x hβx)
apply FactorizedRational.meromorphicOrderAt_ne_top
Β· simp_all |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/Order.lean | import Mathlib.Algebra.Order.WithTop.Untop0
import Mathlib.Analysis.Analytic.Order
import Mathlib.Analysis.Meromorphic.Basic
/-!
# Orders of Meromorphic Functions
This file defines the order of a meromorphic function `f` at a point `zβ`, as an element of
`β€ βͺ {β}`.
We characterize the order being `< 0`, or `= 0`, or `> 0`, as the convergence of the function
to infinity, resp. a nonzero constant, resp. zero.
## TODO
Uniformize API between analytic and meromorphic functions
-/
open Filter Set WithTop.LinearOrderedAddCommGroup
open scoped Topology
variable {π : Type*} [NontriviallyNormedField π]
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
{f fβ fβ : π β E} {x : π}
/-!
## Order at a Point: Definition and Characterization
-/
open scoped Classical in
/-- The order of a meromorphic function `f` at `zβ`, as an element of `β€ βͺ {β}`.
The order is defined to be `β` if `f` is identically 0 on a neighbourhood of `zβ`, and otherwise the
unique `n` such that `f` can locally be written as `f z = (z - zβ) ^ n β’ g z`, where `g` is analytic
and does not vanish at `zβ`. See `MeromorphicAt.meromorphicOrderAt_eq_top_iff` and
`MeromorphicAt.meromorphicOrderAt_eq_int_iff` for these equivalences.
If the function is not meromorphic at `x`, we use the junk value `0`. -/
noncomputable def meromorphicOrderAt (f : π β E) (x : π) : WithTop β€ :=
if hf : MeromorphicAt f x then
((analyticOrderAt (fun z β¦ (z - x) ^ hf.choose β’ f z) x).map (βΒ· : β β β€)) - hf.choose
else 0
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.order := meromorphicOrderAt
@[simp]
lemma meromorphicOrderAt_of_not_meromorphicAt (hf : Β¬ MeromorphicAt f x) :
meromorphicOrderAt f x = 0 :=
dif_neg hf
lemma meromorphicAt_of_meromorphicOrderAt_ne_zero (hf : meromorphicOrderAt f x β 0) :
MeromorphicAt f x := by
contrapose! hf
simp [hf]
/-- The order of a meromorphic function `f` at a `zβ` is infinity iff `f` vanishes locally around
`zβ`. -/
lemma meromorphicOrderAt_eq_top_iff :
meromorphicOrderAt f x = β€ β βαΆ z in π[β ] x, f z = 0 := by
by_cases hf : MeromorphicAt f x; swap
Β· simp only [hf, not_false_eq_true, meromorphicOrderAt_of_not_meromorphicAt, WithTop.zero_ne_top,
false_iff]
contrapose! hf
exact (MeromorphicAt.const 0 x).congr (EventuallyEq.symm hf)
simp only [meromorphicOrderAt, hf, βreduceDIte, sub_eq_top_iff, ENat.map_eq_top_iff,
WithTop.natCast_ne_top, or_false]
by_cases h : analyticOrderAt (fun z β¦ (z - x) ^ hf.choose β’ f z) x = β€
Β· simp only [h, eventually_nhdsWithin_iff, mem_compl_iff, mem_singleton_iff, true_iff]
rw [analyticOrderAt_eq_top] at h
filter_upwards [h] with z hf hz
rwa [smul_eq_zero_iff_right <| pow_ne_zero _ (sub_ne_zero.mpr hz)] at hf
Β· obtain β¨m, hmβ© := ENat.ne_top_iff_exists.mp h
simp only [β hm, ENat.coe_ne_top, false_iff]
contrapose! h
rw [analyticOrderAt_eq_top]
rw [β hf.choose_spec.frequently_eq_iff_eventually_eq analyticAt_const]
apply Eventually.frequently
filter_upwards [h] with z hfz
rw [hfz, smul_zero]
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_eq_top_iff := meromorphicOrderAt_eq_top_iff
/-- The order of a meromorphic function `f` at `zβ` equals an integer `n` iff `f` can locally be
written as `f z = (z - zβ) ^ n β’ g z`, where `g` is analytic and does not vanish at `zβ`. -/
lemma meromorphicOrderAt_eq_int_iff {n : β€} (hf : MeromorphicAt f x) : meromorphicOrderAt f x = n β
β g : π β E, AnalyticAt π g x β§ g x β 0 β§ βαΆ z in π[β ] x, f z = (z - x) ^ n β’ g z := by
simp only [meromorphicOrderAt, hf, βreduceDIte]
by_cases h : analyticOrderAt (fun z β¦ (z - x) ^ hf.choose β’ f z) x = β€
Β· rw [h, ENat.map_top, β WithTop.coe_natCast, top_sub,
eq_false_intro WithTop.top_ne_coe, false_iff]
rw [analyticOrderAt_eq_top] at h
refine fun β¨g, hg_an, hg_ne, hg_eqβ© β¦ hg_ne ?_
apply EventuallyEq.eq_of_nhds
rw [EventuallyEq, β AnalyticAt.frequently_eq_iff_eventually_eq hg_an analyticAt_const]
apply Eventually.frequently
rw [eventually_nhdsWithin_iff] at hg_eq β’
filter_upwards [h, hg_eq] with z hfz hfz_eq hz
rwa [hfz_eq hz, β mul_smul, smul_eq_zero_iff_right] at hfz
exact mul_ne_zero (pow_ne_zero _ (sub_ne_zero.mpr hz)) (zpow_ne_zero _ (sub_ne_zero.mpr hz))
Β· obtain β¨m, hβ© := ENat.ne_top_iff_exists.mp h
rw [β h, ENat.map_coe, β WithTop.coe_natCast, β coe_sub, WithTop.coe_inj]
obtain β¨g, hg_an, hg_ne, hg_eqβ© := hf.choose_spec.analyticOrderAt_eq_natCast.mp h.symm
replace hg_eq : βαΆ (z : π) in π[β ] x, f z = (z - x) ^ (βm - βhf.choose : β€) β’ g z := by
rw [eventually_nhdsWithin_iff]
filter_upwards [hg_eq] with z hg_eq hz
rwa [β smul_right_inj <| zpow_ne_zero _ (sub_ne_zero.mpr hz), β mul_smul,
β zpow_addβ (sub_ne_zero.mpr hz), β add_sub_assoc, add_sub_cancel_left, zpow_natCast,
zpow_natCast]
exact β¨fun h β¦ β¨g, hg_an, hg_ne, h βΈ hg_eqβ©,
AnalyticAt.unique_eventuallyEq_zpow_smul_nonzero β¨g, hg_an, hg_ne, hg_eqβ©β©
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_eq_inf_iff := meromorphicOrderAt_eq_int_iff
/--
The order of a meromorphic function `f` at `zβ` is finite iff `f` can locally be
written as `f z = (z - zβ) ^ order β’ g z`, where `g` is analytic and does not
vanish at `zβ`.
-/
theorem meromorphicOrderAt_ne_top_iff {f : π β E} {zβ : π} (hf : MeromorphicAt f zβ) :
meromorphicOrderAt f zβ β β€ β β (g : π β E), AnalyticAt π g zβ β§ g zβ β 0 β§
f =αΆ [π[β ] zβ] fun z β¦ (z - zβ) ^ ((meromorphicOrderAt f zβ).untopβ) β’ g z :=
β¨fun h β¦ (meromorphicOrderAt_eq_int_iff hf).1 (WithTop.coe_untopβ_of_ne_top h).symm,
fun h β¦ Option.ne_none_iff_exists'.2
β¨(meromorphicOrderAt f zβ).untopD 0, (meromorphicOrderAt_eq_int_iff hf).2 hβ©β©
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_ne_top_iff := meromorphicOrderAt_ne_top_iff
/--
The order of a meromorphic function `f` at `zβ` is finite iff `f` does not have
any zeros in a sufficiently small neighborhood of `zβ`.
-/
theorem meromorphicOrderAt_ne_top_iff_eventually_ne_zero {f : π β E} (hf : MeromorphicAt f x) :
meromorphicOrderAt f x β β€ β βαΆ x in π[β ] x, f x β 0 := by
constructor
Β· intro h
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_ne_top_iff hf).1 h
filter_upwards [hβg, self_mem_nhdsWithin, eventually_nhdsWithin_of_eventually_nhds
((hβg.continuousAt.ne_iff_eventually_ne continuousAt_const).mp hβg)]
simp_all [zpow_ne_zero, sub_ne_zero]
Β· simp_all [meromorphicOrderAt_eq_top_iff, Eventually.frequently]
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.order_ne_top_iff_eventually_ne_zero :=
meromorphicOrderAt_ne_top_iff_eventually_ne_zero
/-- If the order of a meromorphic function is negative, then this function converges to infinity
at this point. See also the iff version `tendsto_cobounded_iff_meromorphicOrderAt_neg`. -/
lemma tendsto_cobounded_of_meromorphicOrderAt_neg (ho : meromorphicOrderAt f x < 0) :
Tendsto f (π[β ] x) (Bornology.cobounded E) := by
have hf : MeromorphicAt f x := meromorphicAt_of_meromorphicOrderAt_ne_zero ho.ne
simp only [β tendsto_norm_atTop_iff_cobounded]
obtain β¨m, hmβ© := WithTop.ne_top_iff_exists.mp ho.ne_top
have m_neg : m < 0 := by simpa [β hm] using ho
rcases (meromorphicOrderAt_eq_int_iff hf).1 hm.symm with β¨g, g_an, gx, hgβ©
have A : Tendsto (fun z β¦ β(z - x) ^ m β’ g zβ) (π[β ] x) atTop := by
simp only [norm_smul]
apply Filter.Tendsto.atTop_mul_pos (C := βg xβ) (by simp [gx]) _
g_an.continuousAt.continuousWithinAt.tendsto.norm
have : Tendsto (fun z β¦ z - x) (π[β ] x) (π[β ] 0) := by
refine tendsto_nhdsWithin_iff.2 β¨?_, ?_β©
Β· have : ContinuousWithinAt (fun z β¦ z - x) ({x}αΆ) x :=
ContinuousAt.continuousWithinAt (by fun_prop)
simpa using this.tendsto
Β· filter_upwards [self_mem_nhdsWithin] with y hy
simpa [sub_eq_zero] using hy
apply Tendsto.comp (NormedField.tendsto_norm_zpow_nhdsNE_zero_atTop m_neg) this
apply A.congr'
filter_upwards [hg] with z hz using by simp [hz]
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_cobounded_of_order_neg :=
tendsto_cobounded_of_meromorphicOrderAt_neg
/-- If the order of a meromorphic function is zero, then this function converges to a nonzero
limit at this point. See also the iff version `tendsto_ne_zero_iff_meromorphicOrderAt_eq_zero`. -/
lemma tendsto_ne_zero_of_meromorphicOrderAt_eq_zero
(hf : MeromorphicAt f x) (ho : meromorphicOrderAt f x = 0) :
β c β 0, Tendsto f (π[β ] x) (π c) := by
rcases (meromorphicOrderAt_eq_int_iff hf).1 ho with β¨g, g_an, gx, hgβ©
refine β¨g x, gx, ?_β©
apply g_an.continuousAt.continuousWithinAt.tendsto.congr'
filter_upwards [hg] with y hy using by simp [hy]
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_ne_zero_of_order_eq_zero :=
tendsto_ne_zero_of_meromorphicOrderAt_eq_zero
/-- If the order of a meromorphic function is positive, then this function converges to zero
at this point. See also the iff version `tendsto_zero_iff_meromorphicOrderAt_pos`. -/
lemma tendsto_zero_of_meromorphicOrderAt_pos (ho : 0 < meromorphicOrderAt f x) :
Tendsto f (π[β ] x) (π 0) := by
have hf : MeromorphicAt f x := meromorphicAt_of_meromorphicOrderAt_ne_zero ho.ne'
cases h'o : meromorphicOrderAt f x with
| top =>
apply tendsto_const_nhds.congr'
filter_upwards [meromorphicOrderAt_eq_top_iff.1 h'o] with y hy using hy.symm
| coe n =>
rcases (meromorphicOrderAt_eq_int_iff hf).1 h'o with β¨g, g_an, gx, hgβ©
lift n to β using by simpa [h'o] using ho.le
have : (0 : E) = (x - x) ^ n β’ g x := by
have : 0 < n := by simpa [h'o] using ho
simp [zero_pow_eq_zero.2 this.ne']
rw [this]
have : ContinuousAt (fun z β¦ (z - x) ^ n β’ g z) x := by fun_prop
apply this.continuousWithinAt.tendsto.congr'
filter_upwards [hg] with y hy using by simp [hy]
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_zero_of_order_pos :=
tendsto_zero_of_meromorphicOrderAt_pos
/-- If the order of a meromorphic function is nonnegative, then this function converges
at this point. See also the iff version `tendsto_nhds_iff_meromorphicOrderAt_nonneg`. -/
lemma tendsto_nhds_of_meromorphicOrderAt_nonneg
(hf : MeromorphicAt f x) (ho : 0 β€ meromorphicOrderAt f x) :
β c, Tendsto f (π[β ] x) (π c) := by
rcases ho.eq_or_lt with ho | ho
Β· rcases tendsto_ne_zero_of_meromorphicOrderAt_eq_zero hf ho.symm with β¨c, -, hcβ©
exact β¨c, hcβ©
Β· exact β¨0, tendsto_zero_of_meromorphicOrderAt_pos hoβ©
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_nhds_of_order_nonneg :=
tendsto_nhds_of_meromorphicOrderAt_nonneg
/-- A meromorphic function converges to infinity iff its order is negative. -/
lemma tendsto_cobounded_iff_meromorphicOrderAt_neg (hf : MeromorphicAt f x) :
Tendsto f (π[β ] x) (Bornology.cobounded E) β meromorphicOrderAt f x < 0 := by
rcases lt_or_ge (meromorphicOrderAt f x) 0 with ho | ho
Β· simp [ho, tendsto_cobounded_of_meromorphicOrderAt_neg]
Β· simp only [lt_iff_not_ge, ho, not_true_eq_false, iff_false, β tendsto_norm_atTop_iff_cobounded]
obtain β¨c, hcβ© := tendsto_nhds_of_meromorphicOrderAt_nonneg hf ho
exact not_tendsto_atTop_of_tendsto_nhds hc.norm
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_cobounded_iff_order_neg :=
tendsto_cobounded_iff_meromorphicOrderAt_neg
/-- A meromorphic function converges to a limit iff its order is nonnegative. -/
lemma tendsto_nhds_iff_meromorphicOrderAt_nonneg (hf : MeromorphicAt f x) :
(β c, Tendsto f (π[β ] x) (π c)) β 0 β€ meromorphicOrderAt f x := by
rcases lt_or_ge (meromorphicOrderAt f x) 0 with ho | ho
Β· simp only [β not_lt, ho, not_true_eq_false, iff_false, not_exists]
intro c hc
apply not_tendsto_atTop_of_tendsto_nhds hc.norm
rw [tendsto_norm_atTop_iff_cobounded]
exact tendsto_cobounded_of_meromorphicOrderAt_neg ho
Β· simp [ho, tendsto_nhds_of_meromorphicOrderAt_nonneg hf ho]
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_nhds_iff_order_nonneg :=
tendsto_nhds_iff_meromorphicOrderAt_nonneg
/-- A meromorphic function converges to a nonzero limit iff its order is zero. -/
lemma tendsto_ne_zero_iff_meromorphicOrderAt_eq_zero (hf : MeromorphicAt f x) :
(β c β 0, Tendsto f (π[β ] x) (π c)) β meromorphicOrderAt f x = 0 := by
rcases eq_or_ne (meromorphicOrderAt f x) 0 with ho | ho
Β· simp [ho, tendsto_ne_zero_of_meromorphicOrderAt_eq_zero hf ho]
simp only [ne_eq, ho, iff_false, not_exists, not_and]
intro c c_ne hc
rcases ho.lt_or_gt with ho | ho
Β· apply not_tendsto_atTop_of_tendsto_nhds hc.norm
rw [tendsto_norm_atTop_iff_cobounded]
exact tendsto_cobounded_of_meromorphicOrderAt_neg ho
Β· apply c_ne
exact tendsto_nhds_unique hc (tendsto_zero_of_meromorphicOrderAt_pos ho)
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_ne_zero_iff_order_eq_zero :=
tendsto_ne_zero_iff_meromorphicOrderAt_eq_zero
/-- A meromorphic function converges to zero iff its order is positive. -/
lemma tendsto_zero_iff_meromorphicOrderAt_pos (hf : MeromorphicAt f x) :
(Tendsto f (π[β ] x) (π 0)) β 0 < meromorphicOrderAt f x := by
rcases lt_or_ge 0 (meromorphicOrderAt f x) with ho | ho
Β· simp [ho, tendsto_zero_of_meromorphicOrderAt_pos ho]
simp only [β not_le, ho, not_true_eq_false, iff_false]
intro hc
rcases ho.eq_or_lt with ho | ho
Β· obtain β¨c, c_ne, h'cβ© := tendsto_ne_zero_of_meromorphicOrderAt_eq_zero hf ho
apply c_ne
exact tendsto_nhds_unique h'c hc
Β· apply not_tendsto_atTop_of_tendsto_nhds hc.norm
rw [tendsto_norm_atTop_iff_cobounded]
exact tendsto_cobounded_of_meromorphicOrderAt_neg ho
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.tendsto_zero_iff_order_pos :=
tendsto_zero_iff_meromorphicOrderAt_pos
/-- Meromorphic functions that agree in a punctured neighborhood of `zβ` have the same order at
`zβ`. -/
theorem meromorphicOrderAt_congr (hfββ : fβ =αΆ [π[β ] x] fβ) :
meromorphicOrderAt fβ x = meromorphicOrderAt fβ x := by
by_cases hfβ : MeromorphicAt fβ x; swap
Β· have : Β¬ MeromorphicAt fβ x := by
contrapose! hfβ
exact hfβ.congr hfββ.symm
simp [hfβ, this]
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· rw [hβfβ, eq_comm]
rw [meromorphicOrderAt_eq_top_iff] at hβfβ β’
exact EventuallyEq.rw hβfβ (fun x => Eq (fβ x)) hfββ.symm
Β· obtain β¨n, hn : meromorphicOrderAt fβ x = nβ© := Option.ne_none_iff_exists'.mp hβfβ
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hn
rw [hn, eq_comm, meromorphicOrderAt_eq_int_iff (hfβ.congr hfββ)]
use g, hβg, hβg
exact EventuallyEq.rw hβg (fun x => Eq (fβ x)) hfββ.symm
@[deprecated (since := "2025-05-22")] alias MeromorphicAt.order_congr :=
meromorphicOrderAt_congr
/-- Compatibility of notions of `order` for analytic and meromorphic functions. -/
lemma AnalyticAt.meromorphicOrderAt_eq (hf : AnalyticAt π f x) :
meromorphicOrderAt f x = (analyticOrderAt f x).map (β) := by
cases hn : analyticOrderAt f x
Β· rw [ENat.map_top, meromorphicOrderAt_eq_top_iff]
exact (analyticOrderAt_eq_top.mp hn).filter_mono nhdsWithin_le_nhds
Β· simp_rw [ENat.map_coe, meromorphicOrderAt_eq_int_iff hf.meromorphicAt, zpow_natCast]
rcases hf.analyticOrderAt_eq_natCast.mp hn with β¨g, h1, h2, h3β©
exact β¨g, h1, h2, h3.filter_mono nhdsWithin_le_nhdsβ©
@[deprecated (since := "2025-05-22")] alias AnalyticAt.meromorphicAt_order :=
AnalyticAt.meromorphicOrderAt_eq
/--
When seen as meromorphic functions, analytic functions have nonnegative order.
-/
theorem AnalyticAt.meromorphicOrderAt_nonneg (hf : AnalyticAt π f x) :
0 β€ meromorphicOrderAt f x := by
simp [hf.meromorphicOrderAt_eq]
@[deprecated (since := "2025-05-22")] alias AnalyticAt.meromorphicAt_order_nonneg :=
AnalyticAt.meromorphicOrderAt_nonneg
/-- If a function is both meromorphic and continuous at a point, then it is analytic there. -/
protected theorem MeromorphicAt.analyticAt {f : π β E} {x : π}
(h : MeromorphicAt f x) (h' : ContinuousAt f x) :
AnalyticAt π f x := by
cases ho : meromorphicOrderAt f x with
| top =>
/- If the order is infinite, then `f` vanishes on a pointed neighborhood of `x`. By continuity,
it also vanishes at `x`.-/
have : AnalyticAt π (fun _ β¦ (0 : E)) x := analyticAt_const
apply this.congr
rw [β ContinuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE continuousAt_const h']
filter_upwards [meromorphicOrderAt_eq_top_iff.1 ho] with y hy using by simp [hy]
| coe n =>
/- If the order is finite, then the order has to be nonnegative, as otherwise the norm of `f`
would tend to infinity at `x`. Then the local expression of `f` coming from its meromorphicity
shows that it coincides with an analytic function close to `x`, except maybe at `x`. By
continuity of `f`, the two functions also coincide at `x`. -/
rcases (meromorphicOrderAt_eq_int_iff h).1 ho with β¨g, g_an, gx, hgβ©
have : 0 β€ meromorphicOrderAt f x := by
apply (tendsto_nhds_iff_meromorphicOrderAt_nonneg h).1
exact β¨f x, h'.continuousWithinAt.tendstoβ©
lift n to β using by simpa [ho] using this
have A : βαΆ (z : π) in π x, (z - x) ^ n β’ g z = f z := by
apply (ContinuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE (by fun_prop) h').1
filter_upwards [hg] with z hz using by simpa using hz.symm
exact AnalyticAt.congr (by fun_prop) A
/--
The order of a constant function is `β€` if the constant is zero and `0` otherwise.
-/
theorem meromorphicOrderAt_const (zβ : π) (e : E) [Decidable (e = 0)] :
meromorphicOrderAt (fun _ β¦ e) zβ = if e = 0 then β€ else (0 : WithTop β€) := by
split_ifs with he
Β· simp [he, meromorphicOrderAt_eq_top_iff]
Β· exact (meromorphicOrderAt_eq_int_iff (.const e zβ)).2 β¨fun _ β¦ e, by fun_prop, by simpaβ©
/--
The order of a constant function is `β€` if the constant is zero and `0` otherwise.
-/
theorem meromorphicOrderAt_const_intCast (zβ : π) (n : β€) [Decidable ((n : π) = 0)] :
meromorphicOrderAt (n : π β π) zβ = if (n : π) = 0 then β€ else (0 : WithTop β€) :=
meromorphicOrderAt_const zβ (n : π)
/--
The order of a constant function is `β€` if the constant is zero and `0` otherwise.
-/
theorem meromorphicOrderAt_const_natCast (zβ : π) (n : β) [Decidable ((n : π) = 0)] :
meromorphicOrderAt (n : π β π) zβ = if (n : π) = 0 then β€ else (0 : WithTop β€) :=
meromorphicOrderAt_const zβ (n : π)
/--
The order of a constant function is `β€` if the constant is zero and `0` otherwise.
-/
@[simp] theorem meromorphicOrderAt_const_ofNat (zβ : π) (n : β) [Decidable ((n : π) = 0)] :
meromorphicOrderAt (ofNat(n) : π β π) zβ = if (n : π) = 0 then β€ else (0 : WithTop β€) := by
convert meromorphicOrderAt_const zβ (n : π)
simp [Semiring.toGrindSemiring_ofNat π n]
/-!
## Order at a Point: Behaviour under Ring Operations
We establish additivity of the order under multiplication and taking powers.
-/
/-- The order is additive when multiplying scalar-valued and vector-valued meromorphic functions. -/
theorem meromorphicOrderAt_smul {f : π β π} {g : π β E}
(hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
meromorphicOrderAt (f β’ g) x = meromorphicOrderAt f x + meromorphicOrderAt g x := by
-- Trivial cases: one of the functions vanishes around zβ
cases hβf : meromorphicOrderAt f x with
| top =>
simp only [top_add, meromorphicOrderAt_eq_top_iff] at hβf β’
filter_upwards [hβf] with z hz using by simp [hz]
| coe m =>
cases hβg : meromorphicOrderAt g x with
| top =>
simp only [add_top, meromorphicOrderAt_eq_top_iff] at hβg β’
filter_upwards [hβg] with z hz using by simp [hz]
| coe n => -- Non-trivial case: both functions do not vanish around zβ
rw [β WithTop.coe_add, meromorphicOrderAt_eq_int_iff (hf.smul hg)]
obtain β¨F, hβF, hβF, hβFβ© := (meromorphicOrderAt_eq_int_iff hf).1 hβf
obtain β¨G, hβG, hβG, hβGβ© := (meromorphicOrderAt_eq_int_iff hg).1 hβg
use F β’ G, hβF.smul hβG, by simp [hβF, hβG]
filter_upwards [self_mem_nhdsWithin, hβF, hβG] with a ha hfa hga
simp [hfa, hga, smul_comm (F a), zpow_addβ (sub_ne_zero.mpr ha), mul_smul]
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_smul := meromorphicOrderAt_smul
/-- The order is additive when multiplying meromorphic functions. -/
theorem meromorphicOrderAt_mul {f g : π β π} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
meromorphicOrderAt (f * g) x = meromorphicOrderAt f x + meromorphicOrderAt g x :=
meromorphicOrderAt_smul hf hg
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_mul := meromorphicOrderAt_mul
/-- The order multiplies by `n` when taking a meromorphic function to its `n`th power. -/
theorem meromorphicOrderAt_pow {f : π β π} {x : π} (hf : MeromorphicAt f x) {n : β} :
meromorphicOrderAt (f ^ n) x = n * meromorphicOrderAt f x := by
induction n
case zero =>
simp only [pow_zero, CharP.cast_eq_zero, zero_mul]
rw [β WithTop.coe_zero, meromorphicOrderAt_eq_int_iff]
Β· exact β¨1, analyticAt_const, by simpβ©
Β· apply MeromorphicAt.const
case succ n hn =>
simp only [pow_add, pow_one, meromorphicOrderAt_mul (hf.pow n) hf, hn, Nat.cast_add,
Nat.cast_one]
cases meromorphicOrderAt f x
Β· aesop
Β· norm_cast
simp only [Nat.cast_add, Nat.cast_one]
ring
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_pow := meromorphicOrderAt_pow
/-- The order multiplies by `n` when taking a meromorphic function to its `n`th power. -/
theorem meromorphicOrderAt_zpow {f : π β π} {x : π} (hf : MeromorphicAt f x) {n : β€} :
meromorphicOrderAt (f ^ n) x = n * meromorphicOrderAt f x := by
-- Trivial case: n = 0
by_cases hn : n = 0
Β· simp only [hn, zpow_zero, WithTop.coe_zero, zero_mul]
rw [β WithTop.coe_zero, meromorphicOrderAt_eq_int_iff]
Β· exact β¨1, analyticAt_const, by simpβ©
Β· apply MeromorphicAt.const
-- Trivial case: f locally zero
by_cases h : meromorphicOrderAt f x = β€
Β· simp only [h, ne_eq, WithTop.coe_eq_zero, hn, not_false_eq_true, WithTop.mul_top]
rw [meromorphicOrderAt_eq_top_iff] at *
filter_upwards [h]
intro y hy
simp [hy, zero_zpow n hn]
-- General case
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_ne_top_iff hf).1 h
rw [β WithTop.coe_untopβ_of_ne_top h, β WithTop.coe_mul,
meromorphicOrderAt_eq_int_iff (hf.zpow n)]
use g ^ n, hβg.zpow hβg
constructor
Β· simp_all [zpow_eq_zero_iff hn]
Β· filter_upwards [hβg]
intro y hy
rw [Pi.pow_apply, hy, smul_eq_mul, mul_zpow]
congr 1
rw [mul_comm, zpow_mul]
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_zpow := meromorphicOrderAt_zpow
/-- The order of the inverse is the negative of the order. -/
theorem meromorphicOrderAt_inv {f : π β π} :
meromorphicOrderAt (fβ»ΒΉ) x = -meromorphicOrderAt f x := by
by_cases hf : MeromorphicAt f x; swap
Β· have : Β¬ MeromorphicAt (fβ»ΒΉ) x := by
contrapose! hf
simpa using hf.inv
simp [hf, this]
by_cases hβf : meromorphicOrderAt f x = β€
Β· rw [hβf, β LinearOrderedAddCommGroupWithTop.neg_top, neg_neg]
rw [meromorphicOrderAt_eq_top_iff] at *
filter_upwards [hβf]
simp
lift meromorphicOrderAt f x to β€ using hβf with a ha
apply (meromorphicOrderAt_eq_int_iff hf.inv).2
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_eq_int_iff hf).1 ha.symm
use gβ»ΒΉ, hβg.inv hβg, inv_eq_zero.not.2 hβg
rw [eventually_nhdsWithin_iff] at *
filter_upwards [hβg]
intro _ hβa hβa
simp only [Pi.inv_apply, hβa hβa, smul_eq_mul, mul_inv_rev, zpow_neg]
ring
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_inv := meromorphicOrderAt_inv
/--
The order of a sum is at least the minimum of the orders of the summands.
-/
theorem meromorphicOrderAt_add (hfβ : MeromorphicAt fβ x) (hfβ : MeromorphicAt fβ x) :
min (meromorphicOrderAt fβ x) (meromorphicOrderAt fβ x) β€ meromorphicOrderAt (fβ + fβ) x := by
-- Handle the trivial cases where one of the orders equals β€
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· rw [hβfβ, min_top_left, meromorphicOrderAt_congr]
filter_upwards [meromorphicOrderAt_eq_top_iff.1 hβfβ]
simp
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· simp only [hβfβ, le_top, inf_of_le_left]
rw [meromorphicOrderAt_congr]
filter_upwards [meromorphicOrderAt_eq_top_iff.1 hβfβ]
simp
-- General case
lift meromorphicOrderAt fβ x to β€ using hβfβ with nβ hnβ
lift meromorphicOrderAt fβ x to β€ using hβfβ with nβ hnβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
let n := min nβ nβ
let g := (fun z β¦ (z - x) ^ (nβ - n)) β’ gβ + (fun z β¦ (z - x) ^ (nβ - n)) β’ gβ
have hβg : AnalyticAt π g x := by
apply AnalyticAt.add
Β· apply (AnalyticAt.zpow_nonneg (by fun_prop) (sub_nonneg.2 (min_le_left nβ nβ))).smul hβgβ
apply (AnalyticAt.zpow_nonneg (by fun_prop) (sub_nonneg.2 (min_le_right nβ nβ))).smul hβgβ
have : fβ + fβ =αΆ [π[β ] x] ((Β· - x) ^ n) β’ g := by
filter_upwards [hβgβ, hβgβ, self_mem_nhdsWithin]
simp_all [g, β smul_assoc, β zpow_add', sub_ne_zero]
have tβ : MeromorphicAt ((Β· - x) ^ n) x := by fun_prop
have tβ : meromorphicOrderAt ((Β· - x) ^ n) x = n :=
(meromorphicOrderAt_eq_int_iff tβ).2 β¨1, analyticAt_const, by simpβ©
rw [meromorphicOrderAt_congr this, meromorphicOrderAt_smul tβ hβg.meromorphicAt, tβ]
exact le_add_of_nonneg_right hβg.meromorphicOrderAt_nonneg
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_add := meromorphicOrderAt_add
/--
Helper lemma for meromorphicOrderAt_add_of_ne.
-/
lemma meromorphicOrderAt_add_eq_left_of_lt (hfβ : MeromorphicAt fβ x)
(h : meromorphicOrderAt fβ x < meromorphicOrderAt fβ x) :
meromorphicOrderAt (fβ + fβ) x = meromorphicOrderAt fβ x := by
by_cases hfβ : MeromorphicAt fβ x; swap
Β· have : Β¬ (MeromorphicAt (fβ + fβ) x) := by
contrapose! hfβ
simpa using hfβ.sub hfβ
simp [this, hfβ]
-- Trivial case: fβ vanishes identically around zβ
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· rw [meromorphicOrderAt_congr]
filter_upwards [meromorphicOrderAt_eq_top_iff.1 hβfβ]
simp
-- General case
lift meromorphicOrderAt fβ x to β€ using hβfβ with nβ hnβ
lift meromorphicOrderAt fβ x to β€ using h.ne_top with nβ hnβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
rw [meromorphicOrderAt_eq_int_iff (hfβ.add hfβ)]
refine β¨gβ + (Β· - x) ^ (nβ - nβ) β’ gβ, ?_, ?_, ?_β©
Β· apply hβgβ.add (AnalyticAt.smul _ hβgβ)
apply AnalyticAt.zpow_nonneg (by fun_prop)
(sub_nonneg.2 (le_of_lt (WithTop.coe_lt_coe.1 h)))
Β· simpa [zero_zpow _ <| sub_ne_zero.mpr (WithTop.coe_lt_coe.1 h).ne']
Β· filter_upwards [hβgβ, hβgβ, self_mem_nhdsWithin]
simp_all [smul_add, β smul_assoc, β zpow_add', sub_ne_zero]
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_add_of_order_lt_order := meromorphicOrderAt_add_eq_left_of_lt
/--
Helper lemma for meromorphicOrderAt_add_of_ne.
-/
lemma meromorphicOrderAt_add_eq_right_of_lt (hfβ : MeromorphicAt fβ x)
(h : meromorphicOrderAt fβ x < meromorphicOrderAt fβ x) :
meromorphicOrderAt (fβ + fβ) x = meromorphicOrderAt fβ x := by
rw [add_comm]
exact meromorphicOrderAt_add_eq_left_of_lt hfβ h
/--
If two meromorphic functions have unequal orders, then the order of their sum is
exactly the minimum of the orders of the summands.
-/
theorem meromorphicOrderAt_add_of_ne
(hfβ : MeromorphicAt fβ x) (hfβ : MeromorphicAt fβ x)
(h : meromorphicOrderAt fβ x β meromorphicOrderAt fβ x) :
meromorphicOrderAt (fβ + fβ) x = min (meromorphicOrderAt fβ x) (meromorphicOrderAt fβ x) := by
rcases lt_or_lt_iff_ne.mpr h with h | h
Β· simpa [h.le] using meromorphicOrderAt_add_eq_left_of_lt hfβ h
Β· simpa [h.le] using meromorphicOrderAt_add_eq_right_of_lt hfβ h
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.order_add_of_order_ne := meromorphicOrderAt_add_of_ne
@[deprecated (since := "2025-04-27")]
alias MeromorphicAt.meromorphicOrderAt_add_of_unequal_order := meromorphicOrderAt_add_of_ne
/-!
## Level Sets of the Order Function
-/
namespace MeromorphicOn
variable {U : Set π}
/-- The set where a meromorphic function has infinite order is clopen in its domain of meromorphy.
-/
theorem isClopen_setOf_meromorphicOrderAt_eq_top (hf : MeromorphicOn f U) :
IsClopen { u : U | meromorphicOrderAt f u = β€ } := by
constructor
Β· rw [β isOpen_compl_iff, isOpen_iff_forall_mem_open]
intro z hz
rcases (hf z.1 z.2).eventually_eq_zero_or_eventually_ne_zero with h | h
Β· -- Case: f is locally zero in a punctured neighborhood of z
rw [β meromorphicOrderAt_eq_top_iff] at h
tauto
Β· -- Case: f is locally nonzero in a punctured neighborhood of z
obtain β¨t', hβt', hβt', hβt'β© := eventually_nhds_iff.1 (eventually_nhdsWithin_iff.1 h)
use Subtype.val β»ΒΉ' t'
constructor
Β· intro w hw
simp only [mem_compl_iff, mem_setOf_eq]
by_cases hβw : w = z
Β· rwa [hβw]
Β· rw [meromorphicOrderAt_eq_top_iff, not_eventually]
apply Filter.Eventually.frequently
rw [eventually_nhdsWithin_iff, eventually_nhds_iff]
use t' \ {z.1}, fun y hβy hβy β¦ hβt' y hβy.1 hβy.2, hβt'.sdiff isClosed_singleton, hw,
mem_singleton_iff.not.2 (Subtype.coe_ne_coe.mpr hβw)
Β· exact β¨isOpen_induced hβt', hβt'β©
Β· apply isOpen_iff_forall_mem_open.mpr
intro z hz
conv =>
arg 1; intro; left; right; arg 1; intro
rw [meromorphicOrderAt_eq_top_iff, eventually_nhdsWithin_iff, eventually_nhds_iff]
simp only [mem_setOf_eq] at hz
rw [meromorphicOrderAt_eq_top_iff, eventually_nhdsWithin_iff, eventually_nhds_iff] at hz
obtain β¨t', hβt', hβt', hβt'β© := hz
use Subtype.val β»ΒΉ' t'
simp only [mem_compl_iff, mem_singleton_iff, isOpen_induced hβt', mem_preimage,
hβt', and_self, and_true]
intro w hw
simp only [mem_setOf_eq]
-- Trivial case: w = z
by_cases hβw : w = z
Β· rw [hβw]
tauto
-- Nontrivial case: w β z
use t' \ {z.1}, fun y hβy _ β¦ hβt' y (mem_of_mem_diff hβy) (mem_of_mem_inter_right hβy)
constructor
Β· exact hβt'.sdiff isClosed_singleton
Β· apply (mem_diff w).1
exact β¨hw, mem_singleton_iff.not.1 (Subtype.coe_ne_coe.2 hβw)β©
@[deprecated (since := "2025-04-27")]
alias isClopen_setOf_order_eq_top := isClopen_setOf_meromorphicOrderAt_eq_top
/-- On a connected set, there exists a point where a meromorphic function `f` has finite order iff
`f` has finite order at every point. -/
theorem exists_meromorphicOrderAt_ne_top_iff_forall (hf : MeromorphicOn f U) (hU : IsConnected U) :
(β u : U, meromorphicOrderAt f u β β€) β (β u : U, meromorphicOrderAt f u β β€) := by
constructor
Β· intro hβf
have := isPreconnected_iff_preconnectedSpace.1 hU.isPreconnected
rcases isClopen_iff.1 hf.isClopen_setOf_meromorphicOrderAt_eq_top with h | h
Β· intro u
have : u β (β
: Set U) := by exact fun a => a
rw [β h] at this
tauto
Β· obtain β¨u, hUβ© := hβf
have : u β univ := by trivial
rw [β h] at this
tauto
Β· intro hβf
obtain β¨v, hvβ© := hU.nonempty
use β¨v, hvβ©, hβf β¨v, hvβ©
@[deprecated (since := "2025-04-27")]
alias exists_order_ne_top_iff_forall := exists_meromorphicOrderAt_ne_top_iff_forall
/-- On a preconnected set, a meromorphic function has finite order at one point if it has finite
order at another point. -/
theorem meromorphicOrderAt_ne_top_of_isPreconnected (hf : MeromorphicOn f U) {y : π}
(hU : IsPreconnected U) (hβx : x β U) (hy : y β U) (hβx : meromorphicOrderAt f x β β€) :
meromorphicOrderAt f y β β€ :=
(hf.exists_meromorphicOrderAt_ne_top_iff_forall β¨nonempty_of_mem hβx, hUβ©).1
(by use β¨x, hβxβ©) β¨y, hyβ©
@[deprecated (since := "2025-04-27")]
alias order_ne_top_of_isPreconnected := meromorphicOrderAt_ne_top_of_isPreconnected
/-- If a function is meromorphic on a set `U`, then for each point in `U`, it is analytic at nearby
points in `U`. When the target space is complete, this can be strengthened to analyticity at all
nearby points, see `MeromorphicAt.eventually_analyticAt`. -/
theorem eventually_analyticAt (h : MeromorphicOn f U) (hx : x β U) :
βαΆ y in π[U \ {x}] x, AnalyticAt π f y := by
/- At neighboring points in `U`, the function `f` is both meromorphic (by meromorphicity on `U`)
and continuous (thanks to the formula for a meromorphic function around the point `x`), so it is
analytic. -/
have : βαΆ y in π[U \ {x}] x, ContinuousAt f y := by
have : U \ {x} β {x}αΆ := by simp
exact nhdsWithin_mono _ this (h x hx).eventually_continuousAt
filter_upwards [this, self_mem_nhdsWithin] with y hy h'y
exact (h y h'y.1).analyticAt hy
theorem eventually_analyticAt_or_mem_compl (h : MeromorphicOn f U) (hx : x β U) :
βαΆ y in π[β ] x, AnalyticAt π f y β¨ y β UαΆ := by
have : {x}αΆ = (U \ {x}) βͺ UαΆ := by aesop (add simp Classical.em)
rw [this, nhdsWithin_union]
simp only [mem_compl_iff, eventually_sup]
refine β¨?_, ?_β©
Β· filter_upwards [h.eventually_analyticAt hx] with y hy using Or.inl hy
Β· filter_upwards [self_mem_nhdsWithin] with y hy using Or.inr hy
/-- Meromorphic functions on `U` are analytic on `U`, outside of a discrete subset. -/
theorem analyticAt_mem_codiscreteWithin (hf : MeromorphicOn f U) :
{ x | AnalyticAt π f x } β Filter.codiscreteWithin U := by
rw [mem_codiscreteWithin]
intro x hx
rw [Filter.disjoint_principal_right, β Filter.eventually_mem_set]
filter_upwards [hf.eventually_analyticAt_or_mem_compl hx] with y hy
simp
tauto
/-- The set where a meromorphic function has zero or infinite
order is codiscrete within its domain of meromorphicity. -/
theorem codiscrete_setOf_meromorphicOrderAt_eq_zero_or_top (hf : MeromorphicOn f U) :
{u : U | meromorphicOrderAt f u = 0 β¨ meromorphicOrderAt f u = β€} β Filter.codiscrete U := by
rw [mem_codiscrete_subtype_iff_mem_codiscreteWithin, mem_codiscreteWithin]
intro x hx
rw [Filter.disjoint_principal_right]
rcases (hf x hx).eventually_eq_zero_or_eventually_ne_zero with hβf | hβf
Β· filter_upwards [eventually_eventually_nhdsWithin.2 hβf] with a hβa
suffices βαΆ (z : π) in π[β ] a, f z = 0 by
simp +contextual [meromorphicOrderAt_eq_top_iff, this]
obtain rfl | hax := eq_or_ne a x
Β· exact hβa
rw [eventually_nhdsWithin_iff, eventually_nhds_iff] at hβa β’
obtain β¨t, hβt, hβt, hβtβ© := hβa
use t \ {x}, fun y hβy _ β¦ hβt y hβy.1 hβy.2
exact β¨hβt.sdiff isClosed_singleton, Set.mem_diff_of_mem hβt haxβ©
Β· filter_upwards [hf.eventually_analyticAt_or_mem_compl hx, hβf] with a hβa h'βa
simp only [mem_compl_iff, mem_diff, mem_image, mem_setOf_eq, Subtype.exists, exists_and_right,
exists_eq_right, not_exists, not_or, not_and, not_forall, Decidable.not_not]
rcases hβa with h' | h'
Β· simp +contextual [h'.meromorphicOrderAt_eq, h'.analyticOrderAt_eq_zero.2, h'βa]
Β· exact fun ha β¦ (h' ha).elim
@[deprecated (since := "2025-04-27")]
alias codiscrete_setOf_order_eq_zero_or_top := codiscrete_setOf_meromorphicOrderAt_eq_zero_or_top
end MeromorphicOn
lemma MeromorphicAt.comp_analyticAt {g : π β π}
(hf : MeromorphicAt f (g x)) (hg : AnalyticAt π g x) : MeromorphicAt (f β g) x := by
obtain β¨r, hrβ© := hf
by_cases hg' : analyticOrderAt (g Β· - g x) x = β€
Β· -- trivial case: `g` is locally constant near `x`
refine .congr (.const (f (g x)) x) ?_
filter_upwards [nhdsWithin_le_nhds <| analyticOrderAt_eq_top.mp hg'] with z hz
grind
Β· -- interesting case: `g z - g x` looks like `(z - x) ^ n` times a non-vanishing function
obtain β¨n, hnβ© := WithTop.ne_top_iff_exists.mp hg'
obtain β¨h, han, hne, heqβ© := (hg.fun_sub analyticAt_const).analyticOrderAt_eq_natCast.mp hn.symm
set j := fun z β¦ (z - g x) ^ r β’ f z
have : AnalyticAt π (fun z β¦ (h z)β»ΒΉ ^ r β’ j (g z)) x := by fun_prop (disch := assumption)
refine β¨n * r, this.congr ?_β©
filter_upwards [heq, han.continuousAt.tendsto.eventually_ne hne] with z hz hzne
simp only [inv_pow, Function.comp_apply, inv_smul_eq_iffβ (pow_ne_zero r hzne)]
rw [β mul_smul (h z ^ r), mul_comm, pow_mul, β mul_pow, β smul_eq_mul, β hz] |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/NormalForm.lean | import Mathlib.Analysis.Meromorphic.Divisor
/-!
# Normal form of meromorphic functions and continuous extension
If a function `f` is meromorphic on `U` and if `g` differs from `f` only along a set that is
codiscrete within `U`, then `g` is likewise meromorphic. The set of meromorphic functions is
therefore huge, and `=αΆ [codiscreteWithin U]` defines an equivalence relation.
This file implements continuous extension to provide an API that allows picking the 'unique best'
representative of any given equivalence class, where 'best' means that the representative can
locally near any point `x` be written 'in normal form', as `f =αΆ [π x] fun z β¦ (z - x) ^ n β’ g`
where `g` is analytic and does not vanish at `x`.
The relevant notions are `MeromorphicNFAt` and `MeromorphicNFOn`; these guarantee normal
form at a single point and along a set, respectively.
-/
open Topology WithTop
variable
{π : Type*} [NontriviallyNormedField π]
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
{f : π β E} {g : π β π}
{x : π}
{U : Set π}
/-!
## Normal form of meromorphic functions at a given point
### Definition and characterizations
-/
variable (f x) in
/-- A function is 'meromorphic in normal form' at `x` if it vanishes around `x`
or if it can locally be written as `fun z β¦ (z - x) ^ n β’ g` where `g` is
analytic and does not vanish at `x`. -/
def MeromorphicNFAt :=
f =αΆ [π x] 0 β¨
β (n : β€) (g : π β E), AnalyticAt π g x β§ g x β 0 β§ f =αΆ [π x] (Β· - x) ^ n β’ g
/-- A meromorphic function has normal form at `x` iff it is either analytic
there, or if it has a pole at `x` and takes the default value `0`. -/
theorem meromorphicNFAt_iff_analyticAt_or :
MeromorphicNFAt f x β
AnalyticAt π f x β¨ (MeromorphicAt f x β§ meromorphicOrderAt f x < 0 β§ f x = 0) := by
constructor
Β· rintro (h | β¨n, g, hβg, hβg, hβgβ©)
Β· simp [(analyticAt_congr h).2 analyticAt_const]
Β· have hf : MeromorphicAt f x := by
apply MeromorphicAt.congr _ (hβg.filter_mono nhdsWithin_le_nhds).symm
fun_prop
have : meromorphicOrderAt f x = n := by
rw [meromorphicOrderAt_eq_int_iff hf]
use g, hβg, hβg
exact eventually_nhdsWithin_of_eventually_nhds hβg
by_cases! hn : 0 β€ n
Β· left
rw [analyticAt_congr hβg]
apply (AnalyticAt.zpow_nonneg (by fun_prop) hn).smul hβg
Β· right
use hf
simp [this, WithTop.coe_lt_zero.2 hn, hβg.eq_of_nhds,
zero_zpow n hn.ne]
Β· rintro (h | β¨hβ, hβ, hββ©)
Β· by_cases hβf : analyticOrderAt f x = β€
Β· rw [analyticOrderAt_eq_top] at hβf
tauto
Β· right
use analyticOrderNatAt f x
have : analyticOrderAt f x β β€ := hβf
rw [β ENat.coe_toNat_eq_self, eq_comm, h.analyticOrderAt_eq_natCast] at this
obtain β¨g, hβg, hβg, hβgβ© := this
use g, hβg, hβg
simpa
Β· right
lift meromorphicOrderAt f x to β€ using LT.lt.ne_top hβ with n hn
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_eq_int_iff hβ).1 hn.symm
use n, g, hβg, hβg
filter_upwards [eventually_nhdsWithin_iff.1 hβg]
intro z hz
by_cases hβz : z = x
Β· simp only [hβz, Pi.smul_apply', Pi.pow_apply, sub_self]
rw [hβ]
apply (smul_eq_zero_of_left (zero_zpow n _) (g x)).symm
by_contra hCon
simp [hCon] at hβ
Β· exact hz hβz
/-!
### Relation to other properties of functions
-/
/-- If a function is meromorphic in normal form at `x`, then it is meromorphic at `x`. -/
theorem MeromorphicNFAt.meromorphicAt (hf : MeromorphicNFAt f x) :
MeromorphicAt f x := by
rw [meromorphicNFAt_iff_analyticAt_or] at hf
rcases hf with h | h
Β· exact h.meromorphicAt
Β· obtain β¨hf, _β© := h
exact hf
/-- If a function is meromorphic in normal form at `x`, then it has non-negative order iff it is
analytic. -/
theorem MeromorphicNFAt.meromorphicOrderAt_nonneg_iff_analyticAt (hf : MeromorphicNFAt f x) :
0 β€ meromorphicOrderAt f x β AnalyticAt π f x := by
constructor <;> intro hβf
Β· rw [meromorphicNFAt_iff_analyticAt_or] at hf
rcases hf with h | β¨_, hβf, _β©
Β· exact h
Β· by_contra h'
exact lt_irrefl 0 (lt_of_le_of_lt hβf hβf)
Β· rw [hβf.meromorphicOrderAt_eq]
simp
@[deprecated (since := "2025-05-22")] alias MeromorphicNFAt.order_nonneg_iff_analyticAt :=
MeromorphicNFAt.meromorphicOrderAt_nonneg_iff_analyticAt
/-- Analytic functions are meromorphic in normal form. -/
theorem AnalyticAt.meromorphicNFAt (hf : AnalyticAt π f x) :
MeromorphicNFAt f x := by
simp [meromorphicNFAt_iff_analyticAt_or, hf]
/-- Meromorphic functions have normal form outside of a discrete subset in the domain of
meromorphicity. -/
theorem MeromorphicOn.meromorphicNFAt_mem_codiscreteWithin {U : Set π}
(hf : MeromorphicOn f U) :
{ x | MeromorphicNFAt f x } β Filter.codiscreteWithin U := by
filter_upwards [hf.analyticAt_mem_codiscreteWithin] with _ ha
exact ha.meromorphicNFAt
/-!
### Vanishing and order
-/
/-- If `f` is meromorphic in normal form at `x`, then `f` has order zero iff it does not vanish at
`x`.
See `AnalyticAt.order_eq_zero_iff` for an analogous statement about analytic functions. -/
theorem MeromorphicNFAt.meromorphicOrderAt_eq_zero_iff (hf : MeromorphicNFAt f x) :
meromorphicOrderAt f x = 0 β f x β 0 := by
constructor
Β· intro hβf
have hβf := hf.meromorphicOrderAt_nonneg_iff_analyticAt.1 (le_of_eq hβf.symm)
rw [β hβf.analyticOrderAt_eq_zero, β ENat.map_natCast_eq_zero (Ξ± := β€)]
rwa [hβf.meromorphicOrderAt_eq] at hβf
Β· intro h
rcases id hf with hβ | β¨n, g, hβg, hβg, hβgβ©
Β· have := hβ.eq_of_nhds
tauto
Β· have : n = 0 := by
by_contra hContra
have := hβg.eq_of_nhds
simp only [Pi.smul_apply', Pi.pow_apply, sub_self, zero_zpow n hContra, zero_smul] at this
tauto
simp only [this, zpow_zero] at hβg
apply (meromorphicOrderAt_eq_int_iff hf.meromorphicAt).2
use g, hβg, hβg
simp only [zpow_zero]
exact hβg.filter_mono nhdsWithin_le_nhds
@[deprecated (since := "2025-05-22")] alias MeromorphicNFAt.order_eq_zero_iff :=
MeromorphicNFAt.meromorphicOrderAt_eq_zero_iff
/-!
### Local nature of the definition and local identity theorem
-/
/-- **Local identity theorem**: two meromorphic functions in normal form agree in a
neighborhood iff they agree in a pointed neighborhood.
See `ContinuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE` for the analogous
statement for continuous functions.
-/
theorem MeromorphicNFAt.eventuallyEq_nhdsNE_iff_eventuallyEq_nhds {g : π β E}
(hf : MeromorphicNFAt f x) (hg : MeromorphicNFAt g x) :
f =αΆ [π[β ] x] g β f =αΆ [π x] g := by
constructor
Β· intro h
have tβ := meromorphicOrderAt_congr h
by_cases cs : meromorphicOrderAt f x = 0
Β· rw [cs] at tβ
have Z := (hf.meromorphicOrderAt_nonneg_iff_analyticAt.1 (le_of_eq cs.symm)).continuousAt
have W := (hg.meromorphicOrderAt_nonneg_iff_analyticAt.1 (le_of_eq tβ)).continuousAt
exact (Z.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE W).1 h
Β· apply eventuallyEq_nhds_of_eventuallyEq_nhdsNE h
let hβf := cs
rw [hf.meromorphicOrderAt_eq_zero_iff] at hβf
let hβg := cs
rw [tβ, hg.meromorphicOrderAt_eq_zero_iff] at hβg
simp only [not_not] at *
rw [hβf, hβg]
Β· exact (Filter.EventuallyEq.filter_mono Β· nhdsWithin_le_nhds)
@[deprecated (since := "2025-05-22")]
alias MeromorphicNFAt.eventuallyEq_nhdNE_iff_eventuallyEq_nhd :=
MeromorphicNFAt.eventuallyEq_nhdsNE_iff_eventuallyEq_nhds
/-- Meromorphicity in normal form is a local property. -/
theorem meromorphicNFAt_congr {g : π β E} (hfg : f =αΆ [π x] g) :
MeromorphicNFAt f x β MeromorphicNFAt g x := by
constructor
Β· rintro (h | β¨n, h, hβh, hβh, hβhβ©)
Β· exact .inl (hfg.symm.trans h)
Β· exact .inr β¨n, h, hβh, hβh, hfg.symm.trans hβhβ©
Β· rintro (h | β¨n, h, hβh, hβh, hβhβ©)
Β· exact .inl (hfg.trans h)
Β· exact .inr β¨n, h, hβh, hβh, hfg.trans hβhβ©
/-!
### Criteria to guarantee normal form
-/
/-- Helper lemma for `meromorphicNFAt_iff_meromorphicNFAt_of_smul_analytic`: if
`f` is meromorphic in normal form at `x` and `g` is analytic without zero at
`x`, then `g β’ f` is meromorphic in normal form at `x`. -/
lemma MeromorphicNFAt.smul_analytic (hf : MeromorphicNFAt f x)
(hβg : AnalyticAt π g x) (hβg : g x β 0) :
MeromorphicNFAt (g β’ f) x := by
rcases hf with hβf | β¨n, g_f, hβg_f, hβg_f, hβg_fβ©
Β· left
filter_upwards [hβf]
simp_all
Β· right
use n, g β’ g_f, hβg.smul hβg_f
constructor
Β· simp [smul_ne_zero hβg hβg_f]
Β· filter_upwards [hβg_f]
intro y hy
simp only [Pi.smul_apply', hy, Pi.pow_apply]
rw [smul_comm]
/-- If `f` is any function and `g` is analytic without zero at `zβ`, then `f` is meromorphic in
normal form at `zβ` iff `g β’ f` is meromorphic in normal form at `zβ`. -/
theorem meromorphicNFAt_smul_iff_right_of_analyticAt (hβg : AnalyticAt π g x)
(hβg : g x β 0) :
MeromorphicNFAt (g β’ f) x β MeromorphicNFAt f x where
mp hprod := by
have : f =αΆ [π x] gβ»ΒΉ β’ g β’ f := by
filter_upwards [hβg.continuousAt.preimage_mem_nhds (compl_singleton_mem_nhds_iff.mpr hβg)]
intro y hy
rw [Set.preimage_compl, Set.mem_compl_iff, Set.mem_preimage,
Set.mem_singleton_iff] at hy
simp [hy]
rw [meromorphicNFAt_congr this]
exact hprod.smul_analytic (hβg.inv hβg) (inv_ne_zero hβg)
mpr hf := hf.smul_analytic hβg hβg
/-- If `f` is any function and `g` is analytic without zero at `zβ`, then `f` is meromorphic in
normal form at `zβ` iff `g * f` is meromorphic in normal form at `zβ`. -/
theorem meromorphicNFAt_mul_iff_right {f : π β π} (hβg : AnalyticAt π g x)
(hβg : g x β 0) :
MeromorphicNFAt (g * f) x β MeromorphicNFAt f x :=
meromorphicNFAt_smul_iff_right_of_analyticAt hβg hβg
/-- If `f` is any function and `g` is analytic without zero at `zβ`, then `f` is meromorphic in
normal form at `zβ` iff `f * g` is meromorphic in normal form at `zβ`. -/
theorem meromorphicNFAt_mul_iff_left {f : π β π} (hβg : AnalyticAt π g x)
(hβg : g x β 0) :
MeromorphicNFAt (f * g) x β MeromorphicNFAt f x := by
rw [mul_comm, β smul_eq_mul]
exact meromorphicNFAt_smul_iff_right_of_analyticAt hβg hβg
/-!
### Continuous extension and conversion to normal form
-/
variable (f x) in
/-- If `f` is meromorphic at `x`, convert `f` to normal form at `x` by changing its value at `x`.
Otherwise, returns the 0 function. -/
noncomputable def toMeromorphicNFAt :
π β E := by
by_cases hf : MeromorphicAt f x
Β· classical -- do not complain about decidability issues in Function.update
apply Function.update f x
by_cases hβf : meromorphicOrderAt f x = (0 : β€)
Β· rw [meromorphicOrderAt_eq_int_iff hf] at hβf
exact (Classical.choose hβf) x
Β· exact 0
Β· exact 0
/-- Conversion to normal form at `x` changes the value only at x. -/
lemma MeromorphicAt.eqOn_compl_singleton_toMeromorphicNFAt (hf : MeromorphicAt f x) :
Set.EqOn f (toMeromorphicNFAt f x) {x}αΆ :=
fun _ _ β¦ by simp_all [toMeromorphicNFAt]
@[deprecated (since := "2025-07-27")]
alias MeromorphicAt.eqOn_compl_singleton_toMermomorphicNFAt :=
MeromorphicAt.eqOn_compl_singleton_toMeromorphicNFAt
/-- If `f` is not meromorphic, conversion to normal form at `x` maps the function to `0`. -/
@[simp] lemma toMeromorphicNFAt_of_not_meromorphicAt (hf : Β¬MeromorphicAt f x) :
toMeromorphicNFAt f x = 0 := by
simp [toMeromorphicNFAt, hf]
/-- Conversion to normal form at `x` changes the value only at x. -/
lemma MeromorphicAt.eq_nhdsNE_toMeromorphicNFAt (hf : MeromorphicAt f x) :
f =αΆ [π[β ] x] toMeromorphicNFAt f x :=
eventually_nhdsWithin_of_forall (fun _ hz β¦ hf.eqOn_compl_singleton_toMeromorphicNFAt hz)
@[deprecated (since := "2025-05-22")]
alias MeromorphicAt.eq_nhdNE_toMeromorphicNFAt := MeromorphicAt.eq_nhdsNE_toMeromorphicNFAt
/-- After conversion to normal form at `x`, the function has normal form. -/
theorem meromorphicNFAt_toMeromorphicNFAt :
MeromorphicNFAt (toMeromorphicNFAt f x) x := by
by_cases hf : MeromorphicAt f x
Β· by_cases hβf : meromorphicOrderAt f x = β€
Β· have : toMeromorphicNFAt f x =αΆ [π x] 0 := by
apply eventuallyEq_nhds_of_eventuallyEq_nhdsNE
Β· exact hf.eq_nhdsNE_toMeromorphicNFAt.symm.trans (meromorphicOrderAt_eq_top_iff.1 hβf)
Β· simp [hβf, toMeromorphicNFAt, hf]
apply AnalyticAt.meromorphicNFAt
rw [analyticAt_congr this]
exact analyticAt_const
Β· lift meromorphicOrderAt f x to β€ using hβf with n hn
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_eq_int_iff hf).1 hn.symm
right
use n, g, hβg, hβg
apply eventuallyEq_nhds_of_eventuallyEq_nhdsNE (hf.eq_nhdsNE_toMeromorphicNFAt.symm.trans hβg)
simp only [toMeromorphicNFAt, hf, βreduceDIte, β hn, WithTop.coe_zero,
WithTop.coe_eq_zero, ne_eq, Function.update_self, sub_self]
split_ifs with hβf
Β· obtain β¨hβG, _, hβGβ© :=
Classical.choose_spec ((meromorphicOrderAt_eq_int_iff hf).1 (hβf βΈ hn.symm))
apply Filter.EventuallyEq.eq_of_nhds
apply (hβG.continuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE (by fun_prop)).1
filter_upwards [hβg, hβG]
simp_all
Β· simp [hβf, zero_zpow]
Β· simp only [toMeromorphicNFAt, hf, βreduceDIte]
exact analyticAt_const.meromorphicNFAt
/-- If `f` has normal form at `x`, then `f` equals `f.toNF`. -/
@[simp] theorem toMeromorphicNFAt_eq_self :
toMeromorphicNFAt f x = f β MeromorphicNFAt f x where
mp hf := by
rw [hf.symm]
exact meromorphicNFAt_toMeromorphicNFAt
mpr hf := by
funext z
by_cases hz : z = x
Β· rw [hz]
simp only [toMeromorphicNFAt, hf.meromorphicAt, WithTop.coe_zero, ne_eq]
have hβf := hf
rcases hf with hβf | hβf
Β· simpa [meromorphicOrderAt_eq_top_iff.2 (hβf.filter_mono nhdsWithin_le_nhds)]
using hβf.eq_of_nhds.symm
Β· obtain β¨n, g, hβg, hβg, hβgβ© := hβf
rw [Filter.EventuallyEq.eq_of_nhds hβg]
have : meromorphicOrderAt f x = n := by
rw [meromorphicOrderAt_eq_int_iff hβf.meromorphicAt]
use g, hβg, hβg
exact eventually_nhdsWithin_of_eventually_nhds hβg
by_cases hβf : meromorphicOrderAt f x = 0
Β· simp only [Pi.smul_apply', Pi.pow_apply, sub_self, hβf, βreduceDIte]
have hn : n = (0 : β€) := by
rw [hβf] at this
exact WithTop.coe_eq_zero.mp this.symm
simp_rw [hn]
simp only [zpow_zero, one_smul]
have : g =αΆ [π x]
Classical.choose ((meromorphicOrderAt_eq_int_iff hβf.meromorphicAt).1 hβf) := by
obtain β¨hβ, hβ, hββ© := Classical.choose_spec
((meromorphicOrderAt_eq_int_iff hβf.meromorphicAt).1 hβf)
rw [β hβg.continuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE hβ.continuousAt]
rw [hn] at hβg
simp only [zpow_zero, one_smul, ne_eq] at hβg hβ
exact (hβg.filter_mono nhdsWithin_le_nhds).symm.trans hβ
simp only [Function.update_self]
exact Filter.EventuallyEq.eq_of_nhds this.symm
Β· rw [eq_comm]
simp only [Pi.smul_apply', Pi.pow_apply, sub_self, hβf, βreduceDIte, smul_eq_zero,
Function.update_self, smul_eq_zero]
left
apply zero_zpow n
by_contra hn
rw [hn] at this
tauto
Β· exact (hf.meromorphicAt.eqOn_compl_singleton_toMeromorphicNFAt hz).symm
/--
If `f` is meromorphic in normal form, then so is its inverse.
-/
theorem MeromorphicNFAt.inv {f : π β π} (hf : MeromorphicNFAt f x) :
MeromorphicNFAt fβ»ΒΉ x := by
rcases hf with h | β¨n, g, hβ, hβ, hββ©
Β· left
filter_upwards [h] with x hx
simp [hx]
Β· right
use -n, gβ»ΒΉ, hβ.inv hβ, (by simp_all)
filter_upwards [hβ] with y hy
simp only [Pi.inv_apply, hy, Pi.smul_apply', Pi.pow_apply, smul_eq_mul, mul_inv_rev, zpow_neg]
ring
/--
A function to π is meromorphic in normal form at a point iff its inverse is.
-/
@[simp] theorem meromorphicNFAt_inv {f : π β π} : MeromorphicNFAt fβ»ΒΉ x β MeromorphicNFAt f x where
mp := by
nth_rw 2 [β inv_inv f]
exact .inv
mpr hf := by simpa using hf.inv
/-!
## Normal form of meromorphic functions on a given set
### Definition
-/
/--
A function is 'meromorphic in normal form' on `U` if has normal form at every
point of `U`.
-/
def MeromorphicNFOn (f : π β E) (U : Set π) := β β¦zβ¦, z β U β MeromorphicNFAt f z
/-!
### Relation to other properties of functions
-/
/--
If a function is meromorphic in normal form on `U`, then it is meromorphic on
`U`.
-/
theorem MeromorphicNFOn.meromorphicOn (hf : MeromorphicNFOn f U) :
MeromorphicOn f U := fun _ hz β¦ (hf hz).meromorphicAt
/--
If a function is meromorphic in normal form on `U`, then its divisor is
non-negative iff it is analytic.
-/
theorem MeromorphicNFOn.divisor_nonneg_iff_analyticOnNhd
(hβf : MeromorphicNFOn f U) :
0 β€ MeromorphicOn.divisor f U β AnalyticOnNhd π f U := by
constructor <;> intro h x
Β· intro hx
rw [β (hβf hx).meromorphicOrderAt_nonneg_iff_analyticAt]
have := h x
simp only [Function.locallyFinsuppWithin.coe_zero, Pi.zero_apply, hβf.meromorphicOn, hx,
MeromorphicOn.divisor_apply, untopβ_nonneg] at this
assumption
Β· by_cases hx : x β U
Β· simp only [Function.locallyFinsuppWithin.coe_zero, Pi.zero_apply, hβf.meromorphicOn, hx,
MeromorphicOn.divisor_apply, untopβ_nonneg]
exact (hβf hx).meromorphicOrderAt_nonneg_iff_analyticAt.2 (h x hx)
Β· simp [hx]
/-- Analytic functions are meromorphic in normal form. -/
theorem AnalyticOnNhd.meromorphicNFOn (hβf : AnalyticOnNhd π f U) :
MeromorphicNFOn f U := fun z hz β¦ (hβf z hz).meromorphicNFAt
/-!
### Divisors and zeros of meromorphic functions in normal form.
-/
/--
If `f` is meromorphic in normal form on `U` and nowhere locally constant zero,
then its zero set equals the support of the associated divisor.
-/
theorem MeromorphicNFOn.zero_set_eq_divisor_support (hβf : MeromorphicNFOn f U)
(hβf : β u : U, meromorphicOrderAt f u β β€) :
U β© fβ»ΒΉ' {0} = Function.support (MeromorphicOn.divisor f U) := by
ext u
constructor <;> intro hu
Β· simp_all only [ne_eq, Subtype.forall, Set.mem_inter_iff, Set.mem_preimage,
Set.mem_singleton_iff, Function.mem_support, hβf.meromorphicOn, MeromorphicOn.divisor_apply,
WithTop.untopβ_eq_zero, (hβf hu.1).meromorphicOrderAt_eq_zero_iff, not_true_eq_false, or_self,
not_false_eq_true]
Β· simp only [Function.mem_support, ne_eq] at hu
constructor
Β· exact (MeromorphicOn.divisor f U).supportWithinDomain hu
Β· rw [Set.mem_preimage, Set.mem_singleton_iff]
have := hβf ((MeromorphicOn.divisor f U).supportWithinDomain hu)
|>.meromorphicOrderAt_eq_zero_iff.not
simp only [hβf.meromorphicOn, (MeromorphicOn.divisor f U).supportWithinDomain hu,
MeromorphicOn.divisor_apply, WithTop.untopβ_eq_zero, not_or] at hu
simp_all [hu.1]
/-!
### Criteria to guarantee normal form
-/
/--
If `f` is any function and `g` is analytic without zero on `U`, then `f` is
meromorphic in normal form on `U` iff `g β’ f` is meromorphic in normal form on
`U`.
-/
theorem meromorphicNFOn_smul_iff_right_of_analyticOnNhd {g : π β π} (hβg : AnalyticOnNhd π g U)
(hβg : β u β U, g u β 0) :
MeromorphicNFOn (g β’ f) U β MeromorphicNFOn f U := by
constructor <;> intro h z hz
Β· rw [β meromorphicNFAt_smul_iff_right_of_analyticAt (hβg z hz) (hβg z hz)]
exact h hz
Β· apply (h hz).smul_analytic (hβg z hz)
exact hβg z hz
/--
If `f` is any function and `g` is analytic without zero in `U`, then `f` is
meromorphic in normal form on `U` iff `g * f` is meromorphic in normal form on
`U`.
-/
theorem meromorphicNFOn_mul_iff_right_of_analyticOnNhd {f g : π β π} (hβg : AnalyticOnNhd π g U)
(hβg : β u β U, g u β 0) :
MeromorphicNFOn (g * f) U β MeromorphicNFOn f U := by
rw [β smul_eq_mul]
exact meromorphicNFOn_smul_iff_right_of_analyticOnNhd hβg hβg
/--
If `f` is any function and `g` is analytic without zero in `U`, then `f` is
meromorphic in normal form on `U` iff `f * g` is meromorphic in normal form on
`U`.
-/
theorem meromorphicNFOn_mul_iff_left_of_analyticOnNhd {f g : π β π} (hβg : AnalyticOnNhd π g U)
(hβg : β u β U, g u β 0) :
MeromorphicNFOn (f * g) U β MeromorphicNFOn f U := by
rw [mul_comm, β smul_eq_mul]
exact meromorphicNFOn_mul_iff_right_of_analyticOnNhd hβg hβg
/--
A function to π is meromorphic in normal form on `U` iff its inverse is.
-/
theorem meromorphicNFOn_inv {f : π β π} :
MeromorphicNFOn fβ»ΒΉ U β MeromorphicNFOn f U where
mp h _ hx := meromorphicNFAt_inv.1 (h hx)
mpr h _ hx := meromorphicNFAt_inv.2 (h hx)
/-!
### Continuous extension and conversion to normal form
-/
variable (f U) in
/--
If `f` is meromorphic on `U`, convert `f` to normal form on `U` by changing its
values along a discrete subset within `U`. Otherwise, returns the 0 function.
-/
noncomputable def toMeromorphicNFOn :
π β E := by
by_cases hβf : MeromorphicOn f U
Β· intro z
by_cases hz : z β U
Β· exact toMeromorphicNFAt f z z
Β· exact f z
Β· exact 0
/--
If `f` is not meromorphic on `U`, conversion to normal form maps the function
to `0`.
-/
@[simp] lemma toMeromorphicNFOn_of_not_meromorphicOn (hf : Β¬MeromorphicOn f U) :
toMeromorphicNFOn f U = 0 := by
simp [toMeromorphicNFOn, hf]
/--
Conversion to normal form on `U` does not change values outside of `U`.
-/
@[simp] lemma toMeromorphicNFOn_eq_self_on_compl (hf : MeromorphicOn f U) :
Set.EqOn (toMeromorphicNFOn f U) f UαΆ := by
intro x hx
simp_all [toMeromorphicNFOn]
/--
Conversion to normal form on `U` changes the value only along a discrete subset
of `U`.
-/
theorem toMeromorphicNFOn_eqOn_codiscrete (hf : MeromorphicOn f U) :
f =αΆ [Filter.codiscreteWithin U] toMeromorphicNFOn f U := by
have : U β Filter.codiscreteWithin U := by
simp [mem_codiscreteWithin.2]
filter_upwards [hf.analyticAt_mem_codiscreteWithin, this] with a hβa hβa
simp [toMeromorphicNFOn, hf, β (toMeromorphicNFAt_eq_self.2 hβa.meromorphicNFAt).symm]
/--
If `f` is meromorphic on `U` and `x β U`, then `f` and its conversion to normal
form on `U` agree in a punctured neighborhood of `x`.
-/
theorem MeromorphicOn.toMeromorphicNFOn_eq_self_on_nhdsNE
(hf : MeromorphicOn f U) (hx : x β U) :
toMeromorphicNFOn f U =αΆ [π[β ] x] f := by
filter_upwards [hf.eventually_analyticAt_or_mem_compl hx] with a ha
rcases ha with ha | ha
Β· simp [toMeromorphicNFOn, hf, β (toMeromorphicNFAt_eq_self.2 ha.meromorphicNFAt).symm]
Β· simp only [Set.mem_compl_iff] at ha
simp [toMeromorphicNFOn, ha, hf]
@[deprecated (since := "2025-05-22")] alias MeromorphicOn.toMeromorphicNFOn_eq_self_on_nhdNE :=
MeromorphicOn.toMeromorphicNFOn_eq_self_on_nhdsNE
/--
If `f` is meromorphic on `U` and `x β U`, then conversion to normal form at `x`
and conversion to normal form on `U` agree in a neighborhood of `x`.
-/
theorem toMeromorphicNFOn_eq_toMeromorphicNFAt_on_nhds (hf : MeromorphicOn f U)
(hx : x β U) :
toMeromorphicNFOn f U =αΆ [π x] toMeromorphicNFAt f x := by
apply eventuallyEq_nhds_of_eventuallyEq_nhdsNE
Β· exact (hf.toMeromorphicNFOn_eq_self_on_nhdsNE hx).trans (hf x hx).eq_nhdsNE_toMeromorphicNFAt
Β· simp [toMeromorphicNFOn, hf, hx]
@[deprecated (since := "2025-05-22")]
alias toMeromorphicNFOn_eq_toMeromorphicNFAt_on_nhd :=
toMeromorphicNFOn_eq_toMeromorphicNFAt_on_nhds
/--
If `f` is meromorphic on `U` and `x β U`, then conversion to normal form at `x`
and conversion to normal form on `U` agree at `x`.
-/
theorem toMeromorphicNFOn_eq_toMeromorphicNFAt (hf : MeromorphicOn f U)
(hx : x β U) :
toMeromorphicNFOn f U x = toMeromorphicNFAt f x x := by
apply Filter.EventuallyEq.eq_of_nhds (g := toMeromorphicNFAt f x)
simp [(toMeromorphicNFOn_eq_toMeromorphicNFAt_on_nhds hf hx).trans]
variable (f U) in
/--
After conversion to normal form on `U`, the function has normal form.
-/
theorem meromorphicNFOn_toMeromorphicNFOn :
MeromorphicNFOn (toMeromorphicNFOn f U) U := by
by_cases hf : MeromorphicOn f U
Β· intro z hz
rw [meromorphicNFAt_congr (toMeromorphicNFOn_eq_toMeromorphicNFAt_on_nhds hf hz)]
exact meromorphicNFAt_toMeromorphicNFAt
Β· simpa [hf] using analyticOnNhd_const.meromorphicNFOn
/--
If `f` has normal form on `U`, then `f` equals `toMeromorphicNFOn f U`.
-/
@[simp] theorem toMeromorphicNFOn_eq_self :
toMeromorphicNFOn f U = f β MeromorphicNFOn f U := by
constructor <;> intro h
Β· rw [h.symm]
apply meromorphicNFOn_toMeromorphicNFOn
Β· ext x
by_cases hx : x β U
Β· simp only [toMeromorphicNFOn, h.meromorphicOn, βreduceDIte, hx]
rw [toMeromorphicNFAt_eq_self.2 (h hx)]
Β· simp [toMeromorphicNFOn, h.meromorphicOn, hx]
/--
Conversion of normal form does not affect orders.
-/
@[simp] theorem meromorphicOrderAt_toMeromorphicNFOn (hf : MeromorphicOn f U) (hx : x β U) :
meromorphicOrderAt (toMeromorphicNFOn f U) x = meromorphicOrderAt f x := by
apply meromorphicOrderAt_congr
exact hf.toMeromorphicNFOn_eq_self_on_nhdsNE hx
@[deprecated (since := "2025-05-22")]
alias order_toMeromorphicNFOn := meromorphicOrderAt_toMeromorphicNFOn
/--
Conversion of normal form does not affect divisors.
-/
@[simp] theorem MeromorphicOn.divisor_of_toMeromorphicNFOn (hf : MeromorphicOn f U) :
divisor (toMeromorphicNFOn f U) U = divisor f U := by
ext z
by_cases hz : z β U <;> simp [hf, (meromorphicNFOn_toMeromorphicNFOn f U).meromorphicOn, hz] |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/Basic.lean | import Mathlib.Analysis.Analytic.IsolatedZeros
/-!
# Meromorphic functions
Main statements:
* `MeromorphicAt`: definition of meromorphy at a point
* `MeromorphicAt.iff_eventuallyEq_zpow_smul_analyticAt`: `f` is meromorphic at `zβ` iff we have
`f z = (z - zβ) ^ n β’ g z` on a punctured neighborhood of `zβ`, for some `n : β€`
and `g` analytic at `zβ`.
-/
open Filter
open scoped Topology
variable {π : Type*} [NontriviallyNormedField π]
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
/-- Meromorphy of `f` at `x` (more precisely, on a punctured neighbourhood of `x`; the value at
`x` itself is irrelevant). -/
@[fun_prop]
def MeromorphicAt (f : π β E) (x : π) :=
β (n : β), AnalyticAt π (fun z β¦ (z - x) ^ n β’ f z) x
@[fun_prop]
lemma AnalyticAt.meromorphicAt {f : π β E} {x : π} (hf : AnalyticAt π f x) :
MeromorphicAt f x :=
β¨0, by simpa only [pow_zero, one_smul]β©
/- Analogue of the principle of isolated zeros for an analytic function: if a function is
meromorphic at `zβ`, then either it is identically zero in a punctured neighborhood of `zβ`, or it
does not vanish there at all. -/
theorem MeromorphicAt.eventually_eq_zero_or_eventually_ne_zero {f : π β E} {zβ : π}
(hf : MeromorphicAt f zβ) :
(βαΆ z in π[β ] zβ, f z = 0) β¨ (βαΆ z in π[β ] zβ, f z β 0) := by
obtain β¨n, hβ© := hf
rcases h.eventually_eq_zero_or_eventually_ne_zero with hβ | hβ
Β· left
filter_upwards [nhdsWithin_le_nhds hβ, self_mem_nhdsWithin] with y hβy hβy
rw [Set.mem_compl_iff, Set.mem_singleton_iff, β sub_eq_zero] at hβy
exact smul_eq_zero_iff_right (pow_ne_zero n hβy) |>.mp hβy
Β· right
filter_upwards [hβ, self_mem_nhdsWithin] with y hβy hβy
exact (smul_ne_zero_iff.1 hβy).2
namespace MeromorphicAt
variable {ΞΉ : Type*} {s : Finset ΞΉ} {F : ΞΉ β π β π} {G : ΞΉ β π β E}
@[fun_prop]
lemma id (x : π) : MeromorphicAt id x := analyticAt_id.meromorphicAt
@[fun_prop, simp]
lemma const (e : E) (x : π) : MeromorphicAt (fun _ β¦ e) x :=
analyticAt_const.meromorphicAt
variable {x : π}
@[fun_prop]
lemma add {f g : π β E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (f + g) x := by
rcases hf with β¨m, hfβ©
rcases hg with β¨n, hgβ©
refine β¨max m n, ?_β©
have : (fun z β¦ (z - x) ^ max m n β’ (f + g) z) = fun z β¦ (z - x) ^ (max m n - m) β’
((z - x) ^ m β’ f z) + (z - x) ^ (max m n - n) β’ ((z - x) ^ n β’ g z) := by
simp_rw [β mul_smul, β pow_add, Nat.sub_add_cancel (Nat.le_max_left _ _),
Nat.sub_add_cancel (Nat.le_max_right _ _), Pi.add_apply, smul_add]
rw [this]
exact (((analyticAt_id.sub analyticAt_const).pow _).smul hf).add
(((analyticAt_id.sub analyticAt_const).pow _).smul hg)
@[fun_prop]
lemma fun_add {f g : π β E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (fun z β¦ f z + g z) x :=
hf.add hg
@[deprecated (since := "2025-05-09")] alias add' := fun_add
@[fun_prop]
lemma smul {f : π β π} {g : π β E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (f β’ g) x := by
rcases hf with β¨m, hfβ©
rcases hg with β¨n, hgβ©
refine β¨m + n, ?_β©
convert hf.fun_smul hg using 2 with z
rw [Pi.smul_apply', smul_eq_mul]
module
@[fun_prop]
lemma fun_smul {f : π β π} {g : π β E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (fun z β¦ f z β’ g z) x :=
hf.smul hg
@[deprecated (since := "2025-05-09")] alias smul' := fun_smul
@[fun_prop]
lemma mul {f g : π β π} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (f * g) x :=
hf.smul hg
@[fun_prop]
lemma fun_mul {f g : π β π} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (fun z β¦ f z * g z) x :=
hf.smul hg
@[deprecated (since := "2025-05-09")] alias mul' := fun_mul
/-- Finite products of meromorphic functions are meromorphic. -/
@[fun_prop]
theorem prod (h : β Ο, MeromorphicAt (F Ο) x) :
MeromorphicAt (β n β s, F n) x := by
classical
induction s using Finset.induction with
| empty =>
rw [Finset.prod_empty]
exact analyticAt_const.meromorphicAt
| insert Ο s hΟ hind =>
rw [Finset.prod_insert hΟ]
exact (h Ο).mul hind
/-- Finite products of meromorphic functions are meromorphic. -/
@[fun_prop]
theorem fun_prod (h : β Ο, MeromorphicAt (F Ο) x) :
MeromorphicAt (fun z β¦ β n β s, F n z) x := by
convert prod h (s := s)
simp
/-- Finite sums of meromorphic functions are meromorphic. -/
@[fun_prop]
theorem sum (h : β Ο, MeromorphicAt (G Ο) x) :
MeromorphicAt (β n β s, G n) x := by
classical
induction s using Finset.induction with
| empty =>
simp only [Finset.sum_empty]
exact analyticAt_const.meromorphicAt
| insert Ο s hΟ hind =>
rw [Finset.sum_insert hΟ]
exact (h Ο).add hind
/-- Finite sums of meromorphic functions are meromorphic. -/
@[fun_prop]
theorem fun_sum (h : β Ο, MeromorphicAt (G Ο) x) :
MeromorphicAt (fun z β¦ β n β s, G n z) x := by
convert sum h (s := s)
simp
@[fun_prop]
lemma neg {f : π β E} (hf : MeromorphicAt f x) : MeromorphicAt (-f) x := by
convert (MeromorphicAt.const (-1 : π) x).smul hf using 1
ext1 z
simp only [Pi.neg_apply, Pi.smul_apply', neg_smul, one_smul]
@[fun_prop]
lemma fun_neg {f : π β E} (hf : MeromorphicAt f x) : MeromorphicAt (fun z β¦ -f z) x :=
hf.neg
@[deprecated (since := "2025-05-09")] alias neg' := fun_neg
@[simp]
lemma neg_iff {f : π β E} :
MeromorphicAt (-f) x β MeromorphicAt f x :=
β¨fun h β¦ by simpa only [neg_neg] using h.neg, MeromorphicAt.negβ©
@[fun_prop]
lemma sub {f g : π β E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (f - g) x := by
convert hf.add hg.neg using 1
ext1 z
simp_rw [Pi.sub_apply, Pi.add_apply, Pi.neg_apply, sub_eq_add_neg]
@[fun_prop]
lemma fun_sub {f g : π β E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (fun z β¦ f z - g z) x :=
hf.sub hg
/--
If `f` is meromorphic at `x`, then `f + g` is meromorphic at `x` if and only if `g` is meromorphic
at `x`.
-/
lemma meromorphicAt_add_iff_meromorphicAtβ {f g : π β E} (hf : MeromorphicAt f x) :
MeromorphicAt (f + g) x β MeromorphicAt g x := by
exact β¨fun h β¦ by simpa using h.sub hf, fun _ β¦ by fun_propβ©
/--
If `g` is meromorphic at `x`, then `f + g` is meromorphic at `x` if and only if `f` is meromorphic
at `x`.
-/
lemma meromorphicAt_add_iff_meromorphicAtβ {f g : π β E} (hg : MeromorphicAt g x) :
MeromorphicAt (f + g) x β MeromorphicAt f x := by
rw [add_comm]
exact meromorphicAt_add_iff_meromorphicAtβ hg
/--
If `f` is meromorphic at `x`, then `f - g` is meromorphic at `x` if and only if `g` is meromorphic
at `x`.
-/
lemma meromorphicAt_sub_iff_meromorphicAtβ {f g : π β E} (hf : MeromorphicAt f x) :
MeromorphicAt (f - g) x β MeromorphicAt g x := by
exact β¨fun h β¦ by simpa using h.sub hf, fun _ β¦ by fun_propβ©
/--
If `g` is meromorphic at `x`, then `f - g` is meromorphic at `x` if and only if `f` is meromorphic
at `x`.
-/
lemma meromorphicAt_sub_iff_meromorphicAtβ {f g : π β E} (hg : MeromorphicAt g x) :
MeromorphicAt (f - g) x β MeromorphicAt f x := by
exact β¨fun h β¦ by simpa using h.add hg, fun _ β¦ by fun_propβ©
@[deprecated (since := "2025-05-09")] alias sub' := fun_sub
/-- With our definitions, `MeromorphicAt f x` depends only on the values of `f` on a punctured
neighbourhood of `x` (not on `f x`) -/
lemma congr {f g : π β E} (hf : MeromorphicAt f x) (hfg : f =αΆ [π[β ] x] g) :
MeromorphicAt g x := by
rcases hf with β¨m, hfβ©
refine β¨m + 1, ?_β©
have : AnalyticAt π (fun z β¦ z - x) x := analyticAt_id.sub analyticAt_const
refine (this.fun_smul hf).congr ?_
rw [eventuallyEq_nhdsWithin_iff] at hfg
filter_upwards [hfg] with z hz
rcases eq_or_ne z x with rfl | hn
Β· simp
Β· rw [hz (Set.mem_compl_singleton_iff.mp hn), pow_succ', mul_smul]
/--
If two functions agree on a punctured neighborhood, then one is meromorphic iff the other is so.
-/
lemma meromorphicAt_congr {f g : π β E} (h : f =αΆ [π[β ] x] g) :
MeromorphicAt f x β MeromorphicAt g x :=
β¨fun hf β¦ hf.congr h, fun hg β¦ hg.congr h.symmβ©
@[simp]
lemma update_iff [DecidableEq π] {f : π β E} {z w : π} {e : E} :
MeromorphicAt (Function.update f w e) z β MeromorphicAt f z :=
meromorphicAt_congr (Function.update_eventuallyEq_nhdsNE f w z e)
@[fun_prop]
lemma update [DecidableEq π] {f : π β E} {z} (hf : MeromorphicAt f z) (w e) :
MeromorphicAt (Function.update f w e) z :=
update_iff.mpr hf
@[fun_prop]
lemma inv {f : π β π} (hf : MeromorphicAt f x) : MeromorphicAt fβ»ΒΉ x := by
rcases hf with β¨m, hfβ©
by_cases h_eq : (fun z β¦ (z - x) ^ m β’ f z) =αΆ [π x] 0
Β· -- silly case: f locally 0 near x
refine (MeromorphicAt.const 0 x).congr ?_
rw [eventuallyEq_nhdsWithin_iff]
filter_upwards [h_eq] with z hfz hz
rw [Pi.inv_apply, (smul_eq_zero_iff_right <| pow_ne_zero _ (sub_ne_zero.mpr hz)).mp hfz,
inv_zero]
Β· -- interesting case: use local formula for `f`
obtain β¨n, g, hg_an, hg_ne, hg_eqβ© := hf.exists_eventuallyEq_pow_smul_nonzero_iff.mpr h_eq
have : AnalyticAt π (fun z β¦ (z - x) ^ (m + 1)) x :=
(analyticAt_id.sub analyticAt_const).pow _
-- use `m + 1` rather than `m` to damp out any silly issues with the value at `z = x`
refine β¨n + 1, (this.fun_smul <| hg_an.inv hg_ne).congr ?_β©
filter_upwards [hg_eq, hg_an.continuousAt.eventually_ne hg_ne] with z hfg hg_ne'
rcases eq_or_ne z x with rfl | hz_ne
Β· simp only [sub_self, pow_succ, mul_zero, zero_smul]
Β· simp_rw [smul_eq_mul] at hfg β’
have aux1 : f z β 0 := by
have : (z - x) ^ n * g z β 0 := mul_ne_zero (pow_ne_zero _ (sub_ne_zero.mpr hz_ne)) hg_ne'
rw [β hfg, mul_ne_zero_iff] at this
exact this.2
simp [field, pow_succ', mul_assoc, hfg]
@[fun_prop]
lemma fun_inv {f : π β π} (hf : MeromorphicAt f x) : MeromorphicAt (fun z β¦ (f z)β»ΒΉ) x :=
hf.inv
@[deprecated (since := "2025-05-09")] alias inv' := fun_inv
@[simp]
lemma inv_iff {f : π β π} :
MeromorphicAt fβ»ΒΉ x β MeromorphicAt f x :=
β¨fun h β¦ by simpa only [inv_inv] using h.inv, MeromorphicAt.invβ©
@[fun_prop]
lemma div {f g : π β π} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (f / g) x :=
(div_eq_mul_inv f g).symm βΈ (hf.mul hg.inv)
@[fun_prop]
lemma fun_div {f g : π β π} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
MeromorphicAt (fun z β¦ f z / g z) x :=
hf.div hg
@[deprecated (since := "2025-05-09")] alias div' := fun_div
@[fun_prop]
lemma pow {f : π β π} (hf : MeromorphicAt f x) (n : β) : MeromorphicAt (f ^ n) x := by
induction n with
| zero => simpa only [pow_zero] using MeromorphicAt.const 1 x
| succ m hm => simpa only [pow_succ] using hm.mul hf
@[fun_prop]
lemma fun_pow {f : π β π} (hf : MeromorphicAt f x) (n : β) :
MeromorphicAt (fun z β¦ (f z) ^ n) x :=
hf.pow n
@[deprecated (since := "2025-05-09")] alias pow' := fun_pow
@[fun_prop]
lemma zpow {f : π β π} (hf : MeromorphicAt f x) (n : β€) : MeromorphicAt (f ^ n) x := by
cases n with
| ofNat m => simpa only [Int.ofNat_eq_coe, zpow_natCast] using hf.pow m
| negSucc m => simpa only [zpow_negSucc, inv_iff] using hf.pow (m + 1)
@[fun_prop]
lemma fun_zpow {f : π β π} (hf : MeromorphicAt f x) (n : β€) :
MeromorphicAt (fun z β¦ (f z) ^ n) x :=
hf.zpow n
@[deprecated (since := "2025-05-09")] alias zpow' := fun_zpow
/-- If a function is meromorphic at a point, then it is continuous at nearby points. -/
theorem eventually_continuousAt {f : π β E}
(h : MeromorphicAt f x) : βαΆ y in π[β ] x, ContinuousAt f y := by
obtain β¨n, hβ© := h
have : βαΆ y in π[β ] x, ContinuousAt (fun z β¦ (z - x) ^ n β’ f z) y :=
nhdsWithin_le_nhds h.eventually_continuousAt
filter_upwards [this, self_mem_nhdsWithin] with y hy h'y
simp only [Set.mem_compl_iff, Set.mem_singleton_iff] at h'y
have : ContinuousAt (fun z β¦ ((z - x) ^ n)β»ΒΉ) y :=
ContinuousAt.invβ (by fun_prop) (by simp [sub_eq_zero, h'y])
apply (this.smul hy).congr
filter_upwards [eventually_ne_nhds h'y] with z hz
simp [smul_smul, hz, sub_eq_zero]
/-- In a complete space, a function which is meromorphic at a point is analytic at all nearby
points. The completeness assumption can be dispensed with if one assumes that `f` is meromorphic
on a set around `x`, see `MeromorphicOn.eventually_analyticAt`. -/
theorem eventually_analyticAt [CompleteSpace E] {f : π β E}
(h : MeromorphicAt f x) : βαΆ y in π[β ] x, AnalyticAt π f y := by
obtain β¨n, hβ© := h
apply AnalyticAt.eventually_analyticAt at h
refine (h.filter_mono ?_).mp ?_
Β· simp [nhdsWithin]
Β· rw [eventually_nhdsWithin_iff]
apply Filter.Eventually.of_forall
intro y hy hf
rw [Set.mem_compl_iff, Set.mem_singleton_iff] at hy
have := ((analyticAt_id (π := π).sub analyticAt_const).pow n).inv
(pow_ne_zero _ (sub_ne_zero_of_ne hy))
apply (this.smul hf).congr β (eventually_ne_nhds hy).mono
intro z hz
simp [smul_smul, hz, sub_eq_zero]
lemma iff_eventuallyEq_zpow_smul_analyticAt {f : π β E} : MeromorphicAt f x β
β (n : β€) (g : π β E), AnalyticAt π g x β§ βαΆ z in π[β ] x, f z = (z - x) ^ n β’ g z := by
refine β¨fun β¨n, hnβ© β¦ β¨-n, _, β¨hn, eventually_nhdsWithin_iff.mpr ?_β©β©, ?_β©
Β· filter_upwards with z hz
match_scalars
simp [sub_ne_zero.mpr hz]
Β· refine fun β¨n, g, hg_an, hg_eqβ© β¦ MeromorphicAt.congr ?_ (EventuallyEq.symm hg_eq)
exact (((MeromorphicAt.id x).sub (.const _ x)).zpow _).smul hg_an.meromorphicAt
end MeromorphicAt
/-- Meromorphy of a function on a set. -/
def MeromorphicOn (f : π β E) (U : Set π) : Prop := β x β U, MeromorphicAt f x
lemma AnalyticOnNhd.meromorphicOn {f : π β E} {U : Set π} (hf : AnalyticOnNhd π f U) :
MeromorphicOn f U :=
fun x hx β¦ (hf x hx).meromorphicAt
namespace MeromorphicOn
variable {s t : π β π} {f g : π β E} {U : Set π}
(hs : MeromorphicOn s U) (ht : MeromorphicOn t U)
(hf : MeromorphicOn f U) (hg : MeromorphicOn g U)
/--
If `f` is meromorphic on `U`, if `g` agrees with `f` on a codiscrete subset of `U` and outside of
`U`, then `g` is also meromorphic on `U`.
-/
theorem congr_codiscreteWithin_of_eqOn_compl (hf : MeromorphicOn f U)
(hβ : f =αΆ [codiscreteWithin U] g) (hβ : Set.EqOn f g UαΆ) :
MeromorphicOn g U := by
intro x hx
apply (hf x hx).congr
simp_rw [EventuallyEq, Filter.Eventually, mem_codiscreteWithin,
disjoint_principal_right] at hβ
filter_upwards [hβ x hx] with a ha
simp at ha
tauto
/--
If `f` is meromorphic on an open set `U`, if `g` agrees with `f` on a codiscrete subset of `U`, then
`g` is also meromorphic on `U`.
-/
theorem congr_codiscreteWithin (hf : MeromorphicOn f U) (hβ : f =αΆ [codiscreteWithin U] g)
(hβ : IsOpen U) :
MeromorphicOn g U := by
intro x hx
apply (hf x hx).congr
simp_rw [EventuallyEq, Filter.Eventually, mem_codiscreteWithin,
disjoint_principal_right] at hβ
have : U β π[β ] x := by
apply mem_nhdsWithin.mpr
use U, hβ, hx, Set.inter_subset_left
filter_upwards [this, hβ x hx] with a hβa hβa
simp only [Set.mem_compl_iff, Set.mem_diff, Set.mem_setOf_eq, not_and] at hβa
tauto
lemma id {U : Set π} : MeromorphicOn id U := fun x _ β¦ .id x
lemma const (e : E) {U : Set π} : MeromorphicOn (fun _ β¦ e) U :=
fun x _ β¦ .const e x
section arithmetic
include hf in
lemma mono_set {V : Set π} (hv : V β U) : MeromorphicOn f V := fun x hx β¦ hf x (hv hx)
include hf hg in
lemma add : MeromorphicOn (f + g) U := fun x hx β¦ (hf x hx).add (hg x hx)
include hf hg in
lemma fun_add : MeromorphicOn (fun z β¦ f z + g z) U := fun x hx β¦ (hf x hx).add (hg x hx)
include hf hg in
lemma sub : MeromorphicOn (f - g) U := fun x hx β¦ (hf x hx).sub (hg x hx)
include hf hg in
lemma fun_sub : MeromorphicOn (fun z β¦ f z - g z) U := fun x hx β¦ (hf x hx).sub (hg x hx)
include hf in
lemma neg : MeromorphicOn (-f) U := fun x hx β¦ (hf x hx).neg
include hf in
lemma fun_neg : MeromorphicOn (fun z β¦ -f z) U := fun x hx β¦ (hf x hx).neg
@[simp] lemma neg_iff : MeromorphicOn (-f) U β MeromorphicOn f U :=
β¨fun h β¦ by simpa only [neg_neg] using h.neg, negβ©
include hs hf in
lemma smul : MeromorphicOn (s β’ f) U := fun x hx β¦ (hs x hx).smul (hf x hx)
include hs hf in
lemma fun_smul : MeromorphicOn (fun z β¦ s z β’ f z) U := fun x hx β¦ (hs x hx).smul (hf x hx)
include hs ht in
lemma mul : MeromorphicOn (s * t) U := fun x hx β¦ (hs x hx).mul (ht x hx)
include hs ht in
lemma fun_mul : MeromorphicOn (fun z β¦ s z * t z) U := fun x hx β¦ (hs x hx).mul (ht x hx)
/-- Finite products of meromorphic functions are meromorphic. -/
lemma prod {U : Set π} {ΞΉ : Type*} {s : Finset ΞΉ} {f : ΞΉ β π β π}
(h : β Ο, MeromorphicOn (f Ο) U) :
MeromorphicOn (β n β s, f n) U :=
fun z hz β¦ MeromorphicAt.prod (fun Ο β¦ h Ο z hz)
/-- Finite products of meromorphic functions are meromorphic. -/
lemma fun_prod {U : Set π} {ΞΉ : Type*} {s : Finset ΞΉ} {f : ΞΉ β π β π}
(h : β Ο, MeromorphicOn (f Ο) U) :
MeromorphicOn (fun z β¦ β n β s, f n z) U :=
fun z hz β¦ MeromorphicAt.fun_prod (fun Ο β¦ h Ο z hz)
/-- Finite sums of meromorphic functions are meromorphic. -/
lemma sum {U : Set π} {ΞΉ : Type*} {s : Finset ΞΉ} {f : ΞΉ β π β E} (h : β Ο, MeromorphicOn (f Ο) U) :
MeromorphicOn (β n β s, f n) U :=
fun z hz β¦ MeromorphicAt.sum (fun Ο β¦ h Ο z hz)
/-- Finite sums of meromorphic functions are meromorphic. -/
lemma fun_sum {U : Set π} {ΞΉ : Type*} {s : Finset ΞΉ} {f : ΞΉ β π β E}
(h : β Ο, MeromorphicOn (f Ο) U) :
MeromorphicOn (fun z β¦ β n β s, f n z) U :=
fun z hz β¦ MeromorphicAt.fun_sum (fun Ο β¦ h Ο z hz)
include hs in
lemma inv : MeromorphicOn sβ»ΒΉ U := fun x hx β¦ (hs x hx).inv
include hs in
lemma fun_inv : MeromorphicOn (fun z β¦ sβ»ΒΉ z) U := fun x hx β¦ (hs x hx).inv
@[simp] lemma inv_iff : MeromorphicOn sβ»ΒΉ U β MeromorphicOn s U :=
β¨fun h β¦ by simpa only [inv_inv] using h.inv, invβ©
include hs ht in
lemma div : MeromorphicOn (s / t) U := fun x hx β¦ (hs x hx).div (ht x hx)
include hs ht in
lemma fun_div : MeromorphicOn (fun z β¦ s z / t z) U := fun x hx β¦ (hs x hx).div (ht x hx)
include hs in
lemma pow (n : β) : MeromorphicOn (s ^ n) U := fun x hx β¦ (hs x hx).pow _
include hs in
lemma fun_pow (n : β) : MeromorphicOn (fun z β¦ s z ^ n) U := fun x hx β¦ (hs x hx).pow _
include hs in
lemma zpow (n : β€) : MeromorphicOn (s ^ n) U := fun x hx β¦ (hs x hx).zpow _
include hs in
lemma fun_zpow (n : β€) : MeromorphicOn (fun z β¦ s z ^ n) U := fun x hx β¦ (hs x hx).zpow _
end arithmetic
include hf in
lemma congr (h_eq : Set.EqOn f g U) (hu : IsOpen U) : MeromorphicOn g U := by
refine fun x hx β¦ (hf x hx).congr (EventuallyEq.filter_mono ?_ nhdsWithin_le_nhds)
exact eventually_of_mem (hu.mem_nhds hx) h_eq
theorem eventually_codiscreteWithin_analyticAt
[CompleteSpace E] (f : π β E) (h : MeromorphicOn f U) :
βαΆ (y : π) in codiscreteWithin U, AnalyticAt π f y := by
rw [eventually_iff, mem_codiscreteWithin]
intro x hx
rw [disjoint_principal_right]
apply Filter.mem_of_superset ((h x hx).eventually_analyticAt)
intro x hx
simp [hx]
end MeromorphicOn |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/TrailingCoefficient.lean | import Mathlib.Analysis.Meromorphic.Order
/-!
# The Trailing Coefficient of a Meromorphic Function
This file defines the trailing coefficient of a meromorphic function. If `f` is meromorphic at a
point `x`, the trailing coefficient is defined as the (unique!) value `g x` for a presentation of
`f` in the form `(z - x) ^ order β’ g z` with `g` analytic at `x`.
The lemma `MeromorphicAt.tendsto_nhds_meromorphicTrailingCoeffAt` expresses the trailing coefficient
as a limit.
-/
variable
{π : Type*} [NontriviallyNormedField π]
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
{f g : π β E} {x : π}
open Filter Topology
variable (f x) in
/--
If `f` is meromorphic of finite order at a point `x`, the trailing coefficient is defined as the
(unique!) value `g x` for a presentation of `f` in the form `(z - x) ^ order β’ g z` with `g`
analytic at `x`. In all other cases, the trailing coefficient is defined to be zero.
-/
noncomputable def meromorphicTrailingCoeffAt : E := by
by_cases hβ : MeromorphicAt f x
Β· by_cases hβ : meromorphicOrderAt f x = β€
Β· exact 0
Β· exact ((meromorphicOrderAt_ne_top_iff hβ).1 hβ).choose x
Β· exact 0
/--
If `f` is not meromorphic at `x`, the trailing coefficient is zero by definition.
-/
@[simp] lemma meromorphicTrailingCoeffAt_of_not_MeromorphicAt (h : Β¬MeromorphicAt f x) :
meromorphicTrailingCoeffAt f x = 0 := by simp [meromorphicTrailingCoeffAt, h]
/--
If `f` is meromorphic of infinite order at `x`, the trailing coefficient is zero by definition.
-/
@[simp] lemma MeromorphicAt.meromorphicTrailingCoeffAt_of_order_eq_top
(h : meromorphicOrderAt f x = β€) :
meromorphicTrailingCoeffAt f x = 0 := by simp_all [meromorphicTrailingCoeffAt]
/-!
## Characterization of the Trailing Coefficient
-/
/--
Definition of the trailing coefficient in case where `f` is meromorphic and a presentation of the
form `f = (z - x) ^ order β’ g z` is given, with `g` analytic at `x`.
-/
lemma AnalyticAt.meromorphicTrailingCoeffAt_of_eq_nhdsNE (hβg : AnalyticAt π g x)
(h : f =αΆ [π[β ] x] fun z β¦ (z - x) ^ (meromorphicOrderAt f x).untopβ β’ g z) :
meromorphicTrailingCoeffAt f x = g x := by
have hβf : MeromorphicAt f x := by
rw [MeromorphicAt.meromorphicAt_congr h]
fun_prop
by_cases hβ : meromorphicOrderAt f x = β€
Β· simp only [hβ, WithTop.untopβ_top, zpow_zero, one_smul,
MeromorphicAt.meromorphicTrailingCoeffAt_of_order_eq_top] at β’ h
apply EventuallyEq.eq_of_nhds (f := 0)
rw [β ContinuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE (by fun_prop) (by fun_prop)]
apply (h.symm.trans (meromorphicOrderAt_eq_top_iff.1 hβ)).symm
Β· unfold meromorphicTrailingCoeffAt
simp only [hβf, reduceDIte, hβ, ne_eq]
obtain β¨h'β, h'β, h'ββ© := ((meromorphicOrderAt_ne_top_iff hβf).1 hβ).choose_spec
apply Filter.EventuallyEq.eq_of_nhds
rw [β h'β.continuousAt.eventuallyEq_nhds_iff_eventuallyEq_nhdsNE hβg.continuousAt]
filter_upwards [h, h'β, self_mem_nhdsWithin] with y hβy hβy hβy
rw [β sub_eq_zero]
rwa [hβy, β sub_eq_zero, β smul_sub, smul_eq_zero_iff_right] at hβy
simp_all [zpow_ne_zero, sub_ne_zero]
/--
Variant of `meromorphicTrailingCoeffAt_of_order_eq_finite`: Definition of the trailing coefficient
in case where `f` is meromorphic of finite order and a presentation is given.
-/
lemma AnalyticAt.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE {n : β€} (hβg : AnalyticAt π g x)
(hβg : g x β 0) (h : f =αΆ [π[β ] x] fun z β¦ (z - x) ^ n β’ g z) :
meromorphicTrailingCoeffAt f x = g x := by
have hβ : MeromorphicAt f x := by
rw [MeromorphicAt.meromorphicAt_congr h]
fun_prop
have : meromorphicOrderAt f x = n := by
simp only [meromorphicOrderAt_eq_int_iff hβ, ne_eq]
use g, hβg, hβg
exact h
simp_all [meromorphicTrailingCoeffAt_of_eq_nhdsNE hβg]
/--
If `f` is analytic and does not vanish at `x`, then the trailing coefficient of `f` at `x` is `f x`.
-/
@[simp]
lemma AnalyticAt.meromorphicTrailingCoeffAt_of_ne_zero (hβ : AnalyticAt π f x) (hβ : f x β 0) :
meromorphicTrailingCoeffAt f x = f x := by
rw [hβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE (n := 0) hβ]
filter_upwards
simp
/--
If `f` is meromorphic at `x`, then the trailing coefficient of `f` at `x` is the limit of the
function `(Β· - x) ^ (-order) β’ f`.
-/
lemma MeromorphicAt.tendsto_nhds_meromorphicTrailingCoeffAt (h : MeromorphicAt f x) :
Tendsto ((Β· - x) ^ (-(meromorphicOrderAt f x).untopβ) β’ f) (π[β ] x)
(π (meromorphicTrailingCoeffAt f x)) := by
by_cases hβ : meromorphicOrderAt f x = β€
Β· simp_all only [WithTop.untopβ_top, neg_zero, zpow_zero, one_smul,
meromorphicTrailingCoeffAt_of_order_eq_top]
apply Tendsto.congr' (fβ := 0)
Β· filter_upwards [meromorphicOrderAt_eq_top_iff.1 hβ] with y hy
simp_all
Β· apply Tendsto.congr' (fβ := 0) (by rfl) continuousWithinAt_const.tendsto
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_ne_top_iff h).1 hβ
apply Tendsto.congr' (fβ := g)
Β· filter_upwards [hβg, self_mem_nhdsWithin] with y hβy hβy
rw [zpow_neg, Pi.smul_apply', Pi.inv_apply, Pi.pow_apply, hβy, β smul_assoc, smul_eq_mul,
β zpow_neg, β zpow_add', neg_add_cancel, zpow_zero, one_smul]
left
simp_all [sub_ne_zero]
Β· rw [hβg.meromorphicTrailingCoeffAt_of_eq_nhdsNE hβg]
apply hβg.continuousAt.continuousWithinAt
/-!
## Elementary Properties
-/
/--
If `f` is meromorphic of finite order at `x`, then the trailing coefficient is not zero.
-/
lemma MeromorphicAt.meromorphicTrailingCoeffAt_ne_zero (hβ : MeromorphicAt f x)
(hβ : meromorphicOrderAt f x β β€) :
meromorphicTrailingCoeffAt f x β 0 := by
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_ne_top_iff hβ).1 hβ
simpa [hβg.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβg hβg] using hβg
/--
The trailing coefficient of a constant function is the constant.
-/
@[simp]
theorem meromorphicTrailingCoeffAt_const {x : π} {e : π} :
meromorphicTrailingCoeffAt (fun _ β¦ e) x = e := by
by_cases he : e = 0
Β· rw [he]
apply MeromorphicAt.meromorphicTrailingCoeffAt_of_order_eq_top
rw [meromorphicOrderAt_eq_top_iff]
simp
Β· exact analyticAt_const.meromorphicTrailingCoeffAt_of_ne_zero he
/--
The trailing coefficient of `fun z β¦ z - constant` at `zβ` equals one if `zβ = constant`, or else
`zβ - constant`.
-/
theorem meromorphicTrailingCoeffAt_id_sub_const [DecidableEq π] {x y : π} :
meromorphicTrailingCoeffAt (Β· - y) x = if x = y then 1 else x - y := by
by_cases h : x = y
Β· simp_all only [sub_self, ite_true]
apply AnalyticAt.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE (n := 1) (by fun_prop)
(by apply one_ne_zero)
simp
Β· simp_all only [ite_false]
apply AnalyticAt.meromorphicTrailingCoeffAt_of_ne_zero (by fun_prop)
simp_all [sub_ne_zero]
/-!
## Congruence Lemma
-/
/--
If two functions agree in a punctured neighborhood, then their trailing coefficients agree.
-/
lemma meromorphicTrailingCoeffAt_congr_nhdsNE {fβ fβ : π β E} (h : fβ =αΆ [π[β ] x] fβ) :
meromorphicTrailingCoeffAt fβ x = meromorphicTrailingCoeffAt fβ x := by
by_cases hβ : Β¬MeromorphicAt fβ x
Β· simp [hβ, (MeromorphicAt.meromorphicAt_congr h).not.1 hβ]
rw [not_not] at hβ
by_cases hβ : meromorphicOrderAt fβ x = β€
Β· simp_all [meromorphicOrderAt_congr h]
obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_ne_top_iff hβ).1 hβ
rw [hβg.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβg hβg,
hβg.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβg (h.symm.trans hβg)]
/-!
## Behavior under Arithmetic Operations
-/
/--
If `fβ` and `fβ` have unequal order at `x`, then the trailing coefficient of `fβ + fβ` at `x` is the
trailing coefficient of the function with the lowest order.
-/
theorem MeromorphicAt.meromorphicTrailingCoeffAt_add_eq_left_of_lt {fβ fβ : π β E}
(hfβ : MeromorphicAt fβ x) (h : meromorphicOrderAt fβ x < meromorphicOrderAt fβ x) :
meromorphicTrailingCoeffAt (fβ + fβ) x = meromorphicTrailingCoeffAt fβ x := by
-- Trivial case: fβ not meromorphic at x
by_cases hfβ : Β¬MeromorphicAt fβ x
Β· have : Β¬MeromorphicAt (fβ + fβ) x := by
rwa [add_comm, hfβ.meromorphicAt_add_iff_meromorphicAtβ]
simp_all
rw [not_not] at hfβ
-- Trivial case: fβ vanishes locally around x
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· apply meromorphicTrailingCoeffAt_congr_nhdsNE
filter_upwards [meromorphicOrderAt_eq_top_iff.1 hβfβ]
simp
-- General case
lift meromorphicOrderAt fβ x to β€ using hβfβ with nβ hnβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
lift meromorphicOrderAt fβ x to β€ using (by aesop) with nβ hnβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
rw [WithTop.coe_lt_coe] at h
have Οβ : βαΆ z in π[β ] x, (fβ + fβ) z = (z - x) ^ nβ β’ (gβ + (z - x) ^ (nβ - nβ) β’ gβ) z := by
filter_upwards [hβgβ, hβgβ, self_mem_nhdsWithin] with z hβz hβz hβz
simp only [Pi.add_apply, hβz, hβz, Pi.smul_apply, smul_add, β smul_assoc, smul_eq_mul,
add_right_inj]
rw [β zpow_addβ, add_sub_cancel]
simp_all [sub_ne_zero]
have Οβ : AnalyticAt π (fun z β¦ gβ z + (z - x) ^ (nβ - nβ) β’ gβ z) x :=
hβgβ.fun_add (AnalyticAt.fun_smul (AnalyticAt.fun_zpow_nonneg (by fun_prop)
(sub_nonneg_of_le h.le)) hβgβ)
have Οβ : gβ x + (x - x) ^ (nβ - nβ) β’ gβ x β 0 := by
simp_all [zero_zpow _ (sub_ne_zero.2 (ne_of_lt h).symm)]
rw [hβgβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβgβ hβgβ,
Οβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE Οβ Οβ, sub_self, add_eq_left,
smul_eq_zero, zero_zpow _ (sub_ne_zero.2 (ne_of_lt h).symm)]
tauto
/--
If `fβ` and `fβ` have equal order at `x` and if their trailing coefficients do not cancel, then the
trailing coefficient of `fβ + fβ` at `x` is the sum of the trailing coefficients.
-/
theorem MeromorphicAt.meromorphicTrailingCoeffAt_add_eq_add {fβ fβ : π β E}
(hfβ : MeromorphicAt fβ x) (hfβ : MeromorphicAt fβ x)
(hβ : meromorphicOrderAt fβ x = meromorphicOrderAt fβ x)
(hβ : meromorphicTrailingCoeffAt fβ x + meromorphicTrailingCoeffAt fβ x β 0) :
meromorphicTrailingCoeffAt (fβ + fβ) x
= meromorphicTrailingCoeffAt fβ x + meromorphicTrailingCoeffAt fβ x := by
-- Trivial case: fβ vanishes locally around x
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· rw [meromorphicTrailingCoeffAt_of_order_eq_top hβfβ, zero_add]
apply meromorphicTrailingCoeffAt_congr_nhdsNE
filter_upwards [meromorphicOrderAt_eq_top_iff.1 hβfβ]
simp
-- General case
lift meromorphicOrderAt fβ x to β€ using (by aesop) with nβ hnβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
lift meromorphicOrderAt fβ x to β€ using (by aesop) with nβ hnβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_eq_int_iff hfβ).1 hnβ.symm
rw [WithTop.coe_eq_coe, hβgβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβgβ hβgβ,
hβgβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβgβ hβgβ] at *
have Οβ : βαΆ z in π[β ] x, (fβ + fβ) z = (z - x) ^ nβ β’ (gβ + gβ) z := by
filter_upwards [hβgβ, hβgβ, self_mem_nhdsWithin] with z hβz hβz hβz
simp_all
simp [AnalyticAt.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE (by fun_prop)
(by simp_all) Οβ]
/--
The trailing coefficient of a scalar product is the scalar product of the trailing coefficients.
-/
lemma MeromorphicAt.meromorphicTrailingCoeffAt_smul {fβ : π β π} {fβ : π β E}
(hfβ : MeromorphicAt fβ x) (hfβ : MeromorphicAt fβ x) :
meromorphicTrailingCoeffAt (fβ β’ fβ) x =
(meromorphicTrailingCoeffAt fβ x) β’ (meromorphicTrailingCoeffAt fβ x) := by
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· simp_all [meromorphicOrderAt_smul hfβ hfβ]
by_cases hβfβ : meromorphicOrderAt fβ x = β€
Β· simp_all [meromorphicOrderAt_smul hfβ hfβ]
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_ne_top_iff hfβ).1 hβfβ
obtain β¨gβ, hβgβ, hβgβ, hβgββ© := (meromorphicOrderAt_ne_top_iff hfβ).1 hβfβ
have : fβ β’ fβ =αΆ [π[β ] x]
fun z β¦ (z - x) ^ (meromorphicOrderAt (fβ β’ fβ) x).untopβ β’ (gβ β’ gβ) z := by
filter_upwards [hβgβ, hβgβ, self_mem_nhdsWithin] with y hβy hβy hβy
simp_all [meromorphicOrderAt_smul hfβ hfβ, zpow_addβ (sub_ne_zero.2 hβy)]
module
rw [hβgβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβgβ hβgβ,
hβgβ.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE hβgβ hβgβ,
(hβgβ.smul hβgβ).meromorphicTrailingCoeffAt_of_eq_nhdsNE this]
simp
/--
The trailing coefficient of a product is the product of the trailing coefficients.
-/
lemma MeromorphicAt.meromorphicTrailingCoeffAt_mul {fβ fβ : π β π} (hfβ : MeromorphicAt fβ x)
(hfβ : MeromorphicAt fβ x) :
meromorphicTrailingCoeffAt (fβ * fβ) x =
(meromorphicTrailingCoeffAt fβ x) * (meromorphicTrailingCoeffAt fβ x) :=
meromorphicTrailingCoeffAt_smul hfβ hfβ
/--
The trailing coefficient of a product is the product of the trailing coefficients.
-/
theorem meromorphicTrailingCoeffAt_prod {ΞΉ : Type*} {s : Finset ΞΉ} {f : ΞΉ β π β π} {x : π}
(h : β Ο, MeromorphicAt (f Ο) x) :
meromorphicTrailingCoeffAt (β n β s, f n) x = β n β s, meromorphicTrailingCoeffAt (f n) x := by
classical
induction s using Finset.induction with
| empty =>
apply meromorphicTrailingCoeffAt_const
| insert Ο sβ hΟ hind =>
rw [Finset.prod_insert hΟ, Finset.prod_insert hΟ, (h Ο).meromorphicTrailingCoeffAt_mul
(MeromorphicAt.prod h), hind]
/--
The trailing coefficient of the inverse function is the inverse of the trailing coefficient.
-/
lemma meromorphicTrailingCoeffAt_inv {f : π β π} :
meromorphicTrailingCoeffAt fβ»ΒΉ x = (meromorphicTrailingCoeffAt f x)β»ΒΉ := by
by_cases hβ : MeromorphicAt f x
Β· by_cases hβ : meromorphicOrderAt f x = β€
Β· simp_all [meromorphicOrderAt_inv (f := f) (x := x)]
have : fβ»ΒΉ * f =αΆ [π[β ] x] 1 := by
filter_upwards [(meromorphicOrderAt_ne_top_iff_eventually_ne_zero hβ).1 hβ]
simp_all
rw [β mul_eq_one_iff_eq_invβ (hβ.meromorphicTrailingCoeffAt_ne_zero hβ),
β hβ.inv.meromorphicTrailingCoeffAt_mul hβ, meromorphicTrailingCoeffAt_congr_nhdsNE this,
analyticAt_const.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE (n := 0)]
Β· simp
Β· simp only [zpow_zero, smul_eq_mul, mul_one]
exact eventuallyEq_nhdsWithin_of_eqOn fun _ β¦ congrFun rfl
Β· simp_all
/--
The trailing coefficient of the power of a function is the power of the trailing coefficient.
-/
lemma MeromorphicAt.meromorphicTrailingCoeffAt_zpow {n : β€} {f : π β π} (hβ : MeromorphicAt f x) :
meromorphicTrailingCoeffAt (f ^ n) x = (meromorphicTrailingCoeffAt f x) ^ n := by
by_cases hβ : meromorphicOrderAt f x = β€
Β· by_cases hβ : n = 0
Β· simp only [hβ, zpow_zero]
apply analyticAt_const.meromorphicTrailingCoeffAt_of_ne_zero (ne_zero_of_eq_one rfl)
Β· simp_all [meromorphicOrderAt_zpow hβ, zero_zpow n hβ]
Β· obtain β¨g, hβg, hβg, hβgβ© := (meromorphicOrderAt_ne_top_iff hβ).1 hβ
rw [hβg.meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE
(n := (meromorphicOrderAt f x).untopβ) hβg hβg,
(hβg.zpow hβg (n := n)).meromorphicTrailingCoeffAt_of_ne_zero_of_eq_nhdsNE
(n := (meromorphicOrderAt (f ^ n) x).untopβ)
(by simp_all [zpow_ne_zero])]
Β· simp only [Pi.pow_apply]
Β· filter_upwards [hβg] with a ha
simp_all [mul_zpow, β zpow_mul, meromorphicOrderAt_zpow hβ, mul_comm]
/--
The trailing coefficient of the power of a function is the power of the trailing coefficient.
-/
lemma MeromorphicAt.meromorphicTrailingCoeffAt_pow {n : β} {f : π β π} (hβ : MeromorphicAt f x) :
meromorphicTrailingCoeffAt (f ^ n) x = (meromorphicTrailingCoeffAt f x) ^ n := by
convert hβ.meromorphicTrailingCoeffAt_zpow (n := n) <;> simp |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/Divisor.lean | import Mathlib.Algebra.Order.WithTop.Untop0
import Mathlib.Analysis.Meromorphic.Order
import Mathlib.Topology.LocallyFinsupp
/-!
# The Divisor of a meromorphic function
This file defines the divisor of a meromorphic function and proves the most basic lemmas about those
divisors. The lemma `MeromorphicOn.divisor_restrict` guarantees compatibility between restrictions
of divisors and of meromorphic functions to subsets of their domain of definition.
-/
variable {π : Type*} [NontriviallyNormedField π] {U : Set π} {z : π}
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
open Filter Topology
namespace MeromorphicOn
/-!
## Definition of the Divisor
-/
open Classical in
/--
The divisor of a meromorphic function `f`, mapping a point `z` to the order of `f` at `z`, and to
zero if the order is infinite.
-/
noncomputable def divisor (f : π β E) (U : Set π) :
Function.locallyFinsuppWithin U β€ where
toFun := fun z β¦ if MeromorphicOn f U β§ z β U then (meromorphicOrderAt f z).untopβ else 0
supportWithinDomain' z hz := by
by_contra hβz
simp [hβz] at hz
supportLocallyFiniteWithinDomain' := by
simp_all only [Function.support_subset_iff, ne_eq, ite_eq_right_iff, WithTop.untopβ_eq_zero,
and_imp, Classical.not_imp, not_or, implies_true,
β supportDiscreteWithin_iff_locallyFiniteWithin]
by_cases hf : MeromorphicOn f U
Β· filter_upwards [mem_codiscrete_subtype_iff_mem_codiscreteWithin.1
hf.codiscrete_setOf_meromorphicOrderAt_eq_zero_or_top]
simp only [Set.mem_image, Set.mem_setOf_eq, Subtype.exists, exists_and_left, exists_prop,
exists_eq_right_right, Pi.ofNat_apply, ite_eq_right_iff, WithTop.untopβ_eq_zero, and_imp]
tauto
Β· simp [hf, Pi.zero_def]
open Classical in
/-- Definition of the divisor -/
theorem divisor_def (f : π β E) (U : Set π) :
divisor f U z = if MeromorphicOn f U β§ z β U then (meromorphicOrderAt f z).untopβ else 0 :=
rfl
/--
Simplifier lemma: on `U`, the divisor of a function `f` that is meromorphic on `U` evaluates to
`order.untopβ`.
-/
@[simp]
lemma divisor_apply {f : π β E} (hf : MeromorphicOn f U) (hz : z β U) :
divisor f U z = (meromorphicOrderAt f z).untopβ := by simp_all [MeromorphicOn.divisor_def]
/-!
## Congruence Lemmas
-/
/--
If `fβ` is meromorphic on `U`, if `fβ` agrees with `fβ` on a codiscrete subset of `U` and outside of
`U`, then `fβ` and `fβ` induce the same divisors on `U`.
-/
theorem divisor_congr_codiscreteWithin_of_eqOn_compl {fβ fβ : π β E} (hfβ : MeromorphicOn fβ U)
(hβ : fβ =αΆ [Filter.codiscreteWithin U] fβ) (hβ : Set.EqOn fβ fβ UαΆ) :
divisor fβ U = divisor fβ U := by
ext x
by_cases hx : x β U
Β· simp only [hfβ, hx, divisor_apply, hfβ.congr_codiscreteWithin_of_eqOn_compl hβ hβ]
congr 1
apply meromorphicOrderAt_congr
simp_rw [EventuallyEq, Filter.Eventually, mem_codiscreteWithin,
disjoint_principal_right] at hβ
filter_upwards [hβ x hx] with a ha
simp at ha
tauto
Β· simp [hx]
/--
If `fβ` is meromorphic on an open set `U`, if `fβ` agrees with `fβ` on a codiscrete subset of `U`,
then `fβ` and `fβ` induce the same divisors on`U`.
-/
theorem divisor_congr_codiscreteWithin {fβ fβ : π β E} (hfβ : MeromorphicOn fβ U)
(hβ : fβ =αΆ [Filter.codiscreteWithin U] fβ) (hβ : IsOpen U) :
divisor fβ U = divisor fβ U := by
ext x
by_cases hx : x β U
Β· simp only [hfβ, hx, divisor_apply, hfβ.congr_codiscreteWithin hβ hβ]
congr 1
apply meromorphicOrderAt_congr
simp_rw [EventuallyEq, Filter.Eventually, mem_codiscreteWithin,
disjoint_principal_right] at hβ
have : U β π[β ] x := by
apply mem_nhdsWithin.mpr
use U, hβ, hx, Set.inter_subset_left
filter_upwards [this, hβ x hx] with a hβa hβa
simp only [Set.mem_compl_iff, Set.mem_diff, Set.mem_setOf_eq, not_and] at hβa
tauto
Β· simp [hx]
/-!
## Divisors of Analytic Functions
-/
/-- Analytic functions have non-negative divisors. -/
theorem AnalyticOnNhd.divisor_nonneg {f : π β E} (hf : AnalyticOnNhd π f U) :
0 β€ MeromorphicOn.divisor f U := by
intro x
by_cases hx : x β U
Β· simp [hf.meromorphicOn, hx, (hf x hx).meromorphicOrderAt_nonneg]
simp [hx]
/--
The divisor of a constant function is `0`.
-/
@[simp]
theorem divisor_const (e : E) :
divisor (fun _ β¦ e) U = 0 := by
classical
ext x
simp only [divisor_def, meromorphicOrderAt_const, Function.locallyFinsuppWithin.coe_zero,
Pi.zero_apply, ite_eq_right_iff, WithTop.untopβ_eq_zero,
LinearOrderedAddCommGroupWithTop.top_ne_zero, imp_false, ite_eq_left_iff, WithTop.zero_ne_top,
Decidable.not_not, and_imp]
tauto
/--
The divisor of a constant function is `0`.
-/
@[simp]
theorem divisor_intCast (n : β€) :
divisor (n : π β π) U = 0 := divisor_const (n : π)
/--
The divisor of a constant function is `0`.
-/
@[simp]
theorem divisor_natCast (n : β) :
divisor (n : π β π) U = 0 := divisor_const (n : π)
/--
The divisor of a constant function is `0`.
-/
@[simp] theorem divisor_ofNat (n : β) :
divisor (ofNat(n) : π β π) U = 0 := by
convert divisor_const (n : π)
simp [Semiring.toGrindSemiring_ofNat π n]
/-!
## Behavior under Standard Operations
-/
/--
If orders are finite, the divisor of the scalar product of two meromorphic functions is the sum of
the divisors.
See `MeromorphicOn.exists_order_ne_top_iff_forall` and
`MeromorphicOn.order_ne_top_of_isPreconnected` for two convenient criteria to guarantee conditions
`hβfβ` and `hβfβ`.
-/
theorem divisor_smul {fβ : π β π} {fβ : π β E} (hβfβ : MeromorphicOn fβ U)
(hβfβ : MeromorphicOn fβ U) (hβfβ : β z β U, meromorphicOrderAt fβ z β β€)
(hβfβ : β z β U, meromorphicOrderAt fβ z β β€) :
divisor (fβ β’ fβ) U = divisor fβ U + divisor fβ U := by
ext z
by_cases hz : z β U
Β· lift meromorphicOrderAt fβ z to β€ using (hβfβ z hz) with aβ haβ
lift meromorphicOrderAt fβ z to β€ using (hβfβ z hz) with aβ haβ
simp [hβfβ, hβfβ, hβfβ.smul hβfβ, hz, meromorphicOrderAt_smul (hβfβ z hz) (hβfβ z hz),
β haβ, β haβ, β WithTop.coe_add]
Β· simp [hz]
/--
If orders are finite, the divisor of the scalar product of two meromorphic functions is the sum of
the divisors.
-/
theorem divisor_fun_smul {fβ : π β π} {fβ : π β E} (hβfβ : MeromorphicOn fβ U)
(hβfβ : MeromorphicOn fβ U) (hβfβ : β z β U, meromorphicOrderAt fβ z β β€)
(hβfβ : β z β U, meromorphicOrderAt fβ z β β€) :
divisor (fun z β¦ fβ z β’ fβ z) U = divisor fβ U + divisor fβ U :=
divisor_smul hβfβ hβfβ hβfβ hβfβ
/--
If orders are finite, the divisor of the product of two meromorphic functions is the sum of the
divisors.
See `MeromorphicOn.exists_order_ne_top_iff_forall` and
`MeromorphicOn.order_ne_top_of_isPreconnected` for two convenient criteria to guarantee conditions
`hβfβ` and `hβfβ`.
-/
theorem divisor_mul {fβ fβ : π β π} (hβfβ : MeromorphicOn fβ U)
(hβfβ : MeromorphicOn fβ U) (hβfβ : β z β U, meromorphicOrderAt fβ z β β€)
(hβfβ : β z β U, meromorphicOrderAt fβ z β β€) :
divisor (fβ * fβ) U = divisor fβ U + divisor fβ U := divisor_smul hβfβ hβfβ hβfβ hβfβ
/--
If orders are finite, the divisor of the product of two meromorphic functions is the sum of the
divisors.
-/
theorem divisor_fun_mul {fβ fβ : π β π} (hβfβ : MeromorphicOn fβ U)
(hβfβ : MeromorphicOn fβ U) (hβfβ : β z β U, meromorphicOrderAt fβ z β β€)
(hβfβ : β z β U, meromorphicOrderAt fβ z β β€) :
divisor (fun z β¦ fβ z * fβ z) U = divisor fβ U + divisor fβ U :=
divisor_smul hβfβ hβfβ hβfβ hβfβ
/-- The divisor of the inverse is the negative of the divisor. -/
@[simp]
theorem divisor_inv {f : π β π} :
divisor fβ»ΒΉ U = -divisor f U := by
ext z
by_cases h : MeromorphicOn f U β§ z β U
Β· simp [divisor_apply, h, meromorphicOrderAt_inv]
Β· simp [divisor_def, h]
/-- The divisor of the inverse is the negative of the divisor. -/
@[simp]
theorem divisor_fun_inv {f : π β π} : divisor (fun z β¦ (f z)β»ΒΉ) U = -divisor f U := divisor_inv
/--
If `f` is meromorphic, then the divisor of `f ^ n` is `n` times the divisor of `f`.
-/
theorem divisor_pow {f : π β π} (hf : MeromorphicOn f U) (n : β) :
divisor (f ^ n) U = n β’ divisor f U := by
classical
ext z
by_cases hn : n = 0
Β· simp [hn]
by_cases hz : z β U
Β· simp [hf.pow, divisor_apply, meromorphicOrderAt_pow (hf z hz), hf, hz]
Β· simp [hz]
/--
If `f` is meromorphic, then the divisor of `f ^ n` is `n` times the divisor of `f`.
-/
theorem divisor_fun_pow {f : π β π} (hf : MeromorphicOn f U) (n : β) :
divisor (fun z β¦ f z ^ n) U = n β’ divisor f U := divisor_pow hf n
/--
If `f` is meromorphic, then the divisor of `f ^ n` is `n` times the divisor of `f`.
-/
theorem divisor_zpow {f : π β π} (hf : MeromorphicOn f U) (n : β€) :
divisor (f ^ n) U = n β’ divisor f U := by
classical
ext z
by_cases hn : n = 0
Β· simp [hn]
by_cases hz : z β U
Β· simp [hf.zpow, divisor_apply, meromorphicOrderAt_zpow (hf z hz), hf, hz]
Β· simp [hz]
/--
If `f` is meromorphic, then the divisor of `f ^ n` is `n` times the divisor of `f`.
-/
theorem divisor_fun_zpow {f : π β π} (hf : MeromorphicOn f U) (n : β€) :
divisor (fun z β¦ f z ^ n) U = n β’ divisor f U := divisor_zpow hf n
/--
Taking the divisor of a meromorphic function commutes with restriction.
-/
@[simp]
theorem divisor_restrict {f : π β E} {V : Set π} (hf : MeromorphicOn f U) (hV : V β U) :
(divisor f U).restrict hV = divisor f V := by
ext x
by_cases hx : x β V
Β· rw [Function.locallyFinsuppWithin.restrict_apply]
simp [hf, hx, hf.mono_set hV, hV hx]
Β· simp [hx]
/-- Adding an analytic function to a meromorphic one does not change the pole divisor. -/
theorem negPart_divisor_add_of_analyticNhdOn_right {fβ fβ : π β E} (hfβ : MeromorphicOn fβ U)
(hfβ : AnalyticOnNhd π fβ U) :
(divisor (fβ + fβ) U)β» = (divisor fβ U)β» := by
ext x
by_cases hx : x β U
Β· suffices -(meromorphicOrderAt (fβ + fβ) x).untopβ β 0 = -(meromorphicOrderAt fβ x).untopβ β 0 by
simpa [negPart_def, hx, hfβ, hfβ.add hfβ.meromorphicOn]
by_cases h : 0 β€ meromorphicOrderAt fβ x
Β· suffices 0 β€ meromorphicOrderAt (fβ + fβ) x by simp_all
calc 0
_ β€ min (meromorphicOrderAt fβ x) (meromorphicOrderAt fβ x) :=
le_inf h (hfβ x hx).meromorphicOrderAt_nonneg
_ β€ meromorphicOrderAt (fβ + fβ) x :=
meromorphicOrderAt_add (hfβ x hx) (hfβ x hx).meromorphicAt
Β· suffices meromorphicOrderAt fβ x < meromorphicOrderAt fβ x by
rwa [meromorphicOrderAt_add_eq_left_of_lt (hfβ.meromorphicOn x hx)]
calc meromorphicOrderAt fβ x
_ < 0 := by simpa using h
_ β€ meromorphicOrderAt fβ x := (hfβ x hx).meromorphicOrderAt_nonneg
simp [hx]
/-- Adding an analytic function to a meromorphic one does not change the pole divisor. -/
theorem negPart_divisor_add_of_analyticNhdOn_left {fβ fβ : π β E} (hfβ : AnalyticOnNhd π fβ U)
(hfβ : MeromorphicOn fβ U) :
(divisor (fβ + fβ) U)β» = (divisor fβ U)β» := by
rw [add_comm]
exact negPart_divisor_add_of_analyticNhdOn_right hfβ hfβ
end MeromorphicOn |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/Complex.lean | import Mathlib.Analysis.Meromorphic.NormalForm
import Mathlib.Analysis.SpecialFunctions.Gamma.Beta
/-!
# The Gamma function is meromorphic
-/
open Set Complex
lemma MeromorphicNFOn.Gamma : MeromorphicNFOn Gamma univ :=
meromorphicNFOn_inv.mp <| AnalyticOnNhd.meromorphicNFOn <|
analyticOnNhd_univ_iff_differentiable.mpr differentiable_one_div_Gamma
lemma MeromorphicOn.Gamma : MeromorphicOn Gamma univ :=
MeromorphicNFOn.Gamma.meromorphicOn |
.lake/packages/mathlib/Mathlib/Analysis/Meromorphic/IsolatedZeros.lean | import Mathlib.Analysis.Meromorphic.Basic
/-!
# Principles of Isolated Zeros and Identity Principles for Meromorphic Functions
In line with results in `Mathlib.Analysis.Analytic.IsolatedZeros` and
`Mathlib.Analysis.Analytic.Uniqueness`, this file establishes principles of isolated zeros and
identity principles for meromorphic functions.
Compared to the results for analytic functions, the principles established here are a little more
complicated to state. This is because meromorphic functions can be modified at will along discrete
subsets and still remain meromorphic.
-/
variable
{π : Type*} [NontriviallyNormedField π]
{E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
{U : Set π} {x : π} {f g : π β E}
open Filter Topology
namespace MeromorphicAt
/-!
## Principles of Isolated Zeros
-/
/--
The principle of isolated zeros: If `f` is meromorphic at `x`, then `f` vanishes eventually in a
punctured neighborhood of `x` iff it vanishes frequently in punctured neighborhoods.
See `AnalyticAt.frequently_zero_iff_eventually_zero` for a stronger result in the analytic case.
-/
theorem frequently_zero_iff_eventuallyEq_zero (hf : MeromorphicAt f x) :
(βαΆ z in π[β ] x, f z = 0) β f =αΆ [π[β ] x] 0 :=
β¨hf.eventually_eq_zero_or_eventually_ne_zero.resolve_right, fun h β¦ h.frequentlyβ©
/--
Variant of the principle of isolated zeros: Let `U` be a subset of `π` and assume that `x β U` is
not an isolated point of `U`. If a function `f` is meromorphic at `x` and vanishes along a subset
that is codiscrete within `U`, then `f` vanishes in a punctured neighbourhood of `f`.
For a typical application, let `U` be a path in the complex plane and let `x` be one of the end
points. If `f` is meromorphic at `x` and vanishes on `U`, then it will vanish in a punctured
neighbourhood of `x`, which intersects `U` non-trivially but is not contained in `U`.
The assumption that `x` is not an isolated point of `U` is expressed as `AccPt x (π U)`. See
`accPt_iff_frequently` and `accPt_iff_frequently_nhdsNE` for useful reformulations.
-/
theorem eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin (hf : MeromorphicAt f x)
(hβx : x β U) (hβx : AccPt x (π U)) (h : f =αΆ [codiscreteWithin U] 0) :
f =αΆ [π[β ] x] 0 := by
rw [β hf.frequently_zero_iff_eventuallyEq_zero]
apply ((accPt_iff_frequently_nhdsNE.1 hβx).and_eventually
(mem_codiscreteWithin_iff_forall_mem_nhdsNE.1 h x hβx)).mp
filter_upwards
intro a
simp_rw [Pi.zero_apply]
rw [(by rfl : ({x | f x = 0} βͺ UαΆ) a β a β {x | f x = 0} βͺ UαΆ)]
simp_all
/-!
## Identity Principles
-/
/--
Formulation of `MeromorphicAt.frequently_zero_iff_eventuallyEq_zero` as an identity principle: If
`f` and `g` are meromorphic at `x`, then `f` and `g` agree eventually in a punctured neighborhood of
`x` iff they agree at points arbitrarily close to (but different from) `x`.
-/
theorem frequently_eq_iff_eventuallyEq (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) :
(βαΆ z in π[β ] x, f z = g z) β f =αΆ [π[β ] x] g := by
rw [eventuallyEq_iff_sub, β (hf.sub hg).frequently_zero_iff_eventuallyEq_zero]
simp_rw [Pi.sub_apply, sub_eq_zero]
/--
Formulation of `MeromorphicAt.eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin` as an
identity principle: Let `U` be a subset of `π` and assume that `x β U` is not an isolated point of
`U`. If function `f` and `g` are meromorphic at `x` and agree along a subset that is codiscrete
within `U`, then `f` and `g` agree in a punctured neighbourhood of `f`.
-/
theorem eventuallyEq_nhdsNE_of_eventuallyEq_codiscreteWithin (hf : MeromorphicAt f x)
(hg : MeromorphicAt g x) (hβx : x β U) (hβx : AccPt x (π U)) (h : f =αΆ [codiscreteWithin U] g) :
f =αΆ [π[β ] x] g := by
rw [eventuallyEq_iff_sub] at *
apply (hf.sub hg).eventuallyEq_zero_nhdsNE_of_eventuallyEq_zero_codiscreteWithin hβx hβx h
end MeromorphicAt |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/RCLike.lean | import Mathlib.Analysis.Normed.Module.RCLike.Basic
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/RieszLemma.lean | import Mathlib.Analysis.Normed.Module.RCLike.Real
import Mathlib.Analysis.Seminorm
import Mathlib.Topology.MetricSpace.HausdorffDistance
/-!
# Applications of the Hausdorff distance in normed spaces
Riesz's lemma, stated for a normed space over a normed field: for any
closed proper subspace `F` of `E`, there is a nonzero `x` such that `βx - Fβ`
is at least `r * βxβ` for any `r < 1`. This is `riesz_lemma`.
In a nontrivially normed field (with an element `c` of norm `> 1`) and any `R > βcβ`, one can
guarantee `βxβ β€ R` and `βx - yβ β₯ 1` for any `y` in `F`. This is `riesz_lemma_of_norm_lt`.
A further lemma, `Metric.closedBall_infDist_compl_subset_closure`, finds a *closed* ball within
the closure of a set `s` of optimal distance from a point in `x` to the frontier of `s`.
-/
open Set Metric
open Topology
variable {π : Type*} [NormedField π]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
variable {F : Type*} [SeminormedAddCommGroup F] [NormedSpace β F]
/-- Riesz's lemma, which usually states that it is possible to find a
vector with norm 1 whose distance to a closed proper subspace is
arbitrarily close to 1. The statement here is in terms of multiples of
norms, since in general the existence of an element of norm exactly 1
is not guaranteed. For a variant giving an element with norm in `[1, R]`, see
`riesz_lemma_of_norm_lt`. -/
theorem riesz_lemma {F : Subspace π E} (hFc : IsClosed (F : Set E)) (hF : β x : E, x β F) {r : β}
(hr : r < 1) : β xβ : E, xβ β F β§ β y β F, r * βxββ β€ βxβ - yβ := by
classical
obtain β¨x, hxβ© : β x : E, x β F := hF
let d := Metric.infDist x F
have hFn : (F : Set E).Nonempty := β¨_, F.zero_memβ©
have hdp : 0 < d :=
lt_of_le_of_ne Metric.infDist_nonneg fun heq =>
hx ((hFc.mem_iff_infDist_zero hFn).2 heq.symm)
let r' := max r 2β»ΒΉ
have hr' : r' < 1 := by
simp only [r', max_lt_iff, hr, true_and]
norm_num
have hlt : 0 < r' := lt_of_lt_of_le (by simp) (le_max_right r 2β»ΒΉ)
have hdlt : d < d / r' := (lt_div_iffβ hlt).mpr ((mul_lt_iff_lt_one_right hdp).2 hr')
obtain β¨yβ, hyβF, hxyββ© : β y β F, dist x y < d / r' := (Metric.infDist_lt_iff hFn).mp hdlt
have x_ne_yβ : x - yβ β F := by
by_contra h
have : x - yβ + yβ β F := F.add_mem h hyβF
simp only [neg_add_cancel_right, sub_eq_add_neg] at this
exact hx this
refine β¨x - yβ, x_ne_yβ, fun y hy => le_of_lt ?_β©
have hyβy : yβ + y β F := F.add_mem hyβF hy
calc
r * βx - yββ β€ r' * βx - yββ := by gcongr; apply le_max_left
_ < d := by
rw [β dist_eq_norm]
exact (lt_div_iffβ' hlt).1 hxyβ
_ β€ dist x (yβ + y) := Metric.infDist_le_dist_of_mem hyβy
_ = βx - yβ - yβ := by rw [sub_sub, dist_eq_norm]
/--
A version of Riesz lemma: given a strict closed subspace `F`, one may find an element of norm `β€ R`
which is at distance at least `1` of every element of `F`. Here, `R` is any given constant
strictly larger than the norm of an element of norm `> 1`. For a version without an `R`, see
`riesz_lemma`.
Since we are considering a general nontrivially normed field, there may be a gap in possible norms
(for instance no element of norm in `(1,2)`). Hence, we cannot allow `R` arbitrarily close to `1`,
and require `R > βcβ` for some `c : π` with norm `> 1`.
-/
theorem riesz_lemma_of_norm_lt {c : π} (hc : 1 < βcβ) {R : β} (hR : βcβ < R) {F : Subspace π E}
(hFc : IsClosed (F : Set E)) (hF : β x : E, x β F) :
β xβ : E, βxββ β€ R β§ β y β F, 1 β€ βxβ - yβ := by
have Rpos : 0 < R := (norm_nonneg _).trans_lt hR
have : βcβ / R < 1 := by
rw [div_lt_iffβ Rpos]
simpa using hR
rcases riesz_lemma hFc hF this with β¨x, xF, hxβ©
have x0 : x β 0 := fun H => by simp [H] at xF
obtain β¨d, d0, dxlt, ledx, -β© :
β d : π, d β 0 β§ βd β’ xβ < R β§ R / βcβ β€ βd β’ xβ β§ βdββ»ΒΉ β€ Rβ»ΒΉ * βcβ * βxβ :=
rescale_to_shell hc Rpos x0
refine β¨d β’ x, dxlt.le, fun y hy => ?_β©
set y' := dβ»ΒΉ β’ y
have yy' : y = d β’ y' := by simp [y', smul_smul, mul_inv_cancelβ d0]
calc
1 = βcβ / R * (R / βcβ) := by field
_ β€ βcβ / R * βd β’ xβ := by gcongr
_ = βdβ * (βcβ / R * βxβ) := by
simp only [norm_smul]
ring
_ β€ βdβ * βx - y'β := by gcongr; exact hx y' (by simp [y', Submodule.smul_mem _ _ hy])
_ = βd β’ x - yβ := by rw [yy', β smul_sub, norm_smul]
theorem Metric.closedBall_infDist_compl_subset_closure {x : F} {s : Set F} (hx : x β s) :
closedBall x (infDist x sαΆ) β closure s := by
rcases eq_or_ne (infDist x sαΆ) 0 with hβ | hβ
Β· rw [hβ, closedBall_zero']
exact closure_mono (singleton_subset_iff.2 hx)
Β· rw [β closure_ball x hβ]
exact closure_mono ball_infDist_compl_subset |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Int.lean | import Mathlib.Analysis.Normed.Ring.Int
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Pointwise.lean | import Mathlib.Analysis.Normed.Module.Ball.Pointwise
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/ENormedSpace.lean | import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.LinearAlgebra.Basis.VectorSpace
/-!
# Extended norm
**ATTENTION.** This file is deprecated. Mathlib now has classes `ENormed(Add)(Comm)Monoid` for
(additive) (commutative) monoids with an `ENorm`: this is very similar to this definition, but
much more general. Should the need arise, an enormed version of a normed space can be added later:
this will be different from this file.
In this file we define a structure `ENormedSpace π V` representing an extended norm (i.e., a norm
that can take the value `β`) on a vector space `V` over a normed field `π`. We do not use `class`
for an `ENormedSpace` because the same space can have more than one extended norm.
For example, the space of measurable functions `f : Ξ± β β` has a family of `L_p` extended norms.
We prove some basic inequalities, then define
* `EMetricSpace` structure on `V` corresponding to `e : ENormedSpace π V`;
* the subspace of vectors with finite norm, called `e.finiteSubspace`;
* a `NormedSpace` structure on this space.
The last definition is an instance because the type involves `e`.
## Implementation notes
We do not define extended normed groups. They can be added to the chain once someone will need them.
## Tags
normed space, extended norm
-/
noncomputable section
open ENNReal
/-- Extended norm on a vector space. As in the case of normed spaces, we require only
`βc β’ xβ β€ βcβ * βxβ` in the definition, then prove an equality in `map_smul`. -/
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
structure ENormedSpace (π : Type*) (V : Type*) [NormedField π] [AddCommGroup V] [Module π V] where
/-- the norm of an ENormedSpace, taking values into `ββ₯0β` -/
toFun : V β ββ₯0β
eq_zero' : β x, toFun x = 0 β x = 0
map_add_le' : β x y : V, toFun (x + y) β€ toFun x + toFun y
map_smul_le' : β (c : π) (x : V), toFun (c β’ x) β€ βcββ * toFun x
set_option linter.deprecated false
namespace ENormedSpace
variable {π : Type*} {V : Type*} [NormedField π] [AddCommGroup V] [Module π V]
(e : ENormedSpace π V)
attribute [coe] ENormedSpace.toFun
instance : CoeFun (ENormedSpace π V) fun _ => V β ββ₯0β :=
β¨ENormedSpace.toFunβ©
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem coeFn_injective : Function.Injective ((β) : ENormedSpace π V β V β ββ₯0β) := by
intro eβ eβ h
cases eβ
cases eβ
congr
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
ext]
theorem ext {eβ eβ : ENormedSpace π V} (h : β x, eβ x = eβ x) : eβ = eβ :=
coeFn_injective <| funext h
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
simp, norm_cast]
theorem coe_inj {eβ eβ : ENormedSpace π V} : (eβ : V β ββ₯0β) = eβ β eβ = eβ :=
coeFn_injective.eq_iff
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
simp]
theorem map_smul (c : π) (x : V) : e (c β’ x) = βcββ * e x := by
apply le_antisymm (e.map_smul_le' c x)
by_cases hc : c = 0
Β· simp [hc]
calc
(βcββ : ββ₯0β) * e x = βcββ * e (cβ»ΒΉ β’ c β’ x) := by rw [inv_smul_smulβ hc]
_ β€ βcββ * (βcβ»ΒΉββ * e (c β’ x)) := by grw [e.map_smul_le']
_ = e (c β’ x) := by
rw [β mul_assoc, nnnorm_inv, ENNReal.coe_inv, ENNReal.mul_inv_cancel _ ENNReal.coe_ne_top,
one_mul]
<;> simp [hc]
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
simp]
theorem map_zero : e 0 = 0 := by
rw [β zero_smul π (0 : V), e.map_smul]
simp
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
simp]
theorem eq_zero_iff {x : V} : e x = 0 β x = 0 :=
β¨e.eq_zero' x, fun h => h.symm βΈ e.map_zeroβ©
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
simp]
theorem map_neg (x : V) : e (-x) = e x :=
calc
e (-x) = β(-1 : π)ββ * e x := by rw [β map_smul, neg_one_smul]
_ = e x := by simp
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem map_sub_rev (x y : V) : e (x - y) = e (y - x) := by rw [β neg_sub, e.map_neg]
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem map_add_le (x y : V) : e (x + y) β€ e x + e y :=
e.map_add_le' x y
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem map_sub_le (x y : V) : e (x - y) β€ e x + e y :=
calc
e (x - y) = e (x + -y) := by rw [sub_eq_add_neg]
_ β€ e x + e (-y) := e.map_add_le x (-y)
_ = e x + e y := by rw [e.map_neg]
instance partialOrder : PartialOrder (ENormedSpace π V) where
le eβ eβ := β x, eβ x β€ eβ x
le_refl _ _ := le_rfl
le_trans _ _ _ hββ hββ x := le_trans (hββ x) (hββ x)
le_antisymm _ _ hββ hββ := ext fun x => le_antisymm (hββ x) (hββ x)
/-- The `ENormedSpace` sending each non-zero vector to infinity. -/
noncomputable instance : Top (ENormedSpace π V) :=
β¨{ toFun := fun x => open scoped Classical in if x = 0 then 0 else β€
eq_zero' := fun x => by split_ifs <;> simp [*]
map_add_le' := fun x y => by
split_ifs with hxy hx hy hy hx hy hy <;> try simp [*]
simp [hx, hy] at hxy
map_smul_le' := fun c x => by
split_ifs with hcx hx hx <;> simp only [smul_eq_zero, not_or] at hcx
Β· simp only [mul_zero, le_refl]
Β· have : c = 0 := by tauto
simp [this]
Β· tauto
Β· simpa [mul_top'] using hcx.1 }β©
noncomputable instance : Inhabited (ENormedSpace π V) :=
β¨β€β©
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem top_map {x : V} (hx : x β 0) : (β€ : ENormedSpace π V) x = β€ :=
if_neg hx
noncomputable instance : OrderTop (ENormedSpace π V) where
le_top e x := by obtain h | h := eq_or_ne x 0 <;> simp [top_map, h]
noncomputable instance : SemilatticeSup (ENormedSpace π V) where
sup := fun eβ eβ =>
{ toFun := fun x => max (eβ x) (eβ x)
eq_zero' := fun _ h => eβ.eq_zero_iff.1 (ENNReal.max_eq_zero_iff.1 h).1
map_add_le' := fun _ _ =>
max_le (le_trans (eβ.map_add_le _ _) <| add_le_add (le_max_left _ _) (le_max_left _ _))
(le_trans (eβ.map_add_le _ _) <| add_le_add (le_max_right _ _) (le_max_right _ _))
map_smul_le' := fun c x => le_of_eq <| by simp only [map_smul, mul_max] }
le_sup_left := fun _ _ _ => le_max_left _ _
le_sup_right := fun _ _ _ => le_max_right _ _
sup_le := fun _ _ _ hβ hβ x => max_le (hβ x) (hβ x)
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
simp, norm_cast]
theorem coe_max (eβ eβ : ENormedSpace π V) : β(eβ β eβ) = fun x => max (eβ x) (eβ x) :=
rfl
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07"),
norm_cast]
theorem max_map (eβ eβ : ENormedSpace π V) (x : V) : (eβ β eβ) x = max (eβ x) (eβ x) :=
rfl
/-- Structure of an `EMetricSpace` defined by an extended norm. -/
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
abbrev emetricSpace : EMetricSpace V where
edist x y := e (x - y)
edist_self x := by simp
eq_of_edist_eq_zero {x y} := by simp [sub_eq_zero]
edist_comm := e.map_sub_rev
edist_triangle x y z :=
calc
e (x - z) = e (x - y + (y - z)) := by rw [sub_add_sub_cancel]
_ β€ e (x - y) + e (y - z) := e.map_add_le (x - y) (y - z)
/-- The subspace of vectors with finite ENormedSpace. -/
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
def finiteSubspace : Subspace π V where
carrier := { x | e x < β€ }
zero_mem' := by simp
add_mem' {x y} hx hy := lt_of_le_of_lt (e.map_add_le x y) (ENNReal.add_lt_top.2 β¨hx, hyβ©)
smul_mem' c x (hx : _ < _) :=
calc
e (c β’ x) = βcββ * e x := e.map_smul c x
_ < β€ := ENNReal.mul_lt_top ENNReal.coe_lt_top hx
/-- Metric space structure on `e.finiteSubspace`. We use `EMetricSpace.toMetricSpace`
to ensure that this definition agrees with `e.emetricSpace`. -/
instance metricSpace : MetricSpace e.finiteSubspace := by
letI := e.emetricSpace
refine EMetricSpace.toMetricSpace fun x y => ?_
change e (x - y) β β€
exact ne_top_of_le_ne_top (ENNReal.add_lt_top.2 β¨x.2, y.2β©).ne (e.map_sub_le x y)
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem finite_dist_eq (x y : e.finiteSubspace) : dist x y = (e (x - y)).toReal :=
rfl
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem finite_edist_eq (x y : e.finiteSubspace) : edist x y = e (x - y) :=
rfl
/-- Normed group instance on `e.finiteSubspace`. -/
instance normedAddCommGroup : NormedAddCommGroup e.finiteSubspace :=
{ e.metricSpace with
norm := fun x => (e x).toReal
dist_eq := fun _ _ => rfl }
@[deprecated "Use ENormedAddCommMonoid or talk to the Carleson project" (since := "2025-05-07")]
theorem finite_norm_eq (x : e.finiteSubspace) : βxβ = (e x).toReal :=
rfl
/-- Normed space instance on `e.finiteSubspace`. -/
instance normedSpace : NormedSpace π e.finiteSubspace where
norm_smul_le c x := le_of_eq <| by simp [finite_norm_eq, ENNReal.toReal_mul]
end ENormedSpace |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/HomeomorphBall.lean | import Mathlib.Analysis.Normed.Module.Ball.Homeomorph
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/ConformalLinearMap.lean | import Mathlib.Analysis.Normed.Operator.Conformal
deprecated_module (since := "2025-09-16") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/IndicatorFunction.lean | import Mathlib.Analysis.Normed.Group.Indicator
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Normalize.lean | import Mathlib.Analysis.RCLike.Basic
import Mathlib.Data.Sign.Defs
/-!
# Normalized vector
Function that returns unit length vector that points in the same direction
(if the given vector is nonzero vector) or returns zero vector
(if the given vector is zero vector).
-/
variable {V : Type*} [NormedAddCommGroup V] [NormedSpace β V]
/-- For a nonzero vector `x`, `normalize x` is the unit-length vector that points
in the same direction as `x`. If `x = 0`, then `normalize x = 0`. -/
noncomputable def NormedSpace.normalize (x : V) : V := βxββ»ΒΉ β’ x
namespace NormedSpace
@[simp]
theorem normalize_zero_eq_zero : normalize (0 : V) = 0 := by
simp [normalize]
@[simp]
theorem normalize_eq_zero_iff (x : V) : normalize x = 0 β x = 0 := by
by_cases hx : x = 0 <;> simp [normalize, hx]
@[simp]
theorem norm_smul_normalize (x : V) : βxβ β’ normalize x = x := by
by_cases hx : x = 0 <;> simp [normalize, hx]
@[simp]
lemma norm_normalize_eq_one_iff {x : V} : βnormalize xβ = 1 β x β 0 := by
by_cases hx : x = 0 <;> simp [normalize, hx, norm_smul]
alias β¨_, norm_normalizeβ© := norm_normalize_eq_one_iff
lemma normalize_eq_self_of_norm_eq_one {x : V} (h : βxβ = 1) : normalize x = x := by
simp [normalize, h]
@[simp]
theorem normalize_normalize (x : V) : normalize (normalize x) = normalize x := by
by_cases hx : x = 0
Β· simp [hx]
Β· simp [normalize_eq_self_of_norm_eq_one, hx]
@[simp]
theorem normalize_neg (x : V) : normalize (- x) = - normalize x := by
simp [normalize]
theorem normalize_smul_of_pos {r : β} (hr : 0 < r) (x : V) :
normalize (r β’ x) = normalize x := by
simp [normalize, norm_smul, smul_smul, abs_of_pos hr, hr.ne']
theorem normalize_smul_of_neg {r : β} (hr : r < 0) (x : V) :
normalize (r β’ x) = - normalize x := by
simpa using normalize_smul_of_pos (show 0 < -r by linarith) (-x)
theorem normalize_smul (r : β) (x : V) :
normalize (r β’ x) = (SignType.sign r : β) β’ normalize x := by
rcases lt_trichotomy 0 r with (h_pos | rfl | h_neg)
Β· simp [normalize_smul_of_pos, h_pos]
Β· simp
Β· simp [normalize_smul_of_neg, h_neg]
end NormedSpace |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/SphereNormEquiv.lean | import Mathlib.Analysis.Normed.Module.Ball.RadialEquiv
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/BallAction.lean | import Mathlib.Analysis.Normed.Module.Ball.Action
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/MStructure.lean | import Mathlib.Algebra.Ring.Idempotent
import Mathlib.Analysis.Normed.Group.Basic
import Mathlib.Order.Basic
import Mathlib.Tactic.NoncommRing
/-!
# M-structure
A projection P on a normed space X is said to be an L-projection (`IsLprojection`) if, for all `x`
in `X`,
$\|x\| = \|P x\| + \|(1 - P) x\|$.
A projection P on a normed space X is said to be an M-projection if, for all `x` in `X`,
$\|x\| = max(\|P x\|,\|(1 - P) x\|)$.
The L-projections on `X` form a Boolean algebra (`IsLprojection.Subtype.BooleanAlgebra`).
## TODO (Motivational background)
The M-projections on a normed space form a Boolean algebra.
The range of an L-projection on a normed space `X` is said to be an L-summand of `X`. The range of
an M-projection is said to be an M-summand of `X`.
When `X` is a Banach space, the Boolean algebra of L-projections is complete. Let `X` be a normed
space with dual `X^*`. A closed subspace `M` of `X` is said to be an M-ideal if the topological
annihilator `M^β` is an L-summand of `X^*`.
M-ideal, M-summands and L-summands were introduced by Alfsen and Effros in [alfseneffros1972] to
study the structure of general Banach spaces. When `A` is a JB*-triple, the M-ideals of `A` are
exactly the norm-closed ideals of `A`. When `A` is a JBW*-triple with predual `X`, the M-summands of
`A` are exactly the weak*-closed ideals, and their pre-duals can be identified with the L-summands
of `X`. In the special case when `A` is a C*-algebra, the M-ideals are exactly the norm-closed
two-sided ideals of `A`, when `A` is also a W*-algebra the M-summands are exactly the weak*-closed
two-sided ideals of `A`.
## Implementation notes
The approach to showing that the L-projections form a Boolean algebra is inspired by
`MeasureTheory.MeasurableSpace`.
Instead of using `P : X βL[π] X` to represent projections, we use an arbitrary ring `M` with a
faithful action on `X`. `ContinuousLinearMap.apply_module` can be used to recover the `X βL[π] X`
special case.
## References
* [Behrends, M-structure and the Banach-Stone Theorem][behrends1979]
* [Harmand, Werner, Werner, M-ideals in Banach spaces and Banach algebras][harmandwernerwerner1993]
## Tags
M-summand, M-projection, L-summand, L-projection, M-ideal, M-structure
-/
variable (X : Type*) [NormedAddCommGroup X]
variable {M : Type*} [Ring M] [Module M X]
/-- A projection on a normed space `X` is said to be an L-projection if, for all `x` in `X`,
$\|x\| = \|P x\| + \|(1 - P) x\|$.
Note that we write `P β’ x` instead of `P x` for reasons described in the module docstring.
-/
structure IsLprojection (P : M) : Prop where
proj : IsIdempotentElem P
Lnorm : β x : X, βxβ = βP β’ xβ + β(1 - P) β’ xβ
/-- A projection on a normed space `X` is said to be an M-projection if, for all `x` in `X`,
$\|x\| = max(\|P x\|,\|(1 - P) x\|)$.
Note that we write `P β’ x` instead of `P x` for reasons described in the module docstring.
-/
structure IsMprojection (P : M) : Prop where
proj : IsIdempotentElem P
Mnorm : β x : X, βxβ = max βP β’ xβ β(1 - P) β’ xβ
variable {X}
namespace IsLprojection
-- TODO: The literature always uses uppercase 'L' for L-projections
theorem Lcomplement {P : M} (h : IsLprojection X P) : IsLprojection X (1 - P) :=
β¨h.proj.one_sub, fun x => by
rw [add_comm, sub_sub_cancel]
exact h.Lnorm xβ©
theorem Lcomplement_iff (P : M) : IsLprojection X P β IsLprojection X (1 - P) :=
β¨Lcomplement, fun h => sub_sub_cancel 1 P βΈ h.Lcomplementβ©
theorem commute [FaithfulSMul M X] {P Q : M} (hβ : IsLprojection X P) (hβ : IsLprojection X Q) :
Commute P Q := by
have PR_eq_RPR : β R : M, IsLprojection X R β P * R = R * P * R := fun R hβ => by
refine @eq_of_smul_eq_smul _ X _ _ _ _ fun x => by
rw [β norm_sub_eq_zero_iff]
have e1 : βR β’ xβ β₯ βR β’ xβ + 2 β’ β(P * R) β’ x - (R * P * R) β’ xβ :=
calc
βR β’ xβ = βR β’ P β’ R β’ xβ + β(1 - R) β’ P β’ R β’ xβ +
(β(R * R) β’ x - R β’ P β’ R β’ xβ + β(1 - R) β’ (1 - P) β’ R β’ xβ) := by
rw [hβ.Lnorm, hβ.Lnorm, hβ.Lnorm ((1 - P) β’ R β’ x), sub_smul 1 P, one_smul, smul_sub,
mul_smul]
_ = βR β’ P β’ R β’ xβ + β(1 - R) β’ P β’ R β’ xβ +
(βR β’ x - R β’ P β’ R β’ xβ + β((1 - R) * R) β’ x - (1 - R) β’ P β’ R β’ xβ) := by
rw [hβ.proj.eq, sub_smul 1 P, one_smul, smul_sub, mul_smul]
_ = βR β’ P β’ R β’ xβ + β(1 - R) β’ P β’ R β’ xβ +
(βR β’ x - R β’ P β’ R β’ xβ + β(1 - R) β’ P β’ R β’ xβ) := by
rw [sub_mul, hβ.proj.eq, one_mul, sub_self, zero_smul, zero_sub, norm_neg]
_ = βR β’ P β’ R β’ xβ + βR β’ x - R β’ P β’ R β’ xβ + 2 β’ β(1 - R) β’ P β’ R β’ xβ := by abel
_ β₯ βR β’ xβ + 2 β’ β(P * R) β’ x - (R * P * R) β’ xβ := by
rw [ge_iff_le]
have :=
add_le_add_right (norm_le_insert' (R β’ x) (R β’ P β’ R β’ x)) (2 β’ β(1 - R) β’ P β’ R β’ xβ)
simpa only [mul_smul, sub_smul, one_smul] using this
rw [ge_iff_le] at e1
nth_rewrite 2 [β add_zero βR β’ xβ] at e1
rw [add_le_add_iff_left, two_smul, β two_mul] at e1
rw [le_antisymm_iff]
refine β¨?_, norm_nonneg _β©
rwa [β mul_zero (2 : β), mul_le_mul_iff_rightβ (show (0 : β) < 2 by simp)] at e1
have QP_eq_QPQ : Q * P = Q * P * Q := by
have e1 : P * (1 - Q) = P * (1 - Q) - (Q * P - Q * P * Q) :=
calc
P * (1 - Q) = (1 - Q) * P * (1 - Q) := by rw [PR_eq_RPR (1 - Q) hβ.Lcomplement]
_ = P * (1 - Q) - (Q * P - Q * P * Q) := by noncomm_ring
rwa [eq_sub_iff_add_eq, add_eq_left, sub_eq_zero] at e1
change P * Q = Q * P
rw [QP_eq_QPQ, PR_eq_RPR Q hβ]
theorem mul [FaithfulSMul M X] {P Q : M} (hβ : IsLprojection X P) (hβ : IsLprojection X Q) :
IsLprojection X (P * Q) := by
refine β¨IsIdempotentElem.mul_of_commute (hβ.commute hβ) hβ.proj hβ.proj, ?_β©
intro x
refine le_antisymm ?_ ?_
Β· calc
βxβ = β(P * Q) β’ x + (x - (P * Q) β’ x)β := by rw [add_sub_cancel ((P * Q) β’ x) x]
_ β€ β(P * Q) β’ xβ + βx - (P * Q) β’ xβ := by apply norm_add_le
_ = β(P * Q) β’ xβ + β(1 - P * Q) β’ xβ := by rw [sub_smul, one_smul]
Β· calc
βxβ = βP β’ Q β’ xβ + (βQ β’ x - P β’ Q β’ xβ + βx - Q β’ xβ) := by
rw [hβ.Lnorm x, hβ.Lnorm (Q β’ x), sub_smul, one_smul, sub_smul, one_smul, add_assoc]
_ β₯ βP β’ Q β’ xβ + βQ β’ x - P β’ Q β’ x + (x - Q β’ x)β :=
((add_le_add_iff_left βP β’ Q β’ xβ).mpr (norm_add_le (Q β’ x - P β’ Q β’ x) (x - Q β’ x)))
_ = β(P * Q) β’ xβ + β(1 - P * Q) β’ xβ := by
rw [sub_add_sub_cancel', sub_smul, one_smul, mul_smul]
theorem join [FaithfulSMul M X] {P Q : M} (hβ : IsLprojection X P) (hβ : IsLprojection X Q) :
IsLprojection X (P + Q - P * Q) := by
convert (Lcomplement_iff _).mp (hβ.Lcomplement.mul hβ.Lcomplement) using 1
noncomm_ring
instance Subtype.hasCompl : HasCompl { f : M // IsLprojection X f } :=
β¨fun P => β¨1 - P, P.prop.Lcomplementβ©β©
@[simp]
theorem coe_compl (P : { P : M // IsLprojection X P }) : βPαΆ = (1 : M) - βP :=
rfl
instance Subtype.inf [FaithfulSMul M X] : Min { P : M // IsLprojection X P } :=
β¨fun P Q => β¨P * Q, P.prop.mul Q.propβ©β©
@[simp]
theorem coe_inf [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
β(P β Q) = (βP : M) * βQ :=
rfl
instance Subtype.sup [FaithfulSMul M X] : Max { P : M // IsLprojection X P } :=
β¨fun P Q => β¨P + Q - P * Q, P.prop.join Q.propβ©β©
@[simp]
theorem coe_sup [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
β(P β Q) = (βP : M) + βQ - βP * βQ :=
rfl
instance Subtype.sdiff [FaithfulSMul M X] : SDiff { P : M // IsLprojection X P } :=
β¨fun P Q => β¨P * (1 - Q), P.prop.mul Q.prop.Lcomplementβ©β©
@[simp]
theorem coe_sdiff [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
β(P \ Q) = (βP : M) * (1 - βQ) :=
rfl
instance Subtype.partialOrder [FaithfulSMul M X] :
PartialOrder { P : M // IsLprojection X P } where
le P Q := (βP : M) = β(P β Q)
le_refl P := by simpa only [coe_inf, β sq] using P.prop.proj.eq.symm
le_trans P Q R hβ hβ := by
simp only [coe_inf] at hβ hβ β’
rw [hβ, mul_assoc, β hβ]
le_antisymm P Q hβ hβ := Subtype.eq (by convert (P.prop.commute Q.prop).eq)
theorem le_def [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
P β€ Q β (P : M) = β(P β Q) :=
Iff.rfl
instance Subtype.zero : Zero { P : M // IsLprojection X P } :=
β¨β¨0, β¨by rw [IsIdempotentElem, zero_mul], fun x => by
simp only [zero_smul, norm_zero, sub_zero, one_smul, zero_add]β©β©β©
@[simp]
theorem coe_zero : β(0 : { P : M // IsLprojection X P }) = (0 : M) :=
rfl
instance Subtype.one : One { P : M // IsLprojection X P } :=
β¨β¨1, sub_zero (1 : M) βΈ (0 : { P : M // IsLprojection X P }).prop.Lcomplementβ©β©
@[simp]
theorem coe_one : β(1 : { P : M // IsLprojection X P }) = (1 : M) :=
rfl
instance Subtype.boundedOrder [FaithfulSMul M X] :
BoundedOrder { P : M // IsLprojection X P } where
top := 1
le_top P := (mul_one (P : M)).symm
bot := 0
bot_le P := (zero_mul (P : M)).symm
@[simp]
theorem coe_bot [FaithfulSMul M X] :
β(BoundedOrder.toOrderBot.toBot.bot : { P : M // IsLprojection X P }) = (0 : M) :=
rfl
@[simp]
theorem coe_top [FaithfulSMul M X] :
β(BoundedOrder.toOrderTop.toTop.top : { P : M // IsLprojection X P }) = (1 : M) :=
rfl
theorem compl_mul {P : { P : M // IsLprojection X P }} {Q : M} : βPαΆ * Q = Q - βP * Q := by
rw [coe_compl, sub_mul, one_mul]
theorem mul_compl_self {P : { P : M // IsLprojection X P }} : (βP : M) * βPαΆ = 0 := by
rw [coe_compl, P.prop.proj.mul_one_sub_self]
theorem distrib_lattice_lemma [FaithfulSMul M X] {P Q R : { P : M // IsLprojection X P }} :
((βP : M) + βPαΆ * R) * (βP + βQ * βR * βPαΆ) = βP + βQ * βR * βPαΆ := by
rw [add_mul, mul_add, mul_add, (mul_assoc _ (R : M) (βQ * βR * βPαΆ)),
β mul_assoc (R : M) (βQ * βR) _, β coe_inf Q, (PαΆ.prop.commute R.prop).eq,
((Q β R).prop.commute PαΆ.prop).eq, (R.prop.commute (Q β R).prop).eq, coe_inf Q,
mul_assoc (Q : M), β mul_assoc, mul_assoc (R : M), (PαΆ.prop.commute P.prop).eq, mul_compl_self,
zero_mul, mul_zero, zero_add, add_zero, β mul_assoc, P.prop.proj.eq,
R.prop.proj.eq, β coe_inf Q, mul_assoc, ((Q β R).prop.commute PαΆ.prop).eq, β mul_assoc,
PαΆ.prop.proj.eq]
/- This instance was created as an auxiliary definition when defining `Subtype.distribLattice`
all at once would cause a timeout. That is no longer the case. Keeping this as a useful shortcut.
-/
instance [FaithfulSMul M X] : Lattice { P : M // IsLprojection X P } where
sup := max
inf := min
le_sup_left P Q := by
rw [le_def, coe_inf, coe_sup, β add_sub, mul_add, mul_sub, β mul_assoc, P.prop.proj.eq,
sub_self, add_zero]
le_sup_right P Q := by
rw [le_def, coe_inf, coe_sup, β add_sub, mul_add, mul_sub, (P.prop.commute Q.prop).eq,
β mul_assoc, Q.prop.proj.eq, add_sub_cancel]
sup_le P Q R := by
rw [le_def, le_def, le_def, coe_inf, coe_inf, coe_sup, coe_inf, coe_sup, β add_sub, add_mul,
sub_mul, mul_assoc]
intro hβ hβ
rw [β hβ, β hβ]
inf_le_left P Q := by
rw [le_def, coe_inf, coe_inf, coe_inf, mul_assoc, (Q.prop.commute P.prop).eq, β mul_assoc,
P.prop.proj.eq]
inf_le_right P Q := by rw [le_def, coe_inf, coe_inf, coe_inf, mul_assoc, Q.prop.proj.eq]
le_inf P Q R := by
rw [le_def, le_def, le_def, coe_inf, coe_inf, coe_inf, coe_inf, β mul_assoc]
intro hβ hβ
rw [β hβ, β hβ]
instance Subtype.distribLattice [FaithfulSMul M X] :
DistribLattice { P : M // IsLprojection X P } where
le_sup_inf P Q R := by
have eβ : β((P β Q) β (P β R)) = βP + βQ * (R : M) * βPαΆ := by
rw [coe_inf, coe_sup, coe_sup, β add_sub, β add_sub, β compl_mul, β compl_mul, add_mul,
mul_add, (PαΆ.prop.commute Q.prop).eq, mul_add, β mul_assoc, mul_assoc (Q : M),
(PαΆ.prop.commute P.prop).eq, mul_compl_self, zero_mul, mul_zero,
zero_add, add_zero, β mul_assoc, mul_assoc (Q : M), P.prop.proj.eq, PαΆ.prop.proj.eq,
mul_assoc, (PαΆ.prop.commute R.prop).eq, β mul_assoc]
have eβ : β((P β Q) β (P β R)) * β(P β Q β R) = (P : M) + βQ * βR * βPαΆ := by
rw [coe_inf, coe_sup, coe_sup, coe_sup, β add_sub, β add_sub, β add_sub, β compl_mul, β
compl_mul, β compl_mul, (PαΆ.prop.commute (Q β R).prop).eq, coe_inf, mul_assoc,
distrib_lattice_lemma, (Q.prop.commute R.prop).eq, distrib_lattice_lemma]
rw [le_def, eβ, coe_inf, eβ]
instance Subtype.BooleanAlgebra [FaithfulSMul M X] :
BooleanAlgebra { P : M // IsLprojection X P } :=
{ IsLprojection.Subtype.hasCompl,
IsLprojection.Subtype.sdiff,
IsLprojection.Subtype.boundedOrder with
inf_compl_le_bot := fun P =>
(Subtype.ext (by rw [coe_inf, coe_compl, coe_bot, β coe_compl, mul_compl_self])).le
top_le_sup_compl := fun P =>
(Subtype.ext
(by
rw [coe_top, coe_sup, coe_compl, add_sub_cancel, β coe_compl, mul_compl_self,
sub_zero])).le
sdiff_eq := fun P Q => Subtype.ext <| by rw [coe_sdiff, β coe_compl, coe_inf] }
end IsLprojection |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Connected.lean | import Mathlib.Analysis.Convex.Contractible
import Mathlib.Analysis.Convex.Topology
import Mathlib.Analysis.Normed.Module.Convex
import Mathlib.LinearAlgebra.Dimension.DivisionRing
import Mathlib.Topology.Algebra.Module.Cardinality
/-!
# Connectedness of subsets of vector spaces
We show several results related to the (path)-connectedness of subsets of real vector spaces:
* `Set.Countable.isPathConnected_compl_of_one_lt_rank` asserts that the complement of a countable
set is path-connected in a space of dimension `> 1`.
* `isPathConnected_compl_singleton_of_one_lt_rank` is the special case of the complement of a
singleton.
* `isPathConnected_sphere` shows that any sphere is path-connected in dimension `> 1`.
* `isPathConnected_compl_of_one_lt_codim` shows that the complement of a subspace
of codimension `> 1` is path-connected.
Statements with connectedness instead of path-connectedness are also given.
-/
assert_not_exists Subgroup.index Nat.divisors
-- TODO assert_not_exists Cardinal
open Convex Set Metric
section TopologicalVectorSpace
variable {E : Type*} [AddCommGroup E] [Module β E]
[TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul β E]
/-- In a real vector space of dimension `> 1`, the complement of any countable set is path
connected. -/
theorem Set.Countable.isPathConnected_compl_of_one_lt_rank
(h : 1 < Module.rank β E) {s : Set E} (hs : s.Countable) :
IsPathConnected sαΆ := by
have : Nontrivial E := (rank_pos_iff_nontrivial (R := β)).1 (zero_lt_one.trans h)
-- the set `sαΆ` is dense, therefore nonempty. Pick `a β sαΆ`. We have to show that any
-- `b β sαΆ` can be joined to `a`.
obtain β¨a, haβ© : sαΆ.Nonempty := (hs.dense_compl β).nonempty
refine β¨a, ha, ?_β©
intro b hb
rcases eq_or_ne a b with rfl | hab
Β· exact JoinedIn.refl ha
/- Assume `b β a`. Write `a = c - x` and `b = c + x` for some nonzero `x`. Choose `y` which
is linearly independent from `x`. Then the segments joining `a = c - x` to `c + ty` are pairwise
disjoint for varying `t` (except for the endpoint `a`) so only countably many of them can
intersect `s`. In the same way, there are countably many `t`s for which the segment
from `b = c + x` to `c + ty` intersects `s`. Choosing `t` outside of these countable exceptions,
one gets a path in the complement of `s` from `a` to `z = c + ty` and then to `b`.
-/
let c := (2 : β)β»ΒΉ β’ (a + b)
let x := (2 : β)β»ΒΉ β’ (b - a)
have Ia : c - x = a := by
simp only [c, x]
module
have Ib : c + x = b := by
simp only [c, x]
module
have x_ne_zero : x β 0 := by simpa [x] using sub_ne_zero.2 hab.symm
obtain β¨y, hyβ© : β y, LinearIndependent β ![x, y] :=
exists_linearIndependent_pair_of_one_lt_rank h x_ne_zero
have A : Set.Countable {t : β | ([c + x -[β] c + t β’ y] β© s).Nonempty} := by
apply countable_setOf_nonempty_of_disjoint _ (fun t β¦ inter_subset_right) hs
intro t t' htt'
apply disjoint_iff_inter_eq_empty.2
have N : {c + x} β© s = β
:= by
simpa only [singleton_inter_eq_empty, mem_compl_iff, Ib] using hb
rw [inter_assoc, inter_comm s, inter_assoc, inter_self, β inter_assoc, β subset_empty_iff, β N]
apply inter_subset_inter_left
apply Eq.subset
apply segment_inter_eq_endpoint_of_linearIndependent_of_ne hy htt'.symm
have B : Set.Countable {t : β | ([c - x -[β] c + t β’ y] β© s).Nonempty} := by
apply countable_setOf_nonempty_of_disjoint _ (fun t β¦ inter_subset_right) hs
intro t t' htt'
apply disjoint_iff_inter_eq_empty.2
have N : {c - x} β© s = β
:= by
simpa only [singleton_inter_eq_empty, mem_compl_iff, Ia] using ha
rw [inter_assoc, inter_comm s, inter_assoc, inter_self, β inter_assoc, β subset_empty_iff, β N]
apply inter_subset_inter_left
rw [sub_eq_add_neg _ x]
apply Eq.subset
apply segment_inter_eq_endpoint_of_linearIndependent_of_ne _ htt'.symm
convert hy.units_smul ![-1, 1]
simp [β List.ofFn_inj]
obtain β¨t, htβ© : Set.Nonempty ({t : β | ([c + x -[β] c + t β’ y] β© s).Nonempty}
βͺ {t : β | ([c - x -[β] c + t β’ y] β© s).Nonempty})αΆ := ((A.union B).dense_compl β).nonempty
let z := c + t β’ y
simp only [compl_union, mem_inter_iff, mem_compl_iff, mem_setOf_eq, not_nonempty_iff_eq_empty]
at ht
have JA : JoinedIn sαΆ a z := by
apply JoinedIn.of_segment_subset
rw [subset_compl_iff_disjoint_right, disjoint_iff_inter_eq_empty]
convert ht.2
exact Ia.symm
have JB : JoinedIn sαΆ b z := by
apply JoinedIn.of_segment_subset
rw [subset_compl_iff_disjoint_right, disjoint_iff_inter_eq_empty]
convert ht.1
exact Ib.symm
exact JA.trans JB.symm
/-- In a real vector space of dimension `> 1`, the complement of any countable set is
connected. -/
theorem Set.Countable.isConnected_compl_of_one_lt_rank (h : 1 < Module.rank β E) {s : Set E}
(hs : s.Countable) : IsConnected sαΆ :=
(hs.isPathConnected_compl_of_one_lt_rank h).isConnected
/-- In a real vector space of dimension `> 1`, the complement of any singleton is path-connected. -/
theorem isPathConnected_compl_singleton_of_one_lt_rank (h : 1 < Module.rank β E) (x : E) :
IsPathConnected {x}αΆ :=
Set.Countable.isPathConnected_compl_of_one_lt_rank h (countable_singleton x)
/-- In a real vector space of dimension `> 1`, the complement of a singleton is connected. -/
theorem isConnected_compl_singleton_of_one_lt_rank (h : 1 < Module.rank β E) (x : E) :
IsConnected {x}αΆ :=
(isPathConnected_compl_singleton_of_one_lt_rank h x).isConnected
end TopologicalVectorSpace
section NormedSpace
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace β E]
section Ball
namespace Metric
theorem ball_contractible {x : E} {r : β} (hr : 0 < r) :
ContractibleSpace (ball x r) :=
Convex.contractibleSpace (convex_ball _ _) (by simpa)
theorem eball_contractible {x : E} {r : ENNReal} (hr : 0 < r) :
ContractibleSpace (EMetric.ball x r) := by
cases r with
| top =>
rw [eball_top_eq_univ, (Homeomorph.Set.univ E).contractibleSpace_iff]
exact RealTopologicalVectorSpace.contractibleSpace
| coe r =>
rw [emetric_ball_nnreal]
apply ball_contractible
simpa using hr
theorem isPathConnected_ball {x : E} {r : β} (hr : 0 < r) :
IsPathConnected (ball x r) := by
rw [isPathConnected_iff_pathConnectedSpace]
exact @ContractibleSpace.instPathConnectedSpace _ _ (ball_contractible hr)
theorem isPathConnected_eball {x : E} {r : ENNReal} (hr : 0 < r) :
IsPathConnected (EMetric.ball x r) := by
rw [isPathConnected_iff_pathConnectedSpace]
exact @ContractibleSpace.instPathConnectedSpace _ _ (eball_contractible hr)
theorem isConnected_ball {x : E} {r : β} (hr : 0 < r) :
IsConnected (ball x r) :=
(isPathConnected_ball hr).isConnected
theorem isConnected_eball {x : E} {r : ENNReal} (hr : 0 < r) :
IsConnected (EMetric.ball x r) :=
(isPathConnected_eball hr).isConnected
end Metric
end Ball
/-- In a real vector space of dimension `> 1`, any sphere of nonnegative radius is
path connected. -/
theorem isPathConnected_sphere (h : 1 < Module.rank β E) (x : E) {r : β} (hr : 0 β€ r) :
IsPathConnected (sphere x r) := by
/- when `r > 0`, we write the sphere as the image of `{0}αΆ` under the map
`y β¦ x + (r * βyββ»ΒΉ) β’ y`. Since the image under a continuous map of a path connected set
is path connected, this concludes the proof. -/
rcases hr.eq_or_lt with rfl | rpos
Β· simpa using isPathConnected_singleton x
let f : E β E := fun y β¦ x + (r * βyββ»ΒΉ) β’ y
have A : ContinuousOn f {0}αΆ := by
intro y hy
apply (continuousAt_const.add _).continuousWithinAt
apply (continuousAt_const.mul (ContinuousAt.invβ continuousAt_id.norm ?_)).smul continuousAt_id
simpa using hy
have B : IsPathConnected ({0}αΆ : Set E) := isPathConnected_compl_singleton_of_one_lt_rank h 0
have C : IsPathConnected (f '' {0}αΆ) := B.image' A
have : f '' {0}αΆ = sphere x r := by
apply Subset.antisymm
Β· rintro - β¨y, hy, rflβ©
have : βyβ β 0 := by simpa using hy
simp [f, norm_smul, abs_of_nonneg hr, mul_assoc, inv_mul_cancelβ this]
Β· intro y hy
refine β¨y - x, ?_, ?_β©
Β· intro H
simp only [mem_singleton_iff, sub_eq_zero] at H
simp only [H, mem_sphere_iff_norm, sub_self, norm_zero] at hy
exact rpos.ne hy
Β· simp [f, mem_sphere_iff_norm.1 hy, mul_inv_cancelβ rpos.ne']
rwa [this] at C
/-- In a real vector space of dimension `> 1`, any sphere of nonnegative radius is connected. -/
theorem isConnected_sphere (h : 1 < Module.rank β E) (x : E) {r : β} (hr : 0 β€ r) :
IsConnected (sphere x r) :=
(isPathConnected_sphere h x hr).isConnected
/-- In a real vector space of dimension `> 1`, any sphere is preconnected. -/
theorem isPreconnected_sphere (h : 1 < Module.rank β E) (x : E) (r : β) :
IsPreconnected (sphere x r) := by
rcases le_or_gt 0 r with hr|hr
Β· exact (isConnected_sphere h x hr).isPreconnected
Β· simpa [hr] using isPreconnected_empty
end NormedSpace
section
variable {F : Type*} [AddCommGroup F] [Module β F] [TopologicalSpace F]
[IsTopologicalAddGroup F] [ContinuousSMul β F]
/-- Let `E` be a linear subspace in a real vector space.
If `E` has codimension at least two, its complement is path-connected. -/
theorem isPathConnected_compl_of_one_lt_codim {E : Submodule β F}
(hcodim : 1 < Module.rank β (F β§Έ E)) : IsPathConnected (EαΆ : Set F) := by
rcases E.exists_isCompl with β¨E', hE'β©
refine isPathConnected_compl_of_isPathConnected_compl_zero hE'.symm
(isPathConnected_compl_singleton_of_one_lt_rank ?_ 0)
rwa [β (E.quotientEquivOfIsCompl E' hE').rank_eq]
/-- Let `E` be a linear subspace in a real vector space.
If `E` has codimension at least two, its complement is connected. -/
theorem isConnected_compl_of_one_lt_codim {E : Submodule β F} (hcodim : 1 < Module.rank β (F β§Έ E)) :
IsConnected (EαΆ : Set F) :=
(isPathConnected_compl_of_one_lt_codim hcodim).isConnected
theorem Submodule.connectedComponentIn_eq_self_of_one_lt_codim (E : Submodule β F)
(hcodim : 1 < Module.rank β (F β§Έ E)) {x : F} (hx : x β E) :
connectedComponentIn ((E : Set F)αΆ) x = (E : Set F)αΆ :=
(isConnected_compl_of_one_lt_codim hcodim).2.connectedComponentIn hx
end |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/FunctionSeries.lean | import Mathlib.Analysis.Normed.Group.FunctionSeries
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/MultipliableUniformlyOn.lean | import Mathlib.Analysis.Normed.Group.FunctionSeries
import Mathlib.Analysis.SpecialFunctions.Log.Summable
import Mathlib.Topology.Algebra.InfiniteSum.UniformOn
import Mathlib.Topology.Algebra.IsUniformGroup.Order
/-!
# Uniform convergence of products of functions
We gather some results about the uniform convergence of infinite products, in particular those of
the form `β' i, (1 + f i x)` for a sequence `f` of complex-valued functions.
-/
open Filter Function Complex Finset Topology
variable {Ξ± ΞΉ : Type*} {π : Set (Set Ξ±)} {K : Set Ξ±} {u : ΞΉ β β}
section Complex
variable {f : ΞΉ β Ξ± β β}
lemma TendstoUniformlyOn.comp_cexp {p : Filter ΞΉ} {g : Ξ± β β}
(hf : TendstoUniformlyOn f g p K) (hg : BddAbove <| (fun x β¦ (g x).re) '' K) :
TendstoUniformlyOn (cexp β f Β·) (cexp β g) p K := by
obtain β¨v, hvβ© : β v, β x β K, (g x).re β€ v := hg.imp <| by simp [mem_upperBounds]
have : βαΆ i in p, β x β K, (f i x).re β€ v + 1 := hf.re.eventually_forall_le (lt_add_one v) hv
refine (UniformContinuousOn.cexp _).comp_tendstoUniformlyOn_eventually (by simpa) ?_ hf
exact fun x hx β¦ (hv x hx).trans (lt_add_one v).le
lemma Summable.hasSumUniformlyOn_log_one_add (hu : Summable u)
(h : βαΆ i in cofinite, β x β K, βf i xβ β€ u i) :
HasSumUniformlyOn (fun i x β¦ log (1 + f i x)) (fun x β¦ β' i, log (1 + f i x)) {K} := by
simp only [hasSumUniformlyOn_iff_tendstoUniformlyOn, Set.mem_singleton_iff, forall_eq]
apply tendstoUniformlyOn_tsum_of_cofinite_eventually <| hu.mul_left (3 / 2)
filter_upwards [h, hu.tendsto_cofinite_zero.eventually_le_const one_half_pos] with i hi hi' x hx
using (norm_log_one_add_half_le_self <| (hi x hx).trans hi').trans (by simpa using hi x hx)
lemma Summable.tendstoUniformlyOn_tsum_nat_log_one_add {f : β β Ξ± β β} {u : β β β}
(hu : Summable u) (h : βαΆ n in atTop, β x β K, βf n xβ β€ u n) :
TendstoUniformlyOn (fun n x β¦ β m β Finset.range n, log (1 + f m x))
(fun x β¦ β' n, log (1 + f n x)) atTop K := by
rw [β Nat.cofinite_eq_atTop] at h
exact (hu.hasSumUniformlyOn_log_one_add h).tendstoUniformlyOn_finsetRange rfl
/-- If `x β¦ β' i, log (f i x)` is uniformly convergent on `π`, its sum has bounded-above real part
on each set in `π`, and the functions `f i x` have no zeroes, then `β' i, f i x` is uniformly
convergent on `π`.
Note that the non-vanishing assumption is really needed here: if this assumption is dropped then
one obtains a counterexample if `ΞΉ = Ξ± = β` and `f i x` is `0` if `i = x` and `1` otherwise. -/
lemma hasProdUniformlyOn_of_clog (hf : SummableUniformlyOn (fun i x β¦ log (f i x)) π)
(hfn : β K β π, β x β K, β i, f i x β 0)
(hg : β K β π, BddAbove <| (fun x β¦ (β' i, log (f i x)).re) '' K) :
HasProdUniformlyOn f (fun x β¦ β' i, f i x) π := by
simp only [hasProdUniformlyOn_iff_tendstoUniformlyOn]
obtain β¨r, hrβ© := hf.exists
intro K hK
suffices H : TendstoUniformlyOn (fun s x β¦ β i β s, f i x) (cexp β r) atTop K by
refine H.congr_right ((hr.tsum_eqOn hK).comp_left.symm.trans ?_)
exact fun x hx β¦ (cexp_tsum_eq_tprod (hfn K hK x hx) (hf.summable hK hx))
have h1 := hr.tsum_eqOn hK
simp only [hasSumUniformlyOn_iff_tendstoUniformlyOn] at hr
refine ((hr K hK).comp_cexp ?_).congr ?_
Β· simpa +contextual [β h1 _] using hg K hK
Β· filter_upwards with s i hi using by simp [exp_sum, fun y β¦ exp_log (hfn K hK i hi y)]
lemma multipliableUniformlyOn_of_clog (hf : SummableUniformlyOn (fun i x β¦ log (f i x)) π)
(hfn : β K β π, β x β K, β i, f i x β 0)
(hg : β K β π, BddAbove <| (fun x β¦ (β' i, log (f i x)).re) '' K) :
MultipliableUniformlyOn f π :=
β¨_, hasProdUniformlyOn_of_clog hf hfn hgβ©
end Complex
namespace Summable
variable {R : Type*} [NormedCommRing R] [NormOneClass R] [CompleteSpace R] [TopologicalSpace Ξ±]
{f : ΞΉ β Ξ± β R}
/-- If a sequence of continuous functions `f i x` on an open compact `K` have norms eventually
bounded by a summable function, then `β' i, (1 + f i x)` is uniformly convergent on `K`. -/
lemma hasProdUniformlyOn_one_add (hK : IsCompact K) (hu : Summable u)
(h : βαΆ i in cofinite, β x β K, βf i xβ β€ u i) (hcts : β i, ContinuousOn (f i) K) :
HasProdUniformlyOn (fun i x β¦ 1 + f i x) (fun x β¦ β' i, (1 + f i x)) {K} := by
simp only [hasProdUniformlyOn_iff_tendstoUniformlyOn, Set.mem_singleton_iff,
tendstoUniformlyOn_iff_tendstoUniformly_comp_coe, forall_eq]
by_cases hKe : K = β
Β· simp [TendstoUniformly, hKe]
Β· haveI hCK : CompactSpace K := isCompact_iff_compactSpace.mp hK
haveI hne : Nonempty K := by rwa [Set.nonempty_coe_sort, Set.nonempty_iff_ne_empty]
let f' i : C(K, R) := β¨_, continuousOn_iff_continuous_restrict.mp (hcts i)β©
have hf'_bd : βαΆ i in cofinite, βf' iβ β€ u i := by
simp only [ContinuousMap.norm_le_of_nonempty]
filter_upwards [h] with i hi using fun x β¦ hi x x.2
have hM : Multipliable fun i β¦ 1 + f' i :=
multipliable_one_add_of_summable (hu.of_norm_bounded_eventually (by simpa using hf'_bd))
convert ContinuousMap.tendsto_iff_tendstoUniformly.mp hM.hasProd
Β· simp [f']
Β· exact funext fun k β¦ ContinuousMap.tprod_apply hM k
lemma multipliableUniformlyOn_one_add (hK : IsCompact K) (hu : Summable u)
(h : βαΆ i in cofinite, β x β K, βf i xβ β€ u i) (hcts : β i, ContinuousOn (f i) K) :
MultipliableUniformlyOn (fun i x β¦ 1 + f i x) {K} :=
β¨_, hasProdUniformlyOn_one_add hK hu h hctsβ©
/-- This is a version of `hasProdUniformlyOn_one_add` for sequences indexed by `β`. -/
lemma hasProdUniformlyOn_nat_one_add {f : β β Ξ± β R} (hK : IsCompact K) {u : β β β}
(hu : Summable u) (h : βαΆ n in atTop, β x β K, βf n xβ β€ u n)
(hcts : β n, ContinuousOn (f n) K) :
HasProdUniformlyOn (fun n x β¦ 1 + f n x) (fun x β¦ β' i, (1 + f i x)) {K} :=
hasProdUniformlyOn_one_add hK hu (Nat.cofinite_eq_atTop βΈ h) hcts
lemma multipliableUniformlyOn_nat_one_add {f : β β Ξ± β R} (hK : IsCompact K)
{u : β β β} (hu : Summable u) (h : βαΆ n in atTop, β x β K, βf n xβ β€ u n)
(hcts : β n, ContinuousOn (f n) K) :
MultipliableUniformlyOn (fun n x β¦ 1 + f n x) {K} :=
β¨_, hasProdUniformlyOn_nat_one_add hK hu h hctsβ©
section LocallyCompactSpace
variable [LocallyCompactSpace Ξ±]
/-- If a sequence of continuous functions `f i x` on an open subset `K` have norms eventually
bounded by a summable function, then `β' i, (1 + f i x)` is locally uniformly convergent on `K`. -/
lemma hasProdLocallyUniformlyOn_one_add (hK : IsOpen K) (hu : Summable u)
(h : βαΆ i in cofinite, β x β K, βf i xβ β€ u i) (hcts : β i, ContinuousOn (f i) K) :
HasProdLocallyUniformlyOn (fun i x β¦ 1 + f i x) (fun x β¦ β' i, (1 + f i x)) K := by
apply hasProdLocallyUniformlyOn_of_forall_compact hK
refine fun S hS hC β¦ hasProdUniformlyOn_one_add hC hu ?_ fun i β¦ (hcts i).mono hS
filter_upwards [h] with i hi a ha using hi a (hS ha)
lemma multipliableLocallyUniformlyOn_one_add (hK : IsOpen K) (hu : Summable u)
(h : βαΆ i in cofinite, β x β K, βf i xβ β€ u i) (hcts : β i, ContinuousOn (f i) K) :
MultipliableLocallyUniformlyOn (fun i x β¦ 1 + f i x) K :=
β¨_, hasProdLocallyUniformlyOn_one_add hK hu h hctsβ©
/-- This is a version of `hasProdLocallyUniformlyOn_one_add` for sequences indexed by `β`. -/
lemma hasProdLocallyUniformlyOn_nat_one_add {f : β β Ξ± β R} (hK : IsOpen K) {u : β β β}
(hu : Summable u) (h : βαΆ n in atTop, β x β K, βf n xβ β€ u n)
(hcts : β n, ContinuousOn (f n) K) :
HasProdLocallyUniformlyOn (fun n x β¦ 1 + f n x) (fun x β¦ β' i, (1 + f i x)) K :=
hasProdLocallyUniformlyOn_one_add hK hu (Nat.cofinite_eq_atTop βΈ h) hcts
lemma multipliableLocallyUniformlyOn_nat_one_add {f : β β Ξ± β R} (hK : IsOpen K) {u : β β β}
(hu : Summable u) (h : βαΆ n in atTop, β x β K, βf n xβ β€ u n)
(hcts : β n, ContinuousOn (f n) K) :
MultipliableLocallyUniformlyOn (fun n x β¦ 1 + f n x) K :=
β¨_, hasProdLocallyUniformlyOn_nat_one_add hK hu h hctsβ©
end LocallyCompactSpace
end Summable |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Extend.lean | import Mathlib.Analysis.Normed.Module.RCLike.Extend
deprecated_module (since := "2025-09-18") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.