Make everything work with the new notation

This commit is contained in:
Dan Frumin 2017-08-08 17:44:27 +02:00
parent 80dabe3162
commit dad6686c4c
4 changed files with 37 additions and 40 deletions

View File

@ -25,10 +25,10 @@ Section sub_classes.
apply _.
Defined.
Definition hasUnion := forall X Y, C X -> C Y -> C (max_fun X Y).
Definition hasIntersection := forall X Y, C X -> C Y -> C (min_fun X Y).
Definition hasEmpty := C empty_sub.
Definition hasSingleton := forall a, C (singleton a).
Definition closedUnion := forall X Y, C X -> C Y -> C (max_fun X Y).
Definition closedIntersection := forall X Y, C X -> C Y -> C (min_fun X Y).
Definition closedEmpty := C empty_sub.
Definition closedSingleton := forall a, C (singleton a).
Definition hasDecidableEmpty := forall X, C X -> hor (X = empty_sub) (hexists (fun a => X a)).
End sub_classes.
@ -37,12 +37,12 @@ Section isIn.
Variable C : (A -> hProp) -> hProp.
Context `{Univalence}.
Context {HS : hasSingleton C} {HIn : forall X, C X -> forall a, Decidable (X a)}.
Context {HS : closedSingleton C} {HIn : forall X, C X -> forall a, Decidable (X a)}.
Theorem decidable_A_isIn : forall a b : A, Decidable (Trunc (-1) (b = a)).
Proof.
intros.
unfold Decidable, hasSingleton in *.
unfold Decidable, closedSingleton in *.
pose (HIn (singleton a) (HS a) b).
destruct s.
- unfold singleton in t.
@ -71,13 +71,13 @@ Section intersect.
Defined.
Context
{HI :hasIntersection C} {HE : hasEmpty C}
{HS : hasSingleton C} {HDE : hasDecidableEmpty C}.
{HI : closedIntersection C} {HE : closedEmpty C}
{HS : closedSingleton C} {HDE : hasDecidableEmpty C}.
Theorem decidable_A_intersect : forall a b : A, Decidable (Trunc (-1) (b = a)).
Proof.
intros.
unfold Decidable, hasEmpty, hasIntersection, hasSingleton, hasDecidableEmpty in *.
unfold Decidable, closedEmpty, closedIntersection, closedSingleton, hasDecidableEmpty in *.
pose (HI (singleton a) (singleton b) (HS a) (HS b)) as IntAB.
pose (HDE (min_fun (singleton a) (singleton b)) IntAB) as IntE.
refine (@Trunc_rec _ _ _ _ _ IntE) ; intros [p | p] ; unfold min_fun, singleton in p.

View File

@ -5,30 +5,29 @@ Require Import FSets implementations.interface.
Section Operations.
Context `{Univalence}.
Global Instance list_empty : hasEmpty list := fun A => nil.
Global Instance list_empty A : hasEmpty (list A) := nil.
Global Instance list_single : hasSingleton list := fun A a => cons a nil.
Global Instance list_single A: hasSingleton (list A) A := fun a => cons a nil.
Global Instance list_union : hasUnion list.
Global Instance list_union A : hasUnion (list A).
Proof.
intros A l1 l2.
intros l1 l2.
induction l1.
* apply l2.
* apply (cons a IHl1).
Defined.
Global Instance list_membership : hasMembership list.
Global Instance list_membership A : hasMembership (list A) A.
Proof.
intros A.
intros a l.
induction l as [ | b l IHl].
- apply False_hp.
- apply (hor (a = b) IHl).
Defined.
Global Instance list_comprehension : hasComprehension list.
Global Instance list_comprehension A: hasComprehension (list A) A.
Proof.
intros A ϕ l.
intros ϕ l.
induction l as [ | b l IHl].
- apply nil.
- apply (if ϕ b then cons b IHl else IHl).
@ -36,8 +35,8 @@ Section Operations.
Fixpoint list_to_set A (l : list A) : FSet A :=
match l with
| nil => E
| cons a l => U (L a) (list_to_set A l)
| nil =>
| cons a l => {|a|} (list_to_set A l)
end.
End Operations.
@ -60,10 +59,10 @@ Section ListToSet.
* apply (tr (inr z2)).
Defined.
Definition empty_empty : list_to_set A empty = := idpath.
Definition empty_empty : list_to_set A = := idpath.
Lemma filter_comprehension (ϕ : A -> Bool) (l : list A) :
list_to_set A (filter ϕ l) = comprehension ϕ (list_to_set A l).
list_to_set A (filter ϕ l) = {| list_to_set A l & ϕ |}.
Proof.
induction l ; cbn in *.
- reflexivity.
@ -81,7 +80,7 @@ Section ListToSet.
list_to_set A (union l1 l2) = (list_to_set A l1) (list_to_set A l2).
Proof.
induction l1 ; induction l2 ; cbn.
- apply (union_idem _)^.
- apply (nl _)^.
- apply (nl _)^.
- rewrite IHl1.
apply assoc.

