mirror of https://github.com/nmvdw/HITs-Examples
subset
This commit is contained in:
parent
826b6ba233
commit
140b02e9f4
|
@ -1,6 +1,5 @@
|
||||||
Require Import HoTT HitTactics.
|
Require Import HoTT HitTactics.
|
||||||
Require Import definition.
|
Require Import definition.
|
||||||
|
|
||||||
Section operations.
|
Section operations.
|
||||||
|
|
||||||
Context {A : Type}.
|
Context {A : Type}.
|
||||||
|
@ -48,4 +47,22 @@ intros X Y.
|
||||||
apply (comprehension (fun (a : A) => isIn a X) Y).
|
apply (comprehension (fun (a : A) => isIn a X) Y).
|
||||||
Defined.
|
Defined.
|
||||||
|
|
||||||
|
|
||||||
|
Definition subset :
|
||||||
|
FSet A -> FSet A -> Bool.
|
||||||
|
Proof.
|
||||||
|
intros X Y.
|
||||||
|
hrecursion X.
|
||||||
|
- exact true.
|
||||||
|
- exact (fun a => (a ∈ Y)).
|
||||||
|
- 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.
|
||||||
|
- intros x; cbn; destruct (x ∈ Y); reflexivity.
|
||||||
|
Defined.
|
||||||
|
|
||||||
|
Notation "⊆" := subset.
|
||||||
|
|
||||||
End operations.
|
End operations.
|
||||||
|
|
|
@ -196,7 +196,8 @@ hinduction; try (intros; apply set_path2).
|
||||||
Defined.
|
Defined.
|
||||||
|
|
||||||
(** assorted lattice laws *)
|
(** assorted lattice laws *)
|
||||||
Lemma distributive_La (z : FSet A) (a : A) : forall Y : FSet A, intersection (U (L a) z) Y = U (intersection (L a) Y) (intersection z Y).
|
Lemma distributive_La (z : FSet A) (a : A) : forall Y : FSet A,
|
||||||
|
intersection (U (L a) z) Y = U (intersection (L a) Y) (intersection z Y).
|
||||||
Proof.
|
Proof.
|
||||||
hinduction; try (intros ; apply set_path2) ; cbn.
|
hinduction; try (intros ; apply set_path2) ; cbn.
|
||||||
- symmetry ; apply nl.
|
- symmetry ; apply nl.
|
||||||
|
@ -265,7 +266,8 @@ hinduction x; try (intros ; apply set_path2) ; cbn.
|
||||||
cbn.
|
cbn.
|
||||||
rewrite P.
|
rewrite P.
|
||||||
rewrite Q.
|
rewrite Q.
|
||||||
destruct (isIn a X1) ; destruct (isIn a X2) ; destruct (isIn a y) ; reflexivity.
|
destruct (isIn a X1) ; destruct (isIn a X2) ; destruct (isIn a y) ;
|
||||||
|
reflexivity.
|
||||||
Defined.
|
Defined.
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,8 +347,10 @@ hinduction X1; try (intros ; apply set_path2) ; cbn.
|
||||||
cbn.
|
cbn.
|
||||||
intros Z1 Z2 P Q.
|
intros Z1 Z2 P Q.
|
||||||
rewrite comprehension_or.
|
rewrite comprehension_or.
|
||||||
assert (U (U (comprehension (fun a : A => isIn a Z1) X2) (comprehension (fun a : A => isIn a Z2) X2))
|
assert (U (U (comprehension (fun a : A => isIn a Z1) X2)
|
||||||
Y = U (U (comprehension (fun a : A => isIn a Z1) X2) (comprehension (fun a : A => isIn a Z2) X2))
|
(comprehension (fun a : A => isIn a Z2) X2))
|
||||||
|
Y = U (U (comprehension (fun a : A => isIn a Z1) X2)
|
||||||
|
(comprehension (fun a : A => isIn a Z2) X2))
|
||||||
(U Y Y)).
|
(U Y Y)).
|
||||||
rewrite (union_idem Y).
|
rewrite (union_idem Y).
|
||||||
reflexivity.
|
reflexivity.
|
||||||
|
@ -354,8 +358,9 @@ hinduction X1; try (intros ; apply set_path2) ; cbn.
|
||||||
rewrite <- assoc.
|
rewrite <- assoc.
|
||||||
rewrite (assoc (comprehension (fun a : A => isIn a Z2) X2)).
|
rewrite (assoc (comprehension (fun a : A => isIn a Z2) X2)).
|
||||||
rewrite Q.
|
rewrite Q.
|
||||||
rewrite (comm (U (comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) X2)
|
rewrite
|
||||||
(comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) Y)) Y).
|
(comm (U (comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) X2)
|
||||||
|
(comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) Y)) Y).
|
||||||
rewrite assoc.
|
rewrite assoc.
|
||||||
rewrite P.
|
rewrite P.
|
||||||
rewrite <- assoc.
|
rewrite <- assoc.
|
||||||
|
@ -364,10 +369,12 @@ hinduction X1; try (intros ; apply set_path2) ; cbn.
|
||||||
rewrite <- assoc.
|
rewrite <- assoc.
|
||||||
rewrite assoc.
|
rewrite assoc.
|
||||||
enough (C : (U (comprehension (fun a : A => (isIn a Z1 || isIn a Y)%Bool) X2)
|
enough (C : (U (comprehension (fun a : A => (isIn a Z1 || isIn a Y)%Bool) X2)
|
||||||
(comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) X2)) = (comprehension (fun a : A => (isIn a Z1 || isIn a Z2 || isIn a Y)%Bool) X2)).
|
(comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) X2))
|
||||||
|
= (comprehension (fun a : A => (isIn a Z1 || isIn a Z2 || isIn a Y)%Bool) X2)).
|
||||||
rewrite C.
|
rewrite C.
|
||||||
enough (D : (U (comprehension (fun a : A => (isIn a Z1 || isIn a Y)%Bool) Y)
|
enough (D : (U (comprehension (fun a : A => (isIn a Z1 || isIn a Y)%Bool) Y)
|
||||||
(comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) Y)) = (comprehension (fun a : A => (isIn a Z1 || isIn a Z2 || isIn a Y)%Bool) Y)).
|
(comprehension (fun a : A => (isIn a Z2 || isIn a Y)%Bool) Y))
|
||||||
|
= (comprehension (fun a : A => (isIn a Z1 || isIn a Z2 || isIn a Y)%Bool) Y)).
|
||||||
rewrite D.
|
rewrite D.
|
||||||
reflexivity.
|
reflexivity.
|
||||||
* repeat (rewrite comprehension_or).
|
* repeat (rewrite comprehension_or).
|
||||||
|
@ -429,4 +436,47 @@ hrecursion X; try (intros ; apply set_path2).
|
||||||
rewrite <- Q.
|
rewrite <- Q.
|
||||||
Admitted.
|
Admitted.
|
||||||
|
|
||||||
|
|
||||||
|
(* Properties about subset relation. *)
|
||||||
|
Lemma subsect_intersection `{Funext} (X Y : FSet A) :
|
||||||
|
subset X Y = true -> U 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).
|
||||||
|
(*intros. apply equiv_hprop_allpath.*)
|
||||||
|
+ intro. cbn. contradiction (false_ne_true).
|
||||||
|
+ intros. destruct (dec (a = a0)).
|
||||||
|
rewrite p; apply idem.
|
||||||
|
contradiction (false_ne_true).
|
||||||
|
+ intros X1 X2 IH1 IH2.
|
||||||
|
intro Ho.
|
||||||
|
destruct (isIn a X1);
|
||||||
|
destruct (isIn a X2).
|
||||||
|
specialize (IH1 idpath).
|
||||||
|
specialize (IH2 idpath).
|
||||||
|
rewrite assoc. rewrite IH1. reflexivity.
|
||||||
|
specialize (IH1 idpath).
|
||||||
|
rewrite assoc. rewrite IH1. reflexivity.
|
||||||
|
specialize (IH2 idpath).
|
||||||
|
rewrite assoc. rewrite (comm (L a)). rewrite <- assoc. rewrite IH2.
|
||||||
|
reflexivity.
|
||||||
|
cbn in Ho. contradiction (false_ne_true).
|
||||||
|
- intros X1 X2 IH1 IH2 G.
|
||||||
|
destruct (subset X1 Y);
|
||||||
|
destruct (subset X2 Y).
|
||||||
|
specialize (IH1 idpath).
|
||||||
|
specialize (IH2 idpath).
|
||||||
|
rewrite <- assoc. rewrite IH2. rewrite IH1. reflexivity.
|
||||||
|
specialize (IH1 idpath).
|
||||||
|
apply IH2 in G.
|
||||||
|
rewrite <- assoc. rewrite G. rewrite IH1. reflexivity.
|
||||||
|
specialize (IH2 idpath).
|
||||||
|
apply IH1 in G.
|
||||||
|
rewrite <- assoc. rewrite IH2. rewrite G. reflexivity.
|
||||||
|
specialize (IH1 G). specialize (IH2 G).
|
||||||
|
rewrite <- assoc. rewrite IH2. rewrite IH1. reflexivity.
|
||||||
|
Defined.
|
||||||
|
|
||||||
End properties.
|
End properties.
|
||||||
|
|
Loading…
Reference in New Issue