{-# OPTIONS --lossy-unification #-}
open import Cat.Instances.Functor.Compose
open import Cat.Functor.Equivalence
open import Cat.Instances.Functor
open import Cat.Functor.Base
open import Cat.Univalent
open import Cat.Prelude

import Cat.Functor.Reasoning.FullyFaithful as FfR
import Cat.Functor.Reasoning as FR
import Cat.Reasoning

open Functor
open _=>_

module Cat.Univalent.Rezk.Universal where

private variable
o β : Level
A B C CβΊ : Precategory o β

private module _ {o β} {C : Precategory o β} where
open Cat.Reasoning C using (_β_)
open _β_ public

-- Using β/Β·Β· over equational reasoning saves ~5k conversion checks


# Universal property of the Rezk completionπ

With the Rezk completion, we defined, for any precategory $\mathcal{C}$, a univalent category $\mathcal{C}^+$, together with a weak equivalence functor $R : \mathcal{C} \to \mathcal{C}^+$. We also stated, but did not in that module prove, the universal property of the Rezk completion: The functor $R$ is the universal map from $\mathcal{C}$ to categories. This module actually proves it, but be warned: the proof is very technical, and is mostly a calculation.

In generic terms, universality of the Rezk completion follows from univalent categories being the class of local objects for the weak equivalences1: A category $\mathcal{C}$ is univalent precisely if any weak equivalence $H : \mathcal{A} \to \mathcal{B}$ induces2 a proper equivalence of categories $- \circ H : [\mathcal{B},\mathcal{C}] \to [\mathcal{A},\mathcal{C}]$.

The high-level overview of the proof is as follows:

• For any eso $H : \mathcal{A} \to \mathcal{B}$, and for any $\mathcal{C}$, all precategories, the functor $- \circ H : [\mathcal{A},\mathcal{B}] \to [\mathcal{B},\mathcal{C}]$ is faithful. This is the least technical part of the proof, so we do it first.

• If $H$ is additionally full, then $- \circ H$ is fully faithful.

• If $H$ is a weak equivalence, and $\mathcal{C}$ is univalent, then $- \circ H$ is essentially surjective. By the principle of unique choice, it is an equivalence, and thus3 an isomorphism.

## Faithfulnessπ

The argument here is almost elementary: Weβre given a witness that $\gamma H = \delta H$, so all we have to do is manipulate the expression $\gamma_b$ to something which has a $\gamma H$ subexpression. Since $H$ is eso, given $b : \mathcal{B}$, we can find $a : \mathcal{A}$ and an iso $m : Ha \cong b$, from which we can calculate:

esoβpre-faithful
: (H : Functor A B) {F G : Functor B C}
β is-eso H β (Ξ³ Ξ΄ : F => G)
β (β b β Ξ³ .Ξ· (H .Fβ b) β‘ Ξ΄ .Ξ· (H .Fβ b)) β Ξ³ β‘ Ξ΄
esoβpre-faithful {A = A} {B = B} {C = C} H {F} {G} h-eso Ξ³ Ξ΄ p =
Nat-path Ξ» b β β₯-β₯-proj {ap = C.Hom-set _ _ _ _} do
(bβ² , m) β h-eso b
β₯_β₯.inc $Ξ³ .Ξ· b β‘β¨ C.intror (F-map-iso F m .invl) β©β‘ Ξ³ .Ξ· b C.β F.β (m .to) C.β F.β (m .from) β‘β¨ C.extendl (Ξ³ .is-natural _ _ _) β©β‘ G.β (m .to) C.β Ξ³ .Ξ· _ C.β F.β (m .from) β‘β¨ apβ C._β_ refl (apβ C._β_ (p bβ²) refl) β©β‘ G.β (m .to) C.β Ξ΄ .Ξ· _ C.β F.β (m .from) β‘β¨ C.extendl (sym (Ξ΄ .is-natural _ _ _)) β©β‘ Ξ΄ .Ξ· b C.β F.β (m .to) C.β F.β (m .from) β‘β¨ C.elimr (F-map-iso F m .invl) β©β‘ Ξ΄ .Ξ· b β where module C = Cat.Reasoning C module F = Functor F module G = Functor G  The above is, unfortunately, the simplest result in this module. The next two proofs are both quite technical: thatβs because weβre given some mere4 data, from the assumption that $H$ is a weak equivalence, so to use it as proper data, we need to show that whatever we want lives in a contractible space, after which we are free to project only the data we are interested in, and forget about the coherences. It will turn out, however, that the coherence data necessary to make these types contractible is exactly the coherence data we need to show that we are indeed building functors, natural transformations, etc. So, not only do we need it to use unique choice, we also need it to show weβre doing category theory. ## Full-faithfulnessπ Let $A$, $B$, $C$ and $H$ be as before, except now assume that $H$ is full (in addition to eso). eso-fullβpre-ff : (H : Functor A B) β is-eso H β is-full H β is-fully-faithful {C = Cat[ B , C ]} (precompose H) eso-fullβpre-ff {A = A} {B = B} {C = C} H H-eso H-full = res where  We will show that, for every natural transformation $\gamma : FH \to GH$, and each $b : \mathcal{B}$, there is a contractible type of βcomponent dataβ over $b$. These data consist of morphisms $g : Fb \to Gb$, each equipped with a witness that $g$ acts naturally when faced with isomorphisms $Ha \cong b$.  module A = Cat.Reasoning A module B = Cat.Reasoning B module C = Cat.Reasoning C module H = FR H module _ (F G : Functor B C) (Ξ³ : F Fβ H => G Fβ H) where module F = FR F module FH = FR (F Fβ H) module G = FR G module GH = FR (G Fβ H) module Ξ³ = _=>_ Ξ³  In more detail, if weβre given an essential fibre $(a,f)$ of $H$ over $b$, we can use $f$ to βmatch upβ our component $g$ with the components of the natural transformation $\gamma$: since $\gamma_a : FH(a) \to FG(a)$, weβve claimed to have a $Fb \to Gb$, and someone has just handed us a $H(a) \cong b$, then it darn well better be the case that $\gamma$ is $FH(a) \xrightarrow{Ff} Fb \xrightarrow{g} Gb \xrightarrow{Gf^{-1}} FG(a)\text{.}$  T : B.Ob β Type _ T b = Ξ£ (C.Hom (F.β b) (G.β b)) Ξ» g β (a : A.Ob) (f : H.β a B.β b) β Ξ³.Ξ· a β‘ G.β (f .from) C.β g C.β F.β (f .to)  Weβll first show that components exist at all. Assume that we have some $b : \mathcal{B}$ and an essential fibre $(a_0, h_0)$ of $H$ over it5. In this situation, guided by the compatibility condition (and isomorphisms being just the best), we can actually define the component to be βwhatever satisfies compatibility at $(a_0,h_0)$,β and a short calculation establishes that defining  module Mk (b : B.Ob) (aβ : A.Ob) (h : H.β aβ B.β b) where private module h = B._β _ h   g = G.β h.to C.β Ξ³.Ξ· aβ C.β F.β h.from  is indeed a possible choice. We present the formalisation below, but do not comment on the calculation, leaving it to the curious reader to load this file in Agda and poke around the proof.  lemma : (a : A.Ob) (f : H.β a B.β b) β Ξ³.Ξ· a β‘ G.β (f .from) C.β g C.β F.β (f .to) lemma a f = β₯-β₯-proj {ap = C.Hom-set _ _ _ _} do (k , p) β H-full (h.from B.β B.to f) (kβ»ΒΉ , q) β H-full (B.from f B.β h.to) β₯_β₯.inc$
C.intror (F.annihilate
(apβ B._β_ q p Β·Β· B.cancel-inner h.invl Β·Β· f .invr))
Β·Β· C.extendl (Ξ³.is-natural _ _ _)
Β·Β· apβ (Ξ» e eβ² β G.β e C.β Ξ³.Ξ· aβ C.β F.β eβ²) q p
Β·Β· apβ (Ξ» e eβ² β e C.β Ξ³.Ξ· aβ C.β eβ²) (G.F-β _ _) (F.F-β _ _)
Β·Β· C.pullr (ap (G.β h.to C.β_) (C.pulll refl) β C.pulll refl)


Anyway, because of how weβve phrased the coherence condition, if $g$, $g'$ both satisfy it, then we have $\gamma$ equal to both $G(h)gF(h^{-1})$ and $G(h)g'F(h^{-1})$.6 Since isomorphisms are both monic and epic, we can cancel $G(h)$ and $F(h^{-1})$ from these equations to conclude $g = g'$. Since the coherence condition is a proposition, the type of component data over $b$ is a proposition.

    T-prop : β b β is-prop (T b)
T-prop b (g , coh) (gβ² , cohβ²) =
Ξ£-prop-path (Ξ» x β Ξ -is-hlevelΒ² 1 Ξ» _ _ β C.Hom-set _ _ _ _) $β₯-β₯-proj {ap = C.Hom-set _ _ _ _} do (aβ , h) β H-eso b pure$ C.isoβepic (F-map-iso F h) _ _
(C.isoβmonic (F-map-iso G (h B.Isoβ»ΒΉ)) _ _
(sym (coh aβ h) β cohβ² aβ h))


Given any $b$, $H$ being eso means that we merely have an essential fibre $(a,h)$ of $H$ over $b$. But since the type of components over $b$ is a proposition, if weβre going to use it to construct a component over $b$, then we are granted the honour of actually getting hold of an $(a,h)$ pair.

    mkTβ² : β b β β₯ Essential-fibre H b β₯ β β₯ T b β₯
mkTβ² b he = do
(aβ , h) β he
β₯_β₯.inc (Mk.g b aβ h , Mk.lemma b aβ h)

mkT : β b β T b
mkT b = β₯-β₯-proj {ap = T-prop b} (mkTβ² b (H-eso b))


Another calculation shows that, since $H$ is full, given any pair of essential fibres $(a, h)$ over $b$ and $(a', h')$ over $b'$, with a mediating map $f : b \to b'$, we can choose a map $k : Ha \to Ha'$ satisfying $Hk = h'fh$, and since both the components at $b$ and $b$ βcome from $\gamma$β (which is natural), we get a naturality result for the transformation weβre defining, too.

That computation is a bit weirder, so itβs hidden in this <details> tag.
    module
_ {b bβ²} (f : B.Hom b bβ²) (a aβ² : A.Ob)
(h : H.β a B.β b) (hβ² : H.β aβ² B.β bβ²)
where
private
module hβ² = B._β_ hβ²
module h = B._β_ h

naturality : _
naturality = β₯-β₯-proj {ap = C.Hom-set _ _ _ _} do
(k , p) β H-full (hβ².from B.β f B.β h.to)
pure $C.pullr (C.pullr (F.weave (sym (B.pushl p β apβ B._β_ refl (B.cancelr h.invl))))) Β·Β· apβ C._β_ refl (C.extendl (Ξ³.is-natural _ _ _)) Β·Β· C.extendl (G.weave (B.lswizzle p hβ².invl))  Because of this naturality result, all the components weβve chosen piece together into a natural transformation. And since we defined $\delta$ parametrically over the choice of essential fibre, if weβre looking at some $Hb$, then we can choose the identity isomorphism, from which it falls out that $\delta H = \gamma$. Since we had already established that $- \circ H$ is faithful, and now weβve shown it is full, it is fully faithful.  Ξ΄ : F => G Ξ΄ .Ξ· b = mkT b .fst Ξ΄ .is-natural b bβ² f = β₯-β₯-elimβ {P = Ξ» Ξ± Ξ² β β₯-β₯-proj {ap = T-prop bβ²} (mkTβ² bβ² Ξ±) .fst C.β F.β f β‘ G.β f C.β β₯-β₯-proj {ap = T-prop b} (mkTβ² b Ξ²) .fst} (Ξ» _ _ β C.Hom-set _ _ _ _) (Ξ» (aβ² , hβ²) (a , h) β naturality f a aβ² h hβ²) (H-eso bβ²) (H-eso b) full : is-full (precompose H) full {x = x} {y = y} Ξ³ = pure (Ξ΄ _ _ Ξ³ , Nat-path p) where p : β b β Ξ΄ _ _ Ξ³ .Ξ· (H.β b) β‘ Ξ³ .Ξ· b p b = subst (Ξ» e β β₯-β₯-proj {ap = T-prop _ _ Ξ³ (H.β b)} (mkTβ² _ _ Ξ³ (H.β b) e) .fst β‘ Ξ³ .Ξ· b) (squash (inc (b , B.id-iso)) (H-eso (H.β b))) (C.eliml (y .F-id) β C.elimr (x .F-id)) res : is-fully-faithful (precompose H) res = full+faithfulβff (precompose H) full Ξ» {F} {G} {Ξ³} {Ξ΄} p β esoβpre-faithful H H-eso Ξ³ Ξ΄ Ξ» b β p Ξ·β b  ## Essential surjectivityπ The rest of the proof proceeds in this same way: Define a type which characterises, up to a compatible space of choices, first the action on morphisms of a functor which inverts $- \circ H$, and in terms of this type, the action on morphisms. Itβs mostly the same trick as above, but a lot wilder. We do not comment on it too extensively: the curious reader, again, can load this file in Agda and play around. module _ {ao aβ bo bβ co cβ} {A : Precategory ao aβ} {B : Precategory bo bβ} {C : Precategory co cβ} (H : Functor A B) (H-eso : is-eso H) (H-ff : is-fully-faithful H) (c-cat : is-category C) where private module A = Cat.Reasoning A module B = Cat.Reasoning B module C = Cat.Reasoning C module H = FfR H H-ff  The type of object-candidates Obs is indexed by a $b : \mathcal{B}$, and any object candidate $c$ must come with a family of isomorphisms $k_h$ giving, for every way of expressing $b$ as coming from $Ha$, a way of $c$ coming from $Fa$. To show this type is a proposition, we additionally require a naturality condition for these isomorphisms.  private module _ (F : Functor A C) where private module F = FR F Obs : B.Ob β Type _ Obs b = Ξ£ C.Ob Ξ» c β Ξ£ ((a : A.Ob) (h : H.β a B.β b) β F.β a C.β c) Ξ» k β ((a , h) (aβ² , hβ²) : Essential-fibre H b) (f : A.Hom a aβ²) β hβ² .to B.β H.β f β‘ h .to β k aβ² hβ² .to C.β F.β f β‘ k a h .to  Note that we can derive an object candidate over $b$ from a fibre $(a,h)$ of $H$ over $b$. Moreover, this choice is a center of contraction, so we can once more apply unique choice and the assumption that $H$ is eso to conclude that every $b : \mathcal{B}$ has an object candidate over it.  objβ² : β {b} β Essential-fibre H b β Obs b objβ² (aβ , hβ) .fst = F.β aβ objβ² (aβ , hβ) .snd .fst a h = F-map-iso F (H.iso.from (h B.βIso (hβ B.Isoβ»ΒΉ))) objβ² (aβ , hβ) .snd .snd (a , h) (aβ² , hβ²) f p = F.collapse (H.ipushr p) Obs-is-prop : β {b} (f : Essential-fibre H b) (c : Obs b) β objβ² f β‘ c Obs-is-prop (aβ , hβ) (cβ² , kβ² , Ξ²) = Ξ£-pathp (Univalent.isoβpath c-cat cβ cβ²)$
Ξ£-prop-pathp
(Ξ» i x β Ξ -is-hlevelΒ³ 1 Ξ» _ _ _ β Ξ -is-hlevel 1 Ξ» _ β C.Hom-set _ _ _ _) $funextP Ξ» a β funextP Ξ» h β C.β -pathp _ _$
Univalent.Hom-pathp-reflr-iso c-cat {q = cβcβ²}
( C.pullr (F.eliml (H.from-id (hβ .invr)))
β Ξ² _ _ _ (H.Ξ΅-lswizzle (hβ .invl)))
where
ckΞ± = objβ² (aβ , hβ)
c = ckΞ± .fst
k = ckΞ± .snd .fst
Ξ± = ckΞ± .snd .snd
cβcβ² = (k aβ hβ C.Isoβ»ΒΉ) C.βIso kβ² aβ hβ

    summon : β {b} β β₯ Essential-fibre H b β₯ β is-contr (Obs b)
summon f = β₯-β₯-proj {ap = is-contr-is-prop} do
f β f
pure $contr (objβ² f) (Obs-is-prop f) Gβ : B.Ob β C.Ob Gβ b = summon {b = b} (H-eso b) .centre .fst k : β {b} a (h : H.β a B.β b) β F.β a C.β Gβ b k {b = b} a h = summon {b = b} (H-eso b) .centre .snd .fst a h kcomm : β {b} ((a , h) (aβ² , hβ²) : Essential-fibre H b) (f : A.Hom a aβ²) β hβ² .to B.β H.β f β‘ h .to β k aβ² hβ² .to C.β F.β f β‘ k a h .to kcomm {b} f1 f2 f w = summon {b = b} (H-eso b) .centre .snd .snd f1 f2 f w  We will write Gβ for the canonical choice of object candidate, and k for the associated family of isomorphisms. The type of morphism candidates over $f : b \to b'$ consists of maps $G_0(b) \to G_0(b')$ which are compatible with the reindexing isomorphisms $k$ for any essential fibre $(a,h)$ over $b$, $(a',h')$ over $b'$, and map $l : a \to a'$ satisfying $h'H(l) = fh$.  compat : β {b bβ²} (f : B.Hom b bβ²) β C.Hom (Gβ b) (Gβ bβ²) β Type _ compat {b} {bβ²} f g = β a (h : H.β a B.β b) aβ² (hβ² : H.β aβ² B.β bβ²) (l : A.Hom a aβ²) β hβ² .to B.β H.β l β‘ f B.β h .to β k aβ² hβ² .to C.β F.β l β‘ g C.β k a h .to Homs : β {b bβ²} (f : B.Hom b bβ²) β Type _ Homs {b = b} {bβ²} f = Ξ£ (C.Hom (Gβ b) (Gβ bβ²)) (compat f)   compat-prop : β {b bβ²} (f : B.Hom b bβ²) {g : C.Hom (Gβ b) (Gβ bβ²)} β is-prop (compat f g) compat-prop f = Ξ -is-hlevelΒ³ 1 Ξ» _ _ _ β Ξ -is-hlevelΒ³ 1 Ξ» _ _ _ β C.Hom-set _ _ _ _  It will again turn out that any initial choice of fibre over $b$ and $b'$ gives a morphism candidate over $f : b \to b'$, and the compatibility data is exactly what we need to show the type of morphism candidates is a proposition. This proof really isnβt commented. Iβm sorry.  module _ {b bβ²} (f : B.Hom b bβ²) aβ (hβ : H.β aβ B.β b) aββ² (hββ² : H.β aββ² B.β bβ²) where lβ : A.Hom aβ aββ² lβ = H.from (hββ² .from B.β f B.β hβ .to) p : hββ² .to B.β H.β lβ β‘ (f B.β hβ .to) p = H.Ξ΅-lswizzle (hββ² .invl) gβ : C.Hom (Gβ b) (Gβ bβ²) gβ = k aββ² hββ² .to C.β F.β lβ C.β k aβ hβ .from module _ a (h : H.β a B.β b) aβ² (hβ² : H.β aβ² B.β bβ²) (l : A.Hom a aβ²) (w : hβ² .to B.β H.β l β‘ f B.β h .to) where m : aβ A.β a m = H.iso.from (hβ B.βIso (h B.Isoβ»ΒΉ)) mβ² : aββ² A.β aβ² mβ² = H.iso.from (hββ² B.βIso (hβ² B.Isoβ»ΒΉ)) Ξ± : k aβ hβ .from β‘ F.β (m .from) C.β k a h .from Ξ± = C.inverse-unique _ _ {f = k aβ hβ} {g = F-map-iso F m C.βIso k a h}$
sym (kcomm _ _ _ (H.Ξ΅-lswizzle (h .invl)))

