@@ -377,7 +377,7 @@ Lemma deriveEjacobian m n (f : 'rV[R]_m -> 'rV[R]_n) (a v : 'rV[R]_m) :
377377Proof . by move=> /deriveE->; rewrite /jacobian mul_rV_lin1. Qed .
378378
379379Definition derive1 V (f : R -> V) (a : R) :=
380- lim ((fun h => h^-1 *: (f (h + a) - f a)) @ 0^').
380+ lim ((fun h => h^-1 *: (f (h + a) - f a)) @ 0^').
381381
382382Local Notation "f ^` ()" := (derive1 f).
383383
@@ -2330,7 +2330,7 @@ Unshelve. all: by end_near. Qed.
23302330
23312331Global Instance is_derive_mx {m n : nat} (M : V -> 'M[R]_(m, n))
23322332 (dM : 'M[R]_(m, n)) (x v : V) :
2333- (forall i j, is_derive x v (fun x => M x i j) (dM i j)) ->
2333+ (forall i j, is_derive x v (fun t => M t i j) (dM i j)) ->
23342334 is_derive x v M dM.
23352335Proof .
23362336move=> MdM; apply: DeriveDef; first exact/derivable_mxP.
@@ -2342,7 +2342,7 @@ by have [] := MdM i0 j0.
23422342Qed .
23432343
23442344Fact dmx {m n : nat} (M : V -> 'M[R]_(m, n)) (x : V) :
2345- let g := fun x0 : V => (\matrix_(i < m, j < n) 'd M x x0 i j) in
2345+ let g := fun t : V => (\matrix_(i < m, j < n) 'd M x t i j) in
23462346 differentiable M x ->
23472347 continuous g /\
23482348 M \o shift x = cst (M x) + g +o_ 0 id.
@@ -2357,13 +2357,13 @@ move=> dM Mx; split => [|].
23572357 by apply/matrixP => i j/=; rewrite mxE.
23582358Qed .
23592359
2360- Lemma diffmx {m n : nat} (M : V -> 'M[R]_(m, n)) t :
2361- differentiable M t ->
2362- 'd M (nbhs_filter_on t ) =
2363- (fun x0 : V => \matrix_(i < m, j < n) 'd M t x0 i j) :> (_ -> _).
2360+ Lemma diffmx {m n : nat} (M : V -> 'M[R]_(m, n)) x :
2361+ differentiable M x ->
2362+ 'd M (nbhs_filter_on x ) =
2363+ (fun t : V => \matrix_(i < m, j < n) 'd M x t i j) :> (_ -> _).
23642364Proof .
23652365move=> dM.
2366- set g := fun x0 : V => \matrix_(i, j) 'd M t x0 i j.
2366+ set g := fun t : V => \matrix_(i, j) 'd M x t i j.
23672367have glin : linear (g : V -> _).
23682368 move=> a u w.
23692369 by rewrite /g linearD linearZ/=; apply/matrixP => i j; rewrite !mxE.
@@ -2379,16 +2379,14 @@ Local Open Scope classical_set_scope.
23792379Context {R : realFieldType}.
23802380
23812381Global Instance is_diff_mx {m n : nat} (M dM : R -> 'M[R]_(m, n)) (x : R) :
2382- (forall i j, is_diff x (fun x => M x i j) (fun x => dM x i j)) ->
2382+ (forall i j, is_diff x (fun t => M t i j) (fun t => dM t i j)) ->
23832383 is_diff x M dM.
23842384Proof .
23852385move=> /= MdM.
2386- have diffM : differentiable M (nbhs_filter_on x).
2386+ have diffMx : differentiable M (nbhs_filter_on x).
23872387 apply/derivable1_diffP; apply/derivable_mxP => i j.
2388- by have [/(@derivable1_diffP _ _ (fun x0 => M x0 i j) x)] := MdM i j.
2389- have diffMx i j : differentiable (fun x0 : R => M x0 i j) x.
2390- by have [/=] := MdM i j.
2391- apply: DiffDef; first exact: diffM.
2388+ by have [/(@derivable1_diffP _ _ (fun t => M t i j) x)] := MdM i j.
2389+ apply: DiffDef; first exact: diffMx.
23922390rewrite diffmx//=; apply/funext => /= v; apply/matrixP => i j.
23932391rewrite !mxE.
23942392have [diffMij dMdM] := MdM i j.
@@ -2401,3 +2399,111 @@ by have [/diff_derivable-/(_ v)] := MdM i0 j0.
24012399Qed .
24022400
24032401End Ris_diff_mx.
2402+
2403+ Section derivable_derive_row_mx.
2404+ Context {R : realFieldType} {V : normedModType R} {n1 n2 : nat}.
2405+ Implicit Types (f : V -> 'rV[R]_n1) (g : V -> 'rV[R]_n2).
2406+
2407+ Lemma derivable_row_mx f g t v : derivable f t v -> derivable g t v ->
2408+ derivable (fun x => row_mx (f x) (g x)) t v.
2409+ Proof .
2410+ move=> /= fv gv; apply/derivable_mxP => i j; rewrite (ord1 i)/=.
2411+ have /cvg_ex[/= l Hl] := fv.
2412+ have /cvg_ex[/= k Hk] := gv.
2413+ apply/cvg_ex => /=; exists (row_mx l k ord0 j).
2414+ apply/cvgrPdist_le => /= e e0.
2415+ move/cvgrPdist_le : Hl => /(_ _ e0) Hl.
2416+ move/cvgrPdist_le : Hk => /(_ _ e0) Hk.
2417+ move: Hl Hk; apply: filterS2 => x Hl Hk.
2418+ rewrite !mxE; case: fintype.splitP => j1 jj1.
2419+ - rewrite (le_trans _ Hl)// [in leRHS]/Num.Def.normr/= mx_normrE.
2420+ by rewrite (le_trans _ (le_bigmax _ _ (ord0, j1)))// !mxE.
2421+ - rewrite (le_trans _ Hk)// [in leRHS]/Num.Def.normr/= mx_normrE.
2422+ by rewrite (le_trans _ (le_bigmax _ _ (ord0, j1)))// !mxE.
2423+ Qed .
2424+
2425+ Lemma derive_row_mx f g t v : derivable f t v -> derivable g t v ->
2426+ 'D_v (fun x => row_mx (f x) (g x)) t = row_mx ('D_v f t) ('D_v g t).
2427+ Proof .
2428+ move=> fv gv; rewrite derive_mx.
2429+ by apply: derivable_row_mx; [exact: fv|exact: gv].
2430+ apply/matrixP => i j.
2431+ rewrite !mxE !derive_mx//; case: splitP => k jE; rewrite !mxE; congr ('D_v _ t);
2432+ apply/funext => w; rewrite !mxE; case: splitP => l lE//.
2433+ - by congr (f w i _); apply/val_inj => /=; rewrite -jE -lE.
2434+ - by absurd: lE; rewrite ltn_eqF//= jE (leq_trans (ltn_ord k))// leq_addr.
2435+ - by absurd: lE; rewrite gtn_eqF//= jE (leq_trans (ltn_ord l))// leq_addr.
2436+ - congr (g w i _); apply/val_inj => /=.
2437+ by apply/eqP; rewrite -(eqn_add2l n1) -lE -jE.
2438+ Qed .
2439+
2440+ Global Instance is_derive_row_mx f A g B x v :
2441+ is_derive x v f A -> is_derive x v g B ->
2442+ is_derive x v (fun t => row_mx (f t) (g t)) (row_mx A B).
2443+ Proof .
2444+ move=> [dfx fA] [dgx gB]; apply: DeriveDef; first exact: derivable_row_mx.
2445+ by rewrite derive_row_mx// fA gB.
2446+ Qed .
2447+
2448+ End derivable_derive_row_mx.
2449+
2450+ Lemma eqo_row_mx (K : realFieldType) {m n1 n2 : nat} (F : filter_on K)
2451+ (A1 : K -> 'M[K]_(m, n1)) (A2 : K -> 'M[K]_(m, n2)) (f : K -> K) :
2452+ (fun t => row_mx ([o_F f of A1] t) ([o_F f of A2] t)) =o_F f.
2453+ Proof .
2454+ apply/eqoP => _/posnumP[e]; near=> x; rewrite norm_row_mx ge_max.
2455+ by apply/andP; split; near: x; apply: littleoP.
2456+ Unshelve. all: by end_near. Qed .
2457+
2458+ Section is_diff_row_mx.
2459+ Local Open Scope classical_set_scope.
2460+ Context {R : realFieldType} {n1 n2 : nat}.
2461+ Implicit Types (M dM : R -> 'rV[R]_n1) (N dN : R -> 'rV[R]_n2) (x t : R).
2462+
2463+ Fact drow_mx M N x (f : R -> R) : differentiable M x -> differentiable N x ->
2464+ continuous (fun y => row_mx ('d M x y) ('d N x y)) /\
2465+ (fun y => row_mx (M y) (N y)) \o shift x = cst (row_mx (M x) (N x)) +
2466+ (fun y => row_mx ('d M x y) ('d N x y)) +o_ 0 id.
2467+ Proof .
2468+ move=> df dg; split=> [/= ?|].
2469+ by apply: cvg_row_mx => //=; exact: diff_continuous.
2470+ apply/eqaddoE; rewrite funeqE => y /=.
2471+ rewrite ![_ (_ + x)]diff_locallyx//.
2472+ have ->/= : forall h e, row_mx (M x + 'd M x y + [o_ 0 id of h] y)
2473+ (N x + 'd N x y + [o_ 0 id of e] y) =
2474+ row_mx (M x) (N x) + row_mx ('d M x y) ('d N x y) +
2475+ row_mx ([o_ 0 id of h] y) ([o_ 0 id of e] y).
2476+ by move=> /= h e; rewrite !add_row_mx.
2477+ congr (_ + _).
2478+ by rewrite -[LHS]/((fun y => row_mx (_ y) (_ y)) y) eqo_row_mx.
2479+ Qed .
2480+
2481+ Lemma diff_row_mx M N x : differentiable M x -> differentiable N x ->
2482+ 'd (fun y => row_mx (M y) (N y)) x =
2483+ (fun y => row_mx ('d M x y) ('d N x y)) :> (R -> 'rV[R]_(n1 + n2)).
2484+ Proof .
2485+ move=> df dg.
2486+ pose d y := row_mx ('d M x y) ('d N x y).
2487+ have lin_row_mx : linear d.
2488+ by move=> /= a b c; rewrite /d 2!linearPZ scale_row_mx add_row_mx.
2489+ pose row_mxlM := GRing.isLinear.Build _ _ _ _ _ lin_row_mx.
2490+ pose row_mxL : {linear _ -> _} := HB.pack d row_mxlM.
2491+ rewrite -/d -[d]/(row_mxL : _ -> _).
2492+ by apply: diff_unique; have [] := drow_mx id df dg.
2493+ Qed .
2494+
2495+ Lemma differentiable_row_mx M N x : differentiable M x -> differentiable N x ->
2496+ differentiable (fun t => row_mx (M t) (N t)) x.
2497+ Proof .
2498+ by move=> df dg; apply/diff_locallyP; rewrite diff_row_mx //; apply: drow_mx.
2499+ Qed .
2500+
2501+ Global Instance is_diff_row_mx M dM N dN x :
2502+ is_diff x M dM -> is_diff x N dN ->
2503+ is_diff x (fun t => row_mx (M t) (N t)) (fun t => row_mx (dM t) (dN t)).
2504+ Proof .
2505+ move=> dfx dgx; apply: DiffDef; first exact: differentiable_row_mx.
2506+ by rewrite diff_row_mx// !diff_val.
2507+ Qed .
2508+
2509+ End is_diff_row_mx.
0 commit comments