2017-08-01 15:12:59 +02:00
|
|
|
(* Operations on the [FSet A] for an arbitrary [A] *)
|
2017-05-24 13:54:00 +02:00
|
|
|
Require Import HoTT HitTactics.
|
2017-08-01 15:41:53 +02:00
|
|
|
Require Import representations.definition disjunction lattice.
|
2017-05-23 16:30:31 +02:00
|
|
|
|
2017-08-01 15:12:59 +02:00
|
|
|
Section operations.
|
2017-05-24 13:54:00 +02:00
|
|
|
Context {A : Type}.
|
2017-08-01 15:12:59 +02:00
|
|
|
Context `{Univalence}.
|
2017-05-23 16:30:31 +02:00
|
|
|
|
2017-08-01 15:12:59 +02:00
|
|
|
Definition isIn : A -> FSet A -> hProp.
|
2017-05-23 16:30:31 +02:00
|
|
|
Proof.
|
|
|
|
intros a.
|
2017-05-24 13:54:00 +02:00
|
|
|
hrecursion.
|
2017-08-01 15:12:59 +02:00
|
|
|
- exists Empty.
|
|
|
|
exact _.
|
|
|
|
- intro a'.
|
|
|
|
exists (Trunc (-1) (a = a')).
|
|
|
|
exact _.
|
|
|
|
- apply lor.
|
|
|
|
- intros ; apply lor_assoc. exact _.
|
|
|
|
- intros ; apply lor_comm. exact _.
|
|
|
|
- intros ; apply lor_nl. exact _.
|
|
|
|
- intros ; apply lor_nr. exact _.
|
|
|
|
- intros ; apply lor_idem. exact _.
|
2017-05-23 16:30:31 +02:00
|
|
|
Defined.
|
|
|
|
|
2017-08-01 15:12:59 +02:00
|
|
|
Definition subset : FSet A -> FSet A -> hProp.
|
|
|
|
Proof.
|
|
|
|
intros X Y.
|
|
|
|
hrecursion X.
|
|
|
|
- exists Unit.
|
|
|
|
exact _.
|
|
|
|
- intros a.
|
|
|
|
apply (isIn a Y).
|
|
|
|
- intros X1 X2.
|
|
|
|
exists (prod X1 X2).
|
|
|
|
exact _.
|
|
|
|
- intros.
|
|
|
|
apply path_trunctype ; apply equiv_prod_assoc.
|
|
|
|
- intros.
|
|
|
|
apply path_trunctype ; apply equiv_prod_symm.
|
|
|
|
- intros.
|
|
|
|
apply path_trunctype ; apply prod_unit_l.
|
|
|
|
- intros.
|
|
|
|
apply path_trunctype ; apply prod_unit_r.
|
|
|
|
- intros a'.
|
|
|
|
apply path_iff_hprop ; cbn.
|
|
|
|
* intros [p1 p2]. apply p1.
|
|
|
|
* intros p.
|
|
|
|
split ; apply p.
|
|
|
|
Defined.
|
2017-05-23 16:30:31 +02:00
|
|
|
|
|
|
|
Definition comprehension :
|
|
|
|
(A -> Bool) -> FSet A -> FSet A.
|
|
|
|
Proof.
|
|
|
|
intros P.
|
2017-05-24 13:54:00 +02:00
|
|
|
hrecursion.
|
2017-05-23 16:30:31 +02:00
|
|
|
- apply E.
|
|
|
|
- intro a.
|
|
|
|
refine (if (P a) then L a else E).
|
|
|
|
- apply U.
|
2017-08-01 15:12:59 +02:00
|
|
|
- apply assoc.
|
|
|
|
- apply comm.
|
|
|
|
- apply nl.
|
|
|
|
- apply nr.
|
|
|
|
- intros; simpl.
|
|
|
|
destruct (P x).
|
2017-05-23 16:30:31 +02:00
|
|
|
+ apply idem.
|
|
|
|
+ apply nl.
|
|
|
|
Defined.
|
|
|
|
|
2017-08-01 15:12:59 +02:00
|
|
|
Definition isEmpty :
|
|
|
|
FSet A -> Bool.
|
2017-05-23 16:30:31 +02:00
|
|
|
Proof.
|
2017-08-01 15:12:59 +02:00
|
|
|
hrecursion.
|
|
|
|
- apply true.
|
|
|
|
- apply (fun _ => false).
|
|
|
|
- apply andb.
|
|
|
|
- intros. symmetry. eauto with bool_lattice_hints.
|
|
|
|
- eauto with bool_lattice_hints.
|
|
|
|
- eauto with bool_lattice_hints.
|
|
|
|
- eauto with bool_lattice_hints.
|
|
|
|
- eauto with bool_lattice_hints.
|
|
|
|
Defined.
|
|
|
|
|
2017-05-24 13:54:00 +02:00
|
|
|
End operations.
|
2017-05-26 12:28:07 +02:00
|
|
|
|
|
|
|
Infix "∈" := isIn (at level 9, right associativity).
|
2017-08-01 15:12:59 +02:00
|
|
|
Infix "⊆" := subset (at level 10, right associativity).
|