Formalizing the ∞-Categorical Yoneda Lemma

Formalized 1-category theory forms a core component of various libraries of mathematical proofs. However, more sophisticated results in fields from algebraic topology to theoretical physics, where objects have “higher structure,” rely on infinite-dimensional categories in place of 1-dimensional categories, and ∞-category theory has thusfar proved unamenable to computer formalization. Using a new proof assistant called Rzk, which is designed to support Riehl–Shulman’s simplicial extension of homotopy type theory for synthetic ∞-category theory, we provide the first formalizations of results from ∞-category theory. This includes in particular a formalization of the Yoneda lemma, often regarded as the fundamental theorem of category theory, a theorem which roughly states that an object of a given category is determined by its relationship to all of the other objects of the category. A key feature of our framework is that, thanks to the synthetic theory, many constructions are automatically natural or functorial. We plan to use Rzk to formalize further results from ∞-category theory, such as the theory of limits and colimits and adjunctions.


Introduction
Computer proof assistants are computer programs that formally verify the logical reasoning of mathematical proofs.There are a wide variety of such programs -including Agda [24,89], Coq [18], HOL Light [52], Isabelle [88], and Lean [35,36], among many others -which have enjoyed striking success in recent decades.Notable accomplishments include: • A project [51] in HOL Light from 2003-2014, to formally verify the Ferguson-Hales proof of the Kepler conjecture, after the referees for the 2005 Annals publication issued a disclaimer stating that they were only 99% certain of its correctness.• A project [45] in Coq, from 2006-2012, to formally verify the Feit-Thompson Odd Order Theorem, a foundational result in the classification of finite simple groups.• A project in Lean [36], from 2020-2022, dubbed the "liquid tensor experiment" [110], to formally verify a result from condensed mathematics after Peter Scholze expressed concern about the correctness of his own proof.
Part of the task in formalizing a cutting-edge mathematical result is to develop an accompanying library of background mathematics on which it depends.For instance, the liquid tensor experiment required a formalized library of standard results from graduate-level homological algebra as well as many other background topics.
In addition to homological algebra, Lean's mathematics library mathlib [80] contains standard results from number theory, representation theory, general topology, linear algebra including Banach and Hilbert spaces, measures and integral calculus, random variables, basic algebraic geometry, model theory, and category theory, among other topics.Despite all these achievements, as of the writing of this article, Lean's mathlib does not contain any ∞-category theory, and thus myriad recent results from algebraic K-theory [20], derived and spectral algebraic geometry [72,75], the Langlands program [39], and symplectic geometry [86] are inaccessible to formalization.
Building such a library would arguably be no more difficult than the successes mentioned above, but the endeavor would be frustrated by the ways in which the traditional set-based foundations for mathematics are not optimal for reasoning about ∞-categories.To give a precise definition of an ∞-category -which, roughly speaking, is an infinitedimensional category with a weak composition law in which all morphisms above dimension 1 are weakly invertibleone must pick a "model," a Bourbaki-style mathematical structure presenting the ∞-categorical data [17,29].A variety of models -such as quasi-categories [21,57], complete Segal spaces [99], and Segal categories [54,93] -are used at various places in the literature, and theorems are often proven "analytically," in reference to the "coordinates" of a particular model.A computer formalizer is thus faced with an unattractive choice of either • picking one model, which must then be used for the entire library of subsequent results, or • formalizing multiple models and the comparisons between them [59], which significantly increases the workload. 1  1.1 Reimagining the foundations of ∞-category theory A radical-sounding alternative, which we argue is worth taking seriously, is to change the foundation system.The article "Could ∞-category theory be taught to undergraduates?" [100] argues that it is possible to narrow the gap between ∞category theory and ordinary 1-category theory by replacing the traditional foundations with a directed extension of homotopy type theory [107,127].The basis for this claim is the paper [103] (and the follow-up work of [14,28,136]), which develops the basic theory of ∞-categories in an alternative foundational framework established there.The simplicial type theory is a formal framework that permits one to make the following intuitive definitions rigorous: • A type is a pre-∞-category (aka a Segal type) if every composable pair of arrows has a unique composite.• A pre-∞-category is an ∞-category (aka a Rezk type) if equalities are equivalent to isomorphisms.• A type is an ∞-groupoid (aka a discrete type) if equalities are equivalent to arrows.• A type family is a covariant fibration (aka a covariant type family) if every arrow in the base type has a unique lift with specified domain.
The intended model of this formal system is in the category of simplicial spaces (aka the category of bisimplicial sets), which Shulman had shown provides a model of homotopy theory, in which types are interpreted as Reedy fibrant simplicial spaces [113].In this model, pre-∞-categories correspond to Segal spaces [99,112], ∞-categories correspond to complete Segal spaces [99], and covariant fibrations correspond to left fibrations [34,62].The phrases "for all . . .there exists . . .unique" are meant in the standard sense of homotopy type theory [107,127].In particular, following the homotopical extension of the Curry-Howard correspondence [10,55,131], uniqueness means contractibility -which is precisely what is true semantically for the composition operation in an ∞-category. 2 This model validates the terminology 1 Experts in the field often prefer to work "model-independently" [12,71] which can be done either by using ∞-category theory itself as the ambient metatheory, or deploying the formalism of ∞-cosmoi (i.e., categories of ∞-categories) [106], but either approach would require some initial formalization in a specific model of ∞-categories. 2Those familiar with the Segal space model of ∞-categories may be surprised that the definition of a pre-∞-category refers to binary sequences of composable arrows and not also composable triples and quadruples and so on.Here the binary statement subsumes the -ary ones for  ≥ 0 because it is interpreted internally in the model as the assertion that the internal used in our synthetic theory of ∞-categories.Via this interpretation functor, proofs of theorems about ∞-categories in the simplicial type theory really do prove theorems about ∞-categories, as instantiated by the complete Segal spaces model in traditional foundations.
More generally, Shulman has proven that homotopy type theory has semantics in any ∞-topos [102,115] and Weinberger [138] has shown that the simplicial type theory of [103] can be interpreted in simplicial objects in any ∞-topos.Thus, theorems proven about synthetic ∞-categories in the simplicial type theory also apply to the internal ∞-categories studied by Martini, Rasekh, Stenzel, and Wolf among others [77,78,96,118].

