@@ -128,6 +128,19 @@ Add Search Blacklist "_mixin_".
128128(* fctE == multi-rule for fct *)
129129(* ``` *)
130130(* *)
131+ (* ``` *)
132+ (* linfun E F s == membership predicate for linear functions of *)
133+ (* type E -> F with scalar operator *)
134+ (* s : K -> F -> F *)
135+ (* E and F have type lmodType K. *)
136+ (* This is used in particular to attach a type of *)
137+ (* lmodType to {linear E -> F | s}. *)
138+ (* linfun_spec f == specification for membership of the linear *)
139+ (* function f *)
140+ (* ``` *)
141+ (* *)
142+ (* *)
143+ (* *)
131144(***************************************************************************** *)
132145
133146Unset SsrOldRewriteGoalsOrder. (* remove the line when requiring MathComp >= 2.6 *)
@@ -2750,3 +2763,96 @@ End function_space_lemmas.
27502763
27512764Lemma inv_funK T (R : unitRingType) (f : T -> R) : (f\^-1\^-1)%R = f.
27522765Proof . by apply/funeqP => x; rewrite /inv_fun/= GRing.invrK. Qed .
2766+
2767+ Local Open Scope ring_scope.
2768+ Import GRing.Theory.
2769+
2770+ Section linfun_pred.
2771+ Context {K : numDomainType} {E : lmodType K} {F : lmodType K}
2772+ {s : K -> F -> F}.
2773+
2774+ (**md Beware that `lfun` is reserved for vector types, hence this one has been
2775+ named `linfun` *)
2776+ Definition linfun : {pred E -> F} := mem [set f | linear_for s f ].
2777+
2778+ Definition linfun_key : pred_key linfun. Proof . exact. Qed .
2779+
2780+ Canonical linfun_keyed := KeyedPred linfun_key.
2781+
2782+ End linfun_pred.
2783+
2784+ Section linfun.
2785+ Context {R : numDomainType} {E : lmodType R}
2786+ {F : lmodType R} {s : GRing.Scale.law R F}.
2787+
2788+ Notation T := {linear E -> F | s}.
2789+
2790+ Notation linfun := (@linfun _ E F s).
2791+
2792+ Section Sub.
2793+ Context (f : E -> F) (fP : f \in linfun).
2794+
2795+ #[local] Definition linfun_Sub_subproof :=
2796+ @GRing.isLinear.Build _ E F s f (set_mem fP).
2797+
2798+ #[local] HB.instance Definition _ := linfun_Sub_subproof.
2799+ Definition linfun_Sub : {linear _ -> _ | _ } := f.
2800+ End Sub.
2801+
2802+ Let linfun_rect (K : T -> Type ) :
2803+ (forall f (Pf : f \in linfun), K (linfun_Sub Pf)) -> forall u : T, K u.
2804+ Proof .
2805+ move=> Ksub [f] [[[Pf1 Pf2]] [Pf3]].
2806+ set G := (G in K G).
2807+ have Pf : f \in linfun by rewrite inE /= => // x u y; rewrite Pf2 Pf3.
2808+ suff -> : G = linfun_Sub Pf by apply: Ksub.
2809+ rewrite {}/G.
2810+ congr (GRing.Linear.Pack (GRing.Linear.Class _ _)).
2811+ - by congr GRing.isNmodMorphism.Axioms_; exact: Prop_irrelevance.
2812+ - by congr GRing.isScalable.Axioms_; exact: Prop_irrelevance.
2813+ Qed .
2814+
2815+ Let linfun_valP f (Pf : f \in linfun) : linfun_Sub Pf = f :> (_ -> _).
2816+ Proof . by []. Qed .
2817+
2818+ HB.instance Definition _ := isSub.Build _ _ T linfun_rect linfun_valP.
2819+
2820+ Lemma linfun_eqP (f g : {linear E -> F | s}) : f = g <-> f =1 g.
2821+ Proof . by split=> [->//|fg]; exact/val_inj/funext. Qed .
2822+
2823+ HB.instance Definition _ := [Choice of {linear E -> F | s} by <:].
2824+
2825+ Variant linfun_spec (f : E -> F) : (E -> F) -> bool -> Type :=
2826+ | Islinfun (l : {linear E -> F | s}) : linfun_spec f l true.
2827+
2828+ Lemma linfunP (f : E -> F) : f \in linfun -> linfun_spec f f (f \in linfun).
2829+ Proof .
2830+ move=> /[dup] f_lc ->.
2831+ have {2}-> : f = linfun_Sub f_lc by rewrite linfun_valP.
2832+ by constructor.
2833+ Qed .
2834+
2835+ End linfun.
2836+
2837+ Section linfun_lmodtype.
2838+ Context {R : numDomainType} {E F : lmodType R}.
2839+ Import GRing.Theory.
2840+
2841+ Let linfun_submod_closed : submod_closed (@linfun R E F *:%R).
2842+ Proof .
2843+ split; first by rewrite inE; exact/linearP.
2844+ move=> r /= _ _ /linfunP[f] /linfunP[g].
2845+ by rewrite inE /=; exact: linearP.
2846+ Qed .
2847+
2848+ HB.instance Definition _ :=
2849+ @GRing.isSubmodClosed.Build _ _ linfun linfun_submod_closed.
2850+
2851+ HB.instance Definition _ :=
2852+ [SubChoice_isSubLmodule of {linear E -> F } by <:].
2853+
2854+ End linfun_lmodtype.
2855+
2856+ (* TODO: we wanted to declare this instance in classical_sets.v but failed and did not understand why, also we couldn't generalize *)
2857+ HB.instance Definition _ {R : numDomainType} (E F : lmodType R) :=
2858+ isPointed.Build {linear E -> F} 0.
0 commit comments