Ξ³ : H.β (mβ² .to) B.β H.β lβ β‘ H.β l B.β H.β (m .to)
Ξ³ =  B.pushl (H.Ξ΅ _)
Β·Β· apβ B._β_ refl (p β
B.pushl (B.insertr (h .invl) β apβ B._β_ (sym w) refl))
Β·Β· B.deletel (hβ² .invr)
β apβ B._β_ refl (sym (H.Ξ΅ _))

Ξ³β² : lβ A.β m .from β‘ mβ² .from A.β l
Ξ³β² = A.isoβmonic mβ² _ _ $A.extendl (H.injective (H.swap Ξ³)) Β·Β· A.elimr (m .invl) Β·Β· A.insertl (mβ² .invl) Ξ΄ : gβ C.β k a h .to β‘ k aβ² hβ² .to C.β F.β l Ξ΄ = C.pullr ( C.pullr refl Β·Β· apβ C._β_ refl (C.pushl Ξ±) Β·Β· C.pulll refl β C.elimr (k a h .invr)) Β·Β· apβ C._β_ refl (F.weave Ξ³β²) Β·Β· C.pulll (C.pushl (sym (kcomm _ _ _ (H.Ξ΅-lswizzle (hβ² .invl)))) β C.elimr (F.annihilate (mβ² .invl))) Homs-pt : Homs f Homs-pt = gβ , Ξ» a h aβ² hβ² l w β sym (Ξ΄ a h aβ² hβ² l w) Homs-propβ² : (hβ² : Homs f) β hβ² .fst β‘ gβ Homs-propβ² (gβ , w) = C.isoβepic (k aβ hβ) _ _ (sym (Ξ΄ aβ hβ aββ² hββ² lβ p β w aβ hβ aββ² hββ² lβ p)) Homs-contrβ² : β {b bβ²} (f : B.Hom b bβ²) β β₯ is-contr (Homs f) β₯ Homs-contrβ² {b = b} {bβ²} f = do (aβ , h) β H-eso b (aββ² , hβ²) β H-eso bβ² inc (contr (Homs-pt f aβ h aββ² hβ²) Ξ» hβ² β Ξ£-prop-path (Ξ» _ β compat-prop f) (sym (Homs-propβ² f _ _ _ _ hβ²))) Homs-contr : β {b bβ²} (f : B.Hom b bβ²) β is-contr (Homs f) Homs-contr f = β₯-β₯-proj (Homs-contrβ² f) Gβ : β {b bβ²} β B.Hom b bβ² β C.Hom (Gβ b) (Gβ bβ²) Gβ f = Homs-contr f .centre .fst  Using the compatibility condition, and choices of $(a, h)$, we can show that the assignment of morphism candidates does assemble into a functor.  module Gβ {x y z} (f : B.Hom y z) (g : B.Hom x y) {ax ay az} (hx : H.β ax B.β x) (hy : H.β ay B.β y) (hz : H.β az B.β z) where af : A.Hom ay az af = H.from (hz .from B.β f B.β hy .to) ag : A.Hom ax ay ag = H.from (hy .from B.β g B.β hx .to) hβ² : H.β (af A.β ag) β‘ hz .from B.β f B.β g B.β hx .to hβ² = H.Ξ΅-expand refl β B.pullr (B.cancel-inner (hy .invl)) commutes : Gβ (f B.β g) β‘ Gβ f C.β Gβ g commutes = C.isoβepic (k ax hx) _ _$
sym (Homs-contr (f B.β g) .centre .snd ax hx az hz (af A.β ag)
(apβ B._β_ refl hβ² Β·Β· B.cancell (hz .invl) Β·Β· B.pulll refl))
β sym ( C.pullr (sym (Homs-contr g .centre .snd ax hx ay hy ag
(H.Ξ΅-lswizzle (hy .invl))))
β C.pulll (sym (Homs-contr f .centre .snd ay hy az hz af
(H.Ξ΅-lswizzle (hz .invl))))
β F.pullr refl)


