Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcat improvements #1766

Merged
merged 8 commits into from
Sep 27, 2023
29 changes: 21 additions & 8 deletions theories/WildCat/ZeroGroupoid.v
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,40 @@ Global Instance hasequivs_0gpd : HasEquivs ZeroGpd
(** Coq can't find the composite of the coercions [cate_fun : G $<~> H >-> G $-> H] and [fun_0gpd : Morphism_0Gpd G H >-> G -> H], probably because it passes through the definitional equality of [G $-> H] and [Morphism_0Gpd G H]. I couldn't find a solution, so instead here is a helper function to manually do the coercion when needed. *)

Definition equiv_fun_0gpd {G H : ZeroGpd} (f : G $<~> H) : G -> H
:= fun_0gpd _ _ (cate_fun f).
:= fun_0gpd _ _ (cat_equiv_fun _ _ _ f).

(** * Some tools for manipulating equivalences of 0-groupoids. Even though the proofs are easy, in certain contexts Coq gets confused about [$==] vs [$->], which makes it hard to prove this inline. So we record them here. *)

(** Every equivalence is injective. *)
Definition isinj_equiv_0gpd {G H : ZeroGpd} (f : G $<~> H)
{x y : G} (h : equiv_fun_0gpd f x $== equiv_fun_0gpd f y)
: x $== y.
Proof.
exact ((cat_eissect f x)^$ $@ fmap (equiv_fun_0gpd f^-1$) h $@ cat_eissect f y).
Defined.

(** This is one example of many things that could be ported from Basics/Equivalences.v. *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud here: It would be nice if we could derive all path. equiv (and maybe even group) lemmas from common wildcat ones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think a lot of what we currently prove about Type is a special case of WildCat results, but there's a challenge about avoiding circularity, since the WildCat library uses some concepts about types. In any case, I'm seeing more and more ways that the WildCat library can have a real impact on other results, and also internal simplifications as more fundamental things get added.

Copy link
Collaborator

@Alizter Alizter Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the circularity issues are a non-issue. We can always prove what we need in wildcat in the library. In fact, we could fully cut the dependency on Types as a result. and have Types depend on Wildcat. We shouldn't need much of Types to prove results about wildcats. On the other hand, we would gain a lot using wildcat in Types.

Definition moveR_equiv_V_0gpd {G H : ZeroGpd} (f : G $<~> H) (x : H) (y : G) (p : x $== equiv_fun_0gpd f y)
: equiv_fun_0gpd f^-1$ x $== y
:= fmap (equiv_fun_0gpd f^-1$) p $@ cat_eissect f y.

(** * We now give a different characterization of the equivalences of 0-groupoids, as the injective split essentially surjective 0-functors, which are defined in EquivGpd. *)

(** Advantages of this logically equivalent formulation are that it tends to be easier to prove in examples and that in some cases it is definitionally equal to [ExtensionAlong], which is convenient. See Homotopy/Suspension.v and Algebra/AbGroups/Abelianization for examples. Advantages of the bi-invertible definition are that it reproduces a definition that is equivalent to [IsEquiv] when applied to types, assuming [Funext]. It also works in any 1-category. *)

(** Every equivalence is injective and split essentially surjective. *)
Definition IsSurjInj_Equiv_0Gpd {G H : ZeroGpd} (f : G $<~> H)
Global Instance issurjinj_equiv_0gpd {G H : ZeroGpd} (f : G $<~> H)
: IsSurjInj (equiv_fun_0gpd f).
Proof.
set (finv := equiv_fun_0gpd f^-1$).
econstructor.
- intro y.
exists (finv y).
exists (equiv_fun_0gpd f^-1$ y).
rapply cat_eisretr.
- intros x1 x2 m.
exact ((cat_eissect f x1)^$ $@ fmap finv m $@ cat_eissect f x2).
- apply isinj_equiv_0gpd.
Defined.

(** Conversely, every injective split essentially surjective 0-functor is an equivalence. *)
Global Instance IsEquiv_0Gpd_IsSurjInj {G H : ZeroGpd} (F : G $-> H)
(** Conversely, every injective split essentially surjective 0-functor is an equivalence. In practice, this is often the easiest way to prove that a functor is an equivalence. *)
Definition isequiv_0gpd_issurjinj {G H : ZeroGpd} (F : G $-> H)
{e : IsSurjInj F}
: Cat_IsBiInv F.
Proof.
Expand Down