@@ -494,14 +494,9 @@ Definition pred_of_finset (K : choiceType)
494494 (f : finSet K) : pred K := fun k => k \in (enum_fset f).
495495Canonical finSetPredType (K : choiceType) := PredType (@pred_of_finset K).
496496
497- Section FinSetCanonicals.
498-
499- Variable (K : choiceType).
500-
501- HB.instance Definition _ := [isSub for (@enum_fset K)].
502- HB.instance Definition _ := [Choice of {fset K} by <:].
503-
504- End FinSetCanonicals.
497+ HB.instance Definition _ (K : choiceType) := [isSub for @enum_fset K].
498+ HB.instance Definition _ (K : choiceType) := [Choice of {fset K} by <:].
499+ HB.instance Definition _ (T : countType) := [Countable of {fset T} by <:].
505500
506501Section FinTypeSet.
507502
@@ -518,7 +513,6 @@ Record fset_sub_type : predArgType :=
518513
519514HB.instance Definition _ := [isSub for fsval].
520515HB.instance Definition _ := [Choice of fset_sub_type by <:].
521- HB.instance Definition _ (T : countType) := [Countable of {fset T} by <:].
522516
523517Definition fset_sub_enum : seq fset_sub_type :=
524518 undup (pmap insub (enum_fset A)).
@@ -577,33 +571,32 @@ Definition set_of_fset (K : choiceType) (A : {fset K}) : {set A} :=
577571
578572Arguments pred_of_finset : simpl never.
579573
574+ HB.lock Definition seq_fset
575+ (finset_key : unit) (K : choiceType) (s : seq K) : {fset K} :=
576+ mkFinSet (@canonical_sort_keys K s).
577+
580578Section SeqFset.
581579
582- Variable finset_key : unit.
583- Definition seq_fset : forall K : choiceType, seq K -> {fset K} :=
584- locked_with finset_key (fun K s => mkFinSet (@canonical_sort_keys K s)).
580+ Variable (finset_key : unit) (K : choiceType) (s : seq K).
585581
586- Variable (K : choiceType) (s : seq K ).
582+ Notation seq_fset := (seq_fset finset_key ).
587583
588584Lemma seq_fsetE : seq_fset s =i s.
589- Proof . by move=> a; rewrite [seq_fset] unlock sort_keysE. Qed .
585+ Proof . by move=> a; rewrite unlock sort_keysE. Qed .
590586
591587Lemma size_seq_fset : size (seq_fset s) = size (undup s).
592- Proof . by rewrite [seq_fset] unlock /= size_sort_keys. Qed .
588+ Proof . by rewrite unlock /= size_sort_keys. Qed .
593589
594590Lemma seq_fset_uniq : uniq (seq_fset s).
595- Proof . by rewrite [seq_fset] unlock /= sort_keys_uniq. Qed .
591+ Proof . by rewrite unlock /= sort_keys_uniq. Qed .
596592
597593Lemma seq_fset_perm : perm_eq (seq_fset s) (undup s).
598- Proof . by rewrite [seq_fset] unlock //= sort_keys_perm. Qed .
594+ Proof . by rewrite unlock //= sort_keys_perm. Qed .
599595
600596End SeqFset.
601597
602598#[global] Hint Resolve keys_canonical sort_keys_uniq : core.
603599
604- HB.instance Definition _ K := [isSub for (@enum_fset K)].
605- HB.instance Definition _ (K : choiceType) := [Choice of {fset K} by <:].
606-
607600Section FinPredStruct.
608601
609602Structure finpredType (T : eqType) := FinPredType {
@@ -746,46 +739,32 @@ Canonical seq_finpredType (T : eqType) :=
746739
747740End CanonicalFinPred.
748741
749- Local Notation imfset_def key :=
750- (fun (T K : choiceType) (f : T -> K) (p : finmempred T)
751- => seq_fset key [seq f x | x <- enum_finmem p]).
752- Local Notation imfset2_def key :=
753- (fun (K T1 : choiceType) (T2 : T1 -> choiceType)
754- (f : forall x : T1, T2 x -> K)
755- (p1 : finmempred T1) (p2 : forall x : T1, finmempred (T2 x)) =>
756- seq_fset key [seq f x y | x <- enum_finmem p1, y <- enum_finmem (p2 x)]).
757-
758- Module Type ImfsetSig.
759- Parameter imfset : forall (key : unit) (T K : choiceType)
760- (f : T -> K) (p : finmempred T), {fset K}.
761- Parameter imfset2 : forall (key : unit) (K T1 : choiceType)
762- (T2 : T1 -> choiceType)(f : forall x : T1, T2 x -> K)
763- (p1 : finmempred T1) (p2 : forall x : T1, finmempred (T2 x)), {fset K}.
764- Axiom imfsetE : forall key, imfset key = imfset_def key.
765- Axiom imfset2E : forall key, imfset2 key = imfset2_def key.
766- End ImfsetSig.
767-
768- Module Imfset : ImfsetSig.
769- Definition imfset key := imfset_def key.
770- Definition imfset2 key := imfset2_def key.
771- Lemma imfsetE key : imfset key = imfset_def key. Proof . by []. Qed .
772- Lemma imfset2E key : imfset2 key = imfset2_def key. Proof . by []. Qed .
742+ HB.lock Definition imfset
743+ (key : unit) (T K : choiceType) (f : T -> K) (p : finmempred T) : {fset K} :=
744+ seq_fset key [seq f x | x <- enum_finmem p].
745+
746+ HB.lock Definition imfset2
747+ (key : unit) (K T1 : choiceType) (T2 : T1 -> choiceType)
748+ (f : forall x : T1, T2 x -> K)
749+ (p1 : finmempred T1) (p2 : forall x : T1, finmempred (T2 x)) : {fset K} :=
750+ seq_fset key [seq f x y | x <- enum_finmem p1, y <- enum_finmem (p2 x)].
751+
752+ Module Imfset.
753+ #[deprecated(since="finmap 2.3.0", note="Use imfset instead.")]
754+ Notation imfset := imfset.
755+ #[deprecated(since="finmap 2.3.0", note="Use imfset2 instead.")]
756+ Notation imfset2 := imfset2.
773757End Imfset.
774758
775- Notation imfset := Imfset.imfset.
776- Notation imfset2 := Imfset.imfset2.
777- Canonical imfset_unlock k := Unlockable (Imfset.imfsetE k).
778- Canonical imfset2_unlock k := Unlockable (Imfset.imfset2E k).
779-
780759Notation "A `=` B" := (A = B :> {fset _}) (only parsing) : fset_scope.
781760Notation "A `<>` B" := (A <> B :> {fset _}) (only parsing) : fset_scope.
782761Notation "A `==` B" := (A == B :> {fset _}) (only parsing) : fset_scope.
783762Notation "A `!=` B" := (A != B :> {fset _}) (only parsing) : fset_scope.
784763Notation "A `=P` B" := (A =P B :> {fset _}) (only parsing) : fset_scope.
785764
786- Notation "f @`[ key ] A" := (Imfset. imfset key f (mem A)) : fset_scope.
765+ Notation "f @`[ key ] A" := (imfset key f (mem A)) : fset_scope.
787766Notation "f @2`[ key ] ( A , B )" :=
788- (Imfset. imfset2 key f (mem A) (fun x => (mem (B x)))) : fset_scope.
767+ (imfset2 key f (mem A) (fun x => (mem (B x)))) : fset_scope.
789768
790769Fact imfset_key : unit. Proof . exact: tt. Qed .
791770
@@ -3766,17 +3745,14 @@ End FsfunDef.
37663745
37673746Coercion fun_of_fsfun : fsfun >-> Funclass.
37683747
3769- Module Type FinSuppSig.
3770- Axiom fs : forall (K : choiceType) (V : eqType) (default : K -> V),
3771- fsfun default -> {fset K}.
3772- Axiom E : fs = (fun K V d f => domf (@fmap_of_fsfun K V d f)).
3773- End FinSuppSig.
3774- Module FinSupp : FinSuppSig.
3775- Definition fs := (fun K V d f => domf (@fmap_of_fsfun K V d f)).
3776- Definition E := erefl fs.
3748+ HB.lock Definition finsupp
3749+ (K : choiceType) (V : eqType) (d : K -> V) (f : fsfun d) : {fset K} :=
3750+ domf (@fmap_of_fsfun K V d f).
3751+
3752+ Module FinSupp.
3753+ #[deprecated(since="finmap 2.3.0", note="Use finsupp instead.")]
3754+ Notation fs := finsupp.
37773755End FinSupp.
3778- Notation finsupp := FinSupp.fs.
3779- Canonical unlockable_finsupp := Unlockable FinSupp.E.
37803756
37813757Section FSfunBasics.
37823758
@@ -3853,38 +3829,34 @@ Notation "{ 'fsfun' 'of' x => dflt }" := {fsfun of x : _ => dflt}
38533829Notation "{ 'fsfun' 'with ' dflt }" := {fsfun of _ => dflt}
38543830 (at level 0, only parsing) : type_scope.
38553831
3856- Module Type FsfunSig.
3857- Section FsfunSig.
3858- Variables (K : choiceType) (V : eqType) (default : K -> V).
3859-
3860- Parameter of_ffun : forall (S : {fset K}), (S -> V) -> unit -> fsfun default.
3861- Variables (S : {fset K}) (h : S -> V).
3862- Axiom of_ffunE :forall key x, of_ffun h key x = odflt (default x) (omap h (insub x)).
3863-
3864- End FsfunSig.
3865- End FsfunSig.
3866-
3867- Module Fsfun : FsfunSig.
38683832Section FsfunOfFinfun.
38693833
3870- Variables (K : choiceType) (V : eqType) (default : K -> V)
3871- (S : {fset K}) (h : S -> V).
3834+ Variables (K : choiceType) (V : eqType).
3835+ Variables (S : {fset K}) (h : S -> V) (default : K -> V).
38723836
3873- Let fmap :=
3837+ Let fmap : {fmap K -> V} : =
38743838 [fmap a : [fsetval a in {: S} | h a != default (val a)]
38753839 => h (fincl (fset_sub_val _ _) a)].
38763840
3877- Fact fmapP a : fmap a != default (val a).
3841+ Fact fsfun_of_ffun_subproof (a : domf fmap) : fmap a != default (val a).
38783842Proof .
38793843rewrite ffunE; have /in_fset_valP [a_in_S] := valP a.
38803844by have -> : [` a_in_S] = fincl (fset_sub_val _ _) a by exact/val_inj.
38813845Qed .
38823846
3883- Definition of_ffun (k : unit) := fsfun_of_can_ffun fmapP .
3847+ End FsfunOfFinfun .
38843848
3885- Lemma of_ffunE key x : of_ffun key x = odflt (default x) (omap h (insub x)).
3849+ HB.lock Definition fsfun_of_ffun
3850+ (k : unit) (K : choiceType) (V : eqType)
3851+ (S : {fset K}) (h : S -> V) (default : K -> V) :=
3852+ fsfun_of_can_ffun (@fsfun_of_ffun_subproof K V S h default).
3853+
3854+ Lemma fsfun_ffun
3855+ (k : unit) (K : choiceType) (V : eqType)
3856+ (default : K -> V) (S : {fset K}) (h : S -> V) (x : K) :
3857+ fsfun_of_ffun k h default x = odflt (default x) (omap h (insub x)).
38863858Proof .
3887- rewrite /fun_of_fsfun /=.
3859+ rewrite unlock /fun_of_fsfun /=.
38883860case: insubP => /= [u _ <-|xNS]; last first.
38893861 case: fndP => //= kf; rewrite !ffunE /=.
38903862 by set y := (X in h X); rewrite (valP y) in xNS.
@@ -3893,17 +3865,23 @@ case: fndP => /= [kf|].
38933865by rewrite inE /= -topredE /= negbK => /eqP ->.
38943866Qed .
38953867
3896- End FsfunOfFinfun.
3868+ Module Fsfun.
3869+
3870+ #[deprecated(since="finmap 2.3.0", note="Use fsfun_of_ffun instead.")]
3871+ Definition of_ffun (K : choiceType) (V : eqType)
3872+ (S : {fset K}) (h : S -> V) (default : K -> V) (key : unit) (x : K) :=
3873+ fsfun_of_ffun key h default x.
3874+
3875+ #[deprecated(since="finmap 2.3.0", note="Use fsfun_ffun instead.")]
3876+ Lemma of_ffunE (K : choiceType) (V : eqType)
3877+ (S : {fset K}) (h : S -> V) (default : K -> V) key (x : K) :
3878+ fsfun_of_ffun key h default x = odflt (default x) (omap h (insub x)).
3879+ Proof . exact: fsfun_ffun. Qed .
3880+
38973881End Fsfun.
3898- Canonical fsfun_of_funE K V default S h key x :=
3899- Unlockable (@Fsfun.of_ffunE K V default S h key x).
39003882
39013883Fact fsfun_key : unit. Proof . exact: tt. Qed .
39023884
3903- Definition fsfun_of_ffun key (K : choiceType) (V : eqType)
3904- (S : {fset K}) (h : S -> V) (default : K -> V) :=
3905- (Fsfun.of_ffun default h key).
3906-
39073885HB.instance Definition _ (K V : choiceType) (d : K -> V) :=
39083886 [Choice of fsfun d by <:].
39093887
@@ -4017,18 +3995,13 @@ Notation "[ 'fsfun' ]" := [fsfun for _]
40173995Section FsfunTheory.
40183996Variables (key : unit) (K : choiceType) (V : eqType) (default : K -> V).
40193997
4020- Lemma fsfun_ffun (S : {fset K}) (h : S -> V) (x : K) :
4021- [fsfun[key] a : S => h a | default a] x =
4022- odflt (default x) (omap h (insub x)).
4023- Proof . by rewrite unlock. Qed .
4024-
40253998Lemma fsfun_fun (S : {fset K}) (h : K -> V) (x : K) :
40263999 [fsfun[key] a in S => h a | default a] x =
40274000 if x \in S then h x else (default x).
40284001Proof . by rewrite fsfun_ffun; case: insubP => //= [u -> ->|/negPf ->]. Qed .
40294002
40304003Lemma fsfun0E : [fsfun for default] =1 default.
4031- Proof . by move=> x; rewrite unlock insubF ?inE. Qed .
4004+ Proof . by move=> x; rewrite fsfun_ffun insubF ?inE. Qed .
40324005
40334006Definition fsfunE := (fsfun_fun, fsfun0E).
40344007
@@ -4043,7 +4016,7 @@ Qed.
40434016Lemma finsupp_sub (S : {fset K}) (h : S -> V) :
40444017 finsupp [fsfun[key] a : S => h a | default a] `<=` S.
40454018Proof .
4046- apply/fsubsetP => a; rewrite mem_finsupp unlock /= .
4019+ apply/fsubsetP => a; rewrite mem_finsupp fsfun_ffun .
40474020by case: insubP => //=; rewrite eqxx.
40484021Qed .
40494022
0 commit comments