Skip to content

Commit af08f5e

Browse files
authored
specialized version of is_diff_mx (#1891)
1 parent 2c3a9bd commit af08f5e

3 files changed

Lines changed: 107 additions & 4 deletions

File tree

CHANGELOG_UNRELEASED.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@
8383

8484
- in `subspace_topology.v`:
8585
+ lemma `withinU_continuous_patch`
86+
- in `matrix_normedtype.v`:
87+
+ lemma `continuous_mx`
88+
89+
- in `derive.v`:
90+
+ instance `is_derive_mx`
91+
+ fact `dmx`
92+
+ lemma `diffmx`
93+
+ lemma `is_diff_mx`
94+
+ instance `is_diff_mx`
8695

8796
### Changed
8897

theories/derive.v

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(* mathcomp analysis (c) 2026 Inria and AIST. License: CeCILL-C. *)
22
From HB Require Import structures.
3-
From mathcomp Require Import all_ssreflect_compat ssralg ssrnum matrix interval poly.
4-
From mathcomp Require Import sesquilinear.
3+
From mathcomp Require Import all_ssreflect_compat ssralg ssrnum matrix interval.
4+
From mathcomp Require Import poly sesquilinear.
55
#[warning="-warn-library-file-internal-analysis"]
66
From mathcomp Require Import unstable.
77
From mathcomp Require Import mathcomp_extra boolp contra classical_sets.
@@ -660,7 +660,7 @@ move=> df; set g := RHS; have glin : linear g.
660660
by move=> a u v; rewrite /g linearP /= scalerDl -scalerA.
661661
pose glM := GRing.isLinear.Build _ _ _ _ _ glin.
662662
pose gL : {linear _ -> _} := HB.pack g glM.
663-
by apply:(@diff_unique _ _ _ gL); have [] := dscalel f df.
663+
by apply: (@diff_unique _ _ _ gL); have [] := dscalel f df.
664664
Qed.
665665

666666
Lemma differentiableZl (k : V -> R) (f : W) x :
@@ -2328,4 +2328,76 @@ rewrite (le_trans (ler_normD _ _))// (splitr e) lerD//.
23282328
by rewrite sub0r normrN; near: x; exact: dnbhs0_lt.
23292329
Unshelve. all: by end_near. Qed.
23302330

2331+
Global Instance is_derive_mx {m n : nat} (M : V -> 'M[R]_(m, n))
2332+
(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)) ->
2334+
is_derive x v M dM.
2335+
Proof.
2336+
move=> MdM; apply: DeriveDef; first exact/derivable_mxP.
2337+
apply/matrixP => i j.
2338+
have [_ <-] := MdM i j.
2339+
rewrite derive_mx ?mxE//.
2340+
apply/derivable_mxP => i0 j0.
2341+
by have [] := MdM i0 j0.
2342+
Qed.
2343+
2344+
Fact 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
2346+
differentiable M x ->
2347+
continuous g /\
2348+
M \o shift x = cst (M x) + g +o_ 0 id.
2349+
Proof.
2350+
move=> dM Mx; split => [|].
2351+
- apply/continuous_mx => i j v; apply/cvgrPdist_le => /= e e0.
2352+
case: Mx => -[+ _] => /(_ v)/cvgrPdist_le/(_ _ e0).
2353+
apply: filterS => /= t; apply: le_trans.
2354+
by rewrite {2}/Num.norm/= mx_normrE (le_trans _ (le_bigmax _ _ (i, j))) ?mxE.
2355+
- apply/eqaddoE; rewrite funeqE => y /=.
2356+
rewrite (diff_locallyx Mx) /dM !fctE; congr (_ + _ + _).
2357+
by apply/matrixP => i j/=; rewrite mxE.
2358+
Qed.
2359+
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) :> (_ -> _).
2364+
Proof.
2365+
move=> dM.
2366+
set g := fun x0 : V => \matrix_(i, j) 'd M t x0 i j.
2367+
have glin : linear (g : V -> _).
2368+
move=> a u w.
2369+
by rewrite /g linearD linearZ/=; apply/matrixP => i j; rewrite !mxE.
2370+
pose glM := GRing.isLinear.Build _ _ _ _ _ glin.
2371+
pose gL : {linear _ -> _} := HB.pack g glM.
2372+
by apply: (@diff_unique _ _ _ _ gL); have [? ?] := dmx dM.
2373+
Qed.
2374+
23312375
End pointwise_derive.
2376+
2377+
Section Ris_diff_mx.
2378+
Local Open Scope classical_set_scope.
2379+
Context {R : realFieldType}.
2380+
2381+
Global 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)) ->
2383+
is_diff x M dM.
2384+
Proof.
2385+
move=> /= MdM.
2386+
have diffM : differentiable M (nbhs_filter_on x).
2387+
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.
2392+
rewrite diffmx//=; apply/funext => /= v; apply/matrixP => i j.
2393+
rewrite !mxE.
2394+
have [diffMij dMdM] := MdM i j.
2395+
rewrite -deriveE//.
2396+
move/(congr1 (fun f => f v)) : dMdM.
2397+
rewrite -(deriveE _ diffMij) => <-.
2398+
rewrite derive_mx ?mxE//=.
2399+
apply/derivable_mxP => i0 j0/=.
2400+
by have [/diff_derivable-/(_ v)] := MdM i0 j0.
2401+
Qed.
2402+
2403+
End Ris_diff_mx.

theories/normedtype_theory/matrix_normedtype.v

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ move=> /= M s /= /(nbhs_ballP (M i j)) [e e0 es].
3737
by apply/nbhs_ballP; exists e => //= N [_ MN]; exact/es/MN.
3838
Qed.
3939

40-
#[local]Lemma rV_compact_nondegenerate (T : ptopologicalType) n
40+
#[local] Lemma rV_compact_nondegenerate (T : ptopologicalType) n
4141
(A : 'I_n.+1 -> set T) :
4242
(forall i, compact (A i)) ->
4343
compact [ set v : 'rV[T]_n.+1 | forall i, A i (v ord0 i)].
@@ -252,3 +252,25 @@ HB.instance Definition _ (K : numFieldType) m n :=
252252
(@mx_normZ K m n).
253253

254254
End matrix_NormedModule.
255+
256+
Lemma continuous_mx {V : topologicalType} {R : realFieldType} {m n : nat}
257+
(f : V -> 'M[R]_(m, n)) :
258+
(forall i j, continuous (fun x => f x i j)) <->
259+
continuous (fun x : V => \matrix_(i < m, j < n) f x i j).
260+
Proof.
261+
split => [cf x|cf i j v].
262+
- apply/cvgrPdist_le => /= e e0; near=> t.
263+
rewrite /Num.norm/= mx_normrE/= (bigmax_le _ (ltW e0))// => -[i j] _.
264+
rewrite !mxE/=.
265+
move: i j; near: t.
266+
apply: filter_forall => /= i; apply: filter_forall => /= j.
267+
have /(@cvgrPdist_le _ R^o)/(_ _ e0) := cf i j x.
268+
exact: filterS.
269+
- apply/(@cvgrPdist_le _ R^o) => /= e e0.
270+
have /cvgrPdist_le/(_ _ e0) := cf v.
271+
apply: filterS => w.
272+
apply: le_trans.
273+
rewrite [in leRHS]/Num.norm/= mx_normrE/=.
274+
apply: le_trans (le_bigmax _ _ (i, j)).
275+
by rewrite !mxE.
276+
Unshelve. all: by end_near. Qed.

0 commit comments

Comments
 (0)