In this manner, the assignment of object candidates and morphism candidates fits together into a functor $G : \mathcal{B} \to \mathcal{C}$. After finishing this, we have to show that $GH = F$. But the compatibility data which we have used to uniquely characterise $G$β¦ uniquely characterises $G$, after all, and it does so as composing with $H$ to give $F$.

    G : Functor B C
G .Fβ b = Gβ b
G .Fβ f = Gβ f

G .F-id = ap fst $Homs-contr B.id .paths$ C.id , Ξ» a h aβ² hβ² l w β
sym (C.idl _ β sym (kcomm (a , h) (aβ² , hβ²) l (w β B.idl _)))


Note that we proved7 that $G_1$ is functorial given choices of essential fibres of all three objects involved in the composition. Since weβre showing an equality in a set β a proposition β these choices donβt matter, so we can use essential surjectivity of $H$.

    G .F-β {x} {y} {z} f g = β₯-β₯-proj do
(ax , hx) β H-eso x
(ay , hy) β H-eso y
(az , hz) β H-eso z
inc (Gβ.commutes f g hx hy hz)


To use the unique charactersation of $G$ as βthe functor satisfying $GH = F$β, observe: for any $x : \mathcal{A}$, the object $F(x)$ can be made into an object candidate over $H(x)$, and since the type of object candidates is a proposition, our candidate $F(x)$ is identical to the value of $GH(x)$. Thatβs half of $GH = F$ established right off the bat!

    module _ (x : A.Ob) where