Formalizing ∞-category theory
It is relatively standard practice in homotopy type theory to formalize results while writing the corresponding paper proofs. 3At the time of the writing of the first paper on synthetic ∞-category theory by Riehl and Shulman [103], it was not possible to formalize any of its results because the work is done in an extension of traditional homotopy type theory, with multilevel contexts and a new type-forming operation providing extension types.
The multilevel context includes cube and tope layers, upon which the final layer of types may depend.The cube and tope layers combine to provide directed shapes that parametrize arrows, composable pairs of arrows, and their composites, among other simplices and their subshapes.The rules for these layers are spelled out in [103, §2.1].The extension types reify all the possible totalizations or extensions of a given partially defined datum along a subshape inclusion and satisfy rules enumerated in [103, §2.2].
Extension types are playing an important rule in both simplicial [103] and cubical type theory [7,9,19,30,33,92], the metatheory thereof [1,46,[119][120][121]140], and various applications in programming language theory [48,122,141].In this work, we require at least simplicial extension types -where the adjective "simplicial" refers to the geometry of the subshape inclusions -whereas cubical provers, such as Cubical Agda [130], red* family of proof assistants [124][125][126], Aya, and Arend all support only cubical extension types.A reasonable alternative could be to postulate extension types, e.g. in Agda with user-defined rewrite rules.4 However, to the best of our knowledge, this approach fails to capture rewriting for an application of a variable of extension type to an argument, leaving computational rules incomplete, and requiring additional bookkeeping in user-defined proofs to mapping types mapping out of the 2-simplex and out of its inner horn are equivalent [103,Section 5]. 3 While homotopy type theory cannot be formalized in Lean or Idris [25] because their kernels assume that all types are sets, contradicting Voevodsky's univalence axiom, it can be done in Agda, Coq, and a growing variety of experimental proof assistants.4 see https://agda.readthedocs.io/en/latest/language/rewriting.htmlpush computation further.The new proof assistant Rzk developed by Kudasov [64] supports simplicial extension types, 5and, thus, finally one can formally test the claims made in the article [100].This is the content of our project.
In §2, we describe the simplicial type theory, and in §3 we introduce synthetic ∞-category theory.In §4, we describe the Rzk proof assistant.In §5, we describe our formalization of the ∞-categorical Yoneda lemma in Rzk.In §6, we compare this formalization with parallel formalizations of the 1-categorical Yoneda lemma in both traditional and univalent foundations.In §7, we offer a few takeaways from this formalization project and describe related future work.
This paper is accompanied by an open source formalization repository available at https://github.com/emilyriehl/yoneda.The code is written in a literate style, using Rzk code blocks embedded in Markdown files.For the convenience of the readers, formalizations are rendered and available at https://emilyriehl.github.io/yoneda/.In this paper, most definitions and proofs have a corresponding identifier, acting also as a hyperlink to its formalized counterpart.For example, the Yoneda lemma is formalized as yoneda-lemma.

