Module mathcomp.analysis.derive
From HB Require Import structures.From mathcomp Require Import boot order ssralg ssrnum matrix interval
interval_inference.
From mathcomp Require Import poly sesquilinear.
#[warning="-warn-library-file-internal-analysis"]
From mathcomp Require Import unstable.
From mathcomp Require Import boolp contra classical_sets functions reals.
From mathcomp Require Import topology tvs normedtype landau.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GRing.Theory Num.Theory.
Import numFieldNormedType.Exports.
Local Open Scope ring_scope.
Local Open Scope classical_set_scope.
Reserved Notation "''d' f x" (at level 0, f at level 0, x at level 0,
format "''d' f x").
Reserved Notation "'is_diff' F" (at level 0, F at level 0,
format "'is_diff' F").
Reserved Notation "''J' f p" (at level 10, p, f at next level,
format "''J' f p").
Reserved Notation "''D_' v f" (at level 10, v, f at next level,
format "''D_' v f").
Reserved Notation "''D_' v f c" (at level 10, v, f at next level,
format "''D_' v f c").
Reserved Notation "f ^` ()" (format "f ^` ()").
Reserved Notation "f ^` ( n )" (format "f ^` ( n )").
Section Differential.
Context {KSource code : numDomainType} {VSource code WSource code : normedModType K}.
Definition diff
diff : forall {K : numDomainType} {V W : normedModType K} [F : filter_on V], phantom (set_system V) F -> (V -> W) -> Linear_type__canonical__classical_sets_Pointed (R:=K) V W diff is not universe polymorphic Arguments diff {K V W} [F] _ f%_function_scope diff is transparent Expands to: Constant mathcomp.analysis.derive.diff Declared in library mathcomp.analysis.derive, line 133, characters 11-15
Source code (FSource code : filter_on V) (_ : phantom (set_system V) F) (fSource code : V -> W) :=
(get (fun (dfSource code : {linear V -> W}) => continuous df /\ forall xSource code,
f x = f (lim F) + df (x - lim F) +o_(xSource code \near F) (x - lim F))).
Local Notation "''d' f x"Source code := (@diff _ (Phantom _ (nbhs x)) f).
Fact diff_keySource code : forall TSource code, T -> unit
Proof.
(phFSource code : phantom (set_system V) x) : Prop := DifferentiableDefSource code of
(continuous ('d f x) /\
f = cst (f (lim x)) + 'd f x \o center (lim x) +o_x (center (lim x))).
Local Notation differentiableSource code f F :=
(@differentiable_def f _ (Phantom _ (nbhs F))).
Class is_diff_defSource code (xSource code : filter_on V) (FphSource code : phantom (set_system V) x) (fSource code : V -> W)
(dfSource code : V -> W) := DiffDef {
ex_diffSource code : differentiable f x ;
diff_valSource code : 'd f x = df :> (V -> W)
}.
Hint Mode is_diff_def - - ! - : typeclass_instances.
Lemma diffPSource code (FSource code : filter_on V) (fSource code : V -> W) :
differentiable f F <->
continuous ('d f F) /\
(forall xSource code, f x = f (lim F) + 'd f F (x - lim F) +o_(xSource code \near F) (x - lim F)).
Proof.
Lemma diff_continuousSource code (xSource code : filter_on V) (fSource code : V -> W) :
differentiable f x -> continuous ('d f x).
Proof.
Lemma diffESource code (FSource code : filter_on V) (fSource code : V -> W) :
differentiable f F ->
forall xSource code, f x = f (lim F) + 'd f F (x - lim F) +o_(xSource code \near F) (x - lim F).
Proof.
Lemma littleo_center0Source code (xSource code : V) (fSource code : V -> W) (eSource code : V -> V) :
[o_x e of f] = [o_ 0 (e \o shift x) of f \o shift x] \o center x.
Proof.
rewrite insubT //= ?comp_shiftK //; apply/asboolP => _/posnumP[eps].
rewrite [\forall xSource code \near _, _ <= _](near_shift x) sub0r; near=> y.
by rewrite /= subrK; near: y; have /eqoP := littleo_eqo g; apply.
rewrite insubF //; apply/asboolP => fe; apply: Nfe => _/posnumP[eps].
by rewrite [\forall xSource code \near _, _ <= _](near_shift 0) subr0; apply: fe.
Unshelve. all: by end_near. Qed.
End Differential.
Section Differential_numFieldType.
Context {KSource code : numFieldType } {VSource code WSource code : normedModType K}.
Local Notation differentiableSource code f F :=
(@differentiable_def _ _ _ f _ (Phantom _ (nbhs F))).
Local Notation "''d' f x"Source code := (@diff _ _ _ _ (Phantom _ (nbhs x)) f).
Hint Extern 0 (continuous _) => solve[now apply: diff_continuous] : core.
Lemma diff_locallyxPSource code (xSource code : V) (fSource code : V -> W) :
differentiable f x <-> continuous ('d f x) /\
forall hSource code, f (h + x) = f x + 'd f x h +o_(hSource code \near 0) h.
Proof.
split => //; apply: eqaddoEx => h; have /diffE -> := dxf.
rewrite lim_id // addrK; congr (_ + _); rewrite littleo_center0 /= addrK.
by congr ('o); rewrite funeqE => k /=; rewrite addrK.
apply/diffP; split=> //; apply: eqaddoEx; move=> y.
rewrite lim_id // -[in LHS](subrK x y) dxf; congr (_ + _).
rewrite -(comp_centerK x id) -[X in the_littleo _ _ _ X](comp_centerK x).
by rewrite -[_ (y - x)]/((_ \o (center x)) y) -littleo_center0.
Qed.
Lemma diff_locallyxSource code (xSource code : V) (fSource code : V -> W) : differentiable f x ->
forall hSource code, f (h + x) = f x + 'd f x h +o_(hSource code \near 0) h.
Proof.
Lemma diff_locallyxCSource code (xSource code : V) (fSource code : V -> W) : differentiable f x ->
forall hSource code, f (x + h) = f x + 'd f x h +o_(hSource code \near 0) h.
Proof.
Lemma diff_locallyPSource code (xSource code : V) (fSource code : V -> W) :
differentiable f x <->
continuous ('d f x) /\ (f \o shift x = cst (f x) + 'd f x +o_ 0 id).
Proof.
Lemma diff_locallySource code (xSource code : V) (fSource code : V -> W) : differentiable f x ->
(f \o shift x = cst (f x) + 'd f x +o_ 0 id).
Proof.
End Differential_numFieldType.
Notation "''d' f F"Source code := (@diff _ _ _ _ (Phantom _ (nbhs F)) f).
Notation differentiableSource code f F := (@differentiable_def _ _ _ f _ (Phantom _ (nbhs F))).
Notation "'is_diff' F"Source code := (is_diff_def (Phantom _ (nbhs F))).
#[global] Hint Extern 0 (differentiable _ _) => solve[apply: ex_diff] : core.
#[global] Hint Extern 0 ({for _, continuous _}) =>
solve[now apply: diff_continuous] : core.
Lemma differentiablePSource code (RSource code : numDomainType) (VSource code WSource code : normedModType R) (fSource code : V -> W) xSource code :
differentiable f x -> is_diff x f ('d f x).
Proof.
Section jacobian.
Definition jacobian
jacobian : forall [n m : nat] [R : numFieldType], ('rV_n -> 'rV_m) -> matrix_matrix__canonical__normed_module_NormedModule R 1 n -> 'M_(n, m) jacobian is not universe polymorphic Arguments jacobian [n m]%_nat_scope [R] f%_function_scope p jacobian is transparent Expands to: Constant mathcomp.analysis.derive.jacobian Declared in library mathcomp.analysis.derive, line 241, characters 11-19
Source code nSource code mSource code (RSource code : numFieldType) (fSource code : 'rV[R]_n -> 'rV[R]_m) pSource code :=
lin1_mx ('d f p).
End jacobian.
Notation "''J' f p"Source code := (jacobian f p).
Section DifferentialR.
Context {RSource code : numFieldType} {VSource code WSource code : normedModType R}.
Lemma differentiable_continuousUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.exp
Source code (xSource code : V) (fSource code : V -> W) :
differentiable f x -> {for x, continuous f}.
Proof.
rewrite (littleo_bigO_eqo (cst (1 : R))).
by apply/eqOP; near=> k; rewrite /cst [`|1|]normr1 mulr1; near do by [].
rewrite addfo; last by move=> /eqolim; rewrite cvg_comp_shift add0r.
by apply/eqolim0P; apply: (cvg_trans (dfc 0)); rewrite linear0.
Unshelve. all: by end_near. Qed.
Section littleo_lemmas.
Context {XSource code YSource code ZSource code : normedModType R}.
Lemma normm_littleoSource code xSource code (fSource code : X -> Y) : `| [o_(xSource code \near x) (1 : R) of f x]| = 0.
Proof.
rewrite pmulr_lgt0 // [`|1|]normr1 mulr1 [leLHS]splitr gerDr pmulr_lle0 //.
by move=> /implyP; case : real_ltgtP; rewrite ?realE ?normrE //= lexx.
Qed.
Lemma littleo_lim0Source code (fSource code : X -> Y) (hSource code : _ -> Z) (xSource code : X) :
f @ x --> 0 -> [o_x f of h] x = 0.
Proof.
End littleo_lemmas.
Section diff_locally_converse_tentative.
Lemma diff_locally_converse_part1Source code (fSource code : R -> R) (aSource code bSource code xSource code : R) :
f \o shift x = cst a + b *: idfun +o_ 0 id -> f x = a.
Proof.
End diff_locally_converse_tentative.
Definition derive
derive : forall {R : numFieldType} {V W : normedModType R}, (V -> W) -> V -> V -> join_normed_module_NormedModule_between_GRing_LSemiModule_and_filter_PointedNbhs W derive is not universe polymorphic Arguments derive {R V W} f%_function_scope (a v)%_ring_scope derive is transparent Expands to: Constant mathcomp.analysis.derive.derive Declared in library mathcomp.analysis.derive, line 301, characters 11-17
Source code (fSource code : V -> W) aSource code vSource code :=
lim ((fun hSource code => h^-1 *: ((f \o shift a) (h *: v) - f a)) @ 0^').
Local Notation "''D_' v f"Source code := (derive f ^~ v).
Local Notation "''D_' v f c"Source code := (derive f c v).
Definition derivable
derivable : forall {R : numFieldType} {V W : normedModType R}, (V -> W) -> V -> V -> Prop derivable is not universe polymorphic Arguments derivable {R V W} f%_function_scope (a v)%_ring_scope derivable is transparent Expands to: Constant mathcomp.analysis.derive.derivable Declared in library mathcomp.analysis.derive, line 307, characters 11-20
Used by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
- mathcomp.analysis.exp
Source code (fSource code : V -> W) aSource code vSource code :=
cvg ((fun hSource code => h^-1 *: ((f \o shift a) (h *: v) - f a)) @ 0^').
Class is_deriveUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
- mathcomp.analysis.exp
Source code (aSource code vSource code : V) (fSource code : V -> W) (dfSource code : W) := DeriveDef {
ex_deriveUsed by
- mathcomp.analysis.probability_theory.exponential_distribution
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.elementary_functions.trigonometry_integral
- mathcomp.analysis.exp
Source code : derivable f a v;
derive_valUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.elementary_functions.trigonometry_integral
- mathcomp.analysis.exp
Source code : 'D_v f a = df
}.
Lemma derivable_nbhsSource code (fSource code : V -> W) aSource code vSource code :
derivable f a v ->
(fun hSource code => (f \o shift a) (h *: v)) = (cst (f a)) +
(fun hSource code => h *: ('D_v f a)) +o_ (nbhs 0) id.
Proof.
rewrite -nbhs_nearE nbhs_simpl /= dnbhsE; split; last first.
apply/principal_filterP.
rewrite opprD -![(_ + _ : _ -> _) _]/(_ + _) scale0r add0r.
by rewrite addrCA addKr normrN scale0r !normr0 mulr0.
have /eqolimP := df.
move=> /eqaddoP /(_ e%:num) /(_ [gt0 of e%:num]).
apply: filter_app; rewrite /= !near_simpl near_withinE; near=> h => hN0.
rewrite /= opprD -![(_ + _ : _ -> _) _]/(_ + _) -![(- _ : _ -> _) _]/(- _).
rewrite /cst /= [`|1|]normr1 mulr1 => dfv.
rewrite addrA -[X in X + _]scale1r -(@mulVf _ h) //.
rewrite mulrC -scalerA -scalerBr normrZ.
by rewrite -ler_pdivlMl ?normr_gt0// mulrC mulfK ?normr_eq0.
Unshelve. all: by end_near. Qed.
Lemma derivable_nbhsPSource code (fSource code : V -> W) aSource code vSource code :
derivable f a v <->
(fun hSource code => (f \o shift a) (h *: v)) = (cst (f a)) +
(fun hSource code => h *: ('D_v f a)) +o_ (nbhs 0) id.
Proof.
move=> df; apply/cvg_ex; exists ('D_v f a).
apply/(@eqolimP _ _ _ (dnbhs_filter_on _))/eqaddoP => _/posnumP[e].
have /eqaddoP /(_ e%:num) /(_ [gt0 of e%:num]) := df.
rewrite /= !(near_simpl, near_withinE); apply: filter_app; near=> h.
rewrite /= opprD -![(_ + _ : _ -> _) _]/(_ + _) -![(- _ : _ -> _) _]/(- _).
rewrite /cst /= [`|1|]normr1 mulr1 addrA => dfv hN0.
rewrite -[X in _ - X]scale1r -(@mulVf _ h) //.
rewrite -scalerA -scalerBr normrZ normfV ler_pdivrMl ?normr_gt0 //.
by rewrite mulrC.
Unshelve. all: by end_near. Qed.
Lemma derivable_nbhsxSource code (fSource code : V -> W) aSource code vSource code :
derivable f a v -> forall hSource code, f (a + h *: v) = f a + h *: 'D_v f a
+o_(hSource code \near (nbhs 0)) h.
Proof.
by apply: eqaddoEx => h; have /= := df h; rewrite addrC => ->.
Qed.
Lemma derivable_nbhsxPSource code (fSource code : V -> W) aSource code vSource code :
derivable f a v <-> forall hSource code, f (a + h *: v) = f a + h *: 'D_v f a
+o_(hSource code \near (nbhs 0)) h.
Proof.
move=> df; apply/derivable_nbhsP; apply/eqaddoE; rewrite funeqE => h.
by rewrite /= addrC df.
Qed.
Lemma derivable0Used by
- mathcomp.analysis.exp
Source code (fSource code : V -> W) (xSource code : V) : derivable f x 0.
Proof.
near=> h.
by rewrite scaler0 add0r subrr scaler0.
Unshelve. all: by end_near. Qed.
Lemma derive0Source code (fSource code : V -> W) (xSource code : V) : 'D_0 f x = 0.
Proof.
near=> h.
by rewrite scaler0 add0r subrr scaler0.
Unshelve. all: by end_near. Qed.
Lemma is_derive0Source code (fSource code : V -> W) (xSource code : V) : is_derive x 0 f 0.
Proof.
End DifferentialR.
Notation "''D_' v f"Used by
- mathcomp.analysis.realfun
- mathcomp.analysis.pi_irrational
- mathcomp.analysis.exp
Source code := (derive f ^~ v).
Notation "''D_' v f c"Used by
- mathcomp.analysis.realfun
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
Source code := (derive f c v).
#[global] Hint Extern 0 (derivable _ _ _) => solve[apply: ex_derive] : core.
Section DifferentialR_numFieldType.
Context {RSource code : numFieldType} {VSource code WSource code : normedModType R}.
Lemma deriveESource code (fSource code : V -> W) (aSource code vSource code : V) :
differentiable f a -> 'D_v f a = 'd f a v.
Proof.
evar (g : R -> W); rewrite [X in X @ _](_ : _ = g) /=.
rewrite funeqE=> h.
by rewrite -[_ - _]addrA addrC subrKA scalerDr addrC linearZ scalerA /g.
apply: cvg_lim => //.
pose g1 : R -> W := fun hSource code => (h^-1 * h) *: 'd f a v.
pose g2 : R -> W := fun hSource code : R => h^-1 *: k (h *: v ).
rewrite (_ : g = g1 + g2) ?funeqE//; apply: cvgD0.
apply: cvg1Z => //= X [e e0].
rewrite /ball_ /= => eX.
apply/nbhs_ballP.
by exists e => //= x _ x0; apply eX; rewrite mulVf//= subrr normr0.
rewrite /g2.
have [->|v0] := eqVneq v 0.
rewrite (_ : (fun _ => _) = cst 0)//.
by rewrite funeqE => ?; rewrite scaler0 /k littleo_lim0 // scaler0.
apply/cvgrPdist_lt => e e0.
rewrite nearE /=; apply/nbhs_ballP.
have /(littleoP [littleo of k]) /nbhs_ballP[i i0 Hi] : 0 < e / (2 * `|v|).
by rewrite divr_gt0 // pmulr_rgt0 // normr_gt0.
exists (i / `|v|); first by rewrite /= divr_gt0 // normr_gt0.
move=> /= j; rewrite /ball /= /ball_ add0r normrN.
rewrite ltr_pdivlMr ?normr_gt0 // => jvi j0.
rewrite add0r normrN normrZ -ltr_pdivlMl ?normr_gt0 ?invr_neq0 //.
have /Hi/le_lt_trans -> // : ball 0 i (j *: v).
by rewrite -ball_normE/= add0r normrN (le_lt_trans _ jvi) // normrZ.
rewrite -(mulrC e) -mulrA -ltr_pdivlMl // mulKf ?gt_eqF// normfV invrK.
rewrite ltr_pdivrMl; first by rewrite pmulr_rgt0 // normr_gt0.
rewrite normrZ mulrC -mulrA.
by rewrite ltr_pMl ?ltr1n // pmulr_rgt0 ?normm_gt0 // normr_gt0.
Qed.
End DifferentialR_numFieldType.
Section DifferentialR2.
Context {RSource code : numFieldType}.
Implicit Type V : normedModType R.
Lemma deriveEjacobianSource code mSource code nSource code (fSource code : 'rV[R]_m -> 'rV[R]_n) (aSource code vSource code : 'rV[R]_m) :
differentiable f a -> 'D_ v f a = v *m jacobian f a.
Proof.
Definition derive1
derive1 : forall {R : numFieldType} [V : normedModType R], (R -> V) -> R -> join_normed_module_NormedModule_between_GRing_LSemiModule_and_filter_PointedNbhs V derive1 is not universe polymorphic Arguments derive1 {R} [V] f%_function_scope a%_ring_scope derive1 is transparent Expands to: Constant mathcomp.analysis.derive.derive1 Declared in library mathcomp.analysis.derive, line 440, characters 11-18
Used by
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
Source code VSource code (fSource code : R -> V) (aSource code : R) :=
lim ((fun hSource code => h^-1 *: (f (h + a) - f a)) @ 0^').
Local Notation "f ^` ()"Source code := (derive1 f).
Lemma derive1EUsed by
- mathcomp.analysis.probability_theory.exponential_distribution
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.probability_theory.normal_distribution
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.elementary_functions.trigonometry_integral
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
- mathcomp.analysis.exp
Source code VSource code (fSource code : R -> V) aSource code : f^`() a = 'D_1 f a.
Proof.
Lemma derive1E'Source code VSource code fSource code aSource code : differentiable (f : R -> V) a ->
f^`() a = 'd f a 1.
Definition derive1n
derive1n : forall {R : numFieldType} [V : normedModType R], nat -> (R -> V) -> R -> V derive1n is not universe polymorphic Arguments derive1n {R} [V] n%_nat_scope f%_function_scope _%_ring_scope derive1n is transparent Expands to: Constant mathcomp.analysis.derive.derive1n Declared in library mathcomp.analysis.derive, line 456, characters 11-19
Source code VSource code nSource code (fSource code : R -> V) := iter n (@derive1 V) f.
Local Notation "f ^` ( n )"Source code := (derive1n n f).
Lemma derive1n0Source code VSource code (fSource code : R -> V) : f^`(0) = f.
Proof.
Lemma derive1n1Source code VSource code (fSource code : R -> V) : f^`(1) = f^`().
Proof.
Lemma derive1nSSource code VSource code (fSource code : R -> V) nSource code : f^`(n.+1) = f^`(n)^`().
Proof.
Lemma derive1SnSource code VSource code (fSource code : R -> V) nSource code : f^`(n.+1) = f^`()^`(n).
Proof.
Lemma derive1DnSource code VSource code (fSource code : R -> V) mSource code nSource code : f^`(n + m) = f^`(m)^`(n).
End DifferentialR2.
Notation "f ^` ()"Source code := (derive1 f) : classical_set_scope.
Notation "f ^` ( n )"Source code := (derive1n n f) : classical_set_scope.
#[deprecated(since="mathcomp-analysis 1.13.0", note="renamed to `deriveEjacobian`")]
Notation derivemxESource code := deriveEjacobian (only parsing).
Section DifferentialR3.
Context {RSource code : numFieldType}.
Fact dcstSource code (VSource code WSource code : normedModType R) (aSource code : W) (xSource code : V) : continuous (0 : V -> W) /\
cst a \o shift x = cst (cst a x) + \0 +o_ 0 id.
Proof.
apply/eqaddoE; rewrite addr0 funeqE => ? /=; rewrite -[LHS]addr0; congr (_ + _).
by rewrite littleoE; first exact: littleo0_subproof.
Qed.
Variables (VSource code WSource code : normedModType R).
Fact daddSource code (fSource code gSource code : V -> W) xSource code :
differentiable f x -> differentiable g x ->
continuous ('d f x \+ 'd g x) /\
(f + g) \o shift x = cst ((f + g) x) + ('d f x \+ 'd g x) +o_ 0 id.
Proof.
apply/(@eqaddoE R); rewrite funeqE => y /=.
by rewrite !fctE ![_ (_ + x)]diff_locallyx// addrACA addox addrACA.
Qed.
Fact doppSource code (fSource code : V -> W) xSource code :
differentiable f x -> continuous (- ('d f x : V -> W)) /\
(- f) \o shift x = cst (- f x) \- 'd f x +o_ 0 id.
Proof.
apply/eqaddoE; rewrite funeqE => y /=.
by rewrite -[(- f) _]/(- (_ _)) diff_locallyx// !opprD oppox.
Qed.
Lemma is_diff_eqSource code (V'Source code W'Source code : normedModType R) (fSource code f'Source code gSource code : V' -> W') (xSource code : V') :
is_diff x f f' -> f' = g -> is_diff x f g.
Proof.
Fact dscaleSource code (fSource code : V -> W) kSource code xSource code :
differentiable f x -> continuous (k \*: 'd f x) /\
(k *: f) \o shift x = cst ((k *: f) x) + k \*: 'd f x +o_ 0 id.
Proof.
apply/eqaddoE; rewrite funeqE => y /=.
by rewrite -[(k *: f) _]/(_ *: _) diff_locallyx // !scalerDr scaleox.
Qed.
Fact dscalelSource code (kSource code : V -> R) (fSource code : W) xSource code :
differentiable k x ->
continuous (fun zSource code : V => 'd k x z *: f) /\
(fun zSource code => k z *: f) \o shift x =
cst (k x *: f) + (fun zSource code => 'd k x z *: f) +o_ 0 id.
Proof.
move=> ?; exact/continuousZr_tmp/diff_continuous.
apply/eqaddoE; rewrite funeqE => y /=.
by rewrite diff_locallyx //= !scalerDl scaleolx.
Qed.
Fact dlinSource code (V'Source code W'Source code : normedModType R) (fSource code : {linear V' -> W'}) xSource code :
continuous f -> f \o shift x = cst (f x) + f +o_ 0 id.
Proof.
Lemma compoO_eqoSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V')
(gSource code : V' -> W') :
[o_ 0 id of g] \o [O_ 0 id of f] =o_ 0 id.
Proof.
have /bigO_exP [_ /posnumP[k]] := bigOP [bigO of [O_ 0 id of f]].
have := littleoP [littleo of [o_ 0 id of g]].
move=> /(_ (e%:num / k%:num)) /(_ _) /nbhs_ballP [//|_ /posnumP[d] hd].
apply: filter_app; near=> x => leOxkx; apply: le_trans (hd _ _) _; last first.
by rewrite -ler_pdivlMl // invf_div mulrA divfK.
by rewrite -ball_normE /= distrC subr0 (le_lt_trans leOxkx) // -ltr_pdivlMl.
Unshelve. all: by end_near. Qed.
Lemma compoO_eqoxSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V')
(gSource code : V' -> W') :
forall xSource code : U, [o_ 0 id of g] ([O_ 0 id of f] x) =o_(xSource code \near 0) x.
Proof.
Lemma compOo_eqoSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V') (gSource code : V' -> W') :
[O_ 0 id of g] \o [o_ 0 id of f] =o_ 0 id.
Proof.
have /bigO_exP [_ /posnumP[k]] := bigOP [bigO of [O_ 0 id of g]].
move=> /nbhs_ballP [_ /posnumP[d] hd].
have ekgt0 : e%:num / k%:num > 0 by [].
have /(_ _ ekgt0) := littleoP [littleo of [o_ 0 id of f]].
apply: filter_app; near=> x => leoxekx; apply: le_trans (hd _ _) _; last first.
by rewrite -ler_pdivlMl // mulrA [_^-1 * _]mulrC.
by rewrite -ball_normE /= distrC subr0 (le_lt_trans leoxekx)// -ltr_pdivlMl //.
Unshelve. all: by end_near. Qed.
End DifferentialR3.
Section DifferentialR3_numFieldType.
Context {RSource code : numFieldType}.
Lemma littleo_linear0Source code (VSource code WSource code : normedModType R) (fSource code : {linear V -> W}) :
(f : V -> W) =o_ 0 id -> f = cst 0 :> (V -> W).
Proof.
rewrite funeqE => x; apply/eqP; have [|xn0] := real_le0P (normr_real x).
by rewrite normr_le0 => /eqP ->; rewrite linear0.
rewrite -normr_le0 -(mul0r `|x|) -ler_pdivrMr //.
apply/ler_gtP => _ /posnumP[e]; rewrite ler_pdivrMr //.
have /oid /nbhs_ballP [_ /posnumP[d] dfe] := [elaborate gt0 e].
set k := ((d%:num / 2) / (PosNum xn0)%:num)^-1.
rewrite -{1}(@scalerKV _ _ k _ x) /k // linearZZ normrZ.
rewrite -ler_pdivlMl; first by rewrite gtr0_norm.
rewrite mulrCA (@le_trans _ _ (e%:num * `|k^-1 *: x|)) //; last first.
by rewrite ler_pM // normrZ normfV.
apply: dfe; rewrite -ball_normE /= sub0r normrN normrZ.
rewrite invrK -ltr_pdivlMr // ger0_norm // ltr_pdivrMr //.
by rewrite divfK ?lt0r_neq0// [ltRHS]splitr ltrDl.
Qed.
Lemma diff_uniqueSource code (VSource code WSource code : normedModType R) (fSource code : V -> W)
(dfSource code : {linear V -> W}) xSource code :
continuous df -> f \o shift x = cst (f x) + df +o_ 0 id ->
'd f x = df :> (V -> W).
Proof.
apply/littleo_linear0/eqoP/eq_some_oP => /=; rewrite funeqE => y /=.
have hdf h : (f \o shift x = cst (f x) + h +o_ 0 id) ->
h = f \o shift x - cst (f x) +o_ 0 id.
move=> hdf; apply: eqaddoE.
rewrite hdf addrAC -!addrA addrC !addrA subrK.
rewrite -[LHS]addr0 -addrA; congr (_ + _).
by apply/eqP; rewrite eq_sym addrC addr_eq0 oppo.
rewrite (hdf _ dxf).
suff /diff_locally /hdf -> : differentiable f x.
by rewrite [_ - _ + _]addrC addrKA oppox addox.
apply/diffP => /=.
apply: (@getPex _ (fun (dfSource code : {linear V -> W}) => continuous df /\
forall ySource code, f y = f (lim (nbhs x)) + df (y - lim (nbhs x))
+o_(ySource code \near x) (y - lim (nbhs x)))).
exists df; split=> //; apply: eqaddoEx => z.
rewrite (hdf _ dxf) !addrA lim_id // /(_ \o _) /= subrK [f _ + _]addrC addrK.
rewrite -addrA -[LHS]addr0; congr (_ + _).
apply/eqP; rewrite eq_sym addrC addr_eq0 oppox; apply/eqP.
rewrite [in LHS]littleo_center0 (comp_centerK x id).
by rewrite -[- _ in RHS](comp_centerK x).
Qed.
Lemma diff_cstSource code (VSource code WSource code : normedModType R) aSource code xSource code : ('d (cst a) x : V -> W) = 0.
Proof.
Variables (VSource code WSource code : normedModType R).
Lemma differentiable_cstSource code (W'Source code : normedModType R) (aSource code : W') (xSource code : V) :
differentiable (cst a) x.
Proof.
Global Instance is_diff_cstSource code (aSource code : W) (xSource code : V) : is_diff x (cst a) 0.
Proof.
Lemma diffDSource code (fSource code gSource code : V -> W) xSource code :
differentiable f x -> differentiable g x ->
'd (f + g) x = 'd f x \+ 'd g x :> (V -> W).
Proof.
Lemma differentiableDSource code (fSource code gSource code : V -> W) xSource code :
differentiable f x -> differentiable g x -> differentiable (f + g) x.
Proof.
Global Instance is_diffDSource code (fSource code gSource code dfSource code dgSource code : V -> W) xSource code :
is_diff x f df -> is_diff x g dg -> is_diff x (f + g) (df + dg).
Proof.
by rewrite diffD; last (congr (_ + _); apply: diff_val).
Qed.
Lemma differentiable_sumSource code nSource code (fSource code : 'I_n -> V -> W) (xSource code : V) :
(forall iSource code, differentiable (f i) x) -> differentiable (\sum_(iSource code < n) f i) x.
Proof.
Lemma diffNSource code (fSource code : V -> W) xSource code :
differentiable f x -> 'd (- f) x = - ('d f x : V -> W) :> (V -> W).
Proof.
Lemma differentiableNSource code (fSource code : V -> W) xSource code :
differentiable f x -> differentiable (- f) x.
Proof.
Global Instance is_diffNSource code (fSource code dfSource code : V -> W) xSource code :
is_diff x f df -> is_diff x (- f) (- df).
Proof.
Global Instance is_diffBSource code (fSource code gSource code dfSource code dgSource code : V -> W) xSource code :
is_diff x f df -> is_diff x g dg -> is_diff x (f - g) (df - dg).
Proof.
Lemma diffBSource code (fSource code gSource code : V -> W) xSource code :
differentiable f x -> differentiable g x ->
'd (f - g) x = 'd f x \- 'd g x :> (V -> W).
Proof.
Lemma differentiableBSource code (fSource code gSource code : V -> W) xSource code :
differentiable f x -> differentiable g x -> differentiable (f \- g) x.
Proof.
Lemma diffZSource code (fSource code : V -> W) kSource code xSource code :
differentiable f x -> 'd (k *: f) x = k \*: 'd f x :> (V -> W).
Proof.
Lemma differentiableZSource code (fSource code : V -> W) kSource code xSource code :
differentiable f x -> differentiable (k *: f) x.
Proof.
Global Instance is_diffZSource code (fSource code dfSource code : V -> W) kSource code xSource code :
is_diff x f df -> is_diff x (k *: f) (k *: df).
Proof.
Lemma diffZlSource code (kSource code : V -> R) (fSource code : W) xSource code : differentiable k x ->
'd (fun zSource code => k z *: f) x = (fun zSource code => 'd k x z *: f) :> (_ -> _).
Proof.
Lemma differentiableZlSource code (kSource code : V -> R) (fSource code : W) xSource code :
differentiable k x -> differentiable (fun zSource code => k z *: f) x.
Proof.
Lemma diff_linSource code (V'Source code W'Source code : normedModType R) (fSource code : {linear V' -> W'}) xSource code :
continuous f -> 'd f x = f :> (V' -> W').
Proof.
Lemma linear_differentiableSource code (V'Source code W'Source code : normedModType R) (fSource code : {linear V' -> W'})
xSource code : continuous f -> differentiable f x.
Proof.
Global Instance is_diff_idSource code (xSource code : V) : is_diff x id id.
Proof.
by apply: (@linear_differentiable _ _ idfun) => ? //.
by rewrite (@diff_lin _ _ idfun) // => ? //.
Qed.
Global Instance is_diff_scalerSource code (kSource code : R) (xSource code : V) : is_diff x ( *:%R k) ( *:%R k).
Proof.
by rewrite diff_lin //; apply: scaler_continuous.
Qed.
Global Instance is_diff_scalelSource code (kSource code : R) (xSource code : V) :
is_diff k ( *:%R ^~ x) ( *:%R ^~ x).
Proof.
by move=> u y z; rewrite scalerDl scalerA.
pose sxlM := GRing.isLinear.Build _ _ _ _ _ sx_lin.
pose sxL : {linear _ -> _} := HB.pack ( *:%R ^~ x) sxlM.
have -> : *:%R ^~ x = sxL by rewrite funeqE.
apply: DiffDef; first exact/linear_differentiable/scalel_continuous.
by rewrite diff_lin //; apply: scalel_continuous.
Qed.
Lemma differentiable_coordSource code mSource code nSource code (MSource code : 'M[R]_(m, n)) iSource code jSource code :
differentiable (fun NSource code : 'M[R]_(m, n) => N i j : R ) M.
Proof.
Lemma linear_lipschitzSource code (V'Source code W'Source code : normedModType R) (fSource code : {linear V' -> W'}) :
continuous f -> exists2 kSource code, k > 0 & forall xSource code, `|f x| <= k * `|x|.
Proof.
move=> /nbhs_ballP [_ /posnumP[e] he]; exists (2 / e%:num) => // x.
have [|xn0] := real_le0P (normr_real x).
by rewrite normr_le0 => /eqP->; rewrite linear0 !normr0 mulr0.
set k := 2 / e%:num * (PosNum xn0)%:num.
have kn0 : k != 0 by rewrite /k.
have abskgt0 : `|k| > 0 by rewrite normr_gt0.
rewrite -[x in leLHS](scalerKV kn0) linearZZ normrZ -ler_pdivlMl //.
suff /he : ball 0 e%:num (k^-1 *: x).
rewrite -ball_normE /= distrC subr0 => /ltW /le_trans; apply.
by rewrite ger0_norm /k // mulVf.
rewrite -ball_normE /= distrC subr0 normrZ.
rewrite normfV ger0_norm /k // invfM/= divfK ?gt_eqF//.
by rewrite invf_div gtr_pMr// invf_lt1// ltr1n.
Qed.
Lemma linear_eqOSource code (V'Source code W'Source code : normedModType R) (fSource code : {linear V' -> W'}) :
continuous f -> (f : V' -> W') =O_ 0 id.
Proof.
Lemma diff_eqOSource code (V'Source code W'Source code : normedModType R) (xSource code : filter_on V') (fSource code : V' -> W') :
differentiable f x -> ('d f x : V' -> W') =O_ 0 id.
Proof.
Lemma compOo_eqoxSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V') (gSource code : V' -> W') xSource code :
[O_ 0 id of g] ([o_ 0 id of f] x) =o_(xSource code \near 0) x.
Proof.
Fact dcompSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V') (gSource code : V' -> W') xSource code :
differentiable f x -> differentiable g (f x) ->
continuous ('d g (f x) \o 'd f x) /\ forall ySource code,
g (f (y + x)) = g (f x) + ('d g (f x) \o 'd f x) y +o_(ySource code \near 0) y.
Proof.
apply: eqaddoEx => y; rewrite diff_locallyx// -addrA diff_locallyxC// linearD.
rewrite addrA -[LHS]addrA; congr (_ + _ + _).
rewrite diff_eqO // ['d f x : _ -> _]diff_eqO //.
by rewrite {2}eqoO addOx compOo_eqox compoO_eqox addox.
Qed.
Lemma diff_compSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V') (gSource code : V' -> W') xSource code :
differentiable f x -> differentiable g (f x) ->
'd (g \o f) x = 'd g (f x) \o 'd f x :> (U -> W').
Proof.
Lemma differentiable_compUsed by
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.exp
Source code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V')
(gSource code : V' -> W') xSource code : differentiable f x -> differentiable g (f x) ->
differentiable (g \o f) x.
Proof.
Global Instance is_diff_compSource code (USource code V'Source code W'Source code : normedModType R) (fSource code dfSource code : U -> V')
(gSource code dgSource code : V' -> W') xSource code : is_diff x f df -> is_diff (f x) g dg ->
is_diff x (g \o f) (dg \o df) | 99.
Proof.
by rewrite diff_comp // !diff_val.
Qed.
Lemma differentiable_rsubmxSource code mSource code {n1Source code n2Source code} vSource code :
differentiable (rsubmx : 'M[R]_(m, n1 + n2) -> 'M[R]_(m, n2)) v.
Proof.
Lemma differentiable_lsubmxSource code mSource code {n1Source code n2Source code} vSource code :
differentiable (lsubmx : 'M[R]_(m, n1 + n2) -> 'M[R]_(m, n1)) v.
Proof.
Lemma bilinear_schwarzSource code (USource code V'Source code W'Source code : normedModType R)
(fSource code : {bilinear U -> V' -> W'}) : continuous (fun pSource code => f p.1 p.2) ->
exists2 kSource code, k > 0 & forall uSource code vSource code, `|f u v| <= k * `|u| * `|v|.
Proof.
move=> /nbhs_ballP [_ /posnumP[e] he]; exists ((2 / e%:num) ^+2) => // u v.
have [|un0] := real_le0P (normr_real u).
by rewrite normr_le0 => /eqP->; rewrite linear0l !normr0 mulr0 mul0r.
have [|vn0] := real_le0P (normr_real v).
by rewrite normr_le0 => /eqP->; rewrite linear0r !normr0 mulr0.
rewrite -[`|u|]/((PosNum un0)%:num) -[`|v|]/((PosNum vn0)%:num).
set ku := 2 / e%:num * (PosNum un0)%:num.
set kv := 2 / e%:num * (PosNum vn0)%:num.
rewrite -[X in f X](@scalerKV _ _ ku) /ku // linearZl_LR normrZ.
rewrite gtr0_norm // -ler_pdivlMl //.
rewrite -[X in f _ X](@scalerKV _ _ kv) /kv // linearZr_LR normrZ.
rewrite gtr0_norm // -ler_pdivlMl //.
suff /he : ball 0 e%:num (ku^-1 *: u, kv^-1 *: v).
rewrite -ball_normE /= distrC subr0 => /ltW /le_trans; apply.
rewrite ler_pdivlMl 1?pmulr_lgt0// mulr1 ler_pdivlMl 1?pmulr_lgt0//.
by rewrite mulrA [ku * _]mulrAC expr2.
rewrite -ball_normE /= distrC subr0.
have -> : (ku^-1 *: u, kv^-1 *: v) =
(e%:num / 2) *: ((PosNum un0)%:num ^-1 *: u, (PosNum vn0)%:num ^-1 *: v).
by rewrite invfM [kv ^-1]invfM invf_div -[_ *: u]scalerA -[_ *: v]scalerA.
rewrite normrZ ger0_norm // -mulrA gtr_pMr // ltr_pdivrMl // mulr1.
by rewrite prod_normE/= !normrZ !normfV !normr_id !mulVf ?gt_eqF// maxxx ltr1n.
Qed.
Lemma bilinear_eqoSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : {bilinear U -> V' -> W'}) :
continuous (fun pSource code => f p.1 p.2) -> (fun pSource code => f p.1 p.2) =o_ (0 : U * V') id.
Proof.
apply/eqoP=> _ /posnumP[e]; near=> x; rewrite (le_trans (fschwarz _ _))//.
rewrite ler_pM ?pmulr_rge0 //; last by rewrite num_le_max /= lexx orbT.
rewrite -ler_pdivlMl //.
suff : `|x| <= k%:num ^-1 * e%:num.
by apply: le_trans; rewrite num_le_max /= lexx.
near: x; apply/nbhs_le_nbhs_norm.
by exists (k%:num ^-1 * e%:num) => //= ? /=; rewrite /= distrC subr0 => /ltW.
Unshelve. all: by end_near. Qed.
Fact dbilinSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : {bilinear U -> V' -> W'}) pSource code :
continuous (fun pSource code => f p.1 p.2) ->
continuous (fun qSource code => (f p.1 q.2 + f q.1 p.2)) /\
(fun qSource code => f q.1 q.2) \o shift p = cst (f p.1 p.2) +
(fun qSource code => f p.1 q.2 + f q.1 p.2) +o_ (0 : U * V') id.
Proof.
by apply: (@continuousD _ _ _ (fun qSource code => f p.1 q.2) (fun qSource code => f q.1 p.2));
move=> A /(fc (_.1, _.2)) /= /nbhs_ballP [_ /posnumP[e] fpqe_A];
apply/nbhs_ballP; exists e%:num => //= r [? ?]; exact: (fpqe_A (_.1, _.2)).
apply/eqaddoE; rewrite funeqE => q /=.
rewrite linearDr !linearDl -addrA addrC addrA [_ + f p.1 p.2]addrC.
by congr (_ + _); rewrite -[LHS]/((fun pSource code => f p.1 p.2) q) bilinear_eqo.
Qed.
Lemma diff_bilinSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : {bilinear U -> V' -> W'}) pSource code :
continuous (fun pSource code => f p.1 p.2) -> 'd (fun qSource code => f q.1 q.2) p =
(fun qSource code => f p.1 q.2 + f q.1 p.2) :> (U * V' -> W').
Proof.
move=> fc; have lind : linear d.
by move=> ? ? ?; rewrite /d linearPr linearPl scalerDr addrACA.
pose dlM := GRing.isLinear.Build _ _ _ _ _ lind.
pose dL : {linear _ -> _} := HB.pack d dlM.
rewrite -/d -[d]/(dL : _ -> _).
by apply/diff_unique; have [] := dbilin p fc.
Qed.
Lemma differentiable_bilinSource code (USource code V'Source code W'Source code : normedModType R)
(fSource code : {bilinear U -> V' -> W'}) pSource code :
continuous (fun pSource code => f p.1 p.2) -> differentiable (fun pSource code => f p.1 p.2) p.
Proof.
Lemma mulr_is_bilinearSource code :
bilinear_for
(GRing.Scale.Law.clone _ _ *:%R _) (GRing.Scale.Law.clone _ _ *:%R _)
(@GRing.mul R).
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code bilinear_isBilinearSource code.Build R R R R _ _ (@GRing.mul R)
mulr_is_bilinear.
Global Instance is_diff_mulrSource code (pSource code : R * R) :
is_diff p (fun q => q.1 * q.2) (fun qSource code => p.1 * q.2 + q.1 * p.2).
Proof.
by apply: differentiable_bilin =>?; apply: mul_continuous.
Qed.
Lemma eqo_pairSource code (USource code V'Source code W'Source code : normedModType R) (FSource code : filter_on U)
(fSource code : U -> V') (gSource code : U -> W') :
(fun tSource code => ([o_F id of f] t, [o_F id of g] t)) =o_F id.
Proof.
by apply/andP; split; near: x; apply: littleoP.
Unshelve. all: by end_near. Qed.
Fact dpairSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V') (gSource code : U -> W') xSource code :
differentiable f x -> differentiable g x ->
continuous (fun ySource code => ('d f x y, 'd g x y)) /\
(fun ySource code => (f y, g y)) \o shift x = cst (f x, g x) +
(fun ySource code => ('d f x y, 'd g x y)) +o_ 0 id.
Proof.
apply/eqaddoE; rewrite funeqE => y /=.
rewrite ![_ (_ + x)]diff_locallyx//.
(* fixme *)
have -> : forall hSource code eSource code, (f x + 'd f x y + [o_ 0 id of h] y,
g x + 'd g x y + [o_ 0 id of e] y) =
(f x, g x) + ('d f x y, 'd g x y) +
([o_ 0 id of h] y, [o_ 0id of e] y) by [].
by congr (_ + _); rewrite -[LHS]/((fun ySource code => (_ y, _ y)) y) eqo_pair.
Qed.
Lemma diff_pairSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V') (gSource code : U -> W') xSource code :
differentiable f x -> differentiable g x -> 'd (fun ySource code => (f y, g y)) x =
(fun ySource code => ('d f x y, 'd g x y)) :> (U -> V' * W').
Proof.
pose d ySource code := ('d f x y, 'd g x y).
have lin_pair : linear d by move=> ???; rewrite /d !linearPZ.
pose pairlM := GRing.isLinear.Build _ _ _ _ _ lin_pair.
pose pairL : {linear _ -> _} := HB.pack d pairlM.
rewrite -/d -[d]/(pairL : _ -> _).
by apply: diff_unique; have [] := dpair df dg.
Qed.
Lemma differentiable_pairSource code (USource code V'Source code W'Source code : normedModType R) (fSource code : U -> V')
(gSource code : U -> W') xSource code : differentiable f x -> differentiable g x ->
differentiable (fun ySource code => (f y, g y)) x.
Proof.
Global Instance is_diff_pairSource code (USource code V'Source code W'Source code : normedModType R) (fSource code dfSource code : U -> V')
(gSource code dgSource code : U -> W') xSource code : is_diff x f df -> is_diff x g dg ->
is_diff x (fun y => (f y, g y)) (fun ySource code => (df y, dg y)).
Proof.
by rewrite diff_pair // !diff_val.
Qed.
Global Instance is_diffMSource code (fSource code gSource code dfSource code dgSource code : V -> R) xSource code :
is_diff x f df -> is_diff x g dg -> is_diff x (f * g) (f x *: dg + g x *: df).
Proof.
Lemma diffMSource code (fSource code gSource code : V -> R) xSource code :
differentiable f x -> differentiable g x ->
'd (f * g) x = f x \*: 'd g x + g x \*: 'd f x :> (V -> R).
Proof.
Lemma differentiableMUsed by
- mathcomp.analysis.exp
Source code (fSource code gSource code : V -> R) xSource code :
differentiable f x -> differentiable g x -> differentiable (f * g) x.
Proof.
Fact dinvSource code (xSource code : R) :
x != 0 -> continuous (fun hSource code : R => - x ^- 2 *: h) /\
(fun xSource code => x^-1)%R \o shift x = cst (x^-1)%R +
(fun hSource code : R => - x ^- 2 *: h) +o_ 0 id.
Proof.
apply/eqaddoP => _ /posnumP[e]; near=> h.
have hDx_neq0 : h + x != 0.
near: h; rewrite !nbhs_simpl; apply/nbhs_normP.
exists `|x|; first by rewrite /= normr_gt0.
move=> h /=; rewrite /= distrC subr0 -subr_gt0 => lthx.
rewrite -(normr_gt0 (h + x)) addrC -[h]opprK.
apply: lt_le_trans (ler_dist_dist _ _).
by rewrite ger0_norm normrN //; apply: ltW.
rewrite !fctE/= opprD scaleNr opprK.
suff: `|h * h| / `|h + x| / `|x * x| <= e%:num * `|h|.
rewrite -2!normf_div -mulrA -invfM; congr (`|_| <= _).
apply/(canLR (mulfK _)); rewrite ?mulf_neq0//.
rewrite mulrDl mulKf// [(_ + _) * _]mulrC mulrDr mulrN.
rewrite -mulrA mulfK// -mulrA mulVKf ?mulf_neq0//.
by rewrite [- _ + _]addrC !mulrDl [x * h]mulrC addrKA subrKC.
rewrite ler_pdivrMr ?normr_gt0 ?mulf_neq0 // mulrAC ler_pdivrMr ?normr_gt0 //.
have : `|h * h| <= `|x / 2| * (e%:num * `|x * x| * `|h|).
rewrite !mulrA; near: h; exists (`|x / 2| * e%:num * `|x * x|).
by rewrite /= !pmulr_rgt0 // normr_gt0 mulf_neq0.
by move=> h /ltW; rewrite distrC subr0 [`|h * _|]normrM => /ler_pM; apply.
move=> /le_trans -> //; rewrite [leLHS]mulrC ler_pM ?mulr_ge0 //.
near: h; exists (`|x| / 2); first by rewrite /= divr_gt0 ?normr_gt0.
move=> h; rewrite /= distrC subr0 => lthhx; rewrite addrC -[h]opprK.
apply: le_trans (@ler_dist_dist _ R _ _).
rewrite normrN [leRHS]ger0_norm.
rewrite subr_ge0; apply: ltW; apply: lt_le_trans lthhx _.
by rewrite ler_pdivrMr // -{1}(mulr1 `|x|) ler_pM // ler1n.
rewrite lerBrDr -lerBrDl (splitr `|x|).
rewrite normf_div (@ger0_norm _ 2) // addrK; apply/ltW.
Unshelve. all: by end_near. Qed.
Lemma diff_RinvSource code (xSource code : R) : x != 0 ->
'd GRing.inv x = (fun hSource code : R => - x ^- 2 *: h) :> (R -> R).
Proof.
Lemma differentiable_RinvSource code (xSource code : R) : x != 0 ->
differentiable (GRing.inv : R -> R) x.
Proof.
Lemma diffVSource code (fSource code : V -> R) xSource code : differentiable f x -> f x != 0 ->
'd (fun ySource code => (f y)^-1) x = - (f x) ^- 2 \*: 'd f x :> (V -> R).
Proof.
Lemma differentiableVSource code (fSource code : V -> R) xSource code :
differentiable f x -> f x != 0 -> differentiable (fun ySource code => (f y)^-1) x.
Proof.
Global Instance is_diffXSource code (fSource code dfSource code : V -> R) nSource code xSource code :
is_diff x f df -> is_diff x (f ^+ n.+1) (n.+1%:R * f x ^+ n *: df).
Proof.
Lemma differentiableXSource code (fSource code : V -> R) nSource code xSource code :
differentiable f x -> differentiable (f ^+ n.+1) x.
Proof.
Lemma diffXSource code (fSource code : V -> R) nSource code xSource code :
differentiable f x ->
'd (f ^+ n.+1) x = n.+1%:R * f x ^+ n \*: 'd f x :> (V -> R).
Proof.
End DifferentialR3_numFieldType.
Section DeriveRU.
Context {RSource code : numFieldType} {USource code : normedModType R}.
Implicit Types f : R -> U.
Let der1Source code fSource code xSource code : derivable f x 1 ->
f \o shift x = cst (f x) + ( *:%R^~ (f^`() x)) +o_ 0 id.
Proof.
Lemma deriv1ESource code fSource code xSource code : derivable f x 1 -> 'd f x = ( *:%R^~ (f^`() x)) :> (R -> U).
Proof.
move=> df; have lin_scal : linear d by move=> ? ? ?; rewrite /d scalerDl scalerA.
pose scallM := GRing.isLinear.Build _ _ _ _ _ lin_scal.
pose scalL : {linear _ -> _} := HB.pack d scallM.
rewrite -/d -[d]/(scalL : _ -> _).
by apply: diff_unique; [apply: scalel_continuous|apply: der1].
Qed.
Lemma diff1ESource code fSource code xSource code :
differentiable f x -> 'd f x = (fun hSource code => h *: f^`()%classic x) :> (R -> U).
Proof.
move=> df; have lin_scal : linear d by move=> ? ? ?; rewrite /d scalerDl scalerA.
pose scallM := GRing.isLinear.Build _ _ _ _ _ lin_scal.
pose scalL : {linear _ -> _} := HB.pack d scallM.
have -> : (fun hSource code => h *: f^`()%classic x) = scalL by rewrite derive1E'.
apply: diff_unique; first exact: scalel_continuous.
apply/eqaddoE; have /diff_locally -> := df; congr (_ + _ + _).
by rewrite funeqE => h /=; rewrite -{1}[h]mulr1 linearZ.
Qed.
Lemma derivable1_diffPUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.exp
Source code fSource code xSource code : derivable f x 1 <-> differentiable f x.
Proof.
by apply/diff_locallyP; rewrite deriv1E //; split;
[apply: scalel_continuous|apply: der1].
apply/derivable_nbhsP/eqaddoE.
have -> : (fun hSource code => (f \o shift x) h%:A) = f \o shift x.
by rewrite funeqE=> ?; rewrite [_%:A]mulr1.
by have /diff_locally := dfx; rewrite diff1E // derive1E =>->.
Qed.
Lemma derivable_within_continuousUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
Source code fSource code (iSource code : interval R) :
{in i, forall xSource code, derivable f x 1} -> {within [set` i], continuous f}.
Proof.
apply/differentiable_continuous; rewrite -derivable1_diffP.
by apply: di; rewrite inE.
Qed.
End DeriveRU.
Section DeriveVW.
Context {RSource code : numFieldType} {VSource code WSource code : normedModType R}.
Implicit Types f : V -> W.
Lemma derivable1PSource code fSource code xSource code vSource code :
derivable f x v <-> derivable (fun hSource code : R => f (h *: v + x)) 0 1.
Proof.
Lemma derivablePUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
Source code fSource code xSource code vSource code : derivable f x v -> is_derive x v f ('D_v f x).
Proof.
Lemma diff_derivableUsed by
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.exp
Source code fSource code aSource code vSource code : differentiable f a -> derivable f a v.
Proof.
by apply: differentiable_comp; rewrite ?scale0r ?add0r.
Qed.
Global Instance is_derive_cstSource code (aSource code : W) (xSource code vSource code : V) : is_derive x v (cst a) 0.
Proof.
Lemma derivable_cstSource code (wSource code : W) (xSource code vSource code : V) : derivable (cst w) x v.
Proof.
Lemma is_derive_eqUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.exp
Source code fSource code (xSource code vSource code : V) (dfSource code f'Source code : W) :
is_derive x v f f' -> f' = df -> is_derive x v f df.
Proof.
End DeriveVW.
Arguments derivable_cst {R V W}.
Section Derive_lemmasVW.
Context {RSource code : numFieldType} {VSource code WSource code : normedModType R}.
Implicit Types f g : V -> W.
Fact der_addSource code fSource code gSource code (xSource code vSource code : V) : derivable f x v -> derivable g x v ->
(fun hSource code => h^-1 *: (((f + g) \o shift x) (h *: v) - (f + g) x)) @
0^' --> 'D_v f x + 'D_v g x.
Proof.
Lemma deriveDUsed by
- mathcomp.analysis.probability_theory.normal_distribution
- mathcomp.analysis.gauss_integral
Source code fSource code gSource code (xSource code vSource code : V) : derivable f x v -> derivable g x v ->
'D_v (f + g) x = 'D_v f x + 'D_v g x.
Lemma derivableDUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.gauss_integral
Source code fSource code gSource code (xSource code vSource code : V) :
derivable f x v -> derivable g x v -> derivable (f + g) x v.
Global Instance is_deriveDSource code fSource code gSource code (xSource code vSource code : V) (dfSource code dgSource code : W) :
is_derive x v f df -> is_derive x v g dg -> is_derive x v (f + g) (df + dg).
Proof.
Global Instance is_derive_sumSource code nSource code (hSource code : 'I_n -> V -> W) (xSource code vSource code : V)
(dhSource code : 'I_n -> W) : (forall iSource code, is_derive x v (h i) (dh i)) ->
is_derive x v (\sum_(iSource code < n) h i) (\sum_(iSource code < n) dh i).
Proof.
Lemma derivable_sumSource code nSource code (hSource code : 'I_n -> V -> W) (xSource code vSource code : V) :
(forall iSource code, derivable (h i) x v) -> derivable (\sum_(iSource code < n) h i) x v.
Proof.
by move=> ?; apply: derivableP.
Qed.
Lemma derive_sumSource code nSource code (hSource code : 'I_n -> V -> W) (xSource code vSource code : V) :
(forall iSource code, derivable (h i) x v) ->
'D_v (\sum_(iSource code < n) h i) x = \sum_(iSource code < n) 'D_v (h i) x.
Proof.
by rewrite derive_val.
by move=> ?; apply: derivableP.
Qed.
Fact der_oppSource code fSource code (xSource code vSource code : V) : derivable f x v ->
(fun hSource code => h^-1 *: (((- f) \o shift x) (h *: v) - (- f) x)) @
0^' --> - 'D_v f x.
Proof.
Lemma deriveNUsed by
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
Source code fSource code (xSource code vSource code : V) : derivable f x v ->
'D_v (- f) x = - 'D_v f x.
Lemma derivableNUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
Source code fSource code (xSource code vSource code : V) :
derivable f x v -> derivable (- f) x v.
Global Instance is_deriveNSource code fSource code (xSource code vSource code : V) (dfSource code : W) :
is_derive x v f df -> is_derive x v (- f) (- df).
Proof.
Global Instance is_deriveBUsed by
- mathcomp.analysis.realfun
Source code fSource code gSource code (xSource code vSource code : V) (dfSource code dgSource code : W) :
is_derive x v f df -> is_derive x v g dg -> is_derive x v (f - g) (df - dg).
Proof.
Lemma deriveBUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
Source code fSource code gSource code (xSource code vSource code : V) : derivable f x v -> derivable g x v ->
'D_v (f - g) x = 'D_v f x - 'D_v g x.
Proof.
Lemma derivableBUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
Source code fSource code gSource code (xSource code vSource code : V) :
derivable f x v -> derivable g x v -> derivable (f - g) x v.
Proof.
Fact der_scalSource code fSource code (kSource code : R) (xSource code vSource code : V) : derivable f x v ->
(fun hSource code => h^-1 *: ((k \*: f \o shift x) (h *: v) - (k \*: f) x)) @
0^' --> k *: 'D_v f x.
Proof.
Lemma deriveZSource code fSource code (kSource code : R) (xSource code vSource code : V) : derivable f x v ->
'D_v (k \*: f) x = k *: 'D_v f x.
Lemma derivableZUsed by
- mathcomp.analysis.realfun
Source code fSource code (kSource code : R) (xSource code vSource code : V) :
derivable f x v -> derivable (k \*: f) x v.
Global Instance is_deriveZUsed by
- mathcomp.analysis.realfun
Source code fSource code (kSource code : R) (xSource code vSource code : V) (dfSource code : W) :
is_derive x v f df -> is_derive x v (k \*: f) (k *: df).
Proof.
Lemma derive_cstUsed by
- mathcomp.analysis.probability_theory.normal_distribution
Source code (kSource code : W) (xSource code vSource code : V) : 'D_v (cst k) x = 0.
Proof.
End Derive_lemmasVW.
Section Derive_LR.
Context {RSource code : numFieldType} {VSource code : normedModType R}.
Implicit Types (k : R -> R) (f : R -> V) (x : R).
Lemma der1_scaleLRSource code kSource code fSource code xSource code : derivable k x 1 -> derivable f x 1 ->
h^-1 *: (((fun x0Source code => k x0 *: f x0) \o shift x) h%:A - k x *: f x)
@[hSource code --> 0^'] --> 'D_1 k x *: f x + k x *: 'D_1 f x.
Proof.
(fun hSource code => (h^-1 * (k (h%:A + x) - k x)) *: f (h%:A + x) +
k x *: (h^-1 *: (f (h%:A + x) - f x)))).
near=> h.
rewrite scalerA (mulrC (k x)) -(scalerA h^-1 (k x)) -scalerA -scalerDr.
by congr (_ *: _); rewrite scalerBl scalerBr addrA subrK.
apply: cvgD.
- apply/(cvgZ der_k)/(@cvg_comp _ _ _ _ _ _ (nbhs x)).
+ apply: cvg0D => //; apply: (@cvg0M _ _ _ _ _ _ 1) => //.
exact: cvg_within_filter.
+ rewrite -/(continuous_at x f).
exact/differentiable_continuous/derivable1_diffP.
- exact: cvgZl_tmp der_f.
Unshelve. all: by end_near. Qed.
Global Instance is_derive1ZLRSource code kSource code fSource code xSource code (dkSource code : R) (dfSource code : V) :
is_derive x 1 k dk -> is_derive x 1 f df ->
is_derive x 1 (fun xSource code => k x *: f x) (dk *: f x + k x *: df).
Proof.
- exact: cvgP (der1_scaleLR _ _).
- by apply: norm_cvg_lim; exact: cvg_trans (der1_scaleLR _ _).
Qed.
Lemma deriveZLRSource code kSource code fSource code xSource code : derivable k x 1 -> derivable f x 1 ->
'D_1 (fun xSource code => k x *: f x) x = 'D_1 k x *: f x + k x *: 'D_1 f x.
Proof.
Lemma derivableZLRSource code kSource code fSource code xSource code : derivable k x 1 -> derivable f x 1 ->
derivable (fun xSource code => k x *: f x) x 1.
Proof.
End Derive_LR.
Section derive_id.
Context {RSource code : numFieldType} {VSource code : normedModType R}.
Lemma derivable_idUsed by
- mathcomp.analysis.ftc
Source code (xSource code vSource code : V) : derivable id x v.
Proof.
Global Instance is_derive_idSource code (xSource code vSource code : V) : is_derive x v id v.
Proof.
rewrite deriveE// (@diff_lin _ _ _ idfun)//=.
by rewrite /continuous_at.
Qed.
Global Instance is_deriveNidUsed by
- mathcomp.analysis.ftc
Source code (xSource code vSource code : V) : is_derive x v -%R (- v).
Proof.
Lemma derive_idUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.probability_theory.normal_distribution
- mathcomp.analysis.ftc
Source code (xSource code vSource code : V) : 'D_v id x = v.
Proof.
End derive_id.
Lemma derive1_onemUsed by
- mathcomp.analysis.ftc
Source code {RSource code : numFieldType} :
(fun xSource code => x.~ : R^o)^`()%classic = cst (-1).
Section Derive_lemmasVR.
Context {RSource code : numFieldType} {VSource code : normedModType R}.
Implicit Types (f g : V -> R) (x v : V).
Fact der_multSource code fSource code gSource code xSource code vSource code :
derivable f x v -> derivable g x v ->
(fun hSource code => h^-1 *: (((f * g) \o shift x) (h *: v) - (f * g) x)) @
0^' --> f x *: 'D_v g x + g x *: 'D_v f x.
Proof.
evar (fg : R -> R); rewrite [X in X @ _](_ : _ = fg) /=.
rewrite funeqE => h.
have -> : (f * g) (h *: v + x) - (f * g) x =
f (h *: v + x) *: (g (h *: v + x) - g x) + g x *: (f (h *: v + x) - f x).
by rewrite !scalerBr -addrA ![g x *: _]mulrC addKr.
rewrite scalerDr scalerA mulrC -scalerA.
by rewrite [_ *: (g x *: _)]scalerA mulrC -scalerA /fg.
apply: cvgD; last exact: cvgZl_tmp df.
apply: cvg_comp2 (@scale_continuous _ _ (_, _)) => /=; last exact: dg.
suff : {for 0, continuous (fun hSource code : R => f(h *: v + x))}.
by move=> /continuous_withinNx; rewrite scale0r add0r.
exact/differentiable_continuous/derivable1_diffP/(derivable1P _ _ _).1.
Qed.
Lemma deriveMUsed by
- mathcomp.analysis.probability_theory.normal_distribution
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
- mathcomp.analysis.exp
Source code fSource code gSource code xSource code vSource code : derivable f x v -> derivable g x v ->
'D_v (f * g) x = f x *: 'D_v g x + g x *: 'D_v f x.
Lemma derivableMUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.pi_irrational
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.exp
Source code fSource code gSource code xSource code vSource code :
derivable f x v -> derivable g x v -> derivable (f * g) x v.
Proof.
Lemma deriveMrUsed by
- mathcomp.analysis.gauss_integral
Source code fSource code (rSource code : R) xSource code vSource code :
derivable f x v -> 'D_v (r \o* f) x = r * 'D_v f x.
Proof.
Lemma deriveMlSource code fSource code (rSource code : R) xSource code vSource code :
derivable f x v -> 'D_v (r \*o f) x = r * 'D_v f x.
Global Instance is_deriveMSource code fSource code gSource code xSource code vSource code (dfSource code dgSource code : R) :
is_derive x v f df -> is_derive x v g dg ->
is_derive x v (f * g) (f x *: dg + g x *: df).
Proof.
Global Instance is_deriveXSource code fSource code nSource code xSource code vSource code (dfSource code : R) :
is_derive x v f df -> is_derive x v (f ^+ n) ((n%:R * f x ^+ n.-1) *: df).
Proof.
Lemma derivableXUsed by
- mathcomp.analysis.probability_theory.beta_distribution
Source code fSource code nSource code xSource code vSource code : derivable f x v -> derivable (f ^+ n) x v.
Proof.
Lemma deriveXSource code fSource code nSource code xSource code vSource code : derivable f x v ->
'D_v (f ^+ n) x = (n%:R * f x ^+ n.-1) *: 'D_v f x.
Proof.
Fact der_invSource code fSource code xSource code vSource code : f x != 0 -> derivable f x v ->
(fun hSource code => h^-1 *: (((fun ySource code => (f y)^-1) \o shift x) (h *: v) - (f x)^-1)) @
0^' --> - (f x) ^-2 *: 'D_v f x.
Proof.
have /derivable1P/derivable1_diffP/differentiable_continuous := df.
move=> /continuous_withinNx; rewrite scale0r add0r => fc.
have fn0 : 0^' [set hSource code | f (h *: v + x) != 0].
apply: (fc [set xSource code | x != 0]); exists `|f x|; first by rewrite /= normr_gt0.
move=> y; rewrite /= => yltfx.
by apply/eqP => y0; move: yltfx; rewrite y0 subr0 ltxx.
have : (fun hSource code => - ((f x)^-1 * (f (h *: v + x))^-1) *:
(h^-1 *: (f (h *: v + x) - f x))) @ 0^' -->
- (f x) ^- 2 *: 'D_v f x.
by apply: cvgM => //; apply: cvgN; rewrite expr2 invfM; apply: cvgM => //;
exact: cvgV.
apply: cvg_trans => A [_/posnumP[e] /= Ae].
move: fn0; apply: filter_app; near=> h => /= fhvxn0.
have he : ball 0 e%:num (h : R) by near: h; exists e%:num => /=.
have hn0 : h != 0 by near: h; exists e%:num => /=.
suff <- :
- ((f x)^-1 * (f (h *: v + x))^-1) *: (h^-1 *: (f (h *: v + x) - f x)) =
h^-1 *: ((f (h *: v + x))^-1 - (f x)^-1) by exact: Ae.
rewrite scalerA mulrC -scalerA; congr (_ *: _).
apply/eqP; rewrite scaleNr eqr_oppLR opprB scalerBr.
rewrite -scalerA [_ *: f _]mulVf // [_%:A]mulr1.
by rewrite mulrC -scalerA [_ *: f _]mulVf // [_%:A]mulr1.
Unshelve. all: by end_near. Qed.
Lemma deriveVSource code fSource code xSource code vSource code : f x != 0 -> derivable f x v ->
'D_v (fun ySource code => (f y)^-1) x = - (f x) ^- 2 *: 'D_v f x.
Lemma derivableVSource code fSource code xSource code vSource code :
f x != 0 -> derivable f x v -> derivable (fun ySource code => (f y)^-1) x v.
Lemma is_deriveVUsed by
- mathcomp.analysis.realfun
Source code fSource code xSource code vSource code (dfSource code : R) :
f x != 0 -> is_derive x v f df ->
is_derive x v (fun ySource code => (f y)^-1) (- (f x) ^- 2 *: df).
Proof.
by rewrite deriveV//; case: Df => _ ->.
Qed.
End Derive_lemmasVR.
#[global] Hint Extern 0 (is_derive _ _ (fun _ => (_ _)^-1) _) =>
(apply: is_deriveV; first by []) : typeclass_instances.
Lemma derive_shiftSource code {RSource code : numFieldType} {VSource code : normedModType R} (vSource code kSource code : V) :
'D_v (shift k : V -> V) = cst v.
Proof.
Lemma derive1_shiftUsed by
- mathcomp.analysis.ftc
Source code {RSource code : numFieldType} (kSource code : R) : (shift k)^`() = cst 1.
Proof.
Lemma is_derive_shiftSource code {RSource code : numFieldType} {VSource code : normedModType R} xSource code (vSource code kSource code : V) :
is_derive x v (shift k) v.
Proof.
Section derive_comp_shift.
Context {RSource code : numFieldType} {VSource code : normedModType R} (fSource code : R -> V).
Implicit Types x a v : R.
Lemma derive_comp_shiftSource code xSource code aSource code vSource code : 'D_v (f \o shift a) x = 'D_v f (x + a).
Lemma derive1_comp_shiftSource code xSource code aSource code : (f \o shift a)^`() x = f^`() (x + a).
Proof.
Lemma derivable_comp_shiftUsed by
- mathcomp.analysis.realfun
Source code xSource code aSource code vSource code :
derivable f (x + a) v -> derivable (f \o shift a) x v.
Lemma is_derive_comp_shiftSource code xSource code aSource code (dfSource code : V) :
is_derive (x + a) 1 f df -> is_derive x 1 (f \o shift a) df.
Proof.
End derive_comp_shift.
Lemma derive1_cstUsed by
- mathcomp.analysis.probability_theory.beta_distribution
Source code {RSource code : numFieldType} (VSource code : normedModType R) (kSource code : V) tSource code :
(cst k)^`() t = 0.
Proof.
Lemma derive1MrUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.gauss_integral
Source code {RSource code : numFieldType} (fSource code : R -> R) (xSource code rSource code : R) :
derivable f x 1 ->
(fun xSource code => f x * r)^`()%classic x = f^`()%classic x * r.
Lemma derive1MlUsed by
- mathcomp.analysis.probability_theory.exponential_distribution
Source code {RSource code : numFieldType} (fSource code : R -> R) (xSource code rSource code : R) :
derivable f x 1 ->
(fun xSource code => r * f x)^`()%classic x = r * f^`()%classic x :> R.
Lemma exprn_derivableUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.realfun
- mathcomp.analysis.gauss_integral
Source code {RSource code : numFieldType} nSource code (xSource code : R) vSource code :
derivable (@GRing.exp R ^~ n) x v.
Proof.
rewrite (_ : _ ^~ _ = (fun xSource code => x * x ^+ n)).
by apply/funext => y; rewrite exprS.
by apply: derivableM; first exact: derivable_id.
Qed.
Lemma exp_deriveUsed by
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.realfun
- mathcomp.analysis.gauss_integral
Source code {RSource code : numFieldType} nSource code xSource code vSource code :
'D_v (@GRing.exp R ^~ n) x = n%:R *: x ^+ n.-1 *: v.
Proof.
by rewrite fctE => ->; rewrite derive_id.
Qed.
Global Instance is_derive_expUsed by
- mathcomp.analysis.exp
Source code (RSource code : numFieldType) nSource code xSource code vSource code :
is_derive x v (@GRing.exp R ^~ n) (n%:R *: x ^+ n.-1 *: v).
Proof.
Lemma exp_derive1Used by
- mathcomp.analysis.gauss_integral
Source code {RSource code : numFieldType} nSource code xSource code :
(@GRing.exp R ^~ n)^`() x = n%:R *: x ^+ n.-1.
Proof.
Lemma compact_EVT_maxSource code (TSource code : topologicalType) (RSource code : realType) (fSource code : T -> R)
(ASource code : set T) :
A !=set0 -> compact A -> {within A, continuous f} ->
exists2 cSource code, c \in A & forall tSource code, t \in A -> f t <= f c.
Proof.
have sup_fA : has_sup (f @` A).
by apply/compact_has_sup; [exact: image_nonempty A0|exact/continuous_compact].
have [|imf_ltsup] := pselect (exists2 cSource code, c \in A & f c = sup (f @` A)).
move=> [c cinA fcsupfA]; exists c => // t tA; rewrite fcsupfA.
by apply/sup_upper_bound => //; exact/imageP/set_mem.
have {}AfsupfA t : t \in A -> f t < sup (f @` A).
move=> tA; have [//|supfAft] := ltrP (f t) (sup (f @` A)).
rewrite falseE; apply: imf_ltsup; exists t => //.
apply/eqP; rewrite eq_le supfAft andbT sup_upper_bound//.
exact/imageP/set_mem.
pose g tSource code : R := (sup (f @` A) - f t)^-1.
have invf_continuous : {within A, continuous g}.
rewrite continuous_subspace_in => t tA; apply: cvgV => //=.
by rewrite subr_eq0 gt_eqF// AfsupfA//; rewrite inE in tA.
by apply: cvgD => //; apply: cvgN; exact: cf.
have /ex_strict_bound_gt0[k k_gt0 /= imVfltk] : bounded_set (g @` A).
exact/compact_bounded/continuous_compact.
have [_ [t tA <-]] : exists2 ySource code, (f @` A) y & sup (f @` A) - k^-1 < y.
by apply: sup_adherent => //; rewrite invr_gt0.
rewrite ltrBlDr -ltrBlDl.
suff : sup (f @` A) - f t > k^-1 by move=> /ltW; rewrite leNgt => /negbTE ->.
rewrite invf_plt ?posrE ?subr_gt0 ?AfsupfA//; first exact/mem_set.
by rewrite (le_lt_trans (ler_norm _))// imVfltk//; exact: imageP.
Qed.
Lemma compact_EVT_minSource code (TSource code : topologicalType) (RSource code : realType) (fSource code : T -> R)
(ASource code : set T) :
A !=set0 -> compact A -> {within A, continuous f} ->
exists2 cSource code, c \in A & forall tSource code, t \in A -> f c <= f t.
Proof.
have /(compact_EVT_max A0 cA)[c cinA fcmin] : {within A, continuous (- f)}.
by move=> ?; apply: continuousN => ?; exact: cf.
by exists c => // t tA; rewrite -lerN2 fcmin.
Qed.
Lemma EVT_maxSource code (RSource code : realType) (fSource code : R -> R) (aSource code bSource code : R) :
a <= b -> {within `[a, b], continuous f} ->
exists2 cSource code, c \in `[a, b]%R & forall tSource code, t \in `[a, b]%R -> f t <= f c.
Proof.
have ab0 : `[a, b] !=set0 by exists a => /=; rewrite in_itv/= lexx.
have [/= c cab maxf] := compact_EVT_max ab0 (@segment_compact _ a b) cf.
by rewrite inE in cab; exists c => //= t tab; apply: maxf; rewrite inE.
Qed.
Lemma EVT_minUsed by
- mathcomp.analysis.pi_irrational
Source code (RSource code : realType) (fSource code : R -> R) (aSource code bSource code : R) :
a <= b -> {within `[a, b], continuous f} ->
exists2 cSource code, c \in `[a, b]%R & forall tSource code, t \in `[a, b]%R -> f c <= f t.
Proof.
have ab0 : `[a, b] !=set0 by exists a => /=; rewrite in_itv/= lexx.
have [/= c cab minf] := compact_EVT_min ab0 (@segment_compact _ a b) cf.
by rewrite inE in cab; exists c => //= t tab; apply: minf; rewrite inE.
Qed.
Lemma EVT_max_rVSource code (RSource code : realType) nSource code (fSource code : 'rV[R]_n -> R) (ASource code : set 'rV[R]_n) :
A !=set0 -> compact A -> {within A, continuous f} ->
exists2 cSource code, c \in A & forall tSource code, t \in A -> f t <= f c.
Proof.
Lemma EVT_min_rVSource code (RSource code : realType) nSource code (fSource code : 'rV[R]_n -> R) (ASource code : set 'rV[R]_n) :
A !=set0 -> compact A -> {within A, continuous f} ->
exists2 cSource code, c \in A & forall tSource code, t \in A -> f c <= f t.
Proof.
Lemma cvg_at_rightESource code (RSource code : numFieldType) (VSource code : normedModType R) (fSource code : R -> V) xSource code :
cvg (f @ x^') -> lim (f @ x^') = lim (f @ at_right x).
Proof.
move=> A /cvfx /nbhs_ballP [_ /posnumP[e] xe_A].
by exists e%:num => //= y xe_y /gt_eqF/negbT/xe_A; exact.
Qed.
Lemma cvg_at_leftESource code (RSource code : numFieldType) (VSource code : normedModType R) (fSource code : R -> V) xSource code :
cvg (f @ x^') -> lim (f @ x^') = lim (f @ at_left x).
Proof.
move=> A /cvfx /nbhs_ballP [_ /posnumP[e] xe_A].
by exists e%:num => //= y xe_y /lt_eqF/negbT/xe_A; exact.
Qed.
Lemma derive1_at_maxSource code (RSource code : realFieldType) (fSource code : R -> R) (aSource code bSource code cSource code : R) :
a <= b -> (forall tSource code, t \in `]a, b[%R -> derivable f t 1) -> c \in `]a, b[%R ->
(forall tSource code, t \in `]a, b[%R -> f t <= f c) -> is_derive c 1 f 0.
Proof.
apply/eqP; rewrite eq_le; apply/andP; split.
rewrite ['D_1 f c]cvg_at_rightE; first exact: fdrvbl.
apply: limr_le.
have /fdrvbl dfc := cab.
rewrite -(cvg_at_rightE (fun hSource code : R => h^-1 *: ((f \o shift c) _ - f c))) //.
apply: cvg_trans dfc; apply: cvg_app.
move=> A [e egt0 Ae]; exists e => // x xe xgt0; apply: Ae => //.
exact/lt0r_neq0.
near=> h; apply: mulr_ge0_le0.
by rewrite invr_ge0; apply: ltW; near: h; exists 1 => /=.
rewrite subr_le0 [_%:A]mulr1; apply: cmax; near: h.
exists (b - c); first by rewrite /= subr_gt0 (itvP cab).
move=> h; rewrite /= distrC subr0 /= in_itv /= -ltrBrDr.
move=> /(le_lt_trans (ler_norm _)) -> /ltr_pDl -> //.
by rewrite (itvP cab).
rewrite ['D_1 f c]cvg_at_leftE; first exact: fdrvbl.
apply: limr_ge.
have /fdrvbl dfc := cab; rewrite -(cvg_at_leftE (fun hSource code => h^-1 *: ((f \o shift c) _ - f c))) //.
apply: cvg_trans dfc; apply: cvg_app.
move=> A [e egt0 Ae]; exists e => // x xe xgt0; apply: Ae => //.
exact/ltr0_neq0.
near=> h; apply: mulr_le0.
by rewrite invr_le0; apply: ltW; near: h; exists 1 => /=.
rewrite subr_le0 [_%:A]mulr1; apply: cmax; near: h.
exists (c - a); first by rewrite /= subr_gt0 (itvP cab).
move=> h; rewrite /= distrC subr0.
move=> /ltr_normlP []; rewrite ltrBrDl ltrBlDl in_itv /= => -> _.
by move=> /ltr_nDl -> //; rewrite (itvP cab).
Unshelve. all: by end_near. Qed.
Lemma derive1_at_minSource code (RSource code : realFieldType) (fSource code : R -> R) (aSource code bSource code cSource code : R) :
a <= b -> (forall tSource code, t \in `]a, b[%R -> derivable f t 1) -> c \in `]a, b[%R ->
(forall tSource code, t \in `]a, b[%R -> f c <= f t) -> is_derive c 1 f 0.
Proof.
apply/eqP; rewrite -oppr_eq0; apply/eqP.
rewrite -deriveN; first exact: fdrvbl.
suff df : is_derive c 1 (- f) 0 by rewrite derive_val.
apply: derive1_at_max leab _ (cab) _ => t tab; first exact/derivableN/fdrvbl.
by rewrite lerN2; apply: cmin.
Qed.
Lemma RolleUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.elementary_functions.trigonometry_functions
Source code (RSource code : realType) (fSource code : R -> R) (aSource code bSource code : R) :
a < b -> (forall xSource code, x \in `]a, b[%R -> derivable f x 1) ->
{within `[a, b], continuous f} -> f a = f b ->
exists2 cSource code, c \in `]a, b[%R & is_derive c 1 f 0.
Proof.
have [cmax cmaxab fcmax] := EVT_max (ltW ltab) fcont.
have [cmaxeaVb|] := boolP (cmax \in [set a; b]); last first.
rewrite notin_setE => /not_orP[/eqP cnea /eqP cneb].
have {}cmaxab : cmax \in `]a, b[%R.
by rewrite in_itv /= !lt_def !(itvP cmaxab) cnea eq_sym cneb.
exists cmax => //; apply: derive1_at_max (ltW ltab) fdrvbl cmaxab _ => t tab.
by apply: fcmax; rewrite in_itv /= !ltW // (itvP tab).
have [cmin cminab fcmin] := EVT_min (ltW ltab) fcont.
have [cmineaVb|] := boolP (cmin \in [set a; b]); last first.
rewrite notin_setE => /not_orP[/eqP cnea /eqP cneb].
have {}cminab : cmin \in `]a, b[%R.
by rewrite in_itv /= !lt_def !(itvP cminab) cnea eq_sym cneb.
exists cmin => //; apply: derive1_at_min (ltW ltab) fdrvbl cminab _ => t tab.
by apply: fcmin; rewrite in_itv /= !ltW // (itvP tab).
have midab : (a + b) / 2 \in `]a, b[%R by apply: mid_in_itvoo.
exists ((a + b) / 2) => //; apply: derive1_at_max (ltW ltab) fdrvbl (midab) _.
move=> t tab.
suff fcst s : s \in `]a, b[%R -> f s = f cmax by rewrite !fcst.
move=> sab.
apply/eqP; rewrite eq_le fcmax; first by rewrite in_itv /= !ltW ?(itvP sab).
suff -> : f cmax = f cmin by rewrite fcmin // in_itv /= !ltW ?(itvP sab).
by move: cmaxeaVb cmineaVb; rewrite 2!inE => -[|] -> [|] ->.
Qed.
Lemma MVTUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.lebesgue_integral_theory.lebesgue_integral_under
- mathcomp.analysis.exp
Source code (RSource code : realType) (fSource code dfSource code : R -> R) (aSource code bSource code : R) :
a < b -> (forall xSource code, x \in `]a, b[%R -> is_derive x 1 f (df x)) ->
{within `[a, b], continuous f} ->
exists2 cSource code, c \in `]a, b[%R & f b - f a = df c * (b - a).
Proof.
set g := f + (- ( *:%R^~ ((f b - f a) / (b - a)) : R -> R)).
have gdrvbl x : x \in `]a, b[%R -> derivable g x 1.
by move=> /fdrvbl dfx; apply/derivableB/derivable1_diffP.
have gcont : {within `[a, b], continuous g}.
move=> x; apply: continuousD _ ; first exact: fcont.
exact/continuousN/continuous_subspaceT/scalel_continuous.
have gaegb : g a = g b.
rewrite /g -![(_ - _ : _ -> _) _]/(_ - _).
apply/eqP; rewrite -subr_eq /= opprK addrAC -addrA -scalerBl.
rewrite [_ *: _]mulrC divfK; last by rewrite addrC subrK.
by apply: lt0r_neq0; rewrite subr_gt0.
have [c cab dgc0] := Rolle altb gdrvbl gcont gaegb.
exists c; first exact: cab.
have /fdrvbl dfc := cab; move/@derive_val: dgc0; rewrite deriveB //.
move/eqP; rewrite [X in _ - X]deriveE // derive_val diff_val scale1r subr_eq0.
by move/eqP->; rewrite divfK// subr_eq0 gt_eqF.
Qed.
Lemma MVT_segmentUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.elementary_functions.trigonometry_functions
Source code (RSource code : realType) (fSource code dfSource code : R -> R) (aSource code bSource code : R) :
a <= b -> (forall xSource code, x \in `]a, b[%R -> is_derive x 1 f (df x)) ->
{within `[a, b], continuous f} ->
exists2 cSource code, c \in `[a, b]%R & f b - f a = df c * (b - a).
Proof.
Section ger0_derive1_le.
Context {RSource code : realType} (fSource code : R -> R) (aSource code bSource code : R).
Hypothesis dfSource code : forall xSource code, x \in `]a, b[%R -> derivable f x 1.
Hypothesis dfge0Source code : forall xSource code, x \in `]a, b[%R -> 0 <= f^`() x.
Lemma ger0_derive1_leSource code (saSource code sbSource code : bool) :
{within [set` (Interval (BSide sa a) (BSide sb b))], continuous f} ->
{in Interval (BSide sa a) (BSide sb b) &, {homo f : xSource code ySource code / x <= y}}.
Proof.
move: (xy); rewrite le_eqVlt=> /predU1P[-> | xy']; first by rewrite lexx.
rewrite !itv_boundlr -subr_ge0 /= => /andP[ax _] /andP[_ yb].
have HMVT1 : {within `[x, y], continuous f}.
exact/(continuous_subspaceW _ cf)/subset_itv.
have zab : `]x, y[ `<=` `]a, b[.
clear -ax yb; apply/subset_itv.
by move: sa ax => []; rewrite !bnd_simp// => /ltW.
by move: sb yb => []; rewrite !bnd_simp// => /ltW.
have HMVT0 z : z \in `]x, y[%R -> is_derive z 1 f (f^`() z).
by move=> zxy; rewrite derive1E; exact/derivableP/df/zab.
have[z zxy ->]:= MVT xy' HMVT0 HMVT1.
by rewrite mulr_ge0// ?subr_ge0// dfge0// zab.
Qed.
Lemma ger0_derive1_le_ccSource code : {within `[a, b] , continuous f} ->
{in `[a, b]%R &, {homo f : xSource code ySource code / x <= y >-> x <= y}}.
Proof.
Lemma ger0_derive1_le_coSource code : {within `[a, b[ , continuous f} ->
{in `[a, b[%R &, {homo f : xSource code ySource code / x <= y >-> x <= y}}.
Proof.
Lemma ger0_derive1_le_ocSource code : {within `]a, b], continuous f} ->
{in `]a, b]%R &, {homo f : xSource code ySource code / x <= y >-> x <= y}}.
Proof.
Lemma ger0_derive1_le_ooSource code : {in `]a, b[, continuous f} ->
{in `]a, b[%R &, {homo f : xSource code ySource code / x <= y >-> x <= y}}.
Proof.
End ger0_derive1_le.
Section ler0_derive1_le.
Context {RSource code : realType} (fSource code : R -> R) (aSource code bSource code : R).
Hypothesis dfSource code : forall xSource code, x \in `]a, b[%R -> derivable f x 1.
Hypothesis dfle0Source code : forall xSource code, x \in `]a, b[%R -> f^`() x <= 0.
Lemma ler0_derive1_leSource code (saSource code sbSource code : bool) :
{within [set` (Interval (BSide sa a) (BSide sb b))], continuous f} ->
{in Interval (BSide sa a) (BSide sb b) &, {homo f : xSource code ySource code /~ x <= y}}.
Proof.
suff : {in Interval (BSide sa a) (BSide sb b) &, {homo (- f) : xSource code ySource code / x <= y}}.
by move=> h y x iy ix xy; move: (h x y ix iy xy); rewrite opprfctE lerNl opprK.
apply: ger0_derive1_le.
- move => x xab; exact/derivableN/df.
- move => x xab; rewrite derive1E deriveN; first exact: df.
by rewrite -derive1E oppr_ge0 dfle0.
by move=> x; exact/continuousN/cf.
Qed.
Lemma ler0_derive1_le_ccSource code :{within `[a, b], continuous f} ->
{in `[a, b]%R &, {homo f : xSource code ySource code /~ x <= y}}.
Proof.
Lemma ler0_derive1_le_coSource code : {within `[a, b[, continuous f} ->
{in `[a, b[%R &, {homo f : xSource code ySource code /~ x <= y}}.
Proof.
Lemma ler0_derive1_le_ocSource code : {within `]a, b], continuous f} ->
{in `]a, b]%R &, {homo f : xSource code ySource code /~ x <= y}}.
Proof.
Lemma ler0_derive1_le_ooSource code : {in `]a, b[, continuous f} ->
{in `]a, b[%R &, {homo f : xSource code ySource code /~ x <= y}}.
Proof.
End ler0_derive1_le.
Section gtr0_derive1_lt.
Context {RSource code : realType} (fSource code : R -> R) (aSource code bSource code : R).
Hypothesis dfSource code : forall xSource code, x \in `]a, b[%R -> derivable f x 1.
Hypothesis dfgt0Source code : forall xSource code, x \in `]a, b[%R -> 0 < f^`() x.
Lemma gtr0_derive1_ltSource code (saSource code sbSource code : bool) :
{within [set` (Interval (BSide sa a) (BSide sb b))], continuous f} ->
{in Interval (BSide sa a) (BSide sb b) &, {homo f : xSource code ySource code / x < y}}.
Proof.
rewrite !itv_boundlr /= -subr_gt0 => /andP [] ax ? /andP [] ? yb.
have HMVT1: {within `[x, y], continuous f}.
exact/(continuous_subspaceW _ cf)/subset_itv.
have zab : `]x, y[ `<=` `]a, b[.
clear -ax yb; apply/subset_itv.
by move: sa ax => []; rewrite !bnd_simp// => /ltW.
by move: sb yb => []; rewrite !bnd_simp// => /ltW.
have HMVT0 (zSource code : R^o) : z \in `]x, y[%R -> is_derive z 1 f (f^`() z).
by move=> zxy; rewrite derive1E; exact/derivableP/df/zab.
have[z zxy ->]:= MVT xy HMVT0 HMVT1.
by rewrite mulr_gt0// ?subr_gt0// dfgt0// zab.
Qed.
Lemma gtr0_derive1_lt_ccSource code : {within `[a, b], continuous f} ->
{in `[a, b]%R &, {homo f : xSource code ySource code / x < y}}.
Proof.
Lemma gtr0_derive1_lt_coSource code : {within `[a, b[, continuous f} ->
{in `[a, b[%R &, {homo f : xSource code ySource code / x < y}}.
Proof.
Lemma gtr0_derive1_lt_ocSource code : {within `]a, b], continuous f} ->
{in `]a, b]%R &, {homo f : xSource code ySource code / x < y}}.
Proof.
Lemma gtr0_derive1_lt_ooSource code : {in `]a, b[, continuous f} ->
{in `]a, b[%R &, {homo f : xSource code ySource code / x < y}}.
Proof.
End gtr0_derive1_lt.
Section ltr0_derive1_lt.
Context {RSource code : realType} (fSource code : R -> R) (aSource code bSource code : R).
Hypothesis dfSource code : forall xSource code, x \in `]a, b[%R -> derivable f x 1.
Hypothesis dflt0Source code : forall xSource code, x \in `]a, b[%R -> f^`() x < 0.
Lemma ltr0_derive1_ltSource code (saSource code sbSource code : bool) :
{within [set` (Interval (BSide sa a) (BSide sb b))], continuous f} ->
{in Interval (BSide sa a) (BSide sb b) &, {homo f : xSource code ySource code /~ x < y}}.
Proof.
suff : {in Interval (BSide sa a) (BSide sb b) &, {homo (- f) : xSource code ySource code / x < y}}.
by move=> h x y ix iy xy; move: (h y x iy ix xy); rewrite opprfctE ltrNl opprK.
apply: gtr0_derive1_lt.
- move => x xab; exact/derivableN/df.
- move => x xab; rewrite derive1E deriveN; first exact: df.
by rewrite -derive1E oppr_gt0 dflt0.
by move=> x; exact/continuousN/cf.
Qed.
Lemma ltr0_derive1_lt_ccSource code : {within `[a, b], continuous f} ->
{in `[a, b]%R &, {homo f : xSource code ySource code /~ x < y}}.
Proof.
Lemma ltr0_derive1_lt_coSource code : {within `[a, b[, continuous f} ->
{in `[a, b[%R &, {homo f : xSource code ySource code /~ x < y}}.
Proof.
Lemma ltr0_derive1_lt_ocSource code : {within `]a, b], continuous f} ->
{in `]a, b]%R &, {homo f : xSource code ySource code /~ x < y}}.
Proof.
Lemma ltr0_derive1_lt_ooSource code : {in `]a, b[, continuous f} ->
{in `]a, b[%R &, {homo f : xSource code ySource code /~ x < y}}.
Proof.
End ltr0_derive1_lt.
#[global] Hint Extern 0 (is_true (_ <= ?x)) => match goal with
H : x \is_near _ |- _ =>
solve[near: x; apply: nbhs_pinfty_ge; apply: num_real]
end : core.
#[global] Hint Extern 0 (is_true (?x <= _)) => match goal with
H : x \is_near _ |- _ =>
solve[near: x; apply: nbhs_ninfty_le; apply: num_real]
end : core.
Lemma ler0_derive1_nincrySource code {RSource code : realType} (fSource code : R -> R) (aSource code : R) :
(forall xSource code, x \in `]a, +oo[%R -> derivable f x 1) ->
(forall xSource code, x \in `]a, +oo[%R -> f^`() x <= 0) ->
{within `[a, +oo[, continuous f} ->
forall xSource code ySource code, a <= x -> x <= y -> f y <= f x.
Proof.
near (pinfty_nbhs R)%R => N.
apply: (@ler0_derive1_le_cc _ _ a N) => [r|r| | | | // ]; rewrite ?in_itv/=.
- by move=> /andP[ar rN]; apply: df; rewrite !in_itv/= andbT ar.
- by move=> /andP[ar rN]; apply: dfle0; rewrite !in_itv/= andbT ar.
- exact/continuous_subspaceW/cf/subset_itvl.
- by rewrite (le_trans ax)/=.
- by rewrite ax/=.
Unshelve. all: end_near. Qed.
Lemma ler0_derive1_nincrNySource code {RSource code : realType} (fSource code : R -> R) (bSource code : R) :
(forall xSource code, x \in `]-oo, b[%R -> derivable f x 1) ->
(forall xSource code, x \in `]-oo, b[%R -> f^`() x <= 0) ->
{within `]-oo, b], continuous f} ->
forall xSource code ySource code, x <= y -> y <= b -> f y <= f x.
Proof.
near (ninfty_nbhs R)%R => N.
apply: (@ler0_derive1_le_cc _ _ N b) => [r|r| | | | // ]; rewrite ?in_itv/=.
- by move=> /andP[Nr rb]; apply: df; rewrite !in_itv/= rb.
- by move=> /andP[Nr rb]; apply: dfle0; rewrite !in_itv/= rb.
- exact/continuous_subspaceW/cf/subset_itvr.
- by rewrite yb andbT.
by rewrite (le_trans xy)//= andbT.
Unshelve. all: end_near. Qed.
Lemma ger0_derive1_ndecrSource code (RSource code : realType) (fSource code : R -> R) (aSource code bSource code : R) :
(forall xSource code, x \in `]a, b[%R -> derivable f x 1) ->
(forall xSource code, x \in `]a, b[%R -> 0 <= f^`() x) ->
{within `[a,b], continuous f} ->
forall xSource code ySource code, a <= x -> x <= y -> y <= b -> f x <= f y.
Proof.
by apply: (@ger0_derive1_le_cc _ _ a b) => //;
rewrite in_itv/= ?(le_trans _ xy)//= ?(le_trans xy) ?andbT.
Qed.
Lemma ger0_derive1_ndecrySource code {RSource code : realType} (fSource code : R -> R) (aSource code : R) :
(forall xSource code, x \in `]a, +oo[%R -> derivable f x 1) ->
(forall xSource code, x \in `]a, +oo[%R -> 0 <= f^`() x) ->
{within `[a, +oo[, continuous f} ->
forall xSource code ySource code, a <= x -> x <= y -> f x <= f y.
Proof.
near (pinfty_nbhs R)%R => N.
apply: (@ger0_derive1_le_cc _ _ a N) => [r|r| | | | // ]; rewrite ?in_itv/=.
- by move=> /andP[ar rN]; apply: df; rewrite !in_itv/= andbT ar.
- by move=> /andP[ar rN]; apply: dfge0; rewrite !in_itv/= andbT ar.
- exact/continuous_subspaceW/cf/subset_itvl.
- by rewrite (le_trans ax)/=.
- by rewrite (le_trans ax)/=.
Unshelve. all: end_near. Qed.
Lemma ger0_derive1_ndecrNySource code {RSource code : realType} (fSource code : R -> R) (bSource code : R) :
(forall xSource code, x \in `]-oo, b[%R -> derivable f x 1) ->
(forall xSource code, x \in `]-oo, b[%R -> 0 <= f^`() x) ->
{within `]-oo, b], continuous f} ->
forall xSource code ySource code, x <= y -> y <= b -> f x <= f y.
Proof.
near (ninfty_nbhs R)%R => N.
apply: (@ger0_derive1_le_cc _ _ N b) => [r|r| | | | // ]; rewrite ?in_itv/=.
- by move=> /andP[Nr rb]; apply: df; rewrite !in_itv/=.
- by move=> /andP[Nr rb]; apply: dfge0; rewrite !in_itv/=.
- exact/continuous_subspaceW/cf/subset_itvr.
- by rewrite (le_trans xy)//= andbT.
- by rewrite yb andbT.
Unshelve. all: end_near. Qed.
Lemma decr_derive1_le0Used by
- mathcomp.analysis.ftc
Source code {RSource code : realFieldType} (fSource code : R -> R) (DSource code : set R) (xSource code : R) :
{in D° : set R, forall xSource code, derivable f x 1%R} ->
{in D &, {homo f : xSource code ySource code /~ x < y}} ->
D° x -> f^`() x <= 0.
Proof.
apply: limr_le.
under eq_fun; first (move=> h; rewrite -{2}(scaler1 h); over).
by apply: df; rewrite inE.
have [e /= e0 Hball] := open_subball (open_interior D) Dx.
near=> h.
have h0 : h != 0%R by near: h.
have Dhx : D° (h + x).
apply: (Hball (`|2 * h|%R)) => //.
- rewrite /= sub0r normrN normr_id normrM ger0_norm// -ltr_pdivlMl//.
by near: h; apply: dnbhs0_lt; exact: mulr_gt0.
by rewrite normrM ger0_norm// mulr_gt0// normr_gt0.
apply: ball_sym; rewrite /ball/= addrK.
by rewrite normrM (@ger0_norm _ 2)// ltr_pMl ?normr_gt0// ltr1n.
move: h0; rewrite neq_lt => /orP[h0|h0].
- rewrite nmulr_rle0 ?invr_lt0// subr_ge0 ltW//.
by apply: decrf; rewrite ?in_itv ?andbT ?gtrDr// inE; exact: interior_subset.
- rewrite pmulr_rle0 ?invr_gt0// subr_le0 ltW//.
by apply: decrf; rewrite ?in_itv ?andbT ?ltrDr// inE; exact: interior_subset.
Unshelve. end_near. Qed.
Lemma decr_derive1_le0_itvSource code {RSource code : realType} (fSource code : R -> R)
(b0Source code b1Source code : bool) (aSource code bSource code : R) (zSource code : R) :
{in `]a, b[, forall xSource code : R, derivable f x 1%R} ->
{in Interval (BSide b0 a) (BSide b1 b) &, {homo f : xSource code ySource code /~ (x < y)%R}} ->
z \in `]a, b[%R -> f^`() z <= 0.
Proof.
Lemma decr_derive1_le0_itvySource code {RSource code : realType} (fSource code : R -> R)
(b0Source code : bool) (aSource code : R) (zSource code : R) :
{in `]a, +oo[, forall xSource code : R, derivable f x 1%R} ->
{in Interval (BSide b0 a) (BInfty _ false) &, {homo f : xSource code ySource code /~ (x < y)%R}} ->
z \in `]a, +oo[%R -> f^`() z <= 0.
Proof.
have {}zay : [set` (Interval (BSide b0 a) (BInfty _ false))]° z.
by rewrite interior_itv// inE/=.
apply: decr_derive1_le0 zay; first by rewrite interior_itv.
by move=> x y /[!inE]/=; apply/decrf.
Qed.
Lemma decr_derive1_le0_itvNySource code {RSource code : realType} (fSource code : R -> R)
(b1Source code : bool) (bSource code : R) (zSource code : R) :
{in `]-oo, b[, forall xSource code : R, derivable f x 1%R} ->
{in Interval (BInfty _ true) (BSide b1 b) &, {homo f : xSource code ySource code /~ (x < y)%R}} ->
z \in `]-oo, b[%R -> f^`() z <= 0.
Proof.
have {}zNyb : [set` (Interval (BInfty _ true) (BSide b1 b))]° z.
by rewrite interior_itv// inE/=.
apply: decr_derive1_le0 zNyb; first by rewrite interior_itv.
by move=> x y /[!inE]/=; apply/decrf.
Qed.
Lemma incr_derive1_ge0Used by
- mathcomp.analysis.ftc
Source code {RSource code : realFieldType} (fSource code : R -> R)
(DSource code : set R) (xSource code : R):
{in D° : set R, forall xSource code : R, derivable f x 1%R} ->
{in D &, {homo f : xSource code ySource code / (x < y)%R}} ->
D° x -> 0 <= f^`() x.
Proof.
Lemma incr_derive1_ge0_itvSource code {RSource code : realType} (fSource code : R -> R)
(b0Source code b1Source code : bool) (aSource code bSource code : R) (zSource code : R) :
{in `]a, b[ : set R, forall xSource code : R, derivable f x 1%R} ->
{in Interval (BSide b0 a) (BSide b1 b) &, {homo f : xSource code ySource code / (x < y)%R}} ->
z \in `]a, b[%R -> 0 <= f^`() z.
Proof.
have dfz : derivable f z 1 by apply: df; rewrite inE.
rewrite derive1E -deriveN// -derive1E.
apply: (@decr_derive1_le0_itv _ _ b0 b1 a b); last exact: zab.
- by move=> y Dy; apply: derivableN; apply: df.
- move=> x y Dx Dy yx; rewrite ltrN2; apply: incrf => //; rewrite in_itv/=.
Qed.
Lemma incr_derive1_ge0_itvySource code {RSource code : realType} (fSource code : R -> R)
(b0Source code : bool) (aSource code : R) (zSource code : R) :
{in `]a, +oo[, forall xSource code : R, derivable f x 1%R} ->
{in Interval (BSide b0 a) +oo%O &, {homo f : xSource code ySource code / (x < y)%R}} ->
z \in `]a, +oo[%R -> 0 <= f^`() z.
Proof.
have dfz : derivable f z 1 by apply: df; rewrite inE.
rewrite derive1E -deriveN// -derive1E.
apply: (@decr_derive1_le0_itvy _ _ b0 _ _ _ _ zay).
- by move=> y Dy; apply: derivableN; apply: df.
- by move=> x y Dx Dy yx; rewrite ltrN2; apply: incrf.
Qed.
Lemma incr_derive1_ge0_itvNyUsed by
- mathcomp.analysis.ftc
Source code {RSource code : realType} (fSource code : R -> R)
(b1Source code : bool) (bSource code : R) (zSource code : R) :
{in `]-oo, b[, forall xSource code : R, derivable f x 1%R} ->
{in Interval (BInfty _ true) (BSide b1 b) &, {homo f : xSource code ySource code / (x < y)%R}} ->
z \in `]-oo, b[%R -> 0 <= f^`() z.
Proof.
have dfz : derivable f z 1 by apply: df; rewrite inE.
rewrite derive1E -deriveN// -derive1E.
apply: (@decr_derive1_le0_itvNy _ _ b1 _ _ _ _ zNyb).
- by move=> y Dy; apply: derivableN; apply: df.
- by move=> x y Dx Dy yx; rewrite ltrN2; apply: incrf.
Qed.
Lemma derive1_compUsed by
- mathcomp.analysis.probability_theory.exponential_distribution
- mathcomp.analysis.probability_theory.beta_distribution
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
- mathcomp.analysis.exp
Source code {RSource code : numFieldType} (fSource code gSource code : R -> R) xSource code :
derivable f x 1 -> derivable g (f x) 1 ->
(g \o f)^`() x = g^`()%classic (f x) * f^`()%classic x.
Proof.
rewrite derive1E'; first exact/differentiable_comp.
rewrite diff_comp // !derive1E' //= -[X in 'd _ _ X = _]mulr1.
by rewrite [LHS]linearZ mulrC.
Qed.
Global Instance is_derive1_compUsed by
- mathcomp.analysis.realfun
- mathcomp.analysis.exp
Source code {RSource code : numFieldType} (fSource code gSource code : R -> R) (xSource code aSource code bSource code : R) :
is_derive (g x) 1 f a -> is_derive x 1 g b -> is_derive x 1 (f \o g) (a * b).
Proof.
apply/derivable1_diffP/differentiable_comp; first exact/derivable1_diffP.
by move/derivable1_diffP in fgxv.
by rewrite -derive1E (derive1_comp gv fgxv) 2!derive1E.
Qed.
Lemma near_eq_growth_rateSource code {RSource code : numFieldType} {VSource code WSource code : normedModType R}
(fSource code gSource code : V -> W) (aSource code vSource code : V) : {near a, f =1 g} ->
\forall hSource code \near 0,
h^-1 *: (f (h *: v + a) - f a) = h^-1 *: (g (h *: v + a) - g a).
Proof.
Lemma near_eq_derivableUsed by
- mathcomp.analysis.exp
Source code {RSource code : numFieldType} {VSource code WSource code : normedModType R}
(fSource code gSource code : V -> W) (aSource code vSource code : V) :
{near a, f =1 g} -> derivable f a v -> derivable g a v.
Proof.
move=> vn0 nfg /cvg_ex[/= l fl]; apply/cvg_ex; exists l => /=.
exact/(cvg_trans _ fl)/near_eq_cvg/cvg_within/near_eq_growth_rate.
Qed.
Lemma near_eq_deriveUsed by
- mathcomp.analysis.exp
Source code {RSource code : numFieldType} {VSource code WSource code : normedModType R}
(fSource code gSource code : V -> W) (aSource code vSource code : V) :
(\forall a0Source code \near a, f a0 = g a0) -> 'D_v f a = 'D_v g a.
Proof.
move=> v0 fg; rewrite /derive; congr (lim _).
rewrite eqEsubset; split; apply/near_eq_cvg/cvg_within/near_eq_growth_rate =>//.
by near do apply/esym.
Unshelve. all: by end_near. Qed.
Lemma near_eq_is_deriveUsed by
- mathcomp.analysis.realfun
Source code {RSource code : numFieldType} {VSource code WSource code : normedModType R}
(fSource code gSource code : V -> W) (aSource code vSource code : V) (dfSource code : W) :
(\forall a0Source code \near a, f a0 = g a0) -> is_derive a v f df -> is_derive a v g df.
Proof.
by apply: DeriveDef => //; exact: near_eq_derivable fav.
Qed.
Section near_eq_derive1.
Context {RSource code : numFieldType} {VSource code : normedModType R}.
Implicit Types (f g : R -> V) (x : R).
Lemma near_eq_derive1n_nearSource code nSource code fSource code gSource code xSource code:
{near x, f =1 g} -> {near x, f^`(n) =1 g^`(n)}.
Proof.
near do (rewrite 2!derive1nS !derive1E; apply: near_eq_derive).
exact: (@near_join _ x).
Unshelve. all: by end_near. Qed.
Lemma near_eq_derive1_nearSource code fSource code gSource code xSource code : {near x, f =1 g} -> {near x, f^`() =1 g^`()}.
Proof.
Lemma near_eq_derive1nSource code nSource code fSource code gSource code xSource code : {near x, f =1 g} -> f^`(n) x = g^`(n) x.
Proof.
Lemma near_eq_derive1Source code fSource code gSource code xSource code : {near x, f =1 g} -> f^`() x = g^`() x.
Proof.
End near_eq_derive1.
Section Derive_max.
Context {KSource code : realType} {VSource code WSource code : normedModType K}.
Implicit Types f g : V -> K^o.
Implicit Type x : V.
Fact der_max_subproofSource code fSource code gSource code xSource code vSource code : f x != g x ->
derivable f x v -> derivable g x v ->
{for x, continuous f} -> {for x, continuous g} ->
(fun hSource code => h^-1 *: (((f \max g) \o shift x) (h *: v) - (f \max g) x))
@ 0^' --> if f x < g x then 'D_v g x else 'D_v f x.
Proof.
move=> wlg; rewrite neq_lt => /orP[fg|gf df dg fxv gxv].
- by apply: wlg => //; rewrite lt_eqF.
- rewrite fun_maxC ltNge if_neg le_eqVlt eq_sym gt_eqF//=.
by apply: wlg => //; rewrite lt_eqF.
move=> fx_lt_gx fg_neq df dg cf cg; case: ifPn => fg /=.
- rewrite /Num.max fg => A DgxA.
apply: (@near_eq_cvg _ _ _ _ (fun hSource code => h^-1 *: (g (h *: v + x) - g x))).
+ near do rewrite ifT// -subr_lt0 -[ltLHS]/(((f - g) \o shift x) (_ *: v)).
have Hf (hSource code : V -> K^o) : continuous_at x h ->
h (shift x (k *: v)) @[kSource code --> nbhs 0^'] --> h x.
move=> ch.
apply: cvg_comp; last exact: ch.
by apply: cvg0D => //; apply: cvg0Z => //; exact: nbhs_dnbhs.
apply/(cvgr_lt (f x - g x)); last by rewrite subr_lt0.
by apply: cvgB; exact: Hf.
+ exact: dg.
- absurd.
by rewrite fx_lt_gx in fg.
Unshelve. all: by end_near. Qed.
Lemma derivable_maxSource code fSource code gSource code xSource code vSource code :
f x != g x -> derivable f x v -> derivable g x v ->
{for x, continuous f} -> {for x, continuous g} ->
derivable (f \max g) x v.
Proof.
Lemma derive_maxlSource code fSource code gSource code xSource code vSource code : f x > g x ->
{for x, continuous f} -> {for x, continuous g} ->
'D_v (f \max g) x = 'D_v f x.
Proof.
Lemma derive_maxrSource code fSource code gSource code xSource code vSource code : f x < g x ->
{for x, continuous f} -> {for x, continuous g} ->
'D_v (f \max g) x = 'D_v g x.
Proof.
Lemma derivable_minSource code fSource code gSource code xSource code vSource code :
f x != g x -> derivable f x v -> derivable g x v ->
{for x, continuous f} -> {for x, continuous g} ->
derivable (f \min g) x v.
Proof.
rewrite min_fun_to_max => fx_gx df dg cf cg.
by apply/derivableB; [apply/(derivableD df dg) |apply/derivable_max].
Qed.
Lemma derive_minrSource code fSource code gSource code xSource code vSource code : f x > g x ->
{for x, continuous f} -> {for x, continuous g} ->
'D_v (f \min g) x = 'D_v g x.
Proof.
Lemma derive_minlSource code fSource code gSource code xSource code vSource code : f x < g x ->
{for x, continuous f} -> {for x, continuous g} ->
'D_v (f \min g) x = 'D_v f x.
Proof.
End Derive_max.
Lemma derive1NUsed by
- mathcomp.analysis.probability_theory.exponential_distribution
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
Source code {RSource code : realFieldType} (fSource code : R -> R) (xSource code : R) :
derivable f x 1 -> (- f)^`() x = (- f^`()%classic x).
Lemma derivable_oppUsed by
- mathcomp.analysis.ftc
Source code {RSource code : realFieldType} (xSource code : R) vSource code : derivable -%R x v.
Proof.
Lemma derive1_idUsed by
- mathcomp.analysis.probability_theory.exponential_distribution
- mathcomp.analysis.ftc
- mathcomp.analysis.gauss_integral
Source code {RSource code : realFieldType} (xSource code : R) : id^`() x = 1.
Lemma trigger_deriveUsed by
- mathcomp.analysis.elementary_functions.trigonometry_functions
- mathcomp.analysis.exp
Source code (RSource code : realType) (fSource code : R -> R) xSource code x1Source code y1Source code :
is_derive x (1 : R) f x1 -> x1 = y1 -> is_derive x 1 f y1.
Proof.
Section derive_horner.
Context {RSource code : realFieldType}.
Local Open Scope ring_scope.
Lemma horner0_extSource code : horner (0 : {poly R}) = 0.
Lemma hornerD_extSource code (pSource code : {poly R}) rSource code :
horner (p * 'X + r%:P) = horner (p * 'X) + horner (r%:P).
Lemma horner_scale_extSource code (pSource code : {poly R}) :
horner (p * 'X) = (fun xSource code => p.[x] * x)%R.
Lemma hornerC_extSource code (rSource code : R) : horner r%:P = cst r.
Lemma derivable_hornerSource code (pSource code : {poly R}) xSource code : derivable (horner p) x 1.
Proof.
rewrite hornerD_ext; apply: derivableD.
- rewrite horner_scale_ext/=.
by apply: derivableM; [exact:ih|exact:derivable_id].
- by rewrite hornerC_ext; exact: derivable_cst.
Qed.
Lemma derivEUsed by
- mathcomp.analysis.pi_irrational
Source code (pSource code : {poly R}) : horner (p^`()) = (horner p)^`()%classic.
Proof.
by rewrite deriv0 hornerC horner0_ext derive1_cst.
rewrite derivD hornerD hornerD_ext.
rewrite derive1E deriveD//; [exact: derivable_horner..|].
rewrite -!derive1E hornerC_ext derive1_cst addr0.
rewrite horner_scale_ext derive1E deriveM//; first exact: derivable_horner.
rewrite derive_id -derive1E -ih derivC horner0 addr0 derivM hornerD !hornerE.
by rewrite derivX hornerE mulr1 addrC mulrC scaler1.
Qed.
Global Instance is_derive_polySource code (pSource code : {poly R}) (xSource code : R) :
is_derive x (1:R) (horner p) p^`().[x].
Proof.
Lemma continuous_hornerUsed by
- mathcomp.analysis.pi_irrational
Source code (pSource code : {poly R}) : continuous (horner p).
Proof.
End derive_horner.
Section pointwise_derivable.
Context {RSource code : realFieldType} {VSource code : normedModType R} {mSource code nSource code : nat}.
Implicit Types M : V -> 'M[R]_(m, n).
Lemma derivable_mxPSource code MSource code tSource code vSource code :
derivable M t v <-> forall iSource code jSource code, derivable (fun xSource code => M x i j) t v.
Proof.
- move=> /cvg_ex[/= l Mvtl] i j; apply/cvg_ex; exists (l i j).
apply/cvgrPdist_le => /= e e0.
move/cvgrPdist_le : Mvtl => /(_ _ e0)[/= r r0] rMvte.
near=> x.
apply: le_trans (rMvte x _ _).
+ rewrite [leRHS]/Num.Def.normr/= mx_normrE.
apply: le_trans; last exact: le_bigmax.
by rewrite !mxE.
+ rewrite /ball_/= sub0r normrN.
by near: x; exact: dnbhs0_lt.
+ by near: x.
- apply/cvg_ex => /=.
exists (\matrix_(iSource code < m, jSource code < n) sval (cid ((cvg_ex _).1 (Mvt i j)))).
apply/cvgrPdist_le => /= e e0.
near=> x.
rewrite /Num.Def.normr/= mx_normrE (bigmax_le _ (ltW e0))//= => i _.
rewrite !mxE/=.
move: i; near: x; apply: filter_forall => /= i.
exact: ((cvgrPdist_le _ _).1 (svalP (cid ((cvg_ex _).1 (Mvt i.1 i.2))))).
Unshelve. all: by end_near. Qed.
End pointwise_derivable.
Section pointwise_derive.
Local Open Scope classical_set_scope.
Context {RSource code : realFieldType} {VSource code : normedModType R}.
Lemma derive_mxSource code {mSource code nSource code : nat} (MSource code : V -> 'M[R]_(m, n)) tSource code vSource code :
derivable M t v ->
'D_v M t = \matrix_(iSource code < m, jSource code < n) 'D_v (fun tSource code => M t i j) t.
Proof.
move/cvgrPdist_le : (Mvtl) => /(_ (e / 2)) /[!divr_gt0]// /(_ isT)[d /= d0 dle].
near=> x.
rewrite [leLHS]/Num.Def.normr/= mx_normrE (bigmax_le _ (ltW e0))//= => -[i j] _.
rewrite [in leLHS]mxE/= [X in _ + X]mxE -(subrKA (l i j)).
rewrite (le_trans (ler_normD _ _))// (splitr e) lerD//.
- rewrite mxE.
suff : (h^-1 *: (M (h *: v + t) i j - M t i j)) @[hSource code --> 0^'] --> l i j.
move/cvg_lim => /=; rewrite /derive /= => ->//.
by rewrite subrr normr0 divr_ge0// ltW.
apply/cvgrPdist_le => /= r r0.
move/cvgrPdist_le : Mvtl => /(_ r r0)[/= s s0] sr.
near=> y.
apply: (@le_trans _ _ (`|l - y^-1 *: (M (y *: v + t) - M t)|)).
rewrite [in leRHS]/Num.Def.normr/= mx_normrE.
by under eq_bigr do rewrite !mxE; exact: (le_bigmax _ _ (i, j)).
rewrite sr//=; last by near: y.
by rewrite sub0r normrN; near: y; exact: dnbhs0_lt.
- rewrite mxE.
apply: (@le_trans _ _ `|l - x^-1 *: (M (x *: v + t) - M t)|).
rewrite [in leRHS]/Num.Def.normr/= mx_normrE/=.
under eq_bigr do rewrite !mxE.
apply: le_trans; last exact: le_bigmax.
by rewrite !mxE.
apply: dle => //=; last by near: x.
by rewrite sub0r normrN; near: x; exact: dnbhs0_lt.
Unshelve. all: by end_near. Qed.
Lemma is_derive_mxSource code {mSource code nSource code : nat} (MSource code : V -> 'M[R]_(m, n))
(dMSource code : 'M[R]_(m, n)) (xSource code vSource code : V) :
(forall iSource code jSource code, is_derive x v (fun tSource code => M t i j) (dM i j)) ->
is_derive x v M dM.
Proof.
apply/matrixP => i j.
have [_ <-] := MdM i j.
rewrite derive_mx ?mxE//.
apply/derivable_mxP => i0 j0.
by have [] := MdM i0 j0.
Qed.
Lemma derivable_trmxSource code {mSource code nSource code} (MSource code : V -> 'M[R]_(m, n)) tSource code vSource code :
derivable (fun xSource code => (M x)^T) t v = derivable M t v.
Proof.
move=> suf; apply/propext; split; last exact: suf.
by move=> /suf; under eq_fun do rewrite trmxK.
move=> {}m {}n {}M /cvg_ex[/= l Ml]; apply/cvg_ex => /=; exists l^T.
apply/cvgrPdist_le => /= e e0.
move/cvgrPdist_le : Ml => /(_ _ e0)[/= r r0 re].
near=> x.
rewrite [leLHS](_ : _ = `|l - x^-1 *: (M (x *: v + t) - M t)|).
rewrite -[RHS]norm_trmx [in RHS]linearD/= [in RHS]linearN/=.
by congr (`| _ - _ |); rewrite [RHS]linearZ/= [in RHS]linearB.
apply: re => /=; last by near: x.
by rewrite sub0r normrN; near: x; exact: dnbhs0_lt.
Unshelve. all: by end_near. Qed.
Lemma derive_trmxSource code {mSource code nSource code} (MSource code : V -> 'M[R]_(m, n)) tSource code vSource code :
derivable M t v -> 'D_v (trmx \o M) t = ('D_v M t)^T.
Proof.
Global Instance is_derive_trmxSource code {mSource code nSource code} (fSource code : V -> 'M[R]_(m, n)) (f'Source code : 'M[R]_(m, n))
(tSource code : V) wSource code :
is_derive t w f f' -> is_derive t w (fun xSource code => (f x)^T) f'^T.
Proof.
have fDer : derivable f t w by case: fD.
apply/DeriveDef; last by have [_ <-] := fD; rewrite derive_trmx.
by rewrite derivable_trmx.
Qed.
Fact dmxSource code {mSource code nSource code : nat} (MSource code : V -> 'M[R]_(m, n)) (xSource code : V) :
let gSource code := fun tSource code : V => (\matrix_(iSource code < m, jSource code < n) 'd M x t i j) in
differentiable M x ->
continuous g /\
M \o shift x = cst (M x) + g +o_ 0 id.
Proof.
- apply/continuous_mx => i j v; apply/cvgrPdist_le => /= e e0.
case: Mx => -[+ _] => /(_ v)/cvgrPdist_le/(_ _ e0).
apply: filterS => /= t; apply: le_trans.
by rewrite {2}/Num.norm/= mx_normrE (le_trans _ (le_bigmax _ _ (i, j))) ?mxE.
- apply/eqaddoE; rewrite funeqE => y /=.
rewrite (diff_locallyx Mx) /dM !fctE; congr (_ + _ + _).
by apply/matrixP => i j/=; rewrite mxE.
Qed.
Lemma diffmxSource code {mSource code nSource code : nat} (MSource code : V -> 'M[R]_(m, n)) xSource code :
differentiable M x ->
'd M (nbhs_filter_on x) =
(fun tSource code : V => \matrix_(iSource code < m, jSource code < n) 'd M x t i j) :> (_ -> _).
Proof.
set g := fun tSource code : V => \matrix_(iSource code, jSource code) 'd M x t i j.
have glin : linear (g : V -> _).
move=> a u w.
by rewrite /g linearD linearZ/=; apply/matrixP => i j; rewrite !mxE.
pose glM := GRing.isLinear.Build _ _ _ _ _ glin.
pose gL : {linear _ -> _} := HB.pack g glM.
by apply: (@diff_unique _ _ _ _ gL); have [? ?] := dmx dM.
Qed.
Global Instance is_derive_mx_coordSource code nSource code mSource code
(fSource code : V -> 'M[R]_(n, m)) (f'Source code : 'M[R]_(n,m)) (tSource code : V) wSource code :
is_derive t w f f' ->
forall iSource code jSource code, is_derive t w (fun xSource code => f x i j) (f' i j).
Proof.
have fDer : derivable f t w by case: fD.
apply/DeriveDef; last by have [_ <-] := fD; rewrite derive_mx// mxE.
by move/derivable_mxP : fDer => /(_ i j).
Qed.
Global Instance is_derive_mulmxSource code nSource code mSource code pSource code
(MSource code : V -> 'M[R]_(n, m)) M'Source code
(NSource code : V -> 'M[R]_(m, p)) N'Source code (tSource code : V) wSource code :
is_derive t w M M' -> is_derive t w N N' ->
is_derive t w (fun tSource code => M t *m N t) (M' *m N t + M t *m N').
Proof.
apply is_derive_mx => i j /=.
rewrite !mxE/=.
under eq_fun do rewrite mxE/=.
rewrite -!big_split /= -fct_sumE.
apply/is_derive_sum => k.
by rewrite mulrC addrC; exact/is_deriveM.
Qed.
End pointwise_derive.
Section Ris_diff_mx.
Local Open Scope classical_set_scope.
Context {RSource code : realFieldType}.
Global Instance is_diff_mxSource code {mSource code nSource code : nat} (MSource code dMSource code : R -> 'M[R]_(m, n)) (xSource code : R) :
(forall iSource code jSource code, is_diff x (fun t => M t i j) (fun tSource code => dM t i j)) ->
is_diff x M dM.
Proof.
have diffMx : differentiable M (nbhs_filter_on x).
apply/derivable1_diffP; apply/derivable_mxP => i j.
by have [/(@derivable1_diffP _ _ (fun tSource code => M t i j) x)] := MdM i j.
apply: DiffDef; first exact: diffMx.
rewrite diffmx//=; apply/funext => /= v; apply/matrixP => i j.
rewrite !mxE.
have [diffMij dMdM] := MdM i j.
rewrite -deriveE//.
move/(congr1 (fun fSource code => f v)) : dMdM.
rewrite -(deriveE _ diffMij) => <-.
rewrite derive_mx; last by rewrite /= mxE.
apply/derivable_mxP => i0 j0/=.
by have [/diff_derivable-/(_ v)] := MdM i0 j0.
Qed.
End Ris_diff_mx.
Section derivable_derive_row_mx.
Context {RSource code : realFieldType} {VSource code : normedModType R} {n1Source code n2Source code : nat}.
Implicit Types (f : V -> 'rV[R]_n1) (g : V -> 'rV[R]_n2).
Lemma derivable_row_mxSource code fSource code gSource code tSource code vSource code : derivable f t v -> derivable g t v ->
derivable (fun xSource code => row_mx (f x) (g x)) t v.
Proof.
have /cvg_ex[/= l Hl] := fv.
have /cvg_ex[/= k Hk] := gv.
apply/cvg_ex => /=; exists (row_mx l k ord0 j).
apply/cvgrPdist_le => /= e e0.
move/cvgrPdist_le : Hl => /(_ _ e0) Hl.
move/cvgrPdist_le : Hk => /(_ _ e0) Hk.
move: Hl Hk; apply: filterS2 => x Hl Hk.
rewrite !mxE; case: fintype.splitP => j1 jj1.
- rewrite (le_trans _ Hl)// [in leRHS]/Num.Def.normr/= mx_normrE.
by rewrite (le_trans _ (le_bigmax _ _ (ord0, j1)))// !mxE.
- rewrite (le_trans _ Hk)// [in leRHS]/Num.Def.normr/= mx_normrE.
by rewrite (le_trans _ (le_bigmax _ _ (ord0, j1)))// !mxE.
Qed.
Lemma derive_row_mxSource code fSource code gSource code tSource code vSource code : derivable f t v -> derivable g t v ->
'D_v (fun xSource code => row_mx (f x) (g x)) t = row_mx ('D_v f t) ('D_v g t).
Proof.
by apply: derivable_row_mx; [exact: fv|exact: gv].
apply/matrixP => i j.
rewrite !mxE !derive_mx//; case: splitP => k jE; rewrite !mxE; congr ('D_v _ t);
apply/funext => w; rewrite !mxE; case: splitP => l lE//.
- by congr (f w i _); apply/val_inj => /=; rewrite -jE -lE.
- by absurd: lE; rewrite ltn_eqF//= jE (leq_trans (ltn_ord k))// leq_addr.
- by absurd: lE; rewrite gtn_eqF//= jE (leq_trans (ltn_ord l))// leq_addr.
- congr (g w i _); apply/val_inj => /=.
by apply/eqP; rewrite -(eqn_add2l n1) -lE -jE.
Qed.
Global Instance is_derive_row_mxSource code fSource code ASource code gSource code BSource code xSource code vSource code :
is_derive x v f A -> is_derive x v g B ->
is_derive x v (fun tSource code => row_mx (f t) (g t)) (row_mx A B).
Proof.
by rewrite derive_row_mx// fA gB.
Qed.
End derivable_derive_row_mx.
Lemma eqo_row_mxSource code (KSource code : realFieldType) {mSource code n1Source code n2Source code : nat} (FSource code : filter_on K)
(A1Source code : K -> 'M[K]_(m, n1)) (A2Source code : K -> 'M[K]_(m, n2)) (fSource code : K -> K) :
(fun tSource code => row_mx ([o_F f of A1] t) ([o_F f of A2] t)) =o_F f.
Proof.
Section is_diff_row_mx.
Local Open Scope classical_set_scope.
Context {RSource code : realFieldType} {n1Source code n2Source code : nat}.
Implicit Types (M dM : R -> 'rV[R]_n1) (N dN : R -> 'rV[R]_n2) (x t : R).
Fact drow_mxSource code MSource code NSource code xSource code (fSource code : R -> R) : differentiable M x -> differentiable N x ->
continuous (fun ySource code => row_mx ('d M x y) ('d N x y)) /\
(fun ySource code => row_mx (M y) (N y)) \o shift x = cst (row_mx (M x) (N x)) +
(fun ySource code => row_mx ('d M x y) ('d N x y)) +o_ 0 id.
Proof.
by apply: cvg_row_mx => //=; exact: diff_continuous.
apply/eqaddoE; rewrite funeqE => y /=.
rewrite ![_ (_ + x)]diff_locallyx//.
have ->/= : forall hSource code eSource code, row_mx (M x + 'd M x y + [o_ 0 id of h] y)
(N x + 'd N x y + [o_ 0 id of e] y) =
row_mx (M x) (N x) + row_mx ('d M x y) ('d N x y) +
row_mx ([o_ 0 id of h] y) ([o_ 0 id of e] y).
by move=> /= h e; rewrite !add_row_mx.
congr (_ + _).
by rewrite -[LHS]/((fun ySource code => row_mx (_ y) (_ y)) y) eqo_row_mx.
Qed.
Lemma diff_row_mxSource code MSource code NSource code xSource code : differentiable M x -> differentiable N x ->
'd (fun ySource code => row_mx (M y) (N y)) x =
(fun ySource code => row_mx ('d M x y) ('d N x y)) :> (R -> 'rV[R]_(n1 + n2)).
Proof.
pose d ySource code := row_mx ('d M x y) ('d N x y).
have lin_row_mx : linear d.
by move=> /= a b c; rewrite /d 2!linearPZ scale_row_mx add_row_mx.
pose row_mxlM := GRing.isLinear.Build _ _ _ _ _ lin_row_mx.
pose row_mxL : {linear _ -> _} := HB.pack d row_mxlM.
rewrite -/d -[d]/(row_mxL : _ -> _).
by apply: diff_unique; have [] := drow_mx id df dg.
Qed.
Lemma differentiable_row_mxSource code MSource code NSource code xSource code : differentiable M x -> differentiable N x ->
differentiable (fun tSource code => row_mx (M t) (N t)) x.
Proof.
Global Instance is_diff_row_mxSource code MSource code dMSource code NSource code dNSource code xSource code :
is_diff x M dM -> is_diff x N dN ->
is_diff x (fun t => row_mx (M t) (N t)) (fun tSource code => row_mx (dM t) (dN t)).
Proof.
by rewrite diff_row_mx// !diff_val.
Qed.
End is_diff_row_mx.
Section derivative_limit_thm_right.
Context {RSource code : realType} (fSource code dfSource code : R -> R) (aSource code lSource code : R).
Hypothesis cfaSource code : f @ a^'+ --> f a.
Hypothesis der_fSource code : \forall xSource code \near a^'+, is_derive x (1 : R) f (df x).
Hypothesis df_rcvgSource code : df @ a^'+ --> l.
Lemma right_derivative_limitSource code : h^-1 *: (f (h + a) - f a) @[hSource code --> 0^'+] --> l.
Proof.
have [/= r r0 dfr] := der_f.
move: df_rcvg => /cvgrPdist_lt /(_ e e0) [/= s s0 dfs].
near=> h.
have aha : a < h + a by rewrite ltrDr.
have [//| | |c + ->] := @MVT _ f df a (h + a).
- move=> x; rewrite in_itv/= => /andP[ax xha].
apply: dfr => //=.
by rewrite ltr0_norm ?subr_lt0// opprB ltrBlDr (lt_trans xha)// ltrD2r.
- apply/continuous_within_itvccP => //; split => //.
+ move=> x; rewrite in_itv/= => /andP[ax xha].
apply/differentiable_continuous/derivable1_diffP/ex_derive.
apply: dfr => //=.
by rewrite ltr0_norm ?subr_lt0// opprB ltrBlDr (lt_trans xha)// ltrD2r.
+ apply: cvg_at_left_filter.
apply/differentiable_continuous/derivable1_diffP/ex_derive.
apply: dfr => //=.
by rewrite addrC opprD subrK normrN gtr0_norm.
rewrite in_itv/= => /andP[ac cha].
rewrite addrK [X in `|_ - X|]mulrCA mulVf ?mulr1//.
apply: dfs => //=.
by rewrite ltr0_norm ?subr_lt0// opprB ltrBlDr (lt_trans cha)// ltrD2r.
Unshelve. all: by end_near. Qed.
End derivative_limit_thm_right.
Arguments right_derivative_limit {R f} df.
Section derivative_limit_thm_left.
Context {RSource code : realType} (fSource code dfSource code : R -> R) (bSource code lSource code : R).
Hypothesis cfbSource code : f @ b^'- --> f b.
Hypothesis der_fSource code : \forall xSource code \near b^'-, is_derive x (1 :> R) f (df x).
Hypothesis df_lcvgSource code : df @ b^'- --> l.
Lemma left_derivative_limitSource code : h^-1 *: (f (h + b) - f b) @[hSource code --> 0^'-] --> l.
Proof.
rewrite /= !opprK.
have /[swap] /[apply] : (f \o -%R) x @[xSource code --> (- b)^'+] --> f b.
by rewrite -cvg_at_leftNP.
have /[swap] /[apply] :
\forall xSource code \near (- b)^'+, is_derive x (1 : R) (f \o -%R) (- df (- x)).
rewrite at_rightN near_map; near=> x.
apply: is_derive_eq.
apply: (is_derive1_comp (a := df x)) => //.
by rewrite opprK; near: x.
by rewrite derive_val mulrN1 opprK.
have /[swap] /[apply] : (\- df \o -%R) x @[xSource code --> (- b)^'+] --> - l.
by apply: cvgN; exact/cvg_at_leftNP.
move=> /cvg_at_rightNP /cvgN; rewrite oppr0 opprK.
apply: cvg_trans; apply: near_eq_cvg.
near=> h.
by rewrite fctE/= opprB invrN scaleNr !opprK (addrC b).
Unshelve. all: by end_near. Qed.
End derivative_limit_thm_left.
Arguments left_derivative_limit {R f} df.
Context {RSource code : realType} (fSource code dfSource code : R -> R) (aSource code lSource code : R).
Hypothesis cfaSource code : continuous_at a f.
Hypothesis der_fSource code : \forall xSource code \near a^', is_derive x (1 : R) f (df x).
Hypothesis df_dcvgSource code : df @ a^' --> l.
Lemma derivative_limitSource code : is_derive a 1 f l.
Proof.
by split; [ exact: cvgP dcvg | exact: norm_cvg_lim dcvg ].
under eq_cvg do rewrite scaler1.
apply: cvg_at_right_left_dnbhs.
- apply: (right_derivative_limit df).
+ exact: cvg_at_right_filter cfa.
+ by apply: within_subset der_f => ? /gt_eqF ->.
+ exact: cvg_dnbhs_at_right.
- apply: (left_derivative_limit df).
+ exact: cvg_at_left_filter cfa.
+ by apply: within_subset der_f => ? /lt_eqF ->.
+ exact: cvg_dnbhs_at_left.
Qed.
End derivative_limit_thm.