hf-obs : Obs (H.β x)
hf-obs .fst = F.Fβ x
hf-obs .snd .fst a h = F-map-iso F (H.iso.from h)
hf-obs .snd .snd (a , h) (aβ² , hβ²) f Ξ± = F.collapse (H.invβl Ξ±)

abstract
objp : Gβ (H.β x) β‘ F.β x
objp = ap fst $summon {H.β x} (H-eso _) .paths hf-obs   kp : (a : A.Ob) (h : H.β a B.β H.β x) β PathP (Ξ» i β F.β a C.β objp i) (k a h) (hf-obs .snd .fst a h) kp a h = ap (Ξ» e β e .snd .fst a h) (summon {H.β x} (H-eso (H.β x)) .paths hf-obs)  Over that identification, we can show that, for any $f : x \to y$ in $\mathcal{A}$, the value $F(f)$ is also a candidate for the morphism $GH(f)$, so these are also identical. This proof is a bit hairier, because $F(f)$ only has the right type if we adjust it by the proof that $GH(x) = F(x)$: we have to transport $F(f)$, and then as punishment for our hubris, invoke a lot of technical lemmas about the characterisation of PathP in the morphism spaces of (pre)categories.  module _ {x y} (f : A.Hom x y) where homβ² : Homs (H.β f) homβ² .fst = transport (Ξ» i β C.Hom (objp x (~ i)) (objp y (~ i))) (F.β f) homβ² .snd a h aβ² hβ² l w = sym$
C.pushl (Hom-transport C (sym (objp x)) (sym (objp y)) (F.β f))
Β·Β· apβ C._β_ refl
( C.pullr (from-pathp-from C (objp x) (Ξ» i β kp x a h i .to))
β F.weave (H.Ξ΅-twist (sym w)))
Β·Β· C.pulll (from-pathp-to C (sym (objp y)) Ξ» i β kp y aβ² hβ² (~ i) .to)

