HITs-Examples/FiniteSets/fsets/extensionality_alt.v

68 lines
2.0 KiB
Coq
Raw Normal View History

(** Extensionality of the FSets *)
Require Import HoTT HitTactics.
Require Import representations.definition fsets.operations.
Section ext.
Context {A : Type}.
Context `{Univalence}.
2017-08-14 16:39:20 +02:00
Lemma equiv_subset1_l (X Y : FSet A) (H1 : Y X = X) (a : A) (Ya : a Y) : a X.
Proof.
2017-08-14 16:39:20 +02:00
apply (transport (fun Z => a Z) H1 (tr(inl Ya))).
Defined.
2017-08-14 16:39:20 +02:00
Lemma equiv_subset1_r X : forall (Y : FSet A), (forall a, a Y -> a X) -> Y X = X.
Proof.
2017-08-14 16:39:20 +02:00
hinduction ; try (intros ; apply path_ishprop).
- intros.
apply nl.
- intros b sub.
specialize (sub b (tr idpath)).
revert sub.
2017-08-14 16:39:20 +02:00
hinduction X ; try (intros ; apply path_ishprop).
* contradiction.
* intros.
strip_truncations.
rewrite sub.
apply union_idem.
* intros X Y subX subY mem.
strip_truncations.
2017-08-14 16:39:20 +02:00
destruct mem as [t | t].
** rewrite assoc, (subX t).
reflexivity.
2017-08-14 16:39:20 +02:00
** rewrite (comm X), assoc, (subY t).
reflexivity.
- intros Y1 Y2 H1 H2 H3.
rewrite <- assoc.
rewrite (H2 (fun a HY => H3 a (tr(inr HY)))).
2017-08-14 16:39:20 +02:00
apply (H1 (fun a HY => H3 a (tr(inl HY)))).
Defined.
2017-08-14 16:39:20 +02:00
Lemma eq_subset1 X Y : (Y X = X) * (X Y = Y) <~> forall (a : A), a X = a Y.
Proof.
eapply equiv_iff_hprop_uncurried ; split.
- intros [H1 H2] a.
apply path_iff_hprop ; apply equiv_subset1_l ; assumption.
- intros H1.
split ; apply equiv_subset1_r ; intros.
* rewrite H1 ; assumption.
* rewrite <- H1 ; assumption.
Defined.
Lemma eq_subset2 (X Y : FSet A) : X = Y <~> (Y X = X) * (X Y = Y).
Proof.
2017-08-14 16:39:20 +02:00
eapply equiv_iff_hprop_uncurried ; split.
- intro Heq.
split.
* apply (ap (fun Z => Z X) Heq^ @ union_idem X).
* apply (ap (fun Z => Z Y) Heq @ union_idem Y).
- intros [H1 H2].
apply (H1^ @ comm Y X @ H2).
Defined.
Theorem fset_ext (X Y : FSet A) :
2017-08-14 16:39:20 +02:00
X = Y <~> forall (a : A), a X = a Y.
Proof.
2017-08-14 16:39:20 +02:00
apply (equiv_compose' (eq_subset1 X Y) (eq_subset2 X Y)).
Defined.
End ext.