View File

@ -223,7 +223,7 @@ Section enumerated_fset.
end.
Lemma list_to_fset_ext (ls : list A) (a : A):
listExt ls a -> isIn a (list_to_fset ls).
listExt ls a -> a (list_to_fset ls).
Proof.
induction ls as [|x xs]; simpl.
- apply idmap.
@ -269,7 +269,7 @@ Section fset_dec_enumerated.
- intros a X Hls.
strip_truncations. apply tr.
destruct Hls as [ls Hls].
exists (cons a ls). intros b. simpl.
exists (cons a ls). intros b. cbn.
f_ap.
- intros. apply path_ishprop.
- intros. apply path_ishprop.
@ -294,16 +294,16 @@ Section subobjects.
Definition enumeratedS (P : Sub A) : hProp :=
enumerated (sigT P).
Lemma enumeratedS_empty : enumeratedS empty_sub.
Lemma enumeratedS_empty : closedEmpty enumeratedS.
Proof.
unfold enumeratedS.
apply tr. exists nil. simpl.
intros [a Ha]. assumption.
Defined.
Lemma enumeratedS_singleton (x : A) : enumeratedS (singleton x).
Lemma enumeratedS_singleton : closedSingleton enumeratedS.
Proof.
apply tr. simpl.
intros x. apply tr. simpl.
exists (cons (x;tr idpath) nil).
intros [y Hxy]. simpl.
strip_truncations. apply tr.
@ -417,7 +417,7 @@ Section subobjects.
end.
Lemma list_weaken_to_fset_ext (P : Sub A) (ls : list (sigT P)) (a : A) (Ha : P a):
listExt ls (a;Ha) -> isIn a (list_weaken_to_fset P ls).
listExt ls (a;Ha) -> a (list_weaken_to_fset P ls).
Proof.
induction ls as [|[x Hx] xs]; simpl.
- apply idmap.

View File

@ -6,7 +6,7 @@ Section k_finite.
Context (A : Type).
Context `{Univalence}.
Definition map (X : FSet A) : Sub A := fun a => isIn a X.
Definition map (X : FSet A) : Sub A := fun a => a X.
Global Instance map_injective : IsEmbedding map.
Proof.
@ -69,37 +69,35 @@ Section structure_k_finite.
Context (A : Type).
Context `{Univalence}.
Lemma map_union : forall X Y : FSet A, map (U X Y) = max_fun (map X) (map Y).
Lemma map_union : forall X Y : FSet A, map (X Y) = max_fun (map X) (map Y).
Proof.
intros.
unfold map, max_fun.
reflexivity.
Defined.
Lemma k_finite_union : hasUnion (Kf_sub A).
Lemma k_finite_union : closedUnion (Kf_sub A).
Proof.
unfold hasUnion, Kf_sub, Kf_sub_intern.
unfold closedUnion, Kf_sub, Kf_sub_intern.
intros.
destruct X0 as [SX XP].
destruct X1 as [SY YP].
exists (U SX SY).
exists (SX SY).
rewrite map_union.
rewrite XP, YP.
reflexivity.
Defined.
Lemma k_finite_empty : hasEmpty (Kf_sub A).
Lemma k_finite_empty : closedEmpty (Kf_sub A).
Proof.
unfold hasEmpty, Kf_sub, Kf_sub_intern, map, empty_sub.
exists E.
exists .
reflexivity.
Defined.
Lemma k_finite_singleton : hasSingleton (Kf_sub A).
Lemma k_finite_singleton : closedSingleton (Kf_sub A).
Proof.
unfold hasSingleton, Kf_sub, Kf_sub_intern, map, singleton.
intro.
exists (L a).
exists {|a|}.
cbn.
apply path_forall.
intro z.
@ -108,7 +106,7 @@ Section structure_k_finite.
Lemma k_finite_hasDecidableEmpty : hasDecidableEmpty (Kf_sub A).
Proof.
unfold hasDecidableEmpty, hasEmpty, Kf_sub, Kf_sub_intern, map.
unfold hasDecidableEmpty, closedEmpty, Kf_sub, Kf_sub_intern, map.
intros.
destruct X0 as [SX EX].
rewrite EX.