2017-05-24 13:54:00 +02:00
|
|
|
Require Import HoTT HitTactics.
|
2017-05-23 16:30:31 +02:00
|
|
|
Require Import definition.
|
|
|
|
Section operations.
|
|
|
|
|
2017-05-24 13:54:00 +02:00
|
|
|
Context {A : Type}.
|
|
|
|
Context {A_deceq : DecidablePaths A}.
|
2017-05-23 16:30:31 +02:00
|
|
|
|
|
|
|
Definition isIn : A -> FSet A -> Bool.
|
|
|
|
Proof.
|
|
|
|
intros a.
|
2017-05-24 13:54:00 +02:00
|
|
|
hrecursion.
|
2017-05-23 16:30:31 +02:00
|
|
|
- exact false.
|
2017-05-24 13:54:00 +02:00
|
|
|
- intro a'. destruct (dec (a = a')); [exact true | exact false].
|
2017-05-23 16:30:31 +02:00
|
|
|
- apply orb.
|
2017-05-24 13:54:00 +02:00
|
|
|
- intros x y z. compute. destruct x; reflexivity.
|
|
|
|
- intros x y. compute. destruct x, y; reflexivity.
|
|
|
|
- intros x. compute. reflexivity.
|
|
|
|
- intros x. compute. destruct x; reflexivity.
|
2017-06-14 18:06:16 +02:00
|
|
|
- intros a'. simpl.
|
|
|
|
destruct (match dec (a = a') with
|
|
|
|
| inl _ => true
|
|
|
|
| inr _ => false
|
|
|
|
end); compute; reflexivity.
|
2017-05-23 16:30:31 +02:00
|
|
|
Defined.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
- intros. cbv. apply assoc.
|
|
|
|
- intros. cbv. apply comm.
|
|
|
|
- intros. cbv. apply nl.
|
|
|
|
- intros. cbv. apply nr.
|
|
|
|
- intros. cbv.
|
|
|
|
destruct (P x); simpl.
|
|
|
|
+ apply idem.
|
|
|
|
+ apply nl.
|
|
|
|
Defined.
|
|
|
|
|
|
|
|
Definition intersection :
|
|
|
|
FSet A -> FSet A -> FSet A.
|
|
|
|
Proof.
|
|
|
|
intros X Y.
|
|
|
|
apply (comprehension (fun (a : A) => isIn a X) Y).
|
|
|
|
Defined.
|
|
|
|
|
2017-06-14 18:06:16 +02:00
|
|
|
Definition difference :
|
|
|
|
FSet A -> FSet A -> FSet A := fun X Y =>
|
|
|
|
comprehension (fun a => negb (isIn a X)) Y.
|
2017-05-24 18:28:24 +02:00
|
|
|
|
|
|
|
Definition subset :
|
|
|
|
FSet A -> FSet A -> Bool.
|
|
|
|
Proof.
|
|
|
|
intros X Y.
|
|
|
|
hrecursion X.
|
|
|
|
- exact true.
|
2017-05-26 12:28:07 +02:00
|
|
|
- exact (fun a => (isIn a Y)).
|
2017-05-24 18:28:24 +02:00
|
|
|
- exact andb.
|
|
|
|
- intros. compute. destruct x; reflexivity.
|
|
|
|
- intros x y; compute; destruct x, y; reflexivity.
|
|
|
|
- intros x; compute; destruct x; reflexivity.
|
|
|
|
- intros x; compute; destruct x; reflexivity.
|
2017-05-26 12:28:07 +02:00
|
|
|
- intros x; cbn; destruct (isIn x Y); reflexivity.
|
2017-05-24 18:28:24 +02:00
|
|
|
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-06-14 18:06:16 +02:00
|
|
|
Infix "⊆" := subset (at level 10, right associativity).
|