End OpenBasis.
Arguments open_basis {X}.
Arguments coverable_by_open_basis_impl_open {X}.
Arguments open_basis_elements {X}.
Arguments open_basis_cover {X}.
Section BuildFromOpenBasis.
Variable X : Type.
Variable B : Family X.
Definition open_basis_cond :=
forall U V:Ensemble X, In B U -> In B V ->
forall x:X, In (Intersection U V) x ->
exists W:Ensemble X, In B W /\ In W x /\
Included W (Intersection U V).
Definition open_basis_cover_cond :=
forall x:X, exists U:Ensemble X, In B U /\ In U x.
Hypothesis Hbasis : open_basis_cond.
Hypothesis Hbasis_cover: open_basis_cover_cond.
Inductive B_open : Ensemble X -> Prop :=
| B_open_intro: forall F:Family X, Included F B ->
B_open (FamilyUnion F).
Definition Build_TopologicalSpace_from_open_basis : TopologicalSpace.
refine (Build_TopologicalSpace X B_open _ _ _).
intros.
pose proof (choice (fun (x:{S:Ensemble X | In F S}) (F:Family X) =>
Included F B /\ proj1_sig x = FamilyUnion F)).
unshelve refine (let H1:=(H0 _) in _); [ | clearbody H1 ].
intros.
destruct x.
pose proof (H x i).
destruct H1.
exists F0.
split; simpl; trivial.
clear H0.
destruct H1.
assert (FamilyUnion F = FamilyUnion (IndexedUnion x)).
apply Extensionality_Ensembles; split; red; intros.
destruct H1.
pose proof (H0 (exist _ _ H1)).
destruct H3.
simpl in H4.
rewrite H4 in H2.
destruct H2.
constructor 1 with S0.
exists (exist _ _ H1).
assumption.
assumption.
destruct H1.
destruct H1.
pose proof (H0 a).
destruct H3.
destruct a.
simpl in H4.
exists x2.
assumption.
rewrite H4.
exists x1.
assumption.
assumption.
rewrite H1.
constructor.
red; intros.
destruct H2.
pose proof (H0 a).
destruct H3.
auto with sets.
intros.
assert (Intersection U V = FamilyUnion
[ S:Ensemble X | In B S /\ Included S (Intersection U V) ]).
apply Extensionality_Ensembles; split; red; intros.
destruct H.
destruct H0.
destruct H1.
destruct H1.
destruct H2.
pose proof (H _ H1).
pose proof (H0 _ H2).
pose proof (Hbasis _ _ H5 H6).
assert (In (Intersection S S0) x). constructor; trivial.
apply H7 in H8.
clear H7.
destruct H8.
destruct H7 as [? [? ?]].
exists x0; trivial.
constructor.
split; trivial.
red; intros.
constructor.
exists S; trivial.
pose proof (H9 x1 H10).
destruct H11; trivial.
exists S0; trivial.
pose proof (H9 x1 H10).
destruct H11; trivial.
destruct H1.
destruct H1.
destruct H1.
auto.
rewrite H1.
constructor.
red; intros.
destruct H2.
destruct H2.
auto.
assert (Full_set = FamilyUnion B).
apply Extensionality_Ensembles; split; red; intros.
pose proof (Hbasis_cover x).
destruct H0.
destruct H0.
exists x0; trivial.
constructor.
rewrite H; constructor.
auto with sets.
Defined.

(* Specifications: *)
Lemma Build_TopologicalSpace_from_open_basis_point_set:
point_set Build_TopologicalSpace_from_open_basis = X.
Lemma Build_TopologicalSpace_from_open_basis_basis:
@open_basis Build_TopologicalSpace_from_open_basis B.