intersection_comm

This commit is contained in:
Leon Gondelman 2017-05-23 11:50:52 +02:00
parent 2f68e833af
commit afdc4a3e6b
1 changed files with 75 additions and 0 deletions

View File

@ -397,6 +397,46 @@ hrecursion.
+ apply nl.
Defined.
Lemma comprehension_union X Y Z :
U (comprehension (fun a => isIn a Y) X)
(comprehension (fun a => isIn a Z) X) =
comprehension (fun a => isIn a (U Y Z)) X.
Proof.
hrecursion X.
- cbn. apply nl.
- cbn. intro a.
destruct (isIn a Y); simpl;
destruct (isIn a Z); simpl.
apply idem.
apply nr.
apply nl.
apply nl.
- cbn. intros X1 X2 IH1 IH2.
rewrite assoc.
rewrite (comm _ (comprehension (fun a : A => isIn a Y) X1)
(comprehension (fun a : A => isIn a Y) X2)).
rewrite <- (assoc _
(comprehension (fun a : A => isIn a Y) X2)
(comprehension (fun a : A => isIn a Y) X1)
(comprehension (fun a : A => isIn a Z) X1)
).
rewrite IH1.
rewrite comm.
rewrite assoc.
rewrite (comm _ (comprehension (fun a : A => isIn a Z) X2) _).
rewrite IH2.
rewrite comm.
reflexivity.
- intros. apply set_path2.
- intros; apply set_path2.
- intros; apply set_path2.
- intros; apply set_path2.
- intros; apply set_path2.
Defined.
Lemma comprehension_false Y : comprehension (fun a => isIn a E) Y = E.
Proof.
hrecursion Y; try (intros; apply set_path2).
@ -446,6 +486,41 @@ intros X Y.
apply (comprehension (fun (a : A) => isIn a X) Y).
Defined.
Lemma intersection_comm X Y: intersection X Y = intersection Y X.
Proof.
hrecursion X; try (intros; apply set_path2).
- cbn. unfold intersection. apply comprehension_false.
- cbn. unfold intersection. intros a.
hrecursion Y; try (intros; apply set_path2).
+ cbn. reflexivity.
+ cbn. intros. unfold deceq.
destruct (dec (a0 = a)).
rewrite p. destruct (dec (a=a)).
reflexivity.
contradiction n.
reflexivity.
destruct (dec (a = a0)).
contradiction n. apply p^. reflexivity.
+ cbn -[isIn]. intros Y1 Y2 IH1 IH2.
rewrite IH1.
rewrite IH2.
symmetry.
rewrite (comprehension_union (L a)).
reflexivity.
- intros X1 X2 IH1 IH2.
cbn.
unfold intersection in *.
rewrite <- IH1.
rewrite <- IH2.
rewrite comprehension_union.
reflexivity.
Defined.
Definition subset (x : FSet A) (y : FSet A) : Bool.
Proof.
hrecursion x.