homp : transport (Ξ» i β C.Hom (objp x (~ i)) (objp y (~ i))) (F.β f)
β‘ Homs-contr (H.β f) .centre .fst
homp = ap fst $sym$ Homs-contr (H.β f) .paths homβ²

correct : G Fβ H β‘ F
correct = Functor-path objp Ξ» {x} {y} f β symP
{A = Ξ» i β C.Hom (objp x (~ i)) (objp y (~ i))} \$
to-pathp (homp f)


Since weβve shown that $GH = F$, so in particular $GH \cong F$, weβve now put together proofs that $- \circ H$ is fully faithful and, since the construction above works for any $F$, essentially surjective. Even better, since weβve actually constructed a functor $G$, weβve shown that $- \circ H$ is split essentially surjective! Since $[-,\mathcal{C}]$ is univalent whenever $\mathcal{C}$ is, the splitting would be automatic, but this is a nice strengthening.

  weak-equivβpre-equiv : is-equivalence {C = Cat[ B , C ]} (precompose H)
weak-equivβpre-equiv = ff+split-esoβis-equivalence {F = precompose H}
(eso-fullβpre-ff H H-eso Ξ» g β inc (H.from g , H.Ξ΅ g))
Ξ» F β G F , pathβiso (correct F)


And since a functor is an equivalence of categories iff. it is an isomorphism of categories, we also have that the rule sending $F$ to its $G$ is an equivalence of types.

  weak-equivβpre-iso : is-precat-iso {C = Cat[ B , C ]} (precompose H)
weak-equivβpre-iso = is-equivalenceβis-precat-iso (precompose H) weak-equivβpre-equiv
(Functor-is-category c-cat)
(Functor-is-category c-cat)


Restating the result that $- \circ H$ acts on objects as an equivalence of types, we have the following result: If $R : \mathcal{C} \to \mathcal{C}^+$ is a weak equivalence (a fully faithful and essentially surjective functor), then for any category $\mathcal{D}$ and functor $G : \mathcal{C} \to \mathcal{D}$, there is a contractible space(!) of extensions $H : \mathcal{C}^+ \to \mathcal{D}$ which factor $G$ through $F$.

weak-equivβreflection
: (F : Functor C CβΊ) β is-eso F β is-fully-faithful F
β {D : Precategory o β} β is-category D
β (G : Functor C D)
β is-contr (Ξ£ (Functor CβΊ D) Ξ» H β H Fβ F β‘ G)
weak-equivβreflection F F-eso F-ff D-cat G =
weak-equivβpre-iso F F-eso F-ff D-cat
.is-precat-iso.has-is-iso .is-eqv G


Note that this is only half of the point of the Rezk completion: we would also like for $\mathcal{C}^+$ to be univalent, but that is not necessary for $D$ to think that precomposition with $F$ is an isomorphism.

1. a weak equivalence is a fully faithful, essentially surjective functorβ©οΈ

2. since both its domain and codomain are univalentβ©οΈ

4. Donβt worry about actually getting your hands on an $(a_0, h_0)$.β©οΈ
5. Iβve implicitly used that $H$ is eso to cough up an $(a,h)$ over $b$, since weβre proving a propositionβ©οΈ
6. in the second <details> tag aboveβ©οΈ