2017-08-01 15:12:59 +02:00
|
|
|
|
(** Extensionality of the FSets *)
|
|
|
|
|
Require Import HoTT HitTactics.
|
2017-08-08 13:35:28 +02:00
|
|
|
|
Require Import representations.definition fsets.operations.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
|
|
|
|
Section ext.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Context {A : Type}.
|
|
|
|
|
Context `{Univalence}.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-09 18:05:58 +02:00
|
|
|
|
Lemma subset_union (X Y : FSet A) :
|
2017-08-08 13:35:28 +02:00
|
|
|
|
X ⊆ Y -> X ∪ Y = Y.
|
|
|
|
|
Proof.
|
|
|
|
|
hinduction X ; try (intros; apply path_forall; intro; apply set_path2).
|
|
|
|
|
- intros. apply nl.
|
|
|
|
|
- intros a.
|
|
|
|
|
hinduction Y ; try (intros; apply path_forall; intro; apply set_path2).
|
|
|
|
|
+ intro.
|
|
|
|
|
contradiction.
|
|
|
|
|
+ intro a0.
|
|
|
|
|
simple refine (Trunc_ind _ _).
|
2017-08-09 18:05:58 +02:00
|
|
|
|
intro p ; simpl.
|
2017-08-08 13:35:28 +02:00
|
|
|
|
rewrite p; apply idem.
|
|
|
|
|
+ intros X1 X2 IH1 IH2.
|
|
|
|
|
simple refine (Trunc_ind _ _).
|
|
|
|
|
intros [e1 | e2].
|
|
|
|
|
++ rewrite assoc.
|
|
|
|
|
rewrite (IH1 e1).
|
|
|
|
|
reflexivity.
|
|
|
|
|
++ rewrite comm.
|
|
|
|
|
rewrite <- assoc.
|
|
|
|
|
rewrite (comm X2).
|
|
|
|
|
rewrite (IH2 e2).
|
|
|
|
|
reflexivity.
|
|
|
|
|
- intros X1 X2 IH1 IH2 [G1 G2].
|
|
|
|
|
rewrite <- assoc.
|
|
|
|
|
rewrite (IH2 G2).
|
|
|
|
|
apply (IH1 G1).
|
|
|
|
|
Defined.
|
|
|
|
|
|
|
|
|
|
Lemma subset_union_l (X : FSet A) :
|
|
|
|
|
forall Y, X ⊆ X ∪ Y.
|
|
|
|
|
Proof.
|
|
|
|
|
hinduction X ; try (repeat (intro; intros; apply path_forall);
|
2017-08-11 13:15:31 +02:00
|
|
|
|
intro ; apply path_ishprop).
|
2017-08-08 13:35:28 +02:00
|
|
|
|
- apply (fun _ => tt).
|
|
|
|
|
- intros a Y.
|
|
|
|
|
apply (tr(inl(tr idpath))).
|
|
|
|
|
- intros X1 X2 HX1 HX2 Y.
|
2017-08-08 17:00:30 +02:00
|
|
|
|
split ; unfold subset in *.
|
2017-08-08 13:35:28 +02:00
|
|
|
|
* rewrite <- assoc. apply HX1.
|
|
|
|
|
* rewrite (comm X1 X2). rewrite <- assoc. apply HX2.
|
|
|
|
|
Defined.
|
|
|
|
|
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Lemma subset_union_equiv
|
2017-08-07 16:49:46 +02:00
|
|
|
|
: forall X Y : FSet A, X ⊆ Y <~> X ∪ Y = Y.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Proof.
|
|
|
|
|
intros X Y.
|
|
|
|
|
eapply equiv_iff_hprop_uncurried.
|
|
|
|
|
split.
|
|
|
|
|
- apply subset_union.
|
|
|
|
|
- intro HXY.
|
|
|
|
|
rewrite <- HXY.
|
|
|
|
|
apply subset_union_l.
|
|
|
|
|
Defined.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Lemma subset_isIn (X Y : FSet A) :
|
2017-08-07 16:49:46 +02:00
|
|
|
|
(forall (a : A), a ∈ X -> a ∈ Y)
|
2017-08-08 17:00:30 +02:00
|
|
|
|
<~> X ⊆ Y.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Proof.
|
|
|
|
|
eapply equiv_iff_hprop_uncurried.
|
|
|
|
|
split.
|
|
|
|
|
- hinduction X ;
|
2017-08-11 13:15:31 +02:00
|
|
|
|
try (intros; repeat (apply path_forall; intro); apply path_ishprop).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
+ intros ; reflexivity.
|
|
|
|
|
+ intros a f.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
apply f.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
apply tr ; reflexivity.
|
|
|
|
|
+ intros X1 X2 H1 H2 f.
|
2017-08-07 16:49:46 +02:00
|
|
|
|
enough (X1 ⊆ Y).
|
|
|
|
|
enough (X2 ⊆ Y).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
{ split. apply X. apply X0. }
|
|
|
|
|
* apply H2.
|
|
|
|
|
intros a Ha.
|
2017-08-07 16:49:46 +02:00
|
|
|
|
refine (f _ (tr _)).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
right.
|
|
|
|
|
apply Ha.
|
|
|
|
|
* apply H1.
|
|
|
|
|
intros a Ha.
|
2017-08-07 16:49:46 +02:00
|
|
|
|
refine (f _ (tr _)).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
left.
|
|
|
|
|
apply Ha.
|
|
|
|
|
- hinduction X ;
|
2017-08-11 13:15:31 +02:00
|
|
|
|
try (intros; repeat (apply path_forall; intro); apply path_ishprop).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
+ intros. contradiction.
|
|
|
|
|
+ intros b f a.
|
|
|
|
|
simple refine (Trunc_ind _ _) ; cbn.
|
|
|
|
|
intro p.
|
|
|
|
|
rewrite p^ in f.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
apply f.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
+ intros X1 X2 IH1 IH2 [H1 H2] a.
|
|
|
|
|
simple refine (Trunc_ind _ _) ; cbn.
|
|
|
|
|
intros [C1 | C2].
|
|
|
|
|
++ apply (IH1 H1 a C1).
|
|
|
|
|
++ apply (IH2 H2 a C2).
|
|
|
|
|
Defined.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-02 11:40:03 +02:00
|
|
|
|
(** ** Extensionality proof *)
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-07 16:49:46 +02:00
|
|
|
|
Lemma eq_subset' (X Y : FSet A) : X = Y <~> (Y ∪ X = X) * (X ∪ Y = Y).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Proof.
|
|
|
|
|
unshelve eapply BuildEquiv.
|
|
|
|
|
{ intro H'. rewrite H'. split; apply union_idem. }
|
|
|
|
|
unshelve esplit.
|
|
|
|
|
{ intros [H1 H2]. etransitivity. apply H1^.
|
|
|
|
|
rewrite comm. apply H2. }
|
2017-08-09 18:05:58 +02:00
|
|
|
|
intro; apply path_prod; apply set_path2.
|
|
|
|
|
all: intro; apply set_path2.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Defined.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Lemma eq_subset (X Y : FSet A) :
|
2017-08-07 16:49:46 +02:00
|
|
|
|
X = Y <~> (Y ⊆ X * X ⊆ Y).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Proof.
|
2017-08-07 16:49:46 +02:00
|
|
|
|
transitivity ((Y ∪ X = X) * (X ∪ Y = Y)).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
apply eq_subset'.
|
|
|
|
|
symmetry.
|
|
|
|
|
eapply equiv_functor_prod'; apply subset_union_equiv.
|
|
|
|
|
Defined.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Theorem fset_ext (X Y : FSet A) :
|
2017-08-07 16:49:46 +02:00
|
|
|
|
X = Y <~> (forall (a : A), a ∈ X = a ∈ Y).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
Proof.
|
|
|
|
|
refine (@equiv_compose' _ _ _ _ _) ; [ | apply eq_subset ].
|
2017-08-07 16:49:46 +02:00
|
|
|
|
refine (@equiv_compose' _ ((forall a, a ∈ Y -> a ∈ X)
|
|
|
|
|
*(forall a, a ∈ X -> a ∈ Y)) _ _ _).
|
2017-08-02 11:40:03 +02:00
|
|
|
|
- apply equiv_iff_hprop_uncurried.
|
|
|
|
|
split.
|
|
|
|
|
* intros [H1 H2 a].
|
|
|
|
|
specialize (H1 a) ; specialize (H2 a).
|
|
|
|
|
apply path_iff_hprop.
|
|
|
|
|
apply H2.
|
|
|
|
|
apply H1.
|
|
|
|
|
* intros H1.
|
|
|
|
|
split ; intro a ; intro H2.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
+ rewrite (H1 a).
|
|
|
|
|
apply H2.
|
|
|
|
|
+ rewrite <- (H1 a).
|
|
|
|
|
apply H2.
|
2017-08-02 11:40:03 +02:00
|
|
|
|
- eapply equiv_functor_prod' ;
|
|
|
|
|
apply equiv_iff_hprop_uncurried ;
|
|
|
|
|
split ; apply subset_isIn.
|
|
|
|
|
Defined.
|
2017-08-01 15:12:59 +02:00
|
|
|
|
|
2017-08-09 18:05:58 +02:00
|
|
|
|
End ext.
|