Skip to content
Snippets Groups Projects
Commit 57a1a207 authored by Alix Trieu's avatar Alix Trieu
Browse files

surjective_finite

parent b2c5f1fe
No related branches found
No related tags found
1 merge request!238surjective_finite
......@@ -220,15 +220,25 @@ Section enc_finite.
Proof. unfold card. simpl. by rewrite fmap_length, seq_length. Qed.
End enc_finite.
Section surjective_finite.
Context `{Finite A, EqDecision B} (f : A B).
Context `{!Surj (=) f}.
Program Instance surjective_finite: Finite B := {| enum := remove_dups (f <$> enum A) |}.
Next Obligation. apply NoDup_remove_dups. Qed.
Next Obligation.
intros y. rewrite elem_of_remove_dups, elem_of_list_fmap.
destruct (Surj0 y). eauto using elem_of_enum.
Qed.
End surjective_finite.
Section bijective_finite.
Context `{Finite A, EqDecision B} (f : A B) (g : B A).
Context `{!Inj (=) (=) f, !Cancel (=) f g}.
Program Instance bijective_finite: Finite B := {| enum := f <$> enum A |}.
Next Obligation. apply (NoDup_fmap_2 _), NoDup_enum. Qed.
Next Obligation.
intros y. rewrite elem_of_list_fmap. eauto using elem_of_enum.
Qed.
Program Instance bijective_finite: Finite B := _.
Next Obligation. eapply surjective_finite. eapply cancel_surj.
Unshelve. all: eapply _. Qed.
End bijective_finite.
Program Instance option_finite `{Finite A} : Finite (option A) :=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment