HITs-Examples/FiniteSets/subobjects/sub.v

79 lines
2.4 KiB
Coq
Raw Normal View History

2017-08-03 12:27:43 +02:00
Require Import HoTT.
2017-09-07 15:44:22 +02:00
Require Import set_names lattice_interface lattice_examples prelude.
2017-08-03 12:27:43 +02:00
Section subobjects.
Variable A : Type.
Definition Sub := A -> hProp.
2017-08-03 15:07:53 +02:00
2017-08-08 19:56:39 +02:00
Global Instance sub_empty : hasEmpty Sub := fun _ => False_hp.
Global Instance sub_union : hasUnion Sub := max_fun.
Global Instance sub_intersection : hasIntersection Sub := min_fun.
Global Instance sub_singleton : hasSingleton Sub A
:= fun a b => BuildhProp (Trunc (-1) (b = a)).
Global Instance sub_membership : hasMembership Sub A := fun a X => X a.
Global Instance sub_comprehension : hasComprehension Sub A
:= fun ϕ X a => BuildhProp (X a * (ϕ a = true)).
Global Instance sub_subset `{Univalence} : hasSubset Sub
:= fun X Y => BuildhProp (forall a, X a -> Y a).
2017-08-03 15:07:53 +02:00
2017-08-03 12:27:43 +02:00
End subobjects.
2017-08-03 15:07:53 +02:00
Section sub_classes.
Context {A : Type}.
2017-08-03 12:27:43 +02:00
Variable C : (A -> hProp) -> hProp.
Context `{Univalence}.
Global Instance subobject_lattice : Lattice (Sub A).
2017-08-03 12:27:43 +02:00
Proof.
apply _.
Defined.
2017-08-08 19:56:39 +02:00
Definition closedUnion := forall X Y, C X -> C Y -> C (X Y).
Definition closedIntersection := forall X Y, C X -> C Y -> C (X Y).
Definition closedEmpty := C .
Definition closedSingleton := forall a, C {|a|}.
Definition hasDecidableEmpty := forall X, C X -> hor (X = ) (hexists (fun a => a X)).
2017-08-03 15:07:53 +02:00
End sub_classes.
Section isIn.
Variable A : Type.
Variable C : (A -> hProp) -> hProp.
Context `{Univalence}.
Context {HS : closedSingleton C} {HIn : forall X, C X -> forall a, Decidable (X a)}.
2017-08-03 15:07:53 +02:00
2017-09-01 16:56:49 +02:00
Theorem decidable_A_isIn (a b : A) : Decidable (Trunc (-1) (b = a)).
2017-08-03 15:07:53 +02:00
Proof.
2017-09-01 16:56:49 +02:00
destruct (HIn {|a|} (HS a) b).
- apply (inl t).
- refine (inr(fun p => _)).
2017-08-03 15:07:53 +02:00
strip_truncations.
contradiction (n (tr p)).
Defined.
End isIn.
Section intersect.
Variable A : Type.
Variable C : (Sub A) -> hProp.
2017-09-01 17:08:00 +02:00
Context `{Univalence}
{HI : closedIntersection C} {HE : closedEmpty C}
{HS : closedSingleton C} {HDE : hasDecidableEmpty C}.
2017-08-03 15:07:53 +02:00
2017-09-01 16:56:49 +02:00
Theorem decidable_A_intersect (a b : A) : Decidable (Trunc (-1) (b = a)).
2017-08-03 15:07:53 +02:00
Proof.
2017-09-01 16:56:49 +02:00
unfold Decidable.
2017-08-08 19:56:39 +02:00
pose (HI {|a|} {|b|} (HS a) (HS b)) as IntAB.
pose (HDE ({|a|} {|b|}) IntAB) as IntE.
2017-09-01 16:56:49 +02:00
refine (Trunc_rec _ IntE) ; intros [p | p].
- refine (inr(fun q => _)).
2017-08-08 19:56:39 +02:00
strip_truncations.
2017-09-01 16:56:49 +02:00
refine (transport (fun Z => a Z) p (tr idpath, tr q^)).
2017-08-03 15:07:53 +02:00
- strip_truncations.
2017-09-01 16:56:49 +02:00
destruct p as [? [t1 t2]].
2017-08-03 15:07:53 +02:00
strip_truncations.
apply (inl (tr (t2^ @ t1))).
Defined.
End intersect.