Contributions
Our contribution consists of a library for synthetic ∞-category theory, developed from scratch for the new Rzk proof assistant.The library contains large portions of formalized synthetic ∞-category theory from the paper [103], previously not supported by any proof assistant.The results range from properties of extension types, to formal properties of synthetic ∞-categories and fibrations thereof, to the Yoneda lemma.We also formalized many results from Standard/Book HoTT [107,127] that were needed as a foundation.Finally, we contribute a comparison to other formalizations of the Yoneda lemma in other systems and proof assistants, in particular to the formalization of the Yoneda lemma for precategories that we contributed to the agda-unimath library.
Moreover, the formalization process led us to discover a mistake in the paper [103]: the published proof of the "only if" direction of Proposition 8.13 employed circular reasoning. 6ortunately, the stated result remains true.Our new formalized proof (is-segal-is-covariant-representable) now appears in [104].
In parallel with the submission of this paper, we invited other researchers to contribute to the broader project of formalizing synthetic ∞-category theory, extending the results reported upon here.To that end, we created a clone of our repository, 7 which to date has had a dozen contributors, in addition to ourselves.In that repository, together with our new collaborators, we are already pursuing some of the projects we describe in §7.

Prerequisites
Our work involves a subtle interplay between (homotopy) type theory and (higher) category theory.While §2 and §3 provide some introductory discussion of the relevant concepts, some familiarity with these topics is necessary for a deeper understanding of our work, and thus we direct the interested reader to further background sources in the literature.Our work assumes very solid knowledge of Martin-Löf type theory (MLTT) and homotopy type theory (HoTT); see the two books on homotopy type theory due to the Univalent Foundations Project [127] and Rijke [107], resp.A working mathematician's discussion of ∞-categories and their peculiarities is given by Riehl in [100].For the discussion of the Rzk proof assistant and the comparisons of formalizations, it may be helpful to have some familiarity with Coq [18] and (Cubical) Agda [24,89,130], as well as agda-unimath [133].

