Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lemmas about imfset #112

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
### Added

- in `finmap.v`:
+ lemmas `bigfcup_imfset`, `fbig_pred1_inj`
+ lemmas `fset_seq1`, `imfset0`, `imfset_fset1`, `imfset_fset2`, `imfsetU`,
`imfsetU1`, `imfsetI`, `bigfcup_imfset`

### Changed

Expand Down
62 changes: 57 additions & 5 deletions finmap.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ From HB Require Import structures.
Set Warnings "-notation-incompatible-format".
From mathcomp Require Import ssreflect ssrbool ssrnat eqtype ssrfun seq.
Set Warnings "notation-incompatible-format".
From mathcomp Require Import choice path finset finfun fintype bigop.
From mathcomp Require Import choice finset finfun fintype bigop.

(*****************************************************************************)
(* This file provides representations for finite sets over a choiceType K, *)
Expand Down Expand Up @@ -1606,6 +1606,11 @@ Proof. by apply/fsetP=> x; rewrite in_fset_cons !inE. Qed.
Lemma fset_nil : [fset[key] x in [::] : seq K] = fset0.
Proof. by apply/fsetP=> x; rewrite in_fset_nil. Qed.

Lemma fset_seq1 a : [:: a] = [fset a].
Proof.
by rewrite (@perm_small_eq _ [fset a] [:: a])//; apply: uniq_perm=>// ? /[!inE].
Qed.

Lemma fset_cat s s' :
[fset[key] x in s ++ s'] = [fset[key] x in s] `|` [fset[key] x in s'].
Proof. by apply/fsetP=> x; rewrite !inE !in_fset_cat. Qed.
Expand Down Expand Up @@ -2131,7 +2136,7 @@ End Enum.

Section ImfsetTh.
Variables (key : unit) (K V V' : choiceType).
Implicit Types (f : K -> V) (g : V -> V') (A V : {fset K}).
Implicit Types (f : K -> V) (g : V -> V') (A B : {fset K}).

Lemma imfset_id (A : {fset K}) : id @` A = A.
Proof. by apply/fsetP=> a; rewrite in_fset. Qed.
Expand Down Expand Up @@ -2159,6 +2164,39 @@ move=> eq_f eqP; apply/fsetP => x; apply/imfsetP/imfsetP => /= [] [k Pk ->];
by exists k => //=; rewrite ?eq_f ?eqP in Pk *.
Qed.

Lemma imfsetU f A B : f @` (A `|` B) = f @` A `|` f @` B.
Proof.
apply/fsetP => v; apply/imfsetP/fsetUP.
by move=> [k /fsetUP [? ->|? ->]]; [left|right]; apply/imfsetP; exists k.
by move=> [|] /imfsetP /= [k kin ->]; exists k => //; rewrite inE kin ?orbT.
Qed.

Lemma imfset0 f : f @` fset0 = fset0.
Proof. by apply/fsetP => v; apply/imfsetP; rewrite inE => -[k /[!inE]]. Qed.

Lemma imfset_fset1 f x : f @` [fset x] = [fset f x].
Proof.
apply/fsetP => y.
by apply/imfsetP/fset1P => [[x' /fset1P -> //]|->]; exists x; rewrite ?fset11.
Qed.

Lemma imfset_fset2 f k1 k2 : f @` [fset k1; k2] = [fset f k1; f k2].
Proof. by rewrite imfsetU 2!imfset_fset1. Qed.

Lemma imfsetU1 f a A : f @` (a |` A) = f a |` (f @` A).
Proof. by rewrite imfsetU imfset_fset1. Qed.

Lemma imfsetI f A B :
{in A & B, injective f} -> f @` (A `&` B) = f @` A `&` f @` B.
Proof.
move=> injf; apply/fsetP => v.
apply/imfsetP/fsetIP => /=.
by move=> [k /fsetIP [kinA kinB] ->]; split; apply/imfsetP; exists k.
move=> [/imfsetP /= [ka kainA eqka] /imfsetP /= [kb kbinB eqkb]].
have eqk : ka = kb by apply: injf => //; rewrite -eqka -eqkb.
by exists ka => //; apply/fsetIP; split=> //; rewrite eqk.
Qed.

End ImfsetTh.

Section PowerSetTheory.
Expand Down Expand Up @@ -2477,15 +2515,29 @@ Qed.

End BigFOpsSeq.

Lemma bigfcup_imfset1 (I T : choiceType) (P : {fset I}) (f : I -> T) :
\bigcup_(i <- P) [fset f i] = f @` P.
Section BigFOps.

Variables (I T : choiceType).
Implicit Types (f : I -> T).

Lemma bigfcup_imfset1 (P : {fset I}) f : \bigcup_(i <- P) [fset f i] = f @` P.
Proof.
apply/eqP; rewrite eqEfsubset; apply/andP; split; apply/fsubsetP => x.
- by case/bigfcupP=> i /andP [] iP _; rewrite inE => /eqP ->; apply/imfsetP; exists i.
- by case/bigfcupP=> i /andP [] iP _ /[!inE] /eqP ->; apply/imfsetP; exists i.
- case/imfsetP => i /= iP ->; apply/bigfcupP; exists i; rewrite ?andbT //.
by apply/imfsetP; exists (f i); rewrite ?inE.
Qed.

Lemma bigfcup_imfset (V : choiceType) f (F : V -> {fset I}) (A : {fset V}):
\bigcup_(a <- A) f @` F a = f @` (\bigcup_(a <- A) F a).
Proof.
apply/fsetP => t; apply/bigfcupP/imfsetP.
by move=> [v ? /imfsetP [i ? ->]]; exists i => //; apply/bigfcupP; exists v.
by move=> [i /bigfcupP [v ? ?] ->]; exists v => //; apply/imfsetP; exists i.
Qed.

End BigFOps.

Section fbig_pred1_inj.
Variables (R : Type) (idx : R) (op : Monoid.com_law idx).

Expand Down
2 changes: 1 addition & 1 deletion multiset.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Set Warnings "-notation-incompatible-format".
From mathcomp Require Import ssreflect ssrbool ssrnat eqtype ssrfun seq.
Set Warnings "notation-incompatible-format".
From mathcomp Require Import choice path finset finfun fintype bigop tuple.
From mathcomp Require Import choice finset finfun fintype bigop tuple.
Require Import finmap.

(*****************************************************************************)
Expand Down
Loading