Related work
A roughly parallel synthetic framework for ∞-category theory has been proposed by Weaver and Licata using bicubical sets as an intended model [135].An alternate approach to formalizing higher category is within the framework of twolevel type theory, using extensional type theory as a metatheory, see e.g.[8,63,132].
A conceptual discussion of the approach behind simplicial type theory with comparisons is done by Buchholtz in [26].A self-contained overview of both syntactic and semantic aspects of simplicial type theory is given in the master's thesis of Bakke [13].
Furthermore, there has been extensive work on directed type theories [67,90,91,134], though most of this was not created to describe ∞-category theory.Other work includes domain-specific languages for two-dimensional categories of various flavors, see [4,44], as well as further work for the case of bicategories [3,5,43,81,116], virtual equipments [87], and double categories [129].There also exist other type theories capturing infinite-dimensional categorical structures.Notable developments include [6,16,22,37,[40][41][42].However, these systems differ from the one that we are using in two major aspects: their setup and their purposes.Our framework features a synthetic and homotopical theory of ∞-categories with the aim of developing a range of classical ∞-categorical results.The other frameworks tend to involve a specific model of either strict or weak infinite-dimensional categories.
Aside from direct applications to category theory, new kinds of type theories have been devised for the purpose of doing differential topology and stable homotopy theory synthetically, making heavy use of type-theoretic modalities [31, 82-85, 108, 109, 111, 114].
In [103], Riehl-Shulman develop a type theory to reason synthetically about ∞-categories.The key features of their theory is that ∞-categories can be described in relatively simple terms, and all the results are invariant under homotopy equivalence -the right notion of equivalence of ∞categories.This is in stark contrast to the more traditional and familiar developments of ∞-category theory in set theory, cf.e.g.[58,73].We will give an overview of the structure and features of the simplicial type theory, with an emphasis on its use for synthetic ∞-category theory.
The theory builds on Martin-Löf intensional type theory (MLTT) [76] whose intensional identity types have homotopically well-behaved path objects as models [10,60,101,123].This homotopical interpretation, paired with Voevodksy's univalence axiom, which allows one to treat homotopy equivalent types as (intensionally) equal, goes by the name homotopy type theory (HoTT) or univalent foundations cf.[10,127,131].Homotopy type theory may be thought of as a synthetic theory for ∞-groupoids (aka homotopy types) and thus provides a fertile basis for the simplicial type theory.

Base Theory: Martin-Löf Intensional Type Theory
Overview.The base theory is intensional Martin-Löf type theory [76] with Σ-, Π-, and identity types.Though Rzk works with a universe type to implement dependent types, this assumption is not necessary [103,Remark 2.5]. 8To stay in line with the notation of [103], we also notate a dependent type  :  ⊢  () as a type family  :  → U, pretending U is a universe type (without being explicit about universe hierarchy or different levels of size).
For  :  → U, the dependent sum :  () is the type consisting of dependent pairs (, ) with  :  and  :  ().This is also referred to as the total type of the family .The Σ-type comes with the usual set of rules for formation, introduction (by forming dependent pairs), and elimination (by projecting to the factors).We also assume the -and -computation rules to be satisfied, meaning that introduction and elimination are inverse to each other in the strictest possible way, i.e., up to judgmental equality.
The family  :  → U can alternatively be encoded as a map   :  → , with the total type  :≡ :  (), and the projection   (, ) :≡ .The total type is then the "sum" of all the fibers of , canonically indexed by .If  is a constant family, i.e.,  () ≡  for all  :  and some type , the Σ-type becomes the cartesian product  × .Π-Types.Of particular interest is the notion of dependent function or section of a family  :  → U, which is an assignment  to each element  :  of some element  () :  () in the corresponding fiber.This is reified as the dependent product type :  (), with introduction rule given by abstraction and elimination rule by function application.Likewise, we require the -and -rules to hold judgmentally.When the type family  is constant with value some type , the dependent function type reduces to an ordinary function type, denoted by  →  or   .
Identity Types (01-paths).The Martin-Löf identity types ( =  ) for a type  and elements ,  :  capture the idea that equality between terms of a type is witnessed proofrelevantly by a term  :  =  .In the homotopical models, identity types get interpreted as path objects in the sense of homotopical algebra [10], so elements  : ( =  ) can be seen as paths from  to  in .The introduction rule is given by the canonical reflexivity terms refl  : ( =  ) witnessing self-identity.Elimination is given by the path induction principle.Intuitively, this says the following.First, for a type , fix  : .Then, for a family  : ( : ( =  )) → U the type of sections (, ):  : (=   )  (, ) is equivalent to  (, refl  ) via the map evrefl , : (, ):  : (=   )  (, ) →  (, refl  ).
In particular, given  :  (, refl  ) we obtain a section ind = () : such that ind = () (, refl  ) ≡ .Thus, for type families over (based) path types, to produce a section of the whole family it suffices to produce a section only at the reflexivity loop.
The Homotopy Theory of Types.The following notions are due to Voevodsky [131], cf. also [10,60,101,123].According to the idea that terms  : ( =  ) encode paths in a type we want to express when a type is homotopically trivial aka contractible.This is witnessed by the type isContr() :≡ ∑︁ : : (is-contr) A contractible type  comes equipped with a canonical inhabitant, the center of contraction   :  (center-contraction) and a homotopy   : : (  =  ) (homotopy-contraction).Contractible types are equivalent to the point or terminal type 1, see (contr-iff-terminal-map-is-equiv).
Traditional homotopy theory involves constructions on topological spaces that are invariant under homotopy equivalence, which is a pair of maps between two spaces in opposite directions whose composites are homotopic to the identity.Translating this into type theory, a map  :  →  between types is a (homotopy) equivalence when there is a term inhabiting the type isEquiv( ) :≡ ∑︁ :→ (is-equiv) This type is a proposition in the sense that it is contractible whenever if it is inhabited.By [107, 12.1.3] ,,: serving to reverse paths as well as concatenating them.One can show that these satisfy the expected groupoid laws, but only up to propositional equality, endowing every type canonically with the structure of a (weak) ∞-groupoid, cf.[55,128].
While ∞-groupoids are special cases of ∞-categories, in a general ∞-category we require directed "arrows" that are not necessarily reversible.This suggests the following extensions of the underlying type theory.

Extension 1: Cube and Tope Layers
Intuitively, a synthetic ∞-category is a type where directed arrows can be composed up to homotopy.To reason about directed arrows, their composites, and other shapes arising from this the idea is to introduce an appropriate shape theory to the type theory.The shapes will be part of the contexts so that type families and sections can depend on them.
Each shape is viewed as a subshape embedded inside a higher dimensional (directed) cube.This is reminiscent of the basic setup of cubical type theory.
For the cube layer, consider a new pretype 2, equipped with two distinct elements 0, 1 : 2, and a binary relation ≤ making 2 into a strict partial order with bottom element 0 and top element 1.The Lawvere theory generated by 2 constitutes the cube layer, i.e., the cubes are exactly the finite powers 2  , with 2 0 ≡ 1.The partial order is captured by a new judgment form, called a tope: The tope layer is a finitary intuitionistic logic over the cube layer.The intention is to carve out subshapes Φ ⊆  of a cube  by describing it via a formula on the cube variables.In general: if  is a cube and  is a tope in context  :  , written as a judgment  :  ⊢  tope, then Φ :≡ { :  |  } is the shape corresponding to .This way, one can define important shapes such as the -simplex Δ  , for  ∈ N, its boundaries Δ  , the (, )-horns Λ   for  ≤ , and more.E.g., we have the following formulas, cf. also Figure 1: 00 10 00 10 00 10 Figure 1.Some important shapes.
Like in cubical type theory, we connect the standard type layer with the cube and tope layer through a three-part context, which allows type families  to depend on a cube context Ξ, a tope context Φ, and a type context Γ, written as The directed arrows in a type are now defined using our interval shape Δ 1 and another feature to be introduced, the extension types.In case  is a constant type, the ensuing extension type will be written as Ψ →  Φ  .In analogy to ordinary type-to-type function types, we can emulate shape-to-type function types by instantiating extension types by the "empty tope"  :≡ ⊥ and the canonical term rec ⊥ , allowing us to define the functions of shape Ψ into type  as Ψ →  :≡ Ψ →  ⊥ rec ⊥ , and similarly for the dependent case.
Extension Extensionality (ExtExt).Just as in [103, §4], to make the extension types homotopically well-behaved, we also assume a version of function extensionality for extension types.In Rzk, we postulate an axiom that allows us to extend relative homotopies between extensions of a given partial section.
Namely, let  be a cube and Φ ⊆ Ψ ⊆  be a shape inclusion.Consider a type family  : Ψ → U with a partial section  :  :Φ ().As in the case of dependent functions, we may use path induction to define a map for any  ,  : :Ψ () Φ  of the form exthtpyeq ,, , : ( = ) →  :Ψ  () = () Φ refl .(ext-htpy-eq) As we did for function extensionality, we assert an extension extensionality axiom of the following form.
Axiom 2.1 (ExtExt).For any , ,  , and  as above, the map (ext-htpy-eq) is an equivalence, i.e., there exists a term extext : ,, , isEquiv(exthtpyeq ,, , ) In the original paper, Axiom 2.1 is derived from another version of the extension extensionality axiom [103,Axiom 4.6].This version is analogous to the version of function extensionality that states that, given a family  :  → U, then if every fiber  is contractible, then so is the type : .In the case of ordinary dependent function types, weak function extensionality is known to be equivalent to the version of function extensionality (FunExt).However, at the time of the writing of the paper [103], it was not known whether this equivalence also held for extension types.Therefore, Riehl-Shulman assumed the version appearing as [103, Axiom 4.6] and proved that the other desired versions, such as (ExtExt), can be derived from it.
The axiom [103, Axiom 4.6] is called relative function extensionality (or extension extensionality), and it reads as follows.Let Φ ⊆ Ψ ⊆  be a shape inclusion and let  : Ψ → U be a family such that each () is contractible.Then, given  :  :Φ (), the type  :Ψ () Φ  is contractible.Our version (ExtExt) then follows as one of the consequences established in [103,Proposition 4.8].
More recently, in the process of formalizing synthetic ∞category theory, Tashi Walde figured out that the standard proof that function extensionality implies weak function extensionality can be adapted to show that extension extensionality implies weak extension extensionality, and thus these axioms are logically equivalent. 9  3 Synthetic ∞-Categories Simplicial type theory is a combination of the homotopical interpretation of Martin-Löf type theory with strict shapes and extension types.As demonstrated in [14,28,103,138], this framework is powerful enough to develop ∞-category theory synthetically, within a genuinely homotopical framework.
A category is a structure consisting of points and arrows that can be composed.To yield a synthetic notion of ∞category we want to implement this idea in homotopy type theory, using the simplicial shapes.

Pre-∞-Categories and ∞-Categories
Hom Types (hom).First, we need to obtain a notion of (directed) arrow in a type , which we define to be a map  : Δ 1 →  out of the 1-simplex.The source and target of the arrow  are given by the terms  (0),  (1) :  respectively.
Using extension types, we can define the type of arrows with fixed source and target.For a type  with elements ,  : , the type of arrows or homomorphisms from  to  is the extension type where  : Δ 1 ⊢ [, ] () :  is the term with [, ] (0) ≡  and [, ] (1) ≡ .
Pre-∞-Categories (05-segal-types).Any type has arbitrarily complicated simplicial structure.After all, we can probe any type by an -simplex for an arbitrarily high dimension .
When is composition of arrows, i.e., 1-simplices defined?We want to state this as a homotopically meaningful condition: any pair of composable arrows should have a composite arrow, bounding a 2-simplex that witnesses that the new arrow is in fact the composite of the given pair.This is classically known as the Segal condition see Figure 3 and [50,112].In our system, we can express it using extension types and contractibility.A synthetic pre-∞-category is a type that admits unique composition of arrows up to contractibility.
Spelled out, this means there exists an arrow  •  : hom  (, ) acting as a composite of  and  , together with a 2-cell comp , , : hom 2  ( , ;  •  ) that witnesses that the 2-simplex bounded by  , , and  •  , is filled, cf. Figure 2.Moreover, the pair of data  •  and comp , , is determined uniquely up to homotopy.
One can show that that the Segal condition of Definition 3.1 can be re-expressed by saying that the type  is local with respect to an inner horn inclusion.
∞-Categories (10-rezk-types).Synthetic pre-∞-categories, cf.Definition 3.1, have two competing notions of sameness between terms, defined by the identity types and by the types of isomorphisms.A pre-∞-category is an ∞-category if the notion of isomorphism just defined coincides with the notion of path in a type.This requirement captures the established notions of Rezk completeness or local univalence [2,99].
Naturality for Free.A useful feature of the synthetic theory is that various functoriality and naturality properties are automatically satisfied.This saves a lot of work compared to set-theoretic foundations.For instance, given pre-∞-categories  and  any type-theoretic function  :  →  turns out to be a functor, i.e., preserves compositions and identity, up to propositional equality, see (functors-pres-id) and (functors-pres-comp). 11 In particular, we do not have to specify object and morphism part separately.'Similarly, given functors  ,  :  → , natural transformations may be defined, using the extension types, to be arrows in the type  → , i.e.,  : hom → ( , ) (nat-trans).This definition automatically yields the expected naturality squares without having to specify them, [103,Proposition 6.6].
Further instances of automatic naturality appear in §3.2 and §5.

Covariant Families of ∞-Groupoids
∞-Groupoids (07-discrete).We are also interested in synthetic ∞-groupoids, meaning ∞-categories where every arrow is invertible. 12E.g., one can show that for any pre-∞-category , the hom types hom  (, ) are necessarily ∞-groupoids.This matches up with the traditional theory and the intuition that ∞-categories are (weakly enriched) in spaces as modeled by ∞-groupoids [94].
The groupoidal condition can be understood as a kind of discreteness condition.To make it precise, we need a comparison of paths with arrows, similarly to our treatment of Rezk 10 More generally, this yields Rezk objects internal to a given ∞-topos by [103,115,138], hence internal ∞-categories [34,79,96,118]. 11Semantically, this can be seen as the fact that any morphism between simplicial objects automatically preserves composition if they happen to be pre-∞-categories. 12As shown in [103, §7], one can drop the assumption of being an ∞-category as it will be implied.This definition also yields the desired notion in the Segal object models [23,117].
To define it, we have to introduce a dependent version of the hom type, capturing arrows in the total type :  () that get mapped to a prescribed arrow in the base.This can, once again, conveniently be formulated using extension types.Definition 3.5 (dependent hom; dhom).Let  :  → U be a type family.For elements ,  : , let  : hom  (, ) be an arrow.For elements in the fibers  :  () and  :  (), the corresponding dependent hom type from  to  is given by the extension type The defining property for a covariant family  :  → U says that we can lift an arrow  : hom  (, ) in the base, given a point  :  () in the fiber over its source, to a dependent arrow lift , , : dhom dhom  ( ) (, ) As shown in [103, §8], it turns out that, over a pre-∞category , covariant families  :  → U behave in the expected ways.Namely, the fibers are all ∞-groupoids [103, Proposition 8.18], and they are functorial in the following sense: for elements , ,  : , morphisms  : hom  (, ),  : hom  (, ), and an element in the fiber  :  (), we get identifications (id-arr-covariant-transport) see [103,Proposition 8.16].

An Overview of the Rzk Proof Assistant
Kudasov has implemented Rzk [64], the first proof assistant to support simplicial type theory.In our work since the spring of 2023, we have been developing a library 13 for Rzk, formalizing a range of results from Riehl-Shulman's work [103], and in addition to that also the required results from standard homotopy type theory [107,127].The formalizations in this paper have been written for and checked with Rzk version 0.7.2.
Syntax of the formalized code in Rzk is very close to the underlying theory, allowing for easy correspondence between statements in the code and on paper.However, proofs in Rzk may appear too detailed sometimes, since, being experimental, Rzk has not yet evolved enough syntactic sugar or tools like implicit parameters, tactics, or type classes to simplify proof construction.
In this section, we overview the key features of Rzk that we have relied on in our formalization.Details about Rzk design and implementation are out of the scope of this paper and should appear later in a separate paper.Still, we should mention that the underlying implementation is a mix of general ideas behind implementations of dependent types in Haskell [70] with an experimental representation of abstract syntax with binders [65], and an intuitionistic sequent-based solver for the tope layer [66].

Key Features of Rzk
The kernel of Rzk provides the following primitive notions and capabilities.
The Universes.There are three fixed universes: CUBE of cubes, TOPE of topes, and U of types.In Rzk, U contains CUBE, TOPE, and itself, implying an unsound "type in type." 14We consider such simplification acceptable for the time being and hope that Rzk will evolve proper universes in the future.
Tope Logic.This includes both cubes and topes.Rzk has built-in unit cube 1 and directed interval cube 2 (with points * 1 : 1 and 0 2 : 2 and 1 2 : 2 correspondingly), standard topes [103, Figure 2], and the inequality tope s ≤ t required for simplicial type theory.When done on paper, proofs in the tope logic are usually omitted as trivial, and we find that in our formalization project, only fairly small problems have been required for coherence checks.In fact, the most complicated checks we have are involved in the formalization of the general result for currying for extension types ([103, §4.1]; curry-uncurry).Rzk offers full automation of the tope layer [66] which helps keep the Rzk syntax and proofs simpler and automatically locate coherence issues in proof terms.
Dependent Types.Rzk offers support for dependent functions (x : A) → B x, dependent pairs Σ (x : A), B x, and identity types x =_{A} y.While at the moment of writing there is no support for user-defined implicit arguments, identity types allow the indices to be implicit with terms x = y and refl instead of x =_{A} y and refl_{x : A}, resp.Absence of implicit arguments and full type inference in Rzk induces more explicit and verbose proof terms.
Extension Types.Rzk offers two separate concepts that result in support for extension types.First, Rzk allows dependent functions to have a cube or a shape (a cube restricted with a tope) argument.These correspond to extension types restricted to rec ⊥ at the empty tope ⊥.
Second, any type is allowed to have a "refinement, " specifying values for arbitrary tope constraints.For example, a type A [ ↦ → x,  ↦ → y] is a refinement of type A such that values of this type are computationally equal to x when  holds and to y when  holds.Of course, x and y must agree when ( ∧  ) holds.Refinements of a type are its subtypes, and A is considered equivalent to A [⊥ ↦ → recBOT].The subtyping is handled by Rzk, removing the need for explicit type coercions.
Combining functions depending on shapes with such refinements yields extension types.For instance, hom  (, ) :≡ Δ 1 →  Δ 1 [, ] (hom) is defined as follows: Sections and Variables.Rzk supports Coq-style sections, 15allowing for locally defined assumptions (variables) which are automatically added as parameters to definitions that use them.Importantly, Rzk features a mechanism for detecting implicitly used assumptions to avoid accidental circular reasoning in definitions.To ensure that such an implicit assumption is not accidental, Rzk has the uses syntax.For example, the Yoneda lemma (yoneda-lemma) itself is specified in a way that makes explicit the use of function extensionality (funext).#def yoneda-lemma uses (funext) We find this particularly useful for readability, highlighting the use of axioms or other assumptions (e.g. that a certain type is a pre-∞-category).

The ∞-Categorical Yoneda Lemma in Rzk
The Statement.In 1-category theory, the Yoneda lemma says the following.Given a category A and a copresheaf 16 on A, i.e., a functor  : A → Set, for any  ∈ ob(A) there is a bijection hom [A,Set] (hom A (, −), )  () mapping a natural transformation  to  (, id  ) ∈  (), naturally in both  and .
The Proof.An inverse map is constructed using the covariant transport of .Namely, we define In the 1-categorical Yoneda lemma, a crucial part of the work is to show that the terms yon ,, () defined by the inverse map are actually morphisms of presheaves, i.e., natural transformations.In our setting, this is, in fact, an automatic consequence from both  and hom  (, −) :  → U being covariant.In the formalization considerable work goes into showing a type  is a pre-∞-category if and only if the type families hom  (, −) are covariant; for the implication relevant here, see (is-covariant-representable-is-pre-∞-category).
For the Yoneda lemma, one has to show that the two composites of evid ,, and yon ,, yield identities.The direction evid ,, • yon ,, = id is rather easy to see.Using function extensionality, we can check this pointwise.For  :  () we have to produce an identification ( ..* ) (, id  ) = .
But the left-hand side evaluates to ( ..* ) (, id  ) = (id  ) * (), and the claim follows by concatenating with the path (id  ) * () = id  () () given by the fact covariant transport of identities gives the identity functor of the fiber.
We now have to abstract over evaluating at  and  using function extensionality twice, which ultimately yields the desired identification (yon ,, • evid ,, ) () = , between fibered maps of type : hom  (, ) →  ().This concludes the proof of the Yoneda lemma.
The Dependent Yoneda Lemma.The Yoneda lemma of Theorem 5.1 is some sort of "arrow-induction" principle, but is not expressed in fully dependent form.This inspired the authors of [103] to search for a dependent generalization, proving a theorem that had not been previously known for ∞-categories. 18rom the dependent Yoneda lemma, the "absolute" version (yoneda-lemma) can be derived.is an equivalence.
Note that Theorem 5.3 is reminiscent of the path induction principle, cf.§ 2.1, and hence it can be seen as a directed arrow induction principle.

Comparing the ∞vs 1-Categorical Yoneda Lemmas
A fundamental advantage of the synthetic framework for ∞-category is that it narrows the gap between ∞-category theory and 1-category theory, by moving much of the complexity inherent in homotopy coherent mathematics into the background foundation system.We can see this by comparing the formalization of the Yoneda lemma for ∞-categories in Rzk with the formalization of the Yoneda lemma for 1categories in other proof assistants.Below we compare our work against 1-categorical Yoneda lemma formalizations in agda-unimath and Lean (3 and 4).Other notable formalizations of the 1-categorical Yoneda lemma appear in UniMath19 [133], agda-categories20 [56], 1Lab 21 , Archive of Formal Proofs in Isabelle/HOL [38,49,61], and mathlib 22 .All of these proof assistants implement some sort of dependent type theory under the hood, but the vernacular employed by the libraries agda-categories, mathlib, and the Archive of Formal Proofs is meant to reflect traditional foundations, where all types are sets, while the vernacular employed by the libraries agda-unimath, UniMath, and 1Lab is meant to reflect univalent foundations, using Voevodsky's univalence axiom to convert equivalences between types to identities.The latter perspective is inconsistent the uniqueness of identity proofs, so can only be implemented in proof assistants that support intensional identity types compatible with the univalence axiom.To capture both perspectives, the formalization discussed in §6.1 is in univalent foundations, while the formalizations discussed in §6.2 are in traditional set-based foundations.

1-Categorical Yoneda Lemma in agda-unimath
As part of this project, we contributed a formalization of the Yoneda lemma for precategories to the agda-unimath library, 23 which describes itself as a "community-driven effort aimed at formalizing mathematics from a univalent point of view." This library contains notions of precategories and categories, which parallel our pre-∞-categories and ∞categories, except their hom-types are sets, as is appropriate to 1-category theory.Both proofs follow the same outline, proving that (evid) is an equivalence by constructing a twosided inverse.A point of difference in the agda-unimath proof is that the data of the inverse involves both the function (yon) together with a proof of its naturality.As with our proof in Rzk, one of the composites is directly identifiable with the identity, while the other requires a calculation together with two instances of function extensionality.
Other differences arise from the varying ways that categorical data is encoded in Rzk vs agda-unimath.There, precategories are types with additional structure while here pre-∞-categories are types satisfying a property.There, representables are encoded as functors valued in the precategory of sets, while here representables are encoded as covariant type families.These differences have more of an effect on the syntax of the proof than its structural content.

1-Categorical Yoneda Lemma in Lean
At our request, Sina Hazratpour wrote a Lean formalization of the 1-categorical Yoneda lemma, first as a self-contained formalization in Lean 3, 24 with the proof of the Yoneda lemma later updated to Lean 4. 25 Formal proofs in Lean are quite different than formal proofs in Rzk or in Agda because of the use of automation tactics in the interactive theorem proving mode, allowing the user to rewrite along known identifications or "simplify" the goal using known lemmas.In addition, Lean's use of type classes and automatic instance inference simplifies the syntax in the statement of the Yoneda lemma, as compared with the agda-unimath proof.
In the Lean 3 proof, the naturality of (yon) must again be checked explicitly via a proof that involves unfolding the definition of the representable functor and using the fact that functors preserve composition.The remainder of the proof proceeds as before.Interestingly, in the Lean 4 proof, Hazratpour proves a lemma -(5.2) in the case where  is id  -and then feeds it to the tactic aesop_cat, 26 which then automatically verifies the naturality of (yon) and checks that the Yoneda maps are inverses.

Conclusions and Future Work
We hope that the Rzk proof assistant will provide a tool that may make ∞-category theory easier to learn.To that end we invite new collaborators to help us formalize other results from ∞-category theory.Indeed, some of this work is already underway in a new repository, 27 which originated as a clone of our Yoneda repository, as we now describe.

Adjunctions
One application of the dependent Yoneda lemma is to the theory of adjunctions between ∞-categories.The standard logically equivalent definitions of an adjunction are encoded by various types that define a transposing adjunction, halfadjoint diagrammatic adjunction, or a bidiagrammatic adjunction.These definitions have been formalized 28 and we have begun the lengthy task of formally proving the equivalences established in [103, §11].

Limits and Colimits
In [14], Bardomiano Martínez introduces limits and colimits of diagrams valued in pre-∞-categories and proves that right adjoints between Segal types preserve limits.Bardomiano Martínez has formalized these definitions 29 and plans to work with us to formalize his results.Once this is done, we would like to explore further developments of the theory of limits and colimits.
The cocartesian Yoneda lemma then states that the evaluation map Efforts in the direction of formalizing Buchholtz-Weinberger's proof of the cocartesian Yoneda lemma from [28, §7] in Rzk are under way, but will require formalizing if not all then at least some of the preliminary structural properties and operations for cocartesian families from [28, §5].

Improvements to Rzk
We note a few improvements for Rzk that would positively affect this and future formalization projects.First, supporting term inference and implicit arguments would help reduce the size of formalizations and, consequently, assist with readability.Second, the current implementation lacks incremental typechecking and proper module support, which makes the feedback on changes less immediate.Finally, while a minimal integration with an IDE exists, 30 it still has to acquire proper language server support.We note also that Rzk's experimental diagram rendering feature 31 (which is useful on small examples) could be extended further to assist with visualizations (or even interactive capabilities) for statements and constructions in simplicial type theory.

Extensions of Simplicial Type Theory
The simplicial type theory is not sufficiently powerful to prove all results of ∞-category theory contained for instance in [73].A longer range goal would be to further extend this synthetic framework by including directed higher inductive types to freely generate ∞-categories, universes to classify covariant fibrations and cocartesian fibrations, and modalities for opposite ∞-categories and the ∞-groupoid core as outlined in [27]; see also [1,47,68,69,85,90,114].If such theoretical developments were paired with experimental extensions to Rzk, that would greatly aid the process of exploring the